/** * @return mixed|string */ public function widget() { $html = ''; if (isset($this->options->slide_show_id)) { $cache = ZCache::getInstance(); $html = $cache->get(self::SLIDE_SHOW_WIDGET_CACHE . $this->options->slide_show_id); if ($html === null) { /** * @var SlideShowItems[] $slideShowItems */ $slideShowItems = SlideShowItems::find(['conditions' => 'id_slide_show = ?0 AND published = 1', 'bind' => [$this->options->slide_show_id], 'order' => 'ordering ASC']); if (count($slideShowItems)) { $html .= '<div class="flexslider"><ul class="slides">'; foreach ($slideShowItems as $item) { $html .= '<li><a target="' . $item->target . '" href="' . $item->link . '"><img src="' . $item->image . '"/></a></li>'; } $html .= ' </ul></div>'; $cache->save(self::SLIDE_SHOW_WIDGET_CACHE . $this->options->slide_show_id, $html); } } } return $html; }
/** * Delete slide show * * @param null $slideShowID * @return \Phalcon\Http\ResponseInterface */ public function deleteAction($slideShowID = null) { $id = null; if ($slideShowID) { $id = intval($slideShowID); } else { $ids = $this->request->getPost('ids'); if (count($ids)) { $id = $ids[0]; } } if ($id > 0) { /** * @var SlideShows $slideShow */ $slideShow = SlideShows::findFirst(['conditions' => 'slide_show_id = ?0', 'bind' => [$id]]); if (!$slideShow) { return $this->response->redirect('/admin/slide/'); } /** * @var $slideShowItems SlideShowItems[] */ $slideShowItems = SlideShowItems::find(['conditions' => 'id_slide_show = ?0', 'bind' => [$id]]); if (count($slideShowItems)) { $this->flashSession->notice('m_admin_slide_message_you_must_delete_slide_show_items_before_delete_slide_show'); } else { $file = ROOT_PATH . '/public' . $slideShow->image; if (!is_dir($file) && file_exists($file) && strpos($file, ROOT_PATH . '/public/' . self::SLIDE_SHOW_FOLDER_UPLOAD) !== false) { unlink($file); } $slideShow->delete(); $this->flashSession->success('m_admin_slide_message_you_must_delete_slide_show_successfully'); return $this->response->redirect('/admin/slide/'); } } return $this->response->redirect('/admin/slide/'); }
/** * List all slide show item(s) in 1 slide show * * @param $id * @return bool */ public function slideAction($id) { $id = intval($id); /** * @var $slideShow SlideShows */ $slideShow = SlideShows::findFirst(['conditions' => 'slide_show_id = ?0', 'bind' => [$id]]); if (!$slideShow) { return $this->response->redirect('/admin/slide/'); } $this->_toolbar->addPublishedButton(); $this->_toolbar->addUnPublishedButton(); $this->_toolbar->addNewButton('new', '/admin/slide/manage-slide/new/' . $id . '/'); $this->_toolbar->addDeleteButton('delete', '/admin/slide/manage-slide/delete/' . $id . '/'); $this->_toolbar->addCancelButton('index', '/admin/slide/', 'Backward', 'fa fa-backward'); //Add sorting $this->addFilter('filter_order', 'slide_show_item_id', 'string'); $this->addFilter('filter_order_dir', 'DESC', 'string'); $this->addFilter('filter_column_title', '', 'string'); $this->addFilter('filter_column_title', '', 'string'); $this->addFilter('filter_published', '', 'string'); $this->addFilter('filter_id', '', 'int'); $filter = $this->getFilter(); $this->view->setVar('_filter', $filter); $conditions = []; if ($filter['filter_column_title']) { $conditions[] = "title ILIKE '%" . htmlspecialchars($filter['filter_column_title']) . "%'"; } if ($filter['filter_id']) { $conditions[] = "slide_show_item_id = " . intval($filter['filter_id']); } if ($filter['filter_published'] != '') { $conditions[] = "published = " . intval($filter['filter_published']); } $conditions[] = 'slide_show_id = ' . $id; $slides = SlideShowItems::find(['conditions' => implode(' AND ', $conditions), 'order' => $filter['filter_order'] . ' ' . $filter['filter_order_dir']]); $paginationLimit = $this->config->pagination->limit; $currentPage = $this->request->getQuery('page', 'int'); $this->view->setVar('_page', ZPagination::getPaginationModel($slides, $paginationLimit, $currentPage)); $this->view->setVar('_pageLayout', [['type' => 'check_all', 'column' => 'slide_show_item_id'], ['type' => 'index', 'title' => '#'], ['type' => 'image', 'width' => '100', 'height' => 'auto', 'uri_prefix' => '', 'column' => 'image', 'css' => 'width : 105px', 'title' => 'Image', 'class' => 'text-center', 'default_thumbnail' => '/media/default/no-image.png'], ['type' => 'link', 'title' => 'Slide Item Name', 'column' => 'title', 'link' => '/admin/slide/manage-slide/edit/' . $id . '/', 'access' => $this->acl->isAllowed('slide|manage-slide|edit'), 'filter' => ['type' => 'text', 'name' => 'filter_column_title', 'attributes' => []]], ['type' => 'actions', 'title' => 'gb_ordering', 'link_prefix' => 'slide_show_item_id', 'class' => 'text-center', 'column' => 'ordering', 'display_value' => true, 'actions' => [['link_title' => 'gb_move_up', 'link' => '/admin/slide/manage-slide/moveUp/' . $id . '/', 'link_class' => '', 'icon_class' => 'glyphicon glyphicon-chevron-up', 'access' => $this->acl->isAllowed('slide|manage-slide|edit')], ['link_title' => 'gb_move_down', 'link' => '/admin/slide/manage-slide/moveDown/' . $id . '/', 'link_class' => '', 'icon_class' => 'glyphicon glyphicon-chevron-down', 'access' => $this->acl->isAllowed('slide|manage-slide|edit')]]], ['type' => 'published', 'title' => 'gb_published', 'access' => $this->acl->isAllowed('slide|manage-slide|edit'), 'link' => '/admin/slide/manage-slide/', 'column' => 'published', 'filter' => ['type' => 'select', 'name' => 'filter_published', 'attributes' => ['useEmpty' => true, 'emptyText' => 'All', 'value' => $filter['filter_published'] == '' ? -1 : $filter['filter_published']], 'value' => [0 => 'No', 1 => 'Yes']]], ['type' => 'id', 'title' => 'gb_id', 'column' => 'slide_show_item_id', 'css' => 'width : 100px', 'filter' => ['type' => 'text', 'name' => 'filter_id', 'attributes' => []]]]); return true; }