/** * @param LifeCycle $lifeCycle * @param Entry[] $entries * @param Entry|null $parent the parent Entry */ public function __construct(LifeCycle $lifeCycle, $entries, Entry $parent = null) { parent::__construct($lifeCycle, "admin/entries_container"); foreach ($entries as $entry) { $view = new EntryTR($this->lifeCycle, $entry->id, $entry->title); $this->addChildView("entries", $view); } if ($parent != null) { $this->setTemplateVar("parent", "&parent_id=" . $parent->id); } }
/** * @param ViewCollection $sliderView the parent view of the images * @param $images Image[] all images associated with this slider * @return ViewCollection the same sliderView, but with all images added to it */ private function buildCollection(ViewCollection $sliderView, $images) { foreach ($images as $image) { $layout = $image->image_link ? "image_link" : "image"; $imageView = new View($this->lifeCycle, $layout); $imageView->setTemplateVar("image_url", $image->image_url); $imageView->setTemplateVar("image_name", $image->name); $imageView->setTemplateVar("image_description", $image->description); if ($image->image_link) { $imageView->setTemplateVar("image_link", $image->image_link); $imageView->setTemplateVar("image_link_target", $image->image_link_new_window ? "_blank" : "_self"); } $sliderView->addChildView("image", $imageView); } return $sliderView; }
/** * Builds an instance of a simple template * @param $entry Entry for the template * @return ViewCollection the build template */ private function buildSimpleTemplate($entry) { $collection = new ViewCollection($this->lifeCycle, "front_end-entry"); $collection->setTemplateVar("title", $entry->title); $collection->setTemplateVar("top_content", $entry->top_content); $collection->setTemplateVar("bottom_content", $entry->bottom_content); if (count($entry->getChildren())) { $collection->addChildViews("children", $this->buildCollections($entry->getChildren())); } return $collection; }