Esempio n. 1
0
 public function cacheCleanGlobalAction()
 {
     HCMS_Cache::getInstance()->getObjectCache(Application_Model_TranslateMapper::getInstance())->clean();
     HCMS_Cache::getInstance()->getCoreCache()->clean();
     $this->_log("All caches cleaned explicitly.", Zend_Log::INFO);
     $this->_helper->json(array("success" => true));
 }
Esempio n. 2
0
 /**
  * Matches a user submitted path with a previously defined route.
  * Assigns and returns an array of defaults on a successful match.
  *
  * @param string $path Path used to match against this routing map
  *
  * @return array|false An array of assigned values or a false on a mismatch
  */
 public function match($path)
 {
     //$this->_log(sprintf("cms route match path: %s",  $path), Zend_Log::DEBUG);
     $path = trim($path, '/');
     //if singlelang than force lang manually
     $singleLang = Zend_Controller_Front::getInstance()->getParam('singleLang');
     if ($singleLang && $singleLang != '') {
         $path = $singleLang . '/' . $path;
     }
     $parts = explode('/', $path);
     //grab lang
     if (count($parts) == 0) {
         $lang = null;
         $findUri = '';
     } else {
         $lang = $parts[0];
         if (Application_Model_TranslateMapper::getInstance()->isLangAvailable($lang)) {
             array_shift($parts);
         } else {
             $lang = null;
         }
         $findUri = implode('/', $parts);
     }
     $route = new Cms_Model_Route();
     if (!Cms_Model_RouteMapper::getInstance()->findByUri($findUri, 1, $route, $lang)) {
         //$this->_log(sprintf("cms route path [%s] not found",  $path), Zend_Log::DEBUG);
         return false;
     }
     list($module, $controller, $action) = explode('/', $route->get_path());
     $result = array('module' => $module, 'controller' => $controller, 'action' => $action, 'lang' => $lang);
     foreach ($route->get_params() as $paramName => $paramValue) {
         $result[$paramName] = $paramValue;
     }
     return $result;
 }
 /**
  * List categories
  */
 public function categoryAction()
 {
     $this->view->languages = Application_Model_TranslateMapper::getInstance()->getLanguages();
     $this->view->categorySets = Cms_Model_CategorySetMapper::getInstance()->getCategorySets();
     $this->view->pageTypes = Cms_Model_PageTypeMapper::getInstance()->fetchAll();
     $modules = Application_Model_ModuleMapper::getInstance()->fetchAll(array('application_id' => $this->_applicationId));
     $this->view->modules = $modules;
 }
