当前位置: 首页>>代码示例>>PHP>>正文


PHP helpers\Html类代码示例

本文整理汇总了PHP中yii\helpers\Html的典型用法代码示例。如果您正苦于以下问题:PHP Html类的具体用法?PHP Html怎么用?PHP Html使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Html类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionIndex

 /**
  * Lists all StaticPageTable models.
  * @return mixed
  */
 public function actionIndex()
 {
     if (!Yii::$app->user->can('static-page-table/index')) {
         Yii::$app->session->setFlash('error', 'Нет доступа!');
         return $this->redirect('/');
     }
     if (isset($_POST['sort_list_2'])) {
         $mas = explode(',', $_POST['sort_list_2']);
         for ($i = 0; $i <= sizeof($mas) - 1; $i++) {
             $model = $this->findModel($mas[$i]);
             $model->position = $i;
             $model->save();
         }
     }
     $staticPagesTrue = StaticPageTable::find()->where(['status' => 1])->orderBy(['position' => SORT_ASC])->all();
     $staticPagesFalse = StaticPageTable::find()->where(['status' => 0])->orderBy(['position' => SORT_ASC])->all();
     $list = [];
     $value = "";
     foreach ($staticPagesTrue as $statispage) {
         $list[$statispage->id] = ['content' => Html::a(FA::icon($statispage->icon) . " " . $statispage->name, ['view', 'url' => $statispage->url])];
         $value .= $statispage->id . ",";
     }
     foreach ($staticPagesFalse as $statispage) {
         $list[$statispage->id] = ['content' => Html::a(FA::icon($statispage->icon) . " " . $statispage->name, ['view', 'url' => $statispage->url]), 'disabled' => true];
         $value .= $statispage->id . ",";
     }
     $value = substr($value, 0, -1);
     return $this->render('index', ['list' => $list, 'value' => $value]);
 }
开发者ID:dosh93,项目名称:shop,代码行数:33,代码来源:StaticPageTableController.php

示例2: 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' => '']);
 }
开发者ID:kennygp,项目名称:yii-myweb,代码行数:34,代码来源:ArticlecommentController.php

示例3: toArray

 public function toArray()
 {
     $response = [];
     $response['status'] = $this->status;
     $response['table'] = [];
     $response['chart'] = [];
     if ($response['status'] == static::STATUS_SUCCESS) {
         if ($this->caption) {
             $response['caption'] = $this->caption;
         }
         foreach ($this->data as $key => $row) {
             $tableRow = [];
             $chartRow = [];
             foreach ($this->dataSeries as $s) {
                 if ($s->value !== null) {
                     $value = call_user_func($s->value, $row, $key);
                 } else {
                     $value = ArrayHelper::getValue($row, $s->name);
                 }
                 $value = $s->encode ? Html::encode($value) : $value;
                 $tableRow[] = $value;
                 if ($s->isInChart) {
                     $chartRow[] = $value;
                 }
             }
             $response['table'][] = $tableRow;
             $response['chart'][] = $chartRow;
         }
     } else {
         $response['message'] = $this->message;
     }
     return $response;
 }
开发者ID:thrieu,项目名称:yii2-statreport,代码行数:33,代码来源:Response.php

示例4: run

 public function run()
 {
     SelectAsset::register($this->view);
     FilterAsset::register($this->view);
     $values = [];
     foreach ($this->data as $value) {
         $value = strval($value);
         $values[$value] = $value;
     }
     if (!$this->default) {
         $this->default = $this->multiple ? array_keys($values) : key($values);
     }
     $selected = $this->selected($this->default);
     // Setup options
     $options = ['id' => $this->name, 'name' => $this->name . '[]', 'style' => 'width: 300px;', 'class' => 'selectpicker'];
     $extra = ['title' => 'Not selected'];
     if ($this->multiple) {
         $extra['multiple'] = 'multiple';
     }
     if ($this->placeholder) {
         $extra['title'] = strval($this->placeholder);
     }
     $options = array_merge($options, $extra);
     if (!$this->method) {
         $this->method = 'get';
     }
     // Render
     echo Html::beginForm(Url::canonical(), $this->method, ['data-pjax' => '1', 'id' => $this->name]);
     echo Html::beginTag('select', $options, ['data-pjax' => '1']);
     echo Html::renderSelectOptions($selected, $values);
     echo Html::endTag("select");
     echo Html::endForm();
     parent::run();
 }
