Esempio n. 1
3
 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;
 }
Esempio n. 2
1
 public function actionConfirm()
 {
     $table = new Users();
     if (Yii::$app->request->get()) {
         //Obtenemos el valor de los parámetros get
         $id = Html::encode($_GET["id"]);
         $authKey = $_GET["authKey"];
         if ((int) $id) {
             //Realizamos la consulta para obtener el registro
             $model = $table->find()->where("id=:id", [":id" => $id])->andWhere("authKey=:authKey", [":authKey" => $authKey]);
             //Si el registro existe
             if ($model->count() == 1) {
                 $activar = Users::findOne($id);
                 $activar->activate = 1;
                 if ($activar->update()) {
                     echo "Enhorabuena registro llevado a cabo correctamente, redireccionando ...";
                     echo "<meta http-equiv='refresh' content='8; " . Url::toRoute("site/login") . "'>";
                 } else {
                     echo "Ha ocurrido un error al realizar el registro, redireccionando ...";
                     echo "<meta http-equiv='refresh' content='8; " . Url::toRoute("site/login") . "'>";
                 }
             } else {
                 //Si no existe redireccionamos a login
                 return $this->redirect(["site/login"]);
             }
         } else {
             //Si id no es un número entero redireccionamos a login
             return $this->redirect(["site/login"]);
         }
     }
 }
 /**
  * Renders menu items.
  * @param  array                  $items the menu items to be rendered
  * @return string                 the rendering result.
  * @throws InvalidConfigException if the label option is not specified in one of the items.
  */
 protected function renderItems($items)
 {
     $lines = [];
     foreach ($items as $i => $item) {
         if (isset($item['visible']) && !$item['visible']) {
             unset($items[$i]);
             continue;
         }
         if (is_string($item)) {
             $lines[] = $item;
             continue;
         }
         if (!isset($item['title'])) {
             throw new InvalidConfigException("The 'title' option is required.");
         }
         $title = $this->encode ? Html::encode($item['title']) : $item['title'];
         $titleOptions = ArrayHelper::getValue($item, 'titleOptions', []);
         Html::addCssClass($titleOptions, 'list-group-item-heading');
         $titleCode = Html::tag('h4', $title, $titleOptions);
         $description = $this->encode ? Html::encode($item['description']) : $item['description'];
         $descriptionOptions = ArrayHelper::getValue($item, 'descriptionOptions', []);
         Html::addCssClass($descriptionOptions, 'list-group-item-text');
         $descriptionCode = Html::tag('p', $description, $descriptionOptions);
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
         Html::addCssClass($linkOptions, 'list-group-item');
         Html::addCssStyle($linkOptions, 'word-wrap: break-word');
         if (isset($item['active']) && $item['active']) {
             Html::addCssClass($linkOptions, 'active');
         }
         $linkOptions['tabindex'] = '-1';
         $lines[] = Html::a($titleCode . "\n" . $descriptionCode, ArrayHelper::getValue($item, 'url', '#'), $linkOptions);
     }
     return Html::tag('div', implode("\n", $lines), $this->options);
 }
 /**
  * Renders menu items.
  * @param array $items the menu items to be rendered
  * @return string the rendering result.
  * @throws InvalidConfigException if the label option is not specified in one of the items.
  */
 protected function renderItems($items)
 {
     $lines = [];
     foreach ($items as $i => $item) {
         if (isset($item['visible']) && !$item['visible']) {
             unset($items[$i]);
             continue;
         }
         if (is_string($item)) {
             $lines[] = $item;
             continue;
         }
         if (!isset($item['label'])) {
             throw new InvalidConfigException("The 'label' option is required.");
         }
         $label = $this->encodeLabels ? Html::encode($item['label']) : $item['label'];
         $options = ArrayHelper::getValue($item, 'options', []);
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
         $linkOptions['tabindex'] = '-1';
         $content = Html::a($label, ArrayHelper::getValue($item, 'url', '#'), $linkOptions);
         if (isset($item['items'])) {
             Html::addCssClass($options, 'has-dropdown');
             $content .= FoundationNavDropDown::widget(['items' => $item['items']]);
         }
         $lines[] = Html::tag('li', $content, $options);
     }
     return Html::tag('ul', implode("\n", $lines), $this->options);
 }
Esempio n. 5
0
 /**
  * @return mixed
  */
 public function roleName()
 {
     $this->columns = array_merge($this->columns, [['attribute' => 'role_id', 'value' => function ($model, $key, $index, $column) {
         return isset($model->role_id) ? Html::encode($model->role->name) : '';
     }]]);
     return $this;
 }
