/** * The UI to view a download category tree. * * @return tempcode The UI */ function tree_view_screen() { $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=downloads&filter='; require_code('splurgh'); if ($GLOBALS['SITE_DB']->query_value('download_categories', 'COUNT(*)') > 1000) { warn_exit(do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM')); } $url_stub = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF', NULL, false, false, true); $last_change_time = $GLOBALS['SITE_DB']->query_value_null_ok('download_categories', 'MAX(add_date)'); $category_rows = $GLOBALS['SITE_DB']->query_select('download_categories', array('id', 'category', 'parent_id')); $map = array(); foreach ($category_rows as $category) { if ($category['category'] != db_get_first_id()) { if (!has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'downloads', strval($category['id']))) { continue; } } $id = $category['id']; $map[$id]['title'] = get_translated_text($category['category']); $children = array(); foreach ($category_rows as $child) { if ($child['parent_id'] == $id) { $children[] = $child['id']; } } $map[$id]['children'] = $children; } $content = splurgh_master_build('id', $map, $url_stub->evaluate(), 'download_tree_made', $last_change_time); $title = get_page_title('DOWNLOADS_TREE'); return do_template('SPLURGH_SCREEN', array('_GUID' => '4efab542cfa3d48a3b23d60b04798a37', 'TITLE' => $title, 'CONTENT' => $content)); }
/** * The UI to view a catalogue category tree. * * @return tempcode The UI */ function tree_view_screen() { require_code('splurgh'); $catalogue_name = get_param('id'); if ($GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)', array('c_name' => $catalogue_name)) > 1000) { warn_exit(do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM')); } $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=catalogues&filter='; $url_stub = build_url(array('page' => '_SELF', 'type' => 'category'), '_SELF', NULL, false, false, true); $last_change_time = $GLOBALS['SITE_DB']->query_value_null_ok('catalogue_categories', 'MAX(cc_add_date)'); if (!has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'catalogues_catalogue', $catalogue_name)) { access_denied('CATALOGUE_ACCESS'); } $category_rows = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('id', 'cc_title', 'cc_parent_id'), array('c_name' => $catalogue_name)); $map = array(); foreach ($category_rows as $i => $category) { if ($i != 0) { if (!has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'catalogues_category', strval($category['id']))) { continue; } } $id = $category['id']; $map[$id]['title'] = get_translated_text($category['cc_title']); $children = array(); foreach ($category_rows as $child) { if ($child['cc_parent_id'] == $id) { $children[] = $child['id']; } } $map[$id]['children'] = $children; } if (count($map) == 0) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } $content = splurgh_master_build('id', $map, $url_stub->evaluate(), 'catalogue_' . $catalogue_name . '_tree_made', $last_change_time, $category_rows[0]['id']); $title = get_page_title('CATEGORIES'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc' . (is_ecommerce_catalogue($catalogue_name) ? ':ecommerce=1' : ''), do_lang_tempcode('CATALOGUES')))); return do_template('SPLURGH_SCREEN', array('_GUID' => '7cbb5d410887e3834a01265e133a9b33', 'TITLE' => $title, 'CONTENT' => $content)); }