예제 #1
0
 /**
  * Retrieves the data for the node $node from the data store and assigns it
  * to the node's 'data' property.
  *
  * @param ezcTreeNode $node
  */
 public function fetchDataForNode(ezcTreeNode $node)
 {
     $id = $node->id;
     $elem = $this->dom->getElementById("{$node->tree->prefix}{$id}");
     $dataElem = $elem->getElementsByTagNameNS('http://components.ez.no/Tree/data', 'data')->item(0);
     if ($dataElem === null || (string) $dataElem->parentNode->getAttribute('id') !== "{$node->tree->prefix}{$id}") {
         throw new ezcTreeDataStoreMissingDataException($node->id);
     }
     $node->injectData($dataElem->firstChild->data);
     $node->dataFetched = true;
 }
예제 #2
0
파일: copy_tree.php 프로젝트: bmdevel/ezc
 private function addChildren(ezcTreeNode $node, array $children)
 {
     foreach ($children as $name => $child) {
         if (is_array($child)) {
             $newNode = $node->tree->createNode($name, $name);
             $node->addChild($newNode);
             $this->addChildren($newNode, $child);
         } else {
             $newNode = $node->tree->createNode($child, $child);
             $node->addChild($newNode);
         }
     }
 }
예제 #3
0
 /**
  * Copies all the children of node $fromNode to node $toNode recursively.
  *
  * This method copies all children recursively from $fromNode to $toNode.
  * The $fromNode belongs to the $from tree and the $toNode to the $to tree.
  * Data associated with the nodes is copied as well from the store
  * associated with the $from tree to the $to tree.
  *
  * @param ezcTree $from
  * @param ezcTree $to
  * @param ezcTreeNode $fromNode
  * @param ezcTreeNode $toNode
  */
 private static function copyChildren(ezcTree $from, ezcTree $to, ezcTreeNode $fromNode, ezcTreeNode $toNode)
 {
     $children = $fromNode->fetchChildren();
     foreach (new ezcTreeNodeListIterator($from, $children, true) as $childNodeKey => $childNodeData) {
         $fromChildNode = $from->fetchNodeById($childNodeKey);
         $toChildNode = new ezcTreeNode($to, $childNodeKey, $childNodeData);
         $toNode->addChild($toChildNode);
         self::copyChildren($from, $to, $fromChildNode, $toChildNode);
     }
 }
예제 #4
0
 /**
  * Retrieves the data for the node $node from the data store and assigns it
  * to the node's 'data' property.
  *
  * @param ezcTreeNode $node
  */
 public function fetchDataForNode(ezcTreeNode $node)
 {
     $db = $this->dbHandler;
     $q = $db->createSelectQuery();
     $id = $node->id;
     $q->select('*')->from($db->quoteIdentifier($this->table))->where($q->expr->eq($db->quoteIdentifier($this->idField), $q->bindValue($id)));
     $s = $q->prepare();
     $s->execute();
     $result = $s->fetch(PDO::FETCH_ASSOC);
     if (!$result) {
         throw new ezcTreeDataStoreMissingDataException($node->id);
     }
     $node->injectData($this->filterDataFromResult($result));
     $node->dataFetched = true;
 }