Esempio n. 6
0
 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);
 }
Esempio n. 7
0
 /**
  * @return mixed
  */
 public function role()
 {
     $this->columns = array_merge($this->columns, [['header' => 'role', 'value' => function ($model, $key, $index, $column) {
         return $model->getUserRole()->exists() ? Html::encode($model->userRole->role->name) : '';
     }]]);
     return $this;
 }
Esempio n. 8
0
 /**
  * @param $tagArray
  * @return array
  */
 public function saveTag($tagArray)
 {
     $saveTags = [];
     if (is_array($tagArray)) {
         foreach ($tagArray as $tag) {
             if ($tagObj = $this->find()->where('value=:value', [':value' => $tag])->one()) {
                 $saveTags[] = $tagObj->tag_id;
             } else {
                 if (!$this->find()->where('tag_id=:tag_id', [':tag_id' => (int) $tag])->exists()) {
                     $this->value = \yii\helpers\Html::encode($tag);
                     if ($this->save()) {
                         $saveTags[] = $this->tag_id;
                         $this->setIsNewRecord(true);
                         unset($this->tag_id);
                     } else {
                         return ['error' => $this->errors['value'][0]];
                     }
                 } else {
                     $saveTags[] = $tag;
                 }
             }
         }
     }
     return $saveTags;
 }
Esempio n. 9
0
 public function actionMonth($y = null, $m = null)
 {
     $m = Html::encode($m);
     $y = Html::encode($y);
     $model = yii::$app->orderModel;
     return $this->render('month', ['m' => $m, 'y' => $y, 'month' => yii::t('order', "month_{$m}"), 'model' => $model]);
 }
Esempio n. 10
0
 /**
  * @return mixed
  */
 public function nameWithLink()
 {
     $this->columns = array_merge($this->columns, [['attribute' => 'name', 'value' => function ($model, $key, $index, $column) {
         return Html::a(Html::encode($model->name), [SELF::CONTROLLER . '/view', 'id' => $model->id]);
     }, 'format' => 'raw']]);
     return $this;
 }
Esempio n. 11
0
 /**
  * Описание
  * @param $desc
  * @return string
  */
 public static function getDescription($desc)
 {
     if (empty($desc)) {
         return 'Нет описания';
     }
     return Html::encode($desc);
 }
Esempio n. 12
0
 /**
  * Отправка сообщения
  */
 public function actionSendMessage()
 {
     $message = Html::encode($_POST['message']);
     $recipient = intval($_POST['recipient']);
     $id = ChatMessage::createNew($message, $recipient)->id;
     echo json_encode(['id' => $id]);
 }
Esempio n. 13
0
 /**
  * @inheritdoc
  */
 public function renderItem($item)
 {
     if (is_string($item)) {
         return $item;
     }
     if (!isset($item['label'])) {
         throw new InvalidConfigException("The 'label' option is required.");
     }
     $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
     $label = $encodeLabel ? Html::encode($item['label']) : $item['label'];
     $options = ArrayHelper::getValue($item, 'options', []);
     $items = ArrayHelper::getValue($item, 'items');
     $url = ArrayHelper::getValue($item, 'url', '#');
     $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
     if (isset($item['active'])) {
         $active = ArrayHelper::remove($item, 'active', false);
     } else {
         $active = $this->isItemActive($item);
     }
     Html::addCssClass($linkOptions, 'filter-item');
     if ($this->activateItems && $active) {
         Html::addCssClass($linkOptions, 'selected');
     }
     return Html::tag('li', Html::a($label, $url, $linkOptions) . $items, $options);
 }
Esempio n. 14
0
 public static function echoEncodeString($string, $default = '')
 {
     if ($string != '0') {
         $string = $string ? $string : $default;
     }
     return Html::encode($string);
 }
