本文整理汇总了PHP中Hooks::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP Hooks::bind方法的具体用法?PHP Hooks::bind怎么用?PHP Hooks::bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hooks
的用法示例。
在下文中一共展示了Hooks::bind方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($src, $default_callbacks = array())
{
if ($src instanceof Uploader) {
$this->post_field = $src->getName();
} elseif (is_string($src)) {
$this->post_field = $name;
}
$this->callbacks = (array) $default_callbacks;
if (array_key_exists($this->post_field, $_FILES)) {
Hooks::bind('system_ready', array($this, 'runCallbacks'));
}
}
示例2: add
public static function add($time, $callback, $specificTime = false)
{
if (!is_callable($callback)) {
error_log('$callback is not a valid callback in Timer::add', E_USER_ERROR);
}
$orig = $time;
if (is_numeric($time) && !$specificTime) {
$time = time() + $time;
} else {
if (is_string($time) && !$specificTime) {
$time = strtotime($time);
}
}
self::$timers[] = array('time' => (int) $time, 'orig-time' => $orig, 'callback' => $callback);
}
public static function callTimers()
{
$time = time();
foreach (self::$timers as $t) {
if ($time >= $t['time']) {
call_user_func_array($t['callback'], array($t['orig-time']));
}
}
}
}
function timer($time, $callback, $specificTime = false)
{
Timers::add($time, $callback, $specificTime);
}
Hooks::bind("system_ready", "Timers::callTimers");
示例3: bind
/**
* A wrapper for Hooks::bind();
*/
public function bind($hook, $callback, $priority = 0)
{
$this->binds[] = array($hook, $callback);
Hooks::bind($hook, $callback, $priority);
}
示例4: register
public static function register($name, $value = null)
{
if (is_array($name)) {
if (is_null($value)) {
foreach ($name as $key => $val) {
self::$tokens[$key] = $val;
}
} else {
foreach ($name as $key => $val) {
self::$tokens[$val] = $value[$key];
}
}
} else {
self::$tokens[$name] = $value;
}
}
public static function registerDefaults()
{
Tokens::register(array("theme_dir" => Themes::$curr_theme->getPublicPath(), "public_root" => TH_PUB_ROOT, "root" => TH_ROOT, "public_content_dir" => TH_PUB_ROOT . TH_CONTENT, "content_dir" => TH_ROOT . TH_CONTENT, "uploads_dir" => TH_ROOT . TH_UPLOADS, "public_uploads_dir" => TH_PUB_ROOT . TH_UPLOADS));
}
public static function fetch($name)
{
return self::$tokens[$name];
}
public static function filter($value)
{
return Tokenizer::perform($value, self::$tokens);
}
}
Hooks::bind("system_after_themes_load", "Tokens::registerDefaults");
Filters::bind("content_get_inital", "Tokens::filter");
示例5: getAllHooks
*/
protected static function getAllHooks()
{
return self::$hooks;
}
/**
* Sets up hooks for form submission.
*/
public static function setupPostHandles()
{
if (!empty($_POST['cc_form'])) {
Hooks::execute('post_' . $_POST['cc_form']);
}
}
}
Hooks::bind('system_ready', 'Hooks::setupPostHandles');
/**
* Wrapper for Hooks::execute().
*/
function plugin($name, $args = array())
{
return Hooks::execute($name, $args);
}
/**
* Fundamentally the same as Hooks, but modifies the variable each time and returns the new value.
*/
class Filters extends Hooks
{
/**
* @var array The list of registered filters.
*/
示例6: registerSubpage
}
/**
* A wrapper for Admin->registerSubpage
*/
public static function registerSubpage()
{
$args = func_get_args();
return call_user_func_array(array(self::$handle, '_registerSubpage'), $args);
}
/**
* Logs the user out.
*/
public static function logout()
{
Users::logout();
cc_redirect(TH_PUB_ROOT);
exit;
}
public static function isPage($page)
{
return $_GET['page'] == $page;
}
public static function doIncludeDesign()
{
self::$handle->includeDesign();
}
}
Hooks::bind('admin_logout', 'Admin::logout', 100);
Hooks::bind('system_complete', 'Admin::bootstrap');
Hooks::bind('system_complete', 'Admin::doIncludeDesign', 100);
示例7: array_keys
return array_keys(self::$registered);
}
public static function getEditorObj()
{
if (array_key_exists(self::$editor, self::$registered)) {
return self::$registered[self::$editor];
} else {
trigger_error(self::$editor . " is not a valid editor.", E_USER_ERROR);
}
}
public static function create($name, $contents)
{
return self::getEditorObj()->run('create', array($name, $contents));
}
}
Hooks::bind('system_ready', 'Editors::bootstrap');
class Editor
{
public $name, $version, $author, $binds = array();
public function __construct($name, $version, $author)
{
$this->name = $name;
$this->version = $version;
$this->author = $author;
}
public function bind_create($callback)
{
if (!is_callable($callback)) {
trigger_error("{$callback} is not callable!");
}
$this->binds['create'] = $callback;
示例8: filter
} else {
$this->info['theme'] = Settings::get('site', 'theme', true);
}
}
return filter('node_theme', $this->info['theme']);
}
protected function checkRow($raw_row = null)
{
if (empty($this->db_row)) {
$row = $raw_row;
$this->id = $row['id'];
$row = filter('page_checkrow', $row);
$this->db_row = $row;
$this->info['content'] = $row['content'];
$this->info['name'] = $row['name'];
$this->info['settings'] = unserialize($row['settings']);
$this->info['title'] = $row['title'];
$this->info['created'] = $row['created'];
$this->info['last_modified'] = $row['last_modified'];
$this->info['weight'] = $row['weight'];
$this->info['menutitle'] = $row['menutitle'];
$this->info['parent_id'] = $row['parent_id'];
$this->info['type'] = $row['type'];
$this->info['slug'] = $row['slug'];
}
}
}
// admin has its own way of doing things
if (!CC_IS_ADMIN) {
Hooks::bind('system_after_content_load', 'Content::bootstrap');
}
示例9: getTranslations
/**
* Gets the translations array
*/
public function getTranslations()
{
return $this->translations;
}
/**
* Returns the list of registered locales (locales may be incomplete)
*/
public static function getLocales()
{
return array_keys(self::$handle->getTranslations());
}
}
Hooks::bind('system_ready', 'i18n::boostrap', -50);
/**
* A wrapper for i18n::translate();
*
* You can use it as if it has 2 arguments and then pass the rest of the arguments as arguments to go to sprintf.
*/
function __($section, $key = null, $locale = 'DEFAULT')
{
if (func_num_args() > 3 || func_num_args() > 2 && $locale !== 'DEFAULT') {
$args = func_get_args();
return call_user_func_array('i18n::translate', $args);
}
return i18n::translate($section, $key, $locale);
}
/**
* Like __() but echos the output.
示例10: array_remove_empty
return;
}
$parts = array_remove_empty(explode("/", ltrim($url, "/")));
preg_match_all("#:([a-zA-Z_]+)#", $url, $matches);
$expecting = count($matches[1]);
// if there is a blank at the end it will be one longer
if (count($url_parts) == count($parts) || count($url_parts) - 1 == count($parts)) {
foreach ($parts as $k => $v) {
if ($v == "*") {
$ret_vals[] = implode("/", array_slice($url_parts, $k));
} elseif (substr($v, 0, 1) == ":") {
$ret_vals[substr($v, 1)] = $url_parts[$k];
} elseif ($url_parts[$k] == $v) {
continue;
} else {
break;
}
}
if (count($ret_vals) == $expecting) {
call_user_func($callback, $ret_vals);
return;
}
} else {
continue;
}
}
}
}
}
Hooks::bind("system_after_content_load", "URLMap::process", 100);