Esempio n. 4
0
 /**
  * Get default locale/lang
  *
  * @return string|null
  */
 public static function getDefaultLocale()
 {
     return Application_Model_TranslateMapper::getInstance()->getDefaultLang();
     /* $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
        $options = $bootstrap->getOption('resources');
        if(isset ($options) && isset ($options['locale']) && isset ($options['locale']['default'])) {
        return $options['locale']['default'];
        }
        else {
        return null;
        } */
 }
 /**
  * List ajax action
  */
 public function listAction()
 {
     $page = $this->_request->getParam('page');
     $perPage = $this->_request->getParam('perPage');
     $orderFilter = $this->_request->getParam('order');
     $criteria = array('application_id' => $this->_applicationId);
     if (null != $this->_getParam('langFilter')) {
         $criteria['lang'] = $this->_getParam('langFilter');
     }
     if (null != $this->_getParam('statusFilter')) {
         $criteria['status'] = $this->_getParam('statusFilter');
     }
     if (null != $this->_getParam('genderFilter')) {
         $criteria['gender'] = $this->_getParam('genderFilter');
     }
     if (null != $this->_getParam('subscribed_from_dt')) {
         $criteria['subscribed_from'] = HCMS_Utils_Date::dateLocalToIso($this->_getParam('subscribed_from_dt'));
     }
     if (null != $this->_getParam('subscribed_to_dt')) {
         $criteria['subscribed_to'] = HCMS_Utils_Date::dateLocalToIso($this->_getParam('subscribed_to_dt'));
     }
     if (null != $this->_getParam('unsubscribed_from_dt')) {
         $criteria['unsubscribed_from'] = HCMS_Utils_Date::dateLocalToIso($this->_getParam('unsubscribed_from_dt'));
     }
     if (null != $this->_getParam('unsubscribed_to_dt')) {
         $criteria['unsubscribed_to'] = HCMS_Utils_Date::dateLocalToIso($this->_getParam('unsubscribed_to_dt'));
     }
     if (isset($orderFilter) && !empty($orderFilter)) {
         $orderBy = array($orderFilter);
     } else {
         $orderBy = array('s.subscribed_dt DESC', 's.unsubscribed_dt DESC', 's.id DESC');
     }
     if (!isset($page) || $page < 1) {
         $page = 1;
     }
     if (!isset($perPage) || $perPage < 1 || $perPage > 100) {
         $perPage = 100;
     }
     $paging = array('page' => $page, 'perPage' => $perPage);
     $records = Contact_Model_SubscriptionMapper::getInstance()->fetchAll($criteria, $orderBy, $paging);
     $data = array('total' => $paging['total'], 'page' => $paging['page'], 'records' => $paging['records'], 'perPage' => $paging['perPage'], 'rows' => array());
     $languages = Application_Model_TranslateMapper::getInstance()->getLanguages();
     /* @var $record Contact_Model_Subscription */
     foreach ($records as $record) {
         $data['rows'][] = array('id' => $record->get_id(), 'subscribed' => HCMS_Utils_Time::timeMysql2Local($record->get_subscribed_dt()), 'unsubscribed' => HCMS_Utils_Time::timeMysql2Local($record->get_unsubscribed_dt()), 'status' => $record->get_status(), 'first_name' => $record->get_first_name(), 'last_name' => $record->get_last_name(), 'email' => $record->get_email(), 'gender' => $this->translate($record->get_gender()), 'language' => $languages[$record->get_lang()]['name']);
     }
     $this->_helper->json->sendJson($data);
 }
 public function activateAction()
 {
     //Get theme name
     $theme = $this->_getParam('theme');
     // Update database
     $mapper = Application_Model_ApplicationMapper::getInstance();
     $appSettings = $mapper->fetchAll();
     $settings = $appSettings[0]->get_settings();
     $settings['theme'] = $theme;
     $app = new Application_Model_Application();
     $app->set_settings($settings);
     $app->set_id(1);
     $mapper->save($app);
     //Create symlinks
     //$this->_createSymlinks($theme);
     //Delete cache
     HCMS_Cache::getInstance()->getObjectCache(Application_Model_TranslateMapper::getInstance())->clean();
     HCMS_Cache::getInstance()->getCoreCache()->clean();
     //Return json
     $this->_helper->json(array('message' => $this->translate("Theme is activated"), 'success' => true));
 }
 private function createMenuList($records, &$data)
 {
     foreach ($records as $key => $record) {
         $item = $record['entity'];
         $lang = null != $this->_getParam('langFilter') ? $this->_getParam('langFilter') : Application_Model_TranslateMapper::getInstance()->getDefaultLang();
         if (!is_null($item->get_page_id())) {
             //default path
             $module = 'cms';
             $controller = 'page';
             $action = 'index';
         } else {
             $mca = explode("/", $item->get_path());
             $module = isset($mca[0]) ? $mca[0] : "";
             $controller = isset($mca[1]) ? $mca[1] : "";
             $action = isset($mca[2]) ? $mca[2] : "";
         }
         $urlParams = array('module' => $module, 'controller' => $controller, 'action' => $action, 'page_id' => $item->get_page_id(), 'lang' => $lang);
         $data['rows'][] = array('id' => $item->get_id(), 'name' => $item->get_name(), 'level' => $item->get_level(), 'hidden' => $item->get_hidden(), 'parent_id' => $item->get_parent_id(), 'ord_num' => $item->get_ord_num(), 'url' => $this->view->url($urlParams, 'cms', true));
         if (count($record['pages']) > 0) {
             $this->createMenuList($record['pages'], $data);
         }
     }
     return $data;
 }
