本文整理汇总了PHP中yii\helpers\Html::cssFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::cssFile方法的具体用法?PHP Html::cssFile怎么用?PHP Html::cssFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::cssFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
<!DOCTYPE html>
<html lang="<?php
echo Yii::$app->language;
?>
">
<head>
<meta charset="<?php
echo Yii::$app->charset;
?>
">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php
echo Html::cssFile('@web/css/temp.css');
?>
<?php
echo Html::cssFile('@web/css/dev.css');
?>
<?php
echo Html::csrfMetaTags();
?>
<title><?php
echo Html::encode($this->title);
?>
</title>
<?php
$this->head();
?>
</head>
<body>
<?php
$this->beginBody();
示例2: minifyCSS
/**
* @return self
*/
protected function minifyCSS()
{
if (!empty($this->cssFiles)) {
$css_files = array_keys($this->cssFiles);
$css_minify_file = $this->minify_path . '/' . $this->_getSummaryFilesHash($this->cssFiles) . '.css';
if (!file_exists($css_minify_file)) {
$css = '';
foreach ($css_files as $file) {
$file = preg_replace("#\\?v=\\d{1,}\$#i", '', $file);
$content = file_get_contents($this->getBasePath($file));
preg_match_all('|url\\(([^)]+)\\)|is', $content, $m);
if (!empty($m[0])) {
$path = dirname($file);
$result = [];
foreach ($m[0] as $k => $v) {
if (0 === strpos($m[1][$k], 'data:')) {
continue;
}
$url = str_replace(['\'', '"'], '', $m[1][$k]);
if ($this->isUrl($url)) {
$result[$m[1][$k]] = '\'' . $url . '\'';
} else {
$result[$m[1][$k]] = '\'' . $path . '/' . $url . '\'';
}
}
$content = str_replace(array_keys($result), array_values($result), $content);
}
$css .= $content;
}
$this->expandImports($css);
$css = (new \CSSmin())->run($css, $this->css_linebreak_pos);
if (false !== $this->force_charset) {
$charsets = '@charset "' . (string) $this->force_charset . '";' . "\n";
} else {
$charsets = $this->collectCharsets($css);
}
$imports = $this->collectImports($css);
$fonts = $this->collectFonts($css);
file_put_contents($css_minify_file, $charsets . $imports . $fonts . $css);
if (false !== $this->file_mode) {
chmod($css_minify_file, $this->file_mode);
}
}
// // debug info ------------------------------------------------------
// \common\components\log\AppLogger::info([
// 'method' => __METHOD__,
// 'line' => __LINE__,
// '$this->base_path' => $this->base_path,
// 'alias' => $this->getBasePath(),
// '$this->minify_path' => $this->minify_path,
// '$css_minify_file' => $css_minify_file,
// ]);
// // -----------------------------------------------------------------
$css_file = str_replace($this->getBasePath(), '', $css_minify_file);
$this->cssFiles = [$css_file => helpers\Html::cssFile($css_file)];
}
return $this;
}
示例3: addCssFiles
/**
* Registers Css
*/
public function addCssFiles($cssFiles, $options = [])
{
$url = $this->getUrlByFiles($cssFiles);
if (Yii::$app->controller->layout) {
Yii::$app->getView()->registerCssFile($url, $options);
} else {
echo Html::cssFile($url, $options);
}
}
示例4: _processingCssFiles
/**
* @param array $files
* @return array
*/
protected function _processingCssFiles($files = [])
{
$fileName = md5(implode(array_keys($files)) . $this->getSettingsHash()) . '.css';
$publicUrl = Yii::getAlias('@web/assets/css-compress/' . $fileName);
$rootDir = Yii::getAlias('@webroot/assets/css-compress');
$rootUrl = $rootDir . '/' . $fileName;
if (file_exists($rootUrl)) {
$resultFiles = [];
foreach ($files as $fileCode => $fileTag) {
if (!Url::isRelative($fileCode) && !$this->cssFileRemouteCompile) {
$resultFiles[$fileCode] = $fileTag;
}
}
$publicUrl = $publicUrl . "?v=" . filemtime($rootUrl);
$resultFiles[$publicUrl] = Html::cssFile($publicUrl);
return $resultFiles;
}
$resultContent = [];
$resultFiles = [];
foreach ($files as $fileCode => $fileTag) {
if (Url::isRelative($fileCode)) {
$contentTmp = trim($this->fileGetContents(Url::to(Yii::$app->request->hostInfo . $fileCode, true)));
$fileCodeTmp = explode("/", $fileCode);
unset($fileCodeTmp[count($fileCodeTmp) - 1]);
$prependRelativePath = implode("/", $fileCodeTmp) . "/";
$contentTmp = \Minify_CSS::minify($contentTmp, ["prependRelativePath" => $prependRelativePath, 'compress' => true, 'removeCharsets' => true, 'preserveComments' => true]);
//$contentTmp = \CssMin::minify($contentTmp);
$resultContent[] = $contentTmp;
} else {
if ($this->cssFileRemouteCompile) {
//Trying to download a remote file
$resultContent[] = trim($this->fileGetContents($fileCode));
} else {
$resultFiles[$fileCode] = $fileTag;
}
}
}
if ($resultContent) {
$content = implode($resultContent, "\n");
if (!is_dir($rootDir)) {
if (!FileHelper::createDirectory($rootDir, 0777)) {
return $files;
}
}
if ($this->cssFileCompress) {
$content = \CssMin::minify($content);
}
$file = fopen($rootUrl, "w");
fwrite($file, $content);
fclose($file);
}
if (file_exists($rootUrl)) {
$publicUrl = $publicUrl . "?v=" . filemtime($rootUrl);
$resultFiles[$publicUrl] = Html::cssFile($publicUrl);
return $resultFiles;
} else {
return $files;
}
}
示例5:
<?php
use yii\helpers\Html;
use yii\helpers\Url;
/* @var $this yii\web\View */
$this->title = 'My Yii Application';
$upload = yii::$app->request->baseUrl . '/../../backend/web/upload/';
echo Html::cssFile('@web/css/bootstrap.css');
?>
<?php
$this->beginBlock('inline_styles');
?>
<style>
.cy-rg1ph input{
width: 88%;
float: right;
margin-right: 4%;
color: #c8c8c8;
}
.cy-rg1ph label{
color: #c8c8c8;
font-weight: normal;
float: left;
display: block;
width: 5%;
}
</style>
<?php
示例6: registerCssFile
/**
* Registers a CSS file.
* @param string $url the CSS file to be registered.
* @param array $options the HTML attributes for the link tag. Please refer to [[Html::cssFile()]] for
* the supported options. The following options are specially handled and are not treated as HTML attributes:
*
* - `depends`: array, specifies the names of the asset bundles that this CSS file depends on.
*
* @param string $key the key that identifies the CSS script file. If null, it will use
* $url as the key. If two CSS files are registered with the same key, the latter
* will overwrite the former.
*/
public function registerCssFile($url, $options = [], $key = null)
{
$url = Yii::getAlias($url);
$key = $key ?: $url;
$depends = ArrayHelper::remove($options, 'depends', []);
if (empty($depends)) {
$this->cssFiles[$key] = Html::cssFile($url, $options);
} else {
$this->getAssetManager()->bundles[$key] = Yii::createObject(['class' => AssetBundle::className(), 'baseUrl' => '', 'css' => [strncmp($url, '//', 2) === 0 ? $url : ltrim($url, '/')], 'cssOptions' => $options, 'depends' => (array) $depends]);
$this->registerAssetBundle($key);
}
}
示例7:
<!DOCTYPE html>
<html lang="<?php
echo Yii::$app->language;
?>
">
<head>
<meta charset="<?php
echo Yii::$app->charset;
?>
">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php
echo Html::csrfMetaTags();
?>
<?php
echo Html::cssFile('frontend/web/css/layout.css');
?>
<?php
echo Html::jsFile('frontend/web/js/jquery-1.8.1.min.js');
?>
<title><?php
echo Html::encode('YII2');
?>
</title>
<?php
$this->head();
?>
</head>
<body>
<?php
$this->beginBody();
示例8: function
<div class="nav-item-inner nav-marketing">文章管理</div>
</li>
</ul>
</div>
<ul id="J_NavContent" class="dl-tab-conten">
</ul>
</div>
<?php
echo Html::cssFile('@web/assets/css/dpl-min.css');
echo Html::cssFile('@web/assets/css/bui-min.css');
echo Html::cssFile('@web/assets/css/main-min.css');
echo Html::cssFile('@web/css/site.css');
echo Html::jsFile('@web/assets/js/jquery-1.8.1.min.js');
echo Html::jsFile('@web/assets/js/bui-min.js');
echo Html::jsFile('@web/assets/js/common/main-min.js');
echo Html::jsFile('@web/assets/js/config-min.js');
?>
<script>
BUI.use('common/main', function () {
var config = [{
id: 'menu',
menu: [{
text: '用户信息修改',
items: [
{
示例9: processMinifyCss
/**
* @param array $files
*/
protected function processMinifyCss($files)
{
$resultFile = $this->minify_path . '/' . $this->_getSummaryFilesHash($files) . '.css';
if (!file_exists($resultFile)) {
$css = '';
foreach ($files as $file => $html) {
$path = dirname($file);
$file = $this->getAbsoluteFilePath($file);
$content = file_get_contents($file);
preg_match_all('|url\\(([^)]+)\\)|is', $content, $m);
if (!empty($m[0])) {
$result = [];
foreach ($m[0] as $k => $v) {
if (in_array(strpos($m[1][$k], 'data:'), [0, 1], true)) {
continue;
}
$url = str_replace(['\'', '"'], '', $m[1][$k]);
if ($this->isUrl($url)) {
$result[$m[1][$k]] = '\'' . $url . '\'';
} else {
$result[$m[1][$k]] = '\'' . $path . '/' . $url . '\'';
}
}
$content = str_replace(array_keys($result), array_values($result), $content);
}
$css .= $content;
}
$this->expandImports($css);
$this->removeCssComments($css);
$css = (new \CSSmin())->run($css, $this->css_linebreak_pos);
if (false !== $this->force_charset) {
$charsets = '@charset "' . (string) $this->force_charset . '";' . "\n";
} else {
$charsets = $this->collectCharsets($css);
}
$imports = $this->collectImports($css);
$fonts = $this->collectFonts($css);
file_put_contents($resultFile, $charsets . $imports . $fonts . $css);
if (false !== $this->file_mode) {
@chmod($resultFile, $this->file_mode);
}
}
$file = sprintf('%s%s', \Yii::getAlias($this->web_path), str_replace(\Yii::getAlias($this->base_path), '', $resultFile));
$this->cssFiles[$file] = helpers\Html::cssFile($file);
}
示例10:
use yii\bootstrap\ActiveForm;
use yii\captcha\Captcha;
$this->title = 'Contact';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-contact">
<h1><?php
echo Html::encode($this->title);
?>
</h1>
<hr>
<?php
echo Html::tag('hoogl', '111', ['class' => 'hoogl', 'data' => '1212']);
?>
<?php
echo Html::cssFile('/asssets/q.css');
?>
<?php
print_r(Html::cssStyleFromArray(['width' => '100px', 'height' => '200px']));
?>
<hr>
<?php
if (Yii::$app->session->hasFlash('contactFormSubmitted')) {
?>
<div class="alert alert-success">
Thank you for contacting us. We will respond to you as soon as possible.
</div>
<p>
示例11: registerCssFile
/**
* Registers a CSS file.
* @param string $url the CSS file to be registered.
* @param array $options the HTML attributes for the link tag. Please refer to [[Html::cssFile()]] for
* the supported options. The following options are specially handled and are not treated as HTML attributes:
*
* - `depends`: array, specifies the names of the asset bundles that this CSS file depends on.
*
* @param string $key the key that identifies the CSS script file. If null, it will use
* $url as the key. If two CSS files are registered with the same key, the latter
* will overwrite the former.
*/
public function registerCssFile($url, $options = [], $key = null)
{
$url = Yii::getAlias($url);
$key = $key ?: $url;
$depends = ArrayHelper::remove($options, 'depends', []);
if (empty($depends)) {
$this->cssFiles[$key] = Html::cssFile($url, $options);
} else {
$this->getAssetManager()->bundles[$key] = new AssetBundle(['baseUrl' => '', 'css' => [ltrim($url, '/')], 'cssOptions' => $options, 'depends' => (array) $depends]);
$this->registerAssetBundle($key);
}
}
示例12:
">
<head>
<meta charset="<?php
echo Yii::$app->charset;
?>
">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php
echo Html::cssFile('backend/web/css/dpl-min.css');
?>
<?php
echo Html::cssFile('backend/web/css/bui-min.css');
?>
<?php
echo Html::cssFile('backend/web/css/main-min.css');
?>
<?php
echo Html::jsFile('backend/web/js/jquery-1.8.1.min.js');
?>
<?php
echo Html::jsFile('backend/web/js/bui-min.js');
?>
<?php
echo Html::jsFile('backend/web/js/main-min.js');
?>
<?php
echo Html::jsFile('backend/web/js/config-min.js');
?>
<?php
示例13:
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php
echo Html::encode($this->title . ' / ' . Yii::t('app', 'Control Panel'));
?>
</title>
<?php
echo Html::csrfMetaTags();
?>
<?php
$this->head();
?>
<?php
echo Html::cssFile('/assets/' . ArrayHelper::getValue(Yii::$app->params['assets'], 'admin.css'));
?>
</head>
<body>
<?php
$this->beginBody();
?>
<?php
if (Yii::$app->controller->action->id == 'login') {
?>
<div class="container">
<?php
echo $content;
?>
</div>
<?php
示例14: filemtime
<!--[if lte IE 9 ]>
<link rel="stylesheet" href="https://libs.cdn.renault.com/etc/designs/renault_v2/2.3.0-92/common-assets/css/pre-ie10.min.css">
<![endif]-->
<link rel="icon" type="image/png" href="/favicon.ico">
<?php
$this->head();
?>
<?php
echo Html::csrfMetaTags();
?>
<?php
echo Html::cssFile(YII_DEBUG ? '@web/css/all.css?v=' . filemtime(Yii::getAlias('@webroot/css/all.min.css')) : '@web/css/all.min.css?v=' . filemtime(Yii::getAlias('@webroot/css/all.min.css')));
?>
<?php
echo Html::cssFile('@web/plugins/rs-plugin/css/settings.css?v=' . filemtime(Yii::getAlias('@webroot/plugins/rs-plugin/css/settings.css')));
echo DbText::widget(['key' => 'frontend.code.head.end', 'domain_id' => Yii::getAlias('@domainId')]);
?>
</head>
<body>
<?php
$this->beginBody();
?>
<main id="container" role="main">
<?php
echo $content;
?>
</main>
示例15:
echo Html::tag('div', 'sdsdsd dddd', $options);
$id = 2;
$option = [['id' => 1, 'name' => 'one'], ['id' => 2, 'name' => 'two'], ['id' => 3, 'name' => 'three'], ['id' => 4, 'name' => 'four']];
$post = ['title' => 'this is title', 'name' => 'this is name', 'child' => [1000, 200]];
echo Html::getInputName($model, 'username');
echo Html::getAttributeValue($model, 'username');
echo Html::tag('hr');
echo Html::getInputId($model, 'username');
echo Html::tag('hr');
?>
<?php
echo Html::style('.username{color:red;font-size:8px;}');
echo Html::script('alert("script is test")', ['defer' => true]);
echo Html::tag('br/');
echo Html::cssFile('@web/css/ie5.css', ['condition' => 'IE 5']);
echo Html::jsFile('@web/js/main.js');
echo Html::a('超链接', ['home/list', 'id' => 12], ['class' => 'link']);
echo Html::mailto('Contact Us', 'xingcuntian@163.com');
echo Html::img('@web/images/logo.png', ['alt' => 'logo']);
?>
<hr/>
<?php
echo Html::beginForm(['home/add', 'id' => $id], 'post', ['enctype' => 'multipart/form-data']);
echo Html::input('text', 'username', 'name', ['class' => 'name']);
echo Html::radio('agree', true, ['label' => 'this is radio']);
echo Html::checkbox('agree', true, ['label' => 'this is checkbox']);
?>
<?php