public function run() { $modelId = $this->model->isNewRecord ? uniqid() : $this->model->getId(); $this->options = array_merge($this->_options, $this->options); $this->options['toolbarFixed'] = true; $this->options['toolbarFixedTarget'] = '#' . $this->htmlOptions['id']; $this->htmlOptions = array_merge($this->_htmlOptions, $this->htmlOptions); $buttonParam = isset($this->options['airButtons']) && $this->options['airButtons'] == true ? 'airButtons' : 'buttons'; $this->plugins = ['fullscreen', 'fontcolor', 'fontsize']; switch ($this->toolbarSize) { case 'full': $this->options[$buttonParam] = ['html', 'formatting', '|', 'bold', 'italic', 'underline', 'deleted', 'fontsize', 'fontcolor', 'backcolor', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'image', 'video', 'file', 'table', 'link', 'alignment', 'horizontalrule']; break; case 'medium': $this->options[$buttonParam] = ['bold', 'italic', 'underline', 'deleted', 'fontsize', 'fontcolor', 'backcolor', '|', 'unorderedlist', 'orderedlist', '|', 'image', 'video', 'file', 'table', 'link']; break; default: $this->options[$buttonParam] = ['bold', 'italic', 'underline', 'deleted', 'link']; break; } switch ($this->size) { case 'full': $this->htmlOptions['style'] = "height: 100%"; break; case 'large': $this->htmlOptions['rows'] = 12; break; case 'medium': $this->htmlOptions['rows'] = 6; break; default: $this->htmlOptions['rows'] = 3; break; } if ($this->enableFiles) { array_push($this->plugins, 'imagemanager', 'filemanager'); $this->options['imageUpload'] = ArrayHelper::getValue($this->options, 'imageUpload', '/image/save/' . $this->model->isWHat() . '/' . $modelId); $this->options['imageManagerJson'] = json_encode(array_map(function ($image) { if (is_array($image)) { return ['thumb' => $image['metadata']['thumb'], 'image' => $image['url'], 'title' => $image['title']]; } }, (array) \nitm\filemanager\models\Image::getImagesFor($this->model, true)->asArray()->all())); $this->options['fileUpload'] = ArrayHelper::getValue($this->options, 'fileUpload', '/file/save/' . $this->model->isWHat() . '/' . $modelId); $this->options['fileManagerJson'] = json_encode(array_map(function ($file) { if (is_array($file)) { return ['name' => $file['metadata']['thumb'], 'image' => $file['url'], 'name' => $file['file_name'], 'title' => $file['title'], 'size' => \Yii::$app->formatter->asShortSize($file['size'])]; } }, (array) \nitm\filemanager\models\File::getFilesFor($this->model, true)->asArray()->all())); } $this->htmlOptions['role'] = $this->role; return parent::run() . \yii\helpers\Html::style("#redactor_modal_overlay, #redactor_modal, .redactor_dropdown {z-index: 10000 !important;}"); }
/** * * @param \yii\web\Application $app * @see \yii\base\BootstrapInterface::bootstrap() */ public function initTheme() { if (($themeId = \Yii::$app->getRequest()->get("theme", null)) != null) { \Yii::$app->getUrlManager()->on(UrlManager::EVENT_CREATE_PARAMS, function ($event) use($themeId) { $event->urlParams = array_merge(["theme" => $themeId], (array) $event->urlParams); }); } else { $themeId = \Yii::$app->get("themeManager")->getDefaultThemeId(); } /** @var \hass\theme\classes\ThemeInfo $themeInfo */ $themeInfo = \Yii::$app->get("themeManager")->findOne($themeId); $package = $themeInfo->getPackage(); $config = []; if (!empty($css = \Yii::$app->get("themeManager")->getCustomCss($package))) { $config["css"] = [md5($css) => Html::style($css)]; } $config["theme"] = ['package' => $package, 'class' => '\\hass\\frontend\\components\\Theme', 'assetClass' => $themeInfo->getAssetClass(), 'pathMap' => $themeInfo->getPathMap()]; Util::setComponent("view", $config, true); $theme = $themeInfo->createEntity(); if ($theme instanceof BootstrapInterface) { $theme->bootstrap(\Yii::$app); } }
public function testStyle() { $content = 'a <>'; $this->assertEquals("<style>{$content}</style>", Html::style($content)); $this->assertEquals("<style type=\"text/less\">{$content}</style>", Html::style($content, ['type' => 'text/less'])); }
/** * Registers a CSS code block. * @param string $css the content of the CSS code block to be registered * @param array $options the HTML attributes for the `<style>`-tag. * @param string $key the key that identifies the CSS code block. If null, it will use * $css as the key. If two CSS code blocks are registered with the same key, the latter * will overwrite the former. */ public function registerCss($css, $options = [], $key = null) { $key = $key ?: md5($css); $this->css[$key] = Html::style($css, $options); }
/** * Generate default messages */ public function generateMessages() { if (!isset($this->footerMessage)) { $this->footerMessage = $this->getFooterMessage(); } if (!isset($this->emptyPreview)) { $this->emptyPreview = '<p class="help-block text-center">' . Yii::t('markdown', 'No content to display') . '</p>'; } $exportAlert = 'Your {type} file will be generated and downloaded as {filename}.'; $popupAlert = Yii::t('markdown', 'Disable any popup blockers in your browser to ensure proper download.'); if (empty($this->exportFileName)) { $this->exportFileName = Yii::t('markdown', 'markdown-export'); } if (!isset($this->exportTextAlert)) { $this->exportTextAlert = Yii::t('markdown', $exportAlert, ['type' => Yii::t('markdown', 'TEXT'), 'filename' => $this->exportFileName . '.txt']) . "\n\n" . $popupAlert; } if (!isset($this->exportHtmlAlert)) { $this->exportHtmlAlert = Yii::t('markdown', $exportAlert, ['type' => Yii::t('markdown', 'HTML'), 'filename' => $this->exportFileName . '.htm']) . "\n\n" . $popupAlert; } if (!isset($this->exportHeader)) { $this->exportHeader = "> - - -\n> " . Yii::t('markdown', "Markdown Export{line} *Generated {date} by {class}", ['line' => "\n> ===============\n>", 'date' => date("d-M-Y H:i"), 'class' => "\\kartik\\markdown\\MarkdownEditor*\n> - - -\n\n"]); } if (!isset($this->exportCss)) { $this->exportCss = Html::cssFile($this->bootstrapCssFile) . "\n" . Html::style('body{margin:20px;padding:20px;border:1px solid #ddd;border-radius:5px;}' . 'th[align="right"]{text-align:right!important;}' . 'th[align="center"]{text-align:center!important;}'); } if (!isset($this->previewProgress)) { $this->previewProgress = '<div class="kv-loading">' . Yii::t('markdown', 'Loading Preview') . ' …</div>'; } }
Html::removeCssClass($options, 'btn-default'); Html::addCssClass($options, 'btn-success'); } 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', '*****@*****.**'); 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']);