1
0

make $serendipity['capabilities'][*] variables work

This commit is contained in:
Ian
2014-10-02 19:11:00 +02:00
parent 6313f50433
commit fbf821c714
2 changed files with 48 additions and 43 deletions

View File

@ -3,6 +3,8 @@
Version 2.0-beta4 / RC? () Version 2.0-beta4 / RC? ()
------------------------------------------------------------------------ ------------------------------------------------------------------------
* Change name and fix $serendipity['capabilities']['jquery_noConflictMode']
* Fix bug in entry listing, which showed wrong categories for * Fix bug in entry listing, which showed wrong categories for
entries (Issue #201) entries (Issue #201)
@ -97,7 +99,7 @@ Version 2.0-beta3 (July 25th, 2014)
to older plugins. to older plugins.
This mode is now considered deprecated and will be removed in This mode is now considered deprecated and will be removed in
future releases. A new variable: future releases. A new variable:
$serendipity['capabilities']['jquery-noconflict'] = false; $serendipity['capabilities']['jquery_noConflictMode'] = false;
in your theme's config.inc.php file can now turn of that in your theme's config.inc.php file can now turn of that
noConflict-mode. noConflict-mode.

View File

@ -1,4 +1,5 @@
<?php # $Id$ <?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details # All rights reserved. See LICENSE file for licensing details
@ -8,16 +9,18 @@ if (IN_serendipity !== true) {
include_once S9Y_INCLUDE_PATH . 'include/functions.inc.php'; include_once S9Y_INCLUDE_PATH . 'include/functions.inc.php';
/* Core API function mappings /* Core API function mappings
* This allows the s9y Core to also execute internal core actions on plugin API hooks * This allows the s9y Core to also execute internal core actions on plugin API hooks
* Future use: Global variable can be customized/overriden by your own plugin on the frontend_configure event * Future use: Global variable can be customized/overriden by your own plugin on the frontend_configure event
* or during runtime, * or during runtime, or the serendipity_config_local.inc.php file.
*/ */
$serendipity['capabilities']['jquery'] = true; if ( false !== $serendipity['capabilities']['jquery'])
$serendipity['capabilities']['jquery_backend'] = true; $serendipity['capabilities']['jquery'] = true;
$serendipity['capabilities']['jquery-noconflict'] = true; //set as being deprecated if ( false !== $serendipity['capabilities']['jquery_backend'])
$serendipity['capabilities']['jquery_backend'] = true;
if ( false !== $serendipity['capabilities']['jquery_noConflictMode'])
$serendipity['capabilities']['jquery_noConflictMode'] = true; //set as being deprecated, while we should not need it anymore
$serendipity['core_events']['frontend_header']['jquery'] = 'serendipity_plugin_api_frontend_header'; $serendipity['core_events']['frontend_header']['jquery'] = 'serendipity_plugin_api_frontend_header';
$serendipity['core_events']['backend_header']['jquery'] = 'serendipity_plugin_api_backend_header'; $serendipity['core_events']['backend_header']['jquery'] = 'serendipity_plugin_api_backend_header';
@ -28,13 +31,13 @@ function serendipity_plugin_api_frontend_header($event_name, &$bag, &$eventData,
// Only execute if current template does not have its own jquery.js file // Only execute if current template does not have its own jquery.js file
// jquery can be disabled if a template's config.inc.php or a plugin sets // jquery can be disabled if a template's config.inc.php or a plugin sets
// $serendipity['capabilities']['jquery'] = false // $serendipity['capabilities']['jquery'] = false
$check = serendipity_getTemplateFile('jquery.js'); $check = serendipity_getTemplateFile('jquery.js');
if (!$check && $serendipity['capabilities']['jquery']) { if (!$check && $serendipity['capabilities']['jquery']) {
?> ?>
<script src="<?php echo $serendipity['serendipityHTTPPath']; ?>templates/jquery.js"></script> <script src="<?php echo $serendipity['serendipityHTTPPath']; ?>templates/jquery.js"></script>
<?php <?php
if ($serendipity['capabilities']['jquery-noconflict']) { if ($serendipity['capabilities']['jquery_noConflictMode']) {
?> ?>
<script>jQuery.noConflict();</script> <script>jQuery.noConflict();</script>
<?php <?php
@ -81,7 +84,7 @@ function errorHandlerCreateDOM(htmlStr) {
} \n"; } \n";
} }
break; break;
case 'external_plugin': case 'external_plugin':
switch ($eventData) { switch ($eventData) {
case 'admin/serendipity_editor.js': case 'admin/serendipity_editor.js':
@ -122,7 +125,7 @@ function errorHandlerCreateDOM(htmlStr) {
* The user can configure instances of plugins. * The user can configure instances of plugins.
*/ */
class serendipity_plugin_api class serendipity_plugin_api
{ {
/** /**
@ -200,7 +203,7 @@ class serendipity_plugin_api
// Secure Plugin path. No leading slashes, no backslashes, no "up" directories // Secure Plugin path. No leading slashes, no backslashes, no "up" directories
$pluginPath = preg_replace('@^(/)@', '', $pluginPath); $pluginPath = preg_replace('@^(/)@', '', $pluginPath);
$pluginPath = str_replace(array('..', "\\"), array('', '/'), serendipity_db_escape_string($pluginPath)); $pluginPath = str_replace(array('..', "\\"), array('', '/'), serendipity_db_escape_string($pluginPath));
if ($pluginPath == 'online_repository') { if ($pluginPath == 'online_repository') {
$pluginPath = $key; $pluginPath = $key;
} }
@ -349,7 +352,7 @@ class serendipity_plugin_api
* @param string The maindir where we started searching from [for recursive use] * @param string The maindir where we started searching from [for recursive use]
* @return * @return
*/ */
static function traverse_plugin_dir($ppath, &$classes, $event_only, $maindir = '') static function traverse_plugin_dir($ppath, &$classes, $event_only, $maindir = '')
{ {
$d = @opendir($ppath); $d = @opendir($ppath);
if ($d) { if ($d) {
@ -419,7 +422,7 @@ class serendipity_plugin_api
* @param string The filter for plugins (left|right|hide|event|eventh) * @param string The filter for plugins (left|right|hide|event|eventh)
* @return array The list of plugins * @return array The list of plugins
*/ */
static function get_installed_plugins($filter = '*') static function get_installed_plugins($filter = '*')
{ {
$plugins = serendipity_plugin_api::enum_plugins($filter); $plugins = serendipity_plugin_api::enum_plugins($filter);
$res = array(); $res = array();
@ -518,7 +521,7 @@ class serendipity_plugin_api
* @param string If an instance ID is passed this means, the plugin to be loaded is internally available * @param string If an instance ID is passed this means, the plugin to be loaded is internally available
* @return string Returns the filename to include for a specific plugin * @return string Returns the filename to include for a specific plugin
*/ */
static function includePlugin($name, $pluginPath = '', $instance_id = '') static function includePlugin($name, $pluginPath = '', $instance_id = '')
{ {
global $serendipity; global $serendipity;
@ -551,7 +554,7 @@ class serendipity_plugin_api
* @param boolean If true, the plugin is a internal plugin (prefixed with '@') * @param boolean If true, the plugin is a internal plugin (prefixed with '@')
* @return string The classname of the plugin * @return string The classname of the plugin
*/ */
static function getClassByInstanceID($instance_id, &$is_internal) static function getClassByInstanceID($instance_id, &$is_internal)
{ {
$instance = explode(':', $instance_id); $instance = explode(':', $instance_id);
$class_name = ltrim($instance[0], '@'); $class_name = ltrim($instance[0], '@');
@ -568,7 +571,7 @@ class serendipity_plugin_api
* @return string Returns the filename of a plugin to load * @return string Returns the filename of a plugin to load
*/ */
/* Probes for the plugin filename */ /* Probes for the plugin filename */
static function probePlugin($instance_id, &$class_name, &$pluginPath) static function probePlugin($instance_id, &$class_name, &$pluginPath)
{ {
global $serendipity; global $serendipity;
@ -618,7 +621,7 @@ class serendipity_plugin_api
* @param string The filename of a plugin (can be autodetected) * @param string The filename of a plugin (can be autodetected)
* @return * @return
*/ */
static function &load_plugin($instance_id, $authorid = null, $pluginPath = '', $pluginFile = null) static function &load_plugin($instance_id, $authorid = null, $pluginPath = '', $pluginFile = null)
{ {
global $serendipity; global $serendipity;
@ -653,7 +656,7 @@ class serendipity_plugin_api
$p->serendipity_owner = $owner[0]; $p->serendipity_owner = $owner[0];
} }
} }
$p->pluginPath = $p->act_pluginPath = $pluginPath; $p->pluginPath = $p->act_pluginPath = $pluginPath;
if (empty($p->act_pluginPath)) { if (empty($p->act_pluginPath)) {
$p->act_pluginPath = $class_name; $p->act_pluginPath = $class_name;
@ -672,7 +675,7 @@ class serendipity_plugin_api
* @param type The type of the plugin (local|spartacus|...) * @param type The type of the plugin (local|spartacus|...)
* @return array Information about the plugin * @return array Information about the plugin
*/ */
static function &getPluginInfo(&$pluginFile, &$class_data, $type) static function &getPluginInfo(&$pluginFile, &$class_data, $type)
{ {
global $serendipity; global $serendipity;
@ -725,7 +728,7 @@ class serendipity_plugin_api
* @param string The location/type of a plugin (local|spartacus) * @param string The location/type of a plugin (local|spartacus)
* @return * @return
*/ */
static function &setPluginInfo(&$plugin, &$pluginFile, &$bag, &$class_data, $pluginlocation = 'local') static function &setPluginInfo(&$plugin, &$pluginFile, &$bag, &$class_data, $pluginlocation = 'local')
{ {
global $serendipity; global $serendipity;
@ -914,7 +917,7 @@ class serendipity_plugin_api
if (count($plugins) == 0) { if (count($plugins) == 0) {
$serendipity['prevent_sidebar_plugins_' . $side] = true; $serendipity['prevent_sidebar_plugins_' . $side] = true;
} }
$loggedin = false; $loggedin = false;
if (serendipity_userLoggedIn() && serendipity_checkPermission('adminPlugins')) { if (serendipity_userLoggedIn() && serendipity_checkPermission('adminPlugins')) {
$loggedin = true; $loggedin = true;
@ -931,7 +934,7 @@ class serendipity_plugin_api
$show_plugin = $plugin->generate_content($title); $show_plugin = $plugin->generate_content($title);
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
if ($loggedin) { if ($loggedin) {
$content .= '<div class="serendipity_edit_nugget"><a href="' . $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[adminModule]=plugins&amp;serendipity[plugin_to_conf]=' . htmlentities($plugin->instance) . '">' . EDIT . '</a></div>'; $content .= '<div class="serendipity_edit_nugget"><a href="' . $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[adminModule]=plugins&amp;serendipity[plugin_to_conf]=' . htmlentities($plugin->instance) . '">' . EDIT . '</a></div>';
} }
@ -1006,7 +1009,7 @@ class serendipity_plugin_api
* @param string Name of a plugin * @param string Name of a plugin
* @return boolean * @return boolean
*/ */
static function is_event_plugin($name) static function is_event_plugin($name)
{ {
return (strstr($name, '_event_')); return (strstr($name, '_event_'));
} }
@ -1019,7 +1022,7 @@ class serendipity_plugin_api
* @param boolean If set to true, the list of cached event plugins will be refreshed * @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 * @return mixed Either returns the whole list of event plugins, or only a specific instance
*/ */
static function &get_event_plugins($getInstance = false, $refresh = false) static function &get_event_plugins($getInstance = false, $refresh = false)
{ {
static $event_plugins; static $event_plugins;
static $false = false; static $false = false;
@ -1073,7 +1076,7 @@ class serendipity_plugin_api
* @param mixed May contain any type of variables that are passed to an event plugin * @param mixed May contain any type of variables that are passed to an event plugin
* @return true * @return true
*/ */
static function hook_event($event_name, &$eventData, $addData = null) static function hook_event($event_name, &$eventData, $addData = null)
{ {
global $serendipity; global $serendipity;
@ -1097,7 +1100,7 @@ class serendipity_plugin_api
$apifunc($event_name, $bag, $eventData, $addData); $apifunc($event_name, $bag, $eventData, $addData);
} }
} }
// execute backend needed core hooks // execute backend needed core hooks
serendipity_plugin_api_core_event_hook($event_name, $bag, $eventData, $addData); serendipity_plugin_api_core_event_hook($event_name, $bag, $eventData, $addData);
@ -1105,7 +1108,7 @@ class serendipity_plugin_api
$apifunc = 'serendipity_plugin_api_pre_event_hook'; $apifunc = 'serendipity_plugin_api_pre_event_hook';
$apifunc($event_name, $bag, $eventData, $addData); $apifunc($event_name, $bag, $eventData, $addData);
} }
// Function names cannot contain ":" etc, so if we ever have event looks like "backend:js" this // Function names cannot contain ":" etc, so if we ever have event looks like "backend:js" this
// needs to be replaced to "backend_js". The real event name is passed as a function argument // needs to be replaced to "backend_js". The real event name is passed as a function argument
// These specific per-hook functions are utilized for theme's config.inc.php files // These specific per-hook functions are utilized for theme's config.inc.php files
@ -1161,7 +1164,7 @@ class serendipity_plugin_api
* @param string A name (may contain wildcards) of a plugin class to check * @param string A name (may contain wildcards) of a plugin class to check
* @return boolean True if a plugin was found * @return boolean True if a plugin was found
*/ */
static function exists($instance_id) static function exists($instance_id)
{ {
global $serendipity; global $serendipity;
@ -1187,7 +1190,7 @@ class serendipity_plugin_api
* @param boolean Indicates if the plugin is an event plugin * @param boolean Indicates if the plugin is an event plugin
* @return object Returns the plugin object or false, if failure * @return object Returns the plugin object or false, if failure
*/ */
static function &autodetect_instance($plugin_name, $authorid, $is_event_plugin = false) static function &autodetect_instance($plugin_name, $authorid, $is_event_plugin = false)
{ {
if ($is_event_plugin) { if ($is_event_plugin) {
$side = 'event'; $side = 'event';
@ -1219,16 +1222,16 @@ class serendipity_plugin_api
if (file_exists($probelang)) { if (file_exists($probelang)) {
include $probelang; include $probelang;
} }
include $path . '/lang_en.inc.php'; include $path . '/lang_en.inc.php';
} }
} }
/** /**
* holds a bunch of properties; since serendipity 0.8 only one value per key is * holds a bunch of properties; since serendipity 0.8 only one value per key is
* allowed [was never really useful] * allowed [was never really useful]
*/ */
class serendipity_property_bag class serendipity_property_bag
{ {
/** /**
* @access private * @access private
@ -1282,9 +1285,9 @@ class serendipity_property_bag
} }
/** /**
* A core plugin, with methods that both event and sidebar plugins share * A core plugin, with methods that both event and sidebar plugins share
*/ */
class serendipity_plugin class serendipity_plugin
{ {
var $instance = null; var $instance = null;
var $protected = false; var $protected = false;
@ -1420,7 +1423,7 @@ class serendipity_plugin
* @param value The value of a config item * @param value The value of a config item
* @return * @return
*/ */
function validate($config_item, &$cbag, &$value) function validate($config_item, &$cbag, &$value)
{ {
static $pattern_mail = '([\.\-\+~@_0-9a-z]+?)'; static $pattern_mail = '([\.\-\+~@_0-9a-z]+?)';
static $pattern_url = '([@!=~\?:&;0-9a-z#\.\-_\/]+?)'; static $pattern_url = '([@!=~\?:&;0-9a-z#\.\-_\/]+?)';
@ -1655,7 +1658,7 @@ class serendipity_plugin
* Events can be called on several occasions when s9y performs an action. * Events can be called on several occasions when s9y performs an action.
* One or multiple plugin can be registered for each of those hooks. * One or multiple plugin can be registered for each of those hooks.
*/ */
class serendipity_event extends serendipity_plugin class serendipity_event extends serendipity_plugin
{ {
/** /**
@ -1685,7 +1688,7 @@ class serendipity_event extends serendipity_plugin
* @param array The entry superarray to get the reference from * @param array The entry superarray to get the reference from
* @return array The value of the array for the fieldname (reference) * @return array The value of the array for the fieldname (reference)
*/ */
function &getFieldReference($fieldname = 'body', &$eventData) function &getFieldReference($fieldname = 'body', &$eventData)
{ {
// Get a reference to a content field (body/extended) of // Get a reference to a content field (body/extended) of
// $entries input data. This is a unifying function because // $entries input data. This is a unifying function because
@ -1734,7 +1737,7 @@ class serendipity_event extends serendipity_plugin
* @param mixed Any additional data from the hook_event call * @param mixed Any additional data from the hook_event call
* @return true * @return true
*/ */
function event_hook($event, &$bag, &$eventData, $addData = null) function event_hook($event, &$bag, &$eventData, $addData = null)
{ {
// Define event hooks here, if you want you plugin to execute those instead of being a sidebar item. // Define event hooks here, if you want you plugin to execute those instead of being a sidebar item.
// Look at external plugins 'serendipity_event_mailer' or 'serendipity_event_weblogping' for usage. // Look at external plugins 'serendipity_event_mailer' or 'serendipity_event_weblogping' for usage.
@ -1748,4 +1751,4 @@ class serendipity_event extends serendipity_plugin
} }
/* vim: set sts=4 ts=4 expandtab : */ /* vim: set sts=4 ts=4 expandtab : */