예제 #1
0
 /**
  * index pages
  */
 public function indexAction()
 {
     $error = '';
     $option = Translation_Model_TranslationMapper::getInstance()->getOptions($this->view);
     HCMS_Utils::generateFormatedOptions(Translation_Model_TranslationMapper::getInstance()->getTranslationSection($error), $section, $sectionValue, false);
     $this->view->section = $sectionValue;
     $this->view->option = json_encode($option);
 }
예제 #2
0
 protected function _loadParams()
 {
     $this->_globalSettings = HCMS_Utils::loadThemeConfig('config.php', 'contact');
     $fieldTypes = HCMS_Utils::loadThemeConfig('types.php', 'contact');
     if (!isset($this->_globalSettings['forms'][$this->_formId])) {
         throw new Exception("Form not found");
     }
     $this->_formParams = $this->_globalSettings['forms'][$this->_formId];
     $this->_fields = Contact_Form_Generic::getFieldsArr($fieldTypes, $this->_formParams['fields']);
 }
예제 #3
0
 /**
  * Set default value
  * 
  * @param string $dataCountryKey
  * @return mixed 
  */
 public function setDefault($dataCountryKey = 'country')
 {
     $emailParams = $this->_settings;
     if ($this->_actionController->getRequest()->isPost() || !isset($emailParams['ip_country_detection']) || $emailParams['ip_country_detection'] != 'yes') {
         return;
     }
     $ip = HCMS_Utils::getRealIpAddr();
     $myCountry = new Application_Model_Country();
     if (Application_Model_CountryMapper::getInstance()->getCountryByGeoIp($ip, $myCountry)) {
         $this->_actionController->view->data[$dataCountryKey] = $myCountry->get_code2();
     }
 }
 protected function _loadParams()
 {
     $this->_globalSettings = HCMS_Utils::loadThemeConfig('config.php', 'contact');
     $fieldTypes = HCMS_Utils::loadThemeConfig('types.php', 'contact');
     if ($this->_request->getParam('form_id')) {
         $this->_formId = $this->_request->getParam('form_id');
     }
     if (!isset($this->_globalSettings['forms'][$this->_formId])) {
         throw new Exception("Form not found");
     }
     $this->_formParams = $this->_globalSettings['forms'][$this->_formId];
     $this->_fields = Contact_Form_Generic::getFieldsArr($fieldTypes, $this->_formParams['fields']);
     $this->_entityClassName = $this->getEntityClassName();
     $this->_mapperClassName = $this->getMapperClassName();
     $this->_columns = $this->getColumns();
     $this->view->columns = $this->_columns;
     $this->view->formId = $this->_formId;
 }
예제 #5
0
 /**
  * Render picture tag
  *
  * @param string $imageSlug image ID
  * @param string $directory directory path
  * @param string $altText alt text
  * @param string $fileExt file extension including dot
  * @param array $params extra params
  * @return string
  */
 public function renderPicture($imageSlug, $directory, $altText = '', $fileExt = '.jpg', $params = array())
 {
     if (!isset(self::$imagesConf)) {
         self::$imagesConf = HCMS_Utils::loadThemeConfig('picture.php');
     }
     $section = isset($params['section']) ? $params['section'] : 'default';
     $images = self::$imagesConf[$section];
     if (isset($params['css_class'])) {
         $cssClass = ' class="' . $params['css_class'] . '"';
     } else {
         $cssClass = '';
     }
     $html = '<picture' . $cssClass . '><!--[if IE 9]><video style="display: none;"><![endif]-->';
     foreach ($images as $query => $suffix) {
         $path = $directory . '/' . $imageSlug . '_' . $suffix . $fileExt;
         if (isset($params['version'])) {
             $path .= '?v=' . $params['version'];
         }
         $html .= '<source srcset="' . $path . ' " media="' . $query . '">';
     }
     $html .= '<!--[if IE 9]></video><![endif]--><img srcset="' . $path . '" alt="' . $this->view->escape($altText) . '"></picture>';
     return $html;
 }
