function getValue($filtered = true) { $values = explode($this->separator, $this->_value); $tags = array(); foreach ($values as &$value) { $value = trim($value); if ($value != '') { if ($this->_filter && $filtered) { $value = call_user_func($this->_filter, $value, $this->getName()); } $tags[] = $value; } } $ids = array(); foreach ($tags as $tag) { $ds = new TableReader('blog_tag'); $id = $ds->select('blog_tag_id')->where('tag', $tag)->fetchScalar(); if (!$id) { $writer = new TableWriter('blog_tag'); $id = $writer->insert(array('tag' => $tag, 'url_tag' => TextHelper::urlize($tag))); } $ids[] = $id; } return $ids; }
static function parse($path, $replacements = array(), &$substitutions = array()) { $path = self::replaceUploadsDir($path); $matches1 = array(); preg_match_all('/{(appd|uploads|public|random|date|root)(?:\\[([0-9a-zA-Z-_]+)\\])?}/', $path, $matches1, PREG_SET_ORDER); $matches2 = array(); $expression = implode('|', array_keys($replacements)); preg_match_all('/{(' . $expression . ')(?:\\[([0-9a-zA-Z-_]+)\\])?}/', $path, $matches2, PREG_SET_ORDER); $matches = array_merge($matches1, $matches2); foreach ($matches as $match) { if (isset($replacements[$match[1]])) { $substitutions[$match[0]] = $replacements[$match[1]]; if (isset($match[2])) { if (is_numeric($match[2])) { $substitutions[$match[0]] = substr($substitutions[$match[0]], 0, $match[2]); } elseif (is_callable($match[2])) { $substitutions[$match[0]] = call_user_func($match[2], $substitutions[$match[0]]); } elseif ($match[2] == 'url') { $substitutions[$match[0]] = TextHelper::urlize($substitutions[$match[0]]); } } } else { $param = isset($match[2]) ? $match[2] : null; $substitutions[$match[0]] = self::replace($match[1], $param); } } return str_replace(array_keys($substitutions), array_values($substitutions), $path); }
function _putUrlEntry($values) { foreach ($values['cms_page_meta'] as $i => $cms_page_meta) { $title = $values['cms_nav_item_name'][$i][0]['name']; $this->db->into('cms_page_meta')->where('language_id', $cms_page_meta[0]['language_id'])->where('page_id', $cms_page_meta[0]['page_id'])->update(array('url_entry' => TextHelper::urlize($title), 'title' => $title)); } }