Created
May 2, 2012 00:47
-
-
Save listenrightmeow/2572705 to your computer and use it in GitHub Desktop.
Kohana v3 Masher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Kohana::modules(array( | |
// 'auth' => MODPATH.'auth', // Basic authentication | |
// 'cache' => MODPATH.'cache', // Caching with multiple backends | |
// 'codebench' => MODPATH.'codebench', // Benchmarking tool | |
// 'database' => MODPATH.'database', // Database access | |
// 'image' => MODPATH.'image', // Image manipulation | |
// 'orm' => MODPATH.'orm', // Object Relationship Mapping | |
// 'unittest' => MODPATH.'unittest', // Unit testing | |
// 'userguide' => MODPATH.'userguide', // User guide and API documentation | |
'ui' => MODPATH.'ui', // Load custom UI module | |
)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') or die('No direct access allowed.'); | |
return array( | |
'global' => array( | |
'css' => array( | |
'public/ui/css/common/reset.css', | |
'public/ui/css/common/layout.css', | |
'public/ui/css/typography/typography.css', | |
), | |
'js' => array( | |
'public/ui/javascript/external/jquery.min.js', | |
'public/ui/javascript/external/fidel.min.js', | |
'public/ui/javascript/external/requirejs.min.js', | |
), | |
), | |
'page/index' => array( | |
'css' => array( | |
'public/ui/css/page/index.css', | |
), | |
'js' => array( | |
'public/ui/javascript/page/index.js', | |
), | |
), | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') or die('No direct script access.'); | |
abstract class Kohana_Ui { | |
/** | |
* Return assets from Masher config. Utilize 3.0 helpers (http://kohanaframework.org/3.0/guide/api/HTML) | |
* | |
* // Call position or type specific assets | |
* Ui::masher('footer', 'js', $page); | |
* | |
* @author Michael Dyer | |
* @param string string : location, type, page | |
* @return Kohana_Ui | |
* @throws None | |
*/ | |
public static function masher($location, $type, $page) | |
{ | |
$assets = array( | |
'header' => array( | |
'css' => array(), | |
'js' => array(), | |
'str' => '', | |
), | |
'footer' => array( | |
'css' => array(), | |
'js' => array(), | |
'str' => '', | |
), | |
); | |
$masher = Kohana::$config->load('masher'); | |
array_push($assets[$location][$type], $masher[$page][$type]); | |
foreach ($assets[$location][$type][0] as $key => $asset) { | |
$assets[$location]['str'] .= ($type == 'css') ? HTML::style($asset) : HTML::script($asset); | |
} | |
return $assets[$location]['str']; | |
} | |
} | |
// END KOHANA UI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo Ui::masher('footer', 'js', 'global'); ?> | |
<?php echo Ui::masher('footer', 'js', $page); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment