/** * @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; }
/** * override to render the main page */ public function renderMainContent() { $view = new View($this->lifeCycle, "admin/entry_edit"); $view->setTemplateVar("task", $this->task->getSlug()); $view->setTemplateVar("available_templates", $this->renderAvailableTemplates()); $view->setTemplateVar("available_posts", $this->renderAvailablePosts()); $title = ""; $subtitle = ""; $id = ""; $aboveEntries = ""; $belowEntries = ""; $usingPost = false; $postSelectDisplay = "none"; $contentEditingDisplay = "block"; $usingPostDisplay = "block"; $childrenEntries = []; $parent = null; if (isset($this->entry)) { $title = $this->entry->title; $subtitle = $this->entry->subtitle; $id = "&id=" . $this->entry->id; $aboveEntries = $this->entry->top_content; $belowEntries = $this->entry->bottom_content; $usingPost = $this->entry->using_post; $childrenEntries = $this->entry->getChildren(); if ($this->entry->getParent()) { $parent = $this->entry->getParent()->id; } } if (isset($_POST["title"])) { $title = $_POST["title"]; } if (isset($_POST["subtitle"])) { $subtitle = $_POST["subtitle"]; } if (isset($_POST["above_entries"])) { $aboveEntries = $_POST["above_entries"]; } if (isset($_POST["below_entries"])) { $belowEntries = $_POST["below_entries"]; } if (isset($_POST["using_post"])) { $usingPost = $_POST["using_post"] == "on"; } if ($usingPost) { $postSelectDisplay = "block"; $contentEditingDisplay = "none"; } if (isset($this->entry) && $this->entry->template == "nested") { $usingPostDisplay = "none"; $postSelectDisplay = "none"; $contentEditingDisplay = "none"; } if (isset($_GET["parent_id"]) && $_GET["parent_id"]) { $parent = $_GET["parent_id"]; } $view->setTemplateVar("using_post", $usingPost ? "checked" : ""); $view->setTemplateVar("post_select_display", $postSelectDisplay); $view->setTemplateVar("content_editing_visibility", $contentEditingDisplay); $view->setTemplateVar("using_post_visibility", $usingPostDisplay); $view->setTemplateVar("title", $title); $view->setTemplateVar("subtitle", $subtitle); $view->setTemplateVar("id", $id); $aboveEditor = new Editor($this->lifeCycle, "above_entries", $aboveEntries, "Above Children Entries"); $aboveEditor->setHeight(200); $view->setTemplateVar("above_entries", $aboveEditor->export()); $belowEditor = new Editor($this->lifeCycle, "below_entries", $belowEntries, "Below Children Entries"); $belowEditor->setHeight(200); $view->setTemplateVar("below_entries", $belowEditor->export()); $entriesContainer = new EntriesContainer($this->lifeCycle, $childrenEntries, $this->entry); $view->setTemplateVar("entries", $entriesContainer->export()); $view->setTemplateVar("action", $this->action); if ($parent) { $view->setTemplateVar("parent", $parent); } return $view->export(); }
public function __construct($lifeCycle, $id, $name) { parent::__construct($lifeCycle, "admin/entry_tr"); $this->setTemplateVar("id", $id); $this->setTemplateVar("name", $name); }