Example #1
0
 /**
  * @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;
 }
Example #2
0
 /**
  * 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/');
 }
 /**
  * Move down slide show item (Ordering)
  * @param $slideID
  * @param $slideItemID
  * @return \Phalcon\Http\ResponseInterface
  * @throws \Phalcon\Exception
  */
 public function moveDownAction($slideID, $slideItemID)
 {
     $slideID = intval($slideID);
     $slideShow = SlideShows::findFirst(['conditions' => 'slide_show_id = ?0', 'bind' => [$slideID]]);
     if (!$slideShow) {
         return $this->response->redirect('/admin/slide/');
     }
     /**
      * @var SlideShowItems $slideShowItems
      */
     $slideItemID = intval($slideItemID);
     $slideShowItems = SlideShowItems::findFirst(['conditions' => 'slide_show_item_id = ?0', 'bind' => [$slideItemID]]);
     if (!$slideShowItems) {
         return $this->response->redirect('/admin/slide/');
     }
     if ($slideShowItems->moveDown('slide_show_id = ?0', [$slideID])) {
         $this->flashSession->success('Move down up successfully');
     } else {
         $this->flashSession->warning('Move down error');
     }
     return $this->response->redirect('/admin/slide/manage-slide/slide/' . $slideID . '/');
 }