Exemplo n.º 1
0
 /**
  * check if the cms is already installed or needs update and redirect to installer in one of these cases
  * @see Zend_Controller_Plugin_Abstract::preDispatch()
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if ($this->getRequest()->getModuleName() == 'install' || $this->getRequest()->getModuleName() == 'devtools') {
         # we don't need to check while we are in the installer itself
         return;
     }
     # check whether the cms is installed or not
     $t = Doctrine::getTable('User_Model_User');
     try {
         $t->count();
         $installed = true;
     } catch (Doctrine_Exception $e) {
         $installed = false;
     }
     $redirect = new Zend_Controller_Action_Helper_Redirector();
     if ($installed) {
         # check if update is needed
         $mig = Install_Api_Migration::getInstance();
         if ($mig->getCurrentVersion() < $mig->getLatestVersion()) {
             # update needed
             $redirect->gotoSimple('index', 'index', 'install');
         }
     } else {
         $redirect->gotoSimple('index', 'index', 'install');
     }
 }
Exemplo n.º 2
0
 public function checkAuth()
 {
     if (!$this->isPublic() && !Zend_Auth::getInstance()->hasIdentity()) {
         $this->_flash->addMessage('You must be logged in');
         $this->_redirector->gotoSimple('login', 'account');
     }
 }
Exemplo n.º 3
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $this->_initAcl();
     if ($this->_auth->hasIdentity()) {
         $ident = $this->_auth->getIdentity();
         $date = new Zend_Date();
         $ident->last_login = $date->get(DATABASE_DATE_FORMAT);
         $ident->save();
     }
     if ($request->getControllerName() != 'admin' && $request->getModuleName() != 'admin') {
         return;
     }
     // if this is not admin skip the rest
     if (!$this->_auth->hasIdentity() && !($request->getControllerName() == 'auth' && $request->getActionName() == 'login' && $request->getModuleName() == 'admin')) {
         $redirect = new Zend_Controller_Action_Helper_Redirector();
         $redirect->gotoSimple('login', 'auth', 'admin');
     }
     if ($request->getModuleName() == 'user' && $request->getControllerName() == 'admin' && $request->getActionName() == 'profile') {
         return;
     }
     // the profile is a free resource
     $resource = $request->getModuleName() . '_' . $request->getControllerName();
     $hasResource = $this->_acl->has($resource);
     if ($hasResource && !$this->_acl->isAllowed('fansubcms_user_custom_role_logged_in_user', $resource, $request->getActionName())) {
         throw new FansubCMS_Exception_Denied('The user is not allowd to do this');
     }
 }
 public function editAction()
 {
     if ($this->_request->getParam('dataPage')) {
         $dataPage = $this->_request->getParam('dataPage');
         $id = $this->_request->getParam('id');
         $item = $this->_modelMapper->find($id, $this->_model);
         $item->setOptions($dataPage);
         $category = $this->_modelCategoriesMapper->find($item->getCategoryId(), new Pipeline_Model_PipelineCategories());
         $fullPath = $category ? $category->getPath() . '/' . $item->getPath() : $item->getPath();
         $item->setFullPath($fullPath);
         $this->setUploadImage($item);
         $markdown = $dataPage['contentMarkdown'];
         $context_html = Michelf\MarkdownExtra::defaultTransform($markdown);
         $item->setContentHtml($context_html);
         $this->_modelMapper->save($item);
         $this->_redirector->gotoUrlAndExit('/pipeline/' . $item->getFullPath());
     }
     parent::editAction();
     $form = $this->_forms['edit'];
     $imageTableElement = $form->getElement('imageTable');
     $imageTablePrepend = '<button type="button" class="btn btn-default" id="imageTableLoadBtn"><span class="glyphicon glyphicon-save"></span></button>';
     $imageTableValue = $imageTableElement->getValue();
     if (!is_null($imageTableValue)) {
         $imageTablePrepend .= '<a href="' . $imageTableValue . '" class="btn btn-default" target="_blank"><span class="glyphicon glyphicon-eye-open"></span></a>';
         //$imageTablePrepend .= '<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-trash"></span></button>';
     }
     $imageTableElement->setAttrib('prepend_btn', $imageTablePrepend);
     $this->setViewPipelineProperties();
 }
Exemplo n.º 5
0
 public function byceAction()
 {
     $images = new Service_Image();
     $namespace = new Zend_Session_Namespace('default');
     $resultKey = new Ble422_Guid();
     $ceId = $this->getRequest()->getParam(CalibrationExercise::COL_ID);
     if ($ceId != null) {
         //get images
         $namespace->{$resultKey} = $images->getImages($ceId);
         //getCeInfo
         //set CE id
         $constCeId = CalibrationExercise::COL_ID;
         $namespace->{$constCeId} = $ceId;
         //Set CE-info result Object
         $dbadapter = Zend_Registry::get('DB_CONNECTION1');
         $select = $dbadapter->select();
         $select->from(array('caex' => CalibrationExercise::TABLE_NAME));
         $select->join(array('exp' => Expertise::TABLE_NAME), 'caex.' . CalibrationExercise::COL_EXPERTISE_ID . "=" . 'exp.' . Expertise::COL_ID);
         $select->join(array('key' => KeyTable::TABLE_NAME), 'caex.' . CalibrationExercise::COL_KEY_TABLE_ID . "=" . 'key.' . KeyTable::COL_ID);
         $select->join(array('work' => Workshop::TABLE_NAME), 'caex.' . CalibrationExercise::COL_WORKSHOP_ID . "=" . "work." . Workshop::COL_ID, array(Workshop::COL_NAME));
         $select->where('caex.' . CalibrationExercise::COL_ID . "=?", $ceId);
         $ceArray = $dbadapter->fetchAll($select);
         $namespace->ceArray = $ceArray;
     } else {
         $redirect = new Zend_Controller_Action_Helper_Redirector();
         $redirect->setGotoSimple('index', 'index', 'default');
     }
     $this->view->resultKey = $resultKey->__toString();
     $this->render('start');
 }
Exemplo n.º 6
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if ('company' == $request->getControllerName()) {
         $tsn = $request->tsn ? $request->tsn : $_COOKIE['tsn'];
         if ($tsn) {
             $token = Token::create($tsn);
             $token->update_sync_time();
         } else {
             $token = Token::create_abstract('123');
         }
         if ($token->is_logined() == true) {
             if ($token->is_expire()) {
                 $token->destroy();
                 include_once LIB_PATH . '/view_helper/BuildUrl.php';
                 $url_builder = new Zend_View_Helper_BuildUrl();
                 $referer = SearchFilter::slashes($url_builder->buildUrl($request->getActionName(), $request->getControllerName(), $request->getModuleName()));
                 $login_url = $url_builder->buildUrl('login', 'auth', 'index', array('redirect' => $referer));
                 $redirector = new Zend_Controller_Action_Helper_Redirector();
                 $redirector->gotoUrl($login_url);
                 return;
             }
             $token->register();
         } else {
             if ('auth' != $request->getActionName()) {
                 $token->destroy();
                 $request->setModuleName('index');
                 $request->setControllerName('auth');
                 $request->setActionName('login');
             }
         }
     }
 }
Exemplo n.º 7
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     if (in_array(System_String::StrToLower($request->getControllerName()), array('admin', 'panel')) && false == $request->isXmlHttpRequest() && false == $request->getParam('direct')) {
         $redirector = new Zend_Controller_Action_Helper_Redirector();
         $redirector->gotoUrlAndExit('#' . $this->_view->baseUrl() . $this->_view->currentUrl());
     }
 }
 /**
  * Appelé avant chaque preDispatch() du contrôleur actuel ($_actionController)
  */
 public function preDispatch()
 {
     if (!$this->_actionController instanceof Zend_Acl_Resource_Interface || $this->_disabled) {
         return;
     }
     $result = false;
     // $action = $this->_actionController->getRequest()->getActionName();
     $roles_tab = $this->_getActualRole();
     foreach ($roles_tab as $role) {
         try {
             $result = $this->_acl->isAllowed($role, $this->_actionController);
             if ($result == true) {
                 break;
             }
         } catch (Zend_Acl_Exception $e) {
             exit($e->getMessage());
             $result = false;
         }
     }
     if ($result === false) {
         $_redirector = new Zend_Controller_Action_Helper_Redirector();
         $_redirector->setGotoRoute(array('controller' => 'index', 'action' => 'index'));
         //$_redirector->goto ('index/index', null);
         //$this->_redirect('/index/index');
         // $this->_actionController->getHelper('redirector')->gotoUrlAndExit('"/index/index"');
     }
 }
