$level seems to be unused //19-11-2004 Fernando Batista -> Copy article, Copy strutures :http://fernandobatista.web.pt //31-03-2005 Fernando Batista -> copy&cut Article Content :http://fernandobatista.web.pt function struct_list ($id, $dbcon, $copy_article_content, $cut_article_content, $copy_id, $copy_article, $cut_id, $cut_article, $listmode=1, $forbid_cut=0, $forbid_copy=0, $counter=0) { $counter++; $sql = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecat WHERE acat_trash=0 AND acat_struct=".intval($id)." ORDER BY acat_sort"; if($result = mysql_query($sql, $dbcon) or die("error while browsing structure".$sql)) { $count_row = 0; while($row = mysql_fetch_assoc($result)) { $struct[$count_row] = $row; $count_row++; } mysql_free_result($result); if(isset($struct[0])) { foreach($struct as $key => $value) { struct_levellist($struct, $key, $counter, $copy_article_content, $cut_article_content, $copy_id, $copy_article, $cut_id, $forbid_cut, $forbid_copy, $listmode, $cut_article, $count_row, $dbcon); } } } } function struct_levellist($struct, $key, $counter, $copy_article_content, $cut_article_content, $copy_id, $copy_article, $cut_id, $forbid_cut, $forbid_copy, $listmode, $cut_article, $count_row, $dbcon) { global $BL; $page_val = ($listmode) ? "do=admin&p=6" : "do=articles"; $child_count = get_root_childcount($struct[$key]["acat_id"], $dbcon); $child_sort = (($child_count+1)*10); $forbid_cut = ($struct[$key]["acat_struct"] == $cut_id || $forbid_cut) ? 1 : 0; $forbid_copy = ($struct[$key]["acat_struct"] == $copy_id || $forbid_copy) ? 1 : 0; $an = html_specialchars($struct[$key]["acat_name"]); $a = "\n"; $a .= ""; $a .= "\n\n"; $a .= '\n"; $a .= "\n"; $a .= "\n\n
\"\""; //14 $a .= ($child_count) ? "" : ""; $a .= "\"\"".(($child_count) ? "" : ""); $a .= "
'; $info .= 'ALIAS: '.html_specialchars($struct[$key]["acat_alias"]).'
'; $info .= $BL['be_cnt_sortvalue'].': '.$struct[$key]["acat_sort"]; $a .= 'onmouseover="Tip(\''.$info.'\');" onmouseout="UnTip()" alt=""'; $a .= ">
\"\"".$an."
\n"; $a .= listmode_edits ($listmode, $struct, $key, $an, $copy_article_content, $cut_article_content, $copy_article, $copy_id, $cut_article, $cut_id, $forbid_cut, $forbid_copy, $count_row, $child_sort); $a .= "\n\n"; echo $a; if(isset($_SESSION["structure"][$struct[$key]["acat_id"]]) && $_SESSION["structure"][$struct[$key]["acat_id"]]) { if(!$listmode) { struct_articlelist ($struct[$key]["acat_id"], $counter, $copy_article_content, $cut_article_content, $copy_article, $cut_article, $struct[$key]["acat_order"]); } struct_list ($struct[$key]["acat_id"], $dbcon, $copy_article_content, $cut_article_content, $copy_id, $copy_article, $cut_id, $cut_article, $listmode, $forbid_cut, $forbid_copy, $counter); } } function get_root_childcount($id, $dbcon) { //Ermittelt Anzahl bereits vorhandener aktiver Unterlevels $p1_count = $p2_count = 0; $id = intval($id); if($p_result = mysql_query("SELECT COUNT(*) FROM ".DB_PREPEND."phpwcms_articlecat WHERE acat_trash=0 AND acat_struct=".$id, $dbcon)) { if($p_row = mysql_fetch_row($p_result)) $p1_count = $p_row[0]; mysql_free_result($p_result); } if($p_result = mysql_query("SELECT COUNT(*) FROM ".DB_PREPEND."phpwcms_article WHERE article_deleted=0 AND article_cid=".$id, $dbcon)) { if($p_row = mysql_fetch_row($p_result)) $p2_count = $p_row[0]; mysql_free_result($p_result); } return $p1_count + $p2_count; } function get_article_content_count($id, $dbcon) { $p_count = 0; $id = intval($id); if($p_result = mysql_query("SELECT COUNT(*) FROM ".DB_PREPEND."phpwcms_articlecontent WHERE acontent_trash=0 AND acontent_aid=".$id, $dbcon)) { if($p_row = mysql_fetch_row($p_result)) $p_count = $p_row[0]; mysql_free_result($p_result); } return $p_count; } function struct_articlelist ($struct_id, $counter, $copy_article_content, $cut_article_content, $copy_article, $cut_article, $article_order=0) { global $BL; $article = array(); // empty article array $sort_array = array(); // empty array to store all sort values for the category $article_order = intval($article_order); $max_article_count = 0; $show_sort = (!$article_order || $article_order == 1) ? 1 : 0; $ao = get_order_sort($article_order); $count_article = 0; $sbutton_string = array(); $sql = "SELECT *, "; $sql .= "DATE_FORMAT(article_tstamp, '%Y-%m-%d %H:%i:%s') AS article_date "; //, article_deleted $sql .= "FROM ".DB_PREPEND."phpwcms_article "; $sql .= "WHERE article_cid='".$struct_id."' AND article_deleted=0 ORDER BY ".$ao[2]; if($result = mysql_query($sql, $GLOBALS['db']) or die ("error while browsing related articles")) { // 1st get max count to know the last index ($max_article_count - 1) $max_article_count = mysql_num_rows($result); // take all entryies and build new array with it while($row = mysql_fetch_assoc($result)) { $article[$count_article] = $row; if($row['article_sort'] > 0) { $sort_array[$count_article] = $row['article_sort']; } // count up for article array index $count_article++; } mysql_free_result($result); } // now check if all sort values are unique // if not do a re-sort for all articles if($max_article_count > count(array_unique($sort_array)) ) { $article = getArticleReSorted($struct_id, $article_order); } // reset article counter $count_article = 0; /* * now we know ALL articles and can run array index +/- * to set correct sorting UP and DOWN based on article * listing -> so the correct sort value is used */ foreach($article as $akey => $avalue) { // set up correct article sorting // can be sorted UP if($count_article == 0) { // this is the first in list -> so no sorting up possible // the sort up icon will be invisible $sort_up = false; } else { // this article has a pre entry // so use these by setting (current index - 1) $article[$akey]['sort_up'] = $article[$akey-1]['article_sort']; $sort_up = $show_sort ? true : false; } // count up for article array index $count_article++; // can be sorted DOWN if($count_article == $max_article_count) { // this is the last in list -> so no sorting down possible // the sort up icon will be invisible $sort_down = false; } else { // this article has a follower // so use these by setting (current index + 1) $article[$akey]['sort_down'] = $article[$akey+1]['article_sort']; $sort_down = $show_sort ? true : false; } // now do some checks to be sure that all sort values // are different to have it sorting in the correct way // sort up if($sort_up) { $sort_up = ''; $sort_up .= ''; } else { $sort_up = ''; } // sort down if($sort_down) { $sort_down = ''; $sort_down .= ''; } else { $sort_down = ''; } $at = html_specialchars($article[$akey]["article_title"]); if($cut_article == $article[$akey]["article_id"] ) { $a = "\n"; } elseif($copy_article == $article[$akey]["article_id"]){ $a = "\n"; } else { $a = "\n"; } $a .= ""; $a .= "\n\n"; $acontent_count = get_article_content_count($article[$akey]["article_id"], $GLOBALS['db']); if($article[$akey]["article_uid"] == $_SESSION["wcs_user_id"] || $_SESSION["wcs_user_admin"]) { $a .= "'; if(!empty($article[$akey]["article_alias"])) { $info .= ''; } if(!empty($article[$akey]["article_begin"])) { $info .= ''; } if(!empty($article[$akey]["article_end"])) { $info .= ''; } $info .= ''; if(isset($article[$akey]["article_end"])) { $info .= ''; } $info .= '
\"\""; $a .= ($acontent_count) ? "" : ""; $a .= "\"\"".(($acontent_count) ? "" : ""); }else{ $a .= "\"\""; } $a .= "'.$article[$akey]["article_id"].'
ALIAS:'.$article[$akey]["article_alias"].'
'.$BL['be_article_cnt_start'].':'.date($BL['be_longdatetime'], strtotime($article[$akey]["article_begin"])).'
'.$BL['be_article_cnt_end'].':'.date($BL['be_longdatetime'], strtotime($article[$akey]["article_end"])).'
'.$BL['be_cnt_sortvalue'].':'.$article[$akey]["article_sort"].'
'.$BL['be_priorize'].':'.$article[$akey]["article_priorize"].'
'; $a .= 'onmouseover="Tip(\''. $info .'\');" onmouseout="UnTip()" alt=""'; //$a .= getAltTitle($info); $a .= " />\n"; $a .= "\"\"\n"; $a .= ""; $a .= $at."\n\n\n"; if($article[$akey]["article_uid"] == $_SESSION["wcs_user_id"] || $_SESSION["wcs_user_admin"]) { $a .= ""; $a .= "\"\""; } else { $a .= "\"\""; } if($cut_article != $article[$akey]["article_id"] && !$cut_article_content) { $a .= ""; $a .= "\"\""; } elseif($cut_article_content) { $a .= '\"\""; } else { $a .= "'; $a .= "\"\""; } if($copy_article != $article[$akey]["article_id"] && !$copy_article_content) { $a .= ""; $a .= "\"\""; } elseif($copy_article_content) { $a .= '\"\""; } else { $a .= "'; $a .= "\"\""; } //Sortierungslink //davor sortieren $a .= $sort_up; //dahinter sortieren $a .= $sort_down; //active und visible Status wechseln $a .= "'; $a .= "\"\""; $a .= "'; $a .= "\"\""; //Article Löschen if($article[$akey]["article_uid"] == $_SESSION["wcs_user_id"] || $_SESSION["wcs_user_admin"]) { $a .= ""; $a .= "\"\""; } else { $a .= "\"\""; } $a .= "\n\n"; echo $a; $sql = "SELECT acontent_id, acontent_sorting, acontent_trash, acontent_block FROM ".DB_PREPEND."phpwcms_articlecontent "; $sql .= "WHERE acontent_aid=".$article[$akey]["article_id"]." ORDER BY acontent_block, acontent_sorting, acontent_id"; if($result = mysql_query($sql, $GLOBALS['db']) or die("error while listing contents for this article")) { $sc = 0; $scc = 0; //Sort-Zwischenzähler while($row = mysql_fetch_row($result)) { $scc++; if($row[2] == 0) { $sc++; $sbutton[$sc]["id"] = $row[0]; $sbutton[$sc]["sort"] = $row[1]; $sbutton[$sc]["block"] = $row[3]; } } } if($sc) { //Jetzt aufbauen der Sortieranweisung foreach($sbutton as $key => $value) { if($key == 1) { // if 1st content part in list $sbutton[$key]["top"] = "\"\""; } elseif(isset($sbutton[$key-1]["block"]) && $sbutton[$key-1]["block"] != $sbutton[$key]["block"]) { // if this content part is selected for different block than previous $sbutton[$key]["top"] = "\"\""; } else { $sbutton[$key]["top"] = "\"\""; } if($key == $sc) { // if this is the last content part in list $sbutton[$key]["bottom"] = "\"\""; } elseif(isset($sbutton[$key+1]["block"]) && $sbutton[$key+1]["block"] != $sbutton[$key]["block"]) { // if this is the last content part in current block and next is different $sbutton[$key]["bottom"] = "\"\""; } else { $sbutton[$key]["bottom"] = "\"\""; } $sbutton_string[$sbutton[$key]["id"]] = $sbutton[$key]["top"]. $sbutton[$key]["bottom"]; } unset($sbutton); } if($article[$akey]["article_uid"] == $_SESSION["wcs_user_id"] || $_SESSION["wcs_user_admin"]) { if(isset($_SESSION["structure"]["article"][$article[$akey]["article_id"]]) && $_SESSION["structure"]["article"][$article[$akey]["article_id"]]) { struct_articlecontentlist ($article, $akey, $copy_article_content, $cut_article_content, $counter, $sbutton_string, $GLOBALS['db']); } } } } function struct_articlecontentlist(& $article, $akey, $copy_article_content, $cut_article_content, $counter, $sbutton_string, $db){ $a = ''; $sql = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecontent "; $sql .= "WHERE acontent_aid=".$article[$akey]["article_id"]." AND acontent_trash=0 "; $sql .= "ORDER BY acontent_block, acontent_sorting, acontent_id"; if($result = mysql_query($sql, $db) or die("error while listing contents for this article")) { while($article_content = mysql_fetch_assoc($result)) { // if type of content part not enabled available if(!isset($GLOBALS['wcs_content_type'][ $article_content["acontent_type"] ]) || ($article_content['acontent_type'] == 30 && !isset($GLOBALS['phpwcms']['modules'][$article_content["acontent_module"]]))) { continue; } $info = "Tip('"; $info .= 'ID: '.$article_content["acontent_id"]; if($article_content['acontent_title']) { $info .= '
' . $GLOBALS['BL']['be_article_cnt_ctitle'].': '.html_specialchars(js_singlequote($article_content['acontent_title'])).''; } if($article_content['acontent_title']) { $info .= '
' . $GLOBALS['BL']['be_article_asubtitle'].': '.html_specialchars(js_singlequote($article_content['acontent_subtitle'])).''; } if($article_content["acontent_comment"]) { $info .= '
' . nl2br( html_specialchars(js_singlequote($article_content["acontent_comment"])) ); } $info .= "');"; if($cut_article_content == $article_content["acontent_id"] ) { $a .= "\n"; } elseif($copy_article_content == $article_content["acontent_id"]) { $a .= "\n"; } else { $a .= "\n"; } $gk = 14+14+29+(14*($counter-1)); $a .= "\"\""; //$counter-1 $a .= "\"\""; $a .= ""; $ab = '[ID:'.$article_content["acontent_id"].'] '; $ab .= $GLOBALS["wcs_content_type"][$article_content["acontent_type"]]; if($article_content["acontent_type"] == 30) { $ab .= ': '.$GLOBALS['BL']['modules'][$article_content["acontent_module"]]['listing_title']; } $a .= $ab; $a .= ""; $a .= "\"\""; $a .= "".html_specialchars(' {'.$article_content['acontent_block'].'} ').""; $a .= ''; //width="110" $at = ' '.$ab.' '; if($article[$akey]["article_uid"] == $_SESSION["wcs_user_id"] || $_SESSION["wcs_user_admin"]) { $a .= ""; $a .= "\"\""; } else { $a .= "\"\""; } if($cut_article_content) { if($cut_article_content != $article_content["acontent_id"]) { $a .= '\"\""; } else { $a .= "\"\""; } } else { if($article_content["acontent_id"]) { $a .= "\"\""; } else { $a .= ""; $a .= "\"\""; } } if($copy_article_content) { if($copy_article_content != $article_content["acontent_id"]) { $a .= '\"\""; } else { $a .= "\"\""; } } else { if($article_content["acontent_id"]) { $a .= "\"\""; } else { $a .= ""; $a .= "\"\""; } } $a .= $sbutton_string[$article_content["acontent_id"]]; $a .= "'; $a .= "\"\""; // added space between visible icon and delete icon $a .= ''; if($article_content["acontent_uid"] == $_SESSION["wcs_user_id"] || $_SESSION["wcs_user_admin"]) { $a .= ""; $a .= "\"\""; } else { $a .= "\"\""; } $a .= "\n"; } if($a) { $aa = "\n"; $aa .= "\n"; $aa .= $a; $aa .= "
"; echo $aa; } } } function listmode_edits ($listmode, $struct, $key, $an, $copy_article_content, $cut_article_content, $copy_article, $copy_id, $cut_article, $cut_id, $forbid_cut, $forbid_copy, $count_row, $child_sort) { // Decide which action available $a = ''; switch($listmode) { case 0: $a .= ""; $a .= "\"\""; if($cut_article) { // Cut $a .= '\"\""; } else { $a .= "\"\""; } if($copy_article) { $a .= '\"\""; } else { $a .= "\"\""; } $a .= "\"\""; $a .= "\"\""; $a .= "\"\""; $a .= "\"\""; break; case 1: $a .= "\"\""; if($cut_id) { if($cut_id != $struct[$key]["acat_id"] && !$forbid_cut) { $a .= '\"\""; } else { $a .= "\"\""; } } else { if($struct[$key]["acat_id"]) { $a .= "\"\""; } else { $a .= ""; $a .= "\"\""; } } if($copy_id) { if($copy_id != $struct[$key]["acat_id"] && !$forbid_copy) { $a .= '\"\""; } else { $a .= "\"\""; } } else { if($struct[$key]["acat_id"]) { $a .= "\"\""; } else { $a .= ""; $a .= "\"\""; } } $a .= "'; $a .= "\"\""; //Sortierungslink $sort_up = (($count_row>1 && $key)?1:0); $sort_down = (($count_row>1 && $key+1<$count_row)?1:0); //davor sortieren $a .= ($sort_up)? '':''; $a .= "\"\"".(($sort_up)?"":""); //dahinter sortieren $a .= ($sort_down)? '':''; $a .= "\"\"".(($sort_down)?"":""); $a .= "\"\""; $a .= "\"\""; if($struct[$key]["acat_id"]) { $a .= '"; $a .= "\"\""; } break; default: $a .= " "; } return $a; } ?>