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


PHP Html::encode方法代码示例

本文整理汇总了PHP中Html::encode方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::encode方法的具体用法?PHP Html::encode怎么用?PHP Html::encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Html的用法示例。


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

示例1: actionReg

 public function actionReg()
 {
     $model = new RegForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($user = $model->reg()) {
             if ($user->status === User::STATUS_ACTIVE) {
                 if (Yii::$app->getUser()->login($user)) {
                     return $this->goHome();
                 }
             } else {
                 if ($model->sendActivationEmail($user)) {
                     Yii::$app->session->setFlash('success', 'Activation mail was sent to email <strong>' . Html::encode($user->email) . '</strong> (check spam folder).');
                 } else {
                     Yii::$app->session->setFlash('error', 'Error.');
                     Yii::error('Mail send error.');
                 }
                 return $this->refresh();
             }
         } else {
             Yii::$app->session->setFlash('error', 'Reg error.');
             Yii::error('Reg error');
             return $this->refresh();
         }
     }
     return $this->render('reg', ['model' => $model]);
 }
开发者ID:verget,项目名称:catering,代码行数:26,代码来源:SiteController.php

示例2: renderContent

 public function renderContent()
 {
     Yii::import('poll.components.CPollHelper');
     $model = $this->_poll;
     if ($model) {
         $fn = new CPollHelper($model);
         $userVote = $fn->loadVote();
         $params = array('model' => $model, 'userVote' => $userVote);
         // Force user to vote if needed
         if (Yii::app()->settings->get('poll', 'is_force') && $model->userCanVote()) {
             $view = 'vote';
             // Convert choices to form options list
             $choices = array();
             foreach ($model->choices as $choice) {
                 $choices[$choice->id] = Html::encode($choice->name);
             }
             $params['choices'] = $choices;
         } else {
             $view = 'view';
             $userChoice = $fn->loadChoice($userVote);
             $params += array('userVote' => $userVote, 'userChoice' => $userChoice);
         }
         $this->render($view, $params);
     }
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:25,代码来源:RandomWidget.php

示例3: add

 public static function add($post_id)
 {
     $post = Input::post(array('name', 'email', 'text'));
     $errors = array();
     if (empty($post['name'])) {
         $errors[] = 'Please enter your name';
     }
     if (filter_var($post['email'], FILTER_VALIDATE_EMAIL) === false) {
         $errors[] = 'Please enter a valid email address';
     }
     if (empty($post['text'])) {
         $errors[] = 'Please enter your comments';
     }
     if (count($errors)) {
         Notifications::set('error', $errors);
         return false;
     }
     $post['date'] = time();
     $post['status'] = Config::get('metadata.auto_published_comments', 0) ? 'published' : 'pending';
     $post['post'] = $post_id;
     // encode any html
     $post['text'] = Html::encode($post['text']);
     Db::insert('comments', $post);
     Notifications::set('success', 'Your comment has been sent');
     return true;
 }
开发者ID:reqshark,项目名称:anchor-cms,代码行数:26,代码来源:comments.php

示例4: renderOptions

 static function renderOptions($options, $default = null, $multiple = False)
 {
     $output = '';
     $last_group = NULL;
     foreach ($options as $key => $option) {
         if ($option->group && $option->group != $last_group) {
             if ($last_group) {
                 $output .= '</optgroup>' . "\n";
             }
             $output .= '<optgroup label="' . Html::encode($option->group) . '">' . "\n";
             $last_group = $option->group;
         }
         // is this option selected?
         $selected = NULL;
         if ($multiple) {
             // Do not use type sensitive in_array, due to php int=>str in array keys
             $selected = $default && in_array($option->value, $default);
         } else {
             $selected = $default == $option->value;
         }
         $output .= '<option' . Html::attributes(array('value' => $option->value, 'selected' => $selected ? 'selected' : NULL)) . '>' . Html::encode($option->caption) . '</option>' . "\n";
     }
     if ($last_group) {
         $output .= '</optgroup>' . "\n";
     }
     return $output;
 }
开发者ID:qix,项目名称:phorms,代码行数:27,代码来源:Select.php

示例5: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     if (empty($this->links)) {
         return;
     }
     echo Html::openTag($this->tagName, $this->htmlOptions);
     if ($this->homeLink !== false) {
         // check whether home link is not a link
         $active = stripos($this->homeLink, '<a') === false ? ' class="active"' : '';
         echo '<li' . $active . '>' . $this->homeLink . $this->separator . '</li>';
     }
     end($this->links);
     $lastLink = key($this->links);
     foreach ($this->links as $label => $url) {
         if (is_string($label) || is_array($url)) {
             echo '<li>';
             echo strtr($this->activeLinkTemplate, ['{url}' => Html::normalizeUrl($url), '{label}' => $this->encodeLabel ? Html::encode($label) : $label]);
         } else {
             echo '<li class="active">';
             echo str_replace('{label}', $this->encodeLabel ? Html::encode($url) : $url, $this->inactiveLinkTemplate);
         }
         if ($lastLink !== $label) {
             echo $this->separator;
         }
         echo '</li>';
     }
     echo Html::closeTag($this->tagName);
 }
