0/5 (1 avis)
Vue 5 331 fois - Téléchargée 680 fois
<?php ######################################################################################## ######################################################################################## ### ### IntyView class, permits to assign variables to a view (template) on MVC models. ### ### @name intyView ### @author Edoaurd Kombo <edouard.kombo@live.fr> ### ######################################################################################## ######################################################################################## class intyView { protected $_template; protected $_delimiter = '#'; function __construct(){} /////////////////////////////////////////// /////////////////////////////////////////// // PRIVATE FUNCTIONS /////////////////////////////////////////// /////////////////////////////////////////// private function get($file){ $this->_template = file_get_contents($file); //We open the file } private function assign($var , $content){ //We assign variables return $this->_template = str_replace($this->_delimiter.$var.$this->_delimiter , $content , $this->_template); } /////////////////////////////////////////// /////////////////////////////////////////// // PUBLIC FUNCTIONS /////////////////////////////////////////// /////////////////////////////////////////// function setDelimiter($delimiter){ //Symbol betwen html variables will be included in return $this->_delimiter = $delimiter; } function export($file , $args = null){ //Get the view for any import (by example mail) $this->get($file); if(is_array($args)){ $new_arr = array_keys($args); foreach($new_arr as $key => $val){ $this->assign($val , $args[$val]); } } return $this->_template; } function render($file , $args = null){ //Show the view when this method is called return eval('?>'.$this->export($file , $args).'<?'); } }
31 oct. 2012 à 11:04
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.