This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/application/classes/lnApp/Style.php

55 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2011-01-17 05:33:55 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is for rendering HTML style tags
*
* @package lnApp
* @subpackage Page
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
2012-11-26 05:57:18 +00:00
abstract class lnApp_Style extends HTMLRender {
2011-01-17 05:33:55 +00:00
protected static $_data = array();
protected static $_spacer = "\n";
protected static $_required_keys = array('type','data');
2012-11-26 05:57:18 +00:00
protected static $_unique_vals = array('file'=>'type');
2011-01-17 05:33:55 +00:00
/**
* Return an instance of this class
*
* @return Style
*/
public static function factory() {
return new Style;
}
/**
* Render the style tag
*
* @see HTMLRender::render()
*/
protected function render() {
2012-11-26 05:57:18 +00:00
$foutput = $soutput = '';
2011-01-17 05:33:55 +00:00
$mediapath = Route::get(static::$_media_path);
foreach (static::$_data as $value) {
switch ($value['type']) {
case 'file':
2012-11-26 05:57:18 +00:00
$foutput .= HTML::style($mediapath->uri(array('file'=>$value['data'])),
2011-01-17 05:33:55 +00:00
array('media'=>(! empty($value['media'])) ? $value['media'] : 'screen'),TRUE);
break;
2012-11-26 05:57:18 +00:00
case 'stdin':
$soutput .= sprintf("<style type=\"text/css\">%s</style>",$value['data']);
break;
2011-01-17 05:33:55 +00:00
default:
throw new Kohana_Exception('Unknown style type :type',array(':type'=>$value['type']));
}
}
2012-11-26 05:57:18 +00:00
return $foutput.static::$_spacer.$soutput;
2011-01-17 05:33:55 +00:00
}
}
?>