45 $this->incFiles = array(
46 'js'=>array(
'nyro'=>array(),
'web'=>array(),
'nyroLast'=>array()),
47 'css'=>array(
'nyro'=>array(),
'web'=>array(),
'nyroLast'=>array())
49 if ($addDefaults && !empty($this->cfg->incFiles) && is_array($this->cfg->incFiles)) {
50 foreach($this->cfg->incFiles as $ic)
70 $this->
setMeta(
'title', $title);
99 $this->cfg->titleInDes = $titleInDes;
109 return $this->cfg->getInArray(
'meta', $name);
119 $this->cfg->setInArray(
'meta', $name, $value);
129 return $this->cfg->getInArray(
'metaProperty', $name);
139 $this->cfg->setInArray(
'metaProperty', $name, $value);
149 return $this->cfg->getInArray(
'link', $rel);
158 public function setLink($rel, array $attributes) {
159 $this->cfg->setInArray(
'link', $rel, $attributes);
171 $value.= $old? $sep.$old : null;
184 $value = $old? $old.$sep.$value : $value;
197 $value.= $old? $sep.$old : null;
210 $value = $old? $old.$sep.$value : $value;
220 if (!array_key_exists($type, $this->blocks))
221 $this->blocks[$type] = array();
233 public function add(array $prm) {
243 $firstFile = $prm[
'file'];
245 if (strpos($firstFile,
'jquery') === 0 && $firstFile !=
'jquery')
246 $this->addJS(
'jquery');
248 foreach($this->
getDepend($prm[
'file'], $prm[
'type']) as $d) {
250 $this->
add(array_merge($prm, $d));
252 $this->
add(array_merge($prm, array(
'file'=>$d)));
255 foreach($this->cfg->getInArray($prm[
'type'],
'alias') as $k=>$a) {
256 if (strtolower($prm[
'file']) == strtolower($k))
260 $prmType = $this->cfg->get($prm[
'type']);
262 $locDir = $prm[
'dir'];
263 if (!array_key_exists($locDir, $this->incFiles[$prm[
'type']]))
266 $fileExt = $prm[
'file'].
'.'.$prm[
'type'];
268 if ($prm[
'verifExists'])
269 $fileExists = $locDir ==
'web' 272 'name'=>
'module_'.
nyro::getCfg()->compressModule.
'_'.$prm[
'type'].
'_'.$prm[
'file'],
274 'tplExt'=>$prm[
'type']
280 if (!isset($this->incFiles[$prm[
'type']][$locDir][$prm[
'media']]))
281 $this->incFiles[$prm[
'type']][$locDir][$prm[
'media']] = array();
282 $this->incFiles[$prm[
'type']][$locDir][$prm[
'media']][$prm[
'file']] = $prm;
283 if ($prm[
'type'] ==
'css') {
285 preg_match_all(
'`@import (url\()?"(.+).css"\)?;`', $c, $matches);
286 if (!empty($matches[2])) {
287 $prefix = substr($prm[
'file'], 0, strpos($prm[
'file'],
'_')+1);
288 foreach($matches[2 ] as $m)
289 $this->
add(array_merge($prm, array(
'file'=>$prefix.$m)));
295 foreach($this->
getDepend($firstFile, $prm[
'type'],
true) as $d) {
297 $this->
add(array_merge($prm, $d));
299 $this->
add(array_merge($prm, array(
'file'=>$d)));
304 throw new nException(
'reponse::add: parameters file and/or type not provied');
323 public function getDepend($file, $type =
'js', $after =
false) {
326 $depend = $this->cfg->getInArray($type,
'depend'.($after?
'After' : null));
327 if (is_array($depend) && array_key_exists($file, $depend)) {
328 if (is_array($depend[$file]))
329 $ret = $depend[$file];
331 $ret = array($depend[$file]);
349 return $this->
add(array_merge($prm, array(
'type'=>
'js')));
351 return $this->
add(array(
'file'=>$prm,
'type'=>
'js'));
368 return $this->
add(array_merge($prm, array(
'type'=>
'css')));
370 return $this->
add(array(
'file'=>$prm,
'type'=>
'css'));
381 public function block($block, $type =
'js', $first =
false) {
385 array_unshift($this->blocks[$type], $block);
387 $this->blocks[$type][] = $block;
400 public function blockJs($block, $first =
false) {
401 return $this->
block($block,
'js', $first);
413 $this->
addJs(
'jquery');
414 $this->blocksJquery[] = $block;
426 return $this->
block($block,
'css', $first);
442 $ret.=
'[{[TITLE]}]';
455 .$this->getHtmlElt(
'meta').$ln
456 .$this->getHtmlElt(
'css', $ln);
473 array(
'[{[TITLE]}]',
'[{[META]}]',
'[{[CSS]}]',
'[{[JS]}]'),
477 $this->
getHtmlIncFiles(
'css', $ln).$ln.$this->getHtmlBlocks(
'css', $ln),
480 $content).($addJsBlocks ? $jsBlocks : null);
493 if (array_key_exists(
'Content-Type', $this->headers))
494 $ret.=
'<meta http-equiv="Content-Type" content="'.$this->headers[
'Content-Type'].
'" />'.$ln;
496 if ($this->cfg->titleInDes)
497 $this->cfg->setInArray(
'meta',
'description',
498 $this->cfg->getInarray(
'meta',
'title').
499 $this->cfg->titleInDes.
500 $this->cfg->getInarray(
'meta',
'description'));
501 foreach($this->cfg->meta as $k=>$v) {
502 if ($k !=
'title' || $this->cfg->useTitleInMeta)
503 $ret.=
'<meta name="'.$k.
'" content="'.
utils::htmlOut($v).
'" />'.$ln;
505 foreach($this->cfg->metaProperty as $k=>$v)
506 $ret.=
'<meta property="'.$k.
'" content="'.
utils::htmlOut($v).
'" />'.$ln;
507 foreach($this->cfg->link as $k=>$v)
521 if (array_key_exists($type, $this->incFiles)) {
522 $all = array_filter($this->incFiles[$type]);
523 $prm = $this->cfg->get($type);
525 foreach($all as $dir=>$medias) {
526 foreach($medias as $media=>$files) {
528 foreach($files as
$f) {
529 $tmp[$f[
'condIE']][] = $f[
'file'];
531 foreach($tmp as $ie=>$t) {
533 $ret.=
'<!--[if '.$ie.
']>'.$ln;
540 $ret.=
'<![endif]-->'.$ln;
558 $prm = $this->cfg->get($type);
559 $url = $this->
getUrlFile($type, $files, $dir);
560 return sprintf($prm[
'include'], $url, $media);
572 $prm = $this->cfg->get($type);
578 $url.=
'/'.(is_array($files)? implode(
request::getCfg(
'sepParam'), $files) : $files);
579 $url.=
'.'.$prm[
'ext'];
593 if ($type ==
'js' && !empty($this->blocksJquery))
594 $this->
blockJs(
'jQuery(function($) {'.$ln.implode($ln, $this->blocksJquery).$ln.
'});');
596 if (array_key_exists($type, $this->blocks)) {
597 $prm = $this->cfg->get($type);
598 $ret.= sprintf($prm[
'block'], implode($ln, $this->blocks[$type]));
604 public function send($headerOnly =
false) {
605 $ret = parent::send($headerOnly);
getHtmlBlocks($type, $ln="\)
addTitleBefore($title, $sep=', ')
static htmlOut($val, $key=false)
getIncludeTagFile($type, $files, $dir='nyro', $media='screen')
addTitleAfter($title, $sep=', ')
getDepend($file, $type='js', $after=false)
blockJs($block, $first=false)
static htmlTag($tag, array $attributes, $content=null)
setMetaProperty($name, $value)
if(!defined('NYROROOT')) define('NYROROOT' ROOT DS
setMetaPropertyBefore($name, $value, $sep=', ')
getUrlFile($type, $files, $dir='nyro')
blockCss($block, $first=false)
static initTab(array &$vars, array $init)
static getPathControllerUri($forceController=false)
setMetaAfter($name, $value, $sep=', ')
static debugger(array $elts=null)
setHtmlEltIntern($content)
setLink($rel, array $attributes)
getHtmlElt($prm='all', $ln="\)
setMetaPropertyAfter($name, $value, $sep=', ')
getHtmlIncFiles($type, $ln="\)
static isAbsolutizeAllUris()
initIncFiles($addDefaults=true)
blockjQuery($block, $addjQuery=true)
setTitleInDes($titleInDes)
setMetaBefore($name, $value, $sep=', ')
block($block, $type='js', $first=false)