/** * Filter * * @see Zend_Filter_Interface::filter() * * @param array Array of values to filter * @returns array The input array, each element processed through the filter * @throws Zend_Filter_Exception */ public function filter($value) { if (!is_array($value)) { throw new Zend_Filter_Exception('Value to filter must be an array'); } foreach ($value as $key => $elem) { if ($this->recursive && is_array($elem)) { $value[$key] = $this->filter($elem); } else { $value[$key] = $this->_filter->filter($elem); } } return $value; }
/** * Apply input filter to values of translation parameters * * @param array &$translateParams * @param array $fieldNames Names of fields values of which are to be filtered * @return void */ protected function _filterTranslationParams(array &$translateParams, array $fieldNames) { foreach ($translateParams as &$param) { foreach ($fieldNames as $fieldName) { $param[$fieldName] = $this->_inputFilter->filter($param[$fieldName]); } } }
/** * Parse a text containing BB-codes * * @param string $text * @return string */ public function parse($text) { if ($this->_preFilter !== null) { $text = $this->_preFilter->filter($text); } $tree = $this->_createTree($text); $result = $this->_translateBBCodeBranch($tree); if ($this->_postFilter !== null) { $result = $this->_postFilter->filter($result); } return $result; }
protected function saveRoute($row) { $module = $this->modules[$this->data[$row]['Module']]; //no path - no route if (!$module['path']) { return; } $titles = explode("\n", $this->data[$row]['Name']); $route = new Cms_Model_Route(); $route->set_application_id(1); if (isset($this->data[$row]['page_id'])) { $route->set_page_id($this->data[$row]['page_id']); } $route->set_path($module['path']); if (isset($module['params'])) { $route->set_params($module['params']); } foreach ($this->languages as $langIndex => $lang) { $title = $this->getLangText($titles, $langIndex); $currRow = $row; if (!isset($module['route_uri'])) { $uriParts = array(); while (isset($this->data[$currRow])) { $currTitles = explode("\n", $this->data[$currRow]['Name']); $uriParts[] = $this->seoFilter->filter($currTitles[$langIndex]); if (!isset($this->data[$currRow]['parent'])) { break; } $currRow = $this->data[$currRow]['parent']; } //print_r($uriParts); $uriParts = array_reverse($uriParts); $uri = implode('/', $uriParts); } else { $uri = $module['route_uri']; } //check if route exists $existingRoutes = Cms_Model_RouteMapper::getInstance()->fetchAll(array('uri' => $uri, 'lang' => $lang)); if (count($existingRoutes) > 0) { continue; } $route->set_name($title)->set_lang($lang)->set_uri($uri); $route->set_id(null); //print_r($route); Cms_Model_RouteMapper::getInstance()->save($route); } $this->data[$row]['route_id'] = $route->get_id(); }
/** * @param string $key * @param \Zend_Filter_Interface $filter * @return void */ private function _addFilter($key, \Zend_Filter_Interface $filter) { $this->_filters[$key][] = $filter; /** * Не используем @see isset(), потому что для массива * $array = array('a' => null) * isset($array['a']) вернёт false, * что не позволит нам фильтровать значения параметров, * сознательно установленные в null при конструировании объекта. */ if (array_key_exists($key, $this->_data)) { $this->_data[$key] = $filter->filter($this->_data[$key]); } }