示例#1
0
 /**
  * get instance
  *
  *
  * @return Cms_Model_PageMapper
  */
 public static function getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
示例#2
0
 public function contentBlock($id, $lang = null, $findBy = 'url_id', $type = null)
 {
     if (!isset($lang)) {
         $lang = CURR_LANG;
     }
     if (!isset($type)) {
         $type = $this->_type;
     }
     $block = new Cms_Model_Page();
     if ($findBy == 'url_id') {
         $result = Cms_Model_PageMapper::getInstance()->findByUrlId($id, $this->_application_id, $block, $lang, $type);
     } elseif ($findBy == 'id') {
         $result = Cms_Model_PageMapper::getInstance()->find($id, $block, $lang);
     } else {
         $result = Cms_Model_PageMapper::getInstance()->findByCode($id, $this->_application_id, $block, $lang);
     }
     if (!$result) {
         return false;
     }
     $pageFormat = $block->get_format();
     //render differently based on format
     switch ($pageFormat) {
         case 'html':
             return $this->view->frontAdmin()->renderEditable($block->get_content(), $block);
             break;
         case 'path':
             if (isset($this->view->theme)) {
                 $themePath = APPLICATION_PATH . '/../themes/' . $this->view->theme . '/views/cms';
                 //add theme view path
                 $this->view->addScriptPath($themePath);
             }
             return $this->view->render('page/static/' . $block->get_content());
             break;
     }
 }
 /**
  * Ajax save page content
  * 
  * @return mixed
  */
 public function saveAction()
 {
     $pageId = $this->_getParam('id');
     $lang = $this->_getParam('lang');
     $content = $this->_getParam('content');
     if (!$pageId) {
         return $this->sendResult(false, 'No page defined');
     }
     if (!$lang) {
         return $this->sendResult(false, 'No lang defined');
     }
     if (!$content) {
         return $this->sendResult(false, 'No content defined');
     }
     $page = new Cms_Model_Page();
     if (!Cms_Model_PageMapper::getInstance()->find($pageId, $page, $lang)) {
         return $this->sendResult(false, 'Page not found');
     }
     $page->set_content($content);
     Cms_Model_PageMapper::getInstance()->save($page, $lang);
     return $this->sendResult(true, 'Content saved');
 }
示例#4
0
 /**
  * Theme Path view helper - prefixes theme path
  *
  * @param string $path Path without theme
  * @return string
  */
 public function slider($given_code)
 {
     $criteria = array('lang' => CURR_LANG, 'type_code' => 'slider');
     $slider_images = Cms_Model_PageMapper::getInstance()->fetchAll($criteria);
     //Zend_Debug::dump($slider_images);
     $slider_show_images = array();
     $order = array();
     if (count($slider_images) > 0) {
         foreach ($slider_images as $key => $slider_image) {
             $toShow = $slider_image->get_data('show');
             if (isset($toShow) && $toShow > 0) {
                 $order[$key] = $slider_image->get_data('order');
                 $slider_show_images[] = $slider_image->toArray();
             }
         }
     }
     array_multisort($order, SORT_ASC, $slider_show_images);
     $slider_images = $this->sortByCode($slider_show_images, $given_code);
     //$this->view->slider_show_images = $slider_show_images;
     $slider = "";
     if (count($slider_images) > 0) {
         $slider .= '<div class="slider">
                         <ul class="bxslider">';
         foreach ($slider_images as $slider_show_image) {
             $target = $slider_show_image['data']['target'];
             if (!isset($target) || $target == '') {
                 $target = "javascript:void(0);";
             }
             $slider_teaser = '';
             if (isset($slider_show_image['data']['teaser']) && $slider_show_image['data']['teaser'] != '') {
                 $slider_teaser = '<div class="sliderTeaserContainer"><div class="slider_teaser">' . $slider_show_image['data']['teaser'] . '</div></div>';
             }
             $slider .= '<li style="background:url(../1/' . $slider_show_image['data']['img'] . ') no-repeat center center; height: 350px;"><a href="' . $target . '" target="_blank" class="slider_link"></a>' . $slider_teaser . '</li>';
         }
         $slider .= "</ul>\n                    </div>";
     }
     return $slider;
 }
示例#5
0
 /**
  * Add entries
  * 
  * @param array $criteria
  * @return array
  */
 protected function _addEntries(Zend_Feed_Writer_Feed $feed, $criteria)
 {
     //always show 50 newest
     $paging = array('perPage' => 50, 'page' => 1);
     $orderBy = array('p.posted DESC');
     $pages = Cms_Model_PageMapper::getInstance()->fetchAll($criteria, $orderBy, $paging);
     /*@var $page Cms_Model_Page */
     foreach ($pages as $page) {
         if (null == $page->get_content() || '' == $page->get_content()) {
             continue;
         }
         $entry = $feed->createEntry();
         $this->_populateFeedEntry($page, $entry);
         $feed->addEntry($entry);
     }
 }
示例#6
0
 protected function savePage($row)
 {
     $titles = explode("\n", $this->data[$row]['Name']);
     if (isset($this->data[$row]['Meta Keywords'])) {
         $metaKeywords = explode("\n", $this->data[$row]['Meta Keywords']);
     }
     if (isset($this->data[$row]['Meta Description'])) {
         $metaDescriptions = explode("\n", $this->data[$row]['Meta Description']);
     }
     $page = new Cms_Model_Page();
     $page->set_application_id(1)->set_format('html')->set_status('published')->set_type_id(1)->set_user_id(1)->set_posted(HCMS_Utils_Time::timeTs2Mysql(time()));
     foreach ($this->languages as $langIndex => $lang) {
         $curRow = $row;
         $title = $this->getLangText($titles, $langIndex);
         if (isset($metaKeywords)) {
             $metaKeyword = $this->getMetaKeywords($metaKeywords, $langIndex);
         }
         if (isset($metaDescriptions)) {
             $metaDescription = $this->getMetaDescription($metaDescriptions, $langIndex);
         }
         $urlIdParts = array();
         while (isset($this->data[$curRow])) {
             $currTitles = explode("\n", $this->data[$curRow]['Name']);
             if (isset($metaKeyword) && isset($metaDescription)) {
                 $meta = array("keywords" => $metaKeyword, "description" => $metaDescription);
             } else {
                 $meta = array("keywords" => "", "description" => "");
             }
             if (isset($currTitles[$langIndex])) {
                 $urlIdParts[] = $this->seoFilter->filter($currTitles[$langIndex]);
             }
             if (!isset($this->data[$curRow]['parent'])) {
                 break;
             }
             $curRow = $this->data[$curRow]['parent'];
         }
         $urlIdParts = array_reverse($urlIdParts);
         $urlId = implode('-', $urlIdParts);
         $page->set_code('')->set_url_id($urlId)->set_content('<h1>' . $title . '</h1>')->set_title($title)->set_meta($meta);
         if (Cms_Model_PageMapper::getInstance()->findByUrlId($urlId, 1, $page)) {
             continue;
         }
         Cms_Model_PageMapper::getInstance()->save($page, $lang);
     }
     $this->data[$row]['page_id'] = $page->get_id();
 }
示例#7
0
 protected function _listPages($categoryId, $typeId = null)
 {
     $paging = array('perPage' => 1, 'page' => $this->getRequest()->getParam("page"));
     $criteria = array('lang' => CURR_LANG, 'type_id' => $typeId, 'category_id' => $categoryId, 'status' => 'published');
     $orderBy = array('p.posted ASC');
     $pages = Cms_Model_PageMapper::getInstance()->fetchAll($criteria, $orderBy, $paging);
     $this->view->paginator = $paging['paginator'];
     $this->view->pages = $pages;
     $this->view->paging = $paging;
     $this->view->route = $this->_routeName;
 }