Exemplo n.º 9
0
 public static function redirectIfSessionExpired()
 {
     $cusNS = new Zend_Session_Namespace('Customer');
     if (isset($cusNS->expired)) {
         $redirector = new Zend_Controller_Action_Helper_Redirector();
         return $redirector->gotoUrl('/error/expire');
     }
 }
Exemplo n.º 10
0
 /**
  * Switch the actual theme seting it on session
  * 
  * @todo improve it to persist the theme through sessions
  */
 public function switchAction()
 {
     if ($this->_hasParam("to")) {
         $themeSession = new Zend_Session_Namespace("theme");
         $themeSession->themeName = $this->_getParam("to");
     }
     $this->_redirector->gotoSimple("index", "index", "aganacore");
 }
Exemplo n.º 11
0
 public function logout()
 {
     $auth = Zend_Auth::getInstance();
     $auth->clearIdentity();
     $storage = $auth->getStorage();
     $storage->clear();
     $controller = new Zend_Controller_Action_Helper_Redirector();
     $controller->gotoSimple('index');
 }
Exemplo n.º 12
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if (PHP_SAPI == 'cli') {
         return;
     }
     $acl = new Zend_Acl();
     // add the roles
     $acl->addRole(new Zend_Acl_Role('guest'));
     $acl->addRole(new Zend_Acl_Role('user'), 'guest');
     $acl->addRole(new Zend_Acl_Role('admin'), 'user');
     // add the resources
     $acl->addResource(new Zend_Acl_Resource('index'));
     $acl->addResource(new Zend_Acl_Resource('error'));
     $acl->addResource(new Zend_Acl_Resource('user'));
     $acl->addResource(new Zend_Acl_Resource('profile'));
     $acl->addResource(new Zend_Acl_Resource('post'));
     $acl->addResource(new Zend_Acl_Resource('*'));
     // set up the access rules
     $acl->allow(null, array('index', 'error'));
     // a guest can only sign up content and login
     $acl->allow('guest', 'user', array('login', 'register', 'unique', 'search'));
     // user
     $acl->allow('user', 'user', array('edit', 'logout'));
     $acl->allow('user', 'profile', array('edit', 'profile', 'getxml', 'viewxml', 'more'));
     $acl->allow('user', 'post', array('new', 'postxml', 'getposts', 'like', 'share', 'comment', 'home', 'edit', 'allcomment', 'notification', 'report'));
     $acl->allow('admin', null);
     // Fetch the current user
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $id = get_user_id();
         $role = "user";
         if ($id == 2) {
             $role = "admin";
         }
     } else {
         $role = 'guest';
     }
     // Authorization
     $controller = $request->controller;
     $action = $request->action;
     try {
         if (!$acl->isAllowed($role, $controller, $action)) {
             if ($role == 'guest') {
                 $redirector = new Zend_Controller_Action_Helper_Redirector();
                 $redirector->gotoSimple('login', 'user');
             } else {
                 // User with role $role is not authorized for $controller/$action"
                 $request->setControllerName('error');
                 $request->setActionName('notauthorized');
             }
         }
     } catch (Exception $e) {
         $request->setControllerName('error');
         $request->setActionName('notfound');
     }
 }
 /**
  * @param Pipeline_Model_PipelineCategories $categories
  * @return $this
  * @throws Zend_Controller_Action_Exception
  */
 public function checkDeleted(Pipeline_Model_PipelineCategories $categories)
 {
     if ($categories->getDeleted() != '0') {
         if (!Zend_Auth::getInstance()->hasIdentity()) {
             throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
         }
         $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'pipeline-categories'), 'adminEdit', true);
     }
     return $this;
 }
 /**
  * @param Oil_Model_Oil $pageItem
  * @return $this
  * @throws Zend_Controller_Action_Exception
  */
 public function checkDeleted(Oil_Model_Oil $pageItem)
 {
     if ($pageItem->getDeleted() != '0') {
         if (!Zend_Auth::getInstance()->hasIdentity()) {
             throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
         }
         $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'oil-categories', 'action' => 'list', 'id' => $pageItem->getCategoryId()), 'adminEdit', true);
     }
     return $this;
 }
