public function edit()
 {
     $Group = D("Group");
     if (I("flag")) {
         if ($Group->create()) {
             $_POST['rules'] = implode(',', I('rules'));
             if ($Group->save($_POST)) {
                 $this->ajaxReturn(1);
                 //成功
             } else {
                 $this->ajaxReturn(0);
                 //失败
             }
         } else {
             $this->ajaxReturn($Group->getError());
         }
     } else {
         $menu = D('menu');
         $id = I('id');
         $map['id'] = array('eq', $id);
         $groupNews = $Group->where($map)->field("id,title,rules,status")->find();
         $groupNews['rules'] = explode(',', $groupNews['rules']);
         $data = $menu->field("id,pid,name")->select();
         $pid = 0;
         $treeList = makeTree($pid, $data);
         $tree = treeOutput($treeList, $groupNews['rules']);
         $this->assign("tree", $tree);
         $this->assign("groupNews", $groupNews);
         $this->display();
     }
 }
Example #2
0
function makeTree($db, $name, $level = 2)
{
    $node = makeNode($name);
    if ($level > 0) {
        $cl = getContacts($db, $name);
        foreach ($cl as $c) {
            $node["children"][] = makeTree($db, $c["name"], $level - 1);
        }
    }
    return $node;
}
Example #3
0
function makeTree($pid, $data)
{
    //数组重组
    if (empty($data)) {
        return '';
    }
    //循环当前数组 获取当前的分类内容
    $tmp = array();
    foreach ($data as $k => $v) {
        if ($v['pid'] == $pid) {
            unset($data['$k']);
            $res = makeTree($v['id'], $data);
            //递推调用
            $v['child'] = $res;
            $tmp[] = $v;
        }
    }
    return $tmp;
}
Example #4
0
function makeTree($directory)
{
    if (!is_dir($directory['path'])) {
        return;
    }
    @($dirlist = scandir($directory['path']));
    $tree = array();
    foreach ($dirlist as $dir) {
        if ($dir != '.' && $dir != '..') {
            $element = array();
            $element['dir'] = is_dir($directory['path'] . '/' . $dir);
            $element['size'] = !is_dir($directory['path'] . '/' . $dir) ? filesize($directory['path'] . '/' . $dir) : 0;
            $element['name'] = $dir;
            $element['path'] = $directory['path'] . '/' . $dir;
            $element['children'] = makeTree($element);
            $element['url'] = makeURL('fileadmin', array('path' => $element['path']));
            $tree[] = $element;
        }
    }
    return $tree;
}
Example #5
0
<?php

$lang->addModSpecificLocalization('fileadmin');
$smarty->assign('lang', $lang->getAll());
require_once 'mod/default/fileadmin/fileadmin.function.php';
if ($login->currentUser() !== false && $rights->isAllowed('fileadmin', 'use')) {
    $root['name'] = 'fileadmin';
    $root['path'] = $dir;
    $tree = makeTree($root);
    $smarty->assign('tree', $tree);
    $pages = $content->getPages();
    $smarty->assign('pages', $pages);
    if ($db->num_rows('mod', "`mod`='formmaker'") > 0) {
        $forms = $db->selectList('formmaker', '*', '1', '`title`');
        if (@count($forms) > 0) {
            foreach ($forms as $i => $form) {
                $forms[$i]['url'] = makeURL($form['key']);
            }
        }
        $smarty->assign('forms', $forms);
    }
    $mods = $db->selectList('mod');
    foreach ($mods as &$mod) {
        $mod['url'] = makeURL($mod['mod']);
    }
    $smarty->assign('mods', $mods);
    $smarty->assign('mode', strip_tags(@$_GET['mode']));
    $smarty->assign('id', strip_tags(@$_GET['id']));
    $smarty->display('../mod/default/fileadmin/browser.tpl');
}
Example #6
0
function makeTree($items)
{
    if (!$items->isEmpty()) {
        foreach ($items as $item) {
            $tree[$item->id]['item'] = $item;
            if ($item->hasSubs()) {
                $tree[$item->id]['children'] = makeTree($item->getSubs());
            } else {
                if ($item->slug == 'vorur') {
                    // Ef þetta er "vörur" síðan... þá sækja vörudæmið
                    $categories = \App\Category::where('parent_id', 0)->where('status', 1)->orderBy('order')->get();
                    $tree[$item->id]['children'] = makeTree($categories);
                }
            }
        }
    }
    return $tree;
}