openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

InsertComponent.class.php (806B)


      1 <?php
      2 
      3 namespace template_engine\components\html\component_insert;
      4 
      5 use template_engine\components\html\Component;
      6 use template_engine\element\CMSElement;
      7 
      8 class InsertComponent extends Component
      9 {
     10 	public $name;
     11 	public $url;
     12 	public $function;
     13 	
     14 	public function createElement()
     15 	{
     16 		if	( $this->function )
     17 		{
     18 			// JS-Function einbinden
     19 			$script = new CMSElement('script');
     20 			$script->addAttribute('type','text/javascript')->addAttribute('name','JavaScript');
     21 			$script->content( $this->function.'();' );
     22 
     23 			return $script;
     24 		}
     25 		elseif	( $this->url )
     26 		{
     27 			// IFrame
     28 			$iframe = new CMSElement('iframe');
     29 			if	( $this->name )
     30 				$iframe->addAttribute('name', $this->name);
     31 			if	( $this->url )
     32 				$iframe->addAttribute('src' ,$this->url);
     33 
     34 			return $iframe;
     35 		}
     36 		else
     37 			return null;
     38 	}
     39 }