Exemplo n.º 15
0
 /**
  * Check permission user
  * @author Nguyễn Mạnh Hùng
  * @email manhhung86it@gmail.com
  * @version 1.0
  * @param Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $module = $request->getParam('module', 'front');
     $auth = Zend_Auth::getInstance();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $redirector = new Zend_Controller_Action_Helper_Redirector();
     //check quyen truy cap vao admin
     if ($module != 'login' && !$auth->hasIdentity()) {
         $redirector->gotoUrlAndExit(SITE_URL . '/auth/login');
     }
 }
Exemplo n.º 16
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if (!Zend_Auth::getInstance()->hasIdentity() && !in_array($this->getRequest()->getControllerName(), array('index', 'login', 'api', 'install', 'error', 'test'))) {
         $redirect = new Zend_Controller_Action_Helper_Redirector();
         $redirect->gotoSimple('index', 'login', null, array('next' => str_replace("/", ";", $this->getRequest()->getRequestUri())));
     }
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $view = Zend_Layout::getMvcInstance()->getView();
         $view->loginStatus = true;
         $view->user = Zend_Auth::getInstance()->getIdentity();
     }
 }
Exemplo n.º 17
0
 public function preDispatchDisabled()
 {
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         $r = $this->getRequest();
         $current = $r->getModuleName() . '.' . $r->getControllerName() . '.' . $r->getActionName();
         if (!in_array($current, $this->allowed)) {
             $r = new Zend_Controller_Action_Helper_Redirector();
             $r->gotoRoute(array(), $this->loginRoute, true);
         }
     }
     parent::preDispatch();
 }
Exemplo n.º 18
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if ($request->getModuleName() === 'painel') {
         if (My_Auth::getInstance('Painel')->hasIdentity()) {
             return;
         } else {
             if ($request->getControllerName() !== 'auth') {
                 $uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
                 $r = new Zend_Controller_Action_Helper_Redirector();
                 $r->gotoUrl('painel/auth?u=' . base64_encode($uri))->redirectAndExit();
             }
         }
     }
 }
Exemplo n.º 19
0
 public function deleteAction()
 {
     //delete fish
     //delete metadata fish done by DB
     $request = $this->getRequest();
     $fishId = intval($this->getRequest()->getParam(Fish::COL_ID));
     $fish = new Fish();
     $rowset = $fish->find($fishId);
     if (count($rowset) == 1) {
         //note: delete of metadata is executed from db
         $fish->delete($fish->getAdapter()->quoteInto(Fish::COL_ID . ' = ?', $fishId));
     }
     $redirect = new Zend_Controller_Action_Helper_Redirector();
     $redirect->setGoto('search', 'search', 'fish');
 }
 public function editAction()
 {
     $itemId = $this->_request->getParam('id');
     if (is_null($itemId)) {
         $this->_redirector->gotoUrlAndExit($this->getCurrentUrl());
         return;
     }
     $item = $this->_modelMapper->find($itemId, new Forum_Model_Forum());
     $oldContent = $item->getContent();
     $markdown = $this->_request->getParam('contentMarkdown');
     if ($markdown && $markdown != '') {
         $context_html = Michelf\MarkdownExtra::defaultTransform($markdown);
         $item->setContent($context_html);
         $item->setContentMarkdown($markdown);
         $item->setTimestamp(date("Y-m-d H:i:s"));
         if ($this->_userAuth->email != $item->getEmail()) {
             $item->setAuthor($this->_userAuth->name);
             $item->setEmail($this->_userAuth->email);
             $this->sendEditMail($item, $oldContent);
         }
         $this->_modelMapper->save($item);
     }
     $cacheName = !$item->getParentId() ? 'forumQuestions' : 'forumReply';
     $this->clearCache($cacheName);
     $this->_redirector->gotoUrlAndExit($this->getCurrentUrl());
 }
Exemplo n.º 21
0
 /**
  * direct() is an alias for goto(), which is an alias for setGoto()
  */
 public function testDirect()
 {
     $request = $this->request;
     $request->setModuleName('blog')->setControllerName('list')->setActionName('all');
     $this->redirector->direct('error');
     $this->assertEquals('/blog/list/error', $this->redirector->getRedirectUrl());
 }
