<?php
/**
*
* @author Benjamin Gillissen <hide@address.com>
*
* **************************************************************
Copyright (C) 2009 Benjamin Gillissen
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details at:
http://www.gnu.org/copyleft/gpl.html
* **************************************************************
*/
/* used to output the content of the media queue (js, css)
*
*/
class tfeat_mediaq {
const PROFILE = FALSE;
public function __construct(){ }
public static function implent(){
//main, theme js folder exists ?
return TRUE;
}
public static function genpart($part, $of=FALSE){
//called by parser, with block like {--TFEAT=stylesheet; $part --}
//1 parts to add needed css into head element
//{--TFEAT=mediaq; stylesheet--} in header
if ( $part == 'stylesheet' ){
$entries = thm_mediaq::flush_css();
} elseif ($part == 'javascript'){
$entries = thm_mediaq::flush_js();
} else {
errors::raise("Invalid MediaQ request '$part' !", CORE_LOG_ERROR, 'TPL');
return FALSE;
}
if ( !is_array($entries) ){
if ( !$of ){ return ''; }
return TRUE;
}
$o='';
if ( $part == 'stylesheet' ){
foreach($entries as &$file){ $o .= '<link id="thm_css_'.CORE::hash($file, 5).'" rel="stylesheet" type="text/css" href="'.$file.'" />'."\n"; }
} else {
foreach($entries as &$data){
if ( $data[0] == 'file' ){
$o .= '<script type="text/javascript" src="'.$data[1].'"></script>'."\n";
} elseif ($data[0] == 'src' ){
$o .= '<script type="text/javascript">'."\n".$data[1]."\n".'</script>'."\n";
}
}
}
if ( !$of ){ return $o; }
call_user_func($of, $o);
return TRUE;
}
}
return TRUE;