开发者ID:intersvyaz,项目名称:yii-bootstrap,代码行数:31,代码来源:Breadcrumbs.php

示例6: createHtmlTree

 private function createHtmlTree($data)
 {
     $result = array();
     foreach ($data as $key => $node) {
         $result[] = array('id' => 'node_' . $node['id'], 'text' => Html::encode($node->name), 'a_attr' => array('class' => 'BALBAL'), 'li_attr' => array('data-switch' => $node->switch, 'data-key' => $key), 'children' => $this->createHtmlTree($node['children']));
     }
     return $result;
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:8,代码来源:DefaultController.php

示例7: getTagLinks

 public function getTagLinks()
 {
     $links = array();
     foreach (Tag::string2array($this->getOwner()->tags) as $tag) {
         $links[] = Html::link(Html::encode($tag), array($this->router, 'tag' => $tag));
     }
     return $links;
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:8,代码来源:TagsBehavior.php

示例8: initPlaceholder

 protected function initPlaceholder(&$options)
 {
     if ($this->autoPlaceholder) {
         $attr = preg_replace('/^\\[[^\\]]\\]/', '', $this->attribute);
         $label = Html::encode($this->model->getAttributeLabel($attr));
         $this->inputOptions['placeholder'] = $label;
         $options['placeholder'] = $label;
     }
 }
开发者ID:NewPaltzKarateAcademy,项目名称:KIMS,代码行数:9,代码来源:ActiveField.php

示例9: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $html = $s = '';
     foreach ($this->model->tags as $tag) {
         $html .= $s . Html::a(Html::encode($tag->name), ['tag/view', 'id' => $tag->id], ['class' => 'btn tag-sm', 'style' => 'background: ' . $tag->color . ';']);
         $s = ' ';
     }
     return $html;
 }
开发者ID:jlorente,项目名称:yii2-tagable-models,代码行数:12,代码来源:TagDisplayer.php

示例10: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $this->clientOptions[] = (string) ($this->encodeMessage ? Html::encode($this->message) : $this->message);
     $this->clientOptions[] = $this->displayLength;
     $this->clientOptions[] = $this->className;
     if ($this->completeCallback !== null) {
         $this->clientOptions[] = $this->completeCallback;
     }
     $this->registerMaterializePlugin('toast');
 }
开发者ID:talview,项目名称:yii2-materialize,代码行数:13,代码来源:Toast.php

