/** * @return string */ public function form() { $title = isset($this->options->title) ? $this->options->title : ""; $slide_show_id = isset($this->options->slide_show_id) ? $this->options->slide_show_id : ""; $form = '<p><label for="' . $this->getFieldId('title') . '">' . __('gb_title') . '</label>'; $form .= Tag::textField([$this->getFieldName('title'), 'class' => 'form-control input-sm', 'value' => $title]); $form .= '</p>'; $form .= '<p><label for="' . $this->getFieldId('slide_show_id') . '">' . __('w_slide_show_form_id_slide_show') . '</label><br/>'; //Get all slide show $slideShows = SlideShows::find(['conditions' => 'published = 1', 'order' => 'slide_show_id ASC']); $form .= Tag::select([$this->getFieldName('slide_show_id'), $slideShows, 'using' => ['slide_show_id', 'title'], 'class' => 'form-control input-sm', 'value' => $slide_show_id]); $form .= '</p>'; return $form; }
/** * 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 . '/'); }