Example #1
0
function gen_tree($a, $level)
{
    $indent = "\n" . str_repeat(" ", $level);
    $res = $indent . "&(struct codetree_node) {";
    //    $res = $indent . "{";
    if ($level == 12) {
        if (count($a) != 1) {
            die("Ambigious code at level 12, something went wrong!\n");
        }
        $res .= key($a) . ", NULL, NULL}";
        return $res;
    }
    $res .= "-1, ";
    /* Split codes */
    $split = array("0" => array(), "1" => array());
    foreach ($a as $k => $code) {
        $split[substr($code, 0, 1)][$k] = substr($code, 1);
    }
    foreach ($split as $digit => $new_codes) {
        if (count($new_codes)) {
            $res .= gen_tree($new_codes, $level + 1);
        } else {
            $res .= $indent . " NULL";
        }
        if ($digit == "0") {
            $res .= ",";
        } else {
            $res .= $indent . "}";
        }
    }
    return $res;
}
Example #2
0
function gen_tree($current, $icons, $imgpath, &$xml_tree, &$tree_id, &$tree_level, $noclick)
{
    while (list($key, $value) = each($current)) {
        if ($current[$key]['FOLDER']) {
            $img = $imgpath . 'icons/ico_folder_s.png,' . $imgpath . 'icons/ico_folderopen_s.png';
            $cststyle = '';
            $dnd = 'false';
            $curr_noclick = $noclick;
        } else {
            $img = $icons['entrymask_small'];
            $cststyle = 'nosub nodrop';
            $dnd = '';
            $curr_noclick = '';
            // Add path
            if ($img != '') {
                $img = $imgpath . 'icons/' . $img;
            }
        }
        $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'entrymask_' . $current[$key]['ID'], 'CAPTION' => htmlspecialchars($current[$key]['NAME']), 'URL' => $url, 'IC' => $img, 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => $cststyle, 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $current[$key]['ID'] . '-entrymask', 'YG_TYPE' => 'entrymask', 'YG_PROPERTY' => 'name', 'DND' => $dnd, 'XTRA' => $curr_noclick);
        array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
        if (is_array($current[$key]['CHILDREN'])) {
            $tree_level++;
            gen_tree($current[$key]['CHILDREN'], $icons, $imgpath, $xml_tree, $tree_id, $tree_level, $noclick);
        }
    }
    $tree_level--;
}
Example #3
0
 public function get_all()
 {
     $navs = $this->nav_model->get_all("position asc, sort asc");
     $new_nav = array();
     foreach ($navs as $key => $value) {
         $new_nav[$value['id']] = $value;
     }
     $navs = getTreeData(gen_tree($new_nav, 'pid'));
     die(json_encode(array('code' => 200, 'data' => $navs, 'message' => '获取成功')));
 }
Example #4
0
 /**
  *  获取分类树
  */
 public function get_category_tree()
 {
     $model = $this->model;
     $categories = $this->CI->{$model}->get_all();
     $new_categories = array();
     foreach ($categories as $key => $value) {
         $new_categories[$value['id']] = $value;
     }
     $categories = gen_tree($new_categories, 'pid');
     return $categories;
 }
Example #5
0
 /**
  *  获取指定栏目集
  *
  *  @param $pid 父ID
  *
  *  return array
  */
 public function get_columns($pid = 0)
 {
     $columns = $this->CI->db->order_by('sort asc')->get('column')->result_array();
     $new_columns = array();
     foreach ($columns as $key => $value) {
         $new_columns[$value['id']] = $value;
     }
     $columns = gen_tree($new_columns, 'pid');
     if ($pid == 0) {
         return $columns;
     }
     return find_grand_node($columns, $pid);
 }
Example #6
0
 public function __construct()
 {
     parent::__construct();
     $this->load->database();
     $this->load->model(array('column_model', 'rule_model', 'archives_model'));
     $this->load->library(array('session', 'Pinyin', 'MyCategory'));
     $this->load->helper(array('array', 'url', 'file'));
     $columns = $this->column_model->get_all(array('field' => 'sort', 'way' => 'asc'));
     $new_columns = array();
     foreach ($columns as $key => $value) {
         $new_columns[$value['id']] = $value;
     }
     $this->columns = gen_tree($new_columns, 'pid');
 }
