/**
  * Set the API breadcrumbs to the view
  * @param zibo\library\smarty\view\SmartyView $view
  * @param string $namespace current namespace
  * @param string $class current class
  * @return null
  */
 private function setBreadcrumbsToView(SmartyView $view, $namespace = null, $class = null)
 {
     $translator = $this->getTranslator();
     $breadcrumbs = new Breadcrumbs();
     $breadcrumbs->setId('breadcrumbs');
     $breadcrumbs->setLabel($translator->translate(self::TRANSLATION_NAVIGATION));
     $breadcrumbs->addBreadcrumb($this->request->getBasePath(), $translator->translate(self::TRANSLATION_NAVIGATION_HOME));
     $view->set('breadcrumbs', $breadcrumbs);
     if (empty($namespace)) {
         return;
     }
     $tokens = explode(ApiBrowser::NAMESPACE_SEPARATOR, $namespace);
     $namespace = null;
     foreach ($tokens as $token) {
         $namespace = $namespace . $token . ApiBrowser::NAMESPACE_SEPARATOR;
         $breadcrumbs->addBreadcrumb($this->namespaceAction . $namespace, $token);
     }
     if ($class) {
         $breadcrumbs->addBreadcrumb($this->classAction . $namespace . $class, $class);
     }
 }
 /**
  * Apply the set filter to a breadcrumbs object, removes all the crumbs with the name of a filtered node
  * @return zibo\library\html\Breadcrumbs
  */
 private function applyFilter(Breadcrumbs $breadcrumbs)
 {
     $filters = $this->getFilter();
     if (!$filters) {
         return $breadcrumbs;
     }
     foreach ($filters as $filter) {
         $breadcrumbs->removeBreadcrumb($filter->name);
     }
     return $breadcrumbs;
 }
 /**
  * Add a breadcrumb to the page
  * @param string $url url for the breadcrumb
  * @param string $label label for the breadcrumb
  * @return null
  */
 public function addBreadcrumb($url, $label)
 {
     $this->breadcrumbs->addBreadcrumb($url, $label);
 }
 /**
  * Gets the detail view of a module
  * @param Module $module Module to display in the view
  * @return zibo\repository\view\ModuleView
  */
 private function getModuleView(Module $module)
 {
     $namespace = $module->getNamespace();
     $name = $module->getName();
     $basePath = $this->request->getBasePath() . '/';
     $repositoryUrl = $basePath . self::ACTION_NAMESPACE . '/' . $namespace;
     $moduleUrl = $basePath . self::ACTION_MODULE . '/';
     $downloadUrl = $basePath . self::ACTION_DOWNLOAD . '/' . $namespace . '/' . $name . '/';
     $table = new ModuleVersionTable($module->getVersions(), $downloadUrl, $moduleUrl . $namespace . '/' . $name);
     $this->breadcrumbs->addBreadcrumb($repositoryUrl, $namespace);
     $this->breadcrumbs->addBreadcrumb($moduleUrl . '/' . $namespace . '/' . $name, $name);
     return new ModuleView($module, $table, $repositoryUrl, $moduleUrl, self::TRANSLATION_DOWNLOAD, $downloadUrl . $module->getVersion());
 }
Beispiel #5
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;
 }