]> dev.renevier.net Git - syj.git/blobdiff - application/controllers/helpers/SyjMedias.php
cache js, css and png files
[syj.git] / application / controllers / helpers / SyjMedias.php
index 4817535538761be31401949db533c465d417d9b5..49650846a47bc64f4bf73837666261f7da6eaab2 100644 (file)
@@ -13,7 +13,7 @@ class Syj_Controller_Action_Helper_SyjMedias extends Zend_Controller_Action_Help
     public function addScripts($action) {
         $view = $this->getActionController()->view;
         if (APPLICATION_ENV == "production") {
-            $view->headScript()->appendFile('js/' . $action . '.js');
+            $view->headScript()->appendFile('js/' . $action . '.js' . '?' . Syj_Version::VERSION);
             return;
         }
         $scripts = explode(',', $this->_config->get('scripts')->get($action));
@@ -21,4 +21,25 @@ class Syj_Controller_Action_Helper_SyjMedias extends Zend_Controller_Action_Help
             $view->headScript()->appendFile('js/' . trim($name) . '.js');
         }
     }
+
+    public function addStyleSheets($action) {
+        $view = $this->getActionController()->view;
+        if (APPLICATION_ENV == "production") {
+            $suffix = '?' . Syj_Version::VERSION;
+        } else {
+            $suffix = '';
+        }
+
+        $sheets = explode(',', $this->_config->get('css')->get($action));
+        foreach ($sheets as $sheet) {
+            $arr = explode(':', $sheet);
+            $arr = array_map('trim', $arr);
+            $href = 'css/' . $arr[0] . '.css' . $suffix;
+            $medias = array_slice($arr, 1);
+            if (!$medias) {
+                $medias = "all";
+            }
+            $view->headLink()->appendStylesheet($href, $medias);
+        }
+    }
 }