Example #7
0
function gen_tree($current, $site = 1, $icons, $imgpath, &$xml_tree, &$tree_id, &$tree_level, $maxlevels, $dnd, $subnodes, $itext, $action)
{
    if ($tree_level > $maxlevels) {
        $tree_level--;
        return;
    }
    $svrload = 'false';
    if ($tree_level == (int) $maxlevels) {
        $svrload = 'true';
    }
    while (list($key, $value) = each($current)) {
        if ($current[$key]["RREAD"] > 0) {
            $img = $imgpath . 'icons/ico_folder_s.png,' . $imgpath . 'icons/ico_folderopen_s.png';
            $cststyle = '';
            if ($current[$key]["VERSIONPUBLISHED"] + 2 != $current[$key]["VERSION"] && $current[$key]["VERSIONPUBLISHED"] != ALWAYS_LATEST_APPROVED_VERSION && $current[$key]["HASCHANGED"] == "1") {
                // Editiert (gr?n)
                $cststyle = "changed";
            } elseif ($current[$key]["HASCHANGED"] == "1") {
                $cststyle = "changed";
            }
            if ($current[$key]["RWRITE"] == "0") {
                // Nur Leserecht (hellgrau)
                $cststyle .= " nowrite";
            }
            if ($current[$key]["RDELETE"] == "0") {
                // Nur Leserecht (hellgrau)
                $cststyle .= " nodelete";
            }
            if ($current[$key]["RSUB"] == "0") {
                $cststyle .= " nosub";
            }
            $node_svrload = 'false';
            if ($svrload == 'true' && $current[$key]['CHILDREN'] != NULL) {
                $node_svrload = $svrload;
            }
            $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => $current[$key]["ID"] == 1 ? 'root_1' : 'file_' . $current[$key]["ID"], 'CAPTION' => htmlspecialchars($current[$key]["NAME"]), 'URL' => $url, 'IC' => $img, 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => $cststyle, 'TARGET' => '', 'TITLE' => '', 'DND' => $dnd, 'SVRLOAD' => $node_svrload, 'YG_ID' => $current[$key]["ID"] . '-file', 'YG_TYPE' => 'file', 'YG_PROPERTY' => 'name');
            array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
            if (is_array($current[$key]["CHILDREN"])) {
                $tree_level++;
                gen_tree($current[$key]["CHILDREN"], $site, $icons, $imgpath, $xml_tree, $tree_id, $tree_level, $maxlevels, $dnd, $subnodes, $itext, $action);
            }
        }
    }
    if (!$action && !$subnodes && $tree_level == 1) {
        $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'cblock_trash', 'CAPTION' => htmlspecialchars($itext['TXT_TRASHCAN']), 'URL' => $url, 'IC' => $imgpath . 'icons/ico_trashcan_s.png', 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => 'nodrag nodrop nosub', 'TARGET' => '', 'TITLE' => '', 'DND' => 'false', 'SVRLOAD' => 'false', 'YG_ID' => 'trash-file', 'YG_TYPE' => 'filetrash', 'YG_PROPERTY' => 'name');
        array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
    }
    $tree_level--;
}
Example #8
0
 public function get_column()
 {
     $data = $this->input->stream();
     $columns = $this->column_model->get_all(array('field' => 'sort', 'way' => 'asc'));
     $new_columns = array();
     foreach ($columns as $key => $value) {
         $new_columns[$value['id']] = $value;
     }
     $columns = getTreeData(gen_tree($new_columns, 'pid'));
     if (isset($data['channelId']) && !empty($data['channelId'])) {
         $columns = array_filter($columns, function ($item) use($data) {
             return $item['channel_id'] == $data['channelId'];
         });
     }
     $columns = array_values($columns);
     die(json_encode(array('code' => 200, 'data' => $columns, 'message' => '获取成功')));
 }