Exemplo n.º 22
0
 public function testPassingDefaultModuleShouldNotRenderModuleNameInRedirectUrl()
 {
     $this->request->setModuleName('admin')->setControllerName('class')->setActionName('view');
     $this->redirector->gotoSimple('login', 'account', 'default');
     $test = $this->redirector->getRedirectUrl();
     $this->assertEquals('/account/login', $test, $test);
 }
 public function addAction()
 {
     if ($this->_request->isPost()) {
         $url = $this->_request->getParam('currentUrl');
         if ($this->_request->getParam('dataFormProducts')) {
             $dataProducts = $this->_request->getParam('dataFormProducts');
             //основные - sku, name, description, note, sorting, path
             $product = new Catalog_Model_Products($dataProducts);
             //modDate, order
             $product->setMetaTitle($dataProducts['name'])->setMetaDescription($dataProducts['description'])->setMetaKeywords($dataProducts['name'])->setOrder($dataProducts['sorting'])->setActive(1)->setDeleted(0)->setAddDate(date("Y-m-d H:i:s"))->setModDate(date("Y-m-d H:i:s"));
             $this->_modelMapper->save($product);
             $productId = $this->_modelMapper->getDbTable()->getAdapter()->lastInsertId();
             $categoriesMapperXref = new Catalog_Model_Mapper_CategoriesXref();
             $categoriesMapperXref->save(new Catalog_Model_CategoriesXref(array('productId' => $productId, 'categoryId' => $this->_request->getParam('categoryId'))));
             $product = $this->_modelMapper->find($productId, $this->_model);
             $upload = new Zend_File_Transfer();
             $uploadPath = '/upload/products/' . $product->getId() . '/';
             //image
             if ($upload->isUploaded('fileLoadImage')) {
                 $imageFile = $this->_uploadFiles($productId, $upload, 'fileLoadImage');
                 $product->setUploadPath($uploadPath)->setImage($imageFile['fileLoadImage']['name']);
             }
             //draft
             if ($upload->isUploaded('fileLoadDraft')) {
                 $imageFile = $this->_uploadFiles($productId, $upload, 'fileLoadDraft');
                 $product->setUploadPathDraft($uploadPath)->setDraft($imageFile['fileLoadDraft']['name']);
             }
             $this->_modelMapper->save($product);
             $url = '/catalog/' . $product->getFullPath();
         }
         $this->clearCache('CatalogProductsList');
         $this->_redirector->gotoUrlAndExit($url);
     }
     //Zend_Debug::dump($this->_request->getParams());
 }
 public function viewAction()
 {
     $request = $this->getRequest();
     $fullPath = $request->getParam('fullPath');
     $manufactureMapper = new Manufacture_Model_Mapper_Manufacture();
     $manufacture = $manufactureMapper->findByFullPath($fullPath, new Manufacture_Model_Manufacture());
     if (is_null($manufacture)) {
         throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
     }
     if (!is_null($this->getRequest()->getParam('json')) && Zend_Auth::getInstance()->hasIdentity()) {
         $this->forward('json', 'manufacture', 'admin', array('id' => $manufacture->getId()));
         return;
     }
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->_request->setParams(array('dataItem' => array('controller' => 'manufacture', 'id' => $manufacture->getId(), 'active' => $manufacture->getActive(), 'deleted' => $manufacture->getDeleted())));
     }
     $manufactureCategoryMapper = new Manufacture_Model_Mapper_ManufactureCategories();
     $manufactureCategory = $manufactureCategoryMapper->find($manufacture->getCategoryId(), new Manufacture_Model_ManufactureCategories());
     if ($manufacture->getDeleted() != '0') {
         if (!Zend_Auth::getInstance()->hasIdentity() && $manufacture->getDeleted() != '0') {
             throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
         }
         $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'manufacture-categories', 'action' => 'list', 'id' => $manufactureCategory->getId()), 'adminEdit', true);
     }
     $this->view->assign(array('manufacture' => $manufacture, 'meta_description' => $manufacture->getMetaDescription(), 'meta_keywords' => $manufacture->getMetaKeywords(), 'adminPath' => 'manufacture/edit/' . $manufacture->getId(), 'category' => $manufactureCategory));
     if ($manufacture->getActive() != '1' && !Zend_Auth::getInstance()->hasIdentity()) {
         $this->view->assign(array('title' => $manufacture->getTitle()));
         throw new Zend_Controller_Action_Exception("Страница временно не доступна", 403);
     }
 }
 public function addAction()
 {
     $form = new Front_Form_Contact();
     if ($this->_request->isPost()) {
         $data = $this->_request->getPost();
         if ($form->isValid($data)) {
             $dataFiltrees = $form->getValues();
             $contact = new Application_Model_Contact();
             $contact->setPrenom($dataFiltrees['prenom'])->setNom($dataFiltrees['nom'])->setEmail($dataFiltrees['email'])->setTelephone($dataFiltrees['telephone']);
             $this->mapper->insert($contact);
             $this->_flashMessenger->addMessage('Le contact ' . $contact->getPrenom() . ' a bien été créé');
             $this->_redirector->gotoRouteAndExit(['controller' => 'contact'], null, true);
         }
     }
     $this->view->contactForm = $form;
 }
 public function viewAction()
 {
     $request = $this->getRequest();
     $mediaPathItem = $request->getParam('fullPath');
     $mediaMapper = new Media_Model_Mapper_Media();
     $mediaItem = $mediaMapper->findByFullPath($mediaPathItem, new Media_Model_Media());
     if (is_null($mediaItem)) {
         throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
     }
     if (!is_null($this->getRequest()->getParam('json')) && Zend_Auth::getInstance()->hasIdentity()) {
         $this->forward('json', 'media', 'admin', array('id' => $mediaItem->getId()));
         return;
     }
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->_request->setParams(array('dataItem' => array('controller' => 'media', 'id' => $mediaItem->getId(), 'active' => $mediaItem->getActive(), 'deleted' => $mediaItem->getDeleted())));
     }
     $mediaCategoryMapper = new Media_Model_Mapper_MediaCategories();
     $currentCategory = $mediaCategoryMapper->find($mediaItem->getCategoryId(), new Media_Model_MediaCategories());
     if ($mediaItem->getDeleted() != '0') {
         if (!Zend_Auth::getInstance()->hasIdentity() && $mediaItem->getDeleted() != '0') {
             throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
         }
         $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'media-categories', 'action' => 'list', 'id' => $currentCategory->getId()), 'adminEdit', true);
     }
     $this->view->assign(array('currentCategory' => $currentCategory, 'adminPath' => 'media/edit/' . $mediaItem->getId()));
     $meta_description = $mediaItem->getMetaDescription() != '' ? $mediaItem->getMetaDescription() : $mediaItem->getName() . '. ' . $currentCategory->getName() . '. Альфа-Гидро.';
     $meta_keywords = $mediaItem->getMetaKeywords() != '' ? $mediaItem->getMetaKeywords() : $mediaItem->getName() . ', ' . $currentCategory->getName() . ', пресса';
     $this->view->assign(array('mediaItem' => $mediaItem, 'meta_description' => $meta_description, 'meta_keywords' => $meta_keywords));
     if ($mediaItem->getActive() != '1' && !Zend_Auth::getInstance()->hasIdentity()) {
         $this->view->assign(array('title' => $mediaItem->getName()));
         throw new Zend_Controller_Action_Exception("Страница временно не доступна", 403);
     }
 }
 public function editAction()
 {
     if ($this->_request->getParam('dataPage')) {
         $dataPage = $this->_request->getParam('dataPage');
         $id = $this->_request->getParam('id');
         $categories = $this->_modelMapper->find($id, $this->_model);
         $categories->setOptions($dataPage);
         $this->setUploadImage($categories);
         $markdown = $dataPage['contentMarkdown'];
         $context_html = Michelf\MarkdownExtra::defaultTransform($markdown);
         $categories->setContentHtml($context_html);
         $this->_modelMapper->save($categories);
         $this->_redirector->gotoUrlAndExit('/manufacture/' . $categories->getPath());
     }
     parent::editAction();
 }