예제 #6
0
 protected function _initMenus()
 {
     $navigation = HCMS_Utils::loadThemeConfig('navigation.php', 'admin');
     $this->view->navigation(new Zend_Navigation($navigation));
 }
예제 #7
0
 public function widgetAction()
 {
     if ($this->getRequest()->isXmlHttpRequest()) {
         $this->getHelper('layout')->disableLayout();
     }
     $this->view->hostingQuota = $this->_fileHelper->getQuota();
     $this->view->hostingFreeSpace = $this->_fileHelper->getFreeSpace();
     $this->view->hostingUsed = $this->view->hostingQuota - $this->view->hostingFreeSpace;
     $this->view->hostingQuotaStr = HCMS_Utils::formatBytes($this->view->hostingQuota);
     $this->view->hostingFreeSpaceStr = HCMS_Utils::formatBytes($this->view->hostingFreeSpace);
     $this->view->hostingUsedStr = HCMS_Utils::formatBytes($this->view->hostingUsed);
 }
예제 #8
0
 /**
  * Save entity
  *
  * @param Cms_Model_MenuItem $item
  * @param string $language
  */
 public function save(Cms_Model_MenuItem $item, $language = null, $dontSaveRoute = false)
 {
     $data = array();
     $this->_entityToRow($item, $data);
     $id = $item->get_id();
     if (!isset($id) || $id <= 0) {
         unset($data['id']);
         $id = $this->_dbTable->insert($data);
         $item->set_id($id);
     } else {
         //if language is defined, save just untraslated strings
         if ($language && $language != HCMS_Utils::getDefaultLocale()) {
             foreach (self::$_translatedFields as $field) {
                 unset($data[$field]);
             }
         }
         $this->_dbTable->update($data, array('id = ?' => $id));
     }
     //save in translation table
     if ($language) {
         $this->_saveTranslation('cms_menu_item', $item->get_id(), $item, self::$_translatedFields, $language);
         if ($item->get_route() != '' && !$dontSaveRoute) {
             $route = new Cms_Model_Route();
             $this->_parseParams(isset($data['params']) ? $data['params'] : "", $item);
             $this->_parseParams($item->get_params_old() != '' ? $item->get_params_old() : "", $item, true);
             $paramsOld = $item->get_params_old();
             if (isset($paramsOld['page_id']) && $paramsOld['page_id'] == '') {
                 unset($paramsOld['page_id']);
             }
             $item->set_params_old($paramsOld);
             if (!Cms_Model_RouteMapper::getInstance()->findByPath($item->get_path(), $item->get_application_id(), $route, $item->get_params_old(), $language)) {
                 $route->set_lang($language)->set_application_id($item->get_application_id())->set_name($item->get_name())->set_path($item->get_path())->set_page_id($item->get_page_id_new())->set_uri($item->get_route_uri())->set_params($this->unsetParamsPageId($item->get_params()));
                 Cms_Model_RouteMapper::getInstance()->save($route);
             } else {
                 if ($route->get_uri() != $item->get_route_uri() || $route->get_page_id() != $item->get_page_id_new() || $this->unsetParamsPageId($item->get_params()) != $this->unsetParamsPageId($item->get_params_old())) {
                     $route->set_uri($item->get_route_uri());
                     $route->set_page_id($item->get_page_id_new());
                     $route->set_params($this->unsetParamsPageId($item->get_params()));
                     Cms_Model_RouteMapper::getInstance()->save($route);
                 }
             }
         }
     }
     $this->cleanCache();
 }