Esempio n. 15
0
 /**
  * Provides a searchable user list of all workspace members in json.
  *
  */
 public function actionSearch()
 {
     Yii::$app->response->format = 'json';
     $space = $this->getSpace();
     if (!$space->isMember()) {
         throw new HttpException(404, Yii::t('SpaceModule.controllers_SpaceController', 'This action is only available for workspace members!'));
     }
     $results = array();
     $keyword = Yii::$app->request->get('keyword');
     $query = User::find();
     $query->leftJoin('space_membership', 'space_membership.user_id=user.id AND space_membership.space_id=:space_id AND space_membership.status=:member', ['space_id' => $space->id, 'member' => Membership::STATUS_MEMBER]);
     $query->andWhere('space_membership.space_id IS NOT NULL');
     $query->joinWith('profile');
     $query->limit(10);
     // Build Search Condition
     $parts = explode(" ", $keyword);
     $i = 0;
     foreach ($parts as $part) {
         $i++;
         $query->andWhere("(user.email LIKE :match OR " . "user.username LIKE :match OR " . "profile.firstname LIKE :match OR " . "profile.lastname LIKE :match OR " . "profile.title LIKE :match)", ['match' => '%' . $part . '%']);
     }
     foreach ($query->all() as $user) {
         $userInfo['guid'] = $user->guid;
         $userInfo['displayName'] = \yii\helpers\Html::encode($user->displayName);
         $userInfo['email'] = $user->email;
         $userInfo['image'] = $user->getProfileImage()->getUrl();
         $userInfo['link'] = $user->getUrl();
         $results[] = $userInfo;
     }
     return $results;
 }
Esempio n. 16
0
 /**
  * @inheritdoc
  */
 public function format($record, $view)
 {
     HighlightAsset::register($view);
     $view->registerJs('hljs.highlightBlock(document.getElementById("response-content"));');
     $view->registerCss('pre code.hljs {background: transparent}');
     return Html::tag('pre', Html::tag('code', Html::encode($record->content), ['id' => 'response-content', 'class' => 'html']));
 }
Esempio n. 17
0
 public static function getChildMenu($ParentId, $ParentLabel)
 {
     $menuData = Menu::find()->where(['ismenu' => TRUE, 'status' => TRUE, 'parentid' => $ParentId, 'isweb' => FALSE])->orderBy('orderby')->all();
     $submenu = array();
     $menu = array();
     if (!empty($menuData)) {
         foreach ($menuData as $mKey => $mValue) {
             $menu['label'] = Html::tag('i', '', ['class' => $mValue['labelicon']]) . Html::encode($mValue['label']);
             $urlArray = [$mValue['module'], $mValue['controller'], $mValue['action']];
             $menu['url'] = \Yii::$app->urlManager->createUrl(implode('/', $urlArray));
             $class = '';
             if (\Yii::$app->controller->id == $urlArray[1] && \Yii::$app->controller->action->id == $urlArray[2]) {
                 $class = 'active';
                 \Yii::$app->params['breadcrumbs'][] = $ParentLabel;
                 \Yii::$app->params['breadcrumbs'][] = $mValue['label'];
             }
             $menu['options'] = ['class' => $class];
             $submenu[$mValue['orderby']] = $menu;
             unset($menu, $urlArray);
         }
         // $submenu['options'] = ['class' => 'children'];
     }
     return $submenu;
     //, 'options' => ['class' => 'children']];
 }