Exemplo n.º 28
0
 /**
  * Rejects activation if exit() as it leads to untestable code.
  *
  * @param boolean $flag
  * @return Mol_Test_Controller_Action_Helper_Redirector Provides a fluent interface.
  * @throws Mol_Test_Exception If method is called to activate exit behavior.
  */
 public function setExit($flag)
 {
     if ($flag) {
         $message = __METHOD__ . '(): Do not force calls to exit() as these will terminate ' . 'the whole test run and therefore make the code untestable.';
         throw new Mol_Test_Exception($message);
     }
     return parent::setExit($flag);
 }
Exemplo n.º 29
0
 public function setGoto($action, $controller = null, $module = null, $params = array())
 {
     if (!is_array($params)) {
         $params = array();
     }
     $params = $this->_appendSid($params);
     parent::setGoto($action, $controller, $module, $params);
 }
 public function seoAction()
 {
     $pageId = $this->_request->getParam('id');
     if (is_null($pageId)) {
         $this->_redirector->gotoSimpleAndExit('index');
     }
     $page = $this->_modelMapper->find($pageId, new Pages_Model_Pages());
     if ($this->getRequest()->isPost()) {
         if ($this->getRequest()->getParam('dataFormSeo')) {
             $dataFormSeo = $this->getRequest()->getParam('dataFormSeo');
             $page->setOptions($dataFormSeo);
             $this->_modelMapper->save($page);
         }
     }
     $url = $page->getPath() != 'home' ? '/' . $page->getPath() : '/';
     $this->_redirector->gotoUrlAndExit($url);
 }