本文整理汇总了PHP中trigger_plugin_hook函数的典型用法代码示例。如果您正苦于以下问题:PHP trigger_plugin_hook函数的具体用法?PHP trigger_plugin_hook怎么用?PHP trigger_plugin_hook使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trigger_plugin_hook函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sitepages_init
/**
* Start the site pages plugin.
*/
function sitepages_init()
{
require_once dirname(__FILE__) . '/sitepages_functions.php';
global $CONFIG;
// register our subtype
run_function_once('sitepages_runonce');
// Register a page handler, so we can have nice URLs
register_page_handler('sitepages', 'sitepages_page_handler');
// Register a URL handler for external pages
register_entity_url_handler('sitepages_url', 'object', 'sitepages');
elgg_extend_view('footer/links', 'sitepages/footer_menu');
elgg_extend_view('metatags', 'sitepages/metatags');
// Replace the default index page if user has requested
if (get_plugin_setting('ownfrontpage', 'sitepages') == 'yes') {
register_plugin_hook('index', 'system', 'sitepages_custom_index');
}
// parse views for keywords
register_plugin_hook('display', 'view', 'sitepages_parse_view');
// register the views we want to parse for the keyword replacement
// right now this is just the custom front page, but we can
// expand it to the other pages later.
$CONFIG->sitepages_parse_views = array('sitepages/custom_frontpage');
// an example of how to register and respond to the get_keywords trigger
register_plugin_hook('get_keywords', 'sitepages', 'sitepages_keyword_hook');
// grab the list of keywords and their views from plugins
if ($keywords = trigger_plugin_hook('get_keywords', 'sitepages', NULL, array())) {
$CONFIG->sitepages_keywords = $keywords;
}
register_action("sitepages/add", FALSE, $CONFIG->pluginspath . "sitepages/actions/add.php");
register_action("sitepages/addfront", FALSE, $CONFIG->pluginspath . "sitepages/actions/addfront.php");
register_action("sitepages/addmeta", FALSE, $CONFIG->pluginspath . "sitepages/actions/addmeta.php");
register_action("sitepages/edit", FALSE, $CONFIG->pluginspath . "sitepages/actions/edit.php");
register_action("sitepages/delete", FALSE, $CONFIG->pluginspath . "sitepages/actions/delete.php");
}
示例2: garbagecollector_cron
/**
* Cron job
*
*/
function garbagecollector_cron($hook, $entity_type, $returnvalue, $params)
{
global $CONFIG;
echo elgg_echo('garbagecollector');
// Garbage collect metastrings
echo elgg_echo('garbagecollector:gc:metastrings');
if (delete_orphaned_metastrings() !== false) {
echo elgg_echo('garbagecollector:ok');
} else {
echo elgg_echo('garbagecollector:error');
}
echo "\n";
// Now, because we are nice, trigger a plugin hook to let other plugins do some GC
$rv = true;
$period = get_plugin_setting('period', 'garbagecollector');
trigger_plugin_hook('gc', 'system', array('period' => $period));
// Now we optimize all tables
$tables = get_db_tables();
foreach ($tables as $table) {
echo sprintf(elgg_echo('garbagecollector:optimize'), $table);
if (optimize_table($table) !== false) {
echo elgg_echo('garbagecollector:ok');
} else {
echo elgg_echo('garbagecollector:error');
}
echo "\n";
}
echo elgg_echo('garbagecollector:done');
}
示例3: profile_fields_setup
/**
* This function loads a set of default fields into the profile, then triggers a hook letting other plugins to edit
* add and delete fields.
*
* Note: This is a secondary system:init call and is run at a super low priority to guarantee that it is called after all
* other plugins have initialised.
*/
function profile_fields_setup()
{
global $CONFIG;
$profile_defaults = array('description' => 'longtext', 'briefdescription' => 'text', 'location' => 'tags', 'interests' => 'tags', 'skills' => 'tags', 'contactemail' => 'email', 'phone' => 'text', 'mobile' => 'text', 'website' => 'url', 'twitter' => 'text');
// TODO: Have an admin interface for this
$n = 0;
$loaded_defaults = array();
while ($translation = get_plugin_setting("admin_defined_profile_{$n}", 'profile')) {
// Add a translation
add_translation(get_current_language(), array("profile:admin_defined_profile_{$n}" => $translation));
// Detect type
$type = get_plugin_setting("admin_defined_profile_type_{$n}", 'profile');
if (!$type) {
$type = 'text';
}
// Set array
$loaded_defaults["admin_defined_profile_{$n}"] = $type;
$n++;
}
if (count($loaded_defaults)) {
$CONFIG->profile_using_custom = true;
$profile_defaults = $loaded_defaults;
}
$CONFIG->profile = trigger_plugin_hook('profile:fields', 'profile', NULL, $profile_defaults);
// register any tag metadata names
foreach ($CONFIG->profile as $name => $type) {
if ($type == 'tags') {
elgg_register_tag_metadata_name($name);
// register a tag name translation
add_translation(get_current_language(), array("tag_names:{$name}" => elgg_echo("profile:{$name}")));
}
}
}
示例4: homepage_cms_page_handler
function homepage_cms_page_handler($page)
{
if (!isset($page[0])) {
$page[0] = 'all';
}
$page_type = $page[0];
$base_plugin_pages = elgg_get_plugins_path() . 'homepage_cms_ed/pages/homepage_cms';
$hpc_params = array("type" => "object", "subtype" => "hpcroles");
$allRoles = elgg_get_entities($hpc_params);
if (!$allRoles) {
//default condition (!$allRoles)
trigger_plugin_hook('action', 'load', 'homepaage_cms_action_hook', array("hpc_role_check" => true));
} else {
//system_message('Total: '.count($allRoles));
//var_dump($allRoles);
//system_message((string)$allRoles[0]->guid);
/*foreach($allRoles as $role){
//var_dump($role);
//system_message((string)$role->guid);
}*/
}
switch ($page_type) {
case 'all':
include "{$base_plugin_pages}/index.php";
break;
}
return true;
}
示例5: elgg_geocode_location
/**
* Encode a location into a latitude and longitude, caching the result.
*
* Works by triggering the 'geocode' 'location' plugin hook, and requires a geocoding module to be installed
* activated in order to work.
*
* @param String $location The location, e.g. "London", or "24 Foobar Street, Gotham City"
*/
function elgg_geocode_location($location)
{
global $CONFIG;
// Handle cases where we are passed an array (shouldn't be but can happen if location is a tag field)
if (is_array($location)) {
$location = implode(', ', $location);
}
$location = sanitise_string($location);
// Look for cached version
$cached_location = get_data_row("SELECT * from {$CONFIG->dbprefix}geocode_cache WHERE location='{$location}'");
if ($cached_location) {
return array('lat' => $cached_location->lat, 'long' => $cached_location->long);
}
// Trigger geocode event if not cached
$return = false;
$return = trigger_plugin_hook('geocode', 'location', array('location' => $location), $return);
// If returned, cache and return value
if ($return && is_array($return)) {
$lat = (double) $return['lat'];
$long = (double) $return['long'];
// Put into cache at the end of the page since we don't really care that much
execute_delayed_write_query("INSERT DELAYED INTO {$CONFIG->dbprefix}geocode_cache (location, lat, `long`) VALUES ('{$location}', '{$lat}', '{$long}') ON DUPLICATE KEY UPDATE lat='{$lat}', `long`='{$long}'");
}
return $return;
}
开发者ID:ashwiniravi,项目名称:Elgg-Social-Network-Single-Sign-on-and-Web-Statistics,代码行数:33,代码来源:location.php
示例6: offsetGet
/**
* Get a variable from either the session, or if its not in the session attempt to get it from
* an api call.
*/
function offsetGet($key)
{
if (!ElggSession::$__localcache) {
ElggSession::$__localcache = array();
}
if (isset($_SESSION[$key])) {
return $_SESSION[$key];
}
if (isset(ElggSession::$__localcache[$key])) {
return ElggSession::$__localcache[$key];
}
$value = null;
$value = trigger_plugin_hook('session:get', $key, null, $value);
ElggSession::$__localcache[$key] = $value;
return ElggSession::$__localcache[$key];
}
示例7: elgg_geocode_location
/**
* Encode a location into a latitude and longitude, caching the result.
*
* Works by triggering the 'geocode' 'location' plugin hook, and requires a geocoding module to be installed
* activated in order to work.
*
* @param String $location The location, e.g. "London", or "24 Foobar Street, Gotham City"
*/
function elgg_geocode_location($location)
{
global $CONFIG;
$location = sanitise_string($location);
// Look for cached version
$cached_location = get_data_row("SELECT * from {$CONFIG->dbprefix}geocode_cache WHERE location='{$location}'");
// Trigger geocode event
$return = false;
$return = trigger_plugin_hook('geocode', 'location', array('location' => $location, $return));
// If returned, cache and return value
if ($return && is_array($return)) {
$lat = (int) $return['lat'];
$long = (int) $return['long'];
// Put into cache at the end of the page since we don't really care that much
execute_delayed_write_query("INSERT DELAYED INTO {$CONFIG->dbprefix}geocode_cache (lat, long) VALUES ({$lat}, {$long}) ON DUPLICATE KEY UPDATE lat={$lat} long={$long}");
}
return $return;
}
示例8: captcha_init
/**
* Elgg captcha plugin
*
* @package ElggCaptcha
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Curverider Ltd
* @copyright Curverider Ltd 2008-2010
* @link http://elgg.com/
*/
function captcha_init()
{
global $CONFIG;
// Register page handler for captcha functionality
register_page_handler('captcha', 'captcha_page_handler');
// Extend CSS
elgg_extend_view('css', 'captcha/css');
// Number of background images
$CONFIG->captcha_num_bg = 5;
// Default length
$CONFIG->captcha_length = 5;
// Register a function that provides some default override actions
register_plugin_hook('actionlist', 'captcha', 'captcha_actionlist_hook');
// Register actions to intercept
$actions = array();
$actions = trigger_plugin_hook('actionlist', 'captcha', null, $actions);
if ($actions && is_array($actions)) {
foreach ($actions as $action) {
register_plugin_hook("action", $action, "captcha_verify_action_hook");
}
}
}
示例9: forward
} else {
if (get_input('returntoreferer')) {
forward($_SERVER['HTTP_REFERER']);
} else {
forward("pg/dashboard/");
}
}
}
} else {
$error_msg = elgg_echo('loginerror');
// figure out why the login failed
if (!empty($username) && !empty($password)) {
// See if it exists and is disabled
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
if (($user = get_user_by_username($username)) && !$user->validated) {
// give plugins a chance to respond
if (!trigger_plugin_hook('unvalidated_login_attempt', 'user', array('entity' => $user))) {
// if plugins have not registered an action, the default action is to
// trigger the validation event again and assume that the validation
// event will display an appropriate message
trigger_elgg_event('validate', 'user', $user);
}
} else {
register_error(elgg_echo('loginerror'));
}
access_show_hidden_entities($access_status);
} else {
register_error(elgg_echo('loginerror'));
}
}
示例10: get_input
*/
$title = get_input('title');
$description = get_input('description');
$address = get_input('address');
$access = ACCESS_PRIVATE;
//this is private and only admins can see it
if ($title && $address) {
$entity = new ElggObject();
$entity->subtype = "reported_content";
$entity->owner_guid = $_SESSION['user']->getGUID();
$entity->title = $title;
$entity->address = $address;
$entity->description = $description;
$entity->access_id = $access;
if ($entity->save()) {
if (!trigger_plugin_hook('reportedcontent:add', $reported->type, array('entity' => $reported), true)) {
$entity->delete();
register_error(elgg_echo('reportedcontent:failed'));
} else {
system_message(elgg_echo('reportedcontent:success'));
$entity->state = "active";
}
forward($address);
} else {
register_error(elgg_echo('reportedcontent:failed'));
forward($address);
}
} else {
register_error(elgg_echo('reportedcontent:failed'));
forward($address);
}
示例11: exportAsArray
function exportAsArray($guid)
{
$guid = (int) $guid;
// Initialise the array
$to_be_serialised = array();
// Trigger a hook to
$to_be_serialised = trigger_plugin_hook("export", "all", array("guid" => $guid), $to_be_serialised);
// Sanity check
if (!is_array($to_be_serialised) || count($to_be_serialised) == 0) {
throw new ExportException(sprintf(elgg_echo('ExportException:NoSuchEntity'), $guid));
}
return $to_be_serialised;
}
开发者ID:ashwiniravi,项目名称:Elgg-Social-Network-Single-Sign-on-and-Web-Statistics,代码行数:13,代码来源:export.php
示例12: define
* @package Elgg
* @subpackage Core
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Curverider Ltd
* @copyright Curverider Ltd 2008-2009
* @link http://elgg.org/
*/
// Load Elgg engine
define('externalpage', true);
require_once "../start.php";
global $CONFIG;
// Get basic parameters
$period = get_input('period');
if (!$period) {
throw new CronException(sprintf(elgg_echo('CronException:unknownperiod'), $period));
}
// Get a list of parameters
$params = array();
$params['time'] = time();
foreach ($CONFIG->input as $k => $v) {
$params[$k] = $v;
}
// Trigger hack
$std_out = "";
// Data to return to
$old_stdout = "";
ob_start();
$old_stdout = trigger_plugin_hook('cron', $period, $params, $old_stdout);
$std_out = ob_get_clean();
// Return event
echo $std_out . $old_stdout;
示例13: get_access_sql_suffix
}
// add access
$access_suffix .= get_access_sql_suffix("e");
// Add access controls
for ($mindex = 1; $mindex <= count($meta_array); $mindex++) {
$access_suffix .= ' and ' . get_access_sql_suffix("m{$mindex}");
// Add access controls
}
if (empty($select)) {
$select = "distinct e.*";
}
// extend with hooks
$join = trigger_plugin_hook("extend_join", "profile_manager_member_search", null, $join);
$order = trigger_plugin_hook("extend_order", "profile_manager_member_search", null, $order);
$select = trigger_plugin_hook("extend_select", "profile_manager_member_search", null, $select);
$where_clause = trigger_plugin_hook("extend_where", "profile_manager_member_search", null, $where_clause);
// build query
$query = "from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}users_entity u on e.guid = u.guid {$join} where " . $where_clause . $access_suffix;
// execute query and retrieve entities
$count = get_data_row("SELECT count(distinct e.guid) as total " . $query);
$count = $count->total;
if (!empty($order)) {
$order = " order by " . $order;
}
$query = "SELECT " . $select . " " . $query . " " . $group_by . $order . " limit {$offset},{$limit}";
$entities = get_data($query, "entity_row_to_elggstar");
// present it
echo "<div class='contentWrapper'>";
echo "<h3 class='settings'>" . elgg_echo("profile_manager:members:searchresults:title") . "</h3>";
if ($count > 0) {
$nav = elgg_view('profile_manager/members/pagination', array('function_name' => "navigate_members_search", 'offset' => $offset, 'count' => $count, 'limit' => $limit));
示例14: elgg_echo
} else {
if (empty($objecttype)) {
$objecttype = 'object';
}
$itemtitle = 'item:' . $objecttype;
if (!empty($subtype)) {
$itemtitle .= ':' . $subtype;
}
$itemtitle = elgg_echo($itemtitle);
$title = sprintf(elgg_echo('advancedsearchtitle'), $itemtitle, $tag);
}
global $CONFIG;
$tagSearch = false;
if (strpos(current_page_url(), $CONFIG->wwwroot . 'tag') > -1 || strpos(current_page_url(), $CONFIG->wwwroot . 'search/?tag') > -1) {
$tagSearch = true;
}
if (!empty($tag)) {
$body = "";
$body .= elgg_view_title($title);
// elgg_view_title(sprintf(elgg_echo('searchtitle'),$tag));
//the custom search doesn't work with tag searching
if (!$tagSearch) {
$body .= trigger_plugin_hook('search', '', $tag, "");
}
$body .= elgg_view('search/startblurb', array('tag' => $tag));
$body .= list_entities_from_metadata($md_type, $tag, $objecttype, $subtype, $owner_guid_array, 10, false, false);
$body = elgg_view_layout('two_column_left_sidebar', '', $body);
}
if ($tagSearch) {
page_draw($title, $body);
}
示例15: get_input
<?php
$email = get_input('email');
$user = get_user_by_email($email);
if (is_array($user)) {
$user = $user[0];
}
if ($user) {
if ($user->validated) {
if (send_new_password_request($user->guid)) {
system_message(elgg_echo('user:password:resetreq:success'));
} else {
register_error(elgg_echo('user:password:resetreq:fail'));
}
} else {
if (!trigger_plugin_hook('unvalidated_requestnewpassword', 'user', array('entity' => $user))) {
// if plugins have not registered an action, the default action is to
// trigger the validation event again and assume that the validation
// event will display an appropriate message
trigger_elgg_event('validate', 'user', $user);
}
}
} else {
register_error(sprintf(elgg_echo('user:email:notfound'), $email));
}
forward();