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


PHP Node::removeChild方法代码示例

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


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

示例1: setParent

 /**
  * Sets the parent node.
  *
  * @param AbstractNode $parent
  * @chainable
  * @throws CircularException
  */
 public function setParent(AbstractNode $parent)
 {
     // check integrity
     if ($this->isDescendant($parent->id())) {
         throw new CircularException('Can not add descendant "' . $parent->id() . '" as my parent.');
     }
     // remove from old parent
     if (!is_null($this->parent)) {
         if ($this->parent->id() == $parent->id()) {
             // already the parent
             return $this;
         }
         $this->parent->removeChild($this->id);
     }
     $this->parent = $parent;
     // assign child to parent
     $this->parent->addChild($this);
     //clear any cache
     $this->clear();
     return $this;
 }
开发者ID:brjpeters,项目名称:php-html-parser,代码行数:28,代码来源:AbstractNode.php

示例2: groupNode

 /**
  * Recursively groups tree nodes given a separator
  *
  * @param Node $node The node to group
  *
  * @return void
  */
 public function groupNode($node)
 {
     if ($node->type != Node::CONTAINER || !$GLOBALS['cfg']['NavigationTreeEnableExpansion']) {
         return;
     }
     $separators = array();
     if (is_array($node->separator)) {
         $separators = $node->separator;
     } else {
         if (strlen($node->separator)) {
             $separators[] = $node->separator;
         }
     }
     $prefixes = array();
     if ($node->separator_depth > 0) {
         foreach ($node->children as $child) {
             $prefix_pos = false;
             foreach ($separators as $separator) {
                 $sep_pos = mb_strpos($child->name, $separator);
                 if ($sep_pos != false && $sep_pos != mb_strlen($child->name) && $sep_pos != 0 && ($prefix_pos == false || $sep_pos < $prefix_pos)) {
                     $prefix_pos = $sep_pos;
                 }
             }
             if ($prefix_pos !== false) {
                 $prefix = mb_substr($child->name, 0, $prefix_pos);
                 if (!isset($prefixes[$prefix])) {
                     $prefixes[$prefix] = 1;
                 } else {
                     $prefixes[$prefix]++;
                 }
             }
             //Bug #4375: Check if prefix is the name of a DB, to create a group.
             foreach ($node->children as $child) {
                 if (array_key_exists($child->name, $prefixes)) {
                     $prefixes[$child->name]++;
                 }
             }
         }
         //Check if prefix is the name of a DB, to create a group.
         foreach ($node->children as $child) {
             if (array_key_exists($child->name, $prefixes)) {
                 $prefixes[$child->name]++;
             }
         }
     }
     foreach ($prefixes as $key => $value) {
         if ($value == 1) {
             unset($prefixes[$key]);
         } else {
             if ($value > 500 && !$this->_largeGroupWarning) {
                 trigger_error(__('There are large item groups in navigation panel which ' . 'may affect the performance. Consider disabling item ' . 'grouping in the navigation panel.'), E_USER_WARNING);
                 $this->_largeGroupWarning = true;
             }
         }
     }
     if (count($prefixes)) {
         $groups = array();
         foreach ($prefixes as $key => $value) {
             $groups[$key] = new Node($key, Node::CONTAINER, true);
             $groups[$key]->separator = $node->separator;
             $groups[$key]->separator_depth = $node->separator_depth - 1;
             $groups[$key]->icon = PMA_Util::getImage('b_group.png');
             $groups[$key]->pos2 = $node->pos2;
             $groups[$key]->pos3 = $node->pos3;
             if ($node instanceof Node_Table_Container || $node instanceof Node_View_Container) {
                 $tblGroup = '&amp;tbl_group=' . urlencode($key);
                 $groups[$key]->links = array('text' => $node->links['text'] . $tblGroup, 'icon' => $node->links['icon'] . $tblGroup);
             }
             $node->addChild($groups[$key]);
             foreach ($separators as $separator) {
                 $separatorLength = strlen($separator);
                 // FIXME: this could be more efficient
                 foreach ($node->children as $child) {
                     $keySeparatorLength = mb_strlen($key) + $separatorLength;
                     $name_substring = mb_substr($child->name, 0, $keySeparatorLength);
                     if ($name_substring != $key . $separator && $child->name != $key || $child->type != Node::OBJECT) {
                         continue;
                     }
                     $class = get_class($child);
                     $new_child = PMA_NodeFactory::getInstance($class, mb_substr($child->name, $keySeparatorLength));
                     if ($new_child instanceof Node_Database && $child->getHiddenCount() > 0) {
                         $new_child->setHiddenCount($child->getHiddenCount());
                     }
                     $new_child->real_name = $child->real_name;
                     $new_child->icon = $child->icon;
                     $new_child->links = $child->links;
                     $new_child->pos2 = $child->pos2;
                     $new_child->pos3 = $child->pos3;
                     $groups[$key]->addChild($new_child);
                     foreach ($child->children as $elm) {
                         $new_child->addChild($elm);
                     }
                     $node->removeChild($child->name);
//.........这里部分代码省略.........
开发者ID:mercysmart,项目名称:naikelas,代码行数:101,代码来源:NavigationTree.class.php

示例3: groupNode

 /**
  * Recursively groups tree nodes given a sperarator
  *
  * @param Node $node The node to group
  *
  * @return void
  */
 public function groupNode($node)
 {
     if ($node->type == Node::CONTAINER) {
         $separators = array();
         if (is_array($node->separator)) {
             $separators = $node->separator;
         } else {
             if (strlen($node->separator)) {
                 $separators[] = $node->separator;
             }
         }
         $prefixes = array();
         if ($node->separator_depth > 0) {
             foreach ($node->children as $child) {
                 $prefix_pos = false;
                 foreach ($separators as $separator) {
                     $sep_pos = strpos($child->name, $separator);
                     if ($sep_pos != false && $sep_pos != strlen($child->name) && $sep_pos != 0 && ($prefix_pos == false || $sep_pos < $prefix_pos)) {
                         $prefix_pos = $sep_pos;
                     }
                 }
                 if ($prefix_pos !== false) {
                     $prefix = substr($child->name, 0, $prefix_pos);
                     if (!isset($prefixes[$prefix])) {
                         $prefixes[$prefix] = 1;
                     } else {
                         $prefixes[$prefix]++;
                     }
                 }
             }
         }
         foreach ($prefixes as $key => $value) {
             if ($value == 1) {
                 unset($prefixes[$key]);
             }
         }
         if (count($prefixes)) {
             $groups = array();
             foreach ($prefixes as $key => $value) {
                 $groups[$key] = new Node($key, Node::CONTAINER, true);
                 $groups[$key]->separator = $node->separator;
                 $groups[$key]->separator_depth = $node->separator_depth - 1;
                 $groups[$key]->icon = '';
                 if (in_array($GLOBALS['cfg']['TableNavigationLinksMode'], array('icons', 'both'))) {
                     $groups[$key]->icon = PMA_Util::getImage('b_group.png');
                 }
                 $groups[$key]->pos2 = $node->pos2;
                 $groups[$key]->pos3 = $node->pos3;
                 $node->addChild($groups[$key]);
                 foreach ($separators as $separator) {
                     // FIXME: this could be more efficient
                     foreach ($node->children as $child) {
                         $name_substring = substr($child->name, 0, strlen($key) + strlen($separator));
                         if ($name_substring == $key . $separator && $child->type == Node::OBJECT) {
                             $class = get_class($child);
                             $new_child = PMA_NodeFactory::getInstance($class, substr($child->name, strlen($key) + strlen($separator)));
                             $new_child->real_name = $child->real_name;
                             $new_child->icon = $child->icon;
                             $new_child->links = $child->links;
                             $new_child->pos2 = $child->pos2;
                             $new_child->pos3 = $child->pos3;
                             $groups[$key]->addChild($new_child);
                             foreach ($child->children as $elm) {
                                 $new_child->addChild($elm);
                             }
                             $node->removeChild($child->name);
                         }
                     }
                 }
             }
             foreach ($prefixes as $key => $value) {
                 $this->groupNode($groups[$key]);
                 $groups[$key]->classes = "navGroup";
             }
         }
     }
 }
开发者ID:GDantas05,项目名称:WorkSeries,代码行数:84,代码来源:NavigationTree.class.php

示例4: groupNode

 /**
  * Recursively groups tree nodes given a separator
  *
  * @param Node $node The node to group
  *
  * @return void
  */
 public function groupNode($node)
 {
     if ($node->type != Node::CONTAINER || $GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']) {
         return;
     }
     $separators = array();
     if (is_array($node->separator)) {
         $separators = $node->separator;
     } else {
         if (strlen($node->separator)) {
             $separators[] = $node->separator;
         }
     }
     $prefixes = array();
     if ($node->separator_depth > 0) {
         foreach ($node->children as $child) {
             $prefix_pos = false;
             foreach ($separators as $separator) {
                 $sep_pos = strpos($child->name, $separator);
                 if ($sep_pos != false && $sep_pos != strlen($child->name) && $sep_pos != 0 && ($prefix_pos == false || $sep_pos < $prefix_pos)) {
                     $prefix_pos = $sep_pos;
                 }
             }
             if ($prefix_pos !== false) {
                 $prefix = substr($child->name, 0, $prefix_pos);
                 if (!isset($prefixes[$prefix])) {
                     $prefixes[$prefix] = 1;
                 } else {
                     $prefixes[$prefix]++;
                 }
             }
             //Bug #4375: Check if prefix is the name of a DB, to create a group.
             foreach ($node->children as $child) {
                 if (array_key_exists($child->name, $prefixes)) {
                     $prefixes[$child->name]++;
                 }
             }
         }
         //Check if prefix is the name of a DB, to create a group.
         foreach ($node->children as $child) {
             if (array_key_exists($child->name, $prefixes)) {
                 $prefixes[$child->name]++;
             }
         }
     }
     foreach ($prefixes as $key => $value) {
         if ($value == 1) {
             unset($prefixes[$key]);
         }
     }
     if (count($prefixes)) {
         $groups = array();
         foreach ($prefixes as $key => $value) {
             $groups[$key] = new Node($key, Node::CONTAINER, true);
             $groups[$key]->separator = $node->separator;
             $groups[$key]->separator_depth = $node->separator_depth - 1;
             $groups[$key]->icon = '';
             if (PMA_Util::showIcons('TableNavigationLinksMode')) {
                 $groups[$key]->icon = PMA_Util::getImage('b_group.png');
             }
             $groups[$key]->pos2 = $node->pos2;
             $groups[$key]->pos3 = $node->pos3;
             if ($node instanceof Node_Table_Container || $node instanceof Node_View_Container) {
                 $tblGroup = '&amp;tbl_group=' . urlencode($key);
                 $groups[$key]->links = array('text' => $node->links['text'] . $tblGroup, 'icon' => $node->links['icon'] . $tblGroup);
             }
             $node->addChild($groups[$key]);
             foreach ($separators as $separator) {
                 // FIXME: this could be more efficient
                 foreach ($node->children as $child) {
                     $name_substring = substr($child->name, 0, strlen($key) + strlen($separator));
                     if ($name_substring != $key . $separator && $child->name != $key || $child->type != Node::OBJECT) {
                         continue;
                     }
                     $class = get_class($child);
                     $new_child = PMA_NodeFactory::getInstance($class, substr($child->name, strlen($key) + strlen($separator)));
                     $new_child->real_name = $child->real_name;
                     $new_child->icon = $child->icon;
                     $new_child->links = $child->links;
                     $new_child->pos2 = $child->pos2;
                     $new_child->pos3 = $child->pos3;
                     $groups[$key]->addChild($new_child);
                     foreach ($child->children as $elm) {
                         $new_child->addChild($elm);
                     }
                     $node->removeChild($child->name);
                 }
             }
         }
         foreach ($prefixes as $key => $value) {
             $this->groupNode($groups[$key]);
             $groups[$key]->classes = "navGroup";
         }
//.........这里部分代码省略.........
开发者ID:JaRomero95,项目名称:dwes,代码行数:101,代码来源:NavigationTree.class.php


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