public function admin() { // $category = D ( 'Category' ); // $data = $category->select(); // load('@.tree'); // $data = getTree( $data ); // $this->assign ( 'data', $data ); // $this->display( 'admin' ); import ('ORG.Util.Page'); $cate = D('Category'); $count = $cate->count(); $page = new Page ($count, 11); $page->setConfig('header', '个分类'); $show = $page->show(); $this->assign('show', $show); $data = $cate->select(); // 加载函数文件 load ( '@.tree' ); // 生成树状结构 $data = getTree ( $data ); // 截取之后的数组 $list = array_slice ( $data, $page->firstRow, $page->listRows ); // 分配数组数据 $this->assign ( 'data', $list ); // 显示模板 $this->display ( 'admin' ); }
function getTree($parentid, &$array_cat, $separator = "") { global $mainframe, $option; $order = ''; $filter_order = $mainframe->getUserStateFromRequest($option . 'filter_order', 'filter_order', '', 'cmd'); $filter_order_Dir = $mainframe->getUserStateFromRequest($option . 'filter_order_Dir', 'filter_order_Dir', '', 'word'); // ensure we have a valid value for filter_order if (!in_array($filter_order, array('ordering', 'id', 'parentid', 'name'))) { $filter_order = 'parentid'; } if ($filter_order == 'ordering') { $order = ' ORDER BY parentid,ordering,name ' . $filter_order_Dir; } elseif ($filter_order == 'name') { $order = ' ORDER BY parentid,name ' . $filter_order_Dir; } else { $order = ' ORDER BY parentid, id DESC '; } $db =& JFactory::getDBO(); $query = ' SELECT id, parentid, name, ordering, published FROM #__w_categories ' . ' WHERE parentid = ' . $parentid . ' ' . $order; $db->setQuery($query); $cats = $db->loadObjectList(); if ($cats == NULL) { return NULL; } else { $i = 1; foreach ($cats as $cat) { $cat->name_display = $separator . $i . ". " . $cat->name; $cat->parent[$i] = $cat->name; $array_cat[] = $cat; getTree($cat->id, $array_cat, " " . $separator . $i . "."); $i++; } } }
function oui_prefs_cat_article_list($name, $val) { $rs = getTree('root', 'article', "title != 'default' ORDER BY id, title"); if ($rs) { return treeSelectInput($name, $rs, $val); } return gtxt('no_categories_exist'); }
function oui_prefs_category_list($name, $val) { $rs = getTree('root', ''); if ($rs) { return treeSelectInput($name, $rs, $val); } return gtxt('no_categories_exist'); }
/** * edit data page * @param int id * @return view */ public function edit($id) { $categoryData = Category::get(); $ids = getChild($categoryData, $id); $ids[] = $id; $category = getTree($categoryData); $info = Category::findOrFail($id); return view('admin.category.edit', compact('ids', 'category', 'info')); }
function linkcategory_popup($cat = "") { $arr = array(''); $rs = getTree("root", "link"); if ($rs) { return treeSelectInput("category", $rs, $cat); } return false; }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { //获取商品类型 $type_list = Type::all(); //获取商品分类 $categoryData = Category::get(); $cate_list = getTree($categoryData); return view('admin.goods.create', compact('type_list', 'cate_list')); }
function getTree($parent = NULL) { $section = new Section(); $section->where('parent_section', $parent)->get(); $line = array(); foreach ($section as $item) { $children = getTree($item->id); $line[] = count($children) > 0 ? array('id' => $item->id, 'description' => $item->name, 'line' => $children) : array('id' => $item->id, 'description' => $item->name); } return $line; }
function getTree($data, $cid = 0) { static $tree = array(); foreach ( $data as $key => $value ) { if ($value ['cid'] == $cid) { $tree [] = $value; unset ($data [$key] ); getTree( $data, $value['id'] ); } } return $tree; }
function getTree($list, $parent_id = 0, $lev = 0) { static $tree = []; foreach ($list as $key => $value) { if ($value['parent_id'] == $parent_id) { $value['lev'] = $lev; $tree[] = $value; getTree($list, $value['id'], $lev + 1); } } return $tree; }
function getTree($arr, $pid = 0, $deep) { static $tree = array(); foreach ($arr as $row) { if ($row['parent_id'] == $pid) { $row['deep'] = $deep; $tree[] = $row; getTree($arr, $row['cat_id'], $deep + 1); } } return $tree; }
public function sidebar() { header("Content-type:text/html;charset=utf-8"); if (!access(C('FM_content'))) { $this->error(C('access_error')); return; } $Column = M('Column'); $columns = $Column->field('id,name,parentid,class,sort')->select(); // var_dump($columns); $this->assign('columns', getTree($columns)); $this->display(); }
function getTree($resultParents, $resultIds, $maxDepth, $id_category = 1, $currentDepth = 0) { global $link; $children = array(); if (isset($resultParents[$id_category]) and sizeof($resultParents[$id_category]) and ($maxDepth == 0 or $currentDepth < $maxDepth)) { foreach ($resultParents[$id_category] as $subcat) { $children[] = getTree($resultParents, $resultIds, $maxDepth, $subcat['id_category'], $currentDepth + 1); } } if (!isset($resultIds[$id_category])) { return false; } return array('id' => $id_category, 'name' => $resultIds[$id_category]['name'], 'children' => $children); }
function image_edit($message = '', $id = '') { if (!$id) { $id = gps('id'); } global $txpcfg, $img_dir; pagetop('image', $message); $categories = getTree("root", "image"); $rs = safe_row("*", "txp_image", "id='{$id}'"); if ($rs) { extract($rs); echo startTable('list'), tr(td('<img src="' . hu . $img_dir . '/' . $id . $ext . '" height="' . $h . '" width="' . $w . '" alt="" />' . br . upload_form(gTxt('replace_image'), 'replace_image_form', 'image_replace', 'image', $id))), tr(td(join('', array($thumbnail ? '<img src="' . hu . $img_dir . '/' . $id . 't' . $ext . '" alt="" />' . br : '', upload_form(gTxt('upload_thumbnail'), 'upload_thumbnail', 'thumbnail_insert', 'image', $id))))), function_exists("imagecreatefromjpeg") ? thumb_ui($id) : '', tr(td(form(graf(gTxt('image_name') . br . fInput('text', 'name', $name, 'edit')) . graf(gTxt('image_category') . br . treeSelectInput('category', $categories, $category)) . graf(gTxt('alt_text') . br . fInput('text', 'alt', $alt, 'edit', '', '', 50)) . graf(gTxt('caption') . br . text_area('caption', '100', '400', $caption)) . graf(fInput('submit', '', gTxt('save'), 'publish')) . hInput('id', $id) . eInput('image') . sInput('image_save')))), endTable(); } }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { //获取当前角色的信息 $role = Models\Role::find($id); //获取当前角色所拥有的权限的ID $nowAuths = array(); foreach ($role->auths as $auth) { $nowAuths[] = $auth->id; } //获取所有权限的信息 $auths = Models\Auth::getAuth(); $auths = getTree($auths); return view('admin.role.edit', compact('role', 'auths', 'nowAuths')); }
function getTree(&$data, $pid = 0, $count = 1) { if (!isset($data['odl'])) { $data = array('new' => array(), 'odl' => $data); } foreach ($data['odl'] as $k => $v) { if ($v['pid'] == $pid) { $v['level'] = $count; $data['new'][] = $v; unset($data['odl'][$k]); getTree($data, $v['id'], $count + 1); } } return $data['new']; }
function getTree($kat_id, $pic_id) { include '../../share/global_config.php'; include $sr . '/bin/share/db_connect1.php'; $result2 = mysql_query("SELECT kat_id, kategorie FROM {$table4} WHERE parent='" . $kat_id . "' ORDER BY kategorie"); while ($einzeln = @mysql_fetch_assoc($result2)) { if (hasChildKats($einzeln['kat_id'], $pic_id)) { $KA = $einzeln['kat_id']; $result3 = mysql_query("DELETE FROM {$table10} WHERE pic_id = '{$pic_id}' AND kat_id = '{$KA}'"); $KAE = getTree($einzeln['kat_id'], $pic_id); } else { $KA = $einzeln['kat_id']; $result4 = mysql_query("DELETE FROM {$table10} WHERE pic_id = '{$pic_id}' AND kat_id = '{$KA}'"); } } }
function getTree($nodes) { $nodeHtml = '<ul>'; foreach ($nodes as $node) { $id = $node['id']; $icon = $node['type'] === 'field' ? 'jstree-file' : 'jstree-folder'; $nodeHtml .= '<li id="' . $id . '" data-jstree=\'{"icon":"' . $icon . '"}\'>'; $nodeHtml .= $node['label']; if (count($node['field_definitions']) > 0) { $nodeHtml .= getTree($node['field_definitions']); } $nodeHtml .= '</li>'; } $nodeHtml .= '</ul>'; return $nodeHtml; }
function getTree($parentID, $level) { global $config; $childCount = 0; $cCounter = 1; if ($children = findChildren($parentID)) { $childCount = count($children); $cCounter = 1; foreach ($children as $value) { for ($x = 0; $x < $level; $x++) { //echo " "; } $galleryNameText = $_SESSION['galleriesData'][$value]['name']; //$galleryNameText = str_replace("'",'\'',$galleryNameText); //$galleryNameText = str_replace('"','"',$galleryNameText); $galleryNameText = str_replace('\\', '', $galleryNameText); $galleryNameText = htmlspecialchars($galleryNameText); // New in 4.4.7 /* $galleryNameText = str_replace('(','',$galleryNameText); $galleryNameText = str_replace(')','',$galleryNameText); $galleryNameText = str_replace('/','',$galleryNameText); $galleryNameText = str_replace(')','',$galleryNameText); */ //$galleryNameText = cleanString($galleryNameText); if ($config['settings']['gallery_count'] and $_SESSION['galleriesData'][$value]['gallery_count']) { $galleryNameText .= " (" . $_SESSION['galleriesData'][$value]['gallery_count'] . ")"; } if ($_SESSION['galleriesData'][$value]['password']) { $galleryNameText .= " <span class='treeLock'> </span>"; } $linkto = $_SESSION['galleriesData'][$value]['linkto']; echo "{ \r\n\t\t\t\t\t\"attr\" : { \"id\" : \"galleryTree{$value}\" }, \r\n\t\t\t\t\t\"data\" : { \r\n\t\t\t\t\t\t\"title\" : \"{$galleryNameText}\", \r\n\t\t\t\t\t\t\"level\" : \"{$level}\", \r\n\t\t\t\t\t\t\"attr\" : { \"href\" : \"{$linkto}\" }, \r\n\t\t\t\t\t\t\"icon\" : \"\" \r\n\t\t\t\t\t},\r\n\t\t\t\t\t\"children\" : [ "; if ($value) { getTree($value, $level + 1); } echo " ]"; // ,\"state\" : \"closed\" echo "}"; //echo "<br /><br />"; // For testing if ($cCounter < $childCount) { echo ","; } $cCounter++; } } }
/** * Fiddle with the article's category selects */ function wet_article_partial_category_1($rs) { static $cats = null; if ($cats == null) { $cats = getTree('root', 'article'); } // Make radio buttons, not drop-downs $out = array(); if ($cats) { foreach ($cats as $c) { $c = doSpecial($c); $id = 'wet_cat-' . $c['name']; $out[] = radio('Category1', $c['name'], $rs['Category1'] == $c['name'] ? '1' : '', 'cat-' . $c['name']) . "<label for='{$id}'>{$c['title']}</label>"; } } return '<ul class="plain-list"><li>' . join('</li><li>', $out) . '</li></ul>'; }
function getTree($data, $pId) { $html = ''; foreach ($data as $k => $v) { $url = $v['menu_url'] . "?menuid={$v['menu_id']}"; if ($v['menu_pid'] == $pId) { if ($v['menu_pid'] != 0) { $html .= "<li><a href='{$url}' target='main'>" . $v['menu_name']; } else { $html .= "<li><a href='{$url}' target='main'>" . $v['menu_name']; } $html .= "</a></li>"; $html .= getTree($data, $v['menu_id']); } } return $html ? '<ul>' . $html . '</ul>' : $html; }
function getChildAverage($ips) { $rs = $GLOBALS['db']->query("select id from tree where ip='{$ips}'"); $row = $rs->fetch_array(); $ips = $row['id']; $ips = getTree($ips); $ips = implode("','", $ips); $ips = "'" . $ips . "'"; $mma = array("min" => "", "max" => "", "avg" => "", "ploss" => ""); $rs = $GLOBALS['db']->query("select MIN(mi),MAX(mx),AVG(av),AVG(pl) from clink_status where ip in (" . $ips . ")"); while ($row = $rs->fetch_array()) { $mma['min'] = round($row[0], 2); $mma['max'] = round($row[1], 2); $mma['avg'] = round($row[2], 2); $mma['ploss'] = round($row[3], 2); } return $mma; }
function getLists() { $lists = array(); if (!isset($this->_published)) { $this->_published = 1; } $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $this->_published); // get category $catgories = array(); getTree(0, $catgories, ""); foreach ($catgories as $result) { if ($this->_id != $result->id) { $category[] = array('value' => $result->id, 'text' => $result->name_display); } } array_unshift($category, array('value' => 0, 'text' => ' 0.Root')); $lists['category'] = JHTML::_('select.genericlist', $category, 'parentid', 'class="inputbox" ' . '', 'value', 'text', $this->_parentid); return $lists; }
function hookDisplay() { $result = Db::getInstance()->ExecuteS(' SELECT id_category,name,id_parent FROM `' . _DB_PREFIX_ . 'category` ORDER BY `position` ASC'); if (!$result) { return; } $resultParents = array(); $resultIds = array(); foreach ($result as &$row) { $resultParents[$row['id_parent']][] =& $row; $resultIds[$row['id_category']] =& $row; } $blockCategTree = getTree($resultParents, $resultIds); unset($resultParents); unset($resultIds); return $blockCategTree; }
function gen_list_Select($list_id, $selectName = '', $list_item_id = 0) { $items = CM('cm_list_item')->where('list_id=' . $list_id)->select(); $cm_list = CM('cm_list')->where('list_id=' . $list_id)->find(); $items = getTree($items); $str = ''; $str .= '<select name="' . $selectName . '">'; $str .= '<option value="0">---选择' . $cm_list['list_desc'] . '---</option>'; foreach ($items as $key => $row) { $checked = ''; if ($row['list_item_id'] == $list_item_id) { $checked = 'selected="true"'; } $deepStr = ''; $deepStr = str_repeat('| ', $row['deep'] - 1); $str .= '<option ' . $checked . ' value="' . $row['list_item_id'] . '">' . $deepStr . $row['item_desc'] . '</option>'; } $str .= '</select>'; return $str; }
function getTree($parentId = null, $showHidden = false, $maxDepth = 0, $path = '', $depth = 1, &$items = array()) { if ($maxDepth && $depth > $maxDepth) { return array(); } $parentId = getID($parentId); $q = null; \cf\createStaticQuery($q, "\n\t\tSELECT id, IFNULL(code,id) AS code, parent_id, name, menu_name, icon, short_txt, link, hidden, sort_order, title, keywords, descr\n\t\tFROM cf_page\n\t\tWHERE (parent_id=:parentId OR (:parentId IS NULL AND parent_id IS NULL))\n\t\t\t" . ($showHidden ? '' : 'AND (hidden IS NULL OR hidden=0)') . "\n\t\tORDER BY sort_order ASC\n\t"); $pages = \cf\query2arrays($q, array('parentId' => $parentId), false, 'id'); foreach ($pages as $id => $page) { $item = array('' => $page); $item['']['depth'] = $depth; $item['']['path'] = $path . '/' . $page['code']; if (!$item['']['link']) { $item['']['link'] = $item['']['path']; } getTree($id, $showHidden, $maxDepth, $item['']['path'], $depth + 1, $item); $items[$page['menu_name']] = $item; } return $items; }
public function add() { if (IS_POST) { $model = D('NoticeClass'); if ($model->create()) { $result = $model->add(); if ($result) { $this->success('添加成功', U('index')); } else { $this->error('添加失败' . $model->getDbError()); } } else { $this->error('添加失败' . $model->getError()); } } else { $list = M('NoticeClass')->order('sort desc,id asc')->select(); $list = getTree($list); $this->assign(array('list' => $list)); $this->display(); } }
public function edit($id) { $model = D('Article'); if (IS_POST) { if ($model->create()) { $result = $model->save(); if ($result !== false) { $this->success('跟新成功', U('index')); } else { $this->error('跟新失败' . $model->getDbError(), __SELF__); } } else { $this->error('跟新失败' . $model->getError(), U('index')); } } else { $id = I('get.id', 0, 'intval'); $data = $model->find($id); $list = M('ArticleClass')->order('pid asc,sort desc,id asc')->select(); $list = getTree($list); $this->assign(array('data' => $data, 'classlist' => $list)); $this->display(); } }
function getTree($id, $level, $alias) { $base = StaticPages::model()->findAll('parent=' . $id); if (count($base) > 0) { $s_text = ''; for ($i = 0; $i < $level; $i++) { $s_text .= "|—"; } foreach ($base as $item) { if ($item->iscat == 0) { echo '<tr><td>' . $s_text . '<a href="' . Yii::app()->createUrl("/core/static/edit", array("id" => $item->id)) . '">' . $item->header . '</a> <span style="color:gray">(<a href="' . Yii::app()->params['frontendUrl'] . '/' . $item->id . '-' . urlencode($item->alias) . '" target="_blank" style="color:gray">открыть на сайте</a>)</span></td>'; } else { echo '<tr><td>' . $s_text . '<a href="' . Yii::app()->createUrl("/core/static/edit", array("id" => $item->id)) . '" style="color:#000">' . $item->header . '</a></td>'; } if ($item->candelete == 0) { echo '<td><a href="' . Yii::app()->createUrl("/core/static/delete", array("id" => $item->id)) . '" onClick="return confirm(\'Are you sure you want to delete this page?\\nAll children of a parent to change the item up.\');">Удалить</a></td>'; } else { echo '<td></td>'; } echo ' </tr> '; getTree($item->id, $level + 1, $alias . "/" . $item->alias); } } }
function getTree($tree, $smarty) { $excludeTags = array('shopsection'); $output = '<ul id="tree_top">'; if ($tree instanceof DOMDocument) { $output .= '<li class="new">'; $output .= '<a href="/?module=system_admin&controller=permissions&action=new&parent_id=">[New Permission]</a>'; $output .= '</li>'; } if ($tree->hasChildNodes()) { $nodes = $tree->childNodes; foreach ($nodes as $node) { if (!$node instanceof DOMText && !in_array($node->tagName, $excludeTags)) { $id = $node->getAttribute('id'); $permission = new Permission(); $permission->load($id); $output .= '<li class="drag ' . strtolower($permission->getFormatted('type')) . '" id="treeitem_' . $node->tagName . '-' . $id . '-' . $permission->type . '-' . $permission->parent_id . '">'; if ($permission->display == 't') { $output .= '<img src="' . THEME_URL . THEME . '/graphics/true.png" />'; } else { $output .= '<img src="' . THEME_URL . THEME . '/graphics/false.png" />'; } $output .= $permission->permission . ' - ' . $permission->title; $output .= '<a href="/?module=system_admin&controller=permissions&action=new&parent_id=' . $id . '">[New]</a> - '; $output .= '<a href="/?module=system_admin&controller=permissions&action=view&id=' . $id . '">[View]</a> - '; $output .= '<a href="/?module=system_admin&controller=permissions&action=edit&id=' . $id . '">[Edit]</a> - '; $output .= '<a href="/?module=system_admin&controller=permissions&action=delete&id=' . $id . '">[Delete]</a>'; $output .= '<span class="tree_info"> (Description: ' . $permission->description . ')</span>'; } $output .= getTree($node, $smarty); $output .= '</li>'; } } $output .= '</ul>'; return $output; }