Beispiel #1
0
 function indexAction()
 {
     if (@(!$_GET['pages_id']) && @$_POST['pages_id']) {
         $_GET['pages_id'] = @$_POST['pages_id'];
     }
     $this->view->name_dop_table = 'page';
     $this->_helper->actionStack('createmenu', 'Menu', 'admin', array('id' => $_GET['menu_id']));
     $page = new default_controllers_PageController();
     $this->pageType = $page->getPageType($_GET['menu_id']);
     $db = Zend_Db_Table::getDefaultAdapter();
     $this->view->iPage = $db->fetchRow("SELECT \tt.*,\n    \t\t\t\t\t\t\t\t\tm.nameforhref, m.type , m.parent_id, m.id as menu_activ, m.name as menu_name, m.default_controller, m.default_controller_add_edit, m.default_view, m.default_add_edit\n    \t\t\t\t\t\t\t\t\t,(select par.name from menu par where par.id = m.parent_id) as name_parenta \n    \t\t\t\t\t\t\tFROM menu m \n    \t\t\t\t\t\t\tleft join  " . $this->pageType . " as t on m.id = t.page_id \n    \t\t\t\t\t\t\tWHERE m.id=" . $_GET['menu_id']);
     if ($_POST && $this->view->iPage['id']) {
         $update = new Core_Controller_Action_Helper_Update();
         $ret = $update->update($this->pageType, $this->view->iPage);
         $this->id_row = $ret['id_row'];
         $this->mess = $ret['message'];
         if (!$this->mess) {
             $this->view->message = 'Изменения внесены';
         }
         //$this->view->page = array_merge($this->view->page,$_POST);
         $this->view->iPage = $db->fetchRow("SELECT \tt.*,\n\t\t\t\t\t\t\t\tm.nameforhref, m.type , m.parent_id, m.id as menu_activ, m.name as menu_name, m.default_controller, m.default_controller_add_edit, m.default_view, m.default_add_edit\n\t\t\t\t\t\t\t\t,(select par.name from menu par where par.id = m.parent_id) as name_parenta \n\t\t\t\t\t\tFROM menu m  \n\t\t\t\t\t\tleft join  " . $this->pageType . " as t on m.id = t.page_id \n\t\t\t\t\t\tWHERE m.id=" . $_GET['menu_id']);
     } elseif ($_POST) {
         $add = new Core_Controller_Action_Helper_Add();
         $ret = $add->add($this->pageType, $this->view->iPage);
         $this->id_row = $ret['id_row'];
         $this->mess = $ret['message'];
         if (!$this->mess) {
             $this->view->message = 'Сохранено';
         }
         //$this->view->page = array_merge($this->view->page,$_POST);
         $this->view->iPage = $db->fetchRow("SELECT \tt.*, \n\t    \t\t\t\t\t\t\t\t\tm.nameforhref, m.type , m.parent_id, m.id as menu_activ, m.name as menu_name, m.default_controller, m.default_controller_add_edit, m.default_view, m.default_add_edit\n\t    \t\t\t\t\t\t\t\t\t,(select par.name from menu par where par.id = m.parent_id) as name_parenta \n\t    \t\t\t\t\t\t\tFROM menu m \n\t    \t\t\t\t\t\t\tleft join  " . $this->pageType . " as t on m.id = t.page_id \n\t    \t\t\t\t\t\t\tWHERE m.id=" . $_GET['menu_id']);
     }
     if (!$this->view->page['default_view']) {
         $this->_helper->viewRenderer->setScriptAction($this->pageType);
     }
     require $_SERVER['DOCUMENT_ROOT'] . "/public/fck_new/fckeditor.php";
     $oFCKeditor = new FCKeditor("textred");
     $oFCKeditor->BasePath = "/public/fck_new/";
     $oFCKeditor->Value = @$this->view->iPage['textred'];
     $this->view->html_editor = $oFCKeditor->CreateHtml();
 }
 function editAction()
 {
     $this->_helper->actionStack('createmenu', 'Menu', 'admin', array('id' => $_GET['menu_id']));
     $page = new default_controllers_PageController();
     $this->pageType = $page->getPageType($_GET['menu_id']);
     $this->view->iPage = $page->getOnePage($_GET['pages_id'], $this->pageType);
     if ($_POST) {
         $cacheId = 'film_' . $_GET['pages_id'];
         $curl = curl_init();
         curl_setopt($curl, CURLOPT_URL, 'http://api.tree.tv/clearcache?id=' . $cacheId);
         curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.12011-10-16 20:23:00");
         //			curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13");
         curl_setopt($curl, CURLOPT_REFERER, "http://www.tree.tv");
         curl_setopt($curl, CURLOPT_ENCODING, "gzip,deflate");
         curl_setopt($curl, CURLOPT_AUTOREFERER, true);
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($curl, CURLOPT_TIMEOUT, 30);
         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
         curl_exec($curl);
         curl_close($curl);
         $update = new Core_Controller_Action_Helper_Update();
         $ret = $update->update($this->pageType, $this->view->iPage);
         $this->id_row = $ret['id_row'];
         $this->mess = $ret['message'];
         $this->view->message = 'Изменения внесены';
         if ($this->mess && $this->mess) {
             $this->view->message = $this->mess;
         }
         $this->view->iPage = $page->getOnePage($_GET['pages_id'], $this->pageType);
     }
     if (!$this->view->iPage['default_controller_add_edit']) {
         $name_controller = 'default_controllers_' . $this->pageType . 'Controller';
         $dopParam = new $name_controller();
         $this->view->dopParam = $dopParam->{$this->pageType . 'afterinsert'}(@$this->view->message);
         if ($this->pageType == 'films' && $_POST && (!$this->view->message || $this->view->message == 'Изменения внесены')) {
             header("Location: /standart/view/?menu_id=" . $_GET['menu_id']);
         }
     }
     require $_SERVER['DOCUMENT_ROOT'] . "/public/fck_new/fckeditor.php";
     $oFCKeditor = new FCKeditor("textred");
     $oFCKeditor->BasePath = "/public/fck_new/";
     $oFCKeditor->Value = $this->view->iPage['textred'];
     $this->view->html_editor = $oFCKeditor->CreateHtml();
     $oFCKeditor = new FCKeditor("grafiks");
     $oFCKeditor->BasePath = "/public/fck_new/";
     $oFCKeditor->Value = $this->view->iPage['grafiks'];
     $this->view->grafiks = $oFCKeditor->CreateHtml();
     $this->view->name_button = 'update';
     if ($this->view->iPage['default_add_edit']) {
         $this->_helper->viewRenderer->setScriptAction($this->pageType);
     } else {
         $phtml_name = $this->pageType;
         if ($this->view->iPage['nameforhref']) {
             $phtml_name = $this->view->iPage['nameforhref'];
         }
         $this->_helper->viewRenderer($this->pageType . '/' . $phtml_name, null, true);
     }
 }