$title = tra('Assign Permissions'); $icon = 'key'; } $data .= '<a href="tiki-objectpermissions.php?objectType=category&objectId=' . $category['categId'] . '&objectName=' . urlencode($category['name']) . '&permType=category">' . smarty_function_icon(array('_id'=>$icon, 'alt'=>$title), $smarty) . '</a>'; $data .= '<a class="catname" href="tiki-admin_categories.php?parentId=' . $category["categId"] . '">' . htmlspecialchars($category['name']) .'</a> '; $treeNodes[] = array( 'id' => $category['categId'], 'parent' => $category['parentId'], 'data' => $data ); } } include_once ('lib/tree/BrowseTreeMaker.php'); $treeMaker = new BrowseTreeMaker('categ'); $smarty->assign('tree', $treeMaker->make_tree(0, $treeNodes)); // --------------------------------------------------- if (!isset($_REQUEST["sort_mode"])) { $sort_mode = 'name_asc'; } else { $sort_mode = $_REQUEST["sort_mode"]; } if (!isset($_REQUEST["offset"])) { $offset = 0; } else { $offset = $_REQUEST["offset"]; } $smarty->assign('offset', $offset); if (isset($_REQUEST["find"])) { $find = $_REQUEST["find"];
if ($g != 'Anonymous') { $addedGroupsDesc[] = $g; } } if (isset($_REQUEST[$g]) && $_REQUEST[$g] == 'cat_remove_desc') { $categlib->group_unwatch_category_and_descendants($g, $_REQUEST['objectId'], false); if ($g != 'Anonymous') { $deletedGroupsDesc[] = $g; } } } $smarty->assign_by_ref('addedGroupsDesc', $addedGroupsDesc); $smarty->assign_by_ref('deletedGroupsDesc', $deletedGroupsDesc); if (!empty($addedGroupsDesc) || !empty($deletedGroupsDesc)) { foreach ($extendedTargets as $d) { $catinfo = $categlib->get_category($d); $catTreeNodes[] = array('id' => $catinfo['categId'], 'parent' => $catinfo['parentId'], 'data' => $catinfo['name']); } include_once 'lib/tree/BrowseTreeMaker.php'; $tm = new BrowseTreeMaker('categ'); $res = $tm->make_tree($catTreeNodes[0]['parent'], $catTreeNodes); $smarty->assign('tree', $res); } } } else { $group_watches = $tikilib->get_groups_watching($_REQUEST['objectId'], $_REQUEST['watch_event'], $objectType); } $smarty->assign_by_ref('group_watches', $group_watches); ask_ticket('object_watches'); $smarty->assign('mid', 'tiki-object_watches.tpl'); $smarty->display('tiki.tpl');
function generate_cat_tree($categories, $canchangeall = false, $forceincat = null) { $smarty = TikiLib::lib('smarty'); include_once 'lib/tree/BrowseTreeMaker.php'; $tree_nodes = array(); $roots = $this->findRoots($categories); foreach ($categories as $c) { if (isset($c['name']) || $c['parentId'] != 0) { // if used for purposes such as find, should be able to "change" all cats if ($canchangeall) { $c['canchange'] = true; } // if used in find, should force incat to check those that have been selected if (is_array($forceincat)) { $c['incat'] = in_array($c['categId'], $forceincat) ? 'y' : 'n'; } $smarty->assign('category_data', $c); $tree_nodes[] = array('id' => $c['categId'], 'parent' => $c['parentId'], 'data' => $smarty->fetch('category_tree_entry.tpl')); } } $tm = new BrowseTreeMaker("categorize"); $res = ''; foreach ($roots as $root) { $res .= $tm->make_tree($root, $tree_nodes); } return $res; }
function getTreeHTML($galleryIdentifier = NULL) { global $prefs, $smarty; require_once 'lib/tree/BrowseTreeMaker.php'; $galleryIdentifier = is_null($galleryIdentifier) ? $prefs['fgal_root_id'] : $galleryIdentifier; $subGalleries = $this->getSubGalleries($galleryIdentifier); $smarty->loadPlugin('smarty_function_icon'); $icon = ' ' . smarty_function_icon(array('_id' => 'folder'), $smarty) . ' '; $smarty->loadPlugin('smarty_block_self_link'); $linkParameters = array('_script' => 'tiki-list_file_gallery.php', '_class' => 'fgalname'); if (!empty($_REQUEST['filegals_manager'])) { $linkParameters['filegals_manager'] = $_REQUEST['filegals_manager']; } $nodes = array(); foreach ($subGalleries['data'] as $subGallery) { $linkParameters['galleryId'] = $subGallery['id']; $nodes[] = array('id' => $subGallery['id'], 'parent' => $subGallery['parentId'], 'data' => smarty_block_self_link($linkParameters, $icon . htmlspecialchars($subGallery['name']), $smarty)); } $browseTreeMaker = new BrowseTreeMaker('Galleries'); return $browseTreeMaker->make_tree($this->getGallerySpecialRoot($galleryIdentifier), $nodes); }
/** * @param $mod_reference * @param $module_params */ function module_categories($mod_reference, &$module_params) { global $prefs; global $user; $smarty = TikiLib::lib('smarty'); $categlib = TikiLib::lib('categ'); if (isset($module_params['type'])) { $type = $module_params['type']; $urlEnd = '&type=' . urlencode($type); } else { $type = ''; $urlEnd = ''; } if (isset($module_params['deep'])) { $deep = $module_params['deep']; } else { $deep = 'on'; } if ($deep === 'on') { $urlEnd .= "&deep={$deep}"; } $name = ""; if (isset($module_params['categId'])) { $categId = $module_params['categId']; $categories = $categlib->getCategories(array('identifier' => $categId, 'type' => 'descendants')); foreach ($categories as $cat) { if ($cat['categId'] == $categId) { $name = $cat['name']; } } } else { $categories = $categlib->getCategories(); $categId = 0; } if (empty($categories)) { $smarty->clearAssign('tree'); return; } if (isset($module_params['categParentIds'])) { $categParentIds = explode(',', $module_params['categParentIds']); $filtered_categories = array(); foreach ($categParentIds as $c) { foreach ($categories as $cat) { if ($cat['categId'] == $c || $cat['parentId'] == $c) { $filtered_categories[] = $cat; } } } $categories = $filtered_categories; unset($filtered_categories); } include_once 'lib/tree/BrowseTreeMaker.php'; $tree_nodes = array(); include_once 'tiki-sefurl.php'; foreach ($categories as $cat) { if (!empty($module_params['hideEmpty']) && $module_params['hideEmpty'] === 'y' && $cat['objects'] == 0) { $has_children = false; foreach ($cat['children'] as $child) { if (!empty($categories[$child]['objects'])) { $has_children = true; break; } } if (!$has_children) { continue; } } if (isset($module_params['selflink']) && $module_params['selflink'] == 'y') { $url = filter_out_sefurl('tiki-index.php?page=' . urlencode($cat['name'])); } else { $url = filter_out_sefurl('tiki-browse_categories.php?parentId=' . $cat['categId'], 'category', $cat['name'], !empty($urlEnd)) . $urlEnd; } $tree_nodes[] = array("id" => $cat["categId"], "parent" => $cat["parentId"], 'parentId' => $cat['parentId'], 'categId' => $cat['categId'], "data" => '<span style="float: left; cursor: pointer; visibility: hidden;" class="ui-icon ui-icon-triangle-1-e"></span><a class="catname" href="' . $url . '">' . htmlspecialchars($cat['name']) . '</a><br />'); } $res = ''; $tm = new BrowseTreeMaker('mod_categ' . $mod_reference['position'] . $mod_reference['ord']); foreach ($categlib->findRoots($tree_nodes) as $node) { $res .= $tm->make_tree($node, $tree_nodes); } $smarty->assign('tree', $res); }
$url = htmlentities('tiki-edit_categories.php?' . http_build_query(array('filter~categories' => $c['categId'])), ENT_QUOTES, 'UTF-8'); $name = htmlentities($c['name'], ENT_QUOTES, 'UTF-8'); $perms = Perms::get('category', $c['categId']); $add = $perms->add_object ? '<span class="control categ-add"></span>' : ''; $remove = $perms->remove_object ? '<span class="control categ-remove"></span>' : ''; $body = <<<BODY {$add} {$remove} <span class="object-count">{$c['objects']}</span> <a class="catname" href="{$url}" data-categ="{$c['categId']}">{$name}</a> BODY; $tree_nodes[] = array('id' => $c['categId'], 'parent' => $c['parentId'], 'data' => $body); } $tree_nodes[] = array('id' => 'orphan', 'parent' => '0', 'data' => '<span class="object-count">' . $orphans['cant'] . '</span><a class="catname" href="tiki-edit_categories.php?filter~categories=orphan"><em>' . tr('Orphans') . '</em></a>'); $tm = new BrowseTreeMaker('categ'); $res = $tm->make_tree(0, $tree_nodes); $smarty->assign('tree', $res); // }}} $filter = isset($_REQUEST['filter']) ? $_REQUEST['filter'] : array(); $smarty->assign('filter', $filter); if (count($filter)) { $unifiedsearchlib = TikiLib::lib('unifiedsearch'); $query = $unifiedsearchlib->buildQuery($filter); if (isset($_REQUEST['sort_mode']) && ($order = Search_Query_Order::parse($_REQUEST['sort_mode']))) { $query->setOrder($order); } $result = $query->search($unifiedsearchlib->getIndex()); $smarty->assign('result', $result); } // }}} $smarty->assign('mid', 'tiki-edit_categories.tpl');
$eyes = add_watch_icons($descendants, $usercatwatches, $_REQUEST['parentId'], $c['categId'], $deep, $user); $c['eyes'] = $eyes; } unset($c); $tree_nodes = array(); foreach ($ctall as $c) { $tree_nodes[] = array( 'id' => $c['categId'], 'parent' => $c['parentId'], 'data' => '<span class="object-count">' . $c['objects'] . '</span>' . $c['eyes'] . ' <a class="catname" href="tiki-browse_categories.php?parentId=' . $c['categId'] . '&deep=' . $deep . '&type='. urlencode($type) . '">' . htmlspecialchars($c['name']) .'</a> ', ); } $tm = new BrowseTreeMaker('categ'); $res = $tm->make_tree($_REQUEST['parentId'], $tree_nodes); $smarty->assign('tree', $res); $objects = $categlib->list_category_objects( $_REQUEST['parentId'], $offset, $maxRecords, $sort_mode, $type, $find, $deep == 'on', (!empty($_REQUEST['and'])) ? true : false ); if ($deep == 'on') { foreach ($objects['data'] as &$object) {
function smarty_block_filter($params, $content, $smarty, &$repeat) { global $prefs; if ($repeat) { return; } $tikilib = TikiLib::lib('tiki'); $unifiedsearchlib = TikiLib::lib('unifiedsearch'); if (!isset($params['action'])) { $params['action'] = ''; } $types = $unifiedsearchlib->getSupportedTypes(); $filter = isset($_REQUEST['filter']) ? $_REQUEST['filter'] : array(); if (isset($params['filter'])) { $filter = array_merge($filter, $params['filter']); } // General $smarty->assign('filter_action', $params['action']); $smarty->assign('filter_content', isset($filter['content']) ? $filter['content'] : ''); $smarty->assign('filter_type', isset($filter['type']) ? $filter['type'] : $prefs['search_default_where']); $smarty->assign('filter_types', $types); $sort_mode = isset($_REQUEST['sort_mode']) ? $_REQUEST['sort_mode'] : 'score_ndesc'; $sort_modes = array('score_ndesc' => tra('Relevance'), 'object_type_asc' => tra('Type'), 'title_asc' => tra('Title'), 'modification_date_ndesc' => tra('Modified date'), 'visits_ndesc' => tra('Visits')); $smarty->assign('sort_mode', $sort_mode); $smarty->assign('sort_modes', $sort_modes); // Categories if ($prefs['feature_categories'] == 'y' && $prefs['search_show_category_filter'] == 'y') { $smarty->assign('filter_deep', isset($filter['deep'])); $smarty->assign('filter_categories', isset($filter['categories']) ? $filter['categories'] : ''); $smarty->assign('filter_categmap', json_encode(TikiDb::get()->fetchMap('SELECT categId, name FROM tiki_categories'))); // Generate the category tree {{{ $categlib = TikiLib::lib('categ'); require_once 'lib/tree/BrowseTreeMaker.php'; $ctall = $categlib->getCategories(); if ($prefs['unified_excluded_categories'] === 'y') { // remove those excluded categs $ctall = array_diff_key($ctall, array_flip($prefs['unified_excluded_categories'])); } $tree_nodes = array(); foreach ($ctall as $c) { $name = htmlentities($c['name'], ENT_QUOTES, 'UTF-8'); $body = <<<BODY <label> \t<input type="checkbox" value="{$c['categId']}"/> \t{$name} </label> BODY; $tree_nodes[] = array('id' => $c['categId'], 'parent' => $c['parentId'], 'data' => $body); } $tm = new BrowseTreeMaker('categ'); $res = $tm->make_tree(0, $tree_nodes); $smarty->assign('filter_category_picker', $res); // }}} } if ($prefs['feature_freetags'] == 'y') { $freetaglib = TikiLib::lib('freetag'); $smarty->assign('filter_tags', isset($filter['tags']) ? $filter['tags'] : ''); $smarty->assign('filter_tagmap', json_encode(TikiDb::get()->fetchMap('SELECT tagId, tag FROM tiki_freetags'))); $smarty->assign('filter_tags_picker', (string) $freetaglib->get_cloud()); } // Language if ($prefs['feature_multilingual'] == 'y') { $langLib = TikiLib::lib('language'); $languages = $langLib->list_languages(); $smarty->assign('filter_languages', $languages); $smarty->assign('filter_language_unspecified', isset($filter['language_unspecified'])); $smarty->assign('filter_language', isset($filter['language']) ? $filter['language'] : ''); } return $smarty->fetch('filter.tpl'); }
$smarty->assign_by_ref('eyes_curr', $eyes_curr); foreach ($ctall as &$c) { $descendants = $categlib->get_category_descendants($c['categId']); $usercatwatches = $tikilib->get_user_watches($user, 'category_changed'); $eyes = add_watch_icons($descendants, $usercatwatches, $_REQUEST['parentId'], $c['categId'], $deep, $user); $c['eyes'] = $eyes; } unset($c); $tree_nodes = array(); foreach ($ctall as $c) { $tree_nodes[] = array('id' => $c['categId'], 'categId' => $c['categId'], 'parent' => $c['parentId'], 'parentId' => $c['parentId'], 'data' => '<span class="object-count">' . $c['objects'] . '</span>' . $c['eyes'] . ' <a class="catname" href="tiki-browse_categories.php?parentId=' . $c['categId'] . '&deep=' . $deep . '&type=' . urlencode($type) . '">' . htmlspecialchars($c['name']) . '</a> '); } $res = ''; $tm = new BrowseTreeMaker('categ'); foreach ($categlib->findRoots($tree_nodes) as $node) { $res .= $tm->make_tree($node, $tree_nodes); } $smarty->assign('tree', $res); $objects = $categlib->list_category_objects($_REQUEST['parentId'], $offset, $maxRecords, $sort_mode, $type, $find, $deep == 'on', !empty($_REQUEST['and']) ? true : false); if ($deep == 'on') { foreach ($objects['data'] as &$object) { $object['categName'] = $tikilib->other_value_in_tab_line($ctall, $object['categId'], 'categId', 'name'); } } $smarty->assign_by_ref('objects', $objects['data']); $smarty->assign_by_ref('cant_pages', $objects['cant']); $smarty->assign_by_ref('maxRecords', $maxRecords); include_once 'tiki-section_options.php'; ask_ticket('browse-categories'); // disallow robots to index page: $smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
function module_categories($mod_reference, &$module_params) { global $smarty, $prefs; global $user; global $categlib; include_once ('lib/categories/categlib.php'); if (isset($module_params['type'])) { $type = $module_params['type']; $urlEnd = '&type='.urlencode($type); } else { $type = ''; $urlEnd = ''; } if (isset($module_params['deep'])) $deep = $module_params['deep']; else $deep= 'on'; $urlEnd .= "&deep=$deep"; $name = ""; $categories = $categlib->getCategories(); if (empty($categories)) { return; } if (isset($module_params['categId'])) { $categId = $module_params['categId']; foreach ($categories as $cat) { if ($cat['categId'] == $categId) $name = $cat['name']; } } else $categId = 0; if (isset($module_params['categParentIds'])) { $categParentIds = explode(',', $module_params['categParentIds']); $filtered_categories = array(); foreach ($categParentIds as $c) { foreach ($categories as $cat) { if ($cat['categId'] == $c || $cat['parentId'] == $c) { $filtered_categories[] = $cat; } } } $categories = $filtered_categories; unset($filtered_categories); } include_once ('lib/tree/BrowseTreeMaker.php'); $tree_nodes = array(); include_once('tiki-sefurl.php'); foreach ($categories as $cat) { if (isset($module_params['selflink']) && $module_params['selflink'] == 'y') { $url = filter_out_sefurl('tiki-index.php?page=' . urlencode($cat['name'])); } else { $url = filter_out_sefurl('tiki-browse_categories.php?parentId=' . $cat['categId'], 'category', $cat['name']) .$urlEnd; } $tree_nodes[] = array( "id" => $cat["categId"], "parent" => $cat["parentId"], "data" => '<a class="catname" href="'.$url.'">' . htmlspecialchars($cat['name']) . '</a><br />' ); } $tm = new BrowseTreeMaker('mod_categ' . $module_params['module_position'] . $module_params['module_ord']); $res = $tm->make_tree($categId, $tree_nodes); $smarty->assign('tree', $res); }
function smarty_block_filter($params, $content, $smarty, &$repeat) { global $prefs; if ($repeat) { return; } $tikilib = TikiLib::lib('tiki'); $unifiedsearchlib = TikiLib::lib('unifiedsearch'); if (!isset($params['action'])) { $params['action'] = ''; } $types = $unifiedsearchlib->getSupportedTypes(); $filter = isset($_REQUEST['filter']) ? $_REQUEST['filter'] : array(); if (isset($params['filter'])) { $filter = array_merge($filter, $params['filter']); } // General $smarty->assign('filter_action', $params['action']); $smarty->assign('filter_content', isset($filter['content']) ? $filter['content'] : ''); $smarty->assign('filter_type', isset($filter['type']) ? $filter['type'] : ''); $smarty->assign('filter_types', $types); // Categories if ($prefs['feature_categories'] == 'y') { $smarty->assign('filter_deep', isset($filter['deep'])); $smarty->assign('filter_categories', isset($filter['categories']) ? $filter['categories'] : ''); $smarty->assign('filter_categmap', json_encode(TikiDb::get()->fetchMap('SELECT categId, name FROM tiki_categories'))); // Generate the category tree {{{ global $categlib; require_once 'lib/categories/categlib.php'; require_once 'lib/tree/BrowseTreeMaker.php'; $ctall = $categlib->getCategories(); $tree_nodes = array(); foreach ($ctall as $c) { $name = htmlentities($c['name'], ENT_QUOTES, 'UTF-8'); $body = <<<BODY <label> \t<input type="checkbox" value="{$c['categId']}"/> \t{$name} </label> BODY; $tree_nodes[] = array('id' => $c['categId'], 'parent' => $c['parentId'], 'data' => $body); } $tm = new BrowseTreeMaker('categ'); $res = $tm->make_tree(0, $tree_nodes); $smarty->assign('filter_category_picker', $res); // }}} } if ($prefs['feature_freetags'] == 'y') { global $freetaglib; require_once 'lib/freetag/freetaglib.php'; $smarty->assign('filter_tags', isset($filter['tags']) ? $filter['tags'] : ''); $smarty->assign('filter_tagmap', json_encode(TikiDb::get()->fetchMap('SELECT tagId, tag FROM tiki_freetags'))); $smarty->assign('filter_tags_picker', (string) $freetaglib->get_cloud()); } // Language if ($prefs['feature_multilingual'] == 'y') { $languages = $tikilib->list_languages(); $smarty->assign('filter_languages', $languages); $smarty->assign('filter_language_unspecified', isset($filter['language_unspecified'])); $smarty->assign('filter_language', isset($filter['language']) ? $filter['language'] : ''); } return $smarty->fetch('filter.tpl'); }