Esempio n. 8
0
 protected function loadLanguages()
 {
     $transMapper = Application_Model_TranslateMapper::getInstance();
     $defLanguage = $transMapper->getDefaultLang();
     $languages = $transMapper->getLanguages();
     $this->languages[] = $defLanguage;
     foreach ($languages as $code => $lang) {
         if (!$lang['default'] && $lang['front_enabled']) {
             $this->languages[] = $code;
         }
     }
 }
 public function userEditAction()
 {
     $data = $this->getRequest()->getPost('data');
     $id = $this->_getParam('id');
     $aclLoader = HCMS_Acl_Loader::getInstance();
     //check permission
     if ($aclLoader->getAcl()->isAllowed($aclLoader->getCurrentRoleCode(), "admin", "master")) {
         $this->view->isAdminLogged = true;
         $data["isAdminLogged"] = true;
     } else {
         $this->view->isAdminLogged = false;
         $data["isAdminLogged"] = false;
     }
     //check if cancel button is pressed
     if ($this->_formHelper->isCancel()) {
         //cancel form
         return $this->_formHelper->returnCancel($this->view->url(array('action' => 'user-edit')), $this->translate('Action canceled'));
     }
     //create form object
     $form = new Auth_Form_User($data);
     //postback - save?
     if ($this->_formHelper->isSave()) {
         //check if valid
         if ($form->isValid()) {
             $values = $form->getValues();
             //create entity object from submitted values, and save
             $user = new Auth_Model_User($values);
             $date = new Zend_Date();
             $user->set_changed_password_dt($date->toString('yyyy-MM-dd HH:mm:ss'));
             if (isset($id) && $id > 0) {
                 if (isset($values['new_password']) && $values['new_password'] != '') {
                     $user->set_password($values['new_password']);
                 }
                 $this->savePassHistory($id);
             }
             Auth_Model_UserMapper::getInstance()->save($user);
             //save done, return success
             return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'user-edit')), $this->translate('User 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) {
             $user = new Auth_Model_User();
             if (!Auth_Model_UserMapper::getInstance()->find($id, $user)) {
                 throw new Exception("User not found");
             }
             //fetch data
             $data = $user->toArray();
         }
     }
     $criteria = array();
     $roles = Auth_Model_RoleMapper::getInstance()->fetchAll($criteria);
     $languages = Application_Model_TranslateMapper::getInstance()->getLanguages();
     $this->view->roles = $roles;
     $this->view->languages = $languages;
     $this->view->data = $data;
     //die(print_R($data));
 }
