tra('Category Path'), 'documentation' => 'PluginCatPath', 'description' => tra('Show the full category path for a wiki page'), 'prefs' => [ 'feature_categories', 'wikiplugin_catpath' ], 'iconname' => 'structure', 'introduced' => 1, 'params' => [ 'divider' => [ 'required' => false, 'name' => tra('Separator'), 'description' => tr( 'String used to separate the categories in the path. Default character is %0.', '>' ), 'since' => '1', 'default' => '>', ], 'top' => [ 'required' => false, 'name' => tra('Display Top Category'), 'description' => tra('Show the top category as part of the path name (not shown by default)'), 'since' => '1', 'filter' => 'alpha', 'default' => 'no', 'options' => [ ['text' => '', 'value' => ''], ['text' => tra('Yes'), 'value' => 'y'], ['text' => tra('No'), 'value' => 'n'] ], ], ], ]; } function wikiplugin_catpath($data, $params) { global $prefs; $smarty = TikiLib::lib('smarty'); $tikilib = TikiLib::lib('tiki'); $categlib = TikiLib::lib('categ'); if ($prefs['feature_categories'] != 'y') { return "" . tra("Categories are disabled") . ""; } extract($params, EXTR_SKIP); // default divider is '>' if (! (isset($divider))) { $divider = '>'; } // default setting for top is 'no' if (! (isset($top))) { $top = 'no'; } elseif ($top != 'y' and $top != 'yes' and $top != 'n' and $top != 'no') { $top = 'no'; } $objId = urldecode($_REQUEST['page']); $cats = $categlib->get_object_categories('wiki page', $objId); $catpath = ''; foreach ($cats as $categId) { $catpath .= ''; // Display TOP on each line if wanted if ($top == 'yes' or $top == 'y') { $catpath .= 'TOP ' . $divider . ' '; } $path = ''; $info = $categlib->get_category($categId); $path = '' . htmlspecialchars($info["name"]) . ''; while ($info["parentId"] != 0) { $info = $categlib->get_category($info["parentId"]); $path = '' . htmlspecialchars($info["name"]) . ' ' . htmlspecialchars($divider) . ' ' . $path; } $catpath .= $path . '
'; } return $catpath; }