Пример #1
2
 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);
 }
Пример #2
0
 public function init()
 {
     if ($this->toUser || $this->subject || $this->content) {
         throw new Exception('邮件属性不能为空');
     }
     $this->subject = Html::encode($this->subject);
 }
Пример #3
0
 /**
  * @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]);
 }
Пример #4
0
 /**
  * @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;
 }
Пример #5
0
 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]);
 }
Пример #6
0
 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        });");
 }
Пример #7
0
 /**
  * @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;
 }
Пример #9
0
 /**
  * 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);
         };
     }
 }
Пример #10
0
 /**
  * @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));
 }
Пример #11
0
 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);
 }
Пример #12
0
 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);
     }
 }
Пример #13
0
 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');
 }
Пример #14
0
 /**
  * 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';
 }
Пример #15
0
 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'));
 }
Пример #16
0
 /**
  * @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);
 }
Пример #17
0
 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();
 }
Пример #18
0
 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>";
     }
 }
Пример #19
0
 /**
  * @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);
 }
Пример #20
0
 /**
  * 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>');
 }
Пример #22
0
 /**
  * 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');
 }
Пример #23
0
 /**
  * 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]);
     }
 }
Пример #24
0
 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);
 }
Пример #25
0
 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, ',', '&thinsp;')) . ' ' . 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;
 }
Пример #26
0
 /**
  * 
  * @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);
 }
Пример #27
0
 /**
  * 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]);
 }
Пример #28
0
 /**
  * @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);
     }
 }
Пример #30
-13
 /**
  * @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;
     }
 }