예제 #1
0
파일: dbtree.php 프로젝트: RushCode/oxDesk
require_once 'classes/safemysql.class.php';
require_once 'classes/DbTree.class.php';
require_once 'classes/DbTreeExt.class.php';
// Data base connect
$dsn['user'] = '******';
$dsn['pass'] = '';
$dsn['host'] = 'localhost';
$dsn['db'] = 'test';
$dsn['charset'] = 'utf8';
$dsn['errmode'] = 'exception';
define('DEBUG_MODE', false);
$db = new SafeMySQL($dsn);
$sql = 'SET NAMES utf8';
$db->query($sql);
$tree_params = array('table' => 'test_sections', 'id' => 'section_id', 'left' => 'section_left', 'right' => 'section_right', 'level' => 'section_level');
$dbtree = new DbTreeExt($tree_params, $db);
/* ------------------------ NAVIGATOR ------------------------ */
$navigator = 'You are here: ';
if (!empty($_GET['section_id'])) {
    $parents = $dbtree->Parents((int) $_GET['section_id'], array('section_id', 'section_name'));
    foreach ($parents as $item) {
        if (@$_GET['section_id'] != $item['section_id']) {
            $navigator .= '<a href="dbtree.php?mode=' . $_GET['mode'] . '&section_id=' . $item['section_id'] . '">' . $item['section_name'] . '</a> > ';
        } else {
            $navigator .= '<strong>' . $item['section_name'] . '</strong>';
        }
    }
}
/* ------------------------ BRANCH ------------------------ */
if (!empty($_GET['mode']) && 'branch' == $_GET['mode']) {
    if (!isset($_GET['section_id'])) {
예제 #2
0
require_once '../safemysql.class.php';
require_once '../DbTree.class.php';
require_once '../DbTreeExt.class.php';
// Data base connect
$dsn['user'] = '******';
$dsn['pass'] = '';
$dsn['host'] = 'localhost';
$dsn['db'] = 'sesmikcms';
$dsn['charset'] = 'utf8';
$dsn['errmode'] = 'exception';
define('DEBUG_MODE', false);
$db = new SafeMySQL($dsn);
$sql = 'SET NAMES utf8';
$db->query($sql);
$tree_params = array('table' => 'test_sections', 'id' => 'section_id', 'left' => 'section_left', 'right' => 'section_right', 'level' => 'section_level');
$dbtree = new DbTreeExt($tree_params, $db);
/* ------------------------ MOVE ------------------------ */
/* ------------------------ MOVE 2 ------------------------ */
// Method 2: Assigns a node with all its children to another parent.
if (!empty($_GET['action']) && 'move_2' == $_GET['action']) {
    // Move node ($_GET['section_id']) and its children to new parent ($_POST['section2_id'])
    $dbtree->MoveAll((int) $_GET['section_id'], (int) $_POST['section2_id']);
    header('Location:dbtree_demo.php');
    exit;
}
/* ------------------------ MOVE 1 ------------------------ */
// Method 1: Swapping nodes within the same level and limits of one parent with all its children.
if (!empty($_GET['action']) && 'move_1' == $_GET['action']) {
    // Change node ($_GET['section_id']) position and all its childrens to
    // before or after ($_POST['position']) node 2 ($_POST['section2_id'])
    $dbtree->ChangePositionAll((int) $_GET['section_id'], (int) $_POST['section2_id'], $_POST['position']);