本文整理汇总了PHP中serendipity_plugin_api::probePlugin方法的典型用法代码示例。如果您正苦于以下问题:PHP serendipity_plugin_api::probePlugin方法的具体用法?PHP serendipity_plugin_api::probePlugin怎么用?PHP serendipity_plugin_api::probePlugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类serendipity_plugin_api
的用法示例。
在下文中一共展示了serendipity_plugin_api::probePlugin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
</h2>
<?php
}
?>
<br />
<?php
$foreignPlugins = $pluginstack = $errorstack = array();
serendipity_plugin_api::hook_event('backend_plugins_fetchlist', $foreignPlugins);
$pluginstack = array_merge((array) $foreignPlugins['pluginstack'], $pluginstack);
$errorstack = array_merge((array) $foreignPlugins['errorstack'], $errorstack);
$plugins = serendipity_plugin_api::get_installed_plugins();
$classes = serendipity_plugin_api::enum_plugin_classes($serendipity['GET']['type'] === 'event');
usort($classes, 'serendipity_pluginListSort');
$counter = 0;
foreach ($classes as $class_data) {
$pluginFile = serendipity_plugin_api::probePlugin($class_data['name'], $class_data['classname'], $class_data['pluginPath']);
$plugin =& serendipity_plugin_api::getPluginInfo($pluginFile, $class_data, $serendipity['GET']['type']);
if (is_object($plugin)) {
// Object is returned when a plugin could not be cached.
$bag = new serendipity_property_bag();
$plugin->introspect($bag);
// If a foreign plugin is upgradable, keep the new version number.
if (isset($foreignPlugins['pluginstack'][$class_data['name']]) && $foreignPlugins['pluginstack'][$class_data['name']]['upgradable']) {
$class_data['upgrade_version'] = $foreignPlugins['pluginstack'][$class_data['name']]['upgrade_version'];
}
$props = serendipity_plugin_api::setPluginInfo($plugin, $pluginFile, $bag, $class_data, 'local', $foreignPlugins);
$counter++;
} elseif (is_array($plugin)) {
// Array is returned if a plugin could be fetched from info cache
$props = $plugin;
} else {
示例2: event_hook
function event_hook($event, &$bag, &$eventData, $addData = null)
{
global $serendipity;
$hooks =& $bag->get('event_hooks');
if (isset($hooks[$event])) {
switch ($event) {
case 'cronjob':
if ($this->get_config('cronjob') == $eventData) {
serendipity_event_cronjob::log('Spartacus', 'plugin');
$avail = array();
$install = array();
$meth = array('event', 'sidebar');
$active = serendipity_plugin_api::get_installed_plugins();
$avail['event'] = $this->buildList($this->fetchOnline('event'), 'event');
$avail['sidebar'] = $this->buildList($this->fetchOnline('sidebar'), 'sidebar');
#echo "XAVAIL:<pre>" . print_r($avail, true) . "</pre>";
$install['event'] = serendipity_plugin_api::enum_plugin_classes(true);
$install['sidebar'] = serendipity_plugin_api::enum_plugin_classes(false);
#echo "XINSTALL:<pre>" . print_r($install, true) . "</pre>";
$mailtext = '';
foreach ($meth as $method) {
foreach ($install[$method] as $class_data) {
#echo "Probe " . $class_data['name']. "<br />\n"; // DEBUG
$pluginFile = serendipity_plugin_api::probePlugin($class_data['name'], $class_data['classname'], $class_data['pluginPath']);
$plugin = serendipity_plugin_api::getPluginInfo($pluginFile, $class_data, $method);
if (is_object($plugin)) {
#echo "Non cached<br />\n";
#echo "<pre>" . print_r($avail[$method][$class_data['name']], true) . "</pre>";
// Object is returned when a plugin could not be cached.
$bag = new serendipity_property_bag();
$plugin->introspect($bag);
// If a foreign plugin is upgradable, keep the new version number.
if (isset($avail[$method][$class_data['name']])) {
$class_data['upgrade_version'] = $avail[$method][$class_data['name']]['upgrade_version'];
}
$props = serendipity_plugin_api::setPluginInfo($plugin, $pluginFile, $bag, $class_data, 'local', $avail[$method]);
#echo "<pre>" . print_r($props, true) . "</pre>";
} elseif (is_array($plugin)) {
// Array is returned if a plugin could be fetched from info cache
$props = $plugin;
#echo "Cached<br />\n";
} else {
$props = false;
#echo "Error<br />\n";
}
if (is_array($props)) {
#echo "<pre>" . print_r($props, true) . "</pre>\n";
if (version_compare($props['version'], $props['upgrade_version'], '<')) {
$mailtext .= ' * ' . $class_data['name'] . " NEW VERSION: " . $props['upgrade_version'] . " - CURRENT VERSION: " . $props['version'] . "\n";
}
} else {
$mailtext .= " X ERROR: " . $class_data['true_name'] . "\n";
}
}
}
if (!empty($mailtext)) {
serendipity_sendMail($serendipity['blogMail'], 'Spartacus update report ' . $serendipity['baseURL'], $mailtext, $serendipity['blogMail']);
echo nl2br($mailtext);
}
} else {
$propbag->add('type', 'suboption');
}
break;
case 'external_plugin':
if (!serendipity_db_bool($this->get_config('enable_remote'))) {
return false;
}
if ($eventData == $this->get_config('remote_url')) {
header('Content-Type: text/plain');
$avail = array();
$install = array();
$meth = array('event', 'sidebar');
$active = serendipity_plugin_api::get_installed_plugins();
$avail['event'] = $this->buildList($this->fetchOnline('event'), 'event');
$avail['sidebar'] = $this->buildList($this->fetchOnline('sidebar'), 'sidebar');
$install['event'] = serendipity_plugin_api::enum_plugin_classes(true);
$install['sidebar'] = serendipity_plugin_api::enum_plugin_classes(false);
foreach ($meth as $method) {
echo "LISTING: {$method}\n-------------------\n";
foreach ($install[$method] as $class_data) {
$pluginFile = serendipity_plugin_api::probePlugin($class_data['name'], $class_data['classname'], $class_data['pluginPath']);
$plugin = serendipity_plugin_api::getPluginInfo($pluginFile, $class_data, $method);
if (is_object($plugin)) {
// Object is returned when a plugin could not be cached.
$bag = new serendipity_property_bag();
$plugin->introspect($bag);
// If a foreign plugin is upgradable, keep the new version number.
if (isset($avail[$method][$class_data['name']])) {
$class_data['upgrade_version'] = $avail[$method][$class_data['name']]['upgrade_version'];
}
$props = serendipity_plugin_api::setPluginInfo($plugin, $pluginFile, $bag, $class_data, 'local', $avail[$method]);
} elseif (is_array($plugin)) {
// Array is returned if a plugin could be fetched from info cache
$props = $plugin;
} else {
$props = false;
}
if (is_array($props)) {
#print_r($props);
if (version_compare($props['version'], $props['upgrade_version'], '<')) {
//.........这里部分代码省略.........
示例3:
/**
* Instantiates a plugin class
*
* @access public
* @param string The ID of the plugin to load
* @param int The owner of the plugin (can be autodetected)
* @param string The path to a plugin (can be autodetected)
* @param string The filename of a plugin (can be autodetected)
* @return
*/
function &load_plugin($instance_id, $authorid = null, $pluginPath = '', $pluginFile = null)
{
global $serendipity;
if ($pluginFile === null) {
$class_name = '';
// $serendipity['debug']['pluginload'][] = "Init probe for plugin $instance_id, $class_name, $pluginPath";
$pluginFile = serendipity_plugin_api::probePlugin($instance_id, $class_name, $pluginPath);
} else {
$is_internal = false;
// $serendipity['debug']['pluginload'][] = "getClassByInstanceID $instance_id, $is_internal";
$class_name = serendipity_plugin_api::getClassByInstanceID($instance_id, $is_internal);
}
if (!class_exists($class_name) && !empty($pluginFile)) {
// $serendipity['debug']['pluginload'][] = "Classname does not exist. Including $pluginFile.";
include $pluginFile;
}
if (!class_exists($class_name)) {
$serendipity['debug']['pluginload'][] = "Classname {$class_name} still does not exist. Aborting.";
return false;
}
// $serendipity['debug']['pluginload'][] = "Returning new $class_name($instance_id)";
$p = new $class_name($instance_id);
if (!is_null($authorid)) {
$p->serendipity_owner = $authorid;
} else {
$sql = "SELECT authorid from {$serendipity['dbPrefix']}plugins WHERE name = '" . $instance_id . "'";
$owner = serendipity_db_query($sql, true);
if (is_array($owner) && isset($owner[0])) {
$p->serendipity_owner = $owner[0];
}
}
$p->pluginPath = $p->act_pluginPath = $pluginPath;
if (empty($p->act_pluginPath)) {
$p->act_pluginPath = $class_name;
}
$p->pluginFile = $pluginFile;
return $p;
}
示例4: event_hook
function event_hook($event, &$bag, &$eventData)
{
global $serendipity;
$hooks =& $bag->get('event_hooks');
if (isset($hooks[$event])) {
switch ($event) {
case 'external_plugin':
if (!serendipity_db_bool($this->get_config('enable_remote'))) {
return false;
}
if ($eventData == $this->get_config('remote_url')) {
header('Content-Type: text/plain');
$avail = array();
$install = array();
$meth = array('event', 'sidebar');
$active = serendipity_plugin_api::get_installed_plugins();
$avail['event'] = $this->buildList($this->fetchOnline('event'), 'event');
$avail['sidebar'] = $this->buildList($this->fetchOnline('sidebar'), 'sidebar');
$install['event'] = serendipity_plugin_api::enum_plugin_classes(true);
$install['sidebar'] = serendipity_plugin_api::enum_plugin_classes(false);
foreach ($meth as $method) {
echo "LISTING: {$method}\n-------------------\n";
foreach ($install[$method] as $class_data) {
$pluginFile = serendipity_plugin_api::probePlugin($class_data['name'], $class_data['classname'], $class_data['pluginPath']);
$plugin = serendipity_plugin_api::getPluginInfo($pluginFile, $class_data, $method);
if (is_object($plugin)) {
// Object is returned when a plugin could not be cached.
$bag = new serendipity_property_bag();
$plugin->introspect($bag);
// If a foreign plugin is upgradable, keep the new version number.
if (isset($avail[$method][$class_data['name']]) && $avail[$method][$class_data['name']]['upgradable']) {
$class_data['upgrade_version'] = $avail[$method][$class_data['name']]['upgrade_version'];
}
$props = serendipity_plugin_api::setPluginInfo($plugin, $pluginFile, $bag, $class_data, 'local', $avail[$method]);
} elseif (is_array($plugin)) {
// Array is returned if a plugin could be fetched from info cache
$props = $plugin;
} else {
$props = false;
}
if (is_array($props)) {
#print_r($props);
if (version_compare($props['version'], $props['upgrade_version'], '<')) {
echo "UPGRADE: " . $class_data['name'] . " -- " . $props['upgrade_version'] . "\n";
} else {
echo "OK: " . $class_data['name'] . " -- " . $props['version'] . "\n";
}
} else {
echo "ERROR: " . $class_data['true_name'] . "\n";
}
}
}
}
return true;
break;
case 'backend_pluginlisting_header':
if (serendipity_db_bool($this->get_config('enable_plugins'))) {
echo '<br /><div id="upgrade_notice" class="serendipityAdminMsgSuccess">';
echo '<a href="?serendipity[adminModule]=plugins&serendipity[adminAction]=addnew&serendipity[only_group]=UPGRADE" class="serendipityIconLink upgrade_sidebar"><img src="' . serendipity_getTemplateFile('admin/img/upgrade_now.png') . '" style="border: 0px none ; vertical-align: middle; display: inline;" alt="" />' . PLUGIN_EVENT_SPARTACUS_CHECK_SIDEBAR . '</a> ';
echo '<a href="?serendipity[adminModule]=plugins&serendipity[adminAction]=addnew&serendipity[only_group]=UPGRADE&serendipity[type]=event" class="serendipityIconLink upgrade_event"><img src="' . serendipity_getTemplateFile('admin/img/upgrade_now.png') . '" style="border: 0px none ; vertical-align: middle; display: inline;" alt="" />' . PLUGIN_EVENT_SPARTACUS_CHECK_EVENT . '</a> ';
echo '</div>';
}
return true;
break;
case 'backend_pluginlisting_header_upgrade':
echo '<em>' . PLUGIN_EVENT_SPARTACUS_CHECK_HINT . '</em><br />';
return true;
break;
case 'backend_templates_fetchlist':
if (serendipity_db_bool($this->get_config('enable_themes'))) {
$eventData = $this->buildTemplateList($this->fetchOnline('template', true), 'template');
}
return true;
break;
case 'backend_templates_fetchtemplate':
if (serendipity_db_bool($this->get_config('enable_themes'))) {
if (!empty($eventData['GET']['spartacus_fetch'])) {
$this->download($this->fetchOnline('template', true), $eventData['GET']['theme'], 'templates');
}
}
return false;
break;
case 'backend_plugins_fetchlist':
if (serendipity_db_bool($this->get_config('enable_plugins'))) {
$type = isset($serendipity['GET']['type']) && !empty($serendipity['GET']['type']) ? $serendipity['GET']['type'] : 'sidebar';
$eventData = array('pluginstack' => $this->buildList($this->fetchOnline($type), $type), 'errorstack' => array(), 'upgradeURI' => '&serendipity[spartacus_upgrade]=true', 'baseURI' => '&serendipity[spartacus_fetch]=' . $type);
}
return true;
break;
case 'backend_plugins_fetchplugin':
if (serendipity_db_bool($this->get_config('enable_plugins'))) {
if (!empty($eventData['GET']['spartacus_fetch'])) {
$baseDir = $this->download($this->fetchOnline($eventData['GET']['spartacus_fetch'], true), $eventData['GET']['install_plugin']);
if ($baseDir === false) {
$eventData['install'] = false;
} elseif (!empty($baseDir)) {
$eventData['GET']['pluginPath'] = $baseDir;
} else {
$eventData['GET']['pluginPath'] = $eventData['GET']['install_plugin'];
}
//.........这里部分代码省略.........