Beispiel #1
0
 public function editTourAction()
 {
     $form = $this->view->form = new Yntour_Form_Tour_Create();
     $model = new Yntour_Model_DbTable_Tours();
     $id = $this->_getParam('tour_id', 0);
     $item = $model->find($id)->current();
     $request = $this->getRequest();
     if ($request->isGet()) {
         if (is_object($item)) {
             $form->populate($item->toArray());
         } else {
             $uri = parse_url($request->getServer('HTTP_REFERER'));
             $path = trim($uri['path']);
             $baseURL = $request->getBaseUrl();
             $path = str_replace($baseURL, '', $path);
             $bodyid = $this->_getParam('body', 'global_page_user-index-home');
             $form->populate(array('path' => $path, 'bodyid' => $bodyid));
         }
         return;
     }
     if ($request->isPost() && $form->isValid($request->getPost())) {
         $data = $form->getValues();
         if (!is_object($item)) {
             $item = $model->fetchNew();
             $item->creation_date = date('Y-m-d H:i:s');
             $item->setPath($form->getValue('path'));
             $item->hash = md5(mt_rand(0, 999999) . mt_rand(0, 999999) . mt_rand(0, 99999), false);
         }
         $item->setFromArray($data);
         if (!$item->save()) {
             throw Exception("Invalid data");
         }
         $this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array('Successful.')));
     }
 }
 public function deleteAction()
 {
     $form = $this->view->form = new Yntour_Form_Admin_Tour_Delete();
     // In smoothbox
     $this->_helper->layout->setLayout('admin-simple');
     $id = $this->_getParam('id');
     $model = new Yntour_Model_DbTable_Tours();
     // Check post
     if ($this->getRequest()->isPost()) {
         $db = $model->getAdapter();
         $db->beginTransaction();
         try {
             $item = $model->find($id)->current();
             // delete the blog entry into the database
             $item->delete();
             $db->commit();
         } catch (Exception $e) {
             $db->rollBack();
             throw $e;
         }
         $this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array('Successful.')));
     }
 }
Beispiel #3
0
 public function loadTour($path, $mode)
 {
     $model = new Yntour_Model_DbTable_Tours();
     $select = $model->select()->where('path=?', urldecode($path));
     $setting = Engine_Api::_()->getApi('settings', 'core')->getSetting('yntourmode', 'disable');
     if ($setting == 'disabled') {
         $select->where('enabled=?', 1);
     }
     $tour = $model->fetchRow($select);
     if (!is_object($tour)) {
         return array('id' => 0, 'total' => 0, 'rows' => array(), 'autoplay' => 0, 'autoclose' => 0, 'autoclose_time_delay' => 0, 'hash' => '', 'view_rule' => 'all');
     }
     $model = new Yntour_Model_DbTable_Touritems();
     $select = $model->select()->where('tour_id=?', $tour->getIdentity())->order('priority');
     $rows = $model->fetchAll($select)->toArray();
     $result = array('hash' => $tour->hash, 'total' => count($rows), 'id' => $tour->getIdentity(), 'rows' => $rows, 'autoplay' => $tour->autoplay, 'autoclose' => $tour->autoclose, 'autoclose_time_delay' => $tour->autoclose_time_delay, 'hash' => $tour->hash, 'view_rule' => $tour->view_rule);
     return $result;
 }