Esempio n. 18
0
 public function setParam($category_id, $post, $db)
 {
     $cfh_id = (int) $post['cfh_id'];
     $title = Html::encode(trim($post['title']));
     $pid = (int) $post['pid'];
     $par_id = $db->createCommand("SELECT param_id FROM idc_categories_filters_params WHERE param = :param")->bindValues([':param' => $title])->queryScalar();
     if ($cfh_id && $title && $pid) {
         if ($par_id) {
             $db->createCommand("UPDATE idc_categories_filters_params_hooks SET idc_categories_filters_params_hooks.param_id = :par_id\n                                    WHERE idc_categories_filters_params_hooks.param_id = :pid\n                                    AND idc_categories_filters_params_hooks.cfh_id = :cfh_id")->bindValues([':cfh_id' => $cfh_id, ':pid' => $pid, ':par_id' => $par_id])->execute();
         } else {
             $db->createCommand("UPDATE idc_categories_filters_params SET idc_categories_filters_params.param = :title\n                    WHERE idc_categories_filters_params.param_id = :pid")->bindValues([':title' => $title, ':pid' => $pid])->execute();
         }
     } elseif ($cfh_id && $title && !$pid) {
         if (!$par_id) {
             $db->createCommand()->insert('idc_categories_filters_params', ['param' => $title])->execute();
             $pid = $db->getLastInsertID();
         } else {
             $pid = $par_id;
         }
         $cid = $category_id;
         $db->createCommand('INSERT INTO idc_categories_filters_params_hooks (cfh_id, param_id)
                                 SELECT :cfh_id, cfp.param_id
                                 FROM idc_categories_filters_params AS cfp
                                 WHERE cfp.param_id = :pid')->bindValues([':cfh_id' => $cfh_id, ':pid' => $pid])->execute();
         return ['cid' => $cid, 'pid' => $pid];
     }
     return false;
 }
Esempio n. 19
0
 public function render($content = null)
 {
     if ($content === null) {
         if (!isset($this->parts['{input}'])) {
             $this->parts['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
         }
         if (!isset($this->parts['{label}'])) {
             $labelsHelp = $this->model->attributeHints();
             if (isset($labelsHelp[$this->attribute])) {
                 $this->labelOptions['label'] = '<span data-toggle="tooltip" title="" data-original-title="';
                 $this->labelOptions['label'] .= Html::encode($labelsHelp[$this->attribute]);
                 $this->labelOptions['label'] .= '">';
                 $this->labelOptions['label'] .= Html::encode($this->model->getAttributeLabel($this->attribute));
                 $this->labelOptions['label'] .= ' <span class="glyphicon glyphicon-question-sign" style="font-size: 8pt;" aria-hidden="true"></span>';
                 $this->labelOptions['label'] .= '</span>';
             } else {
                 $this->labelOptions['label'] = Html::encode($this->model->getAttributeLabel($this->attribute));
             }
             $this->parts['{label}'] = Html::activeLabel($this->model, $this->attribute, $this->labelOptions);
         }
         if (!isset($this->parts['{error}'])) {
             $this->parts['{error}'] = Html::error($this->model, $this->attribute, $this->errorOptions);
         }
         if (!isset($this->parts['{hint}'])) {
             $this->parts['{hint}'] = '';
         }
         $content = strtr($this->template, $this->parts);
     } elseif (!is_string($content)) {
         $content = call_user_func($content, $this);
     }
     return $this->begin() . "\n" . $content . "\n" . $this->end();
 }
Esempio n. 20
0
 public function renderItem($header, $item, $index)
 {
     if (array_key_exists('content', $item)) {
         $id = $this->options['id'] . '-collapse' . $index;
         $options = ArrayHelper::getValue($item, 'contentOptions', []);
         $options['id'] = $id;
         $expanded = false;
         if (array_key_exists('expanded', $item)) {
             $expanded = $item['expanded'];
         }
         Html::addCssClass($options, 'panel-collapse collapse' . ($expanded ? ' in' : ''));
         $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
         if ($encodeLabel) {
             $header = Html::encode($header);
         }
         $headerToggle = Html::a($header, '#' . $id, ['class' => 'collapse-toggle', 'data-toggle' => 'collapse', 'data-parent' => '#' . $this->options['id']]) . "\n";
         $header = Html::tag('h4', $headerToggle, ['class' => 'panel-title']);
         if (is_string($item['content'])) {
             $content = Html::tag('div', $item['content'], ['class' => 'panel-body']) . "\n";
         } elseif (is_array($item['content'])) {
             $content = Html::ul($item['content'], ['class' => 'list-group', 'itemOptions' => ['class' => 'list-group-item'], 'encode' => false]) . "\n";
             if (isset($item['footer'])) {
                 $content .= Html::tag('div', $item['footer'], ['class' => 'panel-footer']) . "\n";
             }
         } else {
             throw new InvalidConfigException('The "content" option should be a string or array.');
         }
     } else {
         throw new InvalidConfigException('The "content" option is required.');
     }
     $group = [];
     $group[] = Html::tag('div', $header, ['class' => 'panel-heading']);
     $group[] = Html::tag('div', $content, $options);
     return implode("\n", $group);
 }
 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;
 }
 /**
  * Generates the button dropdown.
  * @return string the rendering result.
  */
 protected function renderButton()
 {
     Html::addCssClass($this->options, 'btn');
     $label = $this->label;
     if ($this->encodeLabel) {
         $label = Html::encode($label);
     }
     $options = $this->options;
     $splitButton = '';
     $caretHtml = $this->caretHtml ? $this->caretHtml : '<span class="caret"></span>';
     if ($this->split) {
         $options = $this->options;
         $this->options['data-toggle'] = 'dropdown';
         Html::addCssClass($this->options, 'dropdown-toggle');
         $splitButton = Button::widget(['label' => $this->caretHtml ? $this->caretHtml : '<span class="caret"></span>', 'encodeLabel' => false, 'options' => $this->options, 'view' => $this->getView()]);
     } else {
         $label .= ' ' . $this->caretHtml ? $this->caretHtml : '<span class="caret"></span>';
         $options = $this->options;
         if (!isset($options['href'])) {
             $options['href'] = '#';
         }
         Html::addCssClass($options, 'dropdown-toggle');
         $options['data-toggle'] = 'dropdown';
     }
     return Button::widget(['tagName' => $this->tagName, 'label' => $label, 'options' => $options, 'encodeLabel' => false, 'view' => $this->getView()]) . "\n" . $splitButton;
 }
 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());
     }
 }
 public function display($content = null)
 {
     if ($content != null) {
         $this->content = $content;
     }
     return Html::encode($this->content);
 }
