Changeset 1019

Show
Ignore:
Timestamp:
03/10/07 19:43:27 (2 years ago)
Author:
sven
Message:

fix get_list_of_plugins() requiring relative path (clashed with templatesroot), and attempt to split out and cache template CSS.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/_templates/css.php

    r296 r1019  
    55header("Content-type: text/css; charset=utf-8"); 
    66 
    7 $template_id = optional_param('template',0,PARAM_INT); 
     7$template_id = optional_param('template'); 
    88 
    9 echo templates_draw(array( 
     9// templates_draw() uses the global $template_name, not the 'template' array param, to choose a template 
     10$template_name = $template_id; 
     11 
     12$css = templates_draw(array( 
    1013                          'template' => $template_id, 
    1114                          'context' => 'css' 
    1215                          ) 
    1316                    ); 
    14                      
     17 
     18$etag = md5($css); 
     19 
     20header('Cache-Control: public'); 
     21header('Pragma: '); 
     22 
     23//header('Expires: '. gmdate('D, d M Y H:i:s', 0) .'GMT'); 
     24header('ETag: ' . $etag . ''); 
     25 
     26// Send 304s where possible, rather than spitting out the file each time 
     27if (array_key_exists('HTTP_IF_NONE_MATCH',$_SERVER)) { 
     28    $if_none_match = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_NONE_MATCH']); 
     29    if ($if_none_match == $etag) { 
     30        header("{$_SERVER['SERVER_PROTOCOL']} 304 Not Modified"); 
     31        exit; 
     32    } 
     33
     34 
     35echo $css; 
     36 
    1537?> 
  • devel/htaccess-dist

    r1018 r1019  
    4949#RewriteBase / 
    5050 
    51 RewriteRule ^([0-9\-]+)\.css$ _templates/css.php?template=$1 
     51RewriteRule ^_templates/css/(.+)$ _templates/css.php?template=$1 
    5252 
    5353RewriteRule ^(.+)\/rssstyles.xsl$ _rss/styles.php?rssurl=$1&url=$1 
  • devel/lib/elgglib.php

    r992 r1019  
    292292     
    293293    global $CFG; 
     294    if ($plugin == 'mod') { 
     295        $plugin = $CFG->dirroot . $plugin; 
     296    } 
    294297    static $plugincache = array(); 
    295298    $plugincachename = $plugin . "_" . $exclude; 
     
    299302    } else { 
    300303        $plugins = array(); 
    301         $basedir = opendir($CFG->dirroot . $plugin); 
    302         while (false !== ($dir = readdir($basedir))) { 
    303             $firstchar = substr($dir, 0, 1); 
    304             if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf' or $dir == $exclude) { 
    305                 continue; 
     304        if ($basedir = opendir($plugin)) { 
     305            while (false !== ($dir = readdir($basedir))) { 
     306                $firstchar = substr($dir, 0, 1); 
     307                if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf' or $dir == $exclude) { 
     308                    continue; 
     309                } 
     310                if (filetype($plugin .'/'. $dir) != 'dir') { 
     311                    continue; 
     312                } 
     313                $plugins[] = $dir; 
    306314            } 
    307             if (filetype($CFG->dirroot . $plugin .'/'. $dir) != 'dir') { 
    308                 continue; 
    309             } 
    310             $plugins[] = $dir; 
    311315        } 
    312316        if ($plugins) { 
  • devel/lib/templates.php

    r1017 r1019  
    13181318 
    13191319        case "metatags": 
    1320             // $run_result = "<link href=\"/".$template_variable.".css\" rel=\"stylesheet\" type=\"text/css\" />"; 
    1321             $result =  "<style type=\"text/css\">\n" 
    1322                 . templates_draw(array( 
    1323                                        'template' => $template_name, 
    1324                                        'context' => 'css' 
    1325                                        ) 
    1326                                  ) 
    1327                 . "\n</style>\n" 
     1320            $run_result = '<link href="' . $CFG->wwwroot  . '_templates/css/' . $template_name. '" rel="stylesheet" type="text/css" />' 
     1321//             $result =  $template_name . "<style type=\"text/css\">\n" 
     1322//                 . templates_draw(array( 
     1323//                                        'template' => $template_name, 
     1324//                                        'context' => 'css' 
     1325//                                        ) 
     1326//                                  ) 
     1327//                 . "\n</style>\n" 
    13281328                . $metatags; 
    13291329            break;