]> git.mjollnir.org Git - moodle.git/commitdiff
Support for a new CSS template, allowing you to use CSS in the other templates
authormoodler <moodler>
Wed, 29 Mar 2006 18:29:16 +0000 (18:29 +0000)
committermoodler <moodler>
Wed, 29 Mar 2006 18:29:16 +0000 (18:29 +0000)
mod/data/css.php [new file with mode: 0755]
mod/data/templates.php
mod/data/view.php

diff --git a/mod/data/css.php b/mod/data/css.php
new file mode 100755 (executable)
index 0000000..6e9cf07
--- /dev/null
@@ -0,0 +1,40 @@
+<?php  // $Id$
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// NOTICE OF COPYRIGHT                                                   //
+//                                                                       //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//          http://moodle.org                                            //
+//                                                                       //
+// Copyright (C) 2005 Martin Dougiamas  http://dougiamas.com             //
+//                                                                       //
+// This program is free software; you can redistribute it and/or modify  //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation; either version 2 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// This program is distributed in the hope that it will be useful,       //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details:                          //
+//                                                                       //
+//          http://www.gnu.org/copyleft/gpl.html                         //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+    $lifetime  = 600;                                   // Seconds to cache this stylesheet
+    $nomoodlecookie = true;                             // Cookies prevent caching, so don't use them
+
+    require_once('../../config.php');
+
+    $d = optional_param('d', 0, PARAM_INT);   // database id
+
+    if ($data = get_record('data', 'id', $d)) {
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
+        header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $lifetime) . ' GMT');
+        header('Cache-control: max_age = '. $lifetime);
+        header('Pragma: ');
+        header('Content-type: text/css');  // Correct MIME type
+
+        echo $data->csstemplate;
+    } 
index 56dc23a596790da8df4d4eeb457faed1fb4a02f6..7c3568f5016d16114c53786fae85ee9618f0424d 100755 (executable)
 
 /// Add the HTML editor(s).
     echo '<td>';
-    $usehtmleditor = can_use_html_editor();
+    $usehtmleditor = can_use_html_editor() && ($mode != 'csstemplate');
     if ($mode == 'listtemplate'){
         // Print the list template header.
         echo '<tr>';
index d5405f6c983fe2414e53e23b39998816bb484461..5d6a9f4f3a7db866a781ccff8583d0cbbb088b52 100755 (executable)
         }
     }
 
-/// RSS meta
-    $rssmeta = '';
+/// RSS and CSS meta
+    $meta = '';
     if (isset($CFG->enablerssfeeds) && isset($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
         $rsspath = rss_get_url($course->id, $USER->id, 'data', $data->id);
-        $rssmeta = '<link rel="alternate" type="application/rss+xml" ';
-        $rssmeta .= 'title ="'.$course->shortname.': %fullname%" href="'.$rsspath.'" />';
+        $meta .= '<link rel="alternate" type="application/rss+xml" ';
+        $meta .= 'title ="'.$course->shortname.': %fullname%" href="'.$rsspath.'" />';
+    }
+    if ($data->csstemplate) {
+        $meta .= '<link rel="stylesheet" type="text/css" href="'.$CFG->wwwroot.'/mod/data/css.php?d='.$data->id.'" /> ';
     }
     
 /// Print the page header
-    $PAGE->print_header($course->shortname.': %fullname%', '', $rssmeta);
+    $PAGE->print_header($course->shortname.': %fullname%', '', $meta);
     
     echo '<table id="layout-table"><tr>';