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


PHP Html::encode方法代码示例

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


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

示例1: normalizeItem

 /**
  * @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;
 }
开发者ID:ASP96,项目名称:admin,代码行数:29,代码来源:Nav.php

示例2: run

 /**
  * @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]);
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:38,代码来源:Image.php

示例3: init

 public function init()
 {
     if ($this->toUser || $this->subject || $this->content) {
         throw new Exception('邮件属性不能为空');
     }
     $this->subject = Html::encode($this->subject);
 }
开发者ID:specialnote,项目名称:myYii,代码行数:7,代码来源:Mail.php

示例4: getAsHtml

 /**
  * @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));
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:11,代码来源:NewComment.php

示例5: renderItem

 /**
  * @inheritdoc
  * **/
 protected function renderItem($item)
 {
     //Есть ли дочерние элементы
     if (ArrayHelper::getValue($item, 'items')) {
         $template = value($this->parentLinkTemplate, $this->linkTemplate);
     } else {
         $template = $this->linkTemplate;
     }
     if (isset($item['url'])) {
         $template = ArrayHelper::getValue($item, 'template', $template);
         return strtr($template, ['{url}' => Html::encode(Url::to($item['url'])), '{label}' => $item['label'], '{icon}' => ArrayHelper::getValue($item, 'icon', null), '{active}' => ($this->isItemActive($item) or ArrayHelper::getValue($item, 'active', false)) ? $this->activeCssClass : null]);
     } else {
         $template = ArrayHelper::getValue($item, 'template', $this->labelTemplate);
         return strtr($template, ['{label}' => $item['label']]);
     }
 }
开发者ID:nagser,项目名称:base,代码行数:19,代码来源:Menu.php

示例6: actionForm

 public function actionForm()
 {
     /* @var $name string*/
     /*  @var $email string */
     $form = new MyForm();
     if ($form->load(Yii::$app->request->post()) && $form->validate()) {
         $name = Html::encode($form->name);
         $email = Html::encode($form->email);
         $form->file = UploadedFile::getInstance($form, 'file');
         $form->file->saveAs('photo/' . $form->file->baseName . '.' . $form->file->extension);
     } else {
         $name = '';
         $email = '';
     }
     return $this->render('form', ['form' => $form, 'name' => $name, 'email' => $email]);
 }
开发者ID:phstoned,项目名称:rusakov-test,代码行数:16,代码来源:SiteController.php

示例7: renderItem

 /**
  * Renders single item.
  * @param array $item item configuration.
  * @return string rendered HTML
  */
 protected function renderItem($item)
 {
     if (isset($item[0])) {
         $url = $item;
         $options = [];
     } else {
         $url = $item['url'];
         $options = $item;
         unset($options['url']);
     }
     // label :
     if (isset($options['label'])) {
         $label = $options['label'];
         unset($options['label']);
     } else {
         $label = $this->detectLabel($url);
     }
     if (isset($options['encode'])) {
         $encodeLabel = $options['encode'];
         unset($options['encode']);
     } else {
         $encodeLabel = $this->encodeLabels;
     }
     if ($encodeLabel) {
         $label = Html::encode($label);
     }
     // icon :
     if (isset($options['icon'])) {
         $icon = $options['icon'];
         unset($options['icon']);
     } else {
         $icon = $this->detectIcon($url);
     }
     if ($icon) {
         $label = Html::icon($icon) . ' ' . $label;
     }
     // CSS class :
     if (isset($options['class'])) {
         Html::addCssClass($options, ['widget' => 'btn']);
     } else {
         $options['class'] = ['btn', $this->detectClass($url)];
     }
     if (!isset($options['data'])) {
         $options['data'] = $this->detectData($url);
     }
     return Html::a($label, $url, $options);
 }
开发者ID:ASP96,项目名称:admin,代码行数:52,代码来源:ButtonContextMenu.php

