/** * Gets the options for the view type * @param zibo\library\i18n\translation\Translator $translator * @return array */ protected function getViewOptions(Translator $translator) { $views = ContentViewFactory::getInstance()->getDetailViews(); foreach ($views as $name => $class) { $views[$name] = $translator->translate(self::TRANSLATION_VIEW . $name); } return $views; }
/** * Gets the view * @param joppa\content\model\ContentProperties $properties * @param joppa\model\content\Content $content * @return joppa\content\view\ContentView */ private function getView(ContentProperties $contentProperties, $content) { $view = $contentProperties->getView(); $detailViews = ContentViewFactory::getInstance()->getDetailViews(); if (!array_key_exists($view, $detailViews)) { return null; } $viewClass = $detailViews[$view]; $objectFactory = new ObjectFactory(); $view = $objectFactory->create($viewClass, ContentViewFactory::INTERFACE_DETAIL); $view->setContent($this->properties->getWidgetId(), $content, $contentProperties); return $view; }
/** * Gets the view * @param array $result * @param joppa\content\model\ContentProperties $properties * @param integer $pages * @param integer $page * @return joppa\content\view\ContentView */ private function getView(array $result, ContentProperties $contentProperties, $pages = 1, $page = 1) { $view = $contentProperties->getView(); $listViews = ContentViewFactory::getInstance()->getOverviewViews(); if (!array_key_exists($view, $listViews)) { return null; } $viewClass = $listViews[$view]; $paginationProperties = null; if ($contentProperties->willShowPagination() && $pages > 1) { $paginationUrl = $this->request->getBasePath() . Request::QUERY_SEPARATOR . self::ACTION_PAGE . Request::QUERY_SEPARATOR . '%page%'; $paginationProperties = new PaginationProperties($paginationUrl, $pages, $page); } $moreUrl = null; if ($contentProperties->willShowMoreLink()) { $node = $this->models[NodeModel::NAME]->getNode($contentProperties->getMoreNode(), 0, $this->locale); $moreUrl = $this->request->getBaseUrl() . Request::QUERY_SEPARATOR . $node->getRoute(); } $objectFactory = new ObjectFactory(); $view = $objectFactory->create($viewClass, ContentViewFactory::INTERFACE_OVERVIEW); $view->setContent($this->properties->getWidgetId(), $result, $contentProperties, $paginationProperties, $moreUrl); return $view; }