예제 #1
0
 /**
  * setActionController()
  *
  * @param Zend_Controller_Action $oActionController
  * @return Zend_Controller_ActionHelper_Abstract
  */
 public function setActionController(Zend_Controller_Action $oActionController = null)
 {
     static $bSmartyInitialized;
     foreach ($this->_aTranslationsPaths as $sName => $sPath) {
         $this->_aTranslationsPaths[$sName] = Volcano_Tools::fixPath($sPath);
     }
     $aProposedLocales = array();
     if ($this->_sRequestParamName && ($sParam = $oActionController->getRequest()->getParam($this->_sRequestParamName))) {
         $aProposedLocales[] = $sParam;
     }
     $sCookieLocale = false;
     if ($this->_sCookieName && ($sCookieLocale = $oActionController->getRequest()->getCookie($this->_sCookieName))) {
         $aProposedLocales[] = $sCookieLocale;
     }
     $oLocalizer = new Volcano_Localizer($aProposedLocales, $this->_sTranslationAdapterName, $this->_aTranslationsPaths, $this->_bParseRequestHeaders);
     if ($sCookieLocale != $oLocalizer->getLocale()->getLanguage()) {
         setcookie($this->_sCookieName, $oLocalizer->getLocale()->getLanguage(), time() + 60 * 60 * 24 * 30, "/");
     }
     parent::setActionController($oActionController);
     $oActionController->localizer = $oLocalizer;
     //add localizer to smarty
     if (Zend_Controller_Action_HelperBroker::hasHelper('Smarty') && !$bSmartyInitialized) {
         $oSmartyHelper = Zend_Controller_Action_HelperBroker::getExistingHelper('Smarty');
         $oSmartyHelper->addCustomFunction('modifier', array($oLocalizer, 'translate'), 'translate');
         $oSmartyHelper->locale = array('language' => $oLocalizer->getLocale()->getLanguage(), 'region' => $oLocalizer->getLocale()->getRegion());
         $bSmartyInitialized = TRUE;
     }
     return $this;
 }
예제 #2
0
 /**
  * Return smarty instance
  *
  * @return Smarty
  */
 public function getSmarty()
 {
     static $oSmarty;
     if (!$oSmarty) {
         //create smarty object
         require_once 'Smarty.class.php';
         $oSmarty = new Smarty();
         foreach ($this->_aSmartyProperties as $sName => $mValue) {
             $oSmarty->{$sName} = substr($sName, -4) == '_dir' ? Volcano_Tools::fixPath($mValue) : $mValue;
         }
         foreach ($this->_aCustomFunctions as $sType => $aItems) {
             foreach ($aItems as $aItem) {
                 if (substr($oSmarty->_version, 0, 1) != '2') {
                     //bad code, but smarty3 has version like 'Smarty3-SVN$Rev: 3286 $'
                     if ($sType == 'modifier' || $sType == 'function') {
                         $oSmarty->registerPlugin($sType, $aItem[1], $aItem[0]);
                     } elseif ($sType == 'outputfilter') {
                         $oSmarty->registerFilter('output', $aItem[0]);
                     } elseif ($sType == 'postfilter') {
                         $oSmarty->registerFilter('post', $aItem[0]);
                     } elseif ($sType == 'prefilter') {
                         $oSmarty->registerFilter('pre', $aItem[0]);
                     }
                 } else {
                     if ($sType == 'modifier') {
                         $oSmarty->register_modifier($aItem[1], $aItem[0]);
                     } elseif ($sType == 'function') {
                         $oSmarty->register_function($aItem[1], $aItem[0]);
                     } elseif ($sType == 'outputfilter') {
                         $oSmarty->register_outputfilter($aItem[0]);
                     } elseif ($sType == 'postfilter') {
                         $oSmarty->register_postfilter($aItem[0]);
                     } elseif ($sType == 'prefilter') {
                         $oSmarty->register_prefilter($aItem[0]);
                     }
                 }
             }
         }
     }
     $oSmarty->error_reporting = error_reporting() & ~E_NOTICE;
     return $oSmarty;
 }
예제 #3
0
 public function getDbValue()
 {
     return Volcano_Tools::getHash($this->value);
 }