/** * @param $atts shortcode inputs * @return string shortcode content */ public function handleShortcode($atts) { $exportedContent = ''; $slider = Slider::find_one($atts['id']); if ($slider) { $slider->loadImages(); $slider->prepareExport(); if ($slider->popup_only) { $exportedContent .= $this->loadMagnificAssets(); $template = new MustacheTemplate($this->lifeCycle, "popup_link", $slider); $exportedContent .= $template->export(); } else { $css = new CSS($this->lifeCycle, "jquery.bxslider"); $css->setTemplateVar("plugin_directory", plugin_dir_url(__DIR__ . "../")); $exportedContent .= $css->export(); $images = $slider->getImages(); $sliderView = new ViewCollection($this->lifeCycle, "slider"); $sliderView->setTemplateVar("title", $slider->name); $sliderView->setTemplateVar("subtitle", $slider->description); $sliderView->setTemplateVar("id", $slider->id); $sliderView = $this->buildCollection($sliderView, $images); $exportedContent .= $sliderView->export(); $js = new JavaScript($this->lifeCycle, "jquery.bxslider"); $exportedContent .= $js->export(); $js = new JavaScript($this->lifeCycle, "plugin"); $js->setTemplateVar('id', $slider->id); $js->setTemplateVar('auto_play', $slider->auto_play ? 'true' : 'false'); $js->setTemplateVar('fluid_touch', $slider->fluid_touch ? 'true' : 'false'); $js->setTemplateVar('pager', $slider->pager ? 'true' : 'false'); $js->setTemplateVar('auto_play_speed', $slider->auto_play_pause_speed); $js->setTemplateVar("start_slide", $slider->start_slide); if ($slider->light_box) { $exportedContent .= $this->buildLightBox($slider); } $exportedContent .= $js->export(); } } return $exportedContent; }
/** * override to render the main page */ protected function renderMainContent() { $sliders = ["sliders" => Slider::fetchAllActive()]; $template = new MustacheTemplate($this->lifeCycle, "admin/list_sliders", $sliders); return $template->export(); }
/** * override to render the main page * @param $create bool whether or not we are creating an element * @return string */ protected function renderMainContent($create = false) { $this->slider->prepareEdit($this->lifeCycle); if ($create) { $this->slider->action = "create"; } else { $this->slider->action = "edit"; } $template = new MustacheTemplate($this->lifeCycle, "admin/edit_slider", $this->slider); return $template->export(); }