Esempio n. 10
0
 /**
  * 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 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 itemEditAction()
 {
     $data = $this->getRequest()->getPost('data');
     $id = $this->_getParam('id');
     $cloneId = $this->_getParam('clone_id');
     $langFilter = $this->_getParam('langFilter');
     $defaultTeaserId = $this->_getParam('teaser_id');
     //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 Teaser_Form_TeaserItem($data);
     //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 Teaser_Model_Item($values);
             $item->set_start_dt(HCMS_Utils_Date::dateLocalToIso($item->get_start_dt()));
             if (isset($data["end_dt"]) && $data["end_dt"] != "") {
                 $item->set_end_dt(HCMS_Utils_Date::dateLocalToIso($item->get_end_dt()));
             }
             Teaser_Model_ItemMapper::getInstance()->save($item, $langFilter != '' ? $langFilter : null);
             //save done, return success
             return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'index')), $this->translate('Item saved.'));
         } else {
             //we have errors - return json or continue
             $this->_formHelper->returnError($form->getMessages());
         }
     } elseif (!$this->_formHelper->getRequest()->isPost()) {
         if (!isset($id) && isset($cloneId)) {
             $id = $cloneId;
         }
         //edit action
         if (isset($id) && $id > 0) {
             $item = new Teaser_Model_Item();
             if (!Teaser_Model_ItemMapper::getInstance()->find($id, $item, $langFilter != '' ? $langFilter : null)) {
                 throw new Exception("Item not found");
             }
             Teaser_Model_ItemMapper::getInstance()->populateTeaserIds($item);
             //fetch data
             $data = $item->toArray();
             $data['start_dt'] = HCMS_Utils_Date::dateIsoToLocal($item->get_start_dt(), "HH:mm");
             $data['end_dt'] = HCMS_Utils_Date::dateIsoToLocal($item->get_end_dt(), "HH:mm");
             $data['teaser_ids'] = $item->get_teaser_ids();
             if (isset($cloneId)) {
                 unset($data['id']);
                 $data['title'] = 'Clone ' . $data['title'];
             }
             //populate form with data
             $form->setData($data);
         }
         if (null != $this->_getParam('box_code')) {
             $data['box_code'] = $this->_getParam('box_code');
         }
     }
     $languages = Application_Model_TranslateMapper::getInstance()->getLanguages();
     $this->view->languages = $languages;
     if (!isset($data['teaser_ids'])) {
         $data['teaser_ids'] = array();
     }
     $this->view->data = $data;
     //teasers with the same box
     $this->view->availableTeasers = Teaser_Model_TeaserMapper::getInstance()->fetchAll(array('box_code' => $data['box_code']));
     $this->view->defaultTeaserId = $defaultTeaserId;
 }
Esempio n. 13
0
 public function dialogAction()
 {
     $page_id = $this->getRequest()->getParam('page_id', '');
     $langFilter = $this->getRequest()->getParam('langFilter', '');
     $data = $this->getRequest()->getPost('data');
     $this->view->languages = Application_Model_TranslateMapper::getInstance()->getLanguages();
     $this->view->types = Cms_Model_PageTypeMapper::getInstance()->fetchAll();
     $this->view->page_id = $page_id;
     $this->view->langFilter = $langFilter;
     if ($this->_formHelper->isSave()) {
         return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'menu')), $this->translate('Page Selected.'), $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;
     $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;
 }
Esempio n. 15
0
 /**
  * Activate Zend translate DB and language, and locale
  *
  * @param string $language
  * @return string
  */
 public static function activate($language, $section = 'global')
 {
     //default FB locale, ex: en_US
     $language = Application_Model_TranslateMapper::getInstance()->getLang($language);
     //echo "Locale is chosen: " . $language . "<br>";
     //set locale
     Zend_Registry::get('Zend_Locale')->setLocale($language);
     /* @var $translate Zend_Translate */
     if (!Zend_Registry::isRegistered('Zend_Translate')) {
         $translate = new Zend_Translate(array('adapter' => 'HCMS_Translate_Adapter_Db', 'content' => 'db', 'locale' => $language, 'logMessage' => "Missing '%message%' within locale '%locale%'", 'logPriority' => Zend_Log::ALERT, 'logUntranslated' => true, 'disableNotices' => true, 'section' => $section));
         Zend_Registry::set('Zend_Translate', $translate);
     } else {
         $translate = Zend_Registry::get('Zend_Translate');
     }
     $translate->setLocale($language);
     return $language;
 }
Esempio n. 16
0
 /**
  * Add new translation key
  * 
  * @param array $translation
  * @param string $locale
  * @return int|false
  */
 public function addTranslation($translation, $locale)
 {
     if (!$this->isLangAvailable($locale)) {
         return false;
     }
     if (!isset($translation['language_id'])) {
         $translation['language_id'] = self::$_languages[$locale]['id'];
     }
     //clean cache
     HCMS_Cache::getInstance()->getObjectCache(Application_Model_TranslateMapper::getInstance())->clean();
     return $this->_dbTable->insert($translation);
 }