开发者ID:Polymedia,项目名称:BI-Platform-v3,代码行数:34,代码来源:Filter.php

示例5: 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]);
         }]);
     }]]];
 }
开发者ID:hiqdev,项目名称:hipanel-module-dns,代码行数:26,代码来源:RecordGridView.php

示例6: initOptions

 /**
  * Initializes the widget options.
  * This method sets the default values for various options.
  */
 protected function initOptions()
 {
     if ($this->showButton) {
         Html::addCssClass($this->options, 'uk-button');
     }
     $this->options = array_merge(['data-uk-smooth-scroll' => ''], $this->options);
 }
开发者ID:zydecode,项目名称:yii2-uikit,代码行数:11,代码来源:SmoothScroll.php

示例7: actions

 /**
  * @return string $template
  * @return mixed
  */
 public function actions($template = '{update} {delete}')
 {
     $this->columns = array_merge($this->columns, [['class' => ActionColumn::className(), 'controller' => SELF::CONTROLLER, 'template' => $template, 'buttons' => ['update' => function ($url, $model, $key) {
         return Html::a('<i class="fa fa-pencil"></i>', false, ['value' => Url::to([SELF::CONTROLLER . '/update', 'id' => $model->id]), 'title' => 'Update', 'class' => 'showModalButton']);
     }], 'contentOptions' => ['class' => 'text-right']]]);
     return $this;
 }
开发者ID:anli,项目名称:yii2-rbac,代码行数:11,代码来源:UserRoleColumn.php

示例8: run

 /**
  * Renders the widget.
  */
 public function run()
 {
     echo Html::endTag('div');
     //closes the container, opened on init
     $this->infiniteScrollScript();
     $this->registerPlugin();
 }
开发者ID:luoche,项目名称:iisns,代码行数:10,代码来源:Masonry.php

示例9: run

 public function run($id)
 {
     $model = $this->getNodeById($id);
     $model->scenario = 'move';
     $model->load(Yii::$app->request->post(), '');
     if (!$model->validate()) {
         throw new HttpException(500, current(current($model->getErrors())));
     }
     if (!$model->relatedNode instanceof $this->treeModelName) {
         throw new NotFoundHttpException(Yii::t('gtreetable', 'Position indicated by related ID is not exists!'));
     }
     try {
         if (is_callable($this->beforeAction)) {
             call_user_func_array($this->beforeAction, ['model' => $model]);
         }
         $action = $this->getMoveAction($model);
         if (!call_user_func(array($model, $action), $model->relatedNode)) {
             throw new Exception(Yii::t('gtreetable', 'Moving operation `{name}` failed!', ['{name}' => Html::encode((string) $model)]));
         }
         if (is_callable($this->afterAction)) {
             call_user_func_array($this->afterAction, ['model' => $model]);
         }
         echo Json::encode(['id' => $model->getPrimaryKey(), 'name' => $model->getName(), 'level' => $model->getLevel(), 'type' => $model->getType()]);
     } catch (\Exception $e) {
         throw new HttpException(500, $e->getMessage());
     }
 }
开发者ID:antiqwerty,项目名称:yii2-gtreetable-fix,代码行数:27,代码来源:NodeMoveAction.php

示例10: renderLabel

 public function renderLabel()
 {
     if (!isset($this->labelOptions['for'])) {
         $this->labelOptions['for'] = $this->inputOptions['id'];
     }
     return $this->hasModel() ? Html::activeLabel($this->model, $this->attribute, $this->labelOptions) : Html::label($this->label, $this->labelOptions['for'], $this->labelOptions);
 }
开发者ID:fourteenmeister,项目名称:yii2-semantic-ui,代码行数:7,代码来源:Checkbox.php

示例11: renderItems

 protected function renderItems($items, $options = [])
 {
     $lines = [];
     foreach ($items as $i => $item) {
         if (isset($item['visible']) && !$item['visible']) {
             continue;
         }
         if (is_string($item)) {
             $lines[] = $item;
             continue;
         }
         if (!array_key_exists('label', $item)) {
             throw new InvalidConfigException("The 'label' option is required.");
         }
         $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
         $label = $encodeLabel ? Html::encode($item['label']) : $item['label'];
         $itemOptions = ArrayHelper::getValue($item, 'options', []);
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
         $linkOptions['tabindex'] = '-1';
         $url = array_key_exists('url', $item) ? $item['url'] : null;
         if (empty($item['items'])) {
             if ($url === null) {
                 $content = $label;
             } else {
                 $content = Html::a($label, $url, $linkOptions);
             }
         } else {
             $submenuOptions = $options;
             unset($submenuOptions['id']);
             $content = Html::a($label, $url === null ? '#' : $url, $linkOptions) . $this->renderItems($item['items'], $submenuOptions);
         }
         $lines[] = Html::tag('li', $content, $itemOptions);
     }
     return Html::tag('ul', implode("\n", $lines), $options);
 }
