10.30
php
saved
Jippi_
Note
Modified RosSoft's HeadHelper
Added feature to have default and custom css / js folder - usefull when using on alot of websites where you need some basic css / js - but want to have the option to make your own custom without breaking the original source
Modified RosSoft's HeadHelper
Added feature to have default and custom css / js folder - usefull when using on alot of websites where you need some basic css / js - but want to have the option to make your own custom without breaking the original source
- <?php
- /**
- * Head Helper
- * Register <head> tags from helpers, then print them
- * in head through layout.
- * @author RosSoft
- * @license MIT
- * @version 0.2
- */
- class HeadHelper extends Helper
- {
- var $_library; //static array of items to be included
- function __construct()
- {
- $this->_library=& $library;
- }
- /**
- * Adds a css file to array
- * @param string $file CSS file to be included
- * @param string $param Array of htmlAttributes
- */
- function register_css($file,$htmlAttributes=null)
- {
- }
- /**
- * Adds an inline css block to array
- * @param string $css CSS tags to be included
- * @param string $param Array of htmlAttributes
- */
- function register_cssblock($css,$htmlAttributes=null)
- {
- }
- /**
- * Adds a js file to array
- * @param string $file CSS file to be included
- * @param string $param Array of htmlAttributes
- */
- function register_js($file)
- {
- }
- /**
- * Adds a javascript block to array
- * @param string $javascript Javascript block to be included
- * @param string $param Array of htmlAttributes
- */
- function register_jsblock($javascript)
- {
- }
- /**
- * Adds a meta tag to array
- * @param array $htmlAttributes Array of html attributes of meta tag
- */
- function register_meta($htmlAttributes)
- {
- }
- /**
- * Adds a link tag to array
- * @param array $htmlAttributes Array of html attributes of meta tag
- */
- function register_link($htmlAttributes)
- {
- }
- /**
- * Adds a raw sequence of html tags to array
- * @param string $raw Sequence of html tags
- */
- function register_raw($raw)
- {
- }
- //-------------------------------------------------
- // Jippi at dork.dk HeadHacks
- //-------------------------------------------------
- // Var to store our css search paths ( relative to webroot )
- 'custom',
- 'default'
- );
- // Find our CSS files
- function __findCSS( $file ) { return $this->__find( $file, 'css', '.css' ); }
- // Find our JS files
- function __findJS( $file ) { return $this->__find( $file, 'js', '.js' ); }
- /**
- * Try to find our file in webroot
- *
- * @param string $file File to find
- * @param string $folder Folder to search in ( without trailing / )
- * @param string $extension Extension of the file we want
- * @return string Path to the file if we found it - else the original file
- */
- function __find( $file, $folder, $extension )
- {
- foreach ( $this->searchPaths AS $key => $path )
- {
- return $path . DS . $file;
- }
- return $file;
- }
- /**
- * Get our webroot with full path !
- *
- * @return string FULL path to our webroot directory
- */
- function __getWebRoot()
- {
- return ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS;
- }
- /**
- * Prints the html for all of the items registered
- * @return string
- */
- function print_registered()
- {
- $this->getSearchPaths();
- foreach ($this->_library as $l)
- {
- echo "\n\t";
- switch ($l[1])
- {
- case 'css':
- break;
- case 'js':
- break;
- case 'jsblock':
- break;
- case 'meta':
- break;
- case 'link':
- break;
- case 'raw':
- break;
- case 'cssblock':
- break;
- default:
- }
- }
- }
- //------------------------------------------------
- // End Jippi hacks
- //------------------------------------------------
- /**
- * Adds the item in the array if it doesn't already exist
- * @param array $item Item to be added
- * @access private
- */
- function _register($item)
- {
- {
- $this->_library[]=$item;
- }
- }
- /**
- * This is a copy of the same function in HtmlHelper
- * Returns a space-delimited string with items of the $options array. If a
- * key of $options array happens to be one of:
- * + 'compact'
- * + 'checked'
- * + 'declare'
- * + 'readonly'
- * + 'disabled'
- * + 'selected'
- * + 'defer'
- * + 'ismap'
- * + 'nohref'
- * + 'noshade'
- * + 'nowrap'
- * + 'multiple'
- * + 'noresize'
- *
- * And its value is one of:
- * + 1
- * + true
- * + 'true'
- *
- * Then the value will be reset to be identical with key's name.
- * If the value is not one of these 3, the parameter is not output.
- *
- * @param array $options Array of options.
- * @param array $exclude Array of options to be excluded.
- * @param string $insertBefore String to be inserted before options.
- * @param string $insertAfter String to be inserted ater options.
- * @return string
- */
- function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null)
- {
- 'compact',
- 'checked',
- 'declare',
- 'readonly',
- 'disabled',
- 'selected',
- 'defer',
- 'ismap',
- 'nohref',
- 'noshade',
- 'nowrap',
- 'multiple',
- 'noresize'
- );
- {
- }
- {
- foreach ($options as $key => $value)
- {
- {
- $minimizedAttributes)))
- {
- $value = $key;
- }
- {
- continue;
- }
- $out[] = "{$key}=\"{$value}\"";
- }
- }
- return $out? $insertBefore.$out.$insertAfter: null;
- }
- else
- {
- return $options? $insertBefore.$options.$insertAfter: null;
- }
- }
- }
- ?>
Parsed in 0.235 seconds, using GeSHi 1.0.7.14