Esempio n. 17
0
 protected function _initLanguage()
 {
     $singleLang = Zend_Controller_Front::getInstance()->getParam('singleLang');
     if (isset($singleLang) && $singleLang != "") {
         //1. get language from app.ini
         $language = $singleLang;
         $this->getRequest()->setParam("lang", $singleLang);
     } else {
         //1. get language from request
         $language = $this->getRequest()->getParam("lang");
     }
     //$this->_log("Request: " . json_encode($this->getRequest()->getParams()), Zend_Log::DEBUG);
     if ($language == '') {
         $language = null;
     }
     //2. get language from cookie
     if (!isset($language)) {
         $language = $this->getRequest()->getCookie("saved_lang", null);
     }
     //3. get from geoip
     if (!isset($language)) {
         $country = new Application_Model_Country();
         if (Application_Model_CountryMapper::getInstance()->getCountryByGeoIp(HCMS_Utils::getRealIpAddr(), $country)) {
             $language = strtolower($country->get_def_lang());
         }
     }
     //4. get default
     if (!isset($language)) {
         $language = $this->_getPrimaryLang();
     }
     //check if lang available
     if (!HCMS_Translate_Adapter_Db::isLangAvailable($language, $this->_isFrontEnd)) {
         $language = $this->_getPrimaryLang();
     }
     //redirect if lang is not in url
     if ($language != $this->getRequest()->getParam("lang")) {
         //redirect only if lang not exists...otherwise let it 404
         if (!$this->getRequest()->getParam("lang")) {
             $this->_log("redirecting to {$language}", Zend_Log::DEBUG);
             $redirector = new Zend_Controller_Action_Helper_Redirector();
             $redirector->gotoRouteAndExit(array('lang' => $language), 'default', false);
         }
     }
     //activate lang
     HCMS_Translate_Adapter_Db::activate($language);
     //store lang in cookie
     $cookieRes = setcookie('saved_lang', $language, time() + 3600, '/', null, false, true);
     if (!$cookieRes) {
         $this->_logger->log("Error storing lang cookie", Zend_Log::WARN);
     }
     //and in router
     Zend_Controller_Front::getInstance()->getRouter()->setGlobalParam('lang', $language);
     //set view and js var
     if ($this->view) {
         $this->view->availableLang = Application_Model_TranslateMapper::getInstance()->getLanguages();
         $this->view->currLang = $language;
         $this->view->headScript()->appendScript("var CURR_LANG = '" . $language . "';");
         $this->view->singleLang = $this->isSingleLang();
         //$this->addLinkAlternateLang();
     }
     //define php const
     if (!defined("CURR_LANG")) {
         define("CURR_LANG", $language);
     }
 }
 public function indexAction()
 {
     $this->view->languages = Application_Model_TranslateMapper::getInstance()->getLanguages();
     $this->view->lang = (string) Zend_Registry::get('Zend_Locale')->getLanguage();
 }
Esempio n. 19
0
 public function exportToExcel($applicationId, $headerData, $records, $controller)
 {
     $logger = Zend_Registry::get('Zend_Log');
     try {
         /** PHPExcel */
         //require_once APPLICATION_PATH . '/../library/PHPExcel/PHPExcel.php';
         // Create new PHPExcel object
         $objPHPExcel = new PHPExcel();
         // Set properties
         $objPHPExcel->getProperties()->setCreator("Horisen")->setLastModifiedBy("Horisen")->setTitle("Office  XLS Test Document")->setSubject("Office  XLS Test Document")->setDescription("Test document for Office XLS, generated using PHP classes.")->setKeywords("office 5 openxml php")->setCategory("Test result file");
         // Set active sheet index to the first sheet, so Excel opens this as the first sheet
         $objPHPExcel->setActiveSheetIndex(0);
         //------------- HEADER settings ------------//
         //define style
         $styleHeader = array('font' => array('bold' => true), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('argb' => 'FFA0A0A0')));
         $languages = Application_Model_TranslateMapper::getInstance()->getLanguages();
         //set size of every column
         $columns = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
         foreach ($columns as $value) {
             $objPHPExcel->getActiveSheet()->getColumnDimension($value)->setAutoSize(true);
         }
         $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(20);
         //fill with data
         $activeSheet = $objPHPExcel->getActiveSheet();
         $i = 0;
         foreach ($headerData as $key => $val) {
             $activeSheet->setCellValue($columns[$i] . "1", $controller->translate($val));
             //apply style to header
             $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($i, "1")->applyFromArray($styleHeader);
             $i++;
         }
         //------------- BODY settings ------------//
         //define style
         $styleBody = array('font' => array('bold' => false), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID));
         if (count($records) > 0) {
             //fill with data
             $row = 2;
             foreach ($records as $record) {
                 $col = 0;
                 foreach ($headerData as $key => $value) {
                     if (isset($record[$key])) {
                         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $record[$key]);
                         //set size of every column
                         $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col)->setAutoSize(true);
                     }
                     $col++;
                 }
                 $row++;
             }
         }
         return $objPHPExcel;
     } catch (Exception $e) {
         $logger->log($e->getMessage(), Zend_Log::CRIT);
         $logger->log("Exception in export to excel!", Zend_Log::CRIT);
         return false;
     }
 }