Changeset 121
- Timestamp:
- 06/29/09 20:59:21 (14 months ago)
- Files:
-
- 2 modified
-
application/views/header.php (modified) (1 diff)
-
library/helpers/html.helper.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
application/views/header.php
r92 r121 10 10 <?php css('style.css')?> 11 11 12 <?php js(' jquery-1.3.2.min.js'); ?>12 <?php js('http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js'); ?> 13 13 14 14 <?php js('sh_main.js'); ?> -
library/helpers/html.helper.php
r99 r121 7 7 * @param array $attributes 8 8 */ 9 function href($url, $title, $attributes=array()) {9 function href($url, $title, $attributes=array()) { 10 10 global $config; 11 11 $attributeString = ''; 12 foreach($attributes as $attribute=>$value) {12 foreach($attributes as $attribute=>$value) { 13 13 $attributeString .= $attribute.'="'.$value.'"'; 14 14 } 15 if(strstr($url, 'http://') !== 0){15 if(strstr($url, 'http://') === 0 || strstr($url, 'https://')) { 16 16 $url = $config->base_url.$config->index_file.$url; 17 17 } … … 28 28 * @return str 29 29 */ 30 function docType($type = 'html_trans') {30 function docType($type = 'html_trans') { 31 31 $docType = ''; 32 if($type == 'xhtml_strict'){ 33 $docType = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 32 switch ($type) { 33 case 'xhtml_strict': 34 $docType = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 34 35 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; 35 } elseif ($type == 'xhtml_trans'){ 36 $docType = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 36 break; 37 case 'xhtml_trans': 38 $docType = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 37 39 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; 38 } elseif ($type == 'html_strict'){ 39 $docType = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 40 break; 41 case 'html_strict': 42 $docType = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 40 43 "http://www.w3.org/TR/html4/strict.dtd">'; 41 } elseif($type == 'html_trans') { 42 $docType = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 44 break; 45 case 'html_trans': 46 $docType = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 43 47 "http://www.w3.org/TR/html4/loose.dtd">'; 48 break; 49 default: 50 throw new Exception('Invalid doctype specified, it should be one of: xhtml_strict, xhtml_trans, html_strict, html_trans'); 51 break; 44 52 } 45 53 echo $docType; 46 54 } 47 55 48 function metaTag($attributes) {49 if(!is_array($attributes)) {56 function metaTag($attributes) { 57 if(!is_array($attributes)) { 50 58 throw new Exception('Attributes must be provided in array format'); 51 59 } 52 60 $attributeList = ' '; 53 foreach($attributes as $attribute=>$value) {61 foreach($attributes as $attribute=>$value) { 54 62 $attributeList .= sEscape::html($attribute) .'="'.sEscape::html($value).'" '; 55 63 } … … 62 70 * @return str 63 71 */ 64 function charset() {72 function charset() { 65 73 global $config; 66 74 $attributes = array( … … 73 81 /** 74 82 * Generate the css include string 75 * @param <type> $file 83 * @param str $file 84 * @param str 76 85 * @return <type> 77 86 */ 78 function css($file ){87 function css($file, $media=array('all')) { 79 88 global $config; 80 echo '<link rel="stylesheet" type="text/css" href="'.sEscape::html($config->base_url."public/css/$file").'" />'; 89 if(!is_array($media)) { 90 throw new Exception('media must be provided in array format'); 91 } 92 if(strpos($file, 'http://') === 0 || strpos($file, 'https://') === 0) { 93 $str = '<link rel="stylesheet" type="text/css" href="'.sEscape::html($file).'"'; 94 } else { 95 $str = '<link rel="stylesheet" type="text/css" href="'.sEscape::html($config->base_url.'public/css/'.$file).'"'; 96 } 97 $str .= ' media = "'.sEscape::html(implode(',', $media)).'" />'; 98 echo $str; 81 99 } 82 100 … … 86 104 * @return <type> 87 105 */ 88 function js($file) {106 function js($file) { 89 107 global $config; 90 echo '<script type="text/javascript" src="'.sEscape::html($config->base_url."public/js/$file").'" ></script>'; 108 if(strpos($file, 'http://') === 0 || strpos($file, 'https://') === 0) { 109 echo '<script type="text/javascript" src="'.sEscape::html($file).'" ></script>'; 110 } else { 111 echo '<script type="text/javascript" src="'.sEscape::html($config->base_url."public/js/$file").'" ></script>'; 112 } 91 113 }
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)