示例#8
0
 public function pageDeleteAction()
 {
     $id = $this->_getParam('page_id');
     $page = new Cms_Model_Page();
     if (!Cms_Model_PageMapper::getInstance()->find($id, $page)) {
         return $this->_formHelper->returnError($this->translate('Page not found.'));
     }
     if ((int) $page->get_application_id() != $this->_applicationId) {
         return $this->_formHelper->returnError($this->translate('Cannot delete this Page.'));
     }
     //check if page is in use
     if (Cms_Model_PageMapper::getInstance()->isInUse($page)) {
         return $this->_formHelper->returnError($this->translate('This page is in use in menus or routes.'));
     }
     Cms_Model_PageMapper::getInstance()->delete($page);
     //save done, return success
     return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'page')), $this->translate('Page deleted.'));
 }
 public function editAction()
 {
     $data = $this->getRequest()->getPost('data');
     $submit = $this->getRequest()->getPost('submit');
     $id = $this->_getParam('id');
     $data['lang'] = $this->_getParam('langFilter');
     /* get all modules */
     $criteria['application_id'] = $this->_applicationId;
     $modules = Application_Model_ModuleMapper::getInstance()->fetchAll($criteria);
     //check if cancel button is pressed
     if ($this->_formHelper->isCancel()) {
         //cancel form
         return $this->_formHelper->returnCancel($this->view->url(array('action' => 'index')), $this->translate('Action canceled'));
     }
     if (isset($data['path']) && $data['path'] != '') {
         foreach ($modules as $module) {
             $moduleData = $module->get_data();
             if (isset($moduleData['menus'])) {
                 foreach ($moduleData['menus'] as $path => $menu) {
                     if ($module->get_code() . "/" . $path == $data['path']) {
                         $data['dialog_url'] = $menu['dialog_url'];
                     }
                 }
             }
         }
     }
     //        print_r($data);die;
     //create form object
     $form = new Cms_Form_Route($data);
     //postback - save?
     if ($this->_formHelper->isSave()) {
         //check if valid
         if ($form->isValid()) {
             $values = $form->getValues();
             //create entity object from submitted values, and save
             $route = new Cms_Model_Route($values);
             //new entity
             if (!isset($data['id']) || $data['id'] <= 0) {
                 $route->set_application_id($this->_applicationId);
                 $existingRoute = clone $route;
                 if (Cms_Model_RouteMapper::getInstance()->checkRouteExist($existingRoute, $this->_applicationId)) {
                     $route->set_id($existingRoute->get_id());
                 }
             } else {
                 $existingRoute = new Cms_Model_Route();
                 if (!Cms_Model_RouteMapper::getInstance()->find($data['id'], $existingRoute)) {
                     throw new Exception("Menu not found");
                 }
                 if ((int) $existingRoute->get_application_id() != $this->_applicationId) {
                     throw new Exception("Cannot edit this Route.");
                 }
             }
             $route->set_application_id($this->_applicationId);
             Cms_Model_RouteMapper::getInstance()->save($route);
             //save done, return success
             return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'index')), $this->translate('Route saved.'));
         } else {
             //we have errors - return json or continue
             $this->_formHelper->returnError($form->getMessages());
         }
     } elseif (!$this->_formHelper->getRequest()->isPost()) {
         //edit action
         if (isset($id) && $id > 0) {
             $route = new Cms_Model_Route();
             if (!Cms_Model_RouteMapper::getInstance()->find($id, $route)) {
                 throw new Exception("Route not found");
             }
             $data = $route->toArray();
             //populate form with data
             $form->setData($data);
         }
     }
     $this->view->languages = Application_Model_TranslateMapper::getInstance()->getLanguages();
     $this->view->modules = $modules;
     $page = new Cms_Model_Page();
     if (isset($data['page_id'])) {
         Cms_Model_PageMapper::getInstance()->find($data['page_id'], $page);
     }
     $this->view->page_title = $page->get_title();
     $this->view->langFilter = $data['lang'];
     $this->view->data = $data;
 }
 public function editAction()
 {
     $data = $this->getRequest()->getPost('data');
     $submit = $this->getRequest()->getPost('submit');
     $id = $this->_getParam('id');
     $data['lang'] = $this->_getParam('langFilter');
     /* get all modules */
     $criteria['application_id'] = $this->_applicationId;
     //check if cancel button is pressed
     if ($this->_formHelper->isCancel()) {
         //cancel form
         return $this->_formHelper->returnCancel($this->view->url(array('action' => 'index')), $this->translate('Action canceled'));
     }
     //create form object
     $form = new Cms_Form_RouteRedirect($data);
     //postback - save?
     if ($this->_formHelper->isSave()) {
         //check if valid
         if ($form->isValid()) {
             $values = $form->getValues();
             //create entity object from submitted values, and save
             $route = new Cms_Model_Route($values);
             $route->set_application_id($this->_applicationId);
             $route->set_path("cms/redirect/index");
             $route->set_params("url/" . urlencode($route->get_params()));
             Cms_Model_RouteMapper::getInstance()->save($route);
             //save done, return success
             return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'index')), $this->translate('Route saved.'));
         } else {
             //we have errors - return json or continue
             $this->_formHelper->returnError($form->getMessages());
         }
     } elseif (!$this->_formHelper->getRequest()->isPost()) {
         //edit action
         if (isset($id) && $id > 0) {
             $route = new Cms_Model_Route();
             if (!Cms_Model_RouteMapper::getInstance()->find($id, $route)) {
                 throw new Exception("Route not found");
             }
             $data = $route->toArray();
             $data["params"] = urldecode(substr($data["params"], 4));
             //populate form with data
             $form->setData($data);
         }
     }
     $this->view->languages = Application_Model_TranslateMapper::getInstance()->getLanguages();
     $page = new Cms_Model_Page();
     if (isset($data['page_id'])) {
         Cms_Model_PageMapper::getInstance()->find($data['page_id'], $page);
     }
     $this->view->page_title = $page->get_title();
     $this->view->langFilter = $data['lang'];
     $data["path"] = "cms/redirect/index";
     $this->view->data = $data;
 }
 public function menuEditAction()
 {
     $data = $this->getRequest()->getPost('data');
     $submit = $this->getRequest()->getPost('submit');
     $id = $this->_getParam('id');
     $langFilter = $this->_getParam('langFilter');
     $menuFilter = $this->_getParam('menuFilter');
     /* get routes from application.ini */
     $bootstrap = $this->getInvokeArg('bootstrap');
     $routes = array_keys($bootstrap->getResource('router')->getRoutes());
     /* get all modules */
     $criteria['application_id'] = $this->_applicationId;
     $modules = Application_Model_ModuleMapper::getInstance()->fetchAll($criteria);
     //check if cancel button is pressed
     if ($this->_formHelper->isCancel()) {
         //cancel form
         return $this->_formHelper->returnCancel($this->view->url(array('action' => 'menu')), $this->translate('Action canceled'));
     }
     if (isset($data['path']) && $data['path'] != '') {
         foreach ($modules as $module) {
             $moduleData = $module->get_data();
             if (isset($moduleData['menus'])) {
                 foreach ($moduleData['menus'] as $path => $menu) {
                     if ($module->get_code() . "/" . $path == $data['path']) {
                         $data['dialog_url'] = $menu['dialog_url'];
                     }
                 }
             }
         }
     }
     //create form object
     $form = new Cms_Form_MenuItem($data);
     $route = new Cms_Model_Route();
     //postback - save?
     if ($this->_formHelper->isSave()) {
         //check if valid
         if ($form->isValid()) {
             $values = $form->getValues();
             //create entity object from submitted values, and save
             $item = new Cms_Model_MenuItem($values);
             if ($data['route'] == '') {
                 $item->set_path('');
                 $item->set_page_id('');
                 $item->set_page_id_new('');
                 $item->set_params('');
             } else {
                 $item->set_uri('');
             }
             //new entity
             if (!isset($data['id']) || $data['id'] <= 0) {
                 $item->set_application_id($this->_applicationId);
             } else {
                 $existingMenu = new Cms_Model_MenuItem();
                 if (!Cms_Model_MenuItemMapper::getInstance()->find($data['id'], $existingMenu)) {
                     throw new Exception("Menu not found");
                 }
                 if ((int) $existingMenu->get_application_id() != $this->_applicationId) {
                     throw new Exception("Cannot edit this Menu Item.");
                 }
             }
             $item->set_application_id($this->_applicationId);
             Cms_Model_MenuItemMapper::getInstance()->save($item, $langFilter);
             //save done, return success
             return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'menu')), $this->translate('Menu Item saved.'));
         } else {
             //we have errors - return json or continue
             $this->_formHelper->returnError($form->getMessages());
         }
     } elseif (!$this->_formHelper->getRequest()->isPost()) {
         //edit action
         if (isset($id) && $id > 0) {
             $item = new Cms_Model_MenuItem();
             if (!Cms_Model_MenuItemMapper::getInstance()->find($id, $item, $langFilter)) {
                 throw new Exception("Menu not found");
             }
             Cms_Model_RouteMapper::getInstance()->findByPath($item->get_path(), $this->_applicationId, $route, $item->get_params(), $langFilter != '' ? $langFilter : null);
             $item->set_route_uri($route->get_uri());
             $params = $item->get_params();
             $item->set_params(Cms_Model_MenuItemMapper::getInstance()->unsetParamsPageId($params));
             //fetch data
             $data = $item->toArray();
             //populate form with data
             $form->setData($data);
         }
     }
     $this->view->menus = Cms_Model_MenuMapper::getInstance()->getMenus();
     $this->view->menuFilter = $menuFilter;
     $this->view->langFilter = $langFilter;
     $this->view->routes = $routes;
     $this->view->modules = $modules;
     $page = new Cms_Model_Page();
     if (isset($data['page_id'])) {
         Cms_Model_PageMapper::getInstance()->find($data['page_id'], $page);
     }
     $this->view->page_title = $page->get_title();
     $this->view->data = $data;
 }