[geeklog-hg] geeklog: Fix for finding a plugin templates function.php file. I...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sun Dec 20 21:42:09 EST 2015


changeset 9662:7c6086497373
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/7c6086497373
user: Tom
date: Sun Dec 20 21:41:43 2015 -0500
description:
Fix for finding a plugin templates function.php file. It wouldn't find the functions in file if the template wasn't the current theme's name. Added checks for functions named after theme default and the default plugin template directory

diffstat:

 system/lib-template.php |  86 +++++++++++++++++++++++++++++-------------------
 1 files changed, 52 insertions(+), 34 deletions(-)

diffs (96 lines):

diff -r 4a7facc34561 -r 7c6086497373 system/lib-template.php
--- a/system/lib-template.php	Sun Dec 20 21:36:02 2015 -0500
+++ b/system/lib-template.php	Sun Dec 20 21:41:43 2015 -0500
@@ -310,40 +310,58 @@
 	$templateFuncutionsLocation = CTL_plugin_themeFindFile($plugin, 'templates', 'functions.php', false);
 	if (!empty($templateFuncutionsLocation) AND file_exists($templateFuncutionsLocation)) {
 		require_once $templateFuncutionsLocation;
-		
-		/* Include scripts on behalf of plugin template files that are theme specfic */
-		$func = $plugin . "_css_" . $_CONF['theme'];
-		if (function_exists($func)) {
-			foreach ($func() as $info) {
-				$file = (!empty($info['file'])) ? $info['file'] : '';
-				$name = (!empty($info['name'])) ? $info['name'] : md5(!empty($file) ? $file : strval(time()));
-				$constant   = (!empty($info['constant']))   ? $info['constant']   : true;
-				$attributes = (!empty($info['attributes'])) ? $info['attributes'] : array();
-				$priority = (!empty($info['priority']))   ? $info['priority']   : 100;
-				$_SCRIPTS->setCssFile($name, $file, $constant, $attributes, $priority, 'theme');
-			}
-		}
-		$func = $plugin . "_js_libs_" . $_CONF['theme'];
-		if (function_exists($func)) {
-			foreach ($func() as $info) {
-				$footer = true;
-				if (isset($info['footer']) && !$info['footer']) {
-					$footer = false;
-				}
-				$_SCRIPTS->setJavaScriptLibrary($info['library'], $footer);
-			}
-		}
-		$func = $plugin . "_js_files_" . $_CONF['theme'];
-		if (function_exists($func)) {
-			foreach ($func() as $info) {
-				$footer = true;
-				if (isset($info['footer']) && !$info['footer']) {
-					$footer = false;
-				}
-				$priority = (!empty($info['priority']))   ? $info['priority']   : 100;
-				$_SCRIPTS->setJavaScriptFile(md5($info['file']), $info['file'], $footer, $priority);
-			}
-		}    	
+
+        // Workaround since we don't know the theme name of the functions.php file we are using
+        // It would have been checked in the following order. When found then quit
+        $themes[] = $_CONF['theme'];
+        $themes[] = $_CONF['theme_default'];
+        $themes[] = 'default';
+        
+        $function_found = false;
+        foreach ($themes as $theme) {
+            /* Include scripts on behalf of plugin template files that are theme specific */
+            $func = $plugin . "_css_" . $theme;
+            if (function_exists($func)) {
+                $function_found = true;
+                foreach ($func() as $info) {
+                    $file = (!empty($info['file'])) ? $info['file'] : '';
+                    $name = (!empty($info['name'])) ? $info['name'] : md5(!empty($file) ? $file : strval(time()));
+                    $constant   = (!empty($info['constant']))   ? $info['constant']   : true;
+                    $attributes = (!empty($info['attributes'])) ? $info['attributes'] : array();
+                    $priority = (!empty($info['priority']))   ? $info['priority']   : 100;
+                    
+                    $_SCRIPTS->setCssFile($name, $file, $constant, $attributes, $priority, 'theme');
+                }
+            }
+            $func = $plugin . "_js_libs_" . $theme;
+            if (function_exists($func)) {
+                $function_found = true;
+                foreach ($func() as $info) {
+                    $footer = true;
+                    if (isset($info['footer']) && !$info['footer']) {
+                        $footer = false;
+                    }
+                    $_SCRIPTS->setJavaScriptLibrary($info['library'], $footer);
+                }
+            }
+            $func = $plugin . "_js_files_" . $theme;
+            if (function_exists($func)) {
+                $function_found = true;
+                foreach ($func() as $info) {
+                    $footer = true;
+                    if (isset($info['footer']) && !$info['footer']) {
+                        $footer = false;
+                    }
+                    $priority = (!empty($info['priority']))   ? $info['priority']   : 100;
+                    $_SCRIPTS->setJavaScriptFile(md5($info['file']), $info['file'], $footer, $priority);
+                }
+            }
+
+            if ($function_found) {
+                break;    
+            }
+            
+        }
 	}
 }
 



More information about the geeklog-cvs mailing list