[geeklog-hg] geeklog: Made template library function CTL_plugin_cssURL more g...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Wed Mar 4 13:28:41 EST 2015
changeset 9583:0a7e14b855f3
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/0a7e14b855f3
user: Tom
date: Wed Mar 04 13:28:10 2015 -0500
description:
Made template library function CTL_plugin_cssURL more generic so it can be used with Javascript if needed. Now called CTL_plugin_themebaseURL
diffstat:
plugins/calendar/functions.inc | 2 +-
plugins/polls/functions.inc | 2 +-
system/lib-template.php | 76 ++++++++++++++++++++++-------------------
3 files changed, 42 insertions(+), 38 deletions(-)
diffs (179 lines):
diff -r 5284e3ed8a31 -r 0a7e14b855f3 plugins/calendar/functions.inc
--- a/plugins/calendar/functions.inc Sat Feb 21 10:16:47 2015 -0500
+++ b/plugins/calendar/functions.inc Wed Mar 04 13:28:10 2015 -0500
@@ -671,7 +671,7 @@
// use the CSS only if we are on the plugin's pages
if (substr_count ($_SERVER['PHP_SELF'], '/calendar/') > 0) {
- $_SCRIPTS->setCSSFile('calendar', CTL_plugin_cssURL('calendar'), false);
+ $_SCRIPTS->setCSSFile('calendar', CTL_plugin_themebaseURL('calendar', 'css', 'style.css'), false);
}
}
diff -r 5284e3ed8a31 -r 0a7e14b855f3 plugins/polls/functions.inc
--- a/plugins/polls/functions.inc Sat Feb 21 10:16:47 2015 -0500
+++ b/plugins/polls/functions.inc Wed Mar 04 13:28:10 2015 -0500
@@ -1090,7 +1090,7 @@
// You normally only set the css file when needed but with the possibility of
// the poll block or autotag being displayed after COM_SiteHeader being called
// we need to set it just in case
- $_SCRIPTS->setCSSFile('polls', CTL_plugin_cssURL('polls'));
+ $_SCRIPTS->setCSSFile('polls', CTL_plugin_themebaseURL('polls', 'css', 'style.css'));
}
diff -r 5284e3ed8a31 -r 0a7e14b855f3 system/lib-template.php
--- a/system/lib-template.php Sat Feb 21 10:16:47 2015 -0500
+++ b/system/lib-template.php Wed Mar 04 13:28:10 2015 -0500
@@ -120,25 +120,25 @@
// See if plugin templates exist in current theme
if (empty($path)) {
- $retval[] = $_CONF['path_layout'] . $plugin;
+ $retval[] = "{$_CONF['path_layout']}$plugin";
} else {
- $retval[] = $_CONF['path_layout'] . $plugin . '/' . $path;
+ $retval[] = "{$_CONF['path_layout']}$plugin/$path";
}
// Now Check to see if default theme exists, if so add it to the mix
if (!empty($_CONF['theme_default'])) {
if (empty($path)) {
- $retval[] = $_CONF['path_layout_default'] . $plugin;
+ $retval[] = "{$_CONF['path_layout_default']}$plugin";
} else {
- $retval[] = $_CONF['path_layout_default'] . $plugin . '/' . $path;
+ $retval[] = "{$_CONF['path_layout_default']}$plugin/$path";
}
}
// See if current theme templates stored with plugin
if (empty($path)) {
- $layout_path = $_CONF['path'] . 'plugins/' . $plugin . '/templates/'. $_CONF['theme'];
+ $layout_path = "{$_CONF['path']}plugins/$plugin/templates/{$_CONF['theme']}";
} else {
- $layout_path = $_CONF['path'] . 'plugins/' . $plugin . '/templates/' . $_CONF['theme'] . '/' . $path;
+ $layout_path = "{$_CONF['path']}plugins/$plugin/templates/{$_CONF['theme']}/$path";
}
if (is_dir($layout_path)) {
@@ -148,9 +148,9 @@
// Now Check to see if default theme exists for templates stored with plugin
if (!empty($_CONF['theme_default'])) {
if (empty($path)) {
- $layout_path = $_CONF['path'] . 'plugins/' . $plugin . '/templates/'. $_CONF['theme_default'];
+ $layout_path = "{$_CONF['path']}plugins/$plugin/templates/{$_CONF['theme_default']}";
} else {
- $layout_path = $_CONF['path'] . 'plugins/' . $plugin . '/templates/' . $_CONF['theme_default'] . '/' . $path;
+ $layout_path = "{$_CONF['path']}plugins/$plugin/templates/{$_CONF['theme_default']}/$path";
}
if (is_dir($layout_path)) {
@@ -159,7 +159,7 @@
}
// Use default templates then
- $layout_path = $_CONF['path'] . 'plugins/' . $plugin . '/templates/default';
+ $layout_path = "{$_CONF['path']}plugins/$plugin/templates/default";
if (!empty($path)) {
$layout_path .= '/' . $path;
}
@@ -169,35 +169,37 @@
return $retval;
}
+
/**
-* Get HTML path for the plugin css file.
+* Get HTML path for a plugin file.
*
* @param string $plugin name of plugin
-* @param string $filename name of css file
-* @return string full HTML path to css file
+* @param string $directory name of directory
+* @param string $filename name of file
+* @return string full HTML path to file
*
*/
-function CTL_plugin_cssURL($plugin, $filename = "style.css")
+function CTL_plugin_themebaseURL($plugin, $directory, $filename)
{
global $_CONF;
// See if plugin css file exist in current theme
- $css_file = $_CONF['path_layout'] . $plugin . '/' . $filename;
- if (file_exists($css_file)) {
- $retval = $_CONF['layout_url'] . '/' . $plugin . '/' . $filename;
+ $file = "{$_CONF['path_layout']}$plugin/$filename";
+ if (file_exists($file)) {
+ $retval = "{$_CONF['layout_url']}/$plugin/$filename";
} else {
// See if current theme templates stored with plugin
- $css_file = $_CONF['path_html'] . '/' . $plugin . '/css/'. $_CONF['theme'] . '/' . $filename;
- if (file_exists($css_file)) {
- $retval = '/' . $plugin . '/css/'. $_CONF['theme'] . '/' . $filename;;
+ $file = "{$_CONF['path_html']}/$plugin/$directory/{$_CONF['theme']}/$filename";
+ if (file_exists($file)) {
+ $retval = "/$plugin/$directory/{$_CONF['theme']}/$filename";
} else {
- // Use default templates then. This should always exist = $_CONF['path_html'] . '/' . $plugin . '/css/default/' . $filename;
- $css_file = $_CONF['path_html'] . '/' . $plugin . '/css/default/' . $filename;
- if (file_exists($css_file)) {
- $retval = '/' . $plugin . '/css/default/' . $filename;
+ // Use default templates then. This should always exist
+ $file = "{$_CONF['path_html']}/$plugin/$directory/default/$filename";
+ if (file_exists($file)) {
+ $retval = "/$plugin/$directory/default/$filename";
} else {
- // Last guess for css file location
- $retval = '/' . $plugin . '/' . $filename;
+ // Last guess for file location
+ $retval = "/$plugin/$filename";
}
}
}
@@ -206,31 +208,33 @@
}
/**
-* Get HTML path for the plugin css file.
+* Get physical path or url for plugin directory that could be located either in
+* the theme layout directory or the plugins directory
*
* @param string $plugin name of plugin
-* @param string $filename name of css file
-* @return string full HTML path to css file
+* @param string $directory name of directory
+* @param boolean $return_url flag to return url
+* @return string url or physical path
*
*/
-function CTL_plugin_dirLocation($plugin, $path = "images", $return_url = true)
+function CTL_plugin_dirLocation($plugin, $directory = "images", $return_url = true)
{
global $_CONF;
// See if plugin image files exist in current theme
- $images_path = $_CONF['path_layout'] . $plugin . '/' . $path;
- if (is_dir($images_path)) {
+ $path = "{$_CONF['path_layout']}$plugin/$directory";
+ if (is_dir($path)) {
if ($return_url) {
- $retval = $_CONF['layout_url'] . '/' . $plugin . '/' . $path;
+ $retval = "{$_CONF['layout_url']}/$plugin/$directory";
} else {
- $retval = $images_path;
+ $retval = $path;
}
} else {
- // Use default location then. This should always exist : $images_path = $_CONF['path_html'] . '/' . $plugin . '/' . $path;
+ // Use default location then. This should always exist
if ($return_url) {
- $retval = $_CONF['site_url'] . '/' . $plugin . '/' . $path;
+ $retval = "{$_CONF['site_url']}/$plugin/$directory";
} else {
- $retval = $_CONF['path_html'] . '/' . $plugin . '/' . $path;
+ $retval = "{$_CONF['path_html']}/$plugin/$directory";
}
}
More information about the geeklog-cvs
mailing list