Esempio n. 1
0
 /**
  * Construct this view
  * @param joppa\model\Node $node the node which is to be rendered
  * @param string $title title of the site (optional)
  * @return null
  */
 public function __construct(Node $node, $title = null)
 {
     $theme = $node->getTheme();
     $template = $theme->getTemplate();
     parent::__construct(null, $template);
     $resourceHandler = new ThemedResourceHandler($theme->getName());
     $this->setResourceHandler($resourceHandler);
     $style = $theme->getStyle();
     if ($style) {
         $this->addStyle($style);
     }
     if ($title) {
         $this->setTitle($title);
         $this->setPageTitle($node->name);
     } else {
         $this->setTitle($node->name);
     }
     $localeSuffix = '.' . $node->dataLocale;
     $metaDescription = $node->settings->get(NodeSettingModel::SETTING_META_DESCRIPTION . $localeSuffix);
     if ($metaDescription) {
         $this->addMeta(new Meta(Meta::DESCRIPTION, $metaDescription));
     }
     $metaKeywords = $node->settings->get(NodeSettingModel::SETTING_META_KEYWORDS . $localeSuffix);
     if ($metaKeywords) {
         $this->addMeta(new Meta(Meta::KEYWORDS, $metaKeywords));
     }
     $this->node = $node;
 }
Esempio n. 2
0
 /**
  * Construct the dispatcher
  * @param joppa\model\Node $node
  * @param joppa\view\frontend\NodeView $nodeView
  * @return null
  */
 public function __construct(Node $node, NodeView $nodeView)
 {
     $this->node = $node;
     $this->nodeView = $nodeView;
     $this->widgetDispatcher = new WidgetDispatcher();
     $this->regions = $node->getTheme()->getRegions();
     foreach ($this->regions as $regionName => $region) {
         $this->regions[$regionName] = $node->getWidgets($regionName);
     }
 }
 /**
  * Get all the node settings for all the children of the provided node (recursively).
  * @param Node $node
  * @return array Array with NodeSetting objects
  */
 public function getAllNodeSettingsForNode(Node $node, $condition = null, $order = null, array $variables = null)
 {
     $path = $node->getPath();
     $query = $this->createQuery(0);
     $query->addCondition('{node.id} = %1% OR {node.parent} = %2% OR {node.parent} LIKE %3%', $node->id, $path, $path . NodeModel::PATH_SEPARATOR . '%');
     if ($condition) {
         $query->addConditionWithVariables($condition, $variables);
     }
     if ($order) {
         $query->addOrderByWithVariables($order, $variables);
     }
     return $query->query();
 }
Esempio n. 4
0
 /**
  * Construct a new Joppa request
  * @param string $baseUrl the base url of the request
  * @param joppa\model\Node $node The node of this request
  * @param string $controllerName the full name of the controller class (including namespace)
  * @param string $actionName the action method in the controller class
  * @param array $parameters an array containing the parameters for the action method
  * @return null
  */
 public function __construct($baseUrl, Node $node, $controllerName, $actionName, array $parameters)
 {
     $basePath = $baseUrl . Request::QUERY_SEPARATOR . $node->getRoute();
     parent::__construct($baseUrl, $basePath, $controllerName, $actionName, $parameters);
     $this->setNode($node);
 }
