本文整理汇总了PHP中javascript::scriptPaths方法的典型用法代码示例。如果您正苦于以下问题:PHP javascript::scriptPaths方法的具体用法?PHP javascript::scriptPaths怎么用?PHP javascript::scriptPaths使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javascript
的用法示例。
在下文中一共展示了javascript::scriptPaths方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderLinks
public static function renderLinks($inline = FALSE, $index = FALSE)
{
// build a var with the included css files
$scriptincludes = self::$scriptPaths;
self::$scriptPaths = array();
// Get the session so we can track what assets are on the page
$session = Session::instance();
// If this is a full page load (ie not ajax) then there are no assest already on page
if (!request::is_ajax()) {
$session->delete('javascript.onPageAssets');
}
// Initialize the vars to track what has been added, and convience wrappers
$onPageAssets = $session->get('javascript.onPageAssets', array());
// sort the script include paths by weight
ksort($scriptincludes);
// loop all the script includes and determine what needs to go on this page
// and in what order
$includes = array();
foreach ($scriptincludes as $scripts) {
// make sure there are no duplicates in this array
$scripts = array_unique($scripts);
// make sure these css links are not already on the page
// via ajax/parent or in another weight category (lowest weight wins)
$scripts = array_diff($scripts, $onPageAssets);
// add the filtered list to the array of assets to put on the page
$includes = array_merge($includes, $scripts);
// keep track of what we add to the pages
$onPageAssets = array_merge($onPageAssets, $scripts);
}
// NOTICE: setting $session here causes segfault during ajax
// made a hack to move this set outside the event .....
Bluebox_Controller::$onPageAssets['js'] = $onPageAssets;
//$session->set('javascript.onPageAssets', $onPageAssets);
// create a list of links from the script includes
$linkList = html::script($includes, $index);
// are we displaying this inline or returning the string
if ($inline) {
echo $linkList;
} else {
return $linkList;
}
}