$search->offset = (get_current_page() - 1) * $page_size; // pagesize set in the admin panel $search->pagesize = $page_size; // since this is index, we only want to view "published" stories $search->filterToStatus = "published"; // this is for the tabs on the top that filter if (isset($_GET['part'])) { $search->setmek = $db->escape($_GET['part']); } $search->do_setmek(); // do the search $search->doSearch(); $linksum_count = $search->countsql; $linksum_sql = $search->sql; if (isset($_REQUEST['category'])) { $category_data = get_cached_category_data('category_safe_name', sanitize($_REQUEST['category'], 1)); $main_smarty->assign('meta_description', $category_data->category_desc); $main_smarty->assign('meta_keywords', $category_data->category_keywords); // breadcrumbs and page title for the category we're looking at $main_smarty->assign('title', '' . $main_smarty->get_config_vars('PLIGG_Visual_Published_News') . ' - ' . $thecat . ''); $navwhere['text1'] = $main_smarty->get_config_vars('PLIGG_Visual_Published_News'); $navwhere['link1'] = getmyurl('root', ''); $navwhere['text2'] = $thecat; $main_smarty->assign('navbar_where', $navwhere); $main_smarty->assign('pretitle', $thecat); $main_smarty->assign('posttitle', $main_smarty->get_config_vars('PLIGG_Visual_Published_News')); $main_smarty->assign('page_header', $thecat . $main_smarty->get_config_vars('PLIGG_Visual_Published_News')); // pagename define('pagename', 'published'); $main_smarty->assign('pagename', pagename); } else {
function do_sidebar($var_smarty, $navwhere = '') { // show the categories in the sidebar global $db, $dblang, $globals, $the_cats; if ($navwhere == '') { global $navwhere; } // fix for 'undefined index' errors if (!isset($navwhere['text4'])) { $navwhere['text4'] = ''; } else { $navwhere['text4'] = htmlspecialchars($navwhere['text4']); } if (!isset($navwhere['text3'])) { $navwhere['text3'] = ''; } else { $navwhere['text3'] = htmlspecialchars($navwhere['text3']); } if (!isset($navwhere['text2'])) { $navwhere['text2'] = ''; } else { $navwhere['text2'] = htmlspecialchars($navwhere['text2']); } if (!isset($navwhere['text1'])) { $navwhere['text1'] = ''; } else { $navwhere['text1'] = htmlspecialchars($navwhere['text1']); } if (!isset($navwhere['link4'])) { $navwhere['link4'] = ''; } if (!isset($navwhere['link3'])) { $navwhere['link3'] = ''; } if (!isset($navwhere['link2'])) { $navwhere['link2'] = ''; } if (!isset($navwhere['link1'])) { $navwhere['link1'] = ''; } $var_smarty->assign('navbar_where', $navwhere); $var_smarty->assign('body_args', ''); // fix for 'undefined index' errors $_caching = $var_smarty->cache; // get the current cache settings $var_smarty->cache = true; // cache has to be on otherwise is_cached will always be false $var_smarty->cache_lifetime = -1; // lifetime has to be set to something otherwise is_cached will always be false $thetpl = $var_smarty->get_template_vars('the_template_sidebar_modules') . '/categories.tpl'; // check to see if the category sidebar module is already cached // if it is, use it if (isset($_GET['category'])) { $thecat = sanitize($_GET['category'], 3); } else { $thecat = ''; } if ($var_smarty->is_cached($thetpl, 'sidebar|category|' . $thecat)) { $var_smarty->assign('cat_array', 'x'); // this is needed. sidebar.tpl won't include the category module if cat_array doesnt have some data } else { if (isset($_GET['category'])) { $thecat = get_cached_category_data('category_safe_name', urlencode(sanitize($_GET['category'], 1))); $thecat = $thecat->category_name; } $var_smarty->assign('UrlMethod', urlmethod); foreach ($the_cats as $cat) { if ($cat->category_id == $thecat && $cat->category_lang == $dblang && $cat->category_parent == 0) { $globals['category_id'] = $cat->category_id; $globals['category_name'] = $cat->category_name; } } $pos = strrpos($_SERVER["SCRIPT_NAME"], "/"); $script_name = substr($_SERVER["SCRIPT_NAME"], $pos + 1, 100); $script_name = str_replace(".php", "", $script_name); include_once 'dbtree.php'; $login_user = $db->escape(sanitize($_COOKIE['mnm_user'], 3)); if ($login_user) { /////// for user set category----sorojit. $sqlGeticategory = $db->get_var("SELECT user_categories from " . table_users . " where user_login = '******';"); $array1 = "SELECT * from " . table_categories . " where category__auto_id in ({$sqlGeticategory})"; $result = mysql_query($array1); $array = array(); while ($row = mysql_fetch_array($result)) { //print_r($row); $row[] = $row; } $right = array(); $array1 = "SELECT * from " . table_categories . " where category__auto_id in ({$sqlGeticategory}) ORDER BY lft"; $result1 = mysql_query($array1); while ($row = mysql_fetch_object($result1)) { $a[] = $row; } $result = $a; $i = 0; $lastspacer = 0; // added @ thanks to `parterburn` - http://www.pligg.com/forum/showthread.php?t=4888 foreach ($result as $row) { if (count($right) > 0) { // check if we should remove a node from the stack while ($right[count($right) - 1] < $row->rgt) { if (array_pop($right) == NULL) { break; // We've reached the top of the category chain } } } $array[$i]['principlecat'] = $row->rgt - $row->lft - 1; $array[$i]['spacercount'] = count($right); $array[$i]['lastspacercount'] = $lastspacer; $array[$i]['spacerdiff'] = abs($lastspacer - count($right)); $array[$i]['auto_id'] = $row->category__auto_id; $array[$i]['name'] = $row->category_name; $array[$i]['safename'] = $row->category_safe_name; if (isset($row->category_color)) { $array[$i]['color'] = $row->category_color; } if (isset($row->category_parent)) { $array[$i]['parent'] = $row->category_parent; $array[$i]['parent_name'] = GetCatName($row->category_parent); $array[$i]['parent_subcat_count'] = GetSubCatCount($row->category_parent); } $array[$i]['subcat_count'] = GetSubCatCount($row->category__auto_id); $lastspacer = count($right); $i = $i + 1; $right[] = $row->rgt; } ///////end of for user set category $var_smarty->assign('start', 0); } else { $array = tree_to_array(0, table_categories); $var_smarty->assign('start', 1); } $var_smarty->assign('lastspacer', 0); $var_smarty->assign('cat_array', $array); // use the 'totals' table now $published_count = get_story_count('published'); $var_smarty->assign('published_count', $published_count); // $sql = "select *, count(*) as count from " . table_links . ", " . table_categories . " where category_lang='$dblang' and category_id=link_category group by link_category ORDER BY category_name ASC"; // $categorylist = object_2_array($db->get_results($sql)); // $var_smarty->assign('categorylist', $categorylist); $var_smarty->assign('category_url', getmyurl('maincategory')); } $var_smarty->cache = $_caching; // set cache back to original value $vars = ''; check_actions('do_sidebar', $vars); return $var_smarty; }
function tree_to_array($root, $table, $showRoot = TRUE) { // showRoot -- Do we want to include the "root" category named "all" in our results -- all subcats WILL appear regardless global $db; $row = get_cached_category_data('category__auto_id', $root); if (!$row) { $sqlfix = "UPDATE " . table_categories . " SET `category__auto_id` = '0' WHERE `category_name` = 'all' LIMIT 1;"; $db->query($sqlfix); $row = $db->get_row($sql); if (!$row) { die('There is a problem with the categories table. Error CA:001.'); } } $right = array(); $result = get_cached_between($row->lft, $row->rgt); $i = 0; $lastspacer = 0; // added @ thanks to `parterburn` - http://www.pligg.com/forum/showthread.php?t=4888 foreach ($result as $row) { if (count($right) > 0) { // check if we should remove a node from the stack while ($right[count($right) - 1] < $row->rgt) { if (array_pop($right) == NULL) { break; // We've reached the top of the category chain } } } $array[$i]['principlecat'] = $row->rgt - $row->lft - 1; $array[$i]['spacercount'] = count($right); $array[$i]['lastspacercount'] = $lastspacer; $array[$i]['spacerdiff'] = abs($lastspacer - count($right)); $array[$i]['id'] = $row->category_id; $array[$i]['auto_id'] = $row->category__auto_id; $array[$i]['name'] = $row->category_name; $array[$i]['safename'] = $row->category_safe_name; $array[$i]['order'] = $row->category_order; $array[$i]['left'] = $row->lft; $array[$i]['right'] = $row->rgt; $array[$i]['leftrightdiff'] = $row->rgt - $row->lft; $array[$i]['authorlevel'] = $row->category_author_level; // DB 11/12/08 $array[$i]['authorgroup'] = $row->category_author_group; ///// if (isset($row->category_color)) { $array[$i]['color'] = $row->category_color; } if (isset($row->category_parent)) { $array[$i]['parent'] = $row->category_parent; $array[$i]['parent_name'] = GetCatName($row->category_parent); $array[$i]['parent_subcat_count'] = GetSubCatCount($row->category_parent); } $array[$i]['subcat_count'] = GetSubCatCount($row->category__auto_id); $lastspacer = count($right); $right[] = $row->rgt; if ($array[$i]['leftrightdiff'] != 1) { for ($j = 0; $j <= $array[$i]['leftrightdiff']; $j++) { $array[$i]['subcatalign'] = 1; } } $i++; } if ($showRoot == FALSE) { array_splice($array, 0, 1); } return $array; }
function do_submit2() { global $db, $main_smarty, $dblang, $the_template, $linkres, $current_user, $Story_Content_Tags_To_Allow; $linkres = new Link(); $main_smarty->assign('auto_vote', auto_vote); $main_smarty->assign('Submit_Show_URL_Input', Submit_Show_URL_Input); $main_smarty->assign('Submit_Require_A_URL', Submit_Require_A_URL); $main_smarty->assign('link_id', sanitize($_POST['id'], 3)); define('pagename', 'submit'); $main_smarty->assign('pagename', pagename); $linkres->store(); $linkres->id = sanitize($_POST['id'], 3); $thecat = get_cached_category_data('category_id', $linkres->category); $main_smarty->assign('request_category_name', $thecat->category_name); tags_insert_string($_SESSION['newSid'], $dblang, $linkres->tags); $main_smarty->assign('tags', $linkres->tags); if (!empty($linkres->tags)) { $tags_words = str_replace(",", ", ", $linkres->tags); $tags_url = urlencode($linkres->tags); $main_smarty->assign('tags_words', $tags_words); $main_smarty->assign('tags_url', $tags_url); } $main_smarty->assign('submit_url_title', $linkres->url_title); $main_smarty->assign('submit_id', $linkres->id); $main_smarty->assign('submit_title', str_replace('"', """, $link_title)); $main_smarty->assign('submit_content', $link_content); include mnminclude . 'redirector.php'; $x = new redirector($_SERVER['REQUEST_URI']); $Sid = $_SESSION['newSid']; header("Location:/colfusion/story.php?title={$Sid}"); $vars = ''; check_actions('do_submit2', $vars); $_SESSION['step'] = 2; $main_smarty->display($the_template . '/pligg.tpl'); }
function show($fetch = false) { global $main_smarty, $db, $cached_links, $current_user; include_once mnminclude . 'search.php'; $search = new Search(); $search->orderBy = $this->orderBy; $search->pagesize = $this->pagesize; $search->filterToStatus = $this->filterToStatus; $search->filterToTimeFrame = $this->filterToTimeFrame; if ($this->category) { $thecat = get_cached_category_data('category_safe_name', $this->category); $search->category = $thecat->category_id; } $search->doSearch(); $linksum_sql = $search->sql; $link = new Link(); $links = $db->get_col($linksum_sql); $the_results = $links; if ($the_results) { // find out if the logged in user voted / reported each of // the stories that the search found and cache the results require_once mnminclude . 'votes.php'; // DB 03/02/09 // $vote = new Vote; // $vote->type='links'; // $vote->user=$current_user->user_id; // $vote->link=$the_results; // $results = $vote->user_list_all_votes(); ////// $vote = ''; $results = ''; // we don't actually need the results // we're just calling this to cache the results // so when we foreach the links we don't have to // run 1 extra query for each story to determine // current user votes // setup the link cache $i = 0; // if this query changes also change it in the read() function in /libs/link.php $sql = "SELECT " . table_links . ".* FROM " . table_links . " WHERE "; foreach ($the_results as $link_id) { // first make sure we don't already have it cached if (!isset($cached_links[$link_id])) { if ($i > 0) { $sql .= ' OR '; } $sql .= " link_id = {$link_id} "; $i = $i + 1; } } // if $i = 0 then all the links are already cached // so don't touch the db // if $i > 0 then there is at least 1 link to get // so get the SQL and add results to the cache if ($i > 0) { $results = $db->get_results($sql); // add the results to the cache foreach ($results as $row) { $cached_links[$row->link_id] = $row; } } // end link cache setup } $ssLinks = ''; if ($links) { foreach ($links as $link_id) { $link->id = $link_id; $link->check_saved = false; $link->get_author_info = false; $link->check_friends = false; $link->read(); if (is_numeric($this->TitleLengthLimit) && strlen($link->title) > $this->TitleLengthLimit) { $link->title = utf8_substr($link->title, 0, $this->TitleLengthLimit) . '...'; } $main_smarty = $link->fill_smarty($main_smarty); $ssLinks .= $main_smarty->fetch($this->template); } } if ($fetch == true) { return $ssLinks; } else { echo $ssLinks; } }
function do_submit1() { global $db, $main_smarty, $dblang, $the_template, $linkres, $current_user, $Story_Content_Tags_To_Allow; $linkres = new Link(); $main_smarty->assign('auto_vote', auto_vote); $main_smarty->assign('Submit_Show_URL_Input', Submit_Show_URL_Input); $main_smarty->assign('Submit_Require_A_URL', Submit_Require_A_URL); $main_smarty->assign('link_id', sanitize($_POST['id'], 3)); define('pagename', 'submit'); $main_smarty->assign('pagename', pagename); $linkres->store(); $linkres->id = sanitize($_POST['id'], 3); $thecat = get_cached_category_data('category_id', $linkres->category); $main_smarty->assign('request_category_name', $thecat->category_name); if (!isset($_POST['summarytext'])) { $linkres->link_summary = utf8_substr(sanitize($_POST['bodytext'], 4, $Story_Content_Tags_To_Allow), 0, StorySummary_ContentTruncate - 1); $linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary)); } else { $linkres->link_summary = sanitize($_POST['summarytext'], 4, $Story_Content_Tags_To_Allow); $linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary)); if (utf8_strlen($linkres->link_summary) > StorySummary_ContentTruncate) { loghack('SubmitAStory-SummaryGreaterThanLimit', 'username: '******'|email: ' . sanitize($_POST["email"], 3), true); $linkres->link_summary = utf8_substr($linkres->link_summary, 0, StorySummary_ContentTruncate - 1); $linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary)); } } $sid = $_POST["sid"]; tags_insert_string($sid, $dblang, $linkres->tags); //$main_smarty->assign('the_story', $linkres->print_summary('full', true)); $main_smarty->assign('tags', $linkres->tags); if (!empty($linkres->tags)) { $tags_words = str_replace(",", ", ", $linkres->tags); $tags_url = urlencode($linkres->tags); $main_smarty->assign('tags_words', $tags_words); $main_smarty->assign('tags_url', $tags_url); } $main_smarty->assign('submit_url_title', $linkres->url_title); $main_smarty->assign('submit_id', $linkres->id); $main_smarty->assign('submit_title', str_replace('"', """, $link_title)); $main_smarty->assign('submit_content', $link_content); include mnminclude . 'redirector.php'; $x = new redirector($_SERVER['REQUEST_URI']); //$Sid=$_SESSION['newSid']; header("Location:" . my_base_url . my_pligg_base . "/story.php?title={$sid}"); $vars = ''; check_actions('do_submit2', $vars); $_SESSION['step'] = 2; $main_smarty->display($the_template . '/pligg.tpl'); }
function do_submit2() { global $db, $main_smarty, $dblang, $the_template, $linkres, $current_user, $Story_Content_Tags_To_Allow; $main_smarty->assign('auto_vote', auto_vote); $main_smarty->assign('Submit_Show_URL_Input', Submit_Show_URL_Input); $main_smarty->assign('Submit_Require_A_URL', Submit_Require_A_URL); $main_smarty->assign('link_id', sanitize($_POST['id'], 3)); define('pagename', 'submit'); $main_smarty->assign('pagename', pagename); if ($current_user->authenticated != TRUE) { $vars = array('username' => $current_user->user_login); check_actions('register_check_errors', $vars); } check_actions('submit2_check_errors', $vars); if ($vars['error'] == true) { // No action } $linkres = new Link(); $linkres->id = sanitize($_POST['id'], 3); if ($_SESSION['step'] != 1) { die('Wrong step'); } if (!is_numeric($linkres->id)) { die; } if (!$linkres->verify_ownership($current_user->user_id)) { die($main_smarty->get_config_vars('PLIGG_Visual_Submit2Errors_NoAccess')); } $linkres->read(FALSE); if ($linkres->votes($current_user->user_id) == 0 && auto_vote == true) { $linkres->insert_vote($current_user->user_id, '10'); $linkres->store_basic(); $linkres->read(FALSE); } if (is_array($_POST['category'])) { $linkres->category = sanitize($_POST['category'][0], 3); $linkres->additional_cats = array_slice($_POST['category'], 1); } else { $linkres->category = sanitize($_POST['category'], 3); } $thecat = get_cached_category_data('category_id', $linkres->category); $main_smarty->assign('request_category_name', $thecat->category_name); $linkres->title = stripslashes(sanitize($_POST['title'], 3)); $linkres->title_url = makeUrlFriendly($linkres->title, $linkres->id); $linkres->tags = tags_normalize_string(stripslashes(sanitize($_POST['tags'], 3))); $linkres->content = close_tags(stripslashes(sanitize($_POST['bodytext'], 4, $Story_Content_Tags_To_Allow))); //$linkres->content = str_replace("\n", "<br />", $linkres->content); if (isset($_POST['link_field1'])) { $linkres->link_field1 = sanitize($_POST['link_field1'], 4, $Story_Content_Tags_To_Allow); } if (isset($_POST['link_field2'])) { $linkres->link_field2 = sanitize($_POST['link_field2'], 4, $Story_Content_Tags_To_Allow); } if (isset($_POST['link_field3'])) { $linkres->link_field3 = sanitize($_POST['link_field3'], 4, $Story_Content_Tags_To_Allow); } if (isset($_POST['link_field4'])) { $linkres->link_field4 = sanitize($_POST['link_field4'], 4, $Story_Content_Tags_To_Allow); } if (isset($_POST['link_field5'])) { $linkres->link_field5 = sanitize($_POST['link_field5'], 4, $Story_Content_Tags_To_Allow); } if (isset($_POST['link_field6'])) { $linkres->link_field6 = sanitize($_POST['link_field6'], 4, $Story_Content_Tags_To_Allow); } if (isset($_POST['link_field7'])) { $linkres->link_field7 = sanitize($_POST['link_field7'], 4, $Story_Content_Tags_To_Allow); } if (isset($_POST['link_field8'])) { $linkres->link_field8 = sanitize($_POST['link_field8'], 4, $Story_Content_Tags_To_Allow); } if (isset($_POST['link_field9'])) { $linkres->link_field9 = sanitize($_POST['link_field9'], 4, $Story_Content_Tags_To_Allow); } if (isset($_POST['link_field10'])) { $linkres->link_field10 = sanitize($_POST['link_field10'], 4, $Story_Content_Tags_To_Allow); } if (isset($_POST['link_field11'])) { $linkres->link_field11 = sanitize($_POST['link_field11'], 4, $Story_Content_Tags_To_Allow); } if (isset($_POST['link_field12'])) { $linkres->link_field12 = sanitize($_POST['link_field12'], 4, $Story_Content_Tags_To_Allow); } if (isset($_POST['link_field13'])) { $linkres->link_field13 = sanitize($_POST['link_field13'], 4, $Story_Content_Tags_To_Allow); } if (isset($_POST['link_field14'])) { $linkres->link_field14 = sanitize($_POST['link_field14'], 4, $Story_Content_Tags_To_Allow); } if (isset($_POST['link_field15'])) { $linkres->link_field15 = sanitize($_POST['link_field15'], 4, $Story_Content_Tags_To_Allow); } if (!isset($_POST['summarytext'])) { $linkres->link_summary = utf8_substr(sanitize($_POST['bodytext'], 4, $Story_Content_Tags_To_Allow), 0, StorySummary_ContentTruncate - 1); //$linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary)); } else { $linkres->link_summary = sanitize($_POST['summarytext'], 4, $Story_Content_Tags_To_Allow); //$linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary)); if (utf8_strlen($linkres->link_summary) > StorySummary_ContentTruncate) { loghack('SubmitAStory-SummaryGreaterThanLimit', 'username: '******'|email: ' . sanitize($_POST["email"], 3), true); $linkres->link_summary = utf8_substr($linkres->link_summary, 0, StorySummary_ContentTruncate - 1); //$linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary)); } } //get link_group_id if (isset($_REQUEST['link_group_id']) && $_REQUEST['link_group_id'] != '') { $linkres->link_group_id = intval($_REQUEST['link_group_id']); } else { $linkres->link_group_id = 0; } $linkres->store(); if (link_errors($linkres)) { return; } //comment subscription if (isset($_POST['comment_subscription'])) { $vars = array('link_id' => $linkres->id); check_actions('comment_subscription_insert_function', $vars); } //comment subscription if (isset($_POST['timestamp_date_day'])) { //open date $timestamp_date_day = $_POST['timestamp_date_day']; $timestamp_date_month = $_POST['timestamp_date_month']; $timestamp_date_year = $_POST['timestamp_date_year']; if (!is_numeric($timestamp_date_day) || !is_numeric($timestamp_date_month) || !is_numeric($timestamp_date_year)) { $timestamp_date = date("m-d-Y"); } else { $timestamp_date = $timestamp_date_month . "-" . $timestamp_date_day . "-" . $timestamp_date_year; } $vars = array('link_id' => $linkres->id); $vars = array('timestamp_date' => $timestamp_date, 'link_id' => $linkres->id); check_actions('comment_subscription_insert_function', $vars); } $vars = ''; check_actions('submit_step_3_after_first_store', $vars); if ($vars['error'] == true && link_catcha_errors('captcha_error')) { return; } $linkres->read(FALSE); $edit = true; $link_title = $linkres->title; $link_content = $linkres->content; $link_title = stripslashes(sanitize($_POST['title'], 3)); $main_smarty->assign('the_story', $linkres->print_summary('full', true)); $main_smarty->assign('tags', $linkres->tags); if (!empty($linkres->tags)) { $tags_words = str_replace(",", ", ", $linkres->tags); $tags_url = urlencode($linkres->tags); $main_smarty->assign('tags_words', $tags_words); $main_smarty->assign('tags_url', $tags_url); } if (isset($url)) { $main_smarty->assign('submit_url', $url); } else { $main_smarty->assign('submit_url', ''); } $data = parse_url($linkres->url); $main_smarty->assign('url_short', $data['host']); $main_smarty->assign('submit_url_title', $linkres->url_title); $main_smarty->assign('submit_id', $linkres->id); $main_smarty->assign('submit_type', $linkres->type()); $main_smarty->assign('submit_title', str_replace('"', """, $link_title)); $main_smarty->assign('submit_content', $link_content); if (isset($trackback)) { $main_smarty->assign('submit_trackback', $trackback); } else { $main_smarty->assign('submit_trackback', ''); } $main_smarty->assign('tpl_extra_fields', $the_template . '/submit_extra_fields'); $main_smarty->assign('tpl_center', $the_template . '/submit_step_3_center'); $vars = ''; check_actions('do_submit2', $vars); $_SESSION['step'] = 2; if (Submit_Complete_Step2) { do_submit3(); } else { $main_smarty->display($the_template . '/pligg.tpl'); } }
function tree_to_array($root, $table, $showRoot = TRUE) { // showRoot -- Do we want to include the "root" category named "all" in our results -- all subcats WILL appear regardless global $db, $cached_categories; $row = get_cached_category_data('category__auto_id', $root); if (!$row) { $sqlfix = "UPDATE " . table_categories . " SET `category__auto_id` = '0' WHERE `category_name` = 'all' LIMIT 1;"; $db->query($sqlfix); $cached_categories = loadCategoriesForCache(); $row = get_cached_category_data('category__auto_id', $root); if (!$row) { die('There is a problem with the categories table. Error CA:001.'); } } $right = array(); $left = array(); $result = get_cached_between($row->lft, $row->rgt); $i = 0; $lastspacer = 0; foreach ($result as $row) { if (count($right) > 0) { // check if we should remove a node from the stack while ($right[count($right) - 1] < $row->rgt) { array_pop($left); if (array_pop($right) == NULL) { break; // We've reached the top of the category chain } } } $array[$i]['first'] = $row->lft - 1 == $left[sizeof($left) - 1]; $array[$i]['last'] = $row->rgt + 1 == $right[sizeof($right) - 1]; $array[$i]['principlecat'] = $row->rgt - $row->lft - 1; $array[$i]['spacercount'] = count($right); $array[$i]['lastspacercount'] = $lastspacer; $array[$i]['spacerdiff'] = abs($lastspacer - count($right)); $array[$i]['id'] = $row->category_id; $array[$i]['auto_id'] = $row->category__auto_id; $array[$i]['name'] = $row->category_name; $array[$i]['safename'] = $row->category_safe_name; $array[$i]['order'] = $row->category_order; $array[$i]['left'] = $row->lft; $array[$i]['right'] = $row->rgt; $array[$i]['leftrightdiff'] = $row->rgt - $row->lft; $array[$i]['authorlevel'] = $row->category_author_level; $array[$i]['authorgroup'] = $row->category_author_group; $array[$i]['votes'] = $row->category_votes; $array[$i]['karma'] = $row->category_karma; $array[$i]['description'] = $row->category_desc; $array[$i]['keywords'] = $row->category_keywords; if (isset($row->category_color)) { $array[$i]['color'] = $row->category_color; } if (isset($row->category_parent)) { $array[$i]['parent'] = $row->category_parent; $array[$i]['parent_name'] = GetCatName($row->category_parent); $array[$i]['parent_subcat_count'] = GetSubCatCount($row->category_parent); } $array[$i]['subcat_count'] = GetSubCatCount($row->category__auto_id); $lastspacer = count($right); $right[] = $row->rgt; $left[] = $row->lft; if ($array[$i]['leftrightdiff'] != 1) { for ($j = 0; $j <= $array[$i]['leftrightdiff']; $j++) { $array[$i]['subcatalign'] = 1; } } $i++; } if ($showRoot == FALSE) { array_splice($array, 0, 1); } return $array; }