[Fusionforge-commits] r10095 - in trunk: plugins/coclico/hudson/include src/common/include src/www/include

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Fri Jun 18 18:54:46 CEST 2010


Author: aljeux
Date: 2010-06-18 18:54:46 +0200 (Fri, 18 Jun 2010)
New Revision: 10095

Modified:
   trunk/plugins/coclico/hudson/include/hudsonPlugin.class.php
   trunk/src/common/include/utils.php
   trunk/src/www/include/Layout.class.php
Log:
New helper use_javascript() to allow configurable caching per theme.

Modified: trunk/plugins/coclico/hudson/include/hudsonPlugin.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/hudsonPlugin.class.php	2010-06-18 16:40:52 UTC (rev 10094)
+++ trunk/plugins/coclico/hudson/include/hudsonPlugin.class.php	2010-06-18 16:54:46 UTC (rev 10095)
@@ -166,19 +166,12 @@
 	}
 
 	function jsFile($params) {
-		// Only include the js files if we're actually in the IM pages.
-		// This stops styles inadvertently clashing with the main site.
-			echo '<script type="text/javascript" src="/scripts/prototype/prototype.js"></script>'."\n";
-			echo '<script type="text/javascript" src="/scripts/scriptaculous/scriptaculous.js"></script>'."\n";
-			echo '<script type="text/javascript" src="/scripts/codendi/Tooltip.js"></script>'."\n";
-			echo '<script type="text/javascript" src="/scripts/codendi/LayoutManager.js"></script>'."\n";
-			echo '<script type="text/javascript" src="/scripts/codendi/ReorderColumns.js"></script>'."\n";
-			echo '<script type="text/javascript" src="/scripts/codendi/codendi-1236793993.js"></script>'."\n";
-			echo '<script type="text/javascript" src="hudson_tab.js"></script>'."\n";
-		if (strpos($_SERVER['REQUEST_URI'], $this->getPluginPath()) === 0) {
-		//	echo '<script type="text/javascript" src="/scripts/codendi/cross_references.js"></script>'."\n";
-			echo '<script type="text/javascript" src="hudson_tab.js"></script>'."\n";
-		}
+		use_javascript('/scripts/prototype/prototype.js');
+		use_javascript('/scripts/scriptaculous/scriptaculous.js');
+		use_javascript('/scripts/codendi/Tooltip.js');
+		use_javascript('/scripts/codendi/LayoutManager.js');
+		use_javascript('/scripts/codendi/ReorderColumns.js');
+		use_javascript('/plugins/hudson/hudson_tab.js');
 	}
 
 	/**

Modified: trunk/src/common/include/utils.php
===================================================================
--- trunk/src/common/include/utils.php	2010-06-18 16:40:52 UTC (rev 10094)
+++ trunk/src/common/include/utils.php	2010-06-18 16:54:46 UTC (rev 10095)
@@ -1159,6 +1159,10 @@
 	return true;
 }
 
+function use_javascript($js) {
+	return $GLOBALS['HTML']->addJavascript($js);
+}
+
 // array_replace_recursive only appeared in PHP 5.3.0
 if (!function_exists('array_replace_recursive')) {
 	function array_replace_recursive ($a1, $a2) {

Modified: trunk/src/www/include/Layout.class.php
===================================================================
--- trunk/src/www/include/Layout.class.php	2010-06-18 16:40:52 UTC (rev 10094)
+++ trunk/src/www/include/Layout.class.php	2010-06-18 16:54:46 UTC (rev 10095)
@@ -191,6 +191,16 @@
 		$this->imgroot = $this->imgbaseurl;
 	}
 
+	function addJavascript($js) {
+		if (isset($this->js_min[$js])) {
+			$js = $this->js_min[$js];
+		}
+		if (!isset($this->js[$js])) {
+			$this->js[$js] = true;
+			echo '<script type="text/javascript" src="'.$js.'"></script>'."\n";
+		}
+	}
+
 	/** 
 	 * header() - generates the complete header of page by calling 
 	 * headerStart() and bodyHeader().




More information about the Fusionforge-commits mailing list