[geeklog-cvs] geeklog: Added in new Plugin API PLG_getConfigTooltip to support...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Apr 10 13:29:06 EDT 2011
changeset 8220:7d316bccf75e
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/7d316bccf75e
user: Tom <websitemaster at cogeco.net>
date: Sun Apr 10 13:22:37 2011 -0400
description:
Added in new Plugin API PLG_getConfigTooltip to support tooltips in the Geeklog Configuration
diffstat:
plugins/calendar/functions.inc | 14 +++++++++++
plugins/links/functions.inc | 14 +++++++++++
plugins/polls/functions.inc | 14 +++++++++++
plugins/spamx/functions.inc | 14 +++++++++++
plugins/staticpages/functions.inc | 14 +++++++++++
system/classes/config.class.php | 49 +++++++++++++++++++++++---------------
system/lib-plugins.php | 25 +++++++++++++++++++
7 files changed, 125 insertions(+), 19 deletions(-)
diffs (241 lines):
diff -r 2069c8d573b3 -r 7d316bccf75e plugins/calendar/functions.inc
--- a/plugins/calendar/functions.inc Sun Apr 10 01:19:00 2011 +0100
+++ b/plugins/calendar/functions.inc Sun Apr 10 13:22:37 2011 -0400
@@ -2059,4 +2059,18 @@
return $retval;
}
+/**
+* Provides text for a Configuration tooltip
+*
+* @param string $id Id of config value
+* @return mixed Text to use regular tooltip, NULL to use config
+* tooltip hack, or empty string when not available
+*
+*/
+function plugin_getconfigtooltip_calendar($id)
+{
+ // Use config tooltip hack where tooltip is read from the config documentation
+ return;
+}
+
?>
diff -r 2069c8d573b3 -r 7d316bccf75e plugins/links/functions.inc
--- a/plugins/links/functions.inc Sun Apr 10 01:19:00 2011 +0100
+++ b/plugins/links/functions.inc Sun Apr 10 13:22:37 2011 -0400
@@ -1765,4 +1765,18 @@
return $retval;
}
+/**
+* Provides text for a Configuration tooltip
+*
+* @param string $id Id of config value
+* @return mixed Text to use regular tooltip, NULL to use config
+* tooltip hack, or empty string when not available
+*
+*/
+function plugin_getconfigtooltip_links($id)
+{
+ // Use config tooltip hack where tooltip is read from the config documentation
+ return;
+}
+
?>
diff -r 2069c8d573b3 -r 7d316bccf75e plugins/polls/functions.inc
--- a/plugins/polls/functions.inc Sun Apr 10 01:19:00 2011 +0100
+++ b/plugins/polls/functions.inc Sun Apr 10 13:22:37 2011 -0400
@@ -1420,6 +1420,20 @@
}
/**
+* Provides text for a Configuration tooltip
+*
+* @param string $id Id of config value
+* @return mixed Text to use regular tooltip, NULL to use config
+* tooltip hack, or empty string when not available
+*
+*/
+function plugin_getconfigtooltip_polls($id)
+{
+ // Use config tooltip hack where tooltip is read from the config documentation
+ return;
+}
+
+/**
* Provide URL and ID for the link to a comment's parent
*
* @return array array consisting of the base URL and the ID name
diff -r 2069c8d573b3 -r 7d316bccf75e plugins/spamx/functions.inc
--- a/plugins/spamx/functions.inc Sun Apr 10 01:19:00 2011 +0100
+++ b/plugins/spamx/functions.inc Sun Apr 10 13:22:37 2011 -0400
@@ -488,4 +488,18 @@
return $retval;
}
+/**
+* Provides text for a Configuration tooltip
+*
+* @param string $id Id of config value
+* @return mixed Text to use regular tooltip, NULL to use config
+* tooltip hack, or empty string when not available
+*
+*/
+function plugin_getconfigtooltip_spamx($id)
+{
+ // Use config tooltip hack where tooltip is read from the config documentation
+ return;
+}
+
?>
diff -r 2069c8d573b3 -r 7d316bccf75e plugins/staticpages/functions.inc
--- a/plugins/staticpages/functions.inc Sun Apr 10 01:19:00 2011 +0100
+++ b/plugins/staticpages/functions.inc Sun Apr 10 13:22:37 2011 -0400
@@ -1852,6 +1852,20 @@
}
/**
+* Provides text for a Configuration tooltip
+*
+* @param string $id Id of config value
+* @return mixed Text to use regular tooltip, NULL to use config
+* tooltip hack, or empty string when not available
+*
+*/
+function plugin_getconfigtooltip_staticpages($id)
+{
+ // Use config tooltip hack where tooltip is read from the config documentation
+ return;
+}
+
+/**
* Provide URL and ID for the link to a comment's parent
*
* NOTE: The Plugin API does not support $_CONF['url_rewrite'] here,
diff -r 2069c8d573b3 -r 7d316bccf75e system/classes/config.class.php
--- a/system/classes/config.class.php Sun Apr 10 01:19:00 2011 +0100
+++ b/system/classes/config.class.php Sun Apr 10 13:22:37 2011 -0400
@@ -1159,12 +1159,7 @@
$on = $name;
}
if (! is_numeric($on)) {
- $descUrl = $this->_get_ConfigHelp($group, $o);
- if (! empty($descUrl)) {
- $t->set_var('doc_url', $descUrl);
- $t->set_var('doc_link',
- '(<a href="' . $descUrl . '" target="help" class="tooltip">?</a>)');
- }
+ $this->_set_ConfigHelp($t, $group, $o);
}
}
if ($type == "unset") {
@@ -1752,25 +1747,27 @@
}
/**
- * Helper function: Get the URL to the help section for a config option
+ * Helper function: Set the URL to the help section for a config option
*
+ * @param string $t Template
* @param string $group 'Core' or plugin name
* @param string $option name of the config option
- * @return string full URL to help or empty string
*
*/
- function _get_ConfigHelp($group, $option)
+ function _set_ConfigHelp(&$t, $group, $option)
{
static $docUrl;
- if (! isset($docUrl)) {
+ if (!isset($docUrl)) {
$docUrl = array();
}
$retval = '';
- if (! isset($docUrl[$group])) {
+ $configtext = PLG_getConfigTooltip($group, $option);
+ if (empty($configtext)) {
if ($group == 'Core') {
+ $configtext = NULL;
if (!empty($GLOBALS['_CONF']['site_url']) &&
!empty($GLOBALS['_CONF']['path_html'])) {
$baseUrl = $GLOBALS['_CONF']['site_url'];
@@ -1785,19 +1782,33 @@
$url = 'http://www.geeklog.net/docs/english/config.html';
}
$docUrl['Core'] = $url;
- } else { // plugin
+ } else { // plugin
$docUrl[$group] = PLG_getDocumentationUrl($group, 'config');
}
- }
- $retval = $docUrl[$group];
+ $descUrl = $docUrl[$group];
- if (! empty($retval)) {
- if (strpos($retval, '#') === false) {
- $retval .= '#desc_' . $option;
- }
+ if (!empty($descUrl)) {
+ if (strpos($descUrl, '#') === false) {
+ $descUrl .= '#desc_' . $option;
+ }
+
+ $t->set_var('doc_url', $descUrl);
+
+ // Does hack need to be used?
+ if (gettype($configtext) == "NULL") {
+ $t->set_var('doc_link',
+ '(<a href="' . $descUrl . '" target="help" class="tooltip">?</a>)');
+ } else {
+ $t->set_var('doc_link',
+ '(<a href="' . $descUrl . '" target="help">?</a>)');
+ }
+ }
+ } else {
+ $t->set_var('doc_url', '');
+ $retval = "(" . COM_Tooltip("?", $configtext, '', $option,'information') . ")";
+ $t->set_var('doc_link', $retval);
}
- return $retval;
}
/**
diff -r 2069c8d573b3 -r 7d316bccf75e system/lib-plugins.php
--- a/system/lib-plugins.php Sun Apr 10 01:19:00 2011 +0100
+++ b/system/lib-plugins.php Sun Apr 10 13:22:37 2011 -0400
@@ -2716,6 +2716,31 @@
}
/**
+* Ask plugin for text for a Configuration tooltip
+*
+* @param string $group plugin name or 'Core'
+* @param string $id Id of config value
+* @return mixed Text to use regular tooltip, NULL to use config
+* tooltip hack, or empty string when not available
+* @link http://wiki.geeklog.net/index.php/PLG_getConfigTooltip
+* @since Geeklog 1.8.0
+*
+*/
+function PLG_getConfigTooltip($group, $id)
+{
+ if ($group == 'Core') {
+ $retval = false;
+ } else {
+ $args[1] = $id;
+ $function = 'plugin_getconfigtooltip_' . $group;
+
+ $retval = PLG_callFunctionForOnePlugin($function, $args);
+ }
+
+ return $retval;
+}
+
+/**
* Inform plugins when another plugin's state changed
*
* Unlike PLG_enableStateChange, this function is called after the state
More information about the geeklog-cvs
mailing list