Example #9
0
 public function get_reply_message()
 {
     $data = $this->input->stream();
     $messages = $this->message_model->get_all_by_condition();
     $new_messages = array();
     foreach ($messages as $key => $value) {
         $new_messages[$value['id']] = $value;
     }
     $messages = gen_tree($new_messages, 'pid');
     $reply_messages = find_grand_node($messages, $data['id']);
     if (is_array($reply_messages) && !empty($reply_messages)) {
         if (!empty($reply_messages['children'])) {
             die(json_encode(array('code' => 200, 'message' => '获取成功', 'data' => $this->render_html($reply_messages['children']))));
         } else {
             die(json_encode(array('code' => 200, 'message' => '获取成功')));
         }
     } else {
         die(json_encode(array('code' => 403, 'message' => '获取失败')));
     }
 }
Example #10
0
function gen_tree($current, $imgpath, &$xml_tree, &$tree_id, &$tree_level, $noclick, $onlyFolders)
{
    while (list($key, $value) = each($current)) {
        // Do print
        if ($current[$key]['FOLDER'] == 1) {
            // We have a folder, don't fill with data
            $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'template_' . $current[$key]['ID'], 'CAPTION' => htmlspecialchars($current[$key]['NAME']), 'URL' => '', 'IC' => $imgpath . 'icons/ico_folder_s.png,' . $imgpath . 'icons/ico_folderopen_s.png', 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => 'nopreview noedit', 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $current[$key]['ID'] . '-template', 'YG_TYPE' => 'templatefolder', 'YG_PROPERTY' => 'name', 'XTRA' => $noclick);
        } else {
            // We have a normal node, fill with data
            $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'template_' . $current[$key]['ID'], 'CAPTION' => htmlspecialchars($current[$key]['NAME']), 'URL' => '', 'IC' => '', 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => 'nosub', 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $current[$key]['ID'] . '-template', 'YG_TYPE' => 'template', 'YG_PROPERTY' => 'name');
        }
        if (!($onlyFolders && $current[$key]['FOLDER'] != 1)) {
            array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
        }
        if (is_array($current[$key]['CHILDREN'])) {
            $tree_level++;
            gen_tree($current[$key]['CHILDREN'], $imgpath, $xml_tree, $tree_id, $tree_level, $noclick, $onlyFolders);
        }
        $prev_level = $current[$key]['LEVEL'];
    }
    $tree_level--;
}
Example #11
0
function gen_tree($current, $imgpath, &$xml_tree, &$tree_id, &$tree_level, $maxlevels)
{
    if ($tree_level > $maxlevels) {
        $tree_level--;
        return;
    }
    $svrload = 'false';
    if ($tree_level == (int) $maxlevels) {
        $svrload = 'true';
    }
    while (list($key, $value) = each($current)) {
        if ($current[$key]["RREAD"] > 0) {
            $cststyle = '';
            if ($current[$key]["RWRITE"] == "0") {
                // No edit right
                $cststyle .= " nowrite";
            }
            if ($current[$key]["RDELETE"] == "0") {
                // No delete right
                $cststyle .= " nodelete";
            }
            if ($current[$key]["RSUB"] == "0") {
                $cststyle .= " nosub";
            }
            $node_svrload = 'false';
            if ($svrload == 'true' && $current[$key]['CHILDREN'] != NULL) {
                $node_svrload = $svrload;
            }
            $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'tag_' . $current[$key]["ID"], 'CAPTION' => htmlspecialchars($current[$key]["NAME"]), 'URL' => '', 'IC' => $imgpath . 'icons/ico_tag_s.png', 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => $cststyle, 'TARGET' => '', 'TITLE' => '', 'SVRLOAD' => $node_svrload, 'YG_ID' => $current[$key]["ID"] . '-tag', 'YG_TYPE' => 'tag', 'YG_PROPERTY' => 'name');
            array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
            if (is_array($current[$key]["CHILDREN"])) {
                $tree_level++;
                gen_tree($current[$key]["CHILDREN"], $imgpath, $xml_tree, $tree_id, $tree_level, $maxlevels);
            }
        }
    }
    $tree_level--;
}
Example #12
0
function gen_tree($current, $site = 1, $icons, $imgpath, &$xml_tree, &$tree_id, &$tree_level, $itext, $maxlevels, $currentnode)
{
    if ($tree_level > $maxlevels) {
        $tree_level--;
        return;
    }
    $svrload = 'false';
    if ($tree_level == (int) $maxlevels) {
        $svrload = 'true';
    }
    if (is_array($currentnode['CONTENTAREAS']) && count($currentnode['CONTENTAREAS']) > 0 && $currentnode['ID'] != 1) {
        $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'contentareacontainer_' . $currentnode['ID'], 'CAPTION' => '<i>' . ($itext['TXT_CONTENTAREAS'] != '') ? $itext['TXT_CONTENTAREAS'] : '$TXT_CONTENTAREAS' . '</i>', 'URL' => $url, 'IC' => $imgpath . 'icons/' . $icons['contentareas_small'], 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => '', 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $currentnode['ID'] . '-contentareacontainer', 'YG_TYPE' => 'contentareacontainer', 'YG_PROPERTY' => 'name', 'PURL' => $currentnode['PURL'], 'DND' => 'false', 'XTRA' => 'noclick');
        array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
        $tree_level++;
        foreach ($currentnode['CONTENTAREAS'] as $contentarea) {
            $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'contentarea' . $currentnode['ID'] . '_' . $contentarea['ID'], 'CAPTION' => '<i>' . htmlspecialchars($contentarea['NAME']) . '</i>', 'URL' => $url, 'IC' => $imgpath . 'icons/' . $icons['contentarea_small'], 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => '', 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $contentarea['ID'] . '-contentarea' . $current[$key]['ID'], 'YG_TYPE' => 'contentarea', 'YG_PROPERTY' => 'name', 'DND' => 'false', 'XTRA' => 'noclick');
            array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
            foreach ($contentarea['LIST'] as $co_item) {
                if ($co_item['EMBEDDED'] != 1) {
                    $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'co' . $current[$key]['ID'] . '_' . $co_item['ID'] . '_' . $co_item['LINKID'], 'CAPTION' => htmlspecialchars($co_item['NAME']), 'URL' => $url, 'IC' => $imgpath . 'icons/' . $icons['cblock_small'], 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => '', 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $co_item['ID'] . '-cblock' . $current[$key]['ID'], 'YG_TYPE' => 'cblock', 'YG_PROPERTY' => 'name');
                    array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
                }
            }
        }
        $tree_level--;
    }
    while (list($key, $value) = each($current)) {
        if ($current[$key]['RREAD'] > 0) {
            $img = $icons['page_small'];
            $cststyle = '';
            $inactive = false;
            if ($current[$key]['ACTIVE'] == '0') {
                $img = $icons['page_inactive_small'];
                $inactive = true;
            }
            if ($current[$key]['HIDDEN'] == '1' || $current[$key]['TEMPLATEID'] == '0') {
                $img = $icons['page_hidden_small'];
                if ($inactive == true) {
                    $img = $icons['page_inactive_hidden_small'];
                }
            }
            if ($current[$key]['VERSIONPUBLISHED'] + 1 != $current[$key]['VERSION']) {
                // Editiert (gr�n)
                $cststyle = "changed";
            } elseif ($current[$key]['HASCHANGED'] == '1') {
                $cststyle = "changed";
            }
            if ($current[$key]['RWRITE'] == '0') {
                // Nur Leserecht (hellgrau)
                $cststyle = "nowrite";
            }
            // Add path
            if ($img != '') {
                $img = $imgpath . 'icons/' . $img;
            }
            $node_svrload = 'false';
            if ($svrload == 'true' && $current[$key]['CHILDREN'] != NULL) {
                $node_svrload = $svrload;
            }
            $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'page_' . $current[$key]["ID"], 'CAPTION' => htmlspecialchars($current[$key]["NAME"]), 'URL' => $url, 'IC' => $img, 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => $cststyle, 'TARGET' => '', 'TITLE' => '', 'SVRLOAD' => $node_svrload, 'YG_ID' => $current[$key]["ID"] . '-' . $site, 'YG_TYPE' => 'page', 'YG_PROPERTY' => 'name', 'PURL' => $current[$key]['PURL']);
            array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
            if (is_array($current[$key]['CONTENTAREAS']) && count($current[$key]['CONTENTAREAS']) > 0) {
                $tree_level++;
                $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'contentareacontainer_' . $current[$key]['ID'], 'CAPTION' => '<i>' . ($itext['TXT_CONTENTAREAS'] != '') ? $itext['TXT_CONTENTAREAS'] : '$TXT_CONTENTAREAS' . '</i>', 'URL' => $url, 'IC' => $imgpath . 'icons/' . $icons['contentareas_small'], 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => '', 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $current[$key]['ID'] . '-contentareacontainer', 'YG_TYPE' => 'contentareacontainer', 'YG_PROPERTY' => 'name', 'PURL' => $current[$key]['PURL'], 'XTRA' => 'noclick');
                array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
                $tree_level++;
                foreach ($current[$key]['CONTENTAREAS'] as $contentarea) {
                    $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'contentarea' . $current[$key]['ID'] . '_' . $contentarea['ID'], 'CAPTION' => '<i>' . htmlspecialchars($contentarea['NAME']) . '</i>', 'URL' => $url, 'IC' => $imgpath . 'icons/' . $icons['contentarea_small'], 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => '', 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $contentarea['ID'] . '-contentarea' . $current[$key]['ID'], 'YG_TYPE' => 'contentarea', 'YG_PROPERTY' => 'name', 'XTRA' => 'noclick');
                    array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
                    foreach ($contentarea['LIST'] as $co_item) {
                        if ($co_item['EMBEDDED'] != 1) {
                            $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'co' . $current[$key]['ID'] . '_' . $co_item['ID'] . '_' . $co_item['LINKID'], 'CAPTION' => htmlspecialchars($co_item['NAME']), 'URL' => $url, 'IC' => $imgpath . 'icons/' . $icons['cblock_small'], 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => '', 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $co_item['ID'] . '-cblock' . $current[$key]['ID'], 'YG_TYPE' => 'cblock', 'YG_PROPERTY' => 'name');
                            /*
                            											'YG_PROPERTY' => 'name',
                            											'XTRA' => 'noclick' );
                            */
                            array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
                        }
                    }
                }
                $tree_level--;
                $tree_level--;
            }
            if (is_array($current[$key]['CHILDREN'])) {
                $tree_level++;
                gen_tree($current[$key]['CHILDREN'], $site, $icons, $imgpath, $xml_tree, $tree_id, $tree_level, $itext, $maxlevels, $current[$key]);
            }
        }
    }
    $tree_level--;
}
function gen_tree($current, $site = 1, $icons, $imgpath, &$xml_tree, &$tree_id, &$tree_level, $itext, $maxlevels, $currentnode)
{
    if ($tree_level > $maxlevels) {
        $tree_level--;
        return;
    }
    $svrload = 'false';
    if ($tree_level == (int) $maxlevels) {
        $svrload = 'true';
    }
    if (is_array($currentnode['CONTENTAREAS']) && count($currentnode['CONTENTAREAS']) > 0 && $currentnode['ID'] != 1) {
        $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'contentareacontainer_' . $currentnode['ID'], 'CAPTION' => '<i>' . ($itext['TXT_CONTENTAREAS'] != '') ? $itext['TXT_CONTENTAREAS'] : '$TXT_CONTENTAREAS' . '</i>', 'URL' => $url, 'IC' => $imgpath . '/icons/' . $icons['contentareas_small'], 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => '', 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $currentnode['ID'] . '-contentareacontainer', 'YG_TYPE' => 'contentareacontainer', 'YG_PROPERTY' => 'name', 'DND' => 'false', 'XTRA' => 'noclick');
        array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
        $tree_level++;
        foreach ($currentnode['CONTENTAREAS'] as $contentarea) {
            $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'contentarea' . $currentnode['ID'] . '_' . $contentarea['ID'], 'CAPTION' => '<i>' . htmlspecialchars($contentarea['NAME']) . '</i>', 'URL' => $url, 'IC' => $imgpath . '/icons/' . $icons['contentarea_small'], 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => '', 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $contentarea['ID'] . '-contentarea' . $current[$key]['ID'], 'YG_TYPE' => 'contentarea', 'YG_PROPERTY' => 'name', 'DND' => 'false', 'XTRA' => 'noclick');
            array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
            foreach ($contentarea['LIST'] as $co_item) {
                if ($co_item['EMBEDDED'] != 1) {
                    $tmpCblock = sCblockMgr()->getCblock($co_item['OBJECTID']);
                    if ($tmpCblock) {
                        $cBlockInfo = $tmpCblock->get();
                        $co_item['NAME'] = $cBlockInfo['NAME'];
                    }
                    $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'co' . $current[$key]['ID'] . '_' . $co_item['OBJECTID'] . '_' . $co_item['LINKID'], 'CAPTION' => htmlspecialchars($co_item['NAME']), 'URL' => $url, 'IC' => $imgpath . '/icons/' . $icons['cblock_small'], 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => '', 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $co_item['OBJECTID'] . '-cblock' . $current[$key]['ID'], 'YG_TYPE' => 'cblock', 'YG_PROPERTY' => 'name');
                    array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
                }
            }
        }
        $tree_level--;
    }
    while (list($key, $value) = each($current)) {
        if ($current[$key]['RREAD'] > 0) {
            $iconData = getIconForPage($current[$key]);
            $img = $icons[$iconData['img']];
            $cststyle = $iconData['style'];
            // Add path
            if ($img == '' || img != undefined) {
                $img = $imgpath . 'icons/' . $img;
            }
            $node_svrload = 'false';
            if ($svrload == 'true' && $current[$key]['CHILDREN'] != NULL) {
                $node_svrload = $svrload;
            }
            $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'page_' . $current[$key]["ID"], 'CAPTION' => htmlspecialchars($current[$key]["NAME"]), 'URL' => $url, 'IC' => $img, 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => $cststyle, 'TARGET' => '', 'TITLE' => '', 'SVRLOAD' => $node_svrload, 'YG_ID' => $current[$key]["ID"] . '-' . $site, 'YG_TYPE' => 'page', 'YG_PROPERTY' => 'name', 'XTRA' => 'noclick');
            array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
            if (is_array($current[$key]['CONTENTAREAS']) && count($current[$key]['CONTENTAREAS']) > 0) {
                $tree_level++;
                $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'contentareacontainer_' . $current[$key]['ID'], 'CAPTION' => '<i>' . ($itext['TXT_CONTENTAREAS'] != '') ? $itext['TXT_CONTENTAREAS'] : '$TXT_CONTENTAREAS' . '</i>', 'URL' => $url, 'IC' => $imgpath . '/icons/' . $icons['contentareas_small'], 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => '', 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $current[$key]['ID'] . '-contentareacontainer', 'YG_TYPE' => 'contentareacontainer', 'YG_PROPERTY' => 'name', 'XTRA' => 'noclick');
                array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
                $tree_level++;
                foreach ($current[$key]['CONTENTAREAS'] as $contentarea) {
                    $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'contentarea' . $current[$key]['ID'] . '_' . $contentarea['ID'], 'CAPTION' => '<i>' . htmlspecialchars($contentarea['NAME']) . '</i>', 'URL' => $url, 'IC' => $imgpath . '/icons/' . $icons['contentarea_small'], 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => '', 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $contentarea['ID'] . '-contentarea' . $current[$key]['ID'], 'YG_TYPE' => 'contentarea', 'YG_PROPERTY' => 'name', 'XTRA' => 'noclick');
                    array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
                    foreach ($contentarea['LIST'] as $co_item) {
                        if ($co_item['EMBEDDED'] != 1) {
                            $tmpCblock = sCblockMgr()->getCblock($co_item['OBJECTID']);
                            if ($tmpCblock) {
                                $cBlockInfo = $tmpCblock->get();
                                $co_item['NAME'] = $cBlockInfo['NAME'];
                            }
                            $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'co' . $current[$key]['ID'] . '_' . $co_item['OBJECTID'] . '_' . $co_item['LINKID'], 'CAPTION' => htmlspecialchars($co_item['NAME']), 'URL' => $url, 'IC' => $imgpath . '/icons/' . $icons['cblock_small'], 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => '', 'TARGET' => '', 'TITLE' => '', 'YG_ID' => $co_item['OBJECTID'] . '-cblock' . $current[$key]['ID'], 'YG_TYPE' => 'cblock', 'YG_PROPERTY' => 'name');
                            /*
                            											'YG_PROPERTY' => 'name',
                            											 );
                            */
                            array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
                        }
                    }
                }
                $tree_level--;
                $tree_level--;
            }
            if (is_array($current[$key]['CHILDREN'])) {
                $tree_level++;
                gen_tree($current[$key]['CHILDREN'], $site, $icons, $imgpath, $xml_tree, $tree_id, $tree_level, $itext, $maxlevels, $current[$key]);
            }
        }
    }
    $tree_level--;
}
Example #14
0
function gen_tree($current, $site = 1, $icons, $imgpath, &$xml_tree, &$tree_id, &$tree_level, $maxlevels, $dnd, $cms, $subnodes, $itext, $action)
{
    if ($tree_level > $maxlevels) {
        $tree_level--;
        return;
    }
    $svrload = 'false';
    if ($tree_level == (int) $maxlevels) {
        $svrload = 'true';
    }
    $oldlevel = 0;
    $urlprefix = "";
    while (list($key, $value) = each($current)) {
        if ($current[$key]["RREAD"] > 0) {
            $iconData = getIconForPage($current[$key]);
            $img = $icons[$iconData['img']];
            $cststyle = $iconData['style'];
            if ($oldlevel != $current[$key]["LEVEL"]) {
                $pnames = sPageMgr($site)->getParents($current[$key]["ID"]);
                $oldlevel = $current[$key]["LEVEL"];
                $urlprefix = "";
                $pi = count($pnames);
                while ($pi > 0) {
                    if ($pnames[$pi - 1][0]["PNAME"] != "") {
                        $urlprefix .= $pnames[$pi - 1][0]["PNAME"] . "/";
                    }
                    $pi--;
                }
            }
            $url = sApp()->webroot . $urlprefix . $current[$key]["PNAME"] . "/";
            // Add path
            if ($img == '' || img != undefined) {
                $img = $imgpath . 'icons/' . $img;
            }
            $node_svrload = 'false';
            if ($svrload == 'true' && $current[$key]['CHILDREN'] != NULL) {
                $node_svrload = $svrload;
            }
            $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'page_' . $current[$key]["ID"], 'CAPTION' => htmlspecialchars($current[$key]["NAME"]), 'URL' => $url, 'IC' => $img, 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => $cststyle, 'TARGET' => '', 'TITLE' => '', 'DND' => $dnd, 'SVRLOAD' => $node_svrload, 'YG_ID' => $current[$key]["ID"] . '-' . $site, 'YG_TYPE' => 'page', 'YG_PROPERTY' => 'name', 'PNAME' => $current[$key]["PNAME"]);
            array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
            if (is_array($current[$key]["CHILDREN"])) {
                $tree_level++;
                gen_tree($current[$key]["CHILDREN"], $site, $icons, $imgpath, $xml_tree, $tree_id, $tree_level, $maxlevels, $dnd, $cms, $subnodes, $itext, $action);
            }
        }
    }
    if (!$action && !$subnodes && $tree_level == 1) {
        $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'page_trash', 'CAPTION' => htmlspecialchars($itext['TXT_TRASHCAN']), 'URL' => $url, 'IC' => $imgpath . 'icons/ico_trashcan_s.png', 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => 'nodrag nodrop nosub', 'TARGET' => '', 'TITLE' => '', 'DND' => 'false', 'SVRLOAD' => 'false', 'YG_ID' => 'trash-' . $site, 'YG_TYPE' => 'page', 'YG_PROPERTY' => 'name');
        array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
    }
    $tree_level--;
}