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]); }
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); } }
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; }
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; }
/** * @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); }
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; }
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; }
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; } }
/** * @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; }
/** * @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'); }
/** * 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'); } }
/** * 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'); } }
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); }
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); } }
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(); }
private static function maketag($tagname, $void = true, $options = array()) { $ret = '<' . $tagname; foreach ($options as $k => $v) { if ($v == '') { continue; } if (is_int($k)) { $ret .= ' ' . $v; } else { $ret .= ' ' . $k . '="' . Html::encode($v) . '"'; } } if ($void) { $ret .= '>'; } else { $ret .= ' />'; } return $ret; }
/** * Renders the content of the portlet. */ public function run() { if (empty($this->links)) { return; } echo Html::openTag($this->tagName, $this->htmlOptions) . "\n"; $content = ''; if ($this->homeLink === null) { $content .= Html::tag('li', array(), Html::link(Yii::t('zii', 'Home'), Yii::app()->homeUrl), true); } elseif ($this->homeLink !== false) { $content .= Html::tag('li', array(), $this->homeLink, true); } foreach ($this->links as $label => $url) { if (is_string($label) || is_array($url)) { $content .= strtr($this->activeLinkTemplate, array('{url}' => Html::normalizeUrl($url), '{label}' => $this->encodeLabel ? Html::encode($label) : $label)); } else { $content .= str_replace('{label}', $this->encodeLabel ? Html::encode($url) : $url, $this->inactiveLinkTemplate); } } echo $content; echo Html::closeTag($this->tagName); }
/** * Для авто заполнение short_description товара * @param type $object Модель товара * @return string */ public function getStringAttr($object) { $this->_attributes = $object->getEavAttributes(); $data = array(); foreach ($this->getModels() as $model) { $data[$model->title] = $model->renderValue($this->_attributes[$model->name]); } $content = ''; if (!empty($data)) { $numItems = count($data); $i = 0; foreach ($data as $title => $value) { if (++$i === $numItems) { //last element $content .= Html::encode($title) . ': ' . Html::encode($value); } else { $content .= Html::encode($title) . ': ' . Html::encode($value) . ' / '; } } } return $content; }
protected function normalizeItems($items, $route, &$active, $ischild = 0) { foreach ($items as $i => $item) { if (isset($item['visible']) && !$item['visible']) { unset($items[$i]); continue; } if ($this->encodeLabel) { $items[$i]['label'] = Html::encode($item['label']); } $hasActiveChild = false; if (isset($item['items'])) { $items[$i]['items'] = $this->normalizeItems($item['items'], $route, $hasActiveChild, 1); if (empty($items[$i]['items']) && $this->hideEmptyItems) { unset($items[$i]['items']); } } if (!isset($item['active'])) { if ($this->activateParents && $hasActiveChild || $this->isItemActive($item, $route)) { $active = $items[$i]['active'] = true; } else { $items[$i]['active'] = false; } } else { if ($item['active']) { $active = true; } } if ($items[$i]['active'] && $this->activeCssClass != '' && !$ischild) { if (isset($item['itemOptions']['class'])) { $items[$i]['itemOptions']['class'] .= ' ' . $this->activeCssClass; } else { $items[$i]['itemOptions']['class'] = $this->activeCssClass; } } } return array_values($items); }
/** * Sends an email with a link, for resetting the password. * * @return boolean whether the email was send */ public function sendEmail() { /* @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()) { $confirmLink = Yii::$app->urlManager->createAbsoluteUrl(['user/default/confirm-email', 'token' => $user->email_confirm_token]); $message = "Здравствуйте, " . Html::encode($user->username) . "!"; $message .= "Пройдите по ссылке, чтобы сменить пароль:"; $message .= $resetLink; $message .= "Если Вы не регистрировались у на нашем сайте, то просто удалите это письмо."; /* \Yii::$app->mailer->compose(['html' => 'passwordResetToken'], ['user' => $user]) ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) ->setTo($this->email) ->setSubject('Password reset for ' . \Yii::$app->name) ->send();*/ } } return false; }
/** * Update status * @param bool $new * @throws CHttpException */ public function actionUpdate($new = false) { if ($new === true) { $model = new OrderStatus(); $model->unsetAttributes(); } else { $model = OrderStatus::model()->findByPk($_GET['id']); } if (!$model) { throw new CHttpException(404, Yii::t('CartModule.admin', 'NO_STATUSES')); } $title = $model->isNewRecord ? Yii::t('CartModule.admin', 'CONTROL_STATUSES', 1) : Yii::t('CartModule.admin', 'CONTROL_STATUSES', 0); $this->breadcrumbs = array(Yii::t('CartModule.admin', 'STATUSES') => $this->createUrl('index'), $model->isNewRecord ? Yii::t('CartModule.admin', 'CONTROL_STATUSES', 1) : Html::encode($model->name)); $this->pageName = $title; if (Yii::app()->request->isPostRequest) { $model->attributes = $_POST['OrderStatus']; if ($model->validate()) { $model->save(); $this->redirect('index'); } } $this->render('update', array('model' => $model)); }
} ?> </ul> </div> <?php } ?> </div> <div class="col-sm-7 col-xs-12"> <div class="row"> <div class="col-md-8"> <h1><?php echo Html::encode($model->name); ?> </h1> <?php Yii::app()->controller->renderPartial('_configurations', array('model' => $model)); ?> <div class="product-view-rating"> <?php echo $this->widget("ext.rating.StarRating", array('name' => 'rating_' . $model->id, 'id' => 'rating_' . $model->id, 'allowEmpty' => false, 'readOnly' => isset(Yii::app()->request->cookies['rating_' . $model->id]), 'minRating' => 1, 'maxRating' => 5, 'value' => $model->rating + $model->votes ? round($model->rating / $model->votes) : 0, 'callback' => 'js:function(){rating(' . $model->id . ')}'), true); ?> </div> <div class="row product-view-param"> <div class="col-sm-4 col-md-4 col-xs-6 text-muted"><?php echo $model::t('SKU'); ?>
$this->beginContent('@app/views/layouts/structure.php'); ?> <main> <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <div class="b-post-list"> <?php foreach ($posts as $post) { ?> <div class="col-xs-12 col-sm-6 b-post"> <a href="http://vk.com" target="_blank"> <div class="b-post-title"> <h2><?php echo Html::encode($post->title); ?> </h2> </div> <div class="b-post-image-container" data-src="http://test.city-market24.ru/images/products/592/test_name.jpg"> <img class="b-post-image" src="img/img1.jpg" alt="Автобус"> </div> </a> </div> <?php } ?> </div> </div> </div>
<?php ob_start(); ?> <h1>Customers</h1> <?php foreach ($customers as $cust) { $link = Html::link(Html::encode($cust['CompanyName']), array('/customers/' . $cust['CustomerID'])); echo Html::tag('h2', array('style' => 'margin-bottom: 0;'), $link); echo $cust['ContactName']; } ?> <?php app()->load_template(app()->config['default_template'], array('content' => ob_get_clean()));
<?php use yii\helpers\html; echo Html::encode($message);
echo Yii::t('CartModule.default', 'DELIVERY'); ?> </div> <div class="col-md-6 text-right"><?php echo Html::encode($model->delivery_name); ?> </div> <?php if (!empty($model->user_comment)) { ?> <div class="col-md-6"><?php echo $model->getAttributeLabel('user_comment'); ?> </div> <div class="col-md-6 text-right"><?php echo Html::encode($model->user_comment); ?> </div> <?php } ?> </div> </div> </div> </div> <div class="col-md-4"> <div class="panel panel-info"> <div class="panel-heading"><h4><?php echo Yii::t('CartModule.default', 'PAYMENT_METHODS');
<div class="form-group"> <?php echo Html::activeLabel($form, 'payment_id', array('required' => true, 'class' => 'info-title control-label')); ?> <?php foreach ($paymenyMethods as $pay) { echo '<div style="margin-left:15px;">'; echo Html::activeRadioButton($form, 'payment_id', array('checked' => $form->payment_id == $pay->id, 'uncheckValue' => null, 'value' => $pay->id, 'data-value' => Html::encode($pay->name), 'id' => 'payment_id_' . $pay->id, 'class' => 'payment_checkbox')); ?> <label for="payment_id_<?php echo $pay->id; ?> "><?php echo Html::encode($pay->name); ?> </label> <?php echo '</div>'; } ?> </div>
/** * Renders tab items as specified on [[items]]. * @return string the rendering result. * @throws InvalidConfigException. */ protected function renderItems() { $headers = []; $panes = []; if (!$this->hasActiveTab() && !empty($this->items)) { $this->items[0]['active'] = true; } foreach ($this->items as $n => $item) { if (!ArrayHelper::remove($item, 'visible', true)) { 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']; $headerOptions = array_merge($this->headerOptions, ArrayHelper::getValue($item, 'headerOptions', [])); $linkOptions = array_merge($this->linkOptions, ArrayHelper::getValue($item, 'linkOptions', [])); if (isset($item['items'])) { $label .= ' <b class="caret"></b>'; Html::addCssClass($headerOptions, ['widget' => 'dropdown']); if ($this->renderDropdown($n, $item['items'], $panes)) { Html::addCssClass($headerOptions, 'active'); } Html::addCssClass($linkOptions, ['widget' => 'dropdown-toggle']); if (!isset($linkOptions['data-toggle'])) { $linkOptions['data-toggle'] = 'dropdown'; } $header = Html::a($label, "#", $linkOptions) . "\n" . Dropdown::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]); } else { $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', [])); $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n); Html::addCssClass($options, ['widget' => 'tab-pane']); if (ArrayHelper::remove($item, 'active')) { Html::addCssClass($options, 'active'); Html::addCssClass($headerOptions, 'active'); } if (isset($item['url'])) { $header = Html::a($label, $item['url'], $linkOptions); } else { if (!isset($linkOptions['data-toggle'])) { $linkOptions['data-toggle'] = 'tab'; } $header = Html::a($label, '#' . $options['id'], $linkOptions); } if ($this->renderTabContent) { $panes[] = Html::tag('div', isset($item['content']) ? $item['content'] : '', $options); } } $headers[] = Html::tag('li', $header, $headerOptions); } return Html::tag('ul', implode("\n", $headers), $this->options) . ($this->renderTabContent ? "\n" . Html::tag('div', implode("\n", $panes), ['class' => 'tab-content']) : ''); }
<?php $this->renderPartial('//layouts/inc/registerAssets'); $config = Yii::app()->settings->get('core'); $cs = Yii::app()->clientScript; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> <title><?php echo Html::encode($this->pageTitle); ?> </title> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"> <meta name="robots" content="all"> </head> <body> <?php $this->renderPartial('//layouts/partials/header', array('config' => $config)); ?> <?php $this->renderPartial('//layouts/partials/nav'); ?> <script> $(function () { $('[data-toggle="tooltip"]').tooltip();
public function run() { $label = $this->encodeLabel ? Html::encode($this->label) : $this->label; return Html::tag($this->tagName, $label, $this->options); }