当前位置: 首页>>代码示例>>PHP>>正文


PHP Tree::rebuild_tree方法代码示例

本文整理汇总了PHP中Tree::rebuild_tree方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::rebuild_tree方法的具体用法?PHP Tree::rebuild_tree怎么用?PHP Tree::rebuild_tree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tree的用法示例。


在下文中一共展示了Tree::rebuild_tree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 public function save($sample = FALSE)
 {
     if ($this->loaded === FALSE) {
         $this->save();
         $new_item = ORM::factory('navigation_item');
         $new_item->navigation_id = $this->id;
         $new_item->fk_site = $this->fk_site;
         $new_item->display_name = 'ROOT';
         $new_item->type = 'none';
         $new_item->data = 0;
         $new_item->local_parent = 0;
         $new_item->save();
         $this->root_id = $new_item->id;
         if ($sample) {
             $new_item->clear();
             $new_item->navigation_id = $this->id;
             $new_item->fk_site = $this->fk_site;
             $new_item->display_name = 'Sample list item';
             $new_item->type = 'none';
             $new_item->data = '';
             $new_item->local_parent = $navigation->root_id;
             $new_item->save();
             $new_item->clear();
             $new_item->navigation_id = $this->id;
             $new_item->fk_site = $this->fk_site;
             $new_item->display_name = 'Link to Home';
             $new_item->type = 'page';
             $new_item->data = 'home';
             $new_item->local_parent = $navigation->root_id;
             $new_item->save();
             $new_item->clear();
             $new_item->navigation_id = $this->id;
             $new_item->fk_site = $this->fk_site;
             $new_item->display_name = 'External Google Link';
             $new_item->type = 'url';
             $new_item->data = 'google.com';
             $new_item->local_parent = $navigation->root_id;
             $new_item->save();
             # Update left and right values
             Tree::rebuild_tree('navigation_item', $navigation->root_id, $this->fk_site, '1');
         }
     }
     return parent::save();
 }
开发者ID:plusjade,项目名称:plusjade,代码行数:44,代码来源:navigation.php

示例2: add

 public function add()
 {
     if (!$_POST) {
         die('Nothing Sent.');
     }
     $navigation = $this->get_parent('navigation');
     $_POST['data'] = empty($_POST['data']) ? '' : $_POST['data'];
     # if for any reason local_parent is null, just add to root.
     $_POST['local_parent'] = empty($_POST['local_parent']) ? $navigation->root_id : $_POST['local_parent'];
     $new_item = ORM::factory('navigation_item');
     $new_item->navigation_id = $this->pid;
     $new_item->fk_site = $this->site_id;
     $new_item->display_name = $_POST['item'];
     $new_item->type = $_POST['type'];
     $new_item->data = $_POST['data'];
     $new_item->local_parent = $_POST['local_parent'];
     $new_item->save();
     # Update left and right values
     Tree::rebuild_tree('navigation_item', $navigation->root_id, $this->site_id, '1');
     die("{$new_item->id}");
     # output to javascript
 }
开发者ID:plusjade,项目名称:plusjade,代码行数:22,代码来源:edit_navigation.php

示例3: rebuild_tree

 public static function rebuild_tree($model, $local_parent, $site_id, $left)
 {
     # the right value of this node is the left value + 1
     $right = $left + 1;
     $navigation_items = ORM::factory($model)->where(array('fk_site' => $site_id, 'local_parent' => $local_parent))->orderby('position', 'asc')->find_all();
     foreach ($navigation_items as $item) {
         # recursive function for each child of this node
         # $right is the current right value;
         # incremented by the rebuild_tree function
         $right = Tree::rebuild_tree($model, $item->id, $site_id, $right);
     }
     # we've got the left value, and now that we've processed
     # the children of this node we also know the right value
     $item = ORM::factory($model, $local_parent);
     $item->lft = $left;
     $item->rgt = $right;
     $item->save();
     # return the right value of this node + 1
     return $right + 1;
 }
开发者ID:plusjade,项目名称:plusjade,代码行数:20,代码来源:Tree.php


注:本文中的Tree::rebuild_tree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。