本文整理汇总了PHP中CHtml::asset方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::asset方法的具体用法?PHP CHtml::asset怎么用?PHP CHtml::asset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::asset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerCoreScripts
protected function registerCoreScripts()
{
$cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
$cssFile = CHtml::asset(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'cssmenu.css');
$cs->registerCssFile($cssFile);
}
示例2: registerClientScript
public function registerClientScript()
{
CHtml::asset(Yii::getPathOfAlias('ext.pager-scroll.assets'));
$url = $this->getAssetsUrl() . '/scollpage.js';
Yii::app()->clientScript->registerScriptFile($url);
Yii::app()->clientScript->registerCssFile($this->getAssetsUrl() . '/pagers.css');
}
示例3: init
/**
* Initializes the widget.
*/
public function init()
{
$this->baseUrl = CHtml::asset(dirname(__FILE__) . '/assets');
list($name, $id) = $this->resolveNameID();
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $id;
}
if (isset($this->htmlOptions['name'])) {
$name = $this->htmlOptions['name'];
} else {
$this->htmlOptions['name'] = $name;
}
$this->registerClientScript();
if (!$this->onlyScript) {
if ($this->hasModel()) {
$field = $this->textArea ? 'activeTextArea' : 'activeTextField';
echo CHtml::$field($this->model, $this->attribute, $this->htmlOptions);
} else {
$field = $this->textArea ? 'textArea' : 'textField';
echo CHtml::$field($name, $this->value, $this->htmlOptions);
}
}
}
示例4: actionIndex
public function actionIndex()
{
$this->pageTitle = 'Управление переводом';
$criteria = new CDbCriteria();
$criteria->with = array();
$criteria->order = 't.created_at DESC';
$filter = array();
$checkBoxDefaultOn = TRUE;
$count = Translate::model()->count($criteria);
$pages = new CPagination($count);
$pages->pageSize = TRANSLATES_PER_PAGE;
$pages->applyLimit($criteria);
$translates = Translate::model()->findAll($criteria);
$langs = Langs::model()->findAll();
$translatesLang = array();
foreach ($translates as $translate) {
$translatesLang[$translate->id] = array();
foreach ($translate->langs as $translateLang) {
foreach ($langs as $lang) {
if (!array_key_exists($lang->alias, $translatesLang[$translate->id])) {
$translatesLang[$translate->id][$lang->alias] = '';
}
if ($translateLang->lang == $lang->alias) {
$translatesLang[$translate->id][$lang->alias] = $translateLang->translate;
}
}
}
}
$model = new Translate();
$modelLang = new TranslateLang();
$this->include_jquery_form();
CHtml::asset(Yii::getPathOfAlias('application.modules.admin.modules.translate.css'));
$this->render('index', array('translates' => $translates, 'pages' => $pages, 'model' => $model, 'modelLang' => $modelLang, 'langs' => $langs, 'translatesLang' => $translatesLang, 'filter' => $filter, 'checkBoxDefaultOn' => $checkBoxDefaultOn));
}
示例5: run
/**
* Run this widget.
* This method registers necessary CSS and JS files and renders the needed JS and HTML code.
*/
public function run()
{
list($name, $id) = $this->resolveNameID();
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $id;
}
if (isset($this->htmlOptions['name'])) {
$name = $this->htmlOptions['name'];
}
if ($this->hasModel()) {
echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
} else {
echo CHtml::textField($name, $this->value, $this->htmlOptions);
}
$options = CJavaScript::encode($this->options);
$js = "jQuery('#{$id}').tagit({$options});";
$assets = CHtml::asset(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets');
$cs = Yii::app()->getClientScript();
$cs->registerCssFile($assets . '/jquery.tagit.css');
$cs->registerScriptFile($assets . '/tag-it.js', CClientScript::POS_END);
// Position is important here!
$cs->registerScript(__CLASS__ . '#' . $id, $js);
}
示例6: init
public function init()
{
if ($this->visible) {
ob_start();
ob_implicit_flush(false);
$cs = Yii::app()->clientScript;
if ($this->cssFile === null) {
$cssFile = CHtml::asset(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'portlet.css');
$cs->registerCssFile($cssFile);
} else {
if ($this->cssFile !== false) {
$cs->registerCssFile($this->cssFile);
}
}
echo "<div class=\"{$this->cssClass}\" style=\"width:{$this->width}\">\n";
if ($this->headerimage !== null) {
echo "<div class=\"{$this->headerCssClass}\"><img src=\"";
}
echo XHtml::imageUrl($this->headerimage);
echo "\"></div>\n";
echo "<div class=\"{$this->contentCssClass}\">\n";
$this->_openTag = ob_get_contents();
ob_clean();
}
}
示例7: actionLogin
/**
* actionLogin
*/
public function actionLogin()
{
// If you don't want use this login page, just uncomment "return false"
//return false;
if (!Yii::app()->user->isGuest) {
$this->redirect(Yii::app()->homeUrl);
}
$this->layout = 'auth';
$dir = CHtml::asset(__DIR__ . '/../assets/loginCss');
Yii::app()->clientScript->registerCssFile($dir . '/bootstrap.min.css');
Yii::app()->clientScript->registerCssFile($dir . '/style.css');
Yii::import('UserAdmin.models.forms.*');
$model = new ULoginForm();
if (isset($_POST['ULoginForm'])) {
$model->attributes = $_POST['ULoginForm'];
if ($model->validate()) {
$currentUserHomePage = User::getCurrentUserHomePage();
// If user have role and this role have home page
// then we redirect user there
if ($currentUserHomePage) {
$this->redirect($currentUserHomePage);
} else {
$this->redirect(Yii::app()->user->returnUrl);
}
}
}
$this->render('login', compact('model'));
}
示例8: registerScript
public function registerScript()
{
$loadBannersUrl = Yii::app()->createUrl(Yii::app()->getModule('banners')->loadBannersRoute);
$js = CHtml::asset(Yii::getPathOfAlias('banners.components.assets') . DIRECTORY_SEPARATOR . 'banners.js');
$cs = Yii::app()->clientScript;
$cs->registerScriptFile($js);
$cs->registerScript(__CLASS__, 'jQuery.getJSON("' . $loadBannersUrl . '", {bp:DaBp}, function(data) {if (data.length == 0) { return; } replaceBanners(data);});');
}
示例9: registerCoreScripts
protected function registerCoreScripts()
{
$cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
$cs->registerScriptFile('http://api-maps.yandex.ru/1.1/index.xml?key=' . Yii::app()->params['YMapKey']);
$jsFile = CHtml::asset(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'area_script.js');
$cs->registerScriptFile($jsFile);
$cs->registerCssFile('/css/holes_list.css');
}
示例10: init
public function init()
{
parent::init();
$cs = Yii::app()->clientScript;
$cs->registerScriptFile(CHtml::asset(dirname(__FILE__) . '/../assets/BackendUploadedFiles.js'));
if ($this->getObjectParameter()->isRequired()) {
$this->model->getValidatorList()->add(CValidator::createValidator('required', $this->model, array($this->getObjectParameter()->getFieldName()), array('on' => 'backendInsert, backendUpdate')));
}
}
示例11: registerScripts
public function registerScripts()
{
$cs = Yii::app()->clientScript;
$assetsUrl = CHtml::asset($this->getBasePath() . '/assets') . '/';
$cs->registerScriptFile($assetsUrl . 'messenger.js');
$options = array('assetsUrl' => $assetsUrl, 'newMessagesUrl' => Yii::app()->createUrl('messenger/default/getMessages'), 'readMessageUrl' => Yii::app()->createUrl('messenger/default/readMessage'), 'timeout' => $this->ajaxRequestTimeout * 1000);
$options = CMap::mergeArray($options, $this->pluginOptions);
$cs->registerScript('messengerInit', '$.fn.messenger(' . CJavaScript::encode($options) . ')', CClientScript::POS_READY);
}
示例12: init
public function init()
{
if ($this->cssFile === null) {
$this->cssFile = CHtml::asset(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'pager.css');
}
$this->header .= CHtml::openTag('div', array('class' => $this->pagerCssClass));
$this->footer = $this->ajaxProcessTemplate . CHtml::closeTag('div') . $this->footer;
parent::init();
}
示例13: run
public function run()
{
if (Yii::app()->user->hasFlash('email')) {
//register css file
$url = CHtml::asset(Yii::getPathOfAlias('application.extensions.email.css.debug') . '.css');
Yii::app()->getClientScript()->registerCssFile($url);
//dump debug info
echo Yii::app()->user->getFlash('email');
//Yii::app()->user->setFlash('email', null);
}
}
示例14: beforeControllerAction
public function beforeControllerAction($controller, $action)
{
if (parent::beforeControllerAction($controller, $action)) {
$dir = CHtml::asset(__DIR__ . '/assets');
Yii::app()->clientScript->registerCssFile($dir . '/style.css');
Yii::app()->clientScript->registerScriptFile($dir . '/common.js');
return true;
} else {
return false;
}
}
示例15: init
/**
* Initializes the widget.
* This method registers all needed client scripts
*/
public function init()
{
$baseUrl = CHtml::asset(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets');
$url = $this->cssFile !== false ? $this->cssFile : $baseUrl . '/XNoScriptMessage.css';
$jsCode = "\$(document).ready(function(){\n";
$jsCode .= "\$(\"noscript\").hide();\n";
$jsCode .= "})\n";
Yii::app()->getClientScript()->registerCssFile($url)->registerCoreScript('jquery')->registerScript(__CLASS__, $jsCode, CClientScript::POS_HEAD);
echo "<noscript>\n";
echo "<div id=\"js-info\">\n";
echo "<h2 style=\"color:red\">\n";
}