Esempio n. 25
0
 /**
  * Возвращает массив скартой сайта
  * @return array
  * @throws InvalidConfigException
  */
 public function getElements()
 {
     $elements = [];
     foreach ($this->definition as $item) {
         if (empty($item["class"]) || empty($item["urlCreate"])) {
             throw new InvalidConfigException("Class or url create function missing");
         }
         $query = $item["class"]::find();
         $scopes = !empty($item["scopes"]) ? $item["scopes"] : [$this->defaultScope];
         $labelAttr = !empty($item["labelAttr"]) ? $item["labelAttr"] : $this->defaultLabelAttr;
         $this->applyScopes($query, $scopes);
         if ($query instanceof TActiveQuery) {
             $query->orderBy(["lft" => SORT_ASC]);
         } else {
             $query->orderBy(["id" => SORT_DESC]);
         }
         $iterator = $query->each();
         $arr = [];
         $arr['header'] = !empty($item["entityLabel"]) && is_callable($item["entityLabel"]) ? call_user_func($item["entityLabel"]) : $item["class"]::getEntityName();
         if (!empty($item["entityRoute"])) {
             $arr['entityUrl'] = Url::toRoute($item["entityRoute"]);
         }
         $arr['items'] = [];
         foreach ($iterator as $model) {
             if (empty($model->{$labelAttr}) or !empty($item["doAdd"]) and !call_user_func($item["doAdd"], $model)) {
                 continue;
             }
             $arr['items'][] = ["label" => $model->{$labelAttr}, "url" => Html::encode(call_user_func($item["urlCreate"], $model)), "date" => $model->updated_at];
         }
         $elements[] = $arr;
     }
     return $elements;
 }
Esempio n. 26
0
 public function run()
 {
     if (!$this->visible) {
         return false;
     }
     if (($class = self::sizeToClass($this->size)) !== false) {
         Html::addCssClass($this->options, $class);
     }
     Html::addCssClass($this->options, "btn-{$this->type}");
     $label = $this->encodeLabel ? Html::encode($this->label) : $this->label;
     if (isset($this->icon)) {
         $label = "<i class='glyphicon glyphicon-{$this->icon}'></i> " . $label;
     }
     if (isset($this->url)) {
         $this->tagName = 'a';
         $this->options['role'] = 'button';
         $this->options['href'] = Url::to($this->url);
         if ($this->disabled) {
             Html::addCssClass($this->options, 'disabled');
         }
     } else {
         if ($this->disabled) {
             $this->options['disabled'] = 'disabled';
         }
     }
     if ($this->block) {
         Html::addCssClass($this->options, 'btn-block');
     }
     $html = Html::tag($this->tagName, $label, $this->options);
     echo $html;
     $this->registerPlugin('button');
 }