示例8: actionEmail

 /**
  * 验证邮箱
  * @return \yii\web\Response
  * @throws Exception
  */
 public function actionEmail()
 {
     $a = Html::encode(Yii::$app->request->get('a'));
     if (!$a) {
         throw new Exception('链接错误');
     }
     $model = Yii::$app->user->identity;
     if ($model->validateAuthKey($a)) {
         $model->generateAuthKey();
         $model->is_email = User::IS_EMAIL_TRUE;
         if ($model->save(false)) {
             return $this->redirect(['/user/index']);
         } else {
             throw new Exception('验证邮箱失败');
         }
     } else {
         throw new Exception('身份不正确');
     }
 }
开发者ID:specialnote,项目名称:myYii,代码行数:24,代码来源:UserController.php

示例9: renderItems

 /**
  * Renders menu items.
  *
  * @param array $items the menu items to be rendered
  * @param array $options the container HTML attributes
  * @return string the rendering result.
  * @throws InvalidConfigException if the label option is not specified in one of the items.
  */
 protected function renderItems($items, $options = [])
 {
     $lines = [];
     foreach ($items as $i => $item) {
         if (isset($item['visible']) && !$item['visible']) {
             unset($items[$i]);
             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', []);
         $icon = ArrayHelper::getValue($item, 'icon', '');
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
         $linkOptions['tabindex'] = '-1';
         $url = array_key_exists('url', $item) ? $item['url'] : null;
         if (!empty($icon)) {
             $icon = Html::tag('i', '', ['class' => $icon]);
         }
         if (empty($item['items'])) {
             if ($url === null) {
                 $content = $label;
                 Html::addCssClass($itemOptions, 'dropdown-header');
             } else {
                 $content = Html::a($icon . $label, $url, $linkOptions);
             }
         } else {
             $submenuOptions = $options;
             unset($submenuOptions['id']);
             $content = Html::a($label, $url === null ? '#' : $url, $linkOptions) . $this->renderItems($item['items'], $submenuOptions);
             Html::addCssClass($itemOptions, 'dropdown-submenu');
         }
         $lines[] = Html::tag('li', $content, $itemOptions);
     }
     return Html::tag('ul', implode("\n", $lines), $options);
 }
开发者ID:peang,项目名称:components,代码行数:50,代码来源:SidebarDropdownWidget.php

示例10: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     if (!isset($this->options['id'])) {
         $this->options['id'] = $this->getId();
     }
     if ($this->requiresDjax()) {
         ob_start();
         ob_implicit_flush(false);
         $view = $this->getView();
         $view->clear();
         $view->beginPage();
         $view->head();
         $view->beginBody();
         if ($view->title !== null) {
             echo Html::tag('title', Html::encode($view->title));
         }
     } else {
         echo Html::beginTag('div', $this->options);
     }
 }
开发者ID:anmishael,项目名称:yii2-djax,代码行数:23,代码来源:Djax.php

