Example #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();
 }
Example #2
0
 public function positionAction()
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $page = new default_controllers_PageController();
     if ($_POST['mesto'] == 'up') {
         if ($_POST['page'] == 1) {
             die;
         }
         $this->pageType = $page->getPageType($_POST['menu_id']);
         $old_position = $db->fetchRow("select * from " . $this->pageType . " where id = " . $_POST['id']);
         $new_position = $db->fetchRow("select * from " . $this->pageType . " where position = (select MIN(position) as position from " . $this->pageType . " where position < " . $old_position['position'] . " and page_id = " . $_POST['menu_id'] . " group by page_id) and page_id = " . $_POST['menu_id']);
         $db->query("UPDATE " . $this->pageType . " SET position = " . $old_position['position'] . " WHERE id = " . $new_position['id']);
         $db->query("UPDATE " . $this->pageType . " SET position = " . $new_position['position'] . " WHERE id = " . $_POST['id']);
         echo json_encode($new_position);
         die;
     } elseif ($_POST['mesto'] == 'down') {
         $this->pageType = $page->getPageType($_POST['menu_id']);
         $old_position = $db->fetchRow("select * from " . $this->pageType . " where id = " . $_POST['id']);
         $new_position = $db->fetchRow("select * from " . $this->pageType . " where position = (select MAX(position) as position from " . $this->pageType . " where position > " . $old_position['position'] . " and page_id = " . $_POST['menu_id'] . " group by page_id) and page_id = " . $_POST['menu_id']);
         if (!$new_position) {
             die;
         }
         $db->query("UPDATE " . $this->pageType . " SET position = " . $old_position['position'] . " WHERE id = " . $new_position['id']);
         $db->query("UPDATE " . $this->pageType . " SET position = " . $new_position['position'] . " WHERE id = " . $_POST['id']);
         echo json_encode($new_position);
         die;
     } else {
         $this->pageType = $page->getPageType($_POST['menu_activ']);
         $id_newPosition = $db->fetchRow("select position from " . $this->pageType . " where id = " . $_POST['id_newPosition']);
         $id = $db->fetchRow("select position from " . $this->pageType . " where id = " . $_POST['id']);
         $sql_new_position = "UPDATE " . $this->pageType . " SET position=" . $id['position'] . " WHERE id=" . $_POST['id_newPosition'];
         $sql_old_position = "UPDATE " . $this->pageType . " SET position=" . $id_newPosition['position'] . " WHERE id='{$_POST['id']}'";
         $db->query($sql_new_position);
         $db->query($sql_old_position);
         die;
     }
 }