Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!defined('SMF'))
- die('No direct access...');
- // We need to build a menu, so grab categories and types
- function getCategoriesTypes($workIndexOptions)
- {
- global $smcFunc, $scripturl, $user_info, $modSettings, $txt;
- global $settings, $options, $context, $sourcedir;
- $result_work_cats_and_types = $smcFunc['db_query']('workindex_fetch_cats_and_types' , '
- SELECT
- c.id_cat,
- c.cat_order,
- c.cat_name,
- c.cat_desc,
- t.id_type,
- t.id_cat AS parent_cat,
- t.id_parent,
- t.child_level,
- t.type_order,
- t.type_name,
- t.type_desc,
- t.num_works,
- t.num_comments,
- t.unapproved_comments
- FROM
- {db_prefix}works_categories AS c,
- {db_prefix}works_types AS t
- WHERE
- c.id_cat = t.id_cat
- ORDER BY
- c.cat_order, t.id_parent
- ');
- // Start with an empty array.
- $work_categories = array();
- // Build the array of cats and types
- while ($row = $smcFunc['db_fetch_assoc']($result_work_cats_and_types))
- {
- // Make sure we haven't seen the cat yet then grab it
- if (!isset($work_categories[$row['id_cat']]))
- {
- $work_categories[$row['id_cat']] = array(
- 'id_cat' => $row['id_cat'],
- 'order' => $row['cat_order'],
- 'name' => $row['cat_name'],
- 'description' => $row['cat_desc'],
- 'href' => $scripturl . '#c' . $row['id_cat'],
- 'link' => '<a href="' . $scripturl . '#c' . $row['id_cat'] . '">' . $row['cat_name'] . '</a>',
- 'types' => array() ,
- );
- }
- // Make sure to grab the types
- if (($work_categories[$row['child_level']]) == 0)
- {
- $work_categories[$row['id_cat']]['types'][$row['id_type']] = array(
- 'id_type' => $row['id_type'],
- 'order' => $row['type_order'],
- 'parent' => $row['id_parent'],
- 'child_level' => $row['child_level'],
- 'name' => $row['type_name'],
- 'description' => $row['type_desc'],
- 'works' => $row['num_works'],
- 'comments' => $row['num_comments'],
- 'href' => $scripturl . '?type=' . $row['id_type'] . '.0',
- 'link' => '<a href="' . $scripturl . '?type=' . $row['id_type'] . '.0">' . $row['type_name'] . '</a>',
- 'types' => array() ,
- );
- }
- // Grab the syubtypes
- if (($work_categories[$row['child_level']]) > 0)
- {
- $work_categories[$row['id_cat']]['types'][$row['id_parent']]['types'][$row['id_type']] = array(
- 'id_type' => $row['id_type'],
- 'order' => $row['type_order'],
- 'parent' => $row['id_parent'],
- 'child_level' => $row['child_level'],
- 'name' => $row['type_name'],
- 'description' => $row['type_desc'],
- 'works' => $row['num_works'],
- 'comments' => $row['num_comments'],
- 'href' => $scripturl . '?type=' . $row['id_type'] . '.0',
- 'link' => '<a href="' . $scripturl . '?type=' . $row['id_type'] . '.0">' . $row['type_name'] . '</a>',
- );
- }
- }
- // We don't need this query anymore we have the data
- $smcFunc['db_free_result']($result_work_cats_and_types);
- // Let's return something....
- return $work_categories;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement