45 public function get($name) {
46 return isset($this->vars[$name]) ? $this->vars[$name] : null;
55 public function set($name, $value) {
56 $this->vars[$name] = $value;
65 public function setA(array $values) {
66 $this->vars = array_merge($this->vars, $values);
73 $this->vars = array();
83 public function fetch(array $prm=array()) {
85 $cachedContent =
false;
86 $cachedLayout =
false;
93 if ($this->cfg->cache[
'auto']) {
94 $cache =
cache::getInstance(array_merge(array(
'serialize'=>
false), $this->cfg->cache));
95 $cache->get($content, array(
96 'id'=>$this->cfg->module.
'-'.$this->cfg->action.
'-'.str_replace(
':',
'..', $this->cfg->param)
99 $cacheResp->get($callResp, array(
100 'id'=>$this->cfg->module.
'-'.$this->cfg->action.
'-'.str_replace(
':',
'..', $this->cfg->param).
'-callResp' 102 if (!empty($content)) {
103 $cachedContent =
true;
104 $cachedLayout = $this->cfg->cache[
'layout'];
105 if (!empty($callResp)) {
106 $this->responseProxy->doCalls($callResp);
107 $this->responseProxy->initCall();
112 if (!$cachedContent) {
114 $action = $this->cfg->action;
115 if (array_key_exists(
'callback', $prm))
116 $action = call_user_func($prm[
'callback'], $prm[
'callbackPrm']);
117 $file = $this->
findTpl($prm, array(
118 'module_'.$this->cfg->module.
'_view_'.$action,
119 'module_'.$this->cfg->defaultModule.
'_view_'.$this->cfg->default
123 $content = $this->
_fetch($file);
126 if ($this->cfg->layout && !$cachedLayout) {
128 $file = $this->
findTpl($prm, array(
129 'module_'.$this->cfg->module.
'_view_'.$this->cfg->action.
'Layout',
130 'module_'.$this->cfg->module.
'_view_layout' 133 $this->content = $content;
134 $content = $this->
_fetch($file);
136 if ($this->cfg->cache[
'auto'] && $this->cfg->cache[
'layout'])
140 if ($cacheResp && $this->responseProxy->hasCall()) {
141 $callResp = $this->responseProxy->getCall();
157 extract($this->vars, EXTR_REFS OR EXTR_OVERWRITE);
160 $contents = ob_get_contents();
172 protected function findTpl(array $prm, array $name) {
173 foreach($name as $n) {
174 if ($file =
file::nyroExists(array_merge($prm, array(
'name'=>$n,
'type'=>
'tpl'))))
189 if (!is_array($prm)){
190 $tmp = explode(
'/', $prm);
192 $prm[
'module'] = isset($tmp[0]) ? $tmp[0] : null;
193 $prm[
'action'] = isset($tmp[1]) ? $tmp[1] : null;
194 $prm[
'param'] = isset($tmp[2]) ? $tmp[2] : null;
196 $prm = array_merge(array(
'module'=>$this->cfg->module), $prm);
199 return $module->publish($prm);
209 return $this->
fetch();
220 return $this->
get($name);
230 public function __set($name, $val) {
231 $this->
set($name, $val);
static getModule($name, array $cfg=array(), &$scaffold=false, $allowScaffold=true)
static getInstance(array $cfg=array())
fetch(array $prm=array())
findTpl(array $prm, array $name)