本文整理汇总了PHP中serendipity_plugin_api::load_plugin方法的典型用法代码示例。如果您正苦于以下问题:PHP serendipity_plugin_api::load_plugin方法的具体用法?PHP serendipity_plugin_api::load_plugin怎么用?PHP serendipity_plugin_api::load_plugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类serendipity_plugin_api
的用法示例。
在下文中一共展示了serendipity_plugin_api::load_plugin方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show_plugins
/**
* Show the list of plugins
*
* Shows a HTML list of all installed plugins, complete with config/delete/sort order options
*
* @access public
* @param boolean Indicates if event plugins (TRUE) or sidebar plugins (FALSE) shall be shown
* @return null
*/
function show_plugins($event_only = false, $sidebars = null)
{
global $serendipity;
$sql_filter = '';
if (is_array($sidebars)) {
foreach ($sidebars as $sidebar) {
$up = strtoupper($sidebar);
if ($sidebar == 'hide') {
$opts[$sidebar] = HIDDEN;
} elseif (defined('SIDEBAR_' . $up)) {
$opts[$sidebar] = constant('SIDEBAR_' . $up);
} elseif (defined($up)) {
$opts[$sidebar] = constant($up);
} else {
$opts[$sidebar] = $up;
}
$sql_filter .= "AND placement != '" . serendipity_db_escape_string($sidebar) . "' ";
}
}
if (!$event_only) {
$sql = "SELECT * from {$serendipity['dbPrefix']}plugins\n WHERE placement != 'event'\n AND placement != 'eventh'\n " . $sql_filter;
$invisible_plugins = serendipity_db_query($sql);
if (is_array($invisible_plugins)) {
$sidebars[] = 'NONE';
$opts['NONE'] = NONE;
}
}
$opts['event'] = PLUGIN_ACTIVE;
$opts['eventh'] = PLUGIN_INACTIVE;
$data['event_only'] = $event_only;
if (!$event_only) {
$data['is_first'] = true;
}
$data['serendipity_setFormToken'] = serendipity_setFormToken();
$data['serendipity_setFormTokenUrl'] = serendipity_setFormToken('url');
/* Block display the plugins per placement location. */
if ($event_only) {
$plugin_placements = array('event', 'eventh');
} else {
$plugin_placements = $sidebars;
}
$data['plugin_placements'] = $plugin_placements;
static $users = array();
if (empty($users)) {
$users = serendipity_fetchUsers('', 'hidden');
}
$data['users'] = $users;
$i = 0;
foreach ($plugin_placements as $plugin_placement) {
if (!$event_only && $plugin_placement == 'NONE') {
$is_invisible = true;
} else {
$is_invisible = false;
}
$data['placement'][$plugin_placement]['ptitle'] = $ptitle = $opts[$plugin_placement];
$data['placement'][$plugin_placement]['pid'] = $pid = $plugin_placement;
if ($is_invisible) {
$plugins = $invisible_plugins;
} else {
$plugins = serendipity_plugin_api::enum_plugins($plugin_placement);
}
if (!is_array($plugins)) {
continue;
}
$sort_idx = 0;
foreach ($plugins as $plugin_data) {
$i++;
$plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid']);
$key = urlencode($plugin_data['name']);
$css_key = 's9ycid' . str_replace('%', '-', $key);
$is_plugin_owner = $plugin_data['authorid'] == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers');
$is_plugin_editable = $is_plugin_owner || $plugin_data['authorid'] == '0';
$cname = explode(':', $plugin_data['name']);
if (!is_object($plugin)) {
$name = $title = ERROR . '!';
$desc = ERROR . ': ' . $plugin_data['name'];
$can_configure = false;
} else {
/* query for its name, description and configuration data */
$bag = new serendipity_property_bag();
$plugin->introspect($bag);
$name = serendipity_specialchars($bag->get('name'));
$desc = '<details class="plugin_data">';
$desc .= '<summary><var class="perm_name">' . $cname[0] . '</var></summary>';
$desc .= '<div class="plugin_desc clearfix">' . serendipity_specialchars($bag->get('description')) . '</div>';
$desc .= '<span class="block_level">' . VERSION . ': ' . $bag->get('version') . '</span>';
$desc .= '</details>';
$title = serendipity_plugin_api::get_plugin_title($plugin, '[' . $name . ']');
if ($bag->is_set('configuration') && ($plugin->protected === FALSE || $plugin_data['authorid'] == '0' || $plugin_data['authorid'] == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers'))) {
$can_configure = true;
} else {
//.........这里部分代码省略.........
示例2: array
/**
* Prepares a cache of all event plugins and load them in queue so that they can be fetched
*
* @access public
* @param mixed If set to a string, a certain event plugin cache object will be returned by this function
* @param boolean If set to true, the list of cached event plugins will be refreshed
* @return mixed Either returns the whole list of event plugins, or only a specific instance
*/
function &get_event_plugins($getInstance = false, $refresh = false)
{
static $event_plugins;
static $false = false;
if (!$refresh && isset($event_plugins) && is_array($event_plugins)) {
if ($getInstance) {
if (isset($event_plugins[$getInstance]['p'])) {
return $event_plugins[$getInstance]['p'];
}
return $false;
}
return $event_plugins;
}
$plugins = serendipity_plugin_api::enum_plugins('event');
if (!is_array($plugins)) {
return $false;
}
$event_plugins = array();
foreach ($plugins as $plugin_data) {
if ($event_plugins[$plugin_data['name']]['p'] =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid'], $plugin_data['path'])) {
/* query for its name, description and configuration data */
$event_plugins[$plugin_data['name']]['b'] = new serendipity_property_bag();
$event_plugins[$plugin_data['name']]['p']->introspect($event_plugins[$plugin_data['name']]['b']);
$event_plugins[$plugin_data['name']]['t'] = serendipity_plugin_api::get_plugin_title($event_plugins[$plugin_data['name']]['p']);
} else {
unset($event_plugins[$plugin_data['name']]);
// Unset failed plugins
}
}
if ($getInstance) {
if (isset($event_plugins[$getInstance]['p'])) {
return $event_plugins[$getInstance]['p'];
}
return $false;
}
return $event_plugins;
}
示例3: foreach
$plugin->introspect($bag);
if ($bag->is_set('configuration')) {
/* Only play with the plugin if there is something to play with */
echo '<script type="text/javascript">location.href = \'' . $serendipity['baseurl'] . '?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $inst . '\';</script>';
die;
} else {
/* If no config is available, redirect to plugin overview, because we do not want that a user can install the plugin a second time via accidental browser refresh */
echo '<script type="text/javascript">location.href = \'' . $serendipity['baseurl'] . '?serendipity[adminModule]=plugins\';</script>';
die;
}
}
}
if (isset($_POST['REMOVE']) && serendipity_checkFormToken()) {
if (is_array($_POST['serendipity']['plugin_to_remove'])) {
foreach ($_POST['serendipity']['plugin_to_remove'] as $key) {
$plugin =& serendipity_plugin_api::load_plugin($key);
if ($plugin->serendipity_owner == '0' || $plugin->serendipity_owner == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers')) {
serendipity_plugin_api::remove_plugin_instance($key);
}
}
}
}
?>
<?php
if (isset($_POST['SAVE'])) {
?>
<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="<?php
echo serendipity_getTemplateFile('admin/img/admin_msg_success.png');
?>
" alt="" /><?php
示例4: show_plugins
//.........这里部分代码省略.........
<table class="pluginmanager" border="0" cellpadding="5" cellspacing="3" width="100%">
<tr>
<?php
$errors = array();
/* Block display the plugins per placement location. */
if ($event_only) {
$plugin_placements = array('event', 'eventh');
} else {
$plugin_placements = $sidebars;
}
$total = 0;
foreach ($plugin_placements as $plugin_placement) {
if (!$event_only && $plugin_placement == 'NONE') {
$is_invisible = true;
} else {
$is_invisible = false;
}
$ptitle = $opts[$plugin_placement];
$pid = $plugin_placement;
echo '<td class="pluginmanager_side pluginmanager_' . ($event_only ? 'event' : 'sidebar') . '">';
echo '<div class="heading">' . $ptitle . '</div>';
echo '<ol id="' . $pid . '_col" class="pluginmanager_container">';
if ($is_invisible) {
$plugins = $invisible_plugins;
} else {
$plugins = serendipity_plugin_api::enum_plugins($plugin_placement);
}
if (!is_array($plugins)) {
continue;
}
$sort_idx = 0;
foreach ($plugins as $plugin_data) {
$total++;
$plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid']);
$key = urlencode($plugin_data['name']);
$css_key = 's9ycid' . str_replace('%', '-', $key);
$is_plugin_owner = $plugin_data['authorid'] == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers');
$is_plugin_editable = $is_plugin_owner || $plugin_data['authorid'] == '0';
if (!is_object($plugin)) {
$name = $title = ERROR . '!';
$desc = ERROR . ': ' . $plugin_data['name'];
$can_configure = false;
} else {
/* query for its name, description and configuration data */
$bag = new serendipity_property_bag();
$plugin->introspect($bag);
$name = htmlspecialchars($bag->get('name'));
$desc = htmlspecialchars($bag->get('description'));
$desc .= '<br />' . VERSION . ': <em>' . $bag->get('version') . '</em>';
$title = serendipity_plugin_api::get_plugin_title($plugin, '[' . $name . ']');
if ($bag->is_set('configuration') && ($plugin->protected === FALSE || $plugin_data['authorid'] == '0' || $plugin_data['authorid'] == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers'))) {
$can_configure = true;
} else {
$can_configure = false;
}
}
if ($event_only) {
$place = placement_box('serendipity[placement][' . $plugin_data['name'] . ']', $plugin_data['placement'], $is_plugin_editable, true, $opts);
$event_only_uri = '&serendipity[event_plugin]=true';
} else {
$place = placement_box('serendipity[placement][' . $plugin_data['name'] . ']', $plugin_data['placement'], $is_plugin_editable, false, $opts);
$event_only_uri = '';
}
/* Only display UP/DOWN links if there's somewhere for the plugin to go */
if ($sort_idx == 0) {
$moveup = ' ';
示例5: admin_print_sidebar
function admin_print_sidebar(&$sidebar, $side, $plugin_list)
{
global $serendipity;
$i = 0;
$viewlist = unserialize($this->get_config('view_list'));
$category_viewlist = unserialize($this->get_config('category_view_list'));
$usergroups_viewlist = unserialize($this->get_config('usergroups_view_list'));
$mygroups = serendipity_getGroups($serendipity['authorid']);
$enabled = serendipity_db_bool($this->get_config('enable'));
foreach ($sidebar as $plugin_data) {
$plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid'], $plugin_data['path']);
if (is_object($plugin)) {
$checked = "";
$checked_member = "";
$checked_myself = "";
$checked_everyone = "";
if ($plugin_list[$side] && !$plugin_list[$side][$i]) {
$checked = "checked='checked'";
}
if ($viewlist[$plugin->instance] == 'member') {
$checked_member = "checked='checked'";
} elseif ($viewlist[$plugin->instance] == 'myself' || $viewlist[$plugin->instance] == $serendipity['authorid']) {
$checked_myself = "checked='checked'";
} elseif ($viewlist[$plugin->instance] == 'everyone') {
$checked_everyone = "checked='checked'";
} else {
$checked_everyone = "checked='checked'";
}
$title = '';
ob_start();
$show_plugin = $plugin->generate_content($title);
$content = ob_get_contents();
ob_end_clean();
if (empty($title)) {
$title = $plugin->get_config('backend_title');
}
echo "<div class='serendipitySideBarItem' style='margin-top:10px;margin-bottom:20px;'>\n";
echo "<h3 class='serendipitySideBarTitle'>{$title}</h3>\n";
echo "<div class='serendipitySideBarContent'><table>";
if ($enabled) {
echo "<tr>\n";
echo "<td>" . PLUGIN_SIDEBAR_HIDER_CONF_HIDDEN . "</td>\n";
echo "<td><input class='input_checkbox' type='checkbox' name='plugin_" . $side . "_" . $i . "' {$checked} /></td>\n";
echo "</tr>";
}
//--JAM: 2005-10-18 Added "everyone" value to clear members and myself values
echo "<tr>\n";
echo "<td>" . PLUGIN_SIDEBAR_HIDER_CONF_EVERYONE . "</td>\n";
echo "<td><input class='input_radio' type='radio' name='plugin_view[" . base64_encode($plugin->instance) . "]' value='everyone' {$checked_everyone} /></td>\n";
echo "</tr>";
echo "<tr>\n";
echo "<td>" . PLUGIN_SIDEBAR_HIDER_CONF_MEMBERS . "</td>\n";
echo "<td><input class='input_radio' type='radio' name='plugin_view[" . base64_encode($plugin->instance) . "]' value='member' {$checked_member} /></td>\n";
echo "</tr>";
echo "<tr>\n";
echo "<td>" . PLUGIN_SIDEBAR_HIDER_CONF_MYSELF . "</td>\n";
echo "<td><input class='input_radio' type='radio' name='plugin_view[" . base64_encode($plugin->instance) . "]' value='myself' {$checked_myself} /></td>\n";
echo "</tr>";
echo "<tr>\n";
echo "<td colspan='2'>" . GROUP . "<br >\n";
echo "<select name='plugin_usergroups_view[" . base64_encode($plugin->instance) . "][]' multiple='multiple'>\n";
$selected_groups = explode(',', $usergroups_viewlist[$plugin->instance]);
foreach ($mygroups as $group) {
if ('USERLEVEL_' == substr($group['confvalue'], 0, 10)) {
$group['name'] = constant($group['confvalue']);
}
?>
<option value="<?php
echo $group['id'];
?>
" <?php
echo in_array($group['id'], $selected_groups) ? 'selected="selected"' : '';
?>
><?php
echo function_exists('serendipity_specialchars') ? serendipity_specialchars($group['name']) : htmlspecialchars($group['name'], ENT_COMPAT, LANG_CHARSET);
?>
</option>
<?php
}
echo "</select></td>\n";
echo "</tr>";
echo "<tr>\n";
echo "<td colspan='2'>" . PLUGIN_SIDEBAR_HIDER_CONF_CATEGORIES . "<br />\n";
echo "\n";
$selected = explode(',', $category_viewlist[$plugin->instance]);
echo "<select name='plugin_category_view[" . base64_encode($plugin->instance) . "][]' multiple='multiple'>\n";
// --JAM: 2005-10-18: The front page selection goes on the top
echo '<option value="" ' . (in_array('', $selected) ? 'selected="selected"' : '') . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars(ALL_CATEGORIES) : htmlspecialchars(ALL_CATEGORIES, ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n";
echo '<option value="' . PLUGIN_SIDEBAR_HIDER_FRONTPAGE_ID . '" ' . (in_array(PLUGIN_SIDEBAR_HIDER_FRONTPAGE_ID, $selected) ? 'selected="selected"' : '') . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars(PLUGIN_SIDEBAR_HIDER_FRONTPAGE_DESC) : htmlspecialchars(PLUGIN_SIDEBAR_HIDER_FRONTPAGE_DESC, ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n";
// Now add regular categories to the selection list
$cats = serendipity_fetchCategories();
if (is_array($cats)) {
$cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
foreach ($cats as $cat) {
echo '<option value="' . $cat['categoryid'] . '" ' . (in_array($cat['categoryid'], $selected) ? 'selected="selected"' : '') . '>' . str_repeat(' ', $cat['depth']) . (function_exists('serendipity_specialchars') ? serendipity_specialchars($cat['category_name']) : htmlspecialchars($cat['category_name'], ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n";
}
}
echo "</select></td>\n";
echo "</tr>";
echo "</table></div>\n";
//.........这里部分代码省略.........
示例6: event_hook
function event_hook($event, &$bag, &$eventData, $addData = null)
{
global $serendipity;
$hooks =& $bag->get('event_hooks');
if (isset($hooks[$event])) {
switch ($event) {
case 'backend_sidebar_entries':
?>
<li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=mycalendar"><?php
echo PLUGIN_MYCALENDAR_TITLE;
?>
</a></li>
<?php
break;
case 'backend_sidebar_entries_event_display_mycalendar':
$this->showevents();
break;
case 'external_plugin':
if ($eventData == 'mycalendar.rss') {
$plugins = serendipity_plugin_api::enum_plugins('*', false, 'serendipity_plugin_mycalendar', null);
if (!is_array($plugins)) {
return;
}
foreach ($plugins as $plugin_data) {
$plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid'], $plugin_data['path']);
}
if (!is_object($plugin)) {
return;
}
$items = $plugin->generate_content($eventData, true);
header('Content-Type: text/xml; charset=UTF-8');
echo '<?xml version="1.0" encoding="utf-8" ?>' . "\n";
?>
<rss version="2.0"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:admin="http://webns.net/mvcb/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
>
<channel>
<title><?php
echo $serendipity['blogTitle'] . ' - ' . PLUGIN_MYCALENDAR_TITLE;
?>
</title>
<link><?php
echo $serendipity['baseURL'];
?>
</link>
<description><?php
echo PLUGIN_MYCALENDAR_SIDE_NAME;
?>
</description>
<generator>Serendipity - http://www.s9y.org/</generator>
<?php
foreach ($items as $item) {
?>
<item>
<title><?php
echo serendipity_utf8_encode(function_exists('serendipity_specialchars') ? serendipity_specialchars($item['title']) : htmlspecialchars($item['title'], ENT_COMPAT, LANG_CHARSET));
?>
</title>
<link><?php
echo serendipity_utf8_encode(function_exists('serendipity_specialchars') ? serendipity_specialchars($item['url']) : htmlspecialchars($item['url'], ENT_COMPAT, LANG_CHARSET));
?>
</link>
<author><?php
echo $serendipity['blogTitle'];
?>
</author>
<content:encoded>
<?php
echo serendipity_utf8_encode(function_exists('serendipity_specialchars') ? serendipity_specialchars($item['content']) : htmlspecialchars($item['content'], ENT_COMPAT, LANG_CHARSET));
?>
</content:encoded>
<pubDate><?php
echo $item['date'];
?>
</pubDate>
<guid isPermaLink="false"><?php
echo serendipity_utf8_encode(function_exists('serendipity_specialchars') ? serendipity_specialchars($item['url']) : htmlspecialchars($item['url'], ENT_COMPAT, LANG_CHARSET));
?>
</guid>
</item>
<?php
}
?>
</channel>
</rss>
<?php
}
break;
case 'frontend_calendar':
$this->get_month_events($eventData, $addData);
break;
}
}
return true;
}
示例7: list
list($aInfo) = serendipity_fetchAuthor((int) $serendipity['GET']['viewAuthor']);
$title = serendipity_utf8_encode(htmlspecialchars($aInfo['realname'] . ' - ' . $title));
} else {
$title = serendipity_utf8_encode(htmlspecialchars($title));
}
$description = serendipity_utf8_encode(htmlspecialchars($description));
$metadata = array('title' => $title, 'description' => $description, 'language' => $serendipity['lang'], 'additional_fields' => array(), 'link' => $serendipity['baseURL'], 'email' => $serendipity['blogMail'], 'fullFeed' => false, 'showMail' => false, 'version' => $version);
if (!defined('S9Y_FRAMEWORK_PLUGIN_API')) {
include S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php';
}
$plugins = serendipity_plugin_api::enum_plugins();
if (is_array($plugins)) {
// load each plugin to make some introspection
foreach ($plugins as $plugin_data) {
if (preg_match('|@serendipity_syndication_plugin|', $plugin_data['name'])) {
$plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid']);
$metadata['additional_fields'] = $plugin->generate_rss_fields($metadata['title'], $metadata['description'], $entries);
if (is_array($metadata['additional_fields'])) {
// Fix up array keys, because "." are not allowed when wanting to output using Smarty
foreach ($metadata['additional_fields'] as $_aid => $af) {
$aid = str_replace('.', '', $_aid);
$metadata['additional_fields'][$aid] = $af;
}
}
$metadata['fullFeed'] = $plugin->get_config('fullfeed', false);
if ($metadata['fullFeed'] === 'client') {
if ($_GET['fullFeed'] || $serendipity['GET']['fullFeed']) {
$metadata['fullFeed'] = true;
} else {
$metadata['fullFeed'] = false;
}
示例8: checkPlugin
function checkPlugin(&$data, &$plugins, $type)
{
$installable = true;
$upgradeLink = '';
if (in_array($data['class_name'], $plugins)) {
$infoplugin =& serendipity_plugin_api::load_plugin($data['class_name']);
if (is_object($infoplugin)) {
$bag = new serendipity_property_bag();
$infoplugin->introspect($bag);
if ($bag->get('version') == $data['version']) {
$installable = false;
} elseif (version_compare($bag->get('version'), $data['version'], '<')) {
$data['upgradable'] = true;
$data['upgrade_version'] = $data['version'];
$data['version'] = $bag->get('version');
$upgradeLink = '&serendipity[spartacus_upgrade]=true';
}
}
}
$data['installable'] = $installable;
$data['pluginPath'] = 'online_repository';
$data['pluginlocation'] = 'Spartacus';
$data['plugintype'] = $type;
$data['customURI'] = '&serendipity[spartacus_fetch]=' . $type . $upgradeLink;
return true;
}