function setModelLanguage($lang = null) { App::import('Behavior', 'Tradutore.TradTradutore'); TradTradutoreBehavior::setGlobalLanguage($lang); $this->Controller->set('currentModelLanguage', $lang); }
/** * Attempts to save the data POSTed * The JSON object returned has 3 attributes: * - `error` - is false when everyting went ok, or an frindly string describing the error * - `saved` - is false when couldn't saved the data, or the ID of the new entry on database * - `content` - The form * * @access public * @return json An javascript object that contains `error`, `content` and `saved` properties */ public function save() { $saved = false; $Model = null; $error = $this->BuroBurocrata->loadPostedModel($this, $Model); if ($error === false) { if (!empty($this->buroData['language'])) { App::import('Behavior', 'Tradutore.TradTradutore'); TradTradutoreBehavior::setGlobalLanguage($this->buroData['language']); } $methodName = $this->BuroBurocrata->getSaveMethod($this, $Model); $saved = $Model->{$methodName}($this->data) !== false; if (!empty($this->buroData['language'])) { TradTradutoreBehavior::returnToPreviousGlobalLanguage(); } if ($saved) { $this->buroData['id'] = $saved = $Model->id; $this->view(); } else { $this->buroData['id'] = $Model->id; $this->view(false); } } $this->set(compact('saved', 'error')); }
static function returnToPreviousGlobalLanguage() { self::$currentLanguage = array_pop(self::$languageStack); }