public function run() { NavBar::begin(['brandLabel' => false, 'options' => ['class' => 'tor-nav']]); echo Html::tag('div', $this->torMenu(), ['class' => 'container']); NavBar::end(); $view = $this->view; NavAsset::register($view); }
public function init() { if ($this->toUser || $this->subject || $this->content) { throw new Exception('邮件属性不能为空'); } $this->subject = Html::encode($this->subject); }
/** * @inheritdoc */ public function run() { if (!$this->height) { $this->height = $this->width; } if (!isset($this->linkOptions['href'])) { $this->linkOptions['href'] = $this->space->getUrl(); } if ($this->space->color != null) { $color = Html::encode($this->space->color); } else { $color = '#d7d7d7'; } if (!isset($this->htmlOptions['class'])) { $this->htmlOptions['class'] = ""; } if (!isset($this->htmlOptions['style'])) { $this->htmlOptions['style'] = ""; } $acronymHtmlOptions = $this->htmlOptions; $imageHtmlOptions = $this->htmlOptions; $acronymHtmlOptions['class'] .= " space-profile-acronym-" . $this->space->id . " space-acronym"; $acronymHtmlOptions['style'] .= " background-color: " . $color . "; width: " . $this->width . "px; height: " . $this->height . "px;"; $acronymHtmlOptions['style'] .= " " . $this->getDynamicStyles($this->width); $imageHtmlOptions['class'] .= " space-profile-image-" . $this->space->id . " img-rounded profile-user-photo"; $imageHtmlOptions['style'] .= " width: " . $this->width . "px; height: " . $this->height . "px"; $imageHtmlOptions['alt'] = Html::encode($this->space->name); $defaultImage = basename($this->space->getProfileImage()->getUrl()) == 'default_space.jpg' || basename($this->space->getProfileImage()->getUrl()) == 'default_space.jpg?cacheId=0' ? true : false; if (!$defaultImage) { $acronymHtmlOptions['class'] .= " hidden"; } else { $imageHtmlOptions['class'] .= " hidden"; } return $this->render('image', ['space' => $this->space, 'acronym' => $this->getAcronym(), 'link' => $this->link, 'linkOptions' => $this->linkOptions, 'acronymHtmlOptions' => $acronymHtmlOptions, 'imageHtmlOptions' => $imageHtmlOptions]); }
/** * @param string|array $item the item to be normalized. * @return string|array normalized item. */ protected function normalizeItem($item) { if (is_array($item)) { if (isset($item['icon'])) { if (isset($item['label'])) { $label = $item['label']; $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels; if ($encodeLabel) { $label = Html::encode($label); } } else { $label = ''; } $item['encode'] = false; $label = Html::icon($item['icon']) . ' ' . $label; $item['label'] = $label; } if (isset($item['items'])) { foreach ($item['items'] as $key => $value) { $item['items'][$key] = $this->normalizeItem($value); } } } return $item; }
public function getFileLink($class = false) { if (!$class) { $class = ''; } return Html::a($this->vneshnee_imya_fajla, $this->getUri(), ['class' => 'file_item ' . $class, 'data-file-id' => $this->id]); }
public function run() { echo Html::beginTag('div', ['class' => 'input-group']); if (!isset($this->options['class'])) { $this->options['class'] = 'form-control'; } $iconId = 'icon-' . $this->options['id']; if (!isset($this->options['aria-describedby'])) { $this->options['aria-describedby'] = $iconId; } if ($this->hasModel()) { $replace['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->options); } else { $replace['{input}'] = Html::textInput($this->name, $this->value, $this->options); } if ($this->icon != '') { $replace['{icon}'] = Html::tag('span', Icon::show($this->icon, [], Icon::FA), ['class' => 'input-group-addon', 'id' => $iconId]); } echo strtr($this->template, $replace); echo Html::endTag('div'); $view = $this->getView(); Assets::register($view); $idMaster = $this->hasModel() ? Html::getInputId($this->model, $this->fromField) : $this->fromField; $idSlave = $this->options['id']; $view->registerJs("\n \$('#{$idMaster}').syncTranslit({\n destination: '{$idSlave}',\n type: 'url',\n caseStyle: 'lower',\n urlSeparator: '-'\n });"); }
/** * @inheritdoc */ public function init() { parent::init(); if (!isset($this->options['name'])) { $this->options['name'] = $this->hasModel() ? Html::getInputName($this->model, $this->attribute) : $this->name; } }
public function renderHtmlInput($input_type_id, $options = []) { $field = $options['prefix_text'] . " "; switch ($input_type_id) { case Types::$input_type['small_text']['id']: $field .= Html::textInput(sprintf('question_%s', $options['screening_question_id']), '', ['style' => 'width:60px']); break; case Types::$input_type['med_text']['id']: $field .= Html::textInput(sprintf('question_%s', $options['screening_question_id']), '', []); break; case Types::$input_type['large_text']['id']: $field .= Html::textInput(sprintf('question_%s', $options['screening_question_id']), '', ['style' => 'width:240px']); break; case Types::$input_type['date']['id']: $field = sprintf(''); break; case Types::$input_type['radio']['id']: // Enable tristate behavior with custom indeterminate value, custom toggle icon, and a custom label for the indeterminate state. $options['tristate_option_id'] == Types::$boolean['true']['id'] ? $tristate = true : ($tristate = false); $field = Html::radioList(sprintf('question_%s', $options['screening_question_id']), Types::$boolean['null']['id'], [Types::$boolean['true']['description'] => Types::$boolean['true']['description'], Types::$boolean['false']['description'] => Types::$boolean['false']['description']], ['unselect' => Types::$boolean['null']['description'], 'separator' => ' ']); break; case Types::$input_type['text_agreement']['id']: case Types::$input_type['text_agreement']['id']: $field = Html::radioList(sprintf('question_%s', $options['screening_question_id']), Types::$boolean['null']['id'], [yii::t('app', 'Agree') => yii::t('app', 'Agree'), yii::t('app', 'Disagree') => yii::t('app', 'Disagree')], ['unselect' => Types::$boolean['null']['description'], 'separator' => ' ']); break; break; case Types::$input_type['image_overlay']['id']: $field = sprintf('image overlay'); break; } $field .= " " . $options['suffix_text']; return $field; }
/** * Initializes the default button rendering callbacks. */ protected function initDefaultButtons() { /* TODO: Add support! if (!isset($this->buttons['view'])) { $this->buttons['view'] = function ($url, $model, $key) { $options = array_merge([ 'title' => self::t('yii', 'View'), 'aria-label' => self::t('yii', 'View'), 'data-pjax' => '0', ], $this->buttonOptions); return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, $options); }; } */ if (!isset($this->buttons['update'])) { $this->buttons['update'] = function ($url, $model, $key) { $options = array_merge(['title' => self::t('messages', 'Edit'), 'aria-label' => self::t('messages', 'Edit'), 'data-pjax' => '0'], $this->buttonOptions); return Html::a(trim(Icon::show('pencil')), $url, $options); }; } if (!isset($this->buttons['copy'])) { $this->buttons['copy'] = function ($url, $model, $key) { $options = array_merge(['title' => self::t('messages', 'Copy'), 'aria-label' => self::t('messages', 'Copy')], $this->buttonOptions); if ($model->hasMethod('duplicate') && ($model->hasAttribute('removed') && !$model->removed)) { return Html::a(trim(Icon::show('copy')), $url, $options); } }; } if (!isset($this->buttons['lock'])) { $this->buttons['lock'] = function ($url, $model, $key) { $options = array_merge(['title' => self::t('messages', 'Lock'), 'aria-label' => self::t('messages', 'Lock')], $this->buttonOptions); if ($model->hasAttribute('locked') && !$model->locked && ($model->hasAttribute('removed') && !$model->removed)) { return Html::a(trim(Icon::show('lock')), $url, $options); } }; } if (!isset($this->buttons['unlock'])) { $this->buttons['unlock'] = function ($url, $model, $key) { $options = array_merge(['title' => self::t('messages', 'Unlock'), 'aria-label' => self::t('messages', 'Unlock')], $this->buttonOptions); if ($model->hasAttribute('locked') && $model->locked && ($model->hasAttribute('removed') && !$model->removed)) { return Html::a(trim(Icon::show('unlock')), $url, $options); } }; } if (!isset($this->buttons['restore'])) { $this->buttons['restore'] = function ($url, $model, $key) { $options = array_merge(['title' => self::t('messages', 'Restore'), 'aria-label' => self::t('messages', 'Restore'), 'data-confirm' => self::t('messages', 'Are you sure you want to restore this item?'), 'data-method' => 'post', 'data-pjax' => '0'], $this->buttonOptions); if ($model->hasAttribute('removed') && $model->removed) { return Html::a(trim(Icon::show('share-square-o')), $url, $options); } }; } if (!isset($this->buttons['delete'])) { $this->buttons['delete'] = function ($url, $model, $key) { $name = $model->hasAttribute('removed') && !$model->removed ? self::t('messages', 'To trash') : self::t('messages', 'Delete'); $options = array_merge(['title' => $name, 'aria-label' => $name, 'data-confirm' => self::t('messages', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0'], $this->buttonOptions); return Html::a(trim(Icon::show('trash')), $url, $options); }; } }
/** * @inheritdoc */ public function getAsHtml() { $contentInfo = $this->getContentInfo($this->getCommentedRecord()); if ($this->groupCount > 1) { return Yii::t('CommentModule.notification', "{displayNames} commented {contentTitle}.", array('displayNames' => $this->getGroupUserDisplayNames(), 'contentTitle' => $contentInfo)); } return Yii::t('CommentModule.notification', "{displayName} commented {contentTitle}.", array('displayName' => Html::tag('strong', Html::encode($this->originator->displayName)), 'contentTitle' => $contentInfo)); }
public static function begin2($config = []) { $error = Html::tag('div', '{error}', ["class" => "col-lg-8"]); $input = Html::tag('div', '{input}', ["class" => "col-lg-4"]); $template = "{label}\n" . $input . $error; $config = ArrayHelper::merge(['options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['template' => $template, 'labelOptions' => ['class' => 'col-lg-3 control-label']]], $config); return self::begin($config); }
private function renderDropdown() { if ($this->hasModel()) { echo Html::activeDropDownList($this->model, $this->attribute, $this->getItems(), $this->options); } else { echo Html::dropDownList($this->name, $this->value, $this->getItems(), $this->options); } }
public function renderItem($message, $options) { echo Html::beginTag('div', $options) . "\n"; echo Html::beginTag('p'); echo $message; echo Html::endTag('p'); echo "\n" . Html::endTag('div'); }
/** * Returns Bootstrap label widget with user's role * @param User $user * @return string */ public function getRoleLabel(User $user) { $roles = [User::ROLE_USER => ['success', Yii::t('app', 'User')], User::ROLE_EDITOR => ['warning', Yii::t('app', 'Editor')], User::ROLE_ADMINISTRATOR => ['danger', Yii::t('app', 'Administrator')]]; if (isset($roles[$user->role])) { return Html::tag('span', $roles[$user->role][1], ['class' => 'label label-' . $roles[$user->role][0]]); } return 'N/A'; }
public function actionImagine() { $product = ProductRecord::find()->lang()->one(); echo Html::img($product->image->source); echo Html::img($product->imageSrc('200x200', \yii\image\drivers\Image::CROP)); echo Html::img($product->imageSrc('100x200', \yii\image\drivers\Image::CROP)); echo Html::img($product->imageSrc('500x200')); }
/** * @return string */ public function render() { if (isset($this->htmlOptions['class'])) { $this->htmlOptions['class'] = self::LAYER_CLASS . ' ' . $this->htmlOptions['class']; } else { $this->htmlOptions['class'] = self::LAYER_CLASS; } return \yii\bootstrap\Html::tag($this->tag, $this->content, $this->htmlOptions); }
public function run() { if ($this->hasModel()) { echo Html::activeTextarea($this->model, $this->attribute, $this->options); } else { echo Html::textarea($this->name, $this->value, $this->options); } $this->registerPlugin(); }
public function submitButton($label, $options = []) { $buttonStr = Html::submitButton($label, array_merge($options, ['class' => 'btn btn-primary'])); if ($this->layout == 'horizontal') { return "<div class=\"form-group\"><div class=\"col-sm-offset-3 col-sm-6\">{$buttonStr}</div></div>"; } else { return "<div class=\"form-group\">{$buttonStr}</div>"; } }
/** * @return string */ public function render() { if (isset($this->htmlOptions['class'])) { $this->htmlOptions['class'] = self::IMAGE_CLASS . ' ' . $this->htmlOptions['class']; } else { $this->htmlOptions['class'] = self::IMAGE_CLASS; } return \yii\bootstrap\Html::img($this->src, $this->htmlOptions); }
/** * Renders system message at frontend. * * @return string */ public function viewMessage() { $alert = Yii::$app->session->getFlash('system-alert'); $type = ArrayHelper::getValue($alert, 'type', self::INFO); $message = ArrayHelper::getValue($alert, 'message', ''); if (!empty($message)) { return Html::tag('div', $message, ['class' => 'alert alert-' . $type]); } return ''; }
public function run() { $this->clientOptions['treeViewId'] = $this->treeViewId; $this->registerWidget(); \yii\helpers\Html::addCssClass($this->options, 'execut-tree-filter-input'); $inputOptions = $this->inputOptions; Html::addCssClass($inputOptions, 'form-control'); $inputOptions['autocomplete'] = 'off'; echo $this->_renderContainer(Html::input('text', 'search', null, $inputOptions) . '<span class="close" title="Clear search results">×</span>'); }
/** * Renders the widget. */ public function run() { echo "\n" . $this->renderBodyEnd(); echo "\n" . $this->renderFooter(); echo "\n" . Html::endTag('div'); // modal-content echo "\n" . Html::endTag('div'); // modal-dialog $this->registerPlugin('modal'); }
/** * Updates an existing Person model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('alert', ['body' => \Yii::t('app', 'Person {name} was updated', ['name' => Html::a($model->getFullName(), Url::toRoute(['view', 'id' => $model->id]))]), 'options' => ['class' => 'alert-success']]); return $this->redirect(['index']); } else { return $this->render('update', ['model' => $model]); } }
public function run() { if ($this->torAd) { echo $this->render('full', ['torAd' => $this->torAd]); } else { echo Html::tag('div', '<em>По Вашему запросу ничего не найдено</em>', ['class' => 'text-center text-muted']); } $view = $this->view; TorAdsAsset::register($view); }
public function accountMenu() { if (Yii::$app->user->isGuest) { $items[] = ['label' => 'Войти', 'url' => ['/site/login']]; $items[] = ['label' => 'Зарегистрироваться', 'url' => ['/site/signup']]; } else { $user = User::findOne(Yii::$app->user->id); $items[] = ['label' => $user->username . ' ' . Html::tag('span', preg_replace('/\\,00/', '', number_format($user->money, 2, ',', ' ')) . ' ' . Icon::show('user', ['class' => 'fa-btc'], Icon::FA), ['style' => 'margin: 0 2px 0 6px;']), 'items' => [['label' => 'Добавить лот на продажу', 'url' => ['/tor/mng-ad']], '<li class="divider"></li>', ['label' => 'Сменить пароль', 'url' => ['#']], ['label' => 'Выход', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]]]; } return $items; }
/** * * @param type $url * @param Language $model * @param type $key */ public static function deleteButtonFn($url, $model, $key) { $glyphSuffix = 'ok'; $actionPrefix = 'enable'; if ($model['status'] == 0) { $glyphSuffix = 'remove'; $actionPrefix = 'disable'; } $options = ['class' => $actionPrefix . '-language-button', 'data-pjax' => 'language-grid', 'url' => \yii\helpers\Url::to([$actionPrefix . '-language', 'id' => $model['id']]), 'title' => Yii::t('yii', 'Delete'), 'aria-label' => Yii::t('yii', 'Delete'), 'style' => 'cursor:pointer']; return Html::a('<span class="glyphicon glyphicon-' . $glyphSuffix . '"></span>', false, $options); }
/** * Lists all Book models. * @return mixed */ public function actionIndex($id = null) { Yii::$app->session->setFlash('redirectUrl', Yii::$app->request->url); $searchModel = new BookSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); if (!empty($id)) { $model = $this->findModel($id); return $this->render('index', ['bookModel' => $model, 'imageResponse' => Html::img(Url::toRoute($model->imageUrl), ['style' => 'width:550px;']), 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]); } return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
/** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { if ($this->content === null) { $contentParts = []; $variationBehavior = $this->getVariationBehavior($model); foreach ($variationBehavior->getVariationModels() as $variationModel) { $contentParts[] = '<tr><td><b>' . $this->getVariationLabel($model, $variationModel) . '</b></td><td>' . $this->getVariationValue($variationModel) . '</td>'; } return Html::tag('table', implode("\n", $contentParts), $this->tableOptions); } return parent::renderDataCellContent($model, $key, $index); }
/** * @inheritDoc */ protected function renderDataCellContent($model, $key, $index) { /** * @var ISortableActiveRecord|ActiveRecord $model */ Yii2::assertType($model, ActiveRecord::class, ISortableActiveRecord::class); if (!$this->editable) { return $model->getSortBehavior()->getValue(); } else { return Html::textInput($model->getSortBehavior()->attributeName, $model->getSortBehavior()->getValue(), $this->inputOptions); } }
/** * @return string */ public function renderField() { switch ($this->type) { case 'textInput': return Html::textInput($this->param_name, $this->param_value, ['class' => 'form-control']); break; case 'textarea': return Html::textarea($this->param_name, $this->param_value, ['class' => 'form-control']); break; case 'checkbox': return Html::hiddenInput($this->param_name, 0) . \oakcms\bootstrapswitch\Switcher::widget(['name' => $this->param_name, 'checked' => $this->param_value]); break; case 'language': return Html::dropDownList($this->param_name, $this->param_value, ArrayHelper::map(Language::getLanguages(), 'language_id', 'name'), ['class' => 'form-control']); break; case 'getTheme': $files = scandir(Yii::getAlias('@app') . '/templates/frontend'); $items = []; foreach ($files as $file) { //if(!is_file($file) AND $file != '.' AND $file != '..') { if ($file != '.' and $file != '..') { $items[$file] = $file; } } return Html::dropDownList($this->param_name, $this->param_value, $items, ['class' => 'form-control']); break; } }