本文整理匯總了PHP中Core::invoke方法的典型用法代碼示例。如果您正苦於以下問題:PHP Core::invoke方法的具體用法?PHP Core::invoke怎麽用?PHP Core::invoke使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Core
的用法示例。
在下文中一共展示了Core::invoke方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: process
public static function process($source, $process = array())
{
$args = func_get_args();
if (count($args) > 2) {
$process = array_slice($args, 1);
}
if (empty($process)) {
return $source;
}
$process = (array) $process;
foreach ($process as $name => $config) {
if (is_int($name) && is_string($config)) {
$name = $config;
$config = array();
} else {
if (is_int($name) && is_array($config)) {
$source = self::process($source, $config);
}
}
if (!isset(self::$process[$name])) {
continue;
}
if (!is_string(self::$process[$name])) {
$source = Core::invoke(self::$process[$name], array($source));
} else {
$p = Core::make(self::$process[$name]);
if (!Core_Types::is_subclass_of('Text.Process.ProcessInterface', $p)) {
continue;
}
$p->configure($config);
$source = $p->process($source);
}
}
return $source;
}
示例2: tao_cache
public function tao_cache()
{
if (count($this->args) < 2) {
print "no args\n";
return;
}
$command = array_shift($this->args);
$args = $this->args;
$result = var_export(Core::invoke(array(WS::env()->cache, $command), $args), true);
print "{$result}\n";
}
示例3: process_format
protected function process_format($code, $value, $format)
{
if (empty($format['output'])) {
return $value;
}
if (Core_Types::is_callable($format['output'])) {
return Core::invoke($format['output'], array($value));
}
if (is_string($format['output']) || is_array($format['output'])) {
Core::load('Text.Process');
return Text_Process::process($value, $format['output']);
}
return $value;
}
示例4: action
public function action($name, $data, $action, $item = false, $fields = array())
{
$args = func_get_args();
$res = Net_HTTP::Response();
$res->content_type('application/json');
$query = WS::env()->request['query'];
$ents = CMS::items_for_select(Core::invoke($data['search'], array($query)));
$values = array();
$empty = $this->get_empty($data);
if ($empty && empty($query)) {
$values[] = $empty;
}
foreach ($ents as $k => $e) {
$values[] = array('id' => (int) $k, 'title' => (string) $e);
}
$res->body(json_encode(array('data' => $values)));
return $res;
}
示例5: on_change_call
public static function on_change_call($id, $value, $data)
{
$fc = self::db()->full_code($id);
if (!empty(CMS_Vars::$plugins_on_change[$fc])) {
$rc = true;
foreach (CMS_Vars::$plugins_on_change[$fc] as $m) {
$class = trim($m[0]);
$method = trim($m[1]);
if ($class != '' && $method != '') {
$r = Core::invoke(array($class, $method), array($value, $fc));
if (is_string($r)) {
return $r;
}
$rc = $rc && $r;
}
}
return $rc;
}
}
示例6: save
public function save()
{
$args = func_get_args();
array_unshift($args, $this);
return Core::invoke(array($this->get_mapper(), 'save'), $args);
}
示例7: delete
public function delete()
{
$args = func_get_args();
array_unshift($args, $this);
return Core::invoke(array($this->get_storage(), 'delete'), $args);
}
示例8: access
public static function access($realm, $extra_auth_callback = null)
{
if (!$realm) {
return array();
}
if (isset(self::$realms[$realm]) && self::$realms[$realm]) {
return self::$realms[$realm];
}
$data = false;
$cfg_name = "{$realm}_realm";
$cfg = WS::env()->config;
if (isset($cfg->{$cfg_name})) {
$data = (array) $cfg->{$cfg_name};
} elseif (isset(CMS::$restricted_realms[$realm])) {
$data = CMS::$restricted_realms[$realm];
} else {
return self::$realms[$realm] = false;
}
if (!$data) {
return self::$realms[$realm] = false;
}
if ($realm == CMS::$admin_realm) {
CMS::$in_admin = true;
}
if (isset($data['page_404'])) {
CMS::$page_404 = $data['page_404'];
}
if (isset($data['navigation_var'])) {
Core::load(CMS::$nav_module);
Core_Types::reflection_for(CMS::$nav_module)->setStaticPropertyValue('var', $data['navigation_var']);
}
$user = false;
if (isset($data['auth_type']) && $data['auth_type'] == 'basic' || !isset($data['auth_type'])) {
$user = WS::env()->admin_auth->user;
}
if ($user) {
$client = false;
$access = false;
$mp = false;
self::passwords($data, $user, $client, $access, $mp);
Core::load('Net.HTTP.Session');
$session = Net_HTTP_Session::Store();
if (!$access && isset($session['auth_url_access']) && $session['auth_url_access']) {
$access = true;
$mp = $session['auth_url_parms'];
}
if (!$access && isset($data['auth_url'])) {
Core::load('Net.Agents.HTTP');
$url = $data['auth_url'];
$agent = Net_HTTP::Agent();
$res = $agent->with_credentials($user->login, $user->password)->send(Net_HTTP::Request($url));
if ($res->status->code == '200') {
$r = trim($res->body);
if ($r == 'ok' || $r == 'ok:') {
$access = true;
} else {
if ($m = Core_Regexps::match_with_results('{^ok:(.+)$}', $r)) {
$access = true;
$mp = trim($m[1]);
}
}
}
if ($access) {
$session['auth_url_access'] = true;
$session['auth_url_parms'] = $mp;
}
}
if (!$access) {
$args = array($user->login, $user->password, $realm);
if (Core_Types::is_callable($extra_auth_callback)) {
$extra_auth = Core::invoke($extra_auth_callback, $args);
} else {
$extra_auth = self::extra_auth($args[0], $args[1], $args[2]);
}
if ($extra_auth || Core_Types::is_iterable($extra_auth)) {
$mp = $extra_auth;
$access = true;
} else {
return self::$realms[$realm] = false;
}
}
$auth_parms = self::auth_parms($mp, $client);
$user->parms = $auth_parms;
if ($access) {
return self::$realms[$realm] = array('data' => $data, 'auth_parms' => $auth_parms);
}
} else {
return self::$realms[$realm] = false;
}
return self::$realms[$realm] = false;
}
示例9: adapter
public static function adapter($fallback = false)
{
$class = self::adapter_module($fallback);
$adapter = Core::invoke(array($class, 'adapter'));
if (!$fallback && !$adapter->validate()) {
return self::adapter(true);
}
return $adapter;
}
示例10: __call
public function __call($method, $args = array())
{
return Core::invoke(array($this->db, $method), $args);
}
示例11: create_tree
public static function create_tree($flat, $options = array(), &$childs = array())
{
$rows = array();
$id_name = isset($options['id_name']) ? $options['id_name'] : 'id';
$title_name = isset($options['title_name']) ? $options['title_name'] : 'title';
$parent_name = isset($options['parent_name']) ? $options['parent_name'] : 'parent_id';
$childs_name = isset($options['childs_name']) ? $options['childs_name'] : 'childs';
$flat_keys = isset($options['flat_keys']) ? $options['flat_keys'] : false;
$childs_limit = isset($options['childs_limit']) ? $options['childs_limit'] : false;
$missing_callback = isset($options['missing_callback']) ? $options['missing_callback'] : false;
$count = 0;
$missing_ids = array();
foreach ($flat as $k => $row) {
if (isset($options['process_callback'])) {
$row = Core::invoke($options['process_callback'], array($row));
}
if (empty($row)) {
continue;
}
if (is_string($row)) {
$row = array($title_name => $row);
}
$id = (int) isset($row[$id_name]) ? $row[$id_name] : $k;
$rows[$id] = $row;
if (!isset($childs[$id])) {
$childs[$id] = array();
}
if (isset($row[$childs_name])) {
$childs[$id] += self::create_tree($row[$childs_name], $options, $childs);
}
$pid = $row[$parent_name];
if (!is_null($pid) && $pid >= 0) {
$pid = (int) $pid;
if (!isset($childs[$pid])) {
$childs[$pid] = array();
}
$childs[$pid][$id] = $row;
}
}
foreach (array_keys($childs) as $pid) {
if (!isset($rows[$pid]) && $pid > 0) {
$missing_ids[] = $pid;
}
}
if (!empty($missing_ids) && $missing_callback) {
foreach ($missing_ids as $id) {
if ($id > 0) {
Core::invoke($missing_callback, array($id, &$childs, &$rows));
}
}
}
foreach ($rows as $id => &$row) {
$count++;
self::tree_row_childs($row, $id, $childs, $childs_name, $count, $childs_limit);
if ($childs_limit && $count >= $childs_limit) {
continue;
}
}
unset($row);
$root = array();
$root_exists = in_array(0, array_keys($rows), true);
foreach ($rows as $id => $row) {
if (intval($row[$parent_name]) == 0 && !$root_exists || is_null($row[$parent_name]) || $id == 0) {
$root[$id] = $row;
}
}
if (empty($root) && !$root_exists) {
$root = $rows;
}
if ($flat_keys) {
$root = array_values($root);
array_walk($root, 'self::tree_row_flat', $childs_name);
}
return $root;
}
示例12: compile
protected function compile($less_fname, $css_fname)
{
self::load();
$options = self::option('options');
// generate source map
if (self::option('sourse_map')) {
$map_file = str_replace('styles/', '', $css_fname);
$map_file = trim(str_replace('.less.css', '.map', $map_file), '/.');
$map_dir = './styles/less-maps/';
$map_path = "{$map_dir}{$map_file}";
IO_FS::mkdir(dirname($map_path));
$options = array_merge($options, array('sourceMap' => true, 'sourceMapWriteTo' => $map_path, 'sourceMapURL' => trim($map_path, '.')));
// if is out of docroot
if ($less_fname[0] == '/' || Core_Strings::starts_with($less_fname, '..') || Core_Strings::starts_with($less_fname, './..')) {
$less_fname = "file://{$less_fname}";
$less_fname = '.' . Templates_HTML::extern_filepath($less_fname);
}
}
$options['import_dirs'] = self::option('less_import_dirs');
$dir = dirname($css_fname);
$url = 'http://' . WS::env()->request->host . '/';
$args = array(array($less_fname => $url), $options);
$css_file_name = Core::invoke(self::option('less_callback'), $args);
$cached_file = rtrim($options['cache_dir'], '/') . '/' . $css_file_name;
if (is_file($cached_file) && !(WS::env()->request['less_compile'] && self::option('debug'))) {
$less_ftime = filemtime($cached_file);
$css_ftime = false;
if (IO_FS::exists($css_fname)) {
$css_ftime = filemtime($css_fname);
}
if ($css_ftime && $css_ftime >= $less_ftime) {
return false;
}
}
$css = file_get_contents($cached_file);
IO_FS::File($css_fname)->update($css);
}
示例13: items_for_select_generate
static function items_for_select_generate($s)
{
if (Core_Types::is_callable($s)) {
$s = Core::invoke($s);
}
if (is_string($s)) {
if ($m = Core_Regexps::match_with_results('/^:(.+)$/', $s)) {
$method = trim($m[1]);
$s = CMS::$current_controller->{$method}();
}
}
if (Core_Types::is_iterable($s)) {
$items = array();
foreach ($s as $k => $v) {
if ($v == '' && (is_string($k) && Core_Regexps::match('/^(var|db|orm)/', $k))) {
$items += self::items_for_select($k);
} elseif ($v instanceof DB_ORM_Mapper) {
$items += self::items_for_select($v->select());
} else {
if ($v instanceof DB_ORM_Entity) {
$items[$v->id()] = $v;
} else {
if (is_int($k) && (Core_Types::is_callable($v) || is_string($v) && Core_Regexps::match('/^(var|db|orm)/', $v))) {
$items += self::items_for_select($v);
} else {
$items[$k] = $v;
}
}
}
}
return $items;
} else {
if ($m = Core_Regexps::match_with_results('/^var:(.+)$/', $s)) {
return self::get_var_value($m[1]);
} else {
if ($m = Core_Regexps::match_with_results('/^orm:(.+)$/', $s)) {
$items = array();
foreach (self::orm()->downto($m[1]) as $row) {
$items[$row->id] = $row;
}
return $items;
} else {
if ($m = Core_Regexps::match_with_results('/^(.+)::(.+)$/', $s)) {
$class = str_replace('.', '_', trim($m[1]));
$method = trim($m[2]);
$ref = new ReflectionMethod($class, $method);
return $ref->invoke(null);
} else {
if ($m = Core_Regexps::match_with_results('/^db:([a-z0-9_]+)(.*)$/i', $s)) {
$table = $m[1];
$s = $m[2];
$value = 'id';
$title = 'title';
$query = 'select';
if ($m = Core_Regexps::match_with_results('/^->([a-z0-9_]+)(.*)$/', $s)) {
$query = $m[1];
$s = $m[2];
}
if ($m = Core_Regexps::match_with_results('/^\\((.+),(.+)\\)$/', $s)) {
$value = $m[1];
$title = $m[2];
}
$rows = DB_SQL::db()->{$table}->{$query}->run();
$items = array();
foreach ($rows as $row) {
$items[$row->{$value}] = $row->{$title};
}
return $items;
} else {
return array();
}
}
}
}
}
}
示例14: encode
/**
* Кодирует строку пароля
*
* @param string $str пароль
* @param string $salt соль
*
* @return string закодированная строка
*/
public function encode($str, $salt = null)
{
$salt = is_null($salt) ? $this->salt : $salt;
return Core::invoke($this->callback, array($str, $salt));
}
示例15: create_element
protected function create_element()
{
if (Core_Types::is_callable($this->type)) {
$this->element = Core::invoke($this->type, array($this->reader, $this->name));
return $this;
}
$method = "element_" . $this->type;
if (method_exists($this, $method)) {
$this->{$method}();
} else {
$this->element = null;
}
return $this;
}