protected function keywords($s) { $s = " {$s} "; foreach ($this->keywords as $keyword) { $re = "/([^a-z0-9_])({$keyword})([^a-z0-9_])/i"; $s = Core_Regexps::replace($re, '\\1__kwstart__\\2__kwend__\\3', $s); } $s = substr($s, 1, strlen($s) - 2); $s = str_replace('__kwstart__', $this->tag_keyword_start, $s); $s = str_replace('__kwend__', $this->tag_keyword_end, $s); return $s; }
/** */ public function generate() { foreach (new Dev_Source_LibraryDirIterator($this->path_to_library) as $module_name => $module) { if (Core_Strings::contains($module_name, '.')) { $file_place = $this->path_to_html . "/" . Core_Regexps::replace('{/\\w+$}', '', Core_Strings::replace($module_name, '.', '/')); if (!IO_FS::exists($file_place)) { IO_FS::mkdir($file_place, 0775, true); } } try { $module_generator = new Dev_Source_Doc_ModuleGenerator($module, $this->path_to_html . "/" . Core_Strings::replace($module_name, '.', '/')); $module_generator->write(); $module_generator->write_diagram(); $this->add_to_toc($module_generator); } catch (Dev_Source_InvalidSourceException $e) { } } $this->write_css(); $this->write_toc(); $this->write_index(); }
public function quote() { $args = func_get_args(); if (count($args) == 1) { return $this->connection->quote($args[0]); } else { $sql = (string) Core_Arrays::shift($args); foreach ($args as $arg) { $sql = Core_Regexps::replace('{\\?}', $this->connection->quote((string) $arg), $sql, 1); } return $sql; } }
/** */ protected function parse_simple_line($line) { $line = Core_Regexps::replace('{\'\'\'(.+?)\'\'\'}', '<b>\\1</b>', $line); $line = Core_Regexps::replace('{\'\'(.+?)\'\'}', '<i>\\1</i>', $line); $line = Core_Regexps::replace_using_callback('{\\[\\[(.+?)\\]\\]}', array($this, 'parse_link_callback'), $line); if ($m = Core_Regexps::match_with_results('{^([\\s\\*\\#]*)(http://[^\\s+]+)\\s*}', $line)) { $url = $m[2]; $urltext = $url; $urltext = Core_Regexps::replace('{^http://}', '', $urltext); $urltext = Core_Regexps::replace('{/.*$}', '', $urltext); $line = $m[1] . '[<a href="' . $url . '" target="_blank">' . $urltext . '</a>]'; } $line = str_ireplace('[b]', '<b>', $line); $line = str_ireplace('[/b]', '</b>', $line); $line = str_ireplace('[q]', '<blockquote>', $line); $line = str_ireplace('[/q]', '</blockquote>', $line); return $line; }
public function error_handler($errno, $errstr, $errfile, $errline) { $this->result->add_error($this, $this->module, Core_Regexps::replace('/DOMDocument::\\s*[a-zA-Z()]+\\s*:/', '', $errstr)); }
/** * @dataProvider provider_replace */ public function test_replace($pattern, $replace, $subject, $expected) { $this->assertEquals(Core_Regexps::replace($pattern, $replace, $subject), $expected); }
/** * @return Dev_Unit_TestLoader */ public function from() { $args = func_get_args(); foreach (Core_Types::is_iterable($args[0]) ? $args[0] : $args as $class) { $class = "{$this->prefix}{$class}"; if (Core_Types::class_exists($class)) { $this->from_class($class); } else { try { Core::load($class); } catch (Core_ModuleException $e) { var_dump($e); Core::load(Core_Regexps::replace('{\\.[a-zA-Z0-9]+$}', '', $class)); $this->from_class($class); continue; } if (Core_Types::is_subclass_of('Dev.Unit.TestCase', $class)) { $this->from_class($class); } elseif (Core_Types::is_subclass_of('Dev.Unit.TestModuleInterface', $class)) { $this->from_suite(call_user_func(array(Core_Types::real_class_name_for($class), 'suite'))); } } } return $this; }
static function validate_2d($s) { $s = trim(Core_Regexps::replace('{[^\\d]+}', '', $s)); $s = substr($s, 0, 2); while (strlen($s) < 2) { $s = "0{$s}"; } return $s; }
/** * Выполняет запрос * * @uses DB::PLACEHOLDER_REGEXP * * @return self * @throws DB_CursorException Ошибка при выполнении запроса */ public function execute() { $this->close(); $this->adapter = $this->connection->adapter->prepare(Core_Regexps::replace('{' . DB::PLACEHOLDER_REGEXP . '}', '?', $this->sql)); $this->execution_time = 0; $time = microtime(true); try { $this->is_successful = $this->adapter->execute($this->binds); } catch (DB_CursorException $e) { throw new DB_CursorException($e->getMessage(), $this->pure_sql()); } if ($this->is_successful) { $this->execution_time = microtime(true) - $time; $this->metadata = $this->adapter->get_row_metadata(); } $this->connection->listeners->on_execute($this); return $this; }
/** * Возвращает следующий элемент итератора * */ public function next() { while (($line = $this->read_line()) !== null) { $this->buffer .= Core_Regexps::replace('{[^a-zA-Z0-9+/]}', '', $line); if (strlen($this->buffer) > MIME_Decode::BASE64_CHUNK_SIZE) { break; } } if ($this->buffer == '') { $this->current = null; } else { if (strlen($this->buffer) > MIME_Decode::BASE64_CHUNK_SIZE) { $len_4xN = strlen($this->buffer) & ~3; $this->current = base64_decode(substr($this->buffer, 0, $len_4xN)); $this->buffer = substr($this->buffer, $len_4xN); } else { $this->buffer .= '==='; $len_4xN = strlen($this->buffer) & ~3; $this->current = base64_decode(substr($this->buffer, 0, $len_4xN)); $this->buffer = ''; } $this->count++; } }
/** * @param string $name * @param array $args * * @return mixed */ public function __call($name, $args) { if (!Core_Regexps::match('{_url$}', $name)) { throw new Core_MissingMethodException($name); } $name = Core_Strings::replace($name, 'single_', 'single-'); $url = ''; $args = Core_Arrays::reverse($args); $parms = Core_Types::is_array($args[0]) ? Core_Arrays::shift($args) : array(); $parts = Core_Arrays::reverse(Core_Strings::split_by('_', Core_Regexps::replace('{_url$}', '', $name))); $last_idx = count($parts) - 1; $target = false; foreach ($parts as $idx => $part) { $part = Core_Strings::replace($part, '-', '_'); if ($target) { if (isset($this->single_names[$part])) { $url = '/' . $this->single_names[$part] . '/' . (Core_Types::is_object($arg = Core_Arrays::shift($args)) ? $arg->id : (string) $arg) . $url; } elseif ($idx == $last_idx && (isset($this->resources[$target]) && isset($this->resources[$target]['collection']) && isset($this->resources[$target]['collection'][$part])) || isset($this->single_names[$target]) && isset($this->resources[$this->single_names[$target]]['instance']) && isset($this->resources[$this->single_names[$target]]['instance'][$part])) { $url .= "/{$part}"; } else { throw new Core_MissingMethodException($name); } } else { if (isset($this->resources[$part])) { $url = "/{$part}{$url}"; $target = $part; } elseif (isset($this->single_names[$part])) { $id = Core_Arrays::shift($args); $url = '/' . $this->single_names[$part] . '/' . (Core_Types::is_object($id) ? $id->id : (string) $id) . $url; $target = $part; } else { throw new Core_MissingMethodException($name); } } } return $this->add_keyword_parameters($this->add_path($url) . (isset($args[0]) ? '.' . $args[0] : ".{$this->default_format}"), $parms); }
/** * */ protected function make_union_sql() { $queries = ''; $mappers = $this->options['union']; $index = 0; foreach ($mappers as $mapper) { $mapper_binds = $mapper->__get('binds'); $mapper_query = $mapper->as_string(); foreach ($mapper_binds as $bind_name => $bind_value) { $mapper_query = Core_Regexps::replace('{\\:' . Core_Regexps::quote($bind_name) . '\\b}', ':' . ($bind_name = sprintf('union%d_%s', $index, $bind_name)), $mapper_query); $this->binds[$bind_name] = $bind_value; } $queries[] = $mapper_query; $index++; } return '((' . implode(') UNION (', $queries) . '))'; }
/** * @return string */ protected function make_name_and_views_path() { $parts = Core_Strings::split_by('_', Core_Strings::downcase(Core_Regexps::replace('{Controller$}', '', Core_Types::class_name_for($this)))); array_shift($parts); $this->name = Core_Arrays::join_with('.', $parts); //$this->views_path = Core_Arrays::join_with('/', $parts); }
/** * @param string $name * * @return string */ protected function http_field_name($name) { return Core_Strings::downcase(Core_Regexps::replace('{^http_}', '', $name)); }