Commit 28b0d7ec authored by jonnybradley's avatar jonnybradley

[FIX] categ trees: Use CatBrowseTreeMaker in generate_cat_tree(), as once i'd...

[FIX] categ trees: Use CatBrowseTreeMaker in generate_cat_tree(), as once i'd fixed CatPickerTreeMaker the code was identical.
Therefore [KIL] categ_picker_tree.php and categ_admin_tree.php which was completely unused anyway.
(Finishes off r30170 and cures wish3634)
parent 318f77e6
......@@ -3059,9 +3059,7 @@ lib/trackers/dynamic_list.js -text
lib/trackers/index.php -text
lib/trackers/trackerlib.php -text
lib/transitionlib.php -text
lib/tree/categ_admin_tree.php -text
lib/tree/categ_browse_tree.php -text
lib/tree/categ_picker_tree.php -text
lib/tree/index.php -text
lib/tree/tree.php -text
lib/userfiles/index.php -text
......
......@@ -1864,7 +1864,7 @@ class CategLib extends ObjectLib
// generate category tree for use in various places (like categorize_list.php)
function generate_cat_tree($categories, $canchangeall = false, $forceincat = array()) {
global $smarty;
include_once ('lib/tree/categ_picker_tree.php');
include_once ('lib/tree/categ_browse_tree.php');
$tree_nodes = array();
$roots = $this->findRoots( $categories );
foreach ($categories as $c) {
......@@ -1884,11 +1884,11 @@ class CategLib extends ObjectLib
'data' => $smarty->fetch( 'category_tree_entry.tpl' ),
);
if (in_array( $c['parentId'], $roots )) {
$tree_nodes[count($tree_nodes) - 1]['data'] = '<strong>'.$tree_nodes[count($tree_nodes) - 1]['data'].'</strong>';
$tree_nodes[count($tree_nodes) - 1]['data'] = $tree_nodes[count($tree_nodes) - 1]['data'];
}
}
}
$tm = new CatPickerTreeMaker("categorize");
$tm = new CatBrowseTreeMaker("categorize");
$res = '';
foreach( $roots as $root ) {
$res .= $tm->make_tree($root, $tree_nodes);
......
<?php
// (c) Copyright 2002-2010 by authors of the Tiki Wiki/CMS/Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
/** \file
* \brief Categories browse tree
*
* \author zaufi@sendmail.ru
*
*/
require_once ('lib/tree/tree.php');
/**
* \brief Class to render categories browse tree
*/
class CatAdminTreeMaker extends TreeMaker
{
/// Collect javascript cookie set code (internaly used after make_tree() method)
var $jsscriptblock;
/// Generated ID (private usage only)
var $itemID;
/// Constructor
function CatAdminTreeMaker($prefix) {
$this->TreeMaker($prefix);
$this->jsscriptblock = '';
}
/// Generate HTML code for tree. Need to redefine to add javascript cookies block
function make_tree($rootid, $ar) {
global $headerlib;
$r = '<ul class="tree root">'."\n";
$r .= $this->make_tree_r($rootid, $ar) . "</ul>\n";
// java script block that opens the nodes as remembered in cookies
$headerlib->add_jq_onready($this->jsscriptblock);
// return tree
return $r;
}
//
// Change default (no code 'cept user data) generation behaviour
//
// Need to generate:
//
// [node start = <div class="treenode"><table><tr>]
// [flipper] user data [edit][del]
// [node data end = </div>]
// [node child start = <div class="tree">]
// [childs code]
// [node child end = </div>]
//
// Unsymmetrical calls is not important :)
//
function node_start_code($nodeinfo) {
return '<div class="treenode"><table width="100%"><tr>';
}
//
function node_flipper_code($nodeinfo) {
$this->itemID = $this->prefix . 'id' . $nodeinfo["id"];
$this->jsscriptblock .= "setFlipWithSign('" . $this->itemID . "'); ";
return '<td><a class="catname" title="' . tra(
'child categories'). ': ' . $nodeinfo["children"] . ', ' . tra('objects in category'). ': ' . $nodeinfo["objects"] . '" id="flipper' . $this->itemID . '" href="javascript:flipWithSign(\'' . $this->itemID . '\')">[+]</a></td>';
}
//
function node_data_start_code($nodeinfo) {
return '<td>';
}
//
function node_data_end_code($nodeinfo) {
return '</td><td width="10%" align="right">' . $nodeinfo["edit"] . $nodeinfo["remove"] . '</td></tr></table></div>';
}
//
function node_child_start_code($nodeinfo) {
return '<div class="tree" id="' . $this->itemID . '" style="display: none;">';
}
//
function node_child_end_code($nodeinfo) {
return '</div>';
}
//
function node_end_code($nodeinfo) {
return '';
}
}
<?php
// (c) Copyright 2002-2010 by authors of the Tiki Wiki/CMS/Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
/** \file
* \brief Categories browse tree
*
* \author zaufi@sendmail.ru
* \enhanced by luci@sh.ground.cz
* \re-enhanced by jonnyb
*
*/
require_once ('lib/tree/tree.php');
/**
* \brief Class to render categories browse tree
*/
class CatPickerTreeMaker extends TreeMaker
{
/// Collect javascript cookie set code (internaly used after make_tree() method)
var $jsscriptblock;
/// Generated ID (private usage only)
var $itemID;
/// Constructor
function CatPickerTreeMaker($prefix) {
$this->TreeMaker($prefix);
$this->jsscriptblock = '';
}
/// Generate HTML code for tree. Need to redefine to add javascript cookies block
function make_tree($rootid, $ar) {
global $headerlib;
$r = '<ul class="tree root">'."\n";
$r .= $this->make_tree_r($rootid, $ar) . "</ul>\n";
// java script block that opens the nodes as remembered in cookies
$headerlib->add_jq_onready($this->jsscriptblock);
// return tree
return $r;
}
//
// Change default (no code 'cept user data) generation behaviour
//
// Need to generate:
//
// [indent = <tabulator>]
// [node start = <li class="treenode">]
// [node data start]
// [flipper] +/- link to flip
// [node child start = <ul class="tree">]
// [child's code]
// [node child end = </ul>]
// [node data end]
// [node end = </li>]
//
//
//
function indent($nodeinfo) {
return "\t\t";
}
function node_start_code($nodeinfo) {
static $oddness;
if ($nodeinfo['parent'] == 0) {
if (!isset($oddness) || $oddness == 'odd') { $oddness = 'even'; } else { $oddness = 'odd'; }
return "\t<li class=\"treenode $oddness\">";
} else {
return "\t<li class=\"treenode\">";
}
}
//
function node_flipper_code($nodeinfo) {
$this->itemID = $this->prefix . 'id' . $nodeinfo["id"];
$this->jsscriptblock .= "setFlipWithSign('" . $this->itemID . "'); ";
return '<a class="link categflipper" id="flipper' . $this->itemID . '" href="#" onclick="flipWithSign(\'' . $this->itemID . '\');return false;">[+]</a>&nbsp;';
}
//
function node_data_start_code($nodeinfo) {
return '';
}
//
function node_data_end_code($nodeinfo) {
return "\n";
}
//
function node_child_start_code($nodeinfo) {
return '<ul class="tree" id="' . $this->itemID . '">';
}
//
function node_child_end_code($nodeinfo) {
return '</ul>';
}
//
function node_end_code($nodeinfo) {
return "\t" . '</li>';
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment