/** * @param string $path etc /member/home * @param string $bodyId etc global_path-user-index-home * @return array|null * */ public function getTour($path, $bodyid) { $forceEnable = false; //if(Zend_Registry::get('YNTOUR_STATUS_ENABLED')){ // $forceEnable = true; //} $result = array('id' => 0, 'enable' => false, 'total' => 0, 'rows' => array(), 'title' => '', 'autoplay' => 0, 'autoclose' => 0, 'autoclose_time_delay' => 0, 'hash' => '', 'view_rule' => 'all'); $this->view = Zend_Registry::get('Zend_View'); $model = new Yntour_Model_DbTable_Tours(); $select = $model->select()->where('bodyid=?', $bodyid)->orWhere('path=?', $path); $tour = $model->fetchRow($select); // tour exists if (!is_object($tour)) { return $result; } $viewer = Engine_Api::_()->user()->getViewer(); $id = $viewer->getIdentity(); if ($tour->view_rule == 'members' && $id == 0) { return $result; } //if($tour->view_rule == 'guests' && $viewer->level_id > 2) //{ //return $result; //} // 0: path only, check exact path // 1: body_id. all page that has same body id if ($tour->path != $path && $tour->option == 0 || $tour->enabled == 0 && $viewer->level_id > 2) { // return $result; } if (!is_object($tour)) { return $result; } $model = new Yntour_Model_DbTable_Touritems(); $select = $model->select()->where('tour_id=?', $tour->getIdentity())->order('priority'); $rows = $model->fetchAll($select)->toArray(); $temp_rows = array(); $language_select = $this->view->translate()->getLocale(); $model_language = new Yntour_Model_DbTable_Itemlanguages(); foreach ($rows as $row) { $body = $model_language->getLanguage($row['touritem_id'], $language_select)->body; if ($body) { $row['body'] = $body; } $row['width'] = intval($row['width']); $temp_rows[] = $row; } $total = count($temp_rows); $result = array('hash' => $tour->hash, 'total' => $total, 'enable' => $forceEnable | $total, 'id' => $tour->getIdentity(), 'title' => $tour->title, 'rows' => $temp_rows, 'autoplay' => $tour->autoplay, 'autoclose' => $tour->autoclose, 'autoclose_time_delay' => $tour->autoclose_time_delay, 'hash' => $tour->hash, 'view_rule' => $tour->view_rule); return $result; }
protected function _load($path, $bodyid) { $model = new Yntour_Model_DbTable_Tours(); $select = $model->select()->where('bodyid=?', $bodyid)->orWhere('path=?', $path); $setting = Engine_Api::_()->getApi('settings', 'core')->getSetting('yntourmode', 'disable'); if ($setting == 'disabled') { $select->where('enabled=?', 1); } $tour = $model->fetchRow($select); // tour exists if (!is_object($tour)) { return; } if ($tour->path != $path && $tour->option == 1) { return; } if (!is_object($tour)) { return array('id' => 0, 'total' => 0, 'rows' => array(), 'title' => '', '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(); $temp_rows = array(); $language_select = $this->view->translate()->getLocale(); $model_language = new Yntour_Model_DbTable_Itemlanguages(); foreach ($rows as $row) { $body = $model_language->getLanguage($row['touritem_id'], $language_select)->body; if ($body) { $row['body'] = $body; } $row['width'] = intval($row['width']); $temp_rows[] = $row; } $result = array('hash' => $tour->hash, 'total' => count($temp_rows), 'id' => $tour->getIdentity(), 'title' => $tour->title, 'rows' => $temp_rows, 'autoplay' => $tour->autoplay, 'autoclose' => $tour->autoclose, 'autoclose_time_delay' => $tour->autoclose_time_delay, 'hash' => $tour->hash, 'view_rule' => $tour->view_rule); return $result; }