本文整理汇总了PHP中yii\helpers\Html::renderTagAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::renderTagAttributes方法的具体用法?PHP Html::renderTagAttributes怎么用?PHP Html::renderTagAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::renderTagAttributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderItem
/**
* Renders the content of a menu item.
* Note that the container and the sub-menus are not rendered here.
* @param array $item the menu item to be rendered. Please refer to [[items]] to see what data might be in the item.
* @return string the rendering result
*/
protected function renderItem($item)
{
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
if (isset($item['url'])) {
$template = ArrayHelper::getValue($item, 'template', $this->linkTemplate);
return strtr($template, ['{url}' => Html::encode(Url::to($item['url'])), '{label}' => $item['label'], '{attr}' => Html::renderTagAttributes($linkOptions)]);
} else {
$template = ArrayHelper::getValue($item, 'template', $this->labelTemplate);
return strtr($template, ['{label}' => $item['label'], '{attr}' => Html::renderTagAttributes($linkOptions)]);
}
}
示例2: run
public function run()
{
$id = $this->getId();
if (isset($this->options['id']) and !empty($this->options['id'])) {
$id = $this->options['id'];
}
// if no container is set, it will create one
if ($this->containerId === null) {
$this->htmlOptions['id'] = 'div-chart' . $id;
$this->containerId = $this->htmlOptions['id'];
echo '<div ' . Html::renderTagAttributes($this->htmlOptions) . '></div>';
}
$this->registerClientScript($id);
}
示例3: init
public function init()
{
if (!isset($this->options['id'])) {
$this->_cid = $this->options['id'] = 'tilec_' . $this->getId();
}
$collapseTag = 'collapse';
Html::addCssClass($this->options, 'box');
Html::addCssClass($this->options, 'box-solid');
Html::addCssClass($this->options, 'bg-' . $this->type);
if ($this->collapse and $this->collapseDefault and !$this->collapse_remember) {
Html::addCssClass($this->options, 'collapsed-box');
}
$this->registerJs();
echo '<div ' . Html::renderTagAttributes($this->options) . '>' . (!$this->title && !$this->collapse && !$this->custom_tools && !$this->left_tools ? '' : '<div class="box-header"' . (!$this->tooltip ? '' : 'data-toggle="tooltip" data-original-title="' . $this->tooltip . '" data-placement="' . $this->tooltip_placement . '"') . '>' . (!$this->left_tools ? '' : '<div class="box-tools pull-left">' . $this->left_tools . '</div>') . (!$this->title ? '' : '<h3 class="box-title">' . $this->title . '</h3>') . (!$this->collapse ? '' : (!$this->custom_tools ? '<div class="box-tools pull-right"><button class="btn btn-primary btn-xs" data-widget="' . $collapseTag . '" id="' . $this->_cid . '_btn"><i class="fa fa-minus"></i></button></div>' : '')) . (!$this->custom_tools ? '' : '<div class="box-tools pull-right">' . $this->custom_tools . (!$this->collapse ? '' : '<button class="btn btn-primary btn-xs" data-widget="' . $collapseTag . '" id="' . $this->_cid . '_btn">
<i class="fa fa-minus"></i></button>') . '</div>') . '</div>') . '<div class="box-body">';
}
示例4: run
public function run()
{
$boxContent = ob_get_clean();
$boxTitle = $this->title ? strtr($this->titleTemplate, ['{title}' => $this->title]) : '';
Html::addCssClass($this->options, 'box');
if ($this->cssClass) {
Html::addCssClass($this->options, $this->cssClass);
}
if ($this->_hasBody == false) {
ob_start();
$this->beginBody();
echo $boxContent;
$this->endBody();
$boxContent = ob_get_clean();
}
echo strtr($this->template, ['{options}' => Html::renderTagAttributes($this->options), '{title}' => $boxTitle, '{content}' => $boxContent]);
}
示例5: buildTree
/**
* Create tree.
* @param array $rows
* @param int $parent_id
* @return string tree
*/
private function buildTree($rows, $parent_id = 0)
{
$containerAttributes = '';
if (!$this->containerOptionsIsSet) {
$containerAttributes = Html::renderTagAttributes($this->containerOptions);
$this->containerOptionsIsSet = true;
}
$result = "<ul{$containerAttributes}>";
foreach ($rows as $row) {
if ($row['parent_id'] == $parent_id) {
$value = call_user_func_array($this->value, ['model' => $row['model']]);
$result .= "<li>{$value}";
if ($this->hasChild($rows, $row['id'])) {
$result .= $this->buildTree($rows, $row['id']);
}
$result .= '</li>';
}
}
$result .= '</ul>';
return $result;
}
示例6: renderItem
/**
* {@inheritdoc}
*/
protected function renderItem($item)
{
return strtr(ArrayHelper::getValue($item, 'template', isset($item['url']) ? $this->linkTemplate : $this->labelTemplate), ['{url}' => isset($item['url']) ? Url::to($item['url']) : null, '{icon}' => $item['icon'] === false ? '' : sprintf('<i class="%s"></i>', static::iconClass($item['icon'] ?: $this->defaultIcon)), '{label}' => $item['label'], '{arrow}' => !empty($item['items']) ? '<i class="fa pull-right fa-angle-left"></i>' : '', '{linkOptions}' => Html::renderTagAttributes(ArrayHelper::getValue($item, 'linkOptions', []))]);
}
示例7: renderAttribute
/**
* Renders a single attribute.
* @param array $attribute the specification of the attribute to be rendered.
* @param integer $index the zero-based index of the attribute in the [[attributes]] array
* @return string the rendering result
*/
protected function renderAttribute($attribute, $index)
{
if ($attribute['value'] === '') {
return '';
}
$template = ArrayHelper::getValue($attribute, 'template', $this->template);
if (is_string($template)) {
if (isset($attribute['label'])) {
return strtr($template, ['{label}' => $attribute['label'], '{options}' => Html::renderTagAttributes($attribute['options']), '{rawValue}' => $attribute['value'], '{value}' => $this->formatter->format($attribute['value'], $attribute['format'])]);
} else {
return strtr($template, ['{value}' => $this->formatter->format($attribute['value'], $attribute['format'])]);
}
} else {
return call_user_func($template, $attribute, $index, $this);
}
}
示例8: renderItem
/**
* @inheritdoc
*/
protected function renderItem($item)
{
$item['badgeOptions'] = isset($item['badgeOptions']) ? $item['badgeOptions'] : [];
if (!ArrayHelper::getValue($item, 'badgeOptions.class')) {
$bg = isset($item['badgeBgClass']) ? $item['badgeBgClass'] : $this->badgeBgClass;
$item['badgeOptions']['class'] = $this->badgeClass . ' ' . $bg;
}
if (isset($item['items']) && !isset($item['right-icon'])) {
$item['right-icon'] = $this->parentRightIcon;
}
if (isset($item['url'])) {
$template = ArrayHelper::getValue($item, 'template', $this->linkTemplate);
return strtr($template, ['{badge}' => isset($item['badge']) ? Html::tag('small', $item['badge'], $item['badgeOptions']) : '', '{icon}' => isset($item['icon']) ? $item['icon'] : '', '{right-icon}' => isset($item['right-icon']) ? $item['right-icon'] : '', '{url}' => Url::to($item['url']), '{label}' => $item['label'], '{linkOptions}' => isset($item['linkOptions']) ? Html::renderTagAttributes($item['linkOptions']) : '']);
} else {
$template = ArrayHelper::getValue($item, 'template', $this->labelTemplate);
return strtr($template, ['{badge}' => isset($item['badge']) ? Html::tag('small', $item['badge'], $item['badgeOptions']) : '', '{icon}' => isset($item['icon']) ? $item['icon'] : '', '{right-icon}' => isset($item['right-icon']) ? $item['right-icon'] : '', '{label}' => $item['label'], '{linkOptions}' => isset($item['linkOptions']) ? Html::renderTagAttributes($item['linkOptions']) : '']);
}
}
示例9:
<?php
/** @var \yii\web\View $this */
/** @var \bedezign\yii2\desktop\Shortcut $shortcut */
/** @var int $x */
/** @var int $y */
$icon = $shortcut->icon->render(\bedezign\yii2\desktop\Icon::DISPLAY_DESKTOP);
$anchor = \yii\helpers\ArrayHelper::merge(['id' => $shortcut->id, 'style' => "left: {$x}px; top: {$y}px", 'class' => 'application_shortcut'], $shortcut->anchor);
?>
<a <?php
echo \yii\helpers\Html::renderTagAttributes($anchor);
?>
>
<?php
echo $icon;
?>
<?php
if ($shortcut->title) {
?>
<span class="title"><?php
echo $shortcut->title;
?>
</span><?php
}
?>
</a>
示例10: run
/**
* Executes the widget.
* This method registers all needed client scripts and renders
* the text field.
*/
public function run()
{
$uploadDir = \Yii::$app->urlManager->baseUrl . '/uploads';
$id = $this->options['id'];
if (isset($this->options['name'])) {
$name = $this->options['name'];
}
if ($this->sizeValidate !== array() and isset($this->sizeValidate['width'], $this->sizeValidate['height'])) {
$this->width = $this->sizeValidate['width'];
$this->height = $this->sizeValidate['height'];
$textSmall = strtr($this->templateSmall, array('{width}' => $this->sizeValidate['width'], '{height}' => $this->sizeValidate['height']));
echo '<small class="text-muted">' . $textSmall . '</small>';
}
$img = '';
if (!$this->model->isNewRecord and !empty($this->model->{$this->attribute})) {
$img = "<img id=\"jcrop_target{$id}\" class=\"img-responsive img-rounded\" src=\"{$uploadDir}/{$this->model->{$this->attribute}}\" alt=\"\">";
}
$arrayFile = explode('.', $this->model->{$this->attribute});
$ext = end($arrayFile);
if (isset($this->iconExtensions[$ext])) {
$filenamePreview = $this->iconExtensions[$ext];
$img = "<div class=\"text-center\"><a href=\"{$uploadDir}/{$this->model->{$this->attribute}}\" target=\"_blank\"><i class=\"{$filenamePreview}\"></i></a></div>";
}
if (isset($this->imgContainerOptions['class'])) {
$this->imgContainerOptions['class'] = $this->imgContainerOptions['class'] . " {$this->containerCss} {$id}_img text-center";
} else {
$this->imgContainerOptions['class'] = "{$this->containerCss} {$id}_img text-center";
}
$this->imgContainerOptions['data-url'] = "{$uploadDir}";
$icon = "";
if ($this->iconButtom !== false) {
$icon = "<i class=\"fa {$this->iconButtom} mtl\" style=\"font-size: 10em;color: #f0f0f0\"></i>";
}
if (!$this->model->isNewRecord and !empty($this->model->{$this->attribute})) {
$icon = "";
}
echo "<div class=\"tile qq-upload-extra-drop-area\">\n <div" . Html::renderTagAttributes($this->imgContainerOptions) . ">\n {$img}\n {$icon}\n </div>\n <div id=\"{$id}_link\"></div>\n </div>";
if ($this->hasModel()) {
echo Html::activeHiddenInput($this->model, $this->attribute, $this->options);
} else {
echo Html::hiddenInput($this->name, $this->value, $this->options);
}
$this->registerClientScript();
}
示例11: getHtmlOptions
/**
* Retrieves Html options
* @param string $tag given tag
* @param boolean $asString if return as string
* @return type
*/
public static function getHtmlOptions($tag, $options = [], $asString = false)
{
$callback = sprintf('static::_%sOptions', strtolower($tag));
$htmlOptions = call_user_func($callback, $options);
return $asString ? Html::renderTagAttributes($htmlOptions) : $htmlOptions;
}
示例12: renderAttribute
/**
* Renders a single attribute.
* @param array $attribute the specification of the attribute to be rendered.
* @param integer $index the zero-based index of the attribute in the [[attributes]] array
* @return string the rendering result
*/
protected function renderAttribute($attribute, $index)
{
if (is_string($this->template)) {
$captionOptions = Html::renderTagAttributes(ArrayHelper::getValue($attribute, 'captionOptions', []));
$contentOptions = Html::renderTagAttributes(ArrayHelper::getValue($attribute, 'contentOptions', []));
return strtr($this->template, ['{label}' => $attribute['label'], '{value}' => $this->formatter->format($attribute['value'], $attribute['format']), '{captionOptions}' => $captionOptions, '{contentOptions}' => $contentOptions]);
} else {
return call_user_func($this->template, $attribute, $index, $this);
}
}
示例13: sortLink
Translation\backend\assets\ListAssetBundle::register($this);
/**
* @param string $type
* @param string $label
* @return string
*/
function sortLink($type, $label)
{
$label .= ' ' . FA::icon('sort-numeric-desc', ['ng-show' => 'pages.sort.order === "-' . $type . '"']);
$label .= ' ' . FA::icon('sort-numeric-asc', ['ng-show' => 'pages.sort.order === "' . $type . '"']);
return Html::a($label, null, ['ng-click' => 'pages.sort.setOrder("' . $type . '")']);
}
?>
<section <?php
echo Html::renderTagAttributes(['class' => 'content', 'ng-controller' => 'translation.ListController']);
?>
>
<div class="row">
<div class="col-xs-3 com-sm-3 col-md-3 col-lg-2">
<div class="box-filter">
<h3><?php
echo Yii::t('cookyii', 'Filter');
?>
</h3>
<hr>
<?php
echo Html::tag('a', FA::icon('check') . ' ' . Yii::t('cookyii.translation', 'Translated'), ['class' => 'checker', 'ng-click' => 'filter.toggleTranslated()', 'ng-class' => Json::encode(['checked' => new \yii\web\JsExpression('filter.translated === true')])]);
?>
示例14:
if (Yii::$app->user->identity->isAdmin) {
?>
<li class="list-group-item">
<?php
echo ButtonLink::widget(['label' => $user->account->getIsBlocked() ? '<i class="fa fa-fw fa-unlock"></i> ' . Yii::t('app', 'Unblock') : '<i class="fa fa-fw fa-lock"></i> ' . Yii::t('app', 'Block'), 'encodeLabel' => false, 'type' => $user->account->getIsBlocked() ? 'primary' : 'danger', 'url' => ['/accounts/block', 'id' => $user->account->id], 'options' => ['class' => 'btn-block', 'data-method' => 'post', 'data-confirm' => Yii::t('user', 'Are you sure you want to block this user?')]]);
?>
</li>
<?php
}
?>
</ul>
</div>
</div>
<div class="col-md-4">
<div <?php
echo Html::renderTagAttributes(['class' => 'panel ' . ($user->Blocked ? 'panel-danger' : 'panel-success')]);
?>
>
<div class="panel-heading">
<h2 class="panel-title">
<?php
if ($user->group->IsService) {
?>
<i class="fa fa-fw fa-user-md" aria-hidden="true"></i>
<?php
} else {
?>
<i class="fa fa-fw fa-user" aria-hidden="true"></i>
<?php
}
?>
示例15:
$title = $application->title;
$icon = $application->icon->render(\bedezign\yii2\desktop\Icon::DISPLAY_TITLEBAR);
$attributes = ['id' => 'window_' . $application->applicationId, 'class' => 'application_window absolute'];
if ($application->windowState) {
Html::addCssStyle($attributes, $application->windowState);
}
if ($application->windowMaximised) {
Html::addCssClass($attributes, 'window_maximized');
}
if ($application->sessionData) {
$attributes['data-desktop-session'] = \yii\helpers\Json::encode($application->sessionData);
}
?>
<div <?php
echo Html::renderTagAttributes($attributes);
?>
>
<div class="window_titlebar">
<?php
echo $icon;
?>
<div class="window_title"><?php
echo $title;
?>
</div>
<div class="window_buttons">
<a href="#" class="window_button minimize"></a>
<a href="#" class="window_button maximize"></a>
<a href="#<?php
echo $application->applicationId;