/** * * Initialization of individual fields received record * * @param array $row * @return void */ public function _init($row) { $initRow = array(); foreach ($this->_properties as $k => $v) { $val = $row[$k]; switch ($v['type']) { case self::TYPE_TIMESTAMP: if (!is_null($val)) { $val = strtotime($val); } break; case self::TYPE_BOOLEAN: $val = (bool) $val; break; case self::TYPE_HTML: $filterContent = new Default_Form_Filter_AddBasePathUrl(); $content = $filterContent->filter($val); $val = $content; break; } // в базе данных символы " и ' храняться в виде \" и \' // заменим их на (\" -> ") и (\'->') if (is_string($val)) { $val = str_replace('\\"', '"', $val); $val = str_replace("\\'", "'", $val); } $this->_properties[$k]['value'] = $val; $initRow[$k] = $val; } $this->_id = (int) $row[$this->_idField]; $initRow[$this->_idField] = (int) $row[$this->_idField]; return $initRow; }
/** * Content filtering information for blog post: * - when saving removes the base path in the URL resources * - when reading add the base path to the URL resources * * @param string $action Maybe two values: 'save' and 'load' * @return bool */ protected function filterContent($action) { if (!$this->profile->content) { return TRUE; } //Сохранение записи if ($action == 'save') { // Определим действие над полем $action = $this->profile->getAction('content'); // Удалим базовый путь из URL ресурсов $filterContent = new Default_Form_Filter_DeleteBasePathUrl(); $content = $filterContent->filter($this->profile->content); if (!$content === FALSE) { $this->profile->content = $content; // Установим старое действие над полем $this->profile->setAction('content', $action); return TRUE; } else { return FALSE; } } //Чтение записи if ($action == 'load') { // Добавим базовый путь к URL ресурсам на странице HTML $filterContent = new Default_Form_Filter_AddBasePathUrl(); $content = $filterContent->filter($this->profile->content); if (!$content === FALSE) { $this->profile->content = $content; // Установим действие по умолчанию для свойства 'content' $this->profile->setAction('content', Default_Model_Profile::ACTION_NONE); return TRUE; } else { return FALSE; } } }
/** * Content filtering information for different languages: * - when saving removes the base path in the URL resources * - when reading add the base path to the URL resources * * @param string $type Возможно 2 значения: 'save' и 'load' * @return bool */ protected function filterContent($type) { $is_content = false; //-------------------------- // Проверим наличие информации $translate = Zend_Registry::get('Zend_Translate'); $list_languages = $translate->getAdapter()->getList(); foreach ($list_languages as $language) { $key_content = 'content_' . $language; if ($this->profile->{$key_content}) { $is_content = TRUE; } } if (!$is_content) { return TRUE; } //Сохранение записи if ($type === 'save') { foreach ($list_languages as $language) { $key_content = 'content_' . $language; if (!$this->profile->{$key_content}) { continue; } // Определим действие над полем $action = $this->profile->getAction($key_content); // Удалим базовый путь из URL ресурсов $filterContent = new Default_Form_Filter_DeleteBasePathUrl(); $content = $filterContent->filter($this->profile->{$key_content}); if (!$content === FALSE) { $this->profile->{$key_content} = $content; // Установим старое действие над полем $this->profile->setAction($key_content, $action); } else { return FALSE; } } } //Чтение записи if ($type === 'load') { foreach ($list_languages as $language) { $key_content = 'content_' . $language; if (!$this->profile->{$key_content}) { continue; } // Добавим базовый путь к URL ресурсам на странице HTML $filterContent = new Default_Form_Filter_AddBasePathUrl(); $content = $filterContent->filter($this->profile->{$key_content}); if (!$content === FALSE) { $this->profile->{$key_content} = $content; // Установим действие по умолчанию для свойства 'content' $this->profile->setAction($key_content, Default_Model_Profile::ACTION_NONE); } else { return FALSE; } } } return TRUE; }