本文整理汇总了PHP中Plugins::act方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugins::act方法的具体用法?PHP Plugins::act怎么用?PHP Plugins::act使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugins
的用法示例。
在下文中一共展示了Plugins::act方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter_rssblocks_update
public function filter_rssblocks_update($success, $force = false)
{
EventLog::log('Running rrsblocks update');
$blocks = DB::get_results('SELECT b.* FROM {blocks} b WHERE b.type = ?', array('rssblock'), 'Block');
Plugins::act('get_blocks', $blocks);
$success = true;
foreach ($blocks as $block) {
$cachename = array('rssblock', md5($block->feed_url));
if ($force || Cache::expired($cachename)) {
$r = new RemoteRequest($block->feed_url);
$r->set_timeout(10);
$r->execute();
$feed = $r->get_response_body();
try {
if (is_string($feed)) {
new SimpleXMLElement($feed);
// This throws an exception if the feed isn't valid
Cache::set($cachename, $feed, 3600, true);
}
} catch (Exception $e) {
$success = false;
}
}
}
Session::notice('ran rssblocks update');
return $success;
}
示例2: action_ajax_block
public function action_ajax_block(AjaxHandler $handler)
{
if (!isset($_SESSION['ajax_blocks'][$_GET['_b']])) {
die;
}
$block = $_SESSION['ajax_blocks'][$_GET['_b']];
$context = null;
$handler->setup_theme();
$theme = $handler->theme;
$blocks = $theme->get_blocks($block->_area, $block->_scope_id, $theme);
$blocks = array_filter($blocks, function ($b) use($block) {
return $b->id == $block->id;
});
$rebuildblock = reset($blocks);
$rebuildblock->_area = $block->_area;
$rebuildblock->_instance_id = $block->_instance_id;
$rebuildblock->_area_index = $block->_area_index;
$hook = 'block_content_' . $rebuildblock->type;
Plugins::act($hook, $rebuildblock, $theme);
Plugins::act('block_content', $rebuildblock, $theme);
$rebuildblock->_content = $theme->content($rebuildblock, $context);
$rebuildblock->_first = $block->_first;
$rebuildblock->_last = $block->_last;
// Set up the theme for the wrapper
$theme->block = $rebuildblock;
$theme->content = $rebuildblock->_content;
// This is the block wrapper fallback template list
$fallback = array($block->area . '.blockwrapper', 'blockwrapper', 'content');
if (!is_null($context)) {
array_unshift($fallback, $context . '.blockwrapper');
array_unshift($fallback, $context . '.' . $block->area . '.blockwrapper');
}
$output = $theme->display_fallback($fallback, 'fetch');
echo $output;
}
示例3: act
/**
* All handlers must implement act() to conform to handler API.
* This is the default implementation of act(), which attempts
* to call a class member method of $this->act_$action(). Any
* subclass is welcome to override this default implementation.
*
* @param string $action the action that was in the URL rule
*/
public function act($action)
{
if (null === $this->handler_vars) {
$this->handler_vars = new SuperGlobal(array());
}
$this->action = $action;
$action_method = 'act_' . $action;
$before_action_method = 'before_' . $action_method;
$after_action_method = 'after_' . $action_method;
if (method_exists($this, $action_method)) {
if (method_exists($this, $before_action_method)) {
$this->{$before_action_method}();
}
/**
* Plugin action to allow plugins to execute before a certain
* action is triggered
*
* @see ActionHandler::$action
* @action before_act_{$action}
*/
Plugins::act($before_action_method, $this);
$this->{$action_method}();
/**
* Plugin action to allow plugins to execute after a certain
* action is triggered
*
* @see ActionHandler::$action
* @action before_act_{$action}
*/
Plugins::act($after_action_method);
if (method_exists($this, $after_action_method)) {
$this->{$after_action_method}();
}
}
}
示例4: action_admin_header
public function action_admin_header($theme)
{
if ($theme->page == 'configure_block' && $_GET['inline'] == 1) {
Plugins::act('add_jwysiwyg_admin');
Stack::add('admin_stylesheet', array('#block_admin { display: none; } textarea { height: 250px; width: 540px; }', 'screen'));
}
}
示例5: action_plugin_act_podcast_media
/**
* Redirects the link from an embedded player, feed, or an html
* download link to the actual file
*
* @param PluginHandler $handler. Primarily used to get the handler vars
* @return Nothing.
* @TODO make sure $podcast actually holds a valid feed
* @TODO make sure $method is valid
*/
public function action_plugin_act_podcast_media($handler)
{
// $podcast is the name of the podcast
$podcast = $handler->handler_vars['podcast_name'];
// $post is the post we're using
$post = Post::get(array('slug' => $handler->handler_vars['post_name']));
// $method is the source of the link
// embed - from an on-page player
// download- from a download link under the player
// feed - from a feed
$method = $handler->handler_vars['method'];
$info = $post->info->{"{$podcast}"};
if (!empty($info) && isset($info['enclosure'])) {
$filename = $handler->handler_vars['filename'];
$url = dirname($info['enclosure']) . '/' . $filename;
// allow plugins to act. intended for stats
Plugins::act('podcast_redirect', $podcast, $post, $method, rawurldecode($filename));
header('Cache-Control: no-cache, must-revalidate');
// HTTP/1.1
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
header('Pragma:no-cache');
// HTTP/1.0
header('Content-type: ' . Utils::mimetype($url));
header('Content-Length: ' . $info['size']);
Utils::redirect($url);
}
}
示例6: act
/**
* All handlers must implement act() to conform to handler API.
* This is the default implementation of act(), which attempts
* to call a class member method of $this->act_$action(). Any
* subclass is welcome to override this default implementation.
*
* @param string $action the action that was in the URL rule
*/
public function act($action)
{
if (null === $this->handler_vars) {
$this->handler_vars = new SuperGlobal(array());
}
$this->action = $action;
$this->theme->assign('matched_rule', URL::get_matched_rule());
$request = new StdClass();
foreach (URL::get_active_rules() as $rule) {
$request->{$rule->name} = false;
}
$request->{$this->theme->matched_rule->name} = true;
$this->theme->assign('request', $request);
$action_hook = 'plugin_act_' . $action;
$before_action_hook = 'before_' . $action_hook;
$theme_hook = 'route_' . $action;
$after_action_hook = 'after_' . $action_hook;
Plugins::act($before_action_hook, $this);
Plugins::act($action_hook, $this);
if (Plugins::implemented($theme_hook, 'theme')) {
$theme = Themes::create();
$rule = URL::get_matched_rule();
Plugins::theme($theme_hook, $theme, $rule->named_arg_values, $this);
}
Plugins::act($after_action_hook);
}
示例7: act_verified_rest
/**
* Handles incoming REST requests for which the user must be authenticated.
* Used for requests where tokens are provided for verification.
* Forwards the request to plugin hook registered for the RewriteRule.
*
* @see act_rest()
*/
public function act_verified_rest()
{
Plugins::act('auth_rest_verify', $this);
$matched_rule = Controller::get_matched_rule();
$hookfn = $matched_rule->parameters['hook'];
$result = call_user_func_array($hookfn, array($matched_rule->named_arg_values));
if (!$result instanceof RestResponse) {
$result = new RestResponse($result);
}
$result->out();
}
示例8: act_auth_ajax
/**
* Handles incoming ajax requests for which the user must be authenticated.
* Forwards the request to plugin actions for the "context" portion of the URL.
*
* @see act_ajax()
*/
public function act_auth_ajax()
{
$user = User::identify();
if ($user->loggedin) {
/**
* Triggers the ajax plugin action for the context if user is authenticated.
*
* @see act_auth_ajax()
* @action ajax_auth_{$context}
*/
Plugins::act('auth_ajax_' . $this->handler_vars['context'], $this);
exit;
}
}
示例9: check
/**
* Perform a check of all beaconids.
* Notifies update_check plugin hooks when checking so that they can add their beaconids to the list.
* @return array An array of update beacon information for components that have updates
*/
public static function check()
{
try {
$instance = self::instance();
if (count($instance->beacons) == 0) {
Update::add('Habari', '7a0313be-d8e3-11db-8314-0800200c9a66', Version::get_habariversion());
Plugins::act('update_check');
}
$request = new RemoteRequest(UPDATE_URL, 'POST');
$request->set_params(array_map(create_function('$a', 'return $a["version"];'), $instance->beacons));
$request->set_timeout(10);
$result = $request->execute();
if (Error::is_error($result)) {
throw $result;
}
$updatedata = $request->get_response_body();
if (Error::is_error($updatedata)) {
throw $updatedata;
}
$instance->update = new SimpleXMLElement($updatedata);
foreach ($instance->update as $beacon) {
$beaconid = (string) $beacon['id'];
foreach ($beacon->update as $update) {
// Do we have this beacon? If not, don't process it.
if (empty($instance->beacons[$beaconid])) {
continue;
}
// If the remote update info version is newer...
if (version_compare($update['version'], $instance->beacons[$beaconid]['version']) > 0) {
// If this version is more recent than all other newer versions...
if (empty($instance->beacons[$beaconid]['latest_version']) || version_compare((string) $update['version'], $instance->beacons[$beaconid]['latest_version']) > 0) {
$instance->beacons[$beaconid]['latest_version'] = (string) $update['version'];
}
if (isset($instance->beacons[$beaconid]['severity'])) {
$instance->beacons[$beaconid]['severity'][] = (string) $update['severity'];
array_unique($instance->beacons[$beaconid]['severity']);
} else {
$instance->beacons[$beaconid]['severity'] = array((string) $update['severity']);
}
$instance->beacons[$beaconid]['url'] = (string) $beacon['url'];
$instance->beacons[$beaconid]['changes'][(string) $update['version']] = (string) $update;
}
}
}
return array_filter($instance->beacons, array('Update', 'filter_unchanged'));
} catch (Exception $e) {
return $e;
}
}
示例10: __set
/**
* function __set
* Handles setting virtual properties for this class
* @param string Name of the property
* @param mixed Value to set it to
* @return mixed The set value
**/
public function __set($name, $value)
{
$classname = strtolower(get_class($this));
$hook = 'set_' . $classname . '_' . $name;
if (Plugins::implemented($hook, 'action')) {
return Plugins::act('set_' . $classname . '_' . $name, $value, $this);
}
if (isset($this->properties_loaded[$name])) {
$this->newfields[$name] = $value;
} else {
$this->fields[$name] = $value;
$this->properties_loaded[$name] = true;
}
return $value;
}
示例11: act
/**
* All handlers must implement act() to conform to handler API.
* This is the default implementation of act(), which attempts
* to call a class member method of $this->act_$action(). Any
* subclass is welcome to override this default implementation.
*
* @param string $action the action that was in the URL rule
*/
public function act($action)
{
if (null === $this->handler_vars) {
$this->handler_vars = new SuperGlobal(array());
}
$this->action = $action;
$this->theme->assign('matched_rule', URL::get_matched_rule());
$request = new StdClass();
foreach (RewriteRules::get_active() as $rule) {
$request->{$rule->name} = false;
}
$request->{$this->theme->matched_rule->name} = true;
$this->theme->assign('request', $request);
$action_hook = 'plugin_act_' . $action;
$before_action_hook = 'before_' . $action_hook;
$after_action_hook = 'after_' . $action_hook;
Plugins::act($before_action_hook, $this);
Plugins::act($action_hook, $this);
Plugins::act($after_action_hook);
}
示例12: configure
function configure()
{
$ui = new FormUI('jsmincdn');
$scripts = $ui->append('checkboxes', 'scripts', 'jsmincdn__storage', 'Select the scripts that should be served as minimized.');
$theme = Themes::create();
Plugins::act('template_header', $theme);
Plugins::act('template_footer', $theme);
$options = Stack::get_named_stack('template_header_javascript');
$options = array_merge($options, Stack::get_named_stack('template_footer_javascript'));
$options_out = array();
foreach ($options as $option => $value) {
if (preg_match('#[a-f0-9]{32}#', $option)) {
$value = htmlspecialchars(substr($value, 0, 80));
} else {
$value = $option;
}
$options_out[$option] = $value;
}
$scripts->options = $options_out;
$ui->append('submit', 'submit', 'Submit');
return $ui;
}
示例13: delete
/**
* function delete
* Deletes an existing tag and all relations to it (e.g. a post2tag relationship)
*/
public function delete()
{
$allow = true;
$allow = Plugins::filter('tag_delete_allow', $allow, $this);
if (!$allow) {
return;
}
// invoke plugins
Plugins::act('tag_delete_before', $this);
// Delete all tag2post records associated with this tag
$sql = "DELETE FROM {tag2post} WHERE tag_id = ?";
DB::query($sql, array($this->id));
// Delete the parent tags record
$result = parent::deleteRecord(DB::table('tags'), array('id' => $this->id));
EventLog::log(sprintf(_t('Tag %1$s (%2$s) deleted.'), $this->id, $this->tag_text), 'info', 'content', 'habari');
Plugins::act('tag_delete_after', $this);
return $result;
}
示例14: printf
if ($active_theme['info']->license != '') {
?>
<p class="description pct70"><?php
printf(_t('%1$s is licensed under the %2$s'), $active_theme['info']->name, '<a href="' . $active_theme['info']->license['url'] . '">' . $active_theme['info']->license . '</a>');
?>
</p>
<?php
}
?>
</div>
</div>
<?php
// Capture the admin config output. If nothing is there, don't output the section
ob_start();
Plugins::act('theme_ui', $active_theme);
$output = ob_get_clean();
if (trim($output) != '') {
?>
<div class="item clear">
<h3>General</h3>
<?php
echo $output;
?>
<div></div>
</div>
<?php
}
?>
示例15: _e
}
?>
</ul>
<?php
if ($comment->status == Comment::STATUS_SPAM) {
?>
<p><?php
_e('Marked as spam');
?>
</p>
<?php
}
?>
<?php
Plugins::act('comment_info', $comment);
?>
<p class="comment-type"><?php
echo Plugins::filter('comment_type_display', $comment->typename, 'singular');
?>
</p>
</div>
<span class="content pct75"><?php
if (MultiByte::valid_data($comment->content)) {
echo nl2br(Utils::htmlspecialchars($comment->content));
} else {
_e('this post contains text in an invalid encoding');
}
?>
</span>