开发者ID:su-xiaolin,项目名称:yii2-make,代码行数:35,代码来源:Sidedropdown.php

示例12: sendMail

 public function sendMail()
 {
     /* @var $user User */
     $user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
     if ($user) {
         if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
             $user->generatePasswordResetToken();
         }
         if ($user->save()) {
             $setting = Setting::find()->where(['id' => 1])->one();
             $username = $setting->sendgridUsername;
             $password = $setting->sendgridPassword;
             $mail_admin = $setting->emailAdmin;
             $sendgrid = new \SendGrid($username, $password, array("turn_off_ssl_verification" => true));
             $email = new \SendGrid\Email();
             $mail = $user->email;
             //echo $user->email;exit(0);
             $resetLink = \Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]);
             $body_message = 'Hello ' . Html::encode($user->username) . ', <br>
             Follow the link below to reset your password:  <br>
             ' . Html::a(Html::encode($resetLink), $resetLink);
             $email->addTo($user->email)->setFrom($mail_admin)->setSubject('Password reset for ' . \Yii::$app->name)->setHtml($body_message);
             $response = $sendgrid->send($email);
             //print_r($response); exit(0);
             return $response;
         }
     }
     return false;
 }
开发者ID:sintret,项目名称:yii2-basic,代码行数:29,代码来源:PasswordResetRequestForm.php

示例13: run

 public function run()
 {
     if ($this->hasModel()) {
         return Html::activeTextInput($this->model, $this->attribute, $this->options);
     }
     return Html::textInput($this->name, $this->value, $this->options);
 }
开发者ID:madand,项目名称:yii2-clockpicker,代码行数:7,代码来源:ClockPicker.php

示例14: actionIndex

 public function actionIndex()
 {
     $actions = [];
     $rc = new \ReflectionClass($this);
     $publicMethods = $rc->getMethods(\ReflectionMethod::IS_PUBLIC);
     $availableActions = [];
     foreach ($publicMethods as $publicMethod) {
         $methodName = $publicMethod->name;
         if ($methodName == 'actions') {
             continue;
         }
         if (StringHelper::startsWith($methodName, 'action')) {
             $availableActions[] = $methodName;
         }
     }
     if (count($this->actions()) > 0) {
         $availableActions = $availableActions + array_keys($this->actions());
     }
     $menus = [];
     foreach ($availableActions as $actionName) {
         $routeId = Inflector::camel2id(substr($actionName, strlen('action')));
         $menus[] = Html::a($actionName, [$routeId]);
     }
     echo implode('<br/>', $menus);
 }
开发者ID:cjq,项目名称:yii2-playground,代码行数:25,代码来源:SsdbController.php

示例15: renderItems

 protected function renderItems($items)
 {
     $n = count($items);
     $lines = [];
     foreach ($items as $i => $item) {
         $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', []));
         $tag = ArrayHelper::remove($options, 'tag', 'li');
         $class = [];
         if ($item['active']) {
             $class[] = $this->activeCssClass;
         }
         if ($i === 0 && $this->firstItemCssClass !== null) {
             $class[] = $this->firstItemCssClass;
         }
         if ($i === $n - 1 && $this->lastItemCssClass !== null) {
             $class[] = $this->lastItemCssClass;
         }
         $menu = $this->renderItem($item);
         if (!empty($item['items'])) {
             $class[] = $this->treeClass;
             $menu .= strtr($this->submenuTemplate, ['{items}' => $this->renderItems($item['items'])]);
         }
         if (!empty($class)) {
             if (empty($options['class'])) {
                 $options['class'] = implode(' ', $class);
             } else {
                 $options['class'] .= ' ' . implode(' ', $class);
             }
         }
         $lines[] = Html::tag($tag, $menu, $options);
     }
     return implode("\n", $lines);
 }
开发者ID:thedollarsign,项目名称:yii2-adminlte-theme,代码行数:33,代码来源:Menu.php


注:本文中的yii\helpers\Html类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。