瀏覽代碼

Add tempalte config for alternate stylesheets

stevetruckstuff 19 年之前
父節點
當前提交
f7f0248729
共有 2 個文件被更改,包括 36 次插入1 次删除
  1. 28 1
      class/template/Template.class.php
  2. 8 0
      templates/default/config.php

+ 28 - 1
class/template/Template.class.php

@@ -98,6 +98,15 @@ class Template
       */
     var $required_js_files = array();
 
+    /**
+     * Alternate stylesheets provided by the template.  This is defined in the
+     * template config file so that we can provide pretty names in the display
+     * preferences
+     * 
+     * @var array
+     **/
+    var $alternate_stylesehets = array();
+    
     /**
       * Constructor
       *
@@ -190,6 +199,9 @@ class Template
             require($template_config_file);
             $this->required_js_files = is_array($required_js_files) 
                                      ? $required_js_files : array();
+            $this->alternate_stylesheets = is_array($alternate_stylesheets) ?
+                                           $alternate_stylesheets :
+                                           array();
 
         }
 
@@ -470,7 +482,6 @@ class Template
         $files = list_files($directory, '.css', !$full_path);
 
         // need to leave out "rtl.css" 
-        //
         $return_array = array();
         foreach ($files as $file) {
 
@@ -486,6 +497,22 @@ class Template
 
     }
 
+    /**
+     * Return all alternate stylesheets provided by template.  These
+     * sheets are defined in the template config file so that we cna display
+     * pretty names in the Display Preferences.  The CSS files are located in
+     * $this->template_dir/css/alternatives/
+     * 
+     * @return array alternate style sheets
+     **/
+    function get_alternative_stylesheets () {
+        $a = array();
+        foreach ($this->alternate_stylesheets as $css) {
+            $a[] = strtolower(basename($css));
+        }
+        return $a;
+    }
+    
     /**
       * Generate links to all this template set's standard stylesheets
       *

+ 8 - 0
templates/default/config.php

@@ -26,4 +26,12 @@ $required_js_files = array  (
                                 'default.js',
                             );
 
+/**
+ * Alternate stylesheets provided by this template.  Format detailed below.
+ **/
+$alternate_stylesheets = array (
+                                    # CSS File         Stlye Name
+#                                   'example.css'   => 'My Example Style',
+                               );
+