예제 #9
0
 /**
  * Save entity
  *
  * @param Cms_Model_Category $category
  */
 public function save(Cms_Model_Category $category, $language = null)
 {
     $data = array();
     $this->_entityToRow($category, $data);
     $id = $category->get_id();
     if (!isset($id) || $id <= 0) {
         unset($data['id']);
         $id = $this->_dbTable->insert($data);
         $category->set_id($id);
     } else {
         //if language is defined, save just untraslated strings
         if ($language && $language != HCMS_Utils::getDefaultLocale()) {
             foreach (self::$_translatedFields as $field) {
                 unset($data[$field]);
             }
         }
         $this->_dbTable->update($data, array('id = ?' => $id));
     }
     if ($language) {
         $this->_saveTranslation('cms_category', $category->get_id(), $category, self::$_translatedFields, $language, array('meta'));
     }
 }
예제 #10
0
 /**
  * Save entity
  *
  * @param Teaser_Model_Item $item
  * @param string $language
  */
 public function save(Teaser_Model_Item $item, $language = null)
 {
     $data = array();
     $this->_entityToRow($item, $data);
     if (!isset($data['item_template'])) {
         $data['item_template'] = null;
     }
     if ($data['fallback'] == 'yes') {
         $data['start_dt'] = '2014-10-01 00:00:00';
         $data['end_dt'] = '3000-01-01 00:00:00';
     }
     $id = $item->get_id();
     if (!isset($id) || $id <= 0) {
         unset($data['id']);
         $id = $this->_dbTable->insert($data);
         $item->set_id($id);
     } else {
         //if language is defined and curr lang is default one - save all in default table, else save just untraslated strings
         if ($language && $language != HCMS_Utils::getDefaultLocale()) {
             foreach (self::$_translatedFields as $field) {
                 unset($data[$field]);
             }
         }
         $this->_dbTable->update($data, array('id = ?' => $id));
     }
     //save in translation table
     if ($language) {
         $this->_saveTranslation('teaser_item', $item->get_id(), $item, self::$_translatedFields, $language, array('content'));
     }
     $this->_saveTeaserIds($item);
 }
예제 #11
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);
     }
 }
예제 #12
0
 /**
  * Save entity
  *
  * @param Cms_Model_Page $page
  * @param string $language
  */
 public function save(Cms_Model_Page $page, $language = null)
 {
     $data = array();
     $this->_entityToRow($page, $data);
     unset($data['extension']);
     $id = $page->get_id();
     if (!isset($id) || $id <= 0) {
         unset($data['id']);
         $id = $this->_dbTable->insert($data);
         $page->set_id($id);
     } else {
         //if language is defined and curr lang is default one - save all in default table, else save just untraslated strings
         //echo "curr lang: " . $language . ", def lang: " . HCMS_Utils::getDefaultLocale();
         if ($language && $language != HCMS_Utils::getDefaultLocale()) {
             foreach ($this->_translatedFields as $field) {
                 unset($data[$field]);
             }
         }
         //            print_r($data);die;
         if (!isset($data['code'])) {
             $data['code'] = "";
         }
         if ($language && $language == HCMS_Utils::getDefaultLocale()) {
             if (!isset($data['teaser'])) {
                 $data['teaser'] = "";
             }
             if (!isset($data['content'])) {
                 $data['content'] = "";
             }
         }
         $this->_dbTable->update($data, array('id = ?' => $id));
     }
     //save in translation table
     if ($language) {
         $this->_saveTranslation('cms_page', $page->get_id(), $page, $this->_translatedFields, $language, array('data', 'meta'));
     }
     //save extension
     $this->_saveExtension($page, $language);
 }
