本文整理汇总了PHP中yii\helpers\Html::tag方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::tag方法的具体用法?PHP Html::tag怎么用?PHP Html::tag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::tag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* Lists all Articlecomment models.
* @return mixed
*/
public function actionIndex()
{
$list = '';
$post = Yii::$app->request->post();
if ($post['id']) {
$mod = new Query();
$comment = $mod->select(['a.id', 'a.parentId', 'a.articleId', 'a.content', 'a.createTime', 'b.username'])->from('articlecomment as a')->leftJoin('user as b', 'a.userId = b.id')->where(['commentId' => $post['id']])->orderBy(['createTime' => 'DESC', 'id' => 'DESC'])->createCommand()->queryAll();
if ($comment) {
foreach ($comment as $v) {
$content = '回复@' . Articlecomment::getCommentByParId($v['parentId']) . ':' . $v['content'];
$ahtml = html::a(html::tag("i", "", ["class" => "fa fa-thumbs-o-up"]) . html::tag("span", "回复"), ["/main/viewart", "id" => $v["articleId"], "parId" => $v['id']]);
$list .= '<div class="infos small-comment' . $post['id'] . '" style="border:1px solid;">
<div class="media-body markdown-reply content-body">
<p>' . $content . '</p>
<span class="opts pull-right">
<a class="author" >' . $v["username"] . '</a>
•
<addr title="' . $v["createTime"] . '">' . Html::tag("span", Yii::$app->formatter->asRelativeTime($v["createTime"])) . '</addr>
' . $ahtml . '
</span>
</div>
</div>';
}
}
}
$result = array('success' => true, 'message' => $list);
echo json_encode($result);
die;
return $this->renderAjax('index', ['success' => true, 'message' => '']);
}
示例2: defaultColumns
public static function defaultColumns()
{
return ['fqdn' => ['attribute' => 'fqdn', 'value' => function ($model) {
return $model->fqdn;
}], 'type' => ['value' => function ($model) {
return strtoupper($model->type);
}], 'value' => ['value' => function ($model) {
return $model->getValueText();
}], 'zone' => ['class' => MainColumn::className(), 'label' => Yii::t('hipanel:dns', 'Zone'), 'attribute' => 'name'], 'actions' => ['class' => ActionColumn::className(), 'template' => '{update} {delete}', 'visibleButtonsCount' => 2, 'options' => ['style' => 'width: 15%'], 'buttons' => ['update' => function ($url, $model, $key) {
if ($model->is_system) {
return Html::tag('div', Html::a('<i class="fa fa-pencil"></i> ' . Yii::t('hipanel', 'Update'), null, ['class' => 'btn btn-default btn-xs disabled']), ['data-placement' => 'top', 'data-toggle' => 'tooltip', 'title' => Yii::t('hipanel:dns', 'This record was created by hosting panel automatically and cannot be updated'), 'style' => 'display: inline-block; cursor: not-allowed;']);
}
$data = Html::a('<i class="fa fa-pencil"></i> ' . Yii::t('hipanel', 'Update'), null, ['class' => 'btn btn-default btn-xs edit-dns-toggle', 'data' => ['record_id' => $model->id, 'hdomain_id' => $model->hdomain_id, 'load-url' => Url::to(['@dns/record/update', 'hdomain_id' => $model->hdomain_id, 'id' => $model->id])]]);
$progress = Json::htmlEncode("<tr><td colspan='5'>" . Progress::widget(['id' => 'progress-bar', 'percent' => 100, 'barOptions' => ['class' => 'active progress-bar-striped', 'style' => 'width: 100%']]) . '</td></tr>');
Yii::$app->view->registerJs("\n \$('.edit-dns-toggle').click(function () {\n var record_id = \$(this).data('id');\n var hdomain_id = \$(this).data('hdomain_id');\n\n var currentRow = \$(this).closest('tr');\n var newRow = \$({$progress});\n\n \$(newRow).data({'record_id': record_id, hdomain_id: hdomain_id});\n \$('tr').filter(function () { return \$(this).data('id') == record_id; }).find('.btn-cancel').click();\n \$(newRow).insertAfter(currentRow);\n\n jQuery.ajax({\n url: \$(this).data('load-url'),\n type: 'GET',\n timeout: 0,\n error: function() {\n\n },\n success: function(data) {\n newRow.find('td').html(data);\n newRow.find('.btn-cancel').on('click', function (event) {\n event.preventDefault();\n newRow.remove();\n });\n }\n });\n\n });\n ");
return $data;
}, 'delete' => function ($url, $model, $key) {
if ($model->type === 'ns' && $model->is_system) {
return Html::tag('div', Html::a('<i class="fa text-danger fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete'), null, ['class' => 'btn btn-default btn-xs disabled']), ['data-placement' => 'top', 'data-toggle' => 'tooltip', 'title' => Yii::t('hipanel:dns', 'This record is important for the domain zone viability and can not be deleted'), 'style' => 'display: inline-block; cursor: not-allowed;']);
}
return ModalButton::widget(['model' => $model, 'scenario' => 'delete', 'submit' => ModalButton::SUBMIT_PJAX, 'form' => ['action' => Url::to('@dns/record/delete')], 'button' => ['class' => 'btn btn-default btn-xs', 'label' => '<i class="fa text-danger fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete')], 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:dns', 'Confirm DNS record deleting')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => ['label' => Yii::t('hipanel:dns', 'Delete record'), 'data-loading-text' => Yii::t('hipanel:dns', 'Deleting record...'), 'class' => 'btn btn-danger']], 'body' => function ($model) {
echo Html::activeHiddenInput($model, 'hdomain_id');
echo Yii::t('hipanel:dns', 'Are you sure, that you want to delete record {name}?', ['name' => $model->fqdn]);
}]);
}]]];
}
示例3: run
/**
* @inheritdoc
*/
public function run()
{
$view = $this->getView();
$kcfinder = KCFinderAsset::register($view);
if ($this->hasModel()) {
if (!empty($this->model->icon)) {
$this->src = $this->model->icon;
}
}
//$this->options = array_merge($this->options, ['onclick'=>'openKCFinder(this);']);
echo Html::tag('div', Html::img($this->src, ['id' => $this->widget['id'] . '-preview', 'class' => 'img-responsive']), ['class' => 'well well-sm text-center', 'style' => 'margin:5px;']);
echo '<div class="input-group">';
if ($this->hasModel()) {
echo Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
echo Html::textInput($this->name, $this->value, $this->options);
}
echo '<span class="input-group-btn"><button type="button" class="btn btn-default btn-flat" id="' . $this->widget['id'] . '-btn-clear"><i class="glyphicon glyphicon-remove"></i></button></span>';
echo '<span class="input-group-btn"><button type="button" class="btn btn-default btn-flat" id="' . $this->widget['id'] . '-btn-browse"><i class="glyphicon glyphicon-folder-open"></i></button></span>';
echo '</div>';
$session = Yii::$app->session;
if (!$session->has('KCFINDER')) {
$session->set('KCFINDER', ['disabled' => false, 'uploadDir' => $this->uploadDir, 'uploadURL' => $this->uploadURL]);
$htSource = __DIR__ . '/upload.htaccess';
$htDest = $kcfinder->basePath . '/conf/upload.htaccess';
copy($htSource, $htDest);
}
$this->registerJs();
}
示例4: run
public function run()
{
BowerAssets::register($this->getView());
$this->jsOption = \yii\helpers\Json::encode($this->jsOption);
$this->getView()->registerJs("\$('#{$this->getId()}').highcharts({$this->jsOption});");
return \yii\helpers\Html::tag('div', '', \yii\helpers\ArrayHelper::merge($this->option, ['id' => $this->getId()]));
}
示例5: renderOp
public static function renderOp($op)
{
$map = ['add' => 'success', 'replace' => 'warning', 'remove' => 'danger'];
$class = isset($map[$op]) ? $map[$op] : 'default';
$content = $op;
return Html::tag('span', $content, ['class' => 'label label-' . $class]);
}
示例6: run
public function run()
{
if (empty($this->name) && (!empty($this->model) && !empty($this->attribute))) {
$this->name = Html::getInputName($this->model, $this->attribute);
}
if (empty($this->url)) {
$this->url = Url::toRoute(['site/upload']);
}
$options = ['url' => $this->url, 'paramName' => $this->name, 'params' => []];
if (Yii::$app->request->enableCsrfValidation) {
$options['params'][Yii::$app->request->csrfParam] = Yii::$app->request->getCsrfToken();
}
if (!empty($this->message)) {
$message = Html::tag('div', $this->message, $this->messageOptions);
} else {
$message = '';
}
$this->htmlOptions['id'] = $this->id;
$this->options = ArrayHelper::merge($this->options, $options);
echo Html::tag('div', $message, $this->htmlOptions);
$this->registerAssets();
$this->createDropzone();
foreach ($this->eventHandlers as $event => $handler) {
$handler = new \yii\web\JsExpression($handler);
$this->getView()->registerJs($this->dropzoneName . ".on('{$event}', {$handler})");
}
$this->addFiles($this->storedFiles);
$this->decrementMaxFiles(count($this->storedFiles));
if ($this->sortable) {
$options = Json::encode($this->sortableOptions);
$this->getView()->registerJs("jQuery('#{$this->id}').sortable(" . $options . ");");
}
}
示例7: run
public function run()
{
if ($this->hasModel()) {
$replace['{input}'] = Html::activeHiddenInput($this->model, $this->attribute, $this->options);
$attributeId = Html::getInputId($this->model, $this->attribute);
$id = Html::getInputId($this->model, 'hydra_' . $this->attribute);
$name = Html::getInputName($this->model, 'hydra_' . $this->attribute);
$this->value = $this->model[$this->attribute];
} else {
$replace['{input}'] = Html::hiddenInput($this->name, $this->value, $this->options);
$name = $id = 'hydra_' . $this->name;
$attributeId = $this->name;
}
$fileInputName = empty($this->fileInputName) ? $name : $this->fileInputName;
$replace['{preview}'] = 'Файл еще не загружен';
if (!empty($this->value)) {
$replace['{preview}'] = $this->value;
$extension = Yii::$app->hydra->getExtension($this->value);
if (Yii::$app->hydra->isImage($extension)) {
$replace['{preview}'] = Html::img(Yii::$app->hydra->getCacheUrl($this->value, $this->resolution), ['id' => $id . '_image']);
}
$replace['{reset-button}'] = Html::tag($this->resetButton['tag'], $this->resetButton['label'], ArrayHelper::merge(['onClick' => '$("#' . $attributeId . '").val("");$("#' . $id . '_image' . '").remove();$(this).remove();'], $this->resetButton['options']));
}
$replace['{input}'] .= Html::fileInput($fileInputName, null, ArrayHelper::merge(['id' => $id], $this->fileInput['options']));
return strtr($this->template, $replace);
}
示例8: run
/**
* @inheritdoc
*/
public function run()
{
echo Html::tag('div', null, ['id' => $this->containerId, 'style' => 'display:none']);
$view = $this->getView();
PushStreamAsset::register($view);
$options = Json::encode($this->pluginOptions);
$channels = '';
foreach ((array) $this->channels as $channel) {
$channels .= $this->pusher . ".addChannel('{$channel}');";
}
$js = <<<JS
var {$this->pusher} = new PushStream({$options});
{$channels}
{$this->pusher}.onmessage = function (text, id, channel) {
\$.each(text.events, function (index, event) {
\$('#{$this->containerId}').trigger({
channel: channel,
type: event.name,
body: event.body
});
});
};
JS;
if ($this->connect) {
$js .= $this->pusher . '.connect();';
}
$view->registerJs($js);
}
示例9: renderItem
public function renderItem($model, $key, $index)
{
if ($this->itemView === null) {
$content = $key;
} elseif (is_string($this->itemView)) {
$content = $this->getView()->render($this->itemView, array_merge(['model' => $model, 'key' => $key, 'index' => $index, 'widget' => $this, 'user' => $this->user], $this->viewParams));
} else {
$content = call_user_func($this->itemView, $model, $key, $index, $this);
}
$options = $this->itemOptions;
$tag = ArrayHelper::remove($options, 'tag', 'div');
if ($tag !== false) {
$options['data-key'] = is_array($key) ? json_encode($key, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : (string) $key;
$options['data-contact'] = $model['contact_id'];
if (isset($this->clientOptions['unreadCssClass'])) {
if ($model['new_messages'] > 0) {
Html::addCssClass($options, $this->clientOptions['unreadCssClass']);
}
}
if (isset($this->clientOptions['currentCssClass'])) {
if ($model['contact_id'] == \Yii::$app->request->get('contactId')) {
Html::addCssClass($options, $this->clientOptions['currentCssClass']);
}
}
return Html::tag($tag, $content, $options);
} else {
return $content;
}
}
示例10: run
public function run()
{
// Get the JSON string
$jsonstring = $_GET['jsonstring'];
// Decode it into an array
$jsonDecoded = json_decode($jsonstring, true, 64);
// Run the function above
$readbleArray = $this->parseJsonArray($jsonDecoded);
// Loop through the "readable" array and save changes to DB
foreach ($readbleArray as $key => $value) {
// $value should always be an array, but we do a check
if (is_array($value)) {
$modelclass = $this->modelclass;
$pks = (array) $modelclass::primaryKey();
$model = $modelclass::find()->where([join(',', $pks) => $value['id']])->one();
if ($this->scenario) {
$model->setScenario($this->scenario);
}
$model->{$this->orderBy} = $key;
$model->{$this->parentId} = $value['parentID'];
$model->save(false);
}
}
// Echo status message for the update
echo Html::tag('div', Yii::t('claudejanz', "Order Updated on {date}", ['date' => Yii::$app->formatter->asDatetime(time())]), ['class' => 'alert alert-success']);
}
示例11: run
/**
* @inheritdoc
*/
public function run()
{
echo Html::beginTag('div', $this->options);
echo Html::tag('div', $this->content, ['class' => 'ui sticky']);
echo Html::endTag('div');
$this->registerPlugin('sticky');
}
示例12: run
/**
* @return string
*/
public function run()
{
if (YII_ENV == 'prod') {
try {
\Yii::beginProfile("Run: " . $this->_token);
$content = $this->_run();
\Yii::endProfile("Run: " . $this->_token);
} catch (\Exception $e) {
$content = \Yii::t('app', 'Error widget {class}', ['class' => $this->className()]) . " (" . $this->descriptor->name . "): " . $e->getMessage();
}
} else {
\Yii::beginProfile("Run: " . $this->_token);
$content = $this->_run();
\Yii::endProfile("Run: " . $this->_token);
}
\Yii::$app->cmsToolbar->initEnabled();
if (\Yii::$app->cmsToolbar->editWidgets == Cms::BOOL_Y && \Yii::$app->cmsToolbar->enabled) {
$pre = "";
/*$pre = Html::tag('pre', Json::encode($this->attributes), [
'style' => 'display: none;'
]);*/
$id = 'sx-infoblock-' . $this->getId();
$this->getView()->registerJs(<<<JS
new sx.classes.toolbar.EditViewBlock({'id' : '{$id}'});
JS
);
return Html::tag('div', $pre . (string) $content, ['class' => 'skeeks-cms-toolbar-edit-view-block', 'id' => $id, 'title' => \Yii::t('app', "Double-click on the block will open the settings manager"), 'data' => ['id' => $this->getId(), 'config-url' => $this->getEditUrl()]]);
}
return $content;
}
示例13: run
public function run()
{
$blockId = 'block_' . $this->id;
$this->view->beginBlock($blockId);
$inputFile = InputFile::begin(ArrayHelper::merge(['model' => $this->model, 'attribute' => $this->attribute, 'name' => $this->name, 'value' => $this->value], $this->fileInputOptions));
$inputId = $inputFile->options['id'];
$previewId = 'media-' . $inputId;
InputFile::end();
$this->view->endBlock();
$replace['{input}'] = $this->view->blocks[$blockId];
$replace['{img}'] = Html::tag('div', '', ['class' => 'form-media-preview', 'id' => $previewId]);
echo strtr($this->template, $replace);
$this->view->registerJs(<<<JS
\$('#{$inputId}').change(function() {
var src = \$(this).val();
if (src != '') {
var img = \$('<img/>').attr('src', src);
\$('#{$previewId}').wrapInner(img);
} else {
\$('#{$previewId}').empty();
}
}).change();
JS
);
}
示例14: renderReloader
protected function renderReloader()
{
$text = Html::tag('p', 'На изображении плохо видно буквы?');
$link = Html::tag('p', 'Нажмите сюда для обновления.', ['id' => 'verifycode-hint', 'class' => 'captcha-hint-link']);
Html::addCssClass($options, 'captcha-hint');
return Html::tag('div', $text . $link, $options);
}
示例15: renderItem
protected function renderItem($item)
{
$this->validateItems($item);
$template = ArrayHelper::getValue($item, 'template', $this->linkTemplate);
$url = Url::to(ArrayHelper::getValue($item, 'url', '#'));
$linkOptions_ar = ArrayHelper::getValue($item, 'linkOptions');
$linkOptions = '';
if (!empty($linkOptions_ar)) {
foreach ($linkOptions_ar as $key => $value) {
$linkOptions .= ' ' . $key . '="' . $value . '"';
}
}
if (empty($item['top'])) {
if (empty($item['items'])) {
$template = str_replace('{icon}', $this->indItem . '{icon}', $template);
} else {
$template = isset($item['template']) ? $item['template'] : '<a href="{url}" class="kv-toggle">{icon}{label}</a>';
$openOptions = $item['active'] ? ['class' => 'opened'] : ['class' => 'opened', 'style' => 'display:none'];
$closeOptions = $item['active'] ? ['class' => 'closed', 'style' => 'display:none'] : ['class' => 'closed'];
$indicator = Html::tag('span', $this->indMenuOpen, $openOptions) . Html::tag('span', $this->indMenuClose, $closeOptions);
$template = str_replace('{icon}', $indicator . '{icon}', $template);
}
}
$icon = empty($item['icon']) ? '' : '<span class="' . $this->iconPrefix . $item['icon'] . '"></span> ';
unset($item['icon'], $item['top']);
return strtr($template, ['{url}' => $url, '{label}' => $item['label'], '{icon}' => $icon, '{linkOptions}' => $linkOptions]);
}