/**
  * Gets a site tree for the provided node
  * @param \ride\library\cms\node\Node $node Selected node of the tree
  * @param string $locale Locale for the tree
  * @return TreeNode Tree Node for the site of the provided node
  */
 public function getTree(Node $node, $locale)
 {
     $this->locale = $locale;
     $this->node = $node;
     $this->nodeId = $node->getId();
     if ($this->nodeId) {
         $this->rootNodeId = $node->getRootNodeId();
     } else {
         $parentNode = $node->getParentNode();
         if ($parentNode) {
             $this->rootNodeId = $parentNode->getRootNodeId();
         } else {
             return;
         }
     }
     $site = $this->cms->getNode($this->rootNodeId, $node->getRevision(), $this->rootNodeId, null, true);
     $onlyCurrentLocale = $site->isLocalizationMethodUnique();
     return $this->getTreeNode($site, $onlyCurrentLocale);
 }
 /**
  * Gets the available locales options
  * @param \ride\library\cms\node\Node $node
  * @param \ride\library\i18n\translator\Translator $translator
  * @param array $locales
  * @return array Array with the publish code as key and the translation as
  * value
  */
 protected function getLocalesOptions(Node $node, Translator $translator, array $locales)
 {
     $options = array();
     $parentNode = $node->getParentNode();
     if ($parentNode) {
         $inheritedValue = $parentNode->get(Node::PROPERTY_LOCALES, Node::LOCALES_ALL, true, true);
         $options[self::OPTION_INHERITED] = $translator->translate('label.inherited') . ' (' . $inheritedValue . ')';
     }
     $options[Node::LOCALES_ALL] = $translator->translate('label.locales.all');
     foreach ($locales as $locale) {
         $options[$locale] = $translator->translate('language.' . $locale);
     }
     return $options;
 }
Ejemplo n.º 3
0
 /**
  * Gets the breadcrumbs of a node
  * @param \ride\library\cms\node\Node $node
  * @param string $baseScript Base script for the node routes
  * @param string $locale Code of the locale
  * @return array Array with the URL as key and the node name as value
  */
 public function getBreadcrumbsForNode(Node $node, $baseScript, $locale)
 {
     $urls = array();
     if (!$node->hideInBreadcrumbs()) {
         $urls[$baseScript . $node->getRoute($locale)] = $node->getName($locale, 'breadcrumb');
     }
     $parent = $node->getParentNode();
     while ($parent) {
         $nodeType = $this->nodeTypeManager->getNodeType($parent->getType());
         if (($nodeType->getFrontendCallback() || $parent->getLevel() === 0) && !$parent->hideInBreadcrumbs()) {
             $url = $baseScript . $parent->getRoute($locale);
             $urls[$url] = $parent->getName($locale, 'breadcrumb');
         }
         $parent = $parent->getParentNode();
     }
     $urls = array_reverse($urls, true);
     return $urls;
 }
 /**
  * Gets the security options
  * @param \ride\library\cms\node\Node $node
  * @param \ride\library\i18n\translator\Translator $translator
  * @return array Array with the publish code as key and the translation as
  * value
  */
 protected function getSecurityOptions(Node $node, Translator $translator)
 {
     $options = array();
     $parentNode = $node->getParentNode();
     if ($parentNode) {
         $options['inherit'] = $translator->translate('label.inherited') . $this->getSecurityInheritSuffix($parentNode, $translator);
     }
     $options[Node::AUTHENTICATION_STATUS_EVERYBODY] = $translator->translate('label.allow.everybody');
     $options[Node::AUTHENTICATION_STATUS_ANONYMOUS] = $translator->translate('label.allow.anonymous');
     $options[Node::AUTHENTICATION_STATUS_AUTHENTICATED] = $translator->translate('label.allow.authenticated');
     return $options;
 }
 /**
  * Gets the cache options
  * @param \ride\library\cms\node\Node $node
  * @param \ride\library\i18n\translator\Translator $translator
  * @return array Array with the cache code as key and the translation as
  * value
  */
 protected function getCacheOptions(Node $node, Translator $translator, $locale)
 {
     $options = array();
     $parentNode = $node->getParentNode();
     if ($parentNode) {
         $options['inherit'] = $translator->translate('label.inherited') . $this->getInheritedCacheOption($parentNode, $translator, $locale);
     }
     $options['none'] = $translator->translate('label.cache.target.none');
     $options['intermediate'] = $translator->translate('label.cache.target.intermediate');
     $options['all'] = $translator->translate('label.cache.target.all');
     return $options;
 }
 /**
  * Get a HTML representation of a Node instance
  * @param \ride\library\cms\node\Node $node
  * @return string HTML representation of the Node
  */
 protected function getHtmlFromNode(Node $node)
 {
     $properties = array();
     $parentNode = $node->getParentNode();
     while ($parentNode) {
         $parentProperties = $parentNode->getProperties();
         foreach ($parentProperties as $key => $property) {
             if ($property->getInherit() && !isset($properties[$key])) {
                 $properties[$key] = $property;
             }
         }
         $parentNode = $parentNode->getParentNode();
     }
     $nodeProperties = $node->getProperties();
     $properties = $nodeProperties + $properties;
     ksort($properties);
     $html = '';
     foreach ($properties as $key => $property) {
         $value = $property->getIniString(true);
         if ($property->getInherit()) {
             $value = substr($value, 1);
         }
         if (isset($nodeProperties[$key])) {
             $html .= '<strong>' . $value . '</strong>';
         } else {
             $html .= $value;
         }
         $html .= "<br />\n";
     }
     return $html;
 }