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.
lnapp/classes/lnApp/Script.php

48 lines
1.2 KiB
PHP
Raw Normal View History

2013-04-22 05:50:28 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is for rendering HTML script tags
*
* @package lnApp
2013-10-08 23:24:11 +00:00
* @category Helpers
2013-04-22 05:50:28 +00:00
* @author Deon George
* @copyright (c) 2009-2013 Deon George
* @license http://dev.leenooks.net/license.html
*/
abstract class lnApp_Script extends HTMLRender {
protected static $_data = array();
protected static $_spacer = "\n";
2013-04-25 00:22:36 +00:00
protected static $_c = 0;
protected $_items = array('data','media','type');
2013-05-15 12:21:34 +00:00
protected $_unique_vals = array('data');
2013-04-22 05:50:28 +00:00
2013-04-25 00:22:36 +00:00
protected static $_required_keys = array('type','data');
2013-04-22 05:50:28 +00:00
/**
* Render the script tag
*
* @see HTMLRender::render()
*/
protected function render() {
2013-04-25 00:22:36 +00:00
$record = static::$_data[$this->_x];
$output = '';
2013-04-22 05:50:28 +00:00
2013-04-25 00:22:36 +00:00
switch ($record['type']) {
case 'file':
$output .= HTML::script($record['data']);
break;
case 'stdin':
$output .= sprintf("<script type=\"text/javascript\">//<![CDATA[\n%s\n//]]></script>",$record['data']);
break;
case 'src':
$output .= HTML::script($record['data']);
break;
default:
throw new Kohana_Exception('Unknown style type :type',array(':type'=>$record['type']));
2013-04-22 05:50:28 +00:00
}
2013-04-25 00:22:36 +00:00
return $output;
2013-04-22 05:50:28 +00:00
}
}
?>