Esempio n. 27
0
 /**
  * Renders menu items.
  * @param array $items the menu items to be rendered
  * @return string the rendering result.
  * @throws InvalidConfigException if the label option is not specified in one of the items.
  */
 protected function renderItems($items)
 {
     $lines = [];
     foreach ($items as $i => $item) {
         if (isset($item['visible']) && !$item['visible']) {
             unset($items[$i]);
             continue;
         }
         if (is_string($item)) {
             $lines[] = $item;
             continue;
         }
         if (!isset($item['label'])) {
             throw new InvalidConfigException("The 'label' option is required.");
         }
         $label = $this->encodeLabels ? Html::encode($item['label']) : $item['label'];
         $options = ArrayHelper::getValue($item, 'options', []);
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
         $linkOptions['tabindex'] = '-1';
         if (!empty($item['items'])) {
             Html::addCssClass($linkOptions, 'dropdown-toggle');
             $linkOptions['data-toggle'] = 'dropdown';
             $content = Html::a($label, ArrayHelper::getValue($item, 'url', '#'), $linkOptions) . $this->renderItems($item['items']);
             $options = ArrayHelper::merge($this->subMenuOptions, $options);
             Html::addCssClass($options, 'dropdown dropdown-submenu');
         } else {
             $content = Html::a($label, ArrayHelper::getValue($item, 'url', '#'), $linkOptions);
         }
         $lines[] = Html::tag('li', $content, $options);
     }
     return Html::tag('ul', implode("\n", $lines), $this->options);
 }
 public function actionMonth($y = null, $m = null)
 {
     $m = Html::encode($m);
     $y = Html::encode($y);
     if ($data = yii::$app->request->post('user_id')) {
         Schedule::deleteAll("date_format(date, '%Y%m') = :date", [':date' => $y . $m]);
         foreach ($data as $date => $shifts) {
             foreach ($shifts as $shiftId => $userIds) {
                 if (is_array($userIds)) {
                     foreach ($userIds as $userId) {
                         $model = new Schedule();
                         $model->date = $date;
                         $model->shift = $shiftId;
                         $model->user_id = $userId;
                         $model->save();
                     }
                 }
             }
         }
         yii::$app->session->setFlash('success', 'Данные успешно сохранены');
         return $this->redirect(['/worksess/schedule/month', 'y' => $y, 'm' => $m]);
     }
     $model = new Schedule();
     $workers = yii::$app->getModule('worksess')->getWorkersList();
     return $this->render('month', ['m' => $m, 'y' => $y, 'module' => $this->module, 'months' => self::getMonths(), 'days' => self::getDays(), 'month' => yii::t('order', "month_{$m}"), 'model' => $model, 'workers' => $workers]);
 }
Esempio n. 29
0
 public function actionRss()
 {
     /** @var News[] $news */
     $news = News::find()->where(['status' => News::STATUS_PUBLIC])->orderBy('id DESC')->limit(50)->all();
     $feed = new Feed();
     $feed->title = 'YiiFeed';
     $feed->link = Url::to('');
     $feed->selfLink = Url::to(['news/rss'], true);
     $feed->description = 'Yii news';
     $feed->language = 'en';
     $feed->setWebMaster('*****@*****.**', 'Alexander Makarov');
     $feed->setManagingEditor('*****@*****.**', 'Alexander Makarov');
     foreach ($news as $post) {
         $item = new Item();
         $item->title = $post->title;
         $item->link = Url::to(['news/view', 'id' => $post->id], true);
         $item->guid = Url::to(['news/view', 'id' => $post->id], true);
         $item->description = HtmlPurifier::process(Markdown::process($post->text));
         if (!empty($post->link)) {
             $item->description .= Html::a(Html::encode($post->link), $post->link);
         }
         $item->pubDate = $post->created_at;
         $item->setAuthor('*****@*****.**', 'YiiFeed');
         $feed->addItem($item);
     }
     $feed->render();
 }
Esempio n. 30
0
function print_comment($param, $level = 0)
{
    //$output = '<div><ul class="comments">';
    $output = '';
    foreach ($param as $key => $value) {
        //$output .= '<li id="comment-'.$value['id'].'" class="clearfix">';
        $output .= '<article id="comment-' . $value['id'] . '" class="clearfix" style="margin-left: ' . $level * 20 . 'px">';
        $output .= Html::img("http://gravatar.com/avatar/?s=" . ($value['gravatar_id'] ? $value['gravatar_id'] : '230'), ['class' => 'avatar']);
        $output .= '    <div class="post-comments">';
        //$output .= '        <p class="meta">'.Html::encode($value['created_date']).'<a href="#">'.Html::encode($value['author']).'</a> пишет : <i class="pull-right"><a id="comment-reply" data-id="'.$value['id'].'"><small>Ответить</small></a></i></p>';
        $output .= '<p class="meta">';
        //$output .= Yii::$app->formatter->asDatetime($value['created_date'], Yii::$app->params['datetimeFormat']);
        $output .= print_mysqldate_russian($value['created_date']) . '&nbsp;&nbsp;<strong>' . Html::encode($value['author']) . '</strong>&nbsp;пишет:';
        $output .= '<i class="pull-right"><a id="comment-reply" href="#comment-form" data-id="' . $value['id'] . '"><small>Ответить</small></a></i>';
        $output .= '</p>';
        //href="#comment-form"
        $output .= '        <p>' . $value['content'] . '</p>';
        $output .= '    </div>';
        $output .= '</article>';
        if ($value['childs']) {
            $output .= print_comment($value['childs'], $level + 1);
        }
        //$output .= '</li>';
    }
    //$output .= '</ul></div>';
    return $output;
}