示例11: getAsHtml

 /**
  * @inheritdoc
  */
 public function getAsHtml()
 {
     return Yii::t('SpaceModule.notification', '{displayName} declined your membership request for the space {spaceName}', array('{displayName}' => Html::tag('strong', Html::encode($this->originator->displayName)), '{spaceName}' => Html::tag('strong', Html::encode($this->source->name))));
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:7,代码来源:ApprovalRequestDeclined.php

示例12:

Icon::map($this, Icon::FA);
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="<?php 
echo Yii::$app->language;
?>
">
    <head>
        <meta charset="<?php 
echo Yii::$app->charset;
?>
"/>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title><?php 
echo Html::encode($this->title . ' | Administrator');
?>
</title>
        <?php 
// Css
$this->registerCssFile($this->theme->baseUrl . '/css/plugins/iCheck/custom.css', ['depends' => BackendAsset::className()]);
//        $this->registerCssFile($this->theme->baseUrl . '/css/plugins/cropper/cropper.min.css', ['depends' => BackendAsset::className()]);
//        $this->registerCssFile($this->theme->baseUrl . '/css/plugins/cropper/main.css', ['depends' => BackendAsset::className()]);
$this->registerCssFile($this->theme->baseUrl . '/css/animate.css', ['depends' => BackendAsset::className()]);
$this->registerCssFile($this->theme->baseUrl . '/css/style.css', ['depends' => BackendAsset::className()]);
$this->registerCssFile($this->theme->baseUrl . '/css/letyii.css', ['depends' => BackendAsset::className()]);
// Javascript
$this->registerJsFile($this->theme->baseUrl . '/js/plugins/metisMenu/jquery.metisMenu.js', ['depends' => BackendAsset::className()]);
$this->registerJsFile($this->theme->baseUrl . '/js/plugins/slimscroll/jquery.slimscroll.min.js', ['depends' => BackendAsset::className()]);
// iCheck
$this->registerJsFile($this->theme->baseUrl . '/js/plugins/iCheck/icheck.min.js', ['depends' => BackendAsset::className()]);
开发者ID:quynhvv,项目名称:stepup,代码行数:31,代码来源:main.php

示例13: renderButton

 /**
  * Renders button.
  * @param string $name button name.
  * @param mixed $model
  * @param string $key
  * @param integer $index
  * @return string rendered HTML
  * @throws InvalidConfigException on invalid button format.
  */
 protected function renderButton($name, $model, $key, $index)
 {
     if (!isset($this->buttons[$name])) {
         return '';
     }
     $button = $this->buttons[$name];
     if ($button instanceof \Closure) {
         $url = $this->createUrl($name, $model, $key, $index);
         return call_user_func($button, $url, $model, $key);
     }
     if (!is_array($button)) {
         throw new InvalidConfigException("Button should be either a Closure or array configuration.");
     }
     // Visibility :
     if (isset($button['visible'])) {
         if ($button['visible'] instanceof \Closure) {
             if (!call_user_func($button['visible'], $model, $key, $index)) {
                 return '';
             }
         } elseif (!$button['visible']) {
             return '';
         }
     }
     // URL :
     if (isset($button['url'])) {
         $url = call_user_func($button['url'], $name, $model, $key, $index);
     } else {
         $url = $this->createUrl($name, $model, $key, $index);
     }
     // label :
     if (isset($button['label'])) {
         $label = $button['label'];
         if (isset($button['encode'])) {
             $encodeLabel = $button['encode'];
             unset($button['encode']);
         } else {
             $encodeLabel = true;
         }
         if ($encodeLabel) {
             $label = Html::encode($label);
         }
     } else {
         $label = '';
     }
     // icon :
     if (isset($button['icon'])) {
         $icon = $button['icon'];
         $label = Html::icon($icon) . (empty($label) ? '' : ' ' . $label);
     }
     $options = array_merge(ArrayHelper::getValue($button, 'options', []), $this->buttonOptions);
     return Html::a($label, $url, $options);
 }
开发者ID:yii2tech,项目名称:admin,代码行数:61,代码来源:PositionColumn.php

示例14: renderLink

 protected function renderLink($item)
 {
     $lines = [];
     foreach ($item as $i => $item) {
         if (isset($item['url'])) {
             $template = ArrayHelper::getValue($item, 'template', $this->linkTemplate);
             $lines[] = strtr($template, ['{url}' => Html::encode(Url::to($item['url'])), '{label}' => $item['label']]);
         } else {
             $template = ArrayHelper::getValue($item, 'template', $this->labelTemplate);
             $lines[] = strtr($template, ['{label}' => $item['label']]);
         }
     }
     return implode("\n", $lines);
 }
开发者ID:AndMak15,项目名称:script.dev,代码行数:14,代码来源:MenuPanel.php

示例15:

		<tr>
			<td><?php 
echo $specie->getAttributeLabel('dutch');
?>
</td>
			<td><?php 
echo Html::encode($specie->dutch);
?>
</td>
		</tr>
		<?php 
if ($specie->url) {
    ?>
			<tr>
				<td><?php 
    echo $specie->getAttributeLabel('url');
    ?>
</td>
				<td><a href="<?php 
    echo Html::encode($specie->url);
    ?>
"><?php 
    echo Html::encode($specie->url);
    ?>
</a></td>
			</tr>
		<?php 
}
?>
	</table>
</div>
开发者ID:ThijsBosch,项目名称:batboxes,代码行数:31,代码来源:detail.php


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