예제 #13
0
 /**
  * Get image params
  * 
  * @param array $dims
  * @param boolean $independent960
  * @return array
  */
 public function getImagesParams($dims, $section = 'default')
 {
     $imagesConf = HCMS_Utils::loadThemeConfig('picture.php');
     $variations = $imagesConf[$section];
     $result = array();
     $i = 0;
     foreach ($variations as $query => $suffix) {
         $width = $dims[$i * 2];
         $height = $dims[$i * 2 + 1];
         $elements = explode('_', $suffix);
         $vp = $elements[0];
         $density = count($elements) >= 2 ? $elements[1] : 1;
         $result['img_' . $suffix] = array("name" => "Image for viewport width {$vp} and density {$density}", "media_query" => $query, "options" => array("minwidth" => $width, "maxwidth" => $width, "minheight" => $height, "maxheight" => $height));
         $i++;
     }
     return $result;
 }
 public function editAction()
 {
     //load params
     $this->_globalSettings = HCMS_Utils::loadThemeConfig('config.php', 'contact');
     $fieldTypes = HCMS_Utils::loadThemeConfig('types.php', 'contact');
     if ($this->_request->getParam('form_id')) {
         $this->_formId = $this->_request->getParam('form_id');
     }
     if (!isset($this->_globalSettings['forms'][$this->_formId])) {
         throw new Exception("Form not found");
     }
     $this->_formParams = $this->_globalSettings['forms'][$this->_formId];
     $this->_fields = Contact_Form_Generic::getFieldsArr($fieldTypes, $this->_formParams['fields']);
     $data = $this->getRequest()->getPost('data');
     $id = $this->_getParam('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 Contact_Form_AdminSubscribe($data);
     //postback - save?
     if ($this->_formHelper->isSave()) {
         //check if valid
         if ($form->isValid()) {
             $values = $form->getValues();
             $subscription = new Contact_Model_Subscription($values);
             if (isset($data['id'])) {
                 $oldSubscription = new Contact_Model_Subscription();
                 if (Contact_Model_SubscriptionMapper::getInstance()->find($data['id'], $oldSubscription) && $oldSubscription->get_status() != $subscription->get_status()) {
                     $dt = date("Y-m-d H:i:s");
                     switch ($subscription->get_status()) {
                         case 'subscribed':
                             $subscription->set_subscribed_dt($dt);
                             break;
                         case 'unsubscribed':
                             $subscription->set_unsubscribed_dt($dt);
                             break;
                         default:
                             break;
                     }
                 }
             }
             Contact_Model_SubscriptionMapper::getInstance()->save($subscription);
             //sending done, return success
             return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'index')), $this->translate('Saved'));
         } else {
             $this->_formHelper->returnError($form->getMessages());
         }
     } elseif (!$this->_formHelper->getRequest()->isPost()) {
         //edit action
         if (isset($id) && $id > 0) {
             $subscription = new Contact_Model_Subscription();
             if (!Contact_Model_SubscriptionMapper::getInstance()->find($id, $subscription)) {
                 throw new Exception("Record not found");
             }
             //fetch data
             $data = $subscription->toArray();
             //populate form with data
             $form->setData($data);
         }
     }
     $this->view->data = $data;
     $this->view->fields = $this->_fields;
     $this->view->formParams = $this->_formParams;
     $this->view->formId = $this->_formId;
 }
예제 #15
0
 /**
  * Logs a message when the log option is set
  *
  * @param string $message Message to log
  * @param String $locale  Locale to log
  */
 protected function _log($message, $locale)
 {
     if ($this->_options['logUntranslated']) {
         $transString = $message;
         $message = str_replace('%message%', $message, $this->_options['logMessage']);
         $message = str_replace('%locale%', $locale, $message);
         $logger = Zend_Registry::get('Zend_Log');
         $logger->log($message, Zend_Log::NOTICE);
         //save to DB
         $value = $transString;
         $defaultLang = HCMS_Utils::getDefaultLocale();
         //add indication prefix for non default
         if ($locale != $defaultLang) {
             $value = '';
         }
         try {
             Application_Model_TranslateMapper::getInstance()->addTranslation(array('key' => $transString, 'value' => $value, 'section' => $this->_logSection), $locale);
         } catch (Exception $exc) {
             $logger->log("Translation DB: " . $exc, Zend_Log::NOTICE);
         }
     }
 }