From 9cb924c9ef0b426f67c37ab203f412c59a250f52 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@afi-sa.fr>
Date: Sat, 20 Sep 2014 16:55:42 +0200
Subject: [PATCH] CSS editor: force loading of css mode in production

---
 library/Class/ScriptLoader.php | 57 +++++++++++++++++-----------------
 1 file changed, 29 insertions(+), 28 deletions(-)

diff --git a/library/Class/ScriptLoader.php b/library/Class/ScriptLoader.php
index 161408a64b0..2c3f7d609eb 100644
--- a/library/Class/ScriptLoader.php
+++ b/library/Class/ScriptLoader.php
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with AFI-OPAC 2.0; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
 
@@ -28,7 +28,7 @@ class Class_ScriptLoader {
 
 	protected static $instance;
 
-	protected 
+	protected
 		$_script_lines,
 		$_css_lines,
 		$_should_load_amber,
@@ -80,6 +80,7 @@ class Class_ScriptLoader {
 			$this
 				->addScript(AMBERURL.'src/js/lib/jQuery/jquery.textarea.js')
 				->addScript(AMBERURL.'src/js/lib/CodeMirror/codemirror.js')
+				->addScript(AMBERURL.'src/js/lib/CodeMirror/css.js')
 				->addStyleSheet(AMBERURL.'src/js/lib/CodeMirror/codemirror.css')
 				->addStyleSheet(AMBERURL.'src/js/lib/CodeMirror/amber.css')
 				->addStyleSheet(AMBERURL.'src/css/amber.css')
@@ -101,7 +102,7 @@ class Class_ScriptLoader {
 		$this->addScript(AMBERURL.'src/js/amber.js');
 
 		$deploy =  $this->isAmberModeDeploy();
-		
+
 		$amber_options = sprintf('{"home":"%s", "files":%s, "deploy":%s, "ready":%s}',
 														 AMBERURL.'src/',
 														 json_encode($this->_amberAdditionalFiles($deploy)),
@@ -218,14 +219,14 @@ class Class_ScriptLoader {
 		return $this;
 	}
 
-	
+
 	public function addJQueryBackEnd($js) {
 		if(Class_Users::getLoader()->isCurrentUserCanAccesBackend())
 			$this->addJQueryReady($js);
-		 
+
 		return $this;
 	}
-	
+
 
 	/**
 	 * @return ScriptLoader
@@ -320,9 +321,9 @@ class Class_ScriptLoader {
 		return $this
 			->loadNotificationJS()
 			->addJQueryReady(sprintf('showNotification(%s)',
-															 json_encode(array('message' => $message, 
-																								 'autoClose' => true, 
-																								 'duration' => 10, 
+															 json_encode(array('message' => $message,
+																								 'autoClose' => true,
+																								 'duration' => 10,
 																								 'type' => 'information'))));
 	}
 
@@ -352,12 +353,12 @@ class Class_ScriptLoader {
 			unset($attributes['ie_version']);
 		}
 
-		$attributes = array_merge(['type' => 'text/css', 
-															 'rel' => 'stylesheet', 
+		$attributes = array_merge(['type' => 'text/css',
+															 'rel' => 'stylesheet',
 															 'href' => $file,
 															 'media' => 'screen'],
 															$attributes);
-		
+
 		$html_attributes = '';
 		foreach($attributes as $name => $value)
 			$html_attributes .= sprintf(' %s="%s" ', $name, $value);
@@ -439,15 +440,15 @@ class Class_ScriptLoader {
 			$this->addAdminStyleSheet($file, $additional_attributes);
 		return $this;
 	}
-	
 
-	/** 
+
+	/**
 	 * @param $file string
 	 * @param $additional_attributes array
-	 * @return Class_ScriptLoader 
+	 * @return Class_ScriptLoader
 	 */
 	public function addOPACPluginStyleSheet($file, $additional_attributes=null) {
-		return $this->addStyleSheet(BASE_URL . '/public/opac/java/' . $file, 
+		return $this->addStyleSheet(BASE_URL . '/public/opac/java/' . $file,
 																$additional_attributes);
 	}
 
@@ -458,7 +459,7 @@ class Class_ScriptLoader {
 	 * @return Class_ScriptLoader
 	 */
 	public function addOPACPluginStyleSheets($files, $additional_attributes=null) {
-		foreach($files as $file) 
+		foreach($files as $file)
 			$this->addOPACPluginStyleSheet($file, $additional_attributes);
 		return $this;
 	}
@@ -494,7 +495,7 @@ class Class_ScriptLoader {
 
 	/**
 	 * @return ScriptLoader
-	 */	
+	 */
 	 public function _scriptsAddLine($line) {
 		 $this->_script_lines []= $line;
 		 return $this;
@@ -503,7 +504,7 @@ class Class_ScriptLoader {
 
 	/**
 	 * @return ScriptLoader
-	 */	
+	 */
 	 public function cssAddLine($line) {
 		 $this->_css_lines []= $line;
 		 return $this;
@@ -512,7 +513,7 @@ class Class_ScriptLoader {
 
 	/**
 	 * @return Boolean
-	 */	
+	 */
 	public function isAmberModeDeploy() {
 		if (null == $amber = Zend_Registry::get('cfg')->get('amber'))
 			return true;
@@ -525,7 +526,7 @@ class Class_ScriptLoader {
 
 	/**
 	 * @return Array
-	 */	
+	 */
 	public function &getAmberFiles() {
 		if (!isset($this->_amber_files)) {
 			$this->_amber_files = array('AFI-Core');
@@ -540,7 +541,7 @@ class Class_ScriptLoader {
 
 	/**
 	 * @return Array
-	 */	
+	 */
 	public function &getAmberReadyScripts() {
 		if (!isset($this->_amber_ready_scripts))
 			$this->_amber_ready_scripts = array(sprintf('smalltalk.Package._defaultCommitPathJs_("%s/admin/amber/commitJs")', BASE_URL),
@@ -553,7 +554,7 @@ class Class_ScriptLoader {
 	/**
 	 * @param String package
 	 * @return Class_ScriptLoader
-	 */	
+	 */
 	public function addAmberPackage($package) {
 		if (in_array($package, $this->getAmberFiles()))
 				return $this;
@@ -568,7 +569,7 @@ class Class_ScriptLoader {
 	/**
 	 * @param String js
 	 * @return Class_ScriptLoader
-	 */	
+	 */
 	public function addAmberReady($js) {
 		if (!in_array($js, $this->getAmberReadyScripts()))
 			array_push($this->getAmberReadyScripts(), $js);
@@ -578,14 +579,14 @@ class Class_ScriptLoader {
 
 	/**
 	 * @return Boolean
-	 */	
+	 */
 	protected function _amberAdditionalFiles($deploy) {
 		$additional_files = array();
 		foreach ($this->getAmberFiles() as $file) {
 			if ($deploy) $file .= '.deploy';
 			$additional_files []= sprintf('../../afi/js/%s.js', $file);
 		}
-		
+
 		return $additional_files;
 	}
 
@@ -632,7 +633,7 @@ class Class_ScriptLoader {
 
 		$template = $templates[$this->_jquery_ready_mode];
 
-		foreach ($this->_jquery_ready_scripts as $js) 
+		foreach ($this->_jquery_ready_scripts as $js)
 			$this->addInlineScript(sprintf($template, $js));
 
 		return $this;
@@ -695,7 +696,7 @@ class Class_ScriptLoader {
 	}
 
 
-	
+
 	protected function getVersionPergameHash() {
 		if (null == $this->_version_pergame_hash)
 			$this->_version_pergame_hash = md5(VERSION_PERGAME);
-- 
GitLab