/**
  * Moves this node to the position of first child of the node $node.
  * @since 0.1.5
  * @param $node The node to be parent
  * @return false if insert failed, true if success
  */
 function move_to_first_child_of(&$node)
 {
     if ($this->orphan) {
         return $this->insert_as_first_child_of($node);
     }
     if ($this->lft != 1 || $node->orphan || $node->instance->tree_table != $this->instance->tree_table) {
         return false;
     }
     if ($ret = $this->instance->move_node_append($this->lft, $node->lft)) {
         list($this->lft, $this->rgt) = $ret;
         $this->parent =& $node;
         if ($this->parent->children != null) {
             // check if parent already has data
             array_unshift_ref($this->parent->children, $this);
         }
         return true;
     }
     return false;
 }
Пример #2
0
 function open($parser, $tag, $attributes)
 {
     #echo "Opening tag $tag<br>\n";
     $this->data = "";
     $this->last_opened_tag = $tag;
     #tag is a string
     if (array_key_exists($tag, $this->parent)) {
         #echo "There's already an instance of '$tag' at the current level ($level)<br>\n";
         if (is_array($this->parent[$tag]) and array_key_exists(0, $this->parent[$tag])) {
             #if the keys are numeric
             #need to make sure they're numeric (account for attributes)
             $key = count_numeric_items($this->parent[$tag]);
             #echo "There are $key instances: the keys are numeric.<br>\n";
         } else {
             #echo "There is only one instance. Shifting everything around<br>\n";
             $temp =& $this->parent[$tag];
             unset($this->parent[$tag]);
             $this->parent[$tag][0] =& $temp;
             if (array_key_exists("{$tag} attr", $this->parent)) {
                 #shift the attributes around too if they exist
                 $temp =& $this->parent["{$tag} attr"];
                 unset($this->parent["{$tag} attr"]);
                 $this->parent[$tag]["0 attr"] =& $temp;
             }
             $key = 1;
         }
         $this->parent =& $this->parent[$tag];
     } else {
         $key = $tag;
     }
     if ($attributes) {
         $this->parent["{$key} attr"] = $attributes;
     }
     $this->parent[$key] = array();
     $this->parent =& $this->parent[$key];
     // array_unshift($this->parents, &$this->parent);
     /* Fix - this needs to be unshifted by reference */
     array_unshift_ref($this->parents, $this->parent);
 }