MkFramework
 All Data Structures Functions
class_view.php
1 <?php
2 /*
3 This file is part of Mkframework.
4 
5 Mkframework is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License.
8 
9 Mkframework is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13 
14 You should have received a copy of the GNU Lesser General Public License
15 along with Mkframework. If not, see <http://www.gnu.org/licenses/>.
16 
17 */
23 class _view{
24 
25  protected $_sModule;
26  protected $_sTpl;
27  protected $_tVar;
28  protected $_sPath;
29 
35  public function __construct($sRessource=null){
36 
37  $this->_tVar=array();
38 
39  /*LOG*/_root::getLog()->info('--vue: initialisation ['.$sRessource.']');
40  if($sRessource!=null){
41 
42  if(preg_match('/::/',$sRessource)){
43  list($this->_sModule,$this->_sTpl)=preg_split('/::/',$sRessource);
44  $sRessource=_root::getConfigVar('path.module').$this->_sModule.'/';
45  $sRessource.=_root::getConfigVar('path.view','tpl/').$this->_sTpl.'.php';
46  }
47 
48  $this->choose($sRessource);
49  }
50  }
51 
52  public function __set($sVar, $sVal){
53  /*LOG*/_root::getLog()->info('---vue: assignation ['.$sVar.']');
54  $this->_tVar[$sVar]=$sVal;
55  }
56  public function __get($sVar){
57  if(!array_key_exists($sVar,$this->_tVar)){
58  /*LOG*/_root::getLog()->error('Variable '.$sVar.' inexistante dans le template '.$this->_sModule.'::'.$this->_sTpl);
59  throw new Exception('Variable '.$sVar.' inexistante dans le template '.$this->_sModule.'::'.$this->_sTpl);
60  }else{
61  return $this->_tVar[$sVar];
62  }
63  }
67  public function __isset($sVar){
68  return isset($this->_tVar[$sVar]);
69  }
70 
74  public function __unset($sVar){
75  unset($this->_tVar[$sVar]);
76  }
82  public function show(){
83  /*LOG*/_root::getLog()->info('--vue: affichage ['.$this->_sPath.']');
84  ob_start();
85  include $this->_sPath;
86  $sSortie=ob_get_contents();
87  ob_end_clean();
88 
89  return $sSortie;
90  }
96  public function getPath(){
97  return $this->_sPath;
98  }
104  public function getLink($sLink,$tParam=null,$bAmp=true){
105  return _root::getLink($sLink,$tParam,$bAmp);
106  }
107 
108  protected function choose($sPath){
109  if(!file_exists($sPath) and !file_exists($sPath._root::getConfigVar('template.extension'))){
110  /*LOG*/_root::getLog()->error('vue '.$sPath.' et inexistant');
111  throw new Exception('vue '.$sPath.' et '.$sPath._root::getConfigVar('template.extension').' inexistant');
112  }
113  $this->_sPath=$sPath;
114  }
115 
116 
117 
118 }
__isset($sVar)
Definition: class_view.php:67
static getConfigVar($sCatAndVar, $uDefaut=null)
Definition: class_root.php:654
__unset($sVar)
Definition: class_view.php:74
static getLink($uNav, $tParam=null, $bAmp=true)
Definition: class_root.php:756
getPath()
Definition: class_view.php:96
__construct($sRessource=null)
Definition: class_view.php:35
getLink($sLink, $tParam=null, $bAmp=true)
Definition: class_view.php:104
static getLog()
Definition: class_root.php:610
show()
Definition: class_view.php:82