Image.class.php (2523B)
1 <?php 2 3 namespace template_engine\components; 4 5 class ImageComponent extends Component 6 { 7 public $class; 8 public $menu; 9 public $action; 10 public $method; 11 public $config; 12 public $file; 13 public $url; 14 public $icon; 15 public $type; 16 public $elementtype; 17 public $fileext; 18 public $tree; 19 public $notice; 20 public $size; 21 public $title; 22 23 protected function begin() 24 { 25 $styleClass = ''; 26 $tagName = 'img'; 27 $file = ''; 28 $selfClosing = true; 29 30 if ( !empty($this->menu) ) 31 { 32 $tagName = 'i'; 33 $styleClass = 'image-icon image-icon--menu-'.$this->htmlvalue($this->menu); 34 $selfClosing = false; 35 } 36 elseif ( !empty($this->elementtype) ) 37 { 38 $tagName = 'i'; 39 $styleClass = 'image-icon image-icon--action-el_'.$this->htmlvalue($this->elementtype); 40 $selfClosing = false; 41 } 42 elseif ( !empty($this->action) ) 43 { 44 $tagName = 'i'; 45 $styleClass = 'image-icon image-icon--action-'.$this->htmlvalue($this->action); 46 $selfClosing = false; 47 } 48 elseif ( !empty($this->method) ) 49 { 50 $tagName = 'i'; 51 $styleClass = 'image-icon image-icon--method-'.$this->htmlvalue($this->method); 52 $selfClosing = false; 53 } 54 elseif ( !empty($this->type) ) 55 { 56 $file = OR_THEMES_DIR.'default/images/icon_'.$this->htmlvalue($this->type).IMG_ICON_EXT; 57 } 58 elseif ( !empty($this->icon) ) 59 { 60 $file = OR_THEMES_DIR.'default/images/icon/'.$this->htmlvalue($this->icon).IMG_ICON_EXT; 61 } 62 elseif ( !empty($this->notice) ) 63 { 64 $file = OR_THEMES_DIR.'default/images/notice_'.$this->htmlvalue($this->notice).IMG_ICON_EXT; 65 } 66 elseif ( !empty($this->tree) ) 67 { 68 $file = OR_THEMES_DIR.'default/images/tree_'.$this->htmlvalue($this->tree).IMG_EXT; 69 } 70 elseif ( !empty($this->url) ) 71 { 72 $file = $this->htmlvalue($this->url); 73 } 74 elseif ( !empty($this->fileext) ) 75 { 76 $file = OR_THEMES_DIR.'default/images/icon/'.$this->htmlvalue($this->fileext); 77 } 78 elseif ( !empty($this->file) ) 79 { 80 $file = OR_THEMES_DIR.'default/images/icon/'.$this->htmlvalue($this->file).IMG_ICON_EXT; 81 } 82 83 if ( !empty($this->class) ) 84 { 85 $styleClass .= ' '.$this->class; 86 } 87 88 89 echo '<'.$tagName.''; 90 91 if( $styleClass ) 92 echo ' class="'.$styleClass.'"'; 93 94 if($this->title) 95 echo ' title="'.$this->htmlvalue($this->title).'"'; 96 97 if ( $file) 98 echo ' src="'.$file.'"'; 99 100 if ( $selfClosing ) 101 echo ' />'; 102 else 103 echo '></'.$tagName.'>'; 104 } 105 106 protected function end() 107 { 108 } 109 } 110 111 ?>