コード例 #1
0
ファイル: index.php プロジェクト: GeekyNinja/LifesavingCAD
    $result = $tree->remove($_REQUEST['removeId']);
}
if (@$_REQUEST['action_update']) {
    $methodCall = "tree->update( {$_REQUEST['updateId']} , {$_REQUEST['updateData']} )";
    $result = $tree->update($_REQUEST['updateId'], $_REQUEST['updateData']);
}
if (@$_REQUEST['action_move']) {
    $methodCall = "tree->move( {$_REQUEST['move_id']} , {$_REQUEST['move_newParentId']} , {$_REQUEST['move_newPrevId']} )";
    $result = $tree->move($_REQUEST['move_id'], $_REQUEST['move_newParentId'], $_REQUEST['move_newPrevId']);
}
$methodFailed = false;
if (@PEAR::isError($result)) {
    $methodFailed = true;
}
$fid = @$_REQUEST['fid'];
if (!$fid) {
    $fid = $tree->getRootId();
}
$path = $tree->getPath($fid);
$children = $tree->getChildren($fid);
##################################################
#
#       actual tree stuff to show the entire tree using Memory_DBnested
#
require_once 'Tree/Tree.php';
$memTree = Tree::setup('Memory_DBnested', 'mysql://root@localhost/test', array('table' => 'Tree_Nested'));
$memTree->setup();
$entireTree = $memTree->getNode();
$treeDepth = $memTree->getDepth();
$tpl->compile('index.tpl');
include $tpl->compiledTemplate;
コード例 #2
0
ファイル: functions.php プロジェクト: reeze/web-bugs
/**
 * Fetches pseudo packages from database
 *
 * @param string	$project			define what project pseudo packages are returned
 * @param bool		$return_disabled	whether to return read-only items, defaults to true
 *
 * @return array	array of pseudo packages
 */
function get_pseudo_packages($project, $return_disabled = true)
{
    global $project_types;
    require_once 'Tree/Tree.php';
    $where = '1=1';
    $project = strtolower($project);
    if ($project !== false && in_array($project, $project_types)) {
        $where .= " AND project IN ('',  '" . $project . "')";
    }
    if (!$return_disabled) {
        $where .= " AND disabled = 0";
    }
    $pseudo_pkgs = array();
    $tree = Tree::setup('Memory_MDB2simple', DATABASE_DSN, array('order' => 'disabled, id', 'whereAddOn' => $where, 'table' => 'bugdb_pseudo_packages', 'columnNameMaps' => array('parentId' => 'parent')));
    $tree->setup();
    foreach ($tree->data as $data) {
        if (isset($data['children'])) {
            $pseudo_pkgs[$data['name']] = array($data['long_name'], $data['disabled']);
            $long_names = array();
            foreach ($data['children'] as $k => $v) {
                $long_names[$k] = strtolower($v['long_name']);
            }
            array_multisort($long_names, SORT_ASC, SORT_STRING, $data['children']);
            foreach ($data['children'] as $child) {
                $pseudo_pkgs[$child['name']] = array("    {$child['long_name']}", $child['disabled']);
            }
        } else {
            if (!isset($pseudo_pkgs[$data['name']])) {
                $pseudo_pkgs[$data['name']] = array($data['long_name'], $data['disabled']);
            }
        }
    }
    return $pseudo_pkgs;
}
コード例 #3
0
<?php

//
//  $Id: Dynamic_DBnested.php,v 1.2 2003/01/30 17:43:41 cain Exp $
//
//ini_set('include_path',realpath(dirname(__FILE__).'/../../').':'.realpath(dirname(__FILE__).'/../../../includes').':'.ini_get('include_path'));
//ini_set('error_reporting',E_ALL);
require_once 'Tree/Tree.php';
#    $tree = Tree::setupDynamic( 'DBnested' , 'mysql://root@localhost/test' , array('table'=>'nestedTree') );
#   OR
$tree = Tree::setup('Dynamic_DBnested', 'mysql://root@localhost/test', array('table' => 'nestedTree'));
$show[] = '$tree->getRoot()';
$show[] = '$tree->getElement( 1 )';
$show[] = '$tree->getChild( 1 )';
$show[] = '$tree->getPath( 7 )';
$show[] = '$tree->getPath( 2 )';
$show[] = '$tree->add( array("name"=>"c0") , 5 )';
$show[] = '$tree->remove( $res )';
// remove the last element that was added in the line before :-)
$show[] = '$tree->getRight( 5 )';
$show[] = '$tree->getLeft( 5 )';
$show[] = '$tree->getChildren( 1 )';
$show[] = '$tree->getParent( 2 )';
$show[] = '$tree->getNext( 2 )';
$show[] = '$tree->getNext( 4 )';
$show[] = '$tree->getNext( 8 )';
$show[] = '$tree->getPrevious( 2 )';
$show[] = '$tree->getPrevious( 4 )';
$show[] = '$tree->getPrevious( 8 )';
$show[] = '$tree->getPreviousId( 8 )';
$show[] = '$tree->move( 4,3 )';