Exemplo n.º 1
0
 /**
  * Returns current templates tree (JSON)
  *
  * @param \Includes\DataStructure\Graph $node Node
  *
  * @return array
  */
 public static function buildJsonTreeNode(\Includes\DataStructure\Graph $node)
 {
     $result = array();
     $children = $node->getChildren();
     if ($children) {
         /** @var \Includes\DataStructure\Graph $child */
         foreach ($children as $child) {
             $data = $child->getData();
             $label = $data->class ? sprintf('%s (%s)', $child->getKey(), $data->class) : $child->getKey();
             $result[] = array('id' => sprintf('template_%s', $data->templateId), 'text' => $label, 'state' => array('disabled' => $data->isList), 'li_attr' => array('data-template-id' => $data->templateId, 'data-template-path' => $child->getKey()), 'children' => static::buildJsonTreeNode($child));
         }
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Remove child node
  *
  * @param \Includes\DataStructure\Graph $node Node to remove
  *
  * @return void
  */
 public function removeChild(\Includes\DataStructure\Graph $node)
 {
     foreach ($this->getChildren() as $index => $child) {
         if ($node->getKey() === $child->getKey()) {
             $node->setParent(null);
         }
     }
     parent::removeChild($node);
 }
Exemplo n.º 3
0
 /**
  * Prepare and return error message
  *
  * @param string                        $code Error code (or message)
  * @param \Includes\DataStructure\Graph $node Node  Node caused the error OPTIONAL
  *
  * @return string
  */
 protected function prepareErrorMessage($code, \Includes\DataStructure\Graph $node = null)
 {
     return $code . ' (' . $this->getKey() . ($node ? ', ' . $node->getKey() : '') . ')';
 }
Exemplo n.º 4
0
 /**
  * For additional info
  *
  * @param self $node Current node
  *
  * @return string
  */
 protected function drawAdditional(self $node)
 {
     $result = parent::drawAdditional($node);
     if ($node->getParentClass()) {
         $result .= ' <i>(' . $node->getParentClass() . ')</i>';
     }
     return $result;
 }
Exemplo n.º 5
0
 /**
  * For additional info
  *
  * @param \Includes\DataStructure\Graph $node Current node
  *
  * @return string
  */
 protected function drawAdditional(\Includes\DataStructure\Graph $node)
 {
     $result = parent::drawAdditional($node);
     if ($node->getParentClass()) {
         $result .= ' <i>(' . $node->getParentClass() . ')</i>';
     }
     return $result;
 }
Exemplo n.º 6
0
 /**
  * Prepare and return error message
  *
  * @param string $code Error code (or message)
  * @param self   $node Node  Node caused the error OPTIONAL
  *
  * @return string
  */
 protected function prepareErrorMessage($code, self $node = null)
 {
     return $code . ' (' . $this->getKey() . ($node ? ', ' . $node->getKey() : '') . ')';
 }