本文整理汇总了PHP中safe_require_plugin函数的典型用法代码示例。如果您正苦于以下问题:PHP safe_require_plugin函数的具体用法?PHP safe_require_plugin怎么用?PHP safe_require_plugin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了safe_require_plugin函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
global $USER, $THEME;
$configdata = $instance->get('configdata');
$desiredtypes = array();
foreach ($configdata as $k => $v) {
if (!empty($v) && $k != 'maxitems') {
$type = preg_replace('/[^a-z]+/', '', $k);
$desiredtypes[$type] = $type;
}
}
if ($USER->get('admin') && !empty($desiredtypes['adminmessages'])) {
unset($desiredtypes['adminmessages']);
$desiredtypes += get_column('activity_type', 'name', 'admin', 1);
}
$maxitems = isset($configdata['maxitems']) ? $configdata['maxitems'] : 5;
// check if multirecipientnotification plugin is active or if we proceed here
if (record_exists('module_installed', 'name', 'multirecipientnotification', 'active', '1') && safe_require_plugin('module', 'multirecipientnotification')) {
global $USER;
$userid = $USER->get('id');
$activitylist = activityblocklistin(join(',', $desiredtypes), $maxitems);
$records = $activitylist->records;
$showmore = $activitylist->count > $maxitems;
// use a different template
$smartytemplate = 'blocktype:inbox:inboxmr.tpl';
} else {
$records = array();
if ($desiredtypes) {
$sql = "\n SELECT n.id, n.subject, n.message, n.url, n.urltext, n.read, t.name AS type\n FROM {notification_internal_activity} n JOIN {activity_type} t ON n.type = t.id\n WHERE n.usr = ?\n AND t.name IN (" . join(',', array_map('db_quote', $desiredtypes)) . ")\n ORDER BY n.ctime DESC\n LIMIT ?;";
$records = get_records_sql_array($sql, array($USER->get('id'), $maxitems + 1));
}
// Hack to decide whether to show the More... link
if ($showmore = count($records) > $maxitems) {
unset($records[$maxitems]);
}
if ($records) {
foreach ($records as &$r) {
$r->message = format_notification_whitespace($r->message, $r->type);
}
}
$smartytemplate = 'blocktype:inbox:inbox.tpl';
}
if ($records) {
require_once 'activity.php';
foreach ($records as &$r) {
$section = empty($r->plugintype) ? 'activity' : "{$r->plugintype}.{$r->pluginname}";
$r->strtype = get_string('type' . $r->type, $section);
}
}
$smarty = smarty_core();
if ($showmore) {
$smarty->assign('morelink', self::get_link($instance) . '?type=' . implode(',', $desiredtypes));
}
$smarty->assign('blockid', 'blockinstance_' . $instance->get('id'));
$smarty->assign('items', $records);
return $smarty->fetch($smartytemplate);
}
示例2: get_all_blocktype_css
/**
* Returns a list of required css files.
*/
public function get_all_blocktype_css()
{
global $THEME;
$cssfiles = array();
$view_data = $this->get_row_datastructure();
foreach ($view_data as $row_data) {
foreach ($row_data as $column) {
foreach ($column['blockinstances'] as $blockinstance) {
$pluginname = $blockinstance->get('blocktype');
if (!safe_require_plugin('blocktype', $pluginname)) {
continue;
}
$artefactdir = '';
if ($blockinstance->get('artefactplugin') != '') {
$artefactdir = 'artefact/' . $blockinstance->get('artefactplugin') . '/';
}
$hrefs = $THEME->get_url('style/style.css', true, $artefactdir . 'blocktype/' . $pluginname);
$hrefs = array_reverse($hrefs);
foreach ($hrefs as $href) {
$cssfiles[] = '<link rel="stylesheet" type="text/css" href="' . append_version_number($href) . '">';
}
}
}
}
return array_unique($cssfiles);
}
示例3: get_search_plugins
function get_search_plugins()
{
$searchpluginoptions = array();
if ($searchplugins = plugins_installed('search')) {
foreach ($searchplugins as $plugin) {
safe_require_plugin('search', $plugin->name, 'lib.php');
if (!call_static_method(generate_class_name('search', $plugin->name), 'is_available_for_site_setting')) {
continue;
}
$searchpluginoptions[$plugin->name] = $plugin->name;
$config_path = get_config('docroot') . 'search/' . $plugin->name . '/version.php';
if (is_readable($config_path)) {
$config = new stdClass();
require_once $config_path;
if (isset($config->name)) {
$searchpluginoptions[$plugin->name] = $config->name;
}
}
}
}
return $searchpluginoptions;
}
示例4: right_nav
function right_nav()
{
global $USER, $THEME;
safe_require('notification', 'internal');
$unread = $USER->get('unread');
$menu = array('settings' => array('path' => 'settings', 'url' => 'account/index.php', 'title' => get_string('settings'), 'alt' => '', 'weight' => 10, 'iconclass' => 'cogs'), 'inbox' => array('path' => 'inbox', 'url' => 'account/activity/index.php', 'title' => get_string('inbox'), 'alt' => get_string('inbox'), 'count' => $unread, 'countclass' => 'unreadmessagecount', 'linkid' => 'mail', 'weight' => 20, 'iconclass' => 'envelope'), 'settings/account' => array('path' => 'settings/account', 'url' => 'account/index.php', 'title' => get_config('dropdownmenu') ? get_string('general') : get_string('account'), 'weight' => 10, 'iconclass' => 'user'), 'settings/notifications' => array('path' => 'settings/notifications', 'url' => 'account/activity/preferences/index.php', 'title' => get_string('notifications'), 'weight' => 30, 'iconclass' => 'flag'));
// enable plugins to augment the menu structure
foreach (array('artefact', 'interaction', 'module') as $plugintype) {
if ($plugins = plugins_installed($plugintype)) {
foreach ($plugins as &$plugin) {
if (safe_require_plugin($plugintype, $plugin->name)) {
$plugin_nav_menu = call_static_method(generate_class_name($plugintype, $plugin->name), 'right_nav_menu_items');
$menu = array_merge($menu, $plugin_nav_menu);
}
}
}
}
// local_right_nav_update allows sites to customise the menu by munging the $menu array.
if (function_exists('local_right_nav_update')) {
local_right_nav_update($menu);
}
$menu_structure = find_menu_children($menu, '');
return $menu_structure;
}
示例5: array
$plugins['blocktype'] = array();
foreach (plugin_types() as $plugin) {
// this has to happen first because of broken artefact/blocktype ordering
$plugins[$plugin] = array();
$plugins[$plugin]['installed'] = array();
$plugins[$plugin]['notinstalled'] = array();
}
foreach (array_keys($plugins) as $plugin) {
if (table_exists(new XMLDBTable($plugin . '_installed'))) {
if ($installed = plugins_installed($plugin, true)) {
foreach ($installed as $i) {
$key = $i->name;
if ($plugin == 'blocktype') {
$key = blocktype_single_to_namespaced($i->name, $i->artefactplugin);
}
if (!safe_require_plugin($plugin, $key)) {
continue;
}
$plugins[$plugin]['installed'][$key] = array('active' => $i->active, 'disableable' => call_static_method(generate_class_name($plugin, $key), 'can_be_disabled'));
if ($plugins[$plugin]['installed'][$key]['disableable'] || !$i->active) {
$plugins[$plugin]['installed'][$key]['activateform'] = activate_plugin_form($plugin, $i);
}
if ($plugin == 'artefact') {
$plugins[$plugin]['installed'][$key]['types'] = array();
safe_require('artefact', $key);
if ($types = call_static_method(generate_class_name('artefact', $i->name), 'get_artefact_types')) {
foreach ($types as $t) {
$classname = generate_artefact_class_name($t);
if ($collapseto = call_static_method($classname, 'collapse_config')) {
$plugins[$plugin]['installed'][$key]['types'][$collapseto] = true;
} else {
示例6: plugin_account_prefs_submit
/**
* Submit plugin account form values.
*
* @param Pieform $form
* @param array $values
* @return bool is page need to be refreshed
*/
function plugin_account_prefs_submit(Pieform $form, $values)
{
$reload = false;
$elements = array();
$installed = plugin_all_installed();
foreach ($installed as $i) {
if (!safe_require_plugin($i->plugintype, $i->name)) {
continue;
}
$reload = call_static_method(generate_class_name($i->plugintype, $i->name), 'accountprefs_submit', $form, $values) || $reload;
}
return $reload;
}
示例7: render_viewing
/**
* To render the html of a block for viewing
*
* @param boolean $exporting Indicate the rendering is for an export
* If we are doing an export we can't render the block to be loaded via ajax
* @return the rendered block
*/
public function render_viewing($exporting = false)
{
if (!safe_require_plugin('blocktype', $this->get('blocktype'))) {
return;
}
$smarty = smarty_core();
$classname = generate_class_name('blocktype', $this->get('blocktype'));
if (get_config('ajaxifyblocks') && call_static_method($classname, 'should_ajaxify') && $exporting === false) {
$content = '';
$smarty->assign('loadbyajax', true);
} else {
$smarty->assign('loadbyajax', false);
try {
$content = call_static_method($classname, 'render_instance', $this);
} catch (NotFoundException $e) {
// Whoops - where did the image go? There is possibly a bug
// somewhere else that meant that this blockinstance wasn't
// told that the image was previously deleted. But the block
// instance is not allowed to treat this as a failure
log_debug('Artefact not found when rendering a block instance. ' . 'There might be a bug with deleting artefacts of this type? ' . 'Original error follows:');
log_debug($e->getMessage());
$content = '';
}
}
$smarty->assign('id', $this->get('id'));
$smarty->assign('blocktype', $this->get('blocktype'));
// hide the title if required and no content is present
if (call_static_method($classname, 'hide_title_on_empty_content') && !trim($content)) {
return;
}
try {
$title = $this->get_title();
} catch (NotFoundException $e) {
log_debug('Cannot render block title. Original error follows: ' . $e->getMessage());
$title = get_string('notitle', 'view');
}
$smarty->assign('title', $title);
// If this block is for just one artefact, we set the title of the
// block to be a link to view more information about that artefact
$configdata = $this->get('configdata');
if (!empty($configdata['artefactid'])) {
if (call_static_method($classname, 'has_title_link')) {
$smarty->assign('viewartefacturl', get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $configdata['artefactid'] . '&view=' . $this->get('view') . '&block=' . $this->get('id'));
}
}
if (method_exists($classname, 'feed_url')) {
$smarty->assign('feedlink', call_static_method($classname, 'feed_url', $this));
}
$smarty->assign('link', call_static_method($classname, 'get_link', $this));
$smarty->assign('content', $content);
if (isset($configdata['retractable']) && $title) {
$smarty->assign('retractable', $configdata['retractable']);
if (isset($configdata['retractedonload'])) {
$smarty->assign('retractedonload', $configdata['retractedonload']);
}
}
return $smarty->fetch('view/blocktypecontainerviewing.tpl');
}
示例8: plugin_institution_prefs_submit
/**
* Submit plugin institution form values.
*
* @param Pieform $form
* @param array $values
* @param Institution $institution
* @return bool is page need to be refreshed
*/
function plugin_institution_prefs_submit(Pieform $form, $values, Institution $institution)
{
$elements = array();
$installed = plugin_all_installed();
foreach ($installed as $i) {
if (!safe_require_plugin($i->plugintype, $i->name)) {
continue;
}
call_static_method(generate_class_name($i->plugintype, $i->name), 'institutionprefs_submit', $form, $values, $institution);
}
}
示例9: main_nav
/**
* Builds a data structure representing the menu for Mahara.
*/
function main_nav()
{
if (in_admin_section()) {
global $USER, $SESSION;
if ($USER->get('admin')) {
$menu = admin_nav();
} else {
if ($USER->is_institutional_admin()) {
$menu = institutional_admin_nav();
} else {
if ($USER->get('staff')) {
$menu = staff_nav();
} else {
$menu = institutional_staff_nav();
}
}
}
} else {
// Build the menu structure for the site
// The keys of each entry are as follows:
// path: Where the link sits in the menu. E.g. 'myporfolio/myplugin'
// url: The URL to the page, relative to wwwroot. E.g. 'artefact/myplugin/'
// title: Translated text to use for the text of the link. E.g. get_string('myplugin', 'artefact.myplugin')
// weight: Where in the menu the item should be inserted. Larger number are to the right.
$menu = mahara_standard_nav();
}
$menu = array_filter($menu, create_function('$a', 'return empty($a["ignore"]);'));
if ($plugins = plugins_installed('artefact')) {
foreach ($plugins as &$plugin) {
if (safe_require_plugin('artefact', $plugin->name)) {
$plugin_menu = call_static_method(generate_class_name('artefact', $plugin->name), 'menu_items');
$menu = array_merge($menu, $plugin_menu);
}
}
}
if ($plugins = plugins_installed('interaction')) {
foreach ($plugins as &$plugin) {
if (safe_require_plugin('interaction', $plugin->name)) {
$plugin_menu = call_static_method(generate_class_name('interaction', $plugin->name), 'menu_items');
$menu = array_merge($menu, $plugin_menu);
}
}
}
// local_main_nav_update allows sites to customise the menu by munging the $menu array.
if (function_exists('local_main_nav_update')) {
local_main_nav_update($menu);
}
$menu_structure = find_menu_children($menu, '');
return $menu_structure;
}
示例10: main_nav
/**
* Builds a data structure representing the menu for Mahara.
*
* @return array
*/
function main_nav()
{
if (in_admin_section()) {
global $USER, $SESSION;
if ($USER->get('admin')) {
$menu = admin_nav();
} else {
if ($USER->is_institutional_admin()) {
$menu = institutional_admin_nav();
} else {
if ($USER->get('staff')) {
$menu = staff_nav();
} else {
$menu = institutional_staff_nav();
}
}
}
} else {
// Build the menu structure for the site
$menu = mahara_standard_nav();
}
$menu = array_filter($menu, create_function('$a', 'return empty($a["ignore"]);'));
// enable plugins to augment the menu structure
foreach (array('artefact', 'interaction', 'module') as $plugintype) {
if ($plugins = plugins_installed($plugintype)) {
foreach ($plugins as &$plugin) {
if (safe_require_plugin($plugintype, $plugin->name)) {
$plugin_menu = call_static_method(generate_class_name($plugintype, $plugin->name), 'menu_items');
$menu = array_merge($menu, $plugin_menu);
}
}
}
}
// local_main_nav_update allows sites to customise the menu by munging the $menu array.
if (function_exists('local_main_nav_update')) {
local_main_nav_update($menu);
}
$menu_structure = find_menu_children($menu, '');
return $menu_structure;
}
示例11: foreach
$SESSION->set('tablet', $isTablet);
} else {
$SESSION->set('handheld_device', false);
$SESSION->set('mobile', false);
$SESSION->set('tablet', false);
}
$SESSION->set('mobile_detection', true);
}
// Run modules bootstrap code.
if (!defined('INSTALLER')) {
// make sure the table exists if upgrading from older version
require_once 'ddl.php';
if (table_exists(new XMLDBTable('module_installed'))) {
if ($plugins = plugins_installed('module')) {
foreach ($plugins as &$plugin) {
if (safe_require_plugin('module', $plugin->name)) {
call_static_method(generate_class_name('module', $plugin->name), 'bootstrap');
}
}
}
}
}
/*
* Initializes our performance info early.
*
* Pairs up with get_performance_info() which is actually
* in lib/mahara.php. This function is here so that we can
* call it before all the libs are pulled in.
*
* @uses $PERF
*/
示例12: define
<?php
/**
*
* @package mahara
* @subpackage blocktype
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('INTERNAL', 1);
define('PUBLIC', 1);
require dirname(dirname(__FILE__)) . '/init.php';
require $CFG->docroot . '/blocktype/lib.php';
// Close the session to prevent session locking.
session_write_close();
$blockid = param_integer('blockid');
$block = new BlockInstance($blockid);
if (!can_view_view($block->get('view'))) {
throw new AccessDeniedException(get_string('accessdenied', 'error'));
}
safe_require_plugin('blocktype', $block->get('blocktype'));
echo call_static_method(generate_class_name('blocktype', $block->get('blocktype')), 'render_instance', $block);