Esempio n. 5
0
 /**
  * Get the HTML of a node
  * @param joppa\model\Node $node the node to render
  * @param int $defaultNodeId id of the node of the default page
  * @param joppa\model\Node $selectedNode the current node in the ui
  * @param boolean $addUnlocalizedClass Set to true to add the unlocalized class to nodes which are not localized in the current locale
  * @param int $truncateSize number of characters to truncate the name to
  * @return string HTML representation of the node
  */
 private function getNodeHtml(Node $node, $defaultNodeId, $addUnlocalizedClass, Node $selectedNode = null, $truncateSize = 20)
 {
     $isNodeSelected = false;
     if ($selectedNode && $selectedNode->id == $node->id) {
         $isNodeSelected = true;
     }
     $nodeClass = 'node';
     if ($isNodeSelected) {
         $nodeClass .= ' selected';
     }
     if ($addUnlocalizedClass) {
         if ($node->dataLocale != $this->locale) {
             $nodeClass .= ' unlocalized';
         } else {
             $nodeClass .= ' localized';
         }
     }
     if (AjaxTreeController::isNodeCollapsed($node->id)) {
         $nodeClass .= ' closed';
     }
     $html = '<li class="' . $nodeClass . '" id="node_' . $node->id . '">';
     if ($this->nodeTypeFacade->isAvailableInFrontend($node->type)) {
         if ($node->isSecured()) {
             $nodeClass = 'secured' . ucfirst($node->type);
         } else {
             $nodeClass = $node->type;
         }
         if ($node->id == $defaultNodeId) {
             $nodeClass .= 'Default';
         }
         if (!$node->isPublished()) {
             $nodeClass .= 'Hidden';
         }
     } else {
         $nodeClass = $node->type;
     }
     if ($node->children) {
         $html .= '<a href="#" class="toggle"></a>';
     } else {
         $html .= '<span class="toggle"></span>';
     }
     $icon = new Image($this->getIcon($nodeClass));
     $html .= '<div class="handle ' . $nodeClass . '">';
     $html .= $icon->getHtml();
     $html .= '</div>';
     $html .= '<div class="menu">';
     $html .= $this->getAnchorHtml('/node/' . $node->id, String::truncate($node->name, $truncateSize, '...', true, true), false, 'name', null, $node->name);
     $html .= $this->getAnchorHtml('#', ' ', false, 'actionMenuNode', 'nodeActions_' . $node->id);
     //        $html .= $this->getAnchorHtml(' <a href="#" class="actionMenuNode" id="nodeActions_' . $node->id . '" title="' . $node->name . '"></a>';
     //        $html .= ' <a href="#" class="actionMenuNode" id="nodeActions_' . $node->id . '" title="' . $node->name . '"></a>';
     $html .= '<ul class="actions" id="nodeActions_' . $node->id . 'Menu">';
     $addedActions = false;
     foreach ($this->actions as $action) {
         if (!$action->isAvailableForNode($node)) {
             continue;
         }
         $addedActions = true;
         $html .= '<li>';
         $html .= $this->getAnchorHtml('/node/' . $action->getRoute() . '/' . $node->id, $action->getLabel($this->translator), false, $action->getRoute());
         $html .= '</li>';
     }
     $html .= '<li' . ($addedActions ? ' class="separator"' : '') . '>' . $this->getAnchorHtml('/node/edit/' . $node->id, 'button.edit', true, 'edit') . '</li>';
     $html .= '<li>' . $this->getAnchorHtml('/node/copy/' . $node->id, 'joppa.button.copy', true, 'copy') . '</li>';
     $html .= '<li>' . $this->getAnchorHtml('/node/delete/' . $node->id, 'button.delete', true, 'delete confirm') . '</li>';
     $html .= '</ul>';
     $html .= '</div>';
     if ($node->children) {
         $html .= '<ul class="children">';
         foreach ($node->children as $child) {
             $html .= $this->getNodeHtml($child, $defaultNodeId, $addUnlocalizedClass, $selectedNode, $truncateSize - 1);
         }
         $html .= '</ul>';
     }
     $html .= '</li>';
     return $html;
 }
Esempio n. 6
0
 /**
  * Get the breadcrumbs of a node
  * @param joppa\model\Node $node
  * @param string $baseUrl base url for the node routes
  * @return zibo\library\html\Breadcrumbs
  */
 public function getBreadcrumbsForNode(Node $node, $baseUrl)
 {
     $nodeTypeFacade = NodeTypeFacade::getInstance();
     $urls = array($baseUrl . Request::QUERY_SEPARATOR . $node->getRoute() => $node->name);
     $parent = $node->getParentNode();
     do {
         if ($nodeTypeFacade->isAvailableInFrontend($parent->type)) {
             $url = $baseUrl . Request::QUERY_SEPARATOR . $parent->getRoute();
             $urls[$url] = $parent->name;
         }
         $parent = $parent->getParentNode();
     } while ($parent);
     $urls = array_reverse($urls, true);
     $breadcrumbs = new Breadcrumbs();
     foreach ($urls as $url => $name) {
         $breadcrumbs->addBreadcrumb($url, $name);
     }
     return $breadcrumbs;
 }