本文整理汇总了PHP中CHtml::scriptFile方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::scriptFile方法的具体用法?PHP CHtml::scriptFile怎么用?PHP CHtml::scriptFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::scriptFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerCssAndScriptsFiles
/**
* Register using yii methode the css and javascript files.
* The helper will choose the way to register the file depending on :
* 1. It's an ajax request or not
* 2. It's a css or a javascript file
* @param array $files an array with the file path of the css and js to register.
* The paths must be relative from the baseUrl. Ex : '/assets/plugins/bootstrap-datepicker/css/datepicker.css'
* @return true if everything done right
*/
public static function registerCssAndScriptsFiles($files, $path = null)
{
$cs = Yii::app()->getClientScript();
if (!$path) {
$path = Yii::app()->theme->baseUrl;
}
$ajaxRequest = Yii::app()->request->isAjaxRequest;
foreach ($files as $file) {
$extention = pathinfo($file, PATHINFO_EXTENSION);
if ($extention == "js" || $extention == "JS") {
if ($ajaxRequest) {
echo CHtml::scriptFile($path . $file);
} else {
$cs->registerScriptFile($path . $file, CClientScript::POS_END, array(), 2);
}
} else {
if ($extention == "css" || $extention == "CSS") {
if ($ajaxRequest) {
echo CHtml::cssFile($path . $file);
} else {
$cs->registerCssFile($path . $file);
}
} else {
//unknown extension
throw new InvalidArgumentException("unkonw file extension : " . $extention);
}
}
}
return true;
}
示例2: init
/**
* Renders the jsapi script file.
* @param string $apiKey the API key. Null if you do not have a key.
* @return string the script tag that loads Google jsapi.
*/
public static function init($apiKey=null)
{
if($apiKey===null)
return CHtml::scriptFile(self::$bootstrapUrl);
else
return CHtml::scriptFile(self::$bootstrapUrl.'?key='.$apiKey);
}
示例3: init
/**
* Renders the jsapi script file.
* @param string the API key. Null if you do not have a key.
* @return string the script tag that loads Google jsapi.
*/
public static function init($apiKey = null)
{
if ($apiKey === null) {
return CHtml::scriptFile(self::BOOTSTRAP_URL);
} else {
return CHtml::scriptFile(self::BOOTSTRAP_URL . '?key=' . $apiKey);
}
}
示例4: renderOnRequest
/**
* Inserts the scripts at the beginning of the body section.
* @param string the output to be inserted with scripts.
*/
public function renderOnRequest()
{
$html = '';
foreach ($this->scriptFiles as $scriptFiles) {
foreach ($scriptFiles as $scriptFile) {
$html .= CHtml::scriptFile($scriptFile) . "\n";
}
}
foreach ($this->scripts as $script) {
$html .= CHtml::script(implode("\n", $script)) . "\n";
}
if ($html !== '') {
return $html;
}
}
示例5: renderOnRequest
/**
* Inserts the scripts at the beginning of the body section.
* @param boolean $includeScriptFiles whether to include external files, or just dynamic scripts
* @return string the output to be inserted with scripts.
*/
public function renderOnRequest($includeScriptFiles = false)
{
$html = '';
if ($includeScriptFiles) {
foreach ($this->scriptFiles as $scriptFiles) {
foreach ($scriptFiles as $scriptFile) {
$html .= CHtml::scriptFile($scriptFile) . "\n";
}
}
}
foreach ($this->scripts as $script) {
// the good stuff!
$html .= CHtml::script(implode("\n", $script)) . "\n";
}
if ($html !== '') {
return $html;
}
}
示例6: renderBodyEnd
/**
* Inserts the scripts and other html snippets at the end of the body section.
*
* @param string $output the output to be inserted with scripts.
*/
public function renderBodyEnd(&$output)
{
if (!isset($this->scriptFiles[self::POS_END]) && !isset($this->scripts[self::POS_END]) && !isset($this->scripts[self::POS_READY]) && !isset($this->scripts[self::POS_LOAD]) && count($this->htmls) == 0) {
return;
}
$fullPage = 0;
$output = preg_replace('/(<\\/body\\s*>)/is', '<###end###>$1', $output, 1, $fullPage);
$html = '';
if (isset($this->scriptFiles[self::POS_END])) {
foreach ($this->scriptFiles[self::POS_END] as $scriptFile) {
$html .= CHtml::scriptFile($scriptFile) . "\n";
}
}
//----------------------------------------------------------------------------------------------------
// Begin Custom
foreach ($this->htmls as $id => $htmlSnippet) {
$html .= $htmlSnippet;
}
//----------------------------------------------------------------------------------------------------
$scripts = isset($this->scripts[self::POS_END]) ? $this->scripts[self::POS_END] : array();
if (isset($this->scripts[self::POS_READY])) {
if ($fullPage) {
$scripts[] = "jQuery(function(\$) {\n" . implode("\n", $this->scripts[self::POS_READY]) . "\n});";
} else {
$scripts[] = implode("\n", $this->scripts[self::POS_READY]);
}
}
if (isset($this->scripts[self::POS_LOAD])) {
if ($fullPage) {
$scripts[] = "jQuery(window).on('load',function() {\n" . implode("\n", $this->scripts[self::POS_LOAD]) . "\n});";
} else {
$scripts[] = implode("\n", $this->scripts[self::POS_LOAD]);
}
}
if (!empty($scripts)) {
$html .= CHtml::script(implode("\n", $scripts)) . "\n";
}
if ($fullPage) {
$output = str_replace('<###end###>', $html, $output);
} else {
$output = $output . $html;
}
}
示例7: array
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<?php
echo CHtml::tag('title', array(), $this->pageTitle) . "\r\n";
?>
<!-- <?php
echo CHtml::tag('title', array(), Yii::app()->name) . "\r\n";
?>
-->
<?php
echo CHtml::metaTag('Shenzhen Yunle Technology Co., Ltd. http://www.joy-cloud.com Aug 2013', 'author') . "\r\n";
echo CHtml::metaTag('noindex', 'robots') . "\r\n";
echo CHtml::metaTag('no', null, 'imagetoolbar') . "\r\n";
echo CHtml::cssFile(Helper::mediaUrl('stylesheet/stylesheet.css')) . "\r\n";
Yii::app()->clientScript->registerCoreScript('jquery');
echo CHtml::scriptFile(Yii::app()->baseUrl . '/javascript/superfish/js/superfish.js') . "\r\n";
?>
<script type="text/javascript">
$(function() {
$('#menu > ul').superfish({
hoverClass : 'sfHover',
pathClass : 'overideThisToUse',
delay : 0,
animation : {height: 'show'},
speed : 'normal',
autoArrows : false,
dropShadows : false,
disableHI : false, /* set to true to disable hoverIntent detection */
onInit : function(){},
onBeforeShow : function(){},
onShow : function(){},
示例8:
?>
<link href='https://fonts.googleapis.com/css?family=Comfortaa:400,700,300' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Droid+Serif:400,700' rel='stylesheet' type='text/css'>
<!-- SCRIPT's -->
<!-- JQuery -->
<?php
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/jquery/jquery.min.js");
?>
<!-- Bootstrap core javascript -->
<?php
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/bootstrap/js/bootstrap.min.js");
?>
<!-- Angular -->
<?php
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/angular/angular.min.js");
?>
<?php
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/angular/angular-locale_pt-br.js");
?>
<!-- Ui-mask core javascript -->
<?php
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/ui-utils/ui-utils-ieshiv.min.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/ui-utils/ui-utils.min.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/ui-utils/masks.min.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/d3/d3.min.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/angular-chart/dist/angular-charts.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/flex-slider/jquery.flexslider-min.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/flex-slider/angular-flexslider.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/ng-imgur/ng-imgur.js");
示例9: function
<?php
$this->beginClip('extraHead');
Yii::app()->clientScript->registerCssFile(Yii::app()->clientScript->getCoreScriptUrl() . '/jui/css/base/jquery-ui.css');
Yii::app()->clientScript->registerCoreScript('jquery.ui');
echo CHtml::scriptFile(Yii::app()->baseUrl . '/javascript/common.js') . "\r\n";
?>
<script type="text/javascript">
<!--
$(function() {
$('table.list tbody tr').live('mouseover', function() {
$(this).css('backgroundColor', '#EFFBFB');
}).live('mouseout', function() {
$(this).css('backgroundColor', 'white');
});
});
//-->
</script>
<script type="text/javascript">
<!--
var UPDATE_IS_RELEASED_URL = '<?php
echo $this->createUrl("updateIsReleased");
?>
';
$(function() {
$('.tree-table a.is-released-0').live('click', function() {
$(this).attr('class', 'is-released-1');
var m = $(this).attr('href').match(/#(\d+)(\w+)/);
updateIsReleased(UPDATE_IS_RELEASED_URL, m[1], m[2], 1);
return false;
});
示例10:
echo CHtml::scriptFile($baseScript . "service/bairro/bairroService.js?" . $time);
echo CHtml::scriptFile($baseScript . "service/tipoanimal/tipoanimalService.js?" . $time);
echo CHtml::scriptFile($baseScript . "service/unidademedida/unidademedidaService.js?" . $time);
echo CHtml::scriptFile($baseScript . "service/raca/racaService.js?" . $time);
echo CHtml::scriptFile($baseScript . "service/parceiros/parceirosService.js?" . $time);
echo CHtml::scriptFile($baseScript . "service/fornecedor/fornecedorService.js?" . $time);
echo CHtml::scriptFile($baseScript . "service/tipocontato/tipocontatoService.js?" . $time);
echo CHtml::scriptFile($baseScript . "service/marca/marcaService.js?" . $time);
/* CONTROLLERS */
echo CHtml::scriptFile($baseScript . "controller/menu/MenuController.js?" . $time);
echo CHtml::scriptFile($baseScript . "controller/login/LoginController.js?" . $time);
echo CHtml::scriptFile($baseScript . "controller/admin/AdminController.js?" . $time);
echo CHtml::scriptFile($baseScript . "controller/configuracao/ConfiguracaoController.js?" . $time);
echo CHtml::scriptFile($baseScript . "controller/configuracao/RedeController.js?" . $time);
echo CHtml::scriptFile($baseScript . "controller/configuracao/PetshopController.js?" . $time);
echo CHtml::scriptFile($baseScript . "controller/configuracao/CidadeController.js?" . $time);
echo CHtml::scriptFile($baseScript . "controller/configuracao/BairroController.js?" . $time);
echo CHtml::scriptFile($baseScript . "controller/configuracao/TipoanimalController.js?" . $time);
echo CHtml::scriptFile($baseScript . "controller/configuracao/TipoanimalpetshopController.js?" . $time);
echo CHtml::scriptFile($baseScript . "controller/configuracao/UnidademedidaController.js?" . $time);
echo CHtml::scriptFile($baseScript . "controller/configuracao/RacaController.js?" . $time);
echo CHtml::scriptFile($baseScript . "controller/configuracao/ParceirosController.js?" . $time);
echo CHtml::scriptFile($baseScript . "controller/configuracao/FornecedorController.js?" . $time);
echo CHtml::scriptFile($baseScript . "controller/configuracao/MarcaController.js?" . $time);
?>
<script>
(function($angular) {
$angular.bootstrap(document, ['app']);
})(window.angular);
</script>
示例11: renderHead
/**
* Inserts the scripts in the head section.
* @param string $output the output to be inserted with scripts.
* This method is Copyright (c) 2008-2014 by Yii Software LLC
* http://www.yiiframework.com/license/
*/
public function renderHead(&$output)
{
parent::renderHead($output);
$html = '';
foreach ($this->metaTags as $meta) {
$html .= CHtml::metaTag($meta['content'], null, null, $meta) . "\n";
}
foreach ($this->linkTags as $link) {
$html .= CHtml::linkTag(null, null, null, null, $link) . "\n";
}
/* x2modstart */
if (Auxlib::getIEVer() < 10) {
// group registered css files using import statements
$mergedCss = '';
$mediaType = null;
foreach ($this->cssFiles as $url => $media) {
if ($mediaType === null) {
$mediaType = $media;
}
$text = '@import url("' . $url . '");';
if ($media !== $mediaType) {
$html .= CHtml::css($mergedCss, $mediaType) . "\n";
$mergedCss = '';
$mediaType = $media;
}
$mergedCss .= "\n" . $text;
}
if ($mergedCss) {
$html .= CHtml::css($mergedCss, $mediaType) . "\n";
}
} else {
foreach ($this->cssFiles as $url => $media) {
$html .= CHtml::cssFile($url, $media) . "\n";
}
}
if (Auxlib::getIEVer() < 10) {
// merge inline css
$mergedCss = '';
$mediaType = null;
foreach ($this->css as $css) {
$text = $css[0];
$media = $css[1];
if (is_array($text) && isset($text['text'])) {
$text = $text['text'];
}
if ($mediaType === null) {
$mediaType = $media;
}
if (preg_match('/@import/', $text)) {
if ($mergedCss) {
$html .= CHtml::css($mergedCss, $mediaType) . "\n";
}
$mergedCss = '';
$mediaType = null;
$html .= CHtml::css($text, $media) . "\n";
continue;
}
if ($media !== $mediaType) {
$html .= CHtml::css($mergedCss, $mediaType) . "\n";
$mergedCss = '';
$mediaType = $media;
}
$mergedCss .= "\n" . $text;
}
if ($mergedCss) {
$html .= CHtml::css($mergedCss, $mediaType) . "\n";
}
} else {
foreach ($this->css as $css) {
$text = $css[0];
$media = $css[1];
if (is_array($text) && isset($text['text']) && isset($text['htmlOptions'])) {
// special case for css registered with html options
$html .= X2Html::css($text['text'], $media, $text['htmlOptions']);
continue;
}
$html .= CHtml::css($text, $media) . "\n";
}
}
// prevent global css from being applied if this is an admin or guest request
if (!Yii::app()->controller instanceof AdminController && !Yii::app()->user->isGuest) {
$globalCssUrl = GlobalCSSFormModel::getGlobalCssUrl();
$html .= CHtml::cssFile($globalCssUrl . $this->getCacheBusterSuffix($globalCssUrl)) . "\n";
}
/* x2modend */
if ($this->enableJavaScript) {
if (isset($this->scriptFiles[self::POS_HEAD])) {
foreach ($this->scriptFiles[self::POS_HEAD] as $scriptFileValueUrl => $scriptFileValue) {
if (is_array($scriptFileValue)) {
$html .= CHtml::scriptFile($scriptFileValueUrl, $scriptFileValue) . "\n";
} else {
$html .= CHtml::scriptFile($scriptFileValueUrl) . "\n";
}
}
//.........这里部分代码省略.........
示例12: renderBodyEnd
/**
* Inserts the scripts at the end of the body section.
* @param string $output the output to be inserted with scripts.
*/
public function renderBodyEnd(&$output)
{
if(!isset($this->scriptFiles[self::POS_END]) && !isset($this->scripts[self::POS_END])
&& !isset($this->scripts[self::POS_READY]) && !isset($this->scripts[self::POS_LOAD]))
return;
$fullPage=0;
$output=preg_replace('/(<\\/body\s*>)/is','<###end###>$1',$output,1,$fullPage);
$html='';
if(isset($this->scriptFiles[self::POS_END]))
{
foreach($this->scriptFiles[self::POS_END] as $scriptFile)
$html.=CHtml::scriptFile($scriptFile)."\n";
}
$scripts=isset($this->scripts[self::POS_END]) ? $this->scripts[self::POS_END] : array();
if(isset($this->scripts[self::POS_READY]))
{
if($fullPage)
$scripts[]="jQuery(function($) {\n".implode("\n",$this->scripts[self::POS_READY])."\n});";
else
$scripts[]=implode("\n",$this->scripts[self::POS_READY]);
}
if(isset($this->scripts[self::POS_LOAD]))
{
if($fullPage)
$scripts[]="jQuery(window).load(function() {\n".implode("\n",$this->scripts[self::POS_LOAD])."\n});";
else
$scripts[]=implode("\n",$this->scripts[self::POS_LOAD]);
}
if(!empty($scripts))
$html.=CHtml::script(implode("\n",$scripts))."\n";
if($fullPage)
$output=str_replace('<###end###>',$html,$output);
else
$output=$output.$html;
}
示例13:
<?php
/* CSS */
$controller = Yii::app()->getController();
$default_controller = Yii::app()->defaultController;
$isHome = $controller->id === $default_controller && ($controller->action->id === $controller->defaultAction || $controller->action->id === 'deslogarUsuario') ? true : false;
echo CHtml::cssFile(Yii::app()->baseUrl . "/assets/css/bootstrap/css/bootstrap.css");
echo CHtml::cssFile(Yii::app()->baseUrl . "/assets/css/css.php");
echo CHtml::cssFile(Yii::app()->baseUrl . "/assets/css/menu/menu1.css");
if ($isHome) {
} else {
}
/* JAVASCRIPT */
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/js/jquery/jquery.min.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/css/bootstrap/js/bootstrap.min.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/js/angular/angular.min.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/js/angular/angular-locale_pt-br.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/js/ui-utils/ui-utils-ieshiv.min.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/js/ui-utils/ui-utils.min.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/js/ui-utils/masks.min.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/js/d3/d3.min.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/js/angular-chart/dist/angular-charts.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/js/ng-imgur/ng-imgur.js");
echo CHtml::scriptFile(Yii::app()->baseUrl . "/assets/js/message-center/message-center.js");
示例14: JavascriptFile
function JavascriptFile($filename)
{
echo CHtml::scriptFile($filename);
}
示例15: array
?>
" type="image/x-icon" />
<meta name="Author" content="Shenzhen Doocom Technology Co., Ltd. http://www.doocom.cn, Dec 2012" />
<?php
echo CHtml::tag('title', array(), $this->pageTitle) . "\r\n";
if ($this->metaKeywords) {
echo CHtml::metaTag($this->metaKeywords, 'keywords') . "\r\n";
}
if ($this->metaDescription) {
echo CHtml::metaTag($this->metaDescription, 'description') . "\r\n";
}
echo CHtml::cssFile(Helper::mediaUrl('inc/style.css')) . "\r\n";
echo CHtml::scriptFile(Helper::mediaUrl('inc/jquery.js')) . "\r\n";
echo CHtml::scriptFile(Helper::mediaUrl('inc/func.js')) . "\r\n";
echo CHtml::scriptFile(Helper::mediaUrl('inc/jquery.cycle.all.min.js')) . "\r\n";
echo CHtml::scriptFile(Helper::mediaUrl('inc/jquery.masonry.min.js')) . "\r\n";
?>
</head>
<body>
<div class="wrapper">
<?php
$this->widget('Header');
?>
<?php
echo $content;
?>
<?php
$this->widget('Footer');
?>