]> dev.renevier.net Git - syj.git/commitdiff
list of javascript files set in config
authorarno <arno@renevier.net>
Wed, 25 Aug 2010 20:11:34 +0000 (22:11 +0200)
committerarno <arno@renevier.net>
Wed, 25 Aug 2010 20:11:34 +0000 (22:11 +0200)
application/configs/medias.ini [new file with mode: 0644]
application/controllers/AccountController.php
application/controllers/ContactController.php
application/controllers/IdxController.php
application/controllers/ListController.php
application/controllers/LoginController.php
application/controllers/NewpwdController.php
application/controllers/helpers/SyjMedias.php [new file with mode: 0644]

diff --git a/application/configs/medias.ini b/application/configs/medias.ini
new file mode 100644 (file)
index 0000000..22a984a
--- /dev/null
@@ -0,0 +1,12 @@
+; This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+; and is published under the AGPL license. */
+[production]
+scripts.idx = OpenLayers, ModifiablePath, prototype, simplebox, utils, syj
+scripts.rawidx = OpenLayers, syjraw
+scripts.login = prototype, utils, login
+scripts.contact = prototype, utils, contact
+scripts.newpwd = prototype, utils, newpwd
+scripts.list = OpenLayers, prototype, utils, list
+scripts.account = prototype, utils, account
+
+[development:production]
index c9c986ecba33ff6741ae1526acfb6c5344f892b1..5f20cc73849b863932ed287f6a8676abaf044945 100644 (file)
@@ -7,10 +7,8 @@ class AccountController extends Zend_Controller_Action
 
     public function init() {
         $this->_helper->SyjSession->needsLogin();
+        $this->_helper->SyjMedias->addScripts('account');
 
-        $this->view->headScript()->appendFile('js/prototype.js');
-        $this->view->headScript()->appendFile('js/utils.js');
-        $this->view->headScript()->appendFile('js/account.js');
         $this->view->headLink()->appendStylesheet('css/generic.css', 'all');
         $this->view->headLink()->appendStylesheet('css/account.css', 'all');
         $this->view->headTitle($this->view->translate("my account"));
index 3e82c7dc8bff5f86d37e92f0a0fb7d66f2437ccb..9520a67227dc5c644f3c5a4570d5a28aa4ffbe4c 100644 (file)
@@ -6,9 +6,7 @@ class ContactController extends Zend_Controller_Action
 {
 
     public function init() {
-        $this->view->headScript()->appendFile('js/prototype.js');
-        $this->view->headScript()->appendFile('js/utils.js');
-        $this->view->headScript()->appendFile('js/contact.js');
+        $this->_helper->SyjMedias->addScripts('contact');
         $this->view->headLink()->appendStylesheet('css/generic.css', 'all');
         $this->view->headLink()->appendStylesheet('css/contact.css', 'all');
         $this->view->headTitle($this->view->translate("contact form"));
index 4f5fedd80c6e838be35724b8f6e265adfbcd7256..77153c11488bc8bff703c98cb92161e54ac3ff90 100644 (file)
@@ -6,12 +6,7 @@ class IdxController extends Zend_Controller_Action
 {
 
     public function init() {
-        $this->view->headScript()->appendFile('js/OpenLayers.js');
-        $this->view->headScript()->appendFile('js/ModifiablePath.js');
-        $this->view->headScript()->appendFile('js/prototype.js');
-        $this->view->headScript()->appendFile('js/simplebox.js');
-        $this->view->headScript()->appendFile('js/utils.js');
-        $this->view->headScript()->appendFile('js/syj.js');
+        $this->_helper->SyjMedias->addScripts('idx');
         $this->view->headLink()->appendStylesheet('css/openlayers/style.css', "all");
         $this->view->headLink()->appendStylesheet('css/generic.css', "all");
         $this->view->headLink()->appendStylesheet('css/syj.css', "all");
@@ -19,11 +14,10 @@ class IdxController extends Zend_Controller_Action
 
     public function rawmode(Syj_Model_Path $path) {
         $this->_helper->SyjReset->resetPlaceHolders();
+        $this->_helper->SyjMedias->addScripts('syjraw');
 
         $this->view->headLink()->appendStylesheet('css/generic.css', 'all');
         $this->view->headLink()->appendStylesheet('css/syjraw.css', 'all');
-        $this->view->headScript()->appendFile('js/OpenLayers.js');
-        $this->view->headScript()->appendFile('js/syjraw.js');
         $this->view->headTitle($path->displayTitle);
 
         $this->_jsRawLocaleStrings();
index c02f19cf93ee7f34e376b212e8f856bce7c05d7e..cda08aabe990236d020ffb0b9bce202d24ddcd8d 100644 (file)
@@ -8,10 +8,7 @@ class ListController extends Zend_Controller_Action
     public function init() {
         $this->_helper->SyjSession->needsLogin();
 
-        $this->view->headScript()->appendFile('js/OpenLayers.js');
-        $this->view->headScript()->appendFile('js/prototype.js');
-        $this->view->headScript()->appendFile('js/utils.js');
-        $this->view->headScript()->appendFile('js/list.js');
+        $this->_helper->SyjMedias->addScripts('list');
 
         $this->view->headLink()->appendStylesheet('css/generic.css', 'all');
         $this->view->headLink()->appendStylesheet('css/list.css', 'all');
index a6c7b46707130f7a98ab13d17358913346f55254..cb9543d8df7b2890c080aa170a7f4775f22c34c4 100644 (file)
@@ -6,9 +6,7 @@ class LoginController extends Zend_Controller_Action
 {
     public function init() {
         $this->view->headTitle($this->view->translate("login"));
-        $this->view->headScript()->appendFile('js/prototype.js');
-        $this->view->headScript()->appendFile('js/utils.js');
-        $this->view->headScript()->appendFile('js/login.js');
+        $this->_helper->SyjMedias->addScripts('login');
         $this->view->headLink()->appendStylesheet('css/generic.css', 'all');
         $this->view->headLink()->appendStylesheet('css/login.css', 'all');
     }
index de8ec3b644fcb9a242fc518fb253d94d411bbd41..dc9ff5d46a11d263bcb5e80ada45d94c8989b06e 100644 (file)
@@ -6,9 +6,7 @@ class NewpwdController extends Zend_Controller_Action
 {
 
     public function init() {
-        $this->view->headScript()->appendFile('js/prototype.js');
-        $this->view->headScript()->appendFile('js/newpwd.js');
-        $this->view->headScript()->appendFile('js/utils.js');
+        $this->_helper->SyjMedias->addScripts('newpwd');
         $this->view->headLink()->appendStylesheet('css/generic.css', 'all');
         $this->view->headLink()->appendStylesheet('css/newpwd.css', 'all');
     }
diff --git a/application/controllers/helpers/SyjMedias.php b/application/controllers/helpers/SyjMedias.php
new file mode 100644 (file)
index 0000000..a7e15a3
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Controller_Action_Helper_SyjMedias extends Zend_Controller_Action_Helper_Abstract
+{
+    protected $_config;
+
+    public function init() {
+        $this->_config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/medias.ini', APPLICATION_ENV);
+    }
+
+    public function addScripts($action) {
+        $view = $this->getActionController()->view;
+        if (APPLICATION_ENV == "production") {
+            $view->headScript()->appendFile('js/' . $action . '.js');
+            return;
+        }
+        $scripts = explode(',', $this->_config->get('scripts')->get($action));
+        foreach ($scripts as $name) {
+            $view->headScript()->appendFile('js/' . trim($name) . '.js');
+        }
+    }
+}