public function init() { //set timeout $this->_sessionAdmin = new Zend_Session_Namespace(Zend_Auth_Storage_Session::NAMESPACE_DEFAULT); $this->_sessionAdmin->setExpirationSeconds(30 * 60); //load acl $aclLoader = HCMS_Acl_Loader::getInstance(); $aclLoader->load(); if (!Zend_Auth::getInstance()->hasIdentity()) { $this->_admin = null; } else { $this->_admin = Zend_Auth::getInstance()->getIdentity(); $aclLoader->setCurrentRoleCode($aclLoader->getRoleCode($this->_admin->get_role_id())); } $this->view->admin = $this->_admin; if ($this->_checkAuth) { $this->_checkAuthorization(); } $this->_redirect_to_ssl(); $this->_checkIP(); //set ACL object for Zend_Navigation Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($aclLoader->getAcl()); Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($aclLoader->getCurrentRoleCode()); $this->_initVersionInfo(); $this->_module = new Application_Model_Module(); if (Application_Model_ModuleMapper::getInstance()->findByCode($this->getRequest()->getModuleName(), $this->_module)) { $this->view->moduleSettings = $this->_module->get_settings(); } parent::init(); }
public function init() { parent::init(); $this->_module = new Application_Model_Module(); if (Application_Model_ModuleMapper::getInstance()->findByCode($this->getRequest()->getModuleName(), $this->_module)) { $this->view->sitemapSettings = $this->_module->get_settings('sitemap'); } }
public function init() { parent::init(); $this->_formHelper = $this->getHelper('ajaxForm'); $criteria['application_id'] = $this->_applicationId; $this->_modules = Application_Model_ModuleMapper::getInstance()->fetchAll($criteria); $this->_languages = Application_Model_TranslateMapper::getInstance()->getLanguages(); $this->_defaultLang = Application_Model_TranslateMapper::getInstance()->getDefaultLang(); }
public function init() { $this->_formHelper = $this->getHelper('ajaxForm'); $this->_module = new Application_Model_Module(); if (!Application_Model_ModuleMapper::getInstance()->findByCode($this->getRequest()->getModuleName(), $this->_module)) { throw new Exception("Contact module not installed"); } parent::init(); $this->_loadParams(); if ($this->hasFileUpload()) { $this->_genericFileHelper = new HCMS_File_GenericHelper($this->_application, $this->getInvokeArg('bootstrap')->getOption('fileserver')); Zend_Registry::set('genericFileHelper', $this->_genericFileHelper); } }
public function configAction() { $data = $this->getRequest()->getPost('data'); $submit = $this->getRequest()->getPost('submit'); $formTab = $this->getRequest()->getUserParam('tab', "Sitemap"); $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')); } $module = new Application_Model_Module(); //read contact module if (!Application_Model_ModuleMapper::getInstance()->findByCode("cms", $module)) { throw new Exception("CMS module not found"); } $this->view->menus = Cms_Model_MenuMapper::getInstance()->getMenus(); $this->view->data = $module->toArray(); $formClassName = "Cms_Form_Config" . $formTab; if (!class_exists($formClassName)) { $this->_formHelper->returnError("ne postoji"); } //create form object $form = new $formClassName($data); //postback - save? if ($this->_formHelper->isSave()) { //check if valid if ($form->isValid()) { $setings = $module->get_settings(); $setings['sitemap'] = $form->getValues(); //create module entity object $module->set_settings(json_encode($setings)); $module->set_data(json_encode($module->get_data())); //new entity Application_Model_ModuleMapper::getInstance()->save($module); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'config')), $this->translate('Configuration saved.')); } else { //we have errors - return json or continue $this->_formHelper->returnError($form->getMessages()); } } // print_r($data);die; }
/** * Returns inline style for a css selector * */ public function bgChanger($cssSelector = 'body') { $modules = Application_Model_ModuleMapper::getInstance()->fetchAll(array('status' => 'active')); $active = false; foreach ($modules as $module) { $activeModules = $module->get_code(); if ($activeModules == "bgchanger") { $active = true; } } if (!$active) { return ''; } //$bgchanger = new $activePage = null; if (!isset($this->view->menuItems)) { return ''; } //Zend_Debug::dump($this->view->menuItems); foreach ($this->view->menuItems as $currMenu => $menuContainer) { $activeMenu = $this->view->navigation()->findActive($menuContainer); if (isset($activeMenu) && isset($activeMenu['page'])) { /*@var $activePage Zend_Navigation_Page_Mvc */ $activePage = $activeMenu['page']; break; } } $html = ''; if ($activePage != null) { $menuItemBg = new Bgchanger_Model_MenuItemBackground(); $backgrounds = false; // TODO: OPTIONAL MAPPER FOR CONTENT // // MAPPER FOR MENU if ($activePage->entity instanceof Cms_Model_MenuItem) { $i = 0; // LOOP THROUGH PARENTS while ($activePage && isset($activePage->entity) && $activePage->entity) { $backgrounds = Bgchanger_Model_MenuItemBackgroundMapper::getInstance()->fetchAll(array('cms_menu_item_id' => $activePage->entity->get_id())); /*Bgchanger_Model_MenuItemBackgroundMapper::getInstance()->find( $activePage->entity->get_id(), $menuItemBg );*/ if ($backgrounds && count($backgrounds)) { break; } $activePage = $activePage->getParent(); // JUST A HACK IF SOMETHING GOES WRONG ASSUMING THERE WILL BE NO MORE THAN 10 LEVELS $i++; if ($i > 10) { break; } } } $css = ''; if ($backgrounds && count($backgrounds)) { $menuItemBg = $backgrounds[0]; $bacgrounds = array_reverse($menuItemBg->get_content()); foreach ($bacgrounds as $key => $value) { $elements = explode("_", $key); $css .= "\n @media (min-width: " . $elements[1] . "px) {\n " . $cssSelector . "{\n background-image: url('" . $value . " '); \n }\n\n }"; } $html = " \n <style type='text/css'>\n " . $css . "\n </style>\n "; } } return $html; }
public function indexAction() { //get user object $user = new Auth_Model_User(); Auth_Model_UserMapper::getInstance()->find($this->_admin->get_id(), $user); $bootstrap = $this->getInvokeArg('bootstrap'); $config = $bootstrap->getOptions(); $this->view->clientId = isset($config['googleapi']['analitycs']['clientId']) && $config['googleapi']['analitycs']['clientId'] != '' ? $config['googleapi']['analitycs']['clientId'] : ''; //store dashbord if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->isPost()) { $dashboard = $this->_getParam('dashboard'); if (!isset($dashboard)) { $dashboard = array(); } $userData = $user->get_data(); $userData['dashboard'] = $dashboard; $user->set_data($userData); $user->set_password(null); Auth_Model_UserMapper::getInstance()->save($user); return $this->getHelper('json')->direct(array('success' => true)); } $this->view->widgetClasses = array(); $this->view->widgetJsFiles = array(); $this->view->widgetCssFiles = array(); //list modules $modules = Application_Model_ModuleMapper::getInstance()->fetchAll(array('status' => 'active')); /* @var $module Application_Model_Module */ foreach ($modules as $module) { $widgets = $module->get_data('widgets'); if (!isset($widgets)) { continue; } foreach ($widgets as $widgetClass => $widgetArr) { $this->view->widgetClasses[] = $widgetClass; foreach ($widgetArr['jsFiles'] as $jsFile) { $this->view->widgetJsFiles[] = $jsFile; } foreach ($widgetArr['cssFiles'] as $cssFile) { $this->view->widgetCssFiles[] = $cssFile; } } } //get configured user's dashboard $userDashboard = $user->get_data('dashboard'); if (!isset($userDashboard)) { $userDashboard = array('region1' => array('widgets' => array()), 'region2' => array('widgets' => array())); $i = 0; foreach ($this->view->widgetClasses as $widgetClass) { $widgetArr = array('componentClass' => $widgetClass, 'settings' => array()); $regionIndex = $i % 2 + 1; $userDashboard['region' . $regionIndex]['widgets'][] = $widgetArr; $i++; } } $this->view->userDashboard = $userDashboard; }
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 setEditAction() { $data = $this->getRequest()->getPost('data'); if ($this->_formHelper->isCancel()) { //cancel form return $this->_formHelper->returnCancel($this->view->url(array('action' => 'category')), $this->translate('Action canceled')); } //create form object $form = new Cms_Form_CategorySet($data); if ($this->_formHelper->isSave()) { if ($form->isValid()) { $values = $form->getValues(); $categorySet = new Cms_Model_CategorySet($values); Cms_Model_CategorySetMapper::getInstance()->save($categorySet); $data = array('success' => true, 'set' => Cms_Model_CategorySetMapper::getInstance()->getCategorySets(), 'message' => $this->translate("New Category added"), 'selected' => $categorySet->get_id()); $this->_helper->json->sendJson($data); } else { //we have errors - return json or continue $this->_formHelper->returnError($form->getMessages()); } } $modules = Application_Model_ModuleMapper::getInstance()->fetchAll(array('application_id' => $this->_applicationId)); $this->view->modules = $modules; }
/** * Configuration action */ public function configAction() { //read data from request $data = $this->getRequest()->getPost('data'); $inputHashChangePost = $this->_request->getParam('inputHashChangePost'); $inputHashChangeGet = $this->_request->getParam('inputHashChangeGet'); //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 ($this->getRequest()->getParam("type") == 'contact') { $module_name = "contact"; } else { if ($this->getRequest()->getParam("type") == 'newsletter') { $module_name = "newsletter"; } else { if ($this->getRequest()->getParam("type") == 'blog') { $module_name = "blog"; } else { throw new Exception("Contact module not found"); } } } //read contact module $module = new Application_Model_Module(); if (!Application_Model_ModuleMapper::getInstance()->findByCode($module_name, $module)) { throw new Exception("Contact module not found"); } $this->view->data = array('email' => $module->get_settings('email')); $this->view->data['type'] = $module_name; $this->view->emailTransportTypeOptions = Application_Model_Application::getEmailTransportTypeOptions(); //postback - save? if ($this->_formHelper->isSave()) { $formToEmails = new Contact_Form_ConfigToEmailsWrapper($data['email']['to_emails']); $formParameters = new Contact_Form_ConfigParameters($data['email']['parameters'], null, $data['email']['transport']); if ($module_name == 'contact') { $formEmail = new Contact_Form_ConfigEmail($data['email']); } elseif ($module_name == 'newsletter') { $formEmail = new Contact_Form_ConfigEmailNewsletter($data['email']); } elseif ($module_name == 'blog') { $formEmail = new Blog_Form_ConfigEmail($data['email']); } //check if valid if ($formEmail->isValid() && $formParameters->isValid() && $formToEmails->isValid()) { $data['email'] = $formEmail->getValues(); $data['email']['parameters'] = $formParameters->getValues(); $data['email']['to_emails'] = $formToEmails->getValues(); $lang = new Translation_Model_Lang(); if (!Translation_Model_LangMapper::getInstance()->findByCode(CURR_LANG, $lang)) { throw new Exception('No language for this code.'); } Translation_Model_TranslationMapper::getInstance()->save('mailtextRespondContactTranslationkey', $lang->get_id(), $data['email']['mailtext_respond_contact'], 'global'); $data['email']['mailtext_respond_contact'] = 'mailtextRespondContactTranslationkey'; Translation_Model_TranslationMapper::getInstance()->save('landingPageText', $lang->get_id(), $data['email']['landing_page_text'], 'global'); $data['email']['landing_page_text'] = 'landingPageText'; Translation_Model_TranslationMapper::getInstance()->save('subjectContactTranslationkey', $lang->get_id(), $data['email']['subject_contact'], 'global'); $data['email']['subject_contact'] = 'subjectContactTranslationkey'; //create module entity object $settings = $module->get_settings(); $settings['email'] = $data['email']; $module->set_settings(json_encode($settings)); $module->set_data(json_encode($module->get_data())); //new entity Application_Model_ModuleMapper::getInstance()->save($module); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'config', 'inputHashChangeGet' => $inputHashChangePost)), $this->translate('Configuration saved.')); } else { //we have errors - return json or continue $messages = $formEmail->getMessages(); $messages['parameters'] = $formParameters->getMessages(); $messages['to_emails'] = $formToEmails->getMessages(); $this->view->data = $data; $this->_formHelper->returnError($messages); } } if (isset($inputHashChangeGet) && $inputHashChangeGet != '') { $this->view->inputHashChange = $inputHashChangeGet; } else { $this->view->inputHashChange = "email-config"; } //country assign $countries = new Application_Model_Country(); $countries = Application_Model_CountryMapper::getInstance()->getAllCountries(CURR_LANG); $this->view->countries = $countries; $this->view->languages = Application_Model_TranslateMapper::getInstance()->getLanguages(); $this->view->fields = Contact_Form_Contact::getFields(); }
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; }