function get_feeds_list() { global $LANG; require_once PATH_TO_ROOT . '/pages/pages_functions.php'; $cats_tree = new FeedsCat('pages', 0, $LANG['root']); $categories = PagesCategoriesCache::load()->get_categories(); build_pages_cat_children($cats_tree, array_values($categories)); $feeds = new FeedsList(); $feeds->add_feed($cats_tree, Feed::DEFAULT_FEED_NAME); return $feeds; }
function build_pages_cat_children($cats_tree, $cats, $id_parent = 0) { if (!empty($cats)) { $i = 0; $nb_cats = count($cats); $children = array(); while ($i < $nb_cats) { if (isset($cats[$i]) && $cats[$i]['id_parent'] == $id_parent) { $id = $cats[$i]['id']; $feeds_cat = new FeedsCat('pages', $id, stripslashes($cats[$i]['title'])); // Decrease the complexity unset($cats[$i]); $cats = array_merge($cats); // re-index the array $nb_cats = count($cats); build_pages_cat_children($feeds_cat, $cats, $id); $cats_tree->add_child($feeds_cat); } else { $i++; } } } }