示例11: createHtmlTree

 /**
  * Create ul html tree from data array
  * @param string $data
  */
 private function createHtmlTree($data)
 {
     foreach ($data as $node) {
         echo Html::openTag('li', array('id' => $this->id . 'Node_' . $node['id'], 'data-status' => $node['switch'], 'class' => $node['switch'] ? '' : 'hiddenClass'));
         echo Html::link(Html::encode($node->name));
         if ($node['hasChildren'] === true) {
             echo Html::openTag('ul');
             $this->createHtmlTree($node['children']);
             echo Html::closeTag('ul');
         }
         echo Html::closeTag('li');
     }
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:17,代码来源:JsTree.php

示例12: createHtmlTree

 /**
  * Create ul html tree from data array
  * @param string $data
  */
 private function createHtmlTree($data)
 {
     foreach ($data as $node) {
         echo Html::openTag('li', array());
         echo Html::link(Html::encode($node->name));
         if ($node['hasChildren'] === true) {
             echo Html::openTag('ul');
             $this->createHtmlTree($node['children']);
             echo Html::closeTag('ul');
         }
         echo Html::closeTag('li');
     }
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:17,代码来源:JsTree.php

示例13: run

    public function run()
    {
        $icon = $this->encodeIcon ? Html::encode($this->icon) : $this->icon;
        $label = $this->encodeLabel ? Html::encode($this->label) : $this->label;
        $content = <<<EOF
<div class="weui_grid_icon">
    {$icon}
</div>
<p class="weui_grid_label">
    {$label}
</p>
EOF;
        return \xj\weui\Html::tag($this->tagName, $content, $this->options);
    }
开发者ID:xjflyttp,项目名称:yii2-weui-widget,代码行数:14,代码来源:GridItem.php

示例14: actionView

 public function actionView($id)
 {
     Yii::app()->clientScript->scriptMap = array('jquery.js' => false);
     $model = Poll::model()->findByPk($id);
     if ($model) {
         $fn = new CPollHelper($model);
         $params = array('model' => $model);
         if (isset($_POST['PortletPollVote_choice_id'])) {
             foreach ($_POST['PortletPollVote_choice_id'] as $ids) {
                 $userVote = new PollVote();
                 $userVote->choice_id = $ids;
                 $userVote->poll_id = $model->id;
                 if ($userVote->validate()) {
                     $userVote->save(false, false);
                 } else {
                     die('err');
                 }
             }
         }
         $userVote = $fn->loadVote();
         if (Yii::app()->settings->get('poll', 'is_force') && $model->userCanVote()) {
             if (Yii::app()->request->isAjaxRequest) {
                 $this->widget('ext.uniform.UniformWidget', array('theme' => 'default'));
                 $userVote->addError('choise_id', 'Тыкни ты уже кудато!!');
                 $view = 'poll.widgets.random.views.vote';
             } else {
                 $view = 'vote';
             }
             // Convert choices to form options list
             $choices = array();
             foreach ($model->choices as $choice) {
                 $choices[$choice->id] = Html::encode($choice->name);
             }
             $params['choices'] = $choices;
         } else {
             if (Yii::app()->request->isAjaxRequest) {
                 $view = 'poll.widgets.random.views.view';
             } else {
                 $view = 'view';
             }
             $userChoice = $fn->loadChoice($userVote);
             $params += array('userVote' => $userVote, 'userChoice' => $userChoice);
         }
         $this->render($view, $params, false, true);
     }
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:46,代码来源:DefaultController.php

示例15: sendMessage

 public function sendMessage()
 {
     $config = Yii::app()->settings->get('contacts');
     $mails = explode(',', $config['form_emails']);
     $tempArray = array('{sender_name}' => $this->name, '{sender_email}' => $this->email, '{sender_message}' => CHtml::encode($this->msg), '{sender_phone}' => $this->phone);
     $mailer = Yii::app()->mail;
     $mailer->From = 'noreply@' . Yii::app()->request->serverName;
     $mailer->FromName = Yii::t('ContactsModule.default', 'FB_FORM_NAME');
     $mailer->Subject = Yii::t('ContactsModule.default', 'FB_FROM_MESSAGE', array('{name}' => isset($this->name) ? Html::encode($this->name) : $this->email, '{site_name}' => Yii::app()->settings->get('core', 'site_name')));
     $mailer->Body = Html::text(CMS::textReplace($config['tempMessage'], $tempArray));
     foreach ($mails as $mail) {
         $mailer->AddAddress($mail);
     }
     $mailer->isHtml(true);
     $mailer->AddReplyTo($this->email);
     $mailer->Send();
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:17,代码来源:ContactForm.php


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