/**
  * @param               $objectLabel
  * @param               $params
  * @param ModelCriteria $search
  * @param array         $columns
  * @param null          $foreignTable
  * @param string        $foreignKey
  *
  * @return string
  */
 protected function dataAccessWithI18n($objectLabel, $params, ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID')
 {
     if (array_key_exists('data_' . $objectLabel, self::$dataAccessCache)) {
         $data = self::$dataAccessCache['data_' . $objectLabel];
     } else {
         $lang = $this->getNormalizedParam($params, array('lang'));
         if ($lang === null) {
             $lang = $this->getSession()->getLang()->getId();
         }
         ModelCriteriaTools::getI18n(false, $lang, $search, $this->getSession()->getLang()->getLocale(), $columns, $foreignTable, $foreignKey, true);
         $data = $search->findOne();
         self::$dataAccessCache['data_' . $objectLabel] = $data;
     }
     if ($data !== null) {
         $noGetterData = array();
         foreach ($columns as $column) {
             $noGetterData[$column] = $data->getVirtualColumn('i18n_' . $column);
         }
         return $this->dataAccess($objectLabel, $params, $data, $noGetterData);
     } else {
         throw new NotFoundHttpException();
     }
 }
Example #2
0
 /**
  * Setup ModelCriteria for proper i18n processing
  *
  * @param ModelCriteria $search       the Propel Criteria to configure
  * @param array         $columns      the i18n columns
  * @param string        $foreignTable the specified table (default  to criteria table)
  * @param string        $foreignKey   the foreign key in this table (default to criteria table)
  * @param bool          $forceReturn
  *
  * @return mixed the locale
  */
 protected function configureI18nProcessing(ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID', $forceReturn = false)
 {
     /* manage translations */
     $this->locale = ModelCriteriaTools::getI18n($this->getBackendContext(), $this->getLang(), $search, $this->getCurrentRequest()->getSession()->getLang()->getLocale(), $columns, $foreignTable, $foreignKey, $this->getForceReturn());
 }