本文整理汇总了PHP中Observer::observe方法的典型用法代码示例。如果您正苦于以下问题:PHP Observer::observe方法的具体用法?PHP Observer::observe怎么用?PHP Observer::observe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Observer
的用法示例。
在下文中一共展示了Observer::observe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$this->_check();
$this->setLayout("backend");
$this->assignToLayout("sidebar", new View("../../plugins/paw_users/admin/sidebar"));
Observer::observe("view_backend_layout_head", "UserController::_loadCSS");
}
示例2: Init
/**
* Registers the plugin and controller in the system as well as the observers.
*/
public static function Init()
{
// Register plugin
Plugin::setInfos(array('id' => self::PLUGIN_ID, 'title' => __('Page Part Forms'), 'description' => __('Allows to create custom page part forms'), 'version' => self::PLUGIN_VERSION, 'license' => 'AGPL', 'author' => 'THE M', 'website' => 'http://github.com/them/frog_page_part_forms/', 'update_url' => 'http://github.com/them/frog_page_part_forms/raw/master/frog-plugins.xml', 'require_frog_version' => '0.9.5'));
// Register controller
Plugin::addController(self::PLUGIN_ID, __('Page Part Forms'), 'administrator, developer', true);
// Add extra scripting for JSON
Plugin::addJavascript(self::PLUGIN_ID, "labs_json.js");
// The callbacks for the backend
Observer::observe('view_page_page_metadata', __CLASS__ . '::callback_view_page_page_metadata');
Observer::observe('view_page_edit_popup', __CLASS__ . '::callback_view_page');
}
示例3: __construct
public function __construct()
{
AuthUser::load();
if (!AuthUser::isLoggedIn()) {
redirect(get_url("login"));
die;
}
// GET SETTINGS
$settings = array_merge(array("grid-size" => 3, "widget-position" => serialize(array("events" => array("part" => 1, "order" => 1), "rss_reader" => array("part" => 2, "order" => 1)))), Plugin::getAllSettings("dashboard"));
// UNSERIALIZE SETTINGS
foreach ($settings as $key => $value) {
if (is_string($value)) {
if (@unserialize($value) !== false) {
$settings[$key] = unserialize($value);
}
}
}
$this->settings = $settings;
// OBSERVER
DashboardWidgets::init($settings["widget-position"]);
Observer::observe("view_backend_layout_head", "DashboardController::loadFiles");
}
示例4: function
*/
Observer::notify('after_page_load');
/**
* Блок служит для помещения в него виджета с произволным PHP кодом,
* который выполняется после загрузки HTML
*/
Block::run('POST');
});
Observer::observe('view_page_edit_plugins', function ($page) {
$blocks = Widget_Manager::get_blocks_by_layout($page->layout());
echo View::factory('widgets/page/edit', array('page' => $page, 'pages' => Model_Page_Sitemap::get(TRUE)->exclude(array($page->id))->flatten(), 'widgets' => Widget_Manager::get_widgets_by_page($page->id), 'blocks' => Arr::get($blocks, $page->layout())));
});
Observer::observe('page_add_after_save', function ($page) {
$post_data = Request::current()->post('widgets');
if (!empty($post_data['from_page_id'])) {
Widget_Manager::copy($post_data['from_page_id'], $page->id);
}
});
Observer::observe('page_edit_after_save', function ($page) {
$post_data = Request::current()->post('widget');
if (!is_array($post_data)) {
return;
}
foreach ($post_data as $widget_id => $block) {
Widget_Manager::update_location_by_page($page->id, $widget_id, $block);
}
});
Observer::observe(array('widget_after_delete', 'widget_set_location', 'widget_after_edit', 'widget_after_add'), function () {
Cache::instance()->delete_tag('layout_blocks');
});
Route::set('handler', 'handler/<id>', array('id' => '[0-9]+'))->defaults(array('directory' => 'system', 'controller' => 'handler'));
示例5: define
* @package Plugins
* @subpackage shopping-cart
*
* @author Stefan Miller <linuxsmiller@gmail.com>
* Copyright (C) 2014 Stefan Miller <linuxsmiller@gmail.com>
* @license http://www.gnu.org/licenses/gpl.html GPLv3 license
*
*/
/* Security measure */
if (!defined('IN_CMS')) {
exit;
}
/**
* Root location where Files plugin lives.
*/
define('SC_FILES_ROOT', PATH_PUBLIC . 'wolf/plugins/shopping_cart');
/**
* Root location where files get uploaded to as an absolute path.
*/
define('SC_FILES_DIR', CMS_ROOT . DS . 'public');
/**
* Root location where files get uploaded to as a URL.
*/
define('BASE_SC_FILES_DIR', URL_PUBLIC . 'public');
// DO NOT EDIT AFTER THIS LINE -----------------------------------------------
Plugin::setInfos(array('id' => 'shopping_cart', 'title' => 'Shopping Cart', 'description' => 'A shopping cart inventory administration module', 'version' => '0.0.1', 'author' => 'Stefan Miller', 'website' => 'http://www.artisticdigital.com', 'require_wolf_version' => '0.7.0'));
Plugin::addController('shopping_cart', __('Shopping Cart'), 'admin_view', true);
// Make sure possible hack attempts get registered if the statistics API is available.
if (Plugin::isEnabled('statistics_api')) {
Observer::observe('stats_shopping_cart_hack_attempt', 'StatisticsEvent::registerEvent');
}
示例6: __
/**
* Provides Page not found page types.
*
* @package Plugins
* @subpackage page-not-found
*
* @author Philippe Archambault <philippe.archambault@gmail.com>
* @copyright Philippe Archambault, 2008
* @license http://www.gnu.org/licenses/gpl.html GPLv3 license
*/
/* Security measure */
if (!defined('IN_CMS')) {
exit;
}
Plugin::setInfos(array('id' => 'page_not_found', 'title' => __('Page not found'), 'description' => __('Provides Page not found page types.'), 'version' => '1.0.0', 'website' => 'http://www.wolfcms.org/', 'update_url' => 'http://www.wolfcms.org/plugin-versions.xml'));
Behavior::add('page_not_found', '');
Observer::observe('page_not_found', 'behavior_page_not_found');
/**
* Presents browser with a custom 404 page.
*/
function behavior_page_not_found($url)
{
$page = Page::findByBehaviour('page_not_found');
if (is_a($page, 'Page')) {
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
$page->_executeLayout();
exit;
// need to exit otherwise true error page will be sent
}
}
示例7: __
| @file ./index.php
| @author svanlaere
| @version 1.0.0 [1.0.0] - Stable
|
| @license X11 / MIT License
| @copyright Copyright © 2015 pytesNET
*/
if (!defined("IN_CMS")) {
exit;
}
// SET PLUGIN INFOS
Plugin::setInfos(array("id" => "themer", "title" => "Themer", "description" => __("A WordPress AdminTheme configuration plugin."), "version" => "1.0.0", "license" => "GPL", "author" => "svanlaere", "website" => "http://www.wolfcms.org/forum/", "require_wolf_version" => "0.7.5", "type" => "backend"));
Plugin::addController("themer", __("Wordpress admin theme"), "admin_view", false);
if (Plugin::isEnabled("themer")) {
if (!defined("THEMER")) {
define("THEMER", PLUGINS_ROOT . "/themer");
}
if (!defined("THEMER_VIEW")) {
define("THEMER_VIEW", "themer/views/");
}
function themer_customize_admin_theme($path)
{
$admin_theme = Setting::get("theme");
$settings = Plugin::getAllSettings("themer");
if ($admin_theme == "wordpress-3.8") {
echo new View(THEMER . DS . "views" . DS . "head", array("color" => $settings["color"], "sidebar_width" => $settings["sidebar_width"]));
}
return $path;
}
Observer::observe("view_backend_layout_head", "themer_customize_admin_theme");
}
示例8: foreach
if (empty($folder['sections'])) {
continue;
}
$folder_section = Model_Navigation::get_section($folder['name'], $ds_section);
foreach ($folder['sections'] as $id => $section) {
$section->add_to_menu($folder_section);
}
}
foreach ($sections_list as $type => $sections) {
foreach ($sections as $id => $section) {
$section->add_to_menu($ds_section);
}
}
$_create_section = Model_Navigation::get_section(__('Create section'), $ds_section, 999);
foreach ($types as $id => $type) {
$_create_section->add_page(new Model_Navigation_Page(array('name' => $type, 'url' => Route::get('datasources')->uri(array('controller' => 'section', 'directory' => 'datasources', 'action' => 'create', 'id' => $id)), 'permissions' => $id . '.section.create')));
}
unset($sections_list, $folders, $root_section);
} catch (Exception $ex) {
}
});
Observer::observe('update_search_index', function () {
$ds_ids = Datasource_Data_Manager::get_all();
foreach ($ds_ids as $ds_id => $data) {
$ds = Datasource_Data_Manager::load($ds_id);
if (!$ds->loaded()) {
continue;
}
$ds->update_index();
}
});
示例9: RegisteredUser
* ru_register_page() Use this on the page you want to have for registrations eg mysite.com/register
* ru_login_page() Use this on the page you want to have for logging in eg mysite.com/login
* ru_confirm_page() This is the page a user clicks through to validate their account
* ru_auth_required_page() Users who are not authorised to view the requested page will be redirected here
* ru_reset_page() Will allow a user to have an email sent to them with a lnk to reset their password
* ru_logout() A page to logout a user and return them to the hompage
*/
Plugin::setInfos(array('id' => 'registered_users', 'title' => 'Registered Users', 'description' => 'Allows you to manage new user registrations on your site.', 'version' => '1.0-dev', 'author' => 'Martijn van der Kleijn', 'require_wolf_version' => '0.7.7'));
// Only when the plugin is enabled
if (Plugin::isEnabled('registered_users')) {
Plugin::addController('registered_users', 'Registered Users', 'admin_edit', true);
Observer::observe('view_page_edit_plugins', 'registered_users_access_page_checkbox');
Observer::observe('page_add_after_save', 'registered_users_add_page_permissions');
Observer::observe('page_edit_after_save', 'registered_users_edit_page_permissions');
Observer::observe('page_delete', 'registered_users_delete_page_permissions');
Observer::observe('page_found', 'registered_users_page_found');
Behavior::add('login_page', '');
include 'classes/RegisteredUser.php';
include 'classes/RUCommon.php';
include 'observers/RUObservers.php';
// @todo Switch this stupid stuff to use routes
function ru_login_page()
{
$registered_users_class = new RegisteredUser();
$loginpage = $registered_users_class->login_page();
echo $loginpage;
}
function ru_register_page()
{
$registered_users_class = new RegisteredUser();
$registerpage = $registered_users_class->registration_page();
示例10: image_resize_try_resizing
<?php
require_once "ImageResize.php";
Plugin::setInfos(array('id' => 'image_resize', 'title' => 'Image Resize', 'description' => 'Allows for dynamic resizing of images.', 'version' => '1.3.1', 'license' => 'GPL 3.0', 'author' => 'Peter Gassner', 'website' => 'http://www.naehrstoff.ch/code/image-resize-for-frog', 'update_url' => 'http://frog.naehrstoff.ch/plugin-versions.xml', 'require_frog_version' => '0.9.4'));
// Listen for page_not_found messages
Observer::observe('page_not_found', 'image_resize_try_resizing');
// Add the controller without showing a tab (fourth option)
Plugin::addController('image_resize', 'Image Resize', '', FALSE);
/**
* Execute this function on page_not_found.
* If the request is for an image file,
* resize the image.
*/
function image_resize_try_resizing()
{
// Require that visitor be logged in and has
// permission to create files
if (!AuthUser::isLoggedIn()) {
AuthUser::load();
}
if (!AuthUser::hasPermission('administrator,developer,editor')) {
return false;
}
// Check that gd library is available
if (!ImageResize::gd_available()) {
return false;
}
if (preg_match('#\\.(jpe?g|gif|png|wbmp)$#i', CURRENT_URI)) {
// If requested file appears to be an accepted format, create the new image
if (image_resize_scale(CURRENT_URI) && !DEBUG) {
// If Frog isn't debugging, it writes to a file; redirect to it
示例11: defined
<?php
defined('SYSPATH') or die('No direct script access.');
Observer::observe('part_before_save', function ($part) {
if (!$part->loaded()) {
return;
}
$data = array('part_id' => $part->id, 'created_on' => date('Y-m-d H:i:s'), 'content' => Arr::get($part->original_values(), 'content'));
DB::insert('part_revision')->columns(array_keys($data))->values($data)->execute();
});
Observer::observe('part_controls', function () {
$url = Route::get('backend')->uri(array('controller' => 'part', 'action' => 'revision', 'id' => '<%=id%>'));
echo '<a class="part-revision-button btn btn-default btn-xs" href="' . URL::site($url) . '">' . __('Part revision') . '</a>';
});
示例12: sprintf
Observer::observe('layout_after_delete', 'dashboard_log_layout_delete');
Observer::observe('layout_after_add', 'dashboard_log_layout_add');
Observer::observe('layout_after_edit', 'dashboard_log_layout_edit');
Observer::observe('snippet_after_delete', 'dashboard_log_snippet_delete');
Observer::observe('snippet_after_add', 'dashboard_log_snippet_add');
Observer::observe('snippet_after_edit', 'dashboard_log_snippet_edit');
Observer::observe('comment_after_delete', 'dashboard_log_comment_delete');
Observer::observe('comment_after_add', 'dashboard_log_comment_add');
Observer::observe('comment_after_edit', 'dashboard_log_comment_edit');
Observer::observe('comment_after_approve', 'dashboard_log_comment_approve');
Observer::observe('comment_after_unapprove', 'dashboard_log_comment_unapprove');
Observer::observe('plugin_after_enable', 'dashboard_log_plugin_enable');
Observer::observe('plugin_after_disable', 'dashboard_log_plugin_disable');
Observer::observe('admin_login_success', 'dashboard_log_admin_login');
Observer::observe('admin_login_failed', 'dashboard_log_admin_login_failure');
Observer::observe('admin_after_logout', 'dashboard_log_admin_logout');
/* Page */
function dashboard_log_page_add($page)
{
$linked_title = sprintf('<a href="%s">%s</a>', get_url('page/edit/' . $page->id), $page->title);
$message = __('Page <b>:title</b> was created by :name', array(':title' => $linked_title, ':name' => AuthUser::getRecord()->name));
dashboard_log_event($message, 'core');
}
function dashboard_log_page_edit($page)
{
$linked_title = sprintf('<a href="%s">%s</a>', get_url('page/edit/' . $page->id), $page->title);
$message = __('Page <b>:title</b> was revised by :name', array(':title' => $linked_title, ':name' => AuthUser::getRecord()->name));
dashboard_log_event($message, 'core');
}
function dashboard_log_page_delete($page)
{
示例13: defined
<?php
defined('SYSPATH') or die('No direct access allowed.');
Plugin::factory('page_not_found', array('title' => 'Page not found', 'description' => 'Provides Page not found type.', 'author' => 'ButscH'))->register();
Observer::observe('page_not_found', function ($message, $params) {
throw new HTTP_Exception_Front_404($message, $params);
});
示例14: Crookston
* @author Andrew Crookston <andrew@casystems.se>
* @version 0.1.0
* @since Frog version 0.9.5
* @license http://www.gnu.org/licenses/gpl.html GPL License
* @copyright Andrew Crookston, 2009
*
* @todo Only supports text in the Body-part. Should be able to choose fields via settings
* @todo Known issue: Will not filter out markup like Textile or Markdown. Filters out HTML and PHP etc..
* @todo Add a disable.php for rolling back the database changes when disabling the plugin
*/
Plugin::setInfos(array('id' => 'fsearch', 'title' => 'FSearch - Frog MySQL Search', 'description' => 'Provides MySQL full-text search capabilities.', 'version' => '1.1.0', 'license' => 'GPLv3', 'author' => 'Andrew Crookston (CA Systems)', 'website' => 'http://www.casystems.se', 'update_url' => 'http://www.casystems.se/frog-plugin-versions.xml', 'require_frog_version' => '0.9.5'));
// Load the FSearch class into the system
AutoLoader::addFile('FSearch', CORE_ROOT . '/plugins/fsearch/FSearch.php');
// Add observers for page editing
Observer::observe('view_page_edit_plugins', 'fsearch_display_select');
Observer::observe('part_edit_after_save', 'fsearch_clean_contents');
/**
* Retrieve an array with all pages matching the search phrase.
*
* @param Search $search A string containing MySQL full-text search query.
* @return Array Returns an array of Page objects, if any.
*/
function fsearch($search)
{
$pages = FSearch::search(array('search' => $search, 'limit' => 10));
return $pages;
}
/**
* Adds a 'Make searchable' checkbox on the edit page view in the backend.
*
* @param Page $page The object instance for the page that is being edited.
示例15: __
Plugin::setInfos(array('id' => 'multi_lang', 'title' => __('Multiple Languages'), 'description' => __('Provides language specific content when available based on user preferences.'), 'version' => '1.0.0', 'license' => 'GPL', 'author' => 'Martijn van der Kleijn', 'website' => 'http://freshcms.jules.it/', 'update_url' => 'http://freshcms.jules.it/plugin-versions.xml', 'require_cms_version' => '0.6.0'));
Plugin::addController('multi_lang', __('Multiple Languages'), 'administrator', false);
// Observe the necessary events.
$style = Plugin::getSetting('style', 'multi_lang');
$source = Plugin::getSetting('langsource', 'multi_lang');
if (false !== $style && $style == 'tab') {
if ($source == 'uri') {
Observer::observe('page_requested', 'replaceUri');
Observer::observe('page_found', 'replaceContentByUri');
} else {
Observer::observe('page_found', 'replaceContent');
}
} else {
if (false !== $style && $style == 'page') {
if ($source == 'header' || $source == 'preferences') {
Observer::observe('page_found', 'replaceContent');
}
}
}
/**
* Replaces the content of the 'body' part if a language specific part exists.
*
* @param Page $page Page object.
*/
function replaceContent($page)
{
$source = Plugin::getSetting('langsource', 'multi_lang');
$style = Plugin::getSetting('style', 'multi_lang');
if (!$source || !$style) {
return;
}