[ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 // BTSv1.5d 3 unset($javascript,$content,$content_template,$boxLink,$box_id,$box_base_name); 4 // css_page_width is a sort of easter egg, it allows you to change the page with in pixels for the CSS template through the url 5 if (isset ($_GET['css_page_width'])) $css_page_width = strip_tags($_GET['css_page_width']); 6 7 $bts_debug = FALSE; 8 9 if(!defined('DIR_WS_TEMPLATES_DEFAULT')) define ('DIR_WS_TEMPLATES_DEFAULT',TEMPLATE_NAME_DEFAULT); // for JTS sql compatibity 10 define ('DIR_WS_TEMPLATES_BASE','templates/'); 11 12 $tplDir = bts_template_switch(); 13 14 define('DIR_WS_CONTENT', DIR_WS_TEMPLATES . 'content/'); 15 define('DIR_WS_JAVASCRIPT', DIR_WS_INCLUDES . 'javascript/'); 16 define('DIR_WS_BOX_TEMPLATES', DIR_WS_TEMPLATES . 'boxes/'); 17 // define the templatenames used in the project 18 define('TEMPLATENAME_BOX', 'box.tpl.php'); 19 define('TEMPLATENAME_MAIN_PAGE', 'main_page.tpl.php'); 20 define('TEMPLATENAME_POPUP', 'popup.tpl.php'); 21 define('TEMPLATENAME_STATIC', 'static.tpl.php'); 22 define('TEMPLATENAME_SHIPPING', 'shipping.tpl.php'); 23 define('TEMPLATENAME_CONDITIONS', 'conditions.tpl.php'); 24 define('TEMPLATENAME_PRIVACY', 'privacy.tpl.php'); 25 26 /* BTSv1.4 */ 27 define('DIR_WS_TEMPLATES_FALLBACK', 'templates/fallback/'); 28 define('DIR_WS_BOX_TEMPLATES_FALLBACK', DIR_WS_TEMPLATES_FALLBACK . 'boxes/'); 29 define('DIR_WS_CONTENT_FALLBACK', DIR_WS_TEMPLATES_FALLBACK . 'content/'); 30 31 // STS: ADD 32 if (is_file(DIR_WS_INCLUDES . 'configure_sts.php')) include(DIR_WS_INCLUDES . 'configure_sts.php'); 33 // STS: EOADD 34 35 function bts_select($template_type, $filename = '') { 36 // $content_template ?? 37 global $content_template, $content, $box_base_name; 38 39 switch ($template_type) { 40 41 case 'main': 42 // default or main_page 43 if(is_file(DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_PAGE)) { 44 $path = (DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_PAGE); 45 } else { 46 $path = (DIR_WS_TEMPLATES_FALLBACK . TEMPLATENAME_MAIN_PAGE); 47 } 48 break; 49 50 case 'content': 51 // pages or content (middle area) 52 // extra security: added basename() 53 if (isset($content_template)) { 54 if(is_file(DIR_WS_CONTENT . basename($content_template))) { $path = (DIR_WS_CONTENT . basename($content_template)); } elseif (is_file(DIR_WS_CONTENT_FALLBACK . basename($content_template))) { $path = (DIR_WS_CONTENT_FALLBACK . basename($content_template)); } 55 } else { 56 if(is_file(DIR_WS_CONTENT . basename($content . '.tpl.php'))) { $path = (DIR_WS_CONTENT . basename($content . '.tpl.php')); } else { $path = (DIR_WS_CONTENT_FALLBACK . $content . '.tpl.php'); } 57 } 58 break; 59 60 case 'boxes': 61 // small sideboxes 62 if(is_file(DIR_WS_BOX_TEMPLATES . $box_base_name . '.tpl.php')) { 63 // if exists, load unique box template for this box from templates/boxes/ 64 $path = (DIR_WS_BOX_TEMPLATES . $box_base_name . '.tpl.php'); 65 } elseif(is_file(DIR_WS_BOX_TEMPLATES_FALLBACK . $box_base_name . '.tpl.php')) { 66 // if exists, load unique box template for this box from templates/boxes/ 67 $path = (DIR_WS_BOX_TEMPLATES_FALLBACK . $box_base_name . '.tpl.php'); 68 } elseif(is_file(DIR_WS_BOX_TEMPLATES . TEMPLATENAME_BOX)) { 69 // if exists, load unique box template for this box from templates/boxes/ 70 $path = (DIR_WS_BOX_TEMPLATES . TEMPLATENAME_BOX); 71 } else { 72 $path = (DIR_WS_BOX_TEMPLATES_FALLBACK . TEMPLATENAME_BOX); 73 } 74 break; 75 76 case 'popup': 77 // popup main page (images/advanced search) 78 if(is_file(DIR_WS_TEMPLATES . TEMPLATENAME_POPUP)) { 79 $path = (DIR_WS_TEMPLATES . TEMPLATENAME_POPUP); 80 } else { 81 $path = (DIR_WS_TEMPLATES_FALLBACK . TEMPLATENAME_POPUP); 82 } 83 break; 84 85 case 'content_popup': 86 // popup pages or content (images/advanced search) 87 if(is_file(DIR_WS_CONTENT . basename($content) . '.tpl.php')) { 88 $path = (DIR_WS_CONTENT . basename($content) . '.tpl.php'); 89 } else { 90 $path = (DIR_WS_CONTENT_FALLBACK . basename($content) . '.tpl.php'); 91 } 92 break; 93 94 case 'javascript': 95 $path = ''; 96 break; 97 98 case 'stylesheet': 99 // $path = DIR_WS_TEMPLATE_FILES . $filename; 100 if(is_file(DIR_WS_TEMPLATES . $filename)) { 101 $path = DIR_WS_TEMPLATES . $filename; 102 } else { 103 $path = DIR_WS_TEMPLATES_FALLBACK . $filename; 104 } 105 break; 106 107 case 'stylesheets': 108 // for example to load different stylesheets per page :: new 109 if(is_file(DIR_WS_TEMPLATES . 'stylesheets/' . basename($filename, '.php') . '.css')) { 110 $path = DIR_WS_TEMPLATES . 'stylesheets/' . basename($filename, '.php') . '.css'; 111 } elseif (is_file(DIR_WS_TEMPLATES_FALLBACK . 'stylesheets/' . basename($filename, '.php') . '.css')) { 112 $path = DIR_WS_TEMPLATES_FALLBACK . 'stylesheets/' . basename($filename, '.php') . '.css'; 113 } else { 114 return (FALSE); 115 } 116 break; 117 118 case 'column': 119 // enables different columns per template function, falls back to (to fallback/ and then to) stock osC columns (inludes/) if no column templates are found 120 if(is_file(DIR_WS_TEMPLATES . $filename)) { 121 $path = DIR_WS_TEMPLATES . $filename; 122 } elseif (is_file(DIR_WS_TEMPLATES_FALLBACK . $filename)) { 123 $path = DIR_WS_TEMPLATES_FALLBACK . $filename; 124 } else { 125 $path = DIR_WS_INCLUDES . $filename; 126 } 127 break; 128 129 case 'images': 130 // added for loading images directly from your templates directory (w.o. the tep_image() function) 131 if (is_file(DIR_WS_TEMPLATES . 'images/' . $filename)) { 132 $path = DIR_WS_TEMPLATES .'images/' . $filename; 133 } else { 134 $path = DIR_WS_TEMPLATES_FALLBACK . 'images/' . $filename; 135 } 136 break; 137 138 case 'common': 139 if (is_file(DIR_WS_TEMPLATES_BASE . $filename)) { 140 $path = (DIR_WS_TEMPLATES_BASE . $filename); 141 } else { 142 return (FALSE); 143 } 144 break; 145 146 default: 147 // exit ('Error bts_select()! No template selected for template type: '); 148 echo ('Error: bts_select()! No template selected for template type: ' . $template_type); 149 break; 150 151 } 152 return ($path); 153 } 154 155 function bts_template_switch() { 156 if ((TEMPLATE_SWITCHING_ALLOWED == 'true') && (isset($_GET['tplDir'])) && is_dir(DIR_WS_TEMPLATES_BASE . basename($_GET['tplDir'])) ) { 157 $tplDir = basename($_GET['tplDir']); 158 tep_session_register('tplDir'); 159 } else { 160 if ((tep_session_is_registered('tplDir'))&&(TEMPLATE_SWITCHING_ALLOWED == 'true') && is_dir(DIR_WS_TEMPLATES_BASE . basename($_SESSION[tplDir]))){ 161 $tplDir = basename($_SESSION[tplDir]); 162 }else{ 163 $tplDir = DIR_WS_TEMPLATES_DEFAULT; 164 } 165 } 166 167 if ((ereg('^[[:alnum:]|_|-]+$', $tplDir)) && (is_dir (DIR_WS_TEMPLATES_BASE . $tplDir))){ 168 // 'Input Validated' only allow alfanumeric characters and underscores in template name 169 define('DIR_WS_TEMPLATES', DIR_WS_TEMPLATES_BASE . $tplDir . '/' ); 170 } else { 171 if($bts_debug === TRUE) echo strip_tags($tplDir) . '<br>'; 172 exit('Illegal template directory!'); 173 } 174 175 return $tplDir; 176 } 177 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |