|
26.03.2008, 11:07
Работоспособность не проверял, но должно все работать:
PHP код:
function list_pages_categories($cid, $nach) { global $prefix, $db, $sitename, $admin, $multilingual, $module_name, $description, $parentid, $module_title, $admin_file, $number, $show__all_docs, $subkatnumber, $show_signature, $show_date, $show_counter, $page_img, $cat_img, $subcat_img, $subcat_sub_img, $page_title; include("header.php"); if (! $nach): $nach=0; endif; title("$page_title"); OpenTable(); ####### Начало оптимизации ####### // $cid - id категории $cid = intval($cid); // Загоняем весь список категорий в два массива: $cid_array = array(); // Массив с ключами по "cid" $parent_array = array(); // Массив с ключами по "parentid" и значениями "cid" $sql = "SELECT cat.cid, cat.title, cat.description, cat.parentid, COUNT(page.pid) AS count_pages FROM ".$prefix."_rupages_categories AS cat LEFT JOIN ".$prefix."_rupages AS page ON(page.cid=cat.cid AND page.active='1') WHERE cat.active='1' GROUP BY cat.cid ORDER BY cat.title ASC"; $all_result = $db->sql_query($sql); while($all_row = $db->sql_fetchrow($all_result)){ $cid_array[$all_row['cid']] = $all_row; $parent_array[$all_row['parentid']][] = $all_row['cid']; } //$rtitle=getparentlink($parentid, $page_title); echo "<center><b>".$cid_array[$cid]['title']."</b><br>".$cid_array[$cid]['description']."<hr size=\"1\"></center>"; // Выводим из маллива подкатегории нашей категори, если такие есть if($parent_array[$cid] and is_array($parent_array[$cid])){ foreach($parent_array[$cid] as $sub_sid){ echo "<font class=\"option\">$cat_img <a href=\"modules.php?name=$module_name&pa=list_pages_categories&cid=$sub_sid\">".$cid_array[$sub_sid]['title']."</a>"; if ($cid_array[$sub_sid]['count_pages'] >0) { echo "(".$cid_array[$sub_sid]['count_pages'].")"; } echo "</font><br>".$cid_array[$sub_sid]['description']."<br>"; // Если есть подкатегории то выводим их if($parent_array[$sub_sid] and is_array($parent_array[$sub_sid])){ foreach ($parent_array[$sub_sid] as $sub2_cid){ // Проверяем есть ли у еэтой подкатегории подкатегория if (!empty($parent_array[$sub2_cid])) { echo "<font class=\"content\"> $subcat_img <a href=\"modules.php?name=$module_name&pa=list_pages_categories&cid=$sub2_cid\">".$cid_array[$sub2_cid]['title']."</a><br>"; } else { echo "<font class=\"content\"> $subcat_sub_img <a href=\"modules.php?name=$module_name&pa=list_pages_categories&cid=$sub2_cid\">".$cid_array[$sub2_cid]['title']."</a><br>"; } if ($cid_array[$sub2_cid]['count_pages'] >0) { echo "(".$cid_array[$sub2_cid]['count_pages'].")<br>"; } } } } echo "<br><hr size=\"1\">"; } ####### Конец оптимизации ####### $sql1 = "SELECT pid, title, subtitle, clanguage, page_header FROM ".$prefix."_rupages WHERE active='1' AND cid='$cid' ORDER BY title"; $result1=$db->sql_query($sql1); $kolvo=mysql_affected_rows(); $kon=$nach+$number; $sql = "SELECT pid, title, subtitle, clanguage, page_header, signature, counter, date FROM ".$prefix."_rupages WHERE active='1' AND cid='$cid' ORDER BY title LIMIT $nach , $kon"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $pid = $row[pid]; $title = $row[title]; $subtitle = $row[subtitle]; $clanguage = $row[clanguage]; $header = $row[page_header]; if ($multilingual == 1) { $the_lang = "<img src=\"images/language/flag-$clanguage.png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">"; } else { $the_lang = ""; } if ($subtitle != "") { $subtitle = "<br>$subtitle"; } else { $subtitle = ""; } if (is_admin($admin)) { echo "$page_img $the_lang <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid\"><b>$title</b></a>$subtitle<br>$header<br>"; if ($show_signature==1) echo "<font class='pagesdescr'>"._PAUTHOR.": ".$row[signature]."</font><br>"; if ($show_counter==1) echo "<font class='pagesdescr'>"._PCOUNTER.": <b>".$row[counter]."</b> </font>"; $dtp=explode(" ",$row[date]); $datepbl = $dtp[0]; if ($show_date==1) echo "<font class='pagesdescr'>"._PDATE.": ".$datepbl."</font>"; echo "<br>[ <a href=\"".$admin_file.".php?op=pages_edit&pid=$pid\">"._EDIT."</a> | <a href=\"".$admin_file.".php?op=pages_change_status&pid=$pid&active=1\">"._DEACTIVATE."</a> | <a href=\"".$admin_file.".php?op=pages_delete&pid=$pid\">"._DELETE."</a> ]"; echo "<br><br>"; } else { echo "$page_img $the_lang <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid\"><b>$title</b></a> $subtitle<br>$header<br>"; if ($show_signature==1) echo "<font class='pagesdescr'>"._PAUTHOR.": ".$row[signature]."</font><br>"; if ($show_counter==1) echo "<font class='pagesdescr'>"._PCOUNTER.": <b>".$row[counter]."</b> </font>"; $dtp=explode(" ",$row[date]); $datepbl = $dtp[0]; if ($show_date==1) echo "<font class='pagesdescr'>"._PDATE.": ".$datepbl."</font>"; echo "<br><br>"; } } $n=$kolvo/$number; if ($kolvo/$number){ $n++; } if ($n>=2) { $count=0; echo "<center><b>"._PAGEN."</b><br><br>|"; for ($i=1;$i<=$n;$i++){ echo " "; echo "<a href=\"modules.php?name=$module_name&pa=list_pages_categories&cid=$cid&nach=$count\">$i</a>"; echo " |"; $count=$count+$number; } } if ($show__all_docs==1) echo "</center><br>"._ALLDOCS." <b>$kolvo</b>"; if (is_admin($admin)) { $sql = "SELECT pid, title, subtitle, clanguage FROM ".$prefix."_rupages WHERE active='0' AND cid='$cid' ORDER BY date"; $result = $db->sql_query($sql); echo "<br><br><b>"._YOURADMINLIST."</b><br><br>"; echo "<blockquote>"; while ($row = $db->sql_fetchrow($result)) { $pid = $row[pid]; $title = $row[title]; $subtitle = $row[subtitle]; $clanguage = $row[clanguage]; if ($multilingual == 1) { $the_lang = "<img src=\"images/language/flag-$clanguage.png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">"; } else { $the_lang = ""; } if ($subtitle != "") { $subtitle = "<br>$subtitle"; } else { $subtitle = " "; } echo "<strong><big>·</big></strong> $the_lang <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid\"><b>$title</b></a>$subtitle<br>[ <a href=\"".$admin_file.".php?op=pages_edit&pid=$pid\">"._EDIT."</a> | <a href=\"".$admin_file.".php?op=pages_change_status&pid=$pid&active=0\">"._ACTIVATE."</a> | <a href=\"".$admin_file.".php?op=pages_delete&pid=$pid\">"._DELETE."</a> ]<br><br>"; } } echo "<center>[ <a href=\"java script:history.go(-1)\">"._PBACK."</a> | <a href=\"modules.php?name=$module_name\">"._PHOME."</a> ]</center>"; CloseTable(); include("footer.php"); }
|
|