|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00031 function nonzero_process_css($css, $theme) { 00032 00033 00034 // Set the region-pre and region-post widths 00035 if (!empty($theme->settings->regionprewidth) && !empty($theme->settings->regionpostwidth)) { 00036 $regionprewidth = $theme->settings->regionprewidth; 00037 $regionpostwidth = $theme->settings->regionpostwidth; 00038 } else { 00039 $regionprewidth = null; 00040 $regionpostwidth = null; 00041 } 00042 $css = nonzero_set_regionwidths($css, $regionprewidth, $regionpostwidth); 00043 00044 00045 // Set the custom CSS 00046 if (!empty($theme->settings->customcss)) { 00047 $customcss = $theme->settings->customcss; 00048 } else { 00049 $customcss = null; 00050 } 00051 $css = nonzero_set_customcss($css, $customcss); 00052 00053 // Return the CSS 00054 return $css; 00055 } 00056 00065 function nonzero_set_regionwidths($css, $regionprewidth, $regionpostwidth) { 00066 $tag1 = '[[setting:regionprewidth]]'; 00067 $tag2 = '[[setting:regionpostwidth]]'; 00068 $tag3 = '[[setting:regionsumwidth]]'; 00069 $tag4 = '[[setting:regiondoublepresumwidth]]'; 00070 $replacement1 = $regionprewidth; 00071 $replacement2 = $regionpostwidth; 00072 if (is_null($replacement1) or is_null($replacement2)) { 00073 $replacement1 = 200; 00074 $replacement2 = 200; 00075 } 00076 $css = str_replace($tag1, $replacement1.'px', $css); 00077 $css = str_replace($tag2, $replacement2.'px', $css); 00078 $css = str_replace($tag3, ($replacement1+$replacement2).'px', $css); 00079 $css = str_replace($tag4, (2*$replacement1+$replacement2).'px', $css); 00080 return $css; 00081 } 00082 00083 00092 function nonzero_set_customcss($css, $customcss) { 00093 $tag = '[[setting:customcss]]'; 00094 $replacement = $customcss; 00095 if (is_null($replacement)) { 00096 $replacement = ''; 00097 } 00098 $css = str_replace($tag, $replacement, $css); 00099 return $css; 00100 }