Example #1
23
 public function run()
 {
     if ($this->footerWrapper) {
         echo Html::beginTag('div', ['class' => 'form-group panel-footer']);
     }
     $submit_options = [];
     if ($this->form) {
         $submit_options['form'] = $this->form;
     }
     $extra = '';
     if ($this->extraBtns) {
         $extra = ' ' . implode(' ', (array) $this->extraBtns);
     }
     if (isset($this->model->isNewRecord) && $this->model->isNewRecord) {
         if ($this->saveLink) {
             $submit_options['class'] = 'btn btn-success';
             echo Html::submitButton(__('Create'), $submit_options);
         }
         echo $extra;
     } else {
         if ($this->saveLink) {
             $submit_options['class'] = 'btn btn-primary';
             echo Html::submitButton(__('Update'), $submit_options);
         }
         echo $extra;
         if ($this->removeLink) {
             echo ' ';
             echo Html::a(__('Delete'), ['delete', 'id' => $this->model->id], ['class' => 'btn btn-danger', 'data-confirm' => __('Are you sure you want to delete this item?'), 'data-method' => 'post']);
         }
     }
     if ($this->footerWrapper) {
         echo Html::endTag('div');
     }
 }
 /**
  * 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]);
 }
Example #3
4
 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;
 }
 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]);
         }]);
     }]]];
 }
 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);
 }
Example #6
2
 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);
 }
Example #7
2
 public function init()
 {
     $url = is_array($this->route) ? Url::to($this->route) : Url::to([$this->route, 'term' => 'QUERY']);
     $this->dataset = [['remote' => ['url' => $url, 'wildcard' => 'QUERY'], 'templates' => ['empty' => Html::tag('span', Yii::t('app', 'Hit enter to search'), ['class' => 'empty-search']), 'suggestion' => new JsExpression("Handlebars.compile('{$this->template}')")]]];
     $this->pluginOptions = ['hint' => false];
     parent::init();
 }
 public function getHint()
 {
     if ($this->owner->isNewRecord || !$this->file) {
         return '';
     }
     return Html::a(Yii::t('app', 'View attached file'), $this->fileUrl, ['target' => '_blank']);
 }
Example #9
1
 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();
 }
Example #10
1
 public function run()
 {
     echo Html::beginTag('img', $this->options);
     $this->options['src'] = ArrayHelper::remove($this->options, 'data-src');
     Html::removeCssClass($this->options, 'lazy');
     echo '<noscript>' . Html::beginTag('img', $this->options) . '</noscript>';
 }
 /**
  * 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' => '']);
 }
    public function run()
    {
        $chatModel = new \nitm\widgets\models\Replies(['constrain' => ['type' => 'chat']]);
        $notificationModel = new \nitm\widgets\models\Notification(['constrain' => ['user_id' => \Yii::$app->user->getId()], 'queryOptions' => ['read' => 0]]);
        $uniqid = uniqid();
        $chatWidget = Nav::widget(['encodeLabels' => false, 'options' => ['id' => 'communication-center-messages-wrapper' . $uniqid, 'class' => 'nav navbar-right navbar-nav'], 'items' => [['label' => Icon::show('comment') . Html::tag('span', $chatModel->hasNew(), ['class' => 'badge']), 'options' => ['class' => !$chatModel->hasNew() ? 'text-disabled' : 'text-success'], 'linkOptions' => ['id' => 'communication-center-messages-button' . $uniqid, 'title' => 'Click here again to refresh the info', 'role' => 'dynamicValue', 'data-run-once' => 1, 'data-animation-target' => '#chat' . $uniqid, 'data-animation-start-only' => 1, 'data-type' => 'html', 'data-id' => '#chat' . $uniqid, 'data-url' => \Yii::$app->urlManager->createUrl(['/reply/index/chat/0', '__format' => 'html', \nitm\widgets\models\Replies::FORM_PARAM => true])], 'items' => [['label' => Html::tag('div', Html::tag('h2', 'Loading Messages...', ['class' => 'text-center']) . Html::script('$("#communication-center-messages-button' . $uniqid . '").one("mouseover", function (event) {
								$(this).trigger("click");
							})', ['type' => 'text/javascript']), ['role' => 'chatParent', 'id' => 'chat' . $uniqid, 'class' => '']), 'options' => $this->contentOptions]]]]]);
        $alertWidget = Nav::widget(['encodeLabels' => false, 'options' => ['id' => 'communication-center-notifications-wrapper' . $uniqid, 'class' => 'nav navbar-right navbar-nav'], 'items' => [['label' => Icon::show('bell') . Html::tag('span', $notificationModel->count(), ['class' => 'badge']), 'options' => ['class' => !$notificationModel->count() ? 'bg-disabled' : 'bg-success'], 'linkOptions' => ['id' => 'communication-center-notifications-button' . $uniqid, 'title' => 'Click here again to refresh the info', 'role' => 'dynamicValue', 'data-run-once' => 1, 'data-animation-target' => '#communication-center-notifications' . $uniqid, 'data-animation-start-only' => 1, 'data-type' => 'html', 'data-id' => '#communication-center-notifications' . $uniqid, 'data-url' => \Yii::$app->urlManager->createUrl(['/alerts/notifications', '__format' => 'html'])], 'items' => [['label' => Html::tag('div', Html::tag('h2', 'Loading Alerts...', ['class' => 'text-center']) . Html::script('$("#communication-center-notifications-button' . $uniqid . '").one("mouseover", function (event) {
								$(this).trigger("click");
							})', ['type' => 'text/javascript']), ['id' => 'communication-center-notifications' . $uniqid, 'class' => '']), 'options' => $this->contentOptions]]]]]);
        $widget = $alertWidget . $chatWidget;
        //$js = "\$nitm.onModuleLoad('communication-center', function (module) {
        //	module.initChatTabs('#".$this->options['id']."');
        //});";
        $js = "";
        if ($this->chatUpdateOptions['enabled']) {
            $js .= "\$nitm.onModuleLoad('polling', function (module) {\r\n\t\t\t\tmodule.initPolling('chat', {\r\n\t\t\t\t\tenabled: true,\r\n\t\t\t\t\turl: '" . $this->chatUpdateOptions['url'] . "', \r\n\t\t\t\t\tinterval: " . $this->chatUpdateOptions['interval'] . ",\r\n\t\t\t\t\tcontainer: '#nitm-communication-center-widget" . $uniqid . "'\r\n\t\t\t\t}, {object: \$nitm.module('replies'), method: 'chatStatus'});\r\n\t\t\t});";
        }
        if ($this->notificationUpdateOptions['enabled']) {
            $js .= "\r\n\t\t\t\$nitm.onModuleLoad('polling', function (module) {\r\n\t\t\t\tmodule.initPolling('notifications', {\r\n\t\t\t\t\tenabled: true,\r\n\t\t\t\t\tinterval: " . $this->notificationUpdateOptions['interval'] . ",\r\n\t\t\t\t\turl: '" . $this->notificationUpdateOptions['url'] . "',\r\n\t\t\t\t\tcontainer: '#nitm-communication-center-widget" . $uniqid . "'\r\n\t\t\t\t}, {object: \$nitm.module('notifications'), method: 'notificationStatus'});\r\n\t\t\t});";
        }
        if ($js) {
            $js = Html::script($js, ['type' => 'text/javascript']);
        }
        return $widget . $js;
    }
Example #13
1
 /**
  * Inits pager
  */
 protected function initPager()
 {
     $this->pager['firstPageLabel'] = Html::tag('i', '', ['class' => 'fa fa-angle-double-left']);
     $this->pager['lastPageLabel'] = Html::tag('i', '', ['class' => 'fa fa-angle-double-right']);
     $this->pager['prevPageLabel'] = Html::tag('i', '', ['class' => 'fa fa-angle-left']);
     $this->pager['nextPageLabel'] = Html::tag('i', '', ['class' => 'fa fa-angle-right']);
 }
Example #14
1
 /**
  * Renders the widget.
  */
 public function run()
 {
     echo Html::endTag('div');
     //closes the container, opened on init
     $this->infiniteScrollScript();
     $this->registerPlugin();
 }
Example #15
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"]);
         }
     }
 }
 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;
 }
Example #17
0
 /**
  * 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);
 }
Example #18
0
 /**
  * @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;
 }
Example #19
0
 public function run()
 {
     if ($this->hasModel()) {
         return Html::activeTextInput($this->model, $this->attribute, $this->options);
     }
     return Html::textInput($this->name, $this->value, $this->options);
 }
 public function actionIndex()
 {
     $model = new UploadForm();
     if (Yii::$app->request->isPost) {
         $model->file = UploadedFile::getInstance($model, 'file');
         $ext = $model->file->extension;
         $file_name = $model->file->baseName . '.' . $model->file->extension;
         if ($model->upload()) {
             if ($ext == 'csv') {
                 $erros = $this->ConverterCSV($file_name);
             }
             if ($ext == 'txt') {
                 $erros = $this->ConverterTXT($file_name);
             }
             if ($erros == NULL) {
                 $link = Html::a('Ver em produtos', ['/produto'], ['class' => 'btn btn-primary']);
                 \Yii::$app->getSession()->setFlash('success', 'Dados importados! ' . $link . '');
             } else {
                 if (is_array($erros)) {
                     $texto_erro = "";
                     foreach ($erros as $erro) {
                         $texto_erro .= $erro . '<br/>';
                     }
                     \Yii::$app->getSession()->setFlash('error', $texto_erro);
                 }
             }
         }
     }
     return $this->render('index', ['model' => $model]);
 }
Example #21
0
 protected static function renderRow($model, $row, $templateName = null)
 {
     if (!empty($row['items'])) {
         $html = null;
         $items = static::renderItems($model, $row['items'], $templateName);
         if (count($items)) {
             $type = !empty($row['type']) && in_array($row['type'], self::types()) ? self::$types[$row['type']] : ['tag' => null, 'class' => null, 'delimiter' => "\n"];
             if (!empty($type['tag']) && !empty($type['options']) && count($items) > 1) {
                 $html .= Html::beginTag($type['tag'], $type['options']);
             }
             foreach ($items as $elements) {
                 if (!empty($type['itemTag'])) {
                     $html .= Html::beginTag($type['itemTag']);
                 }
                 foreach ($elements as $element) {
                     $html .= $element;
                 }
                 if (!empty($type['itemTag'])) {
                     $html .= Html::endTag($type['itemTag']);
                 }
             }
             if (!empty($type['tag']) && !empty($type['options']) && count($items) > 1) {
                 $html .= Html::endTag($type['tag']);
             }
         }
     }
     return $html;
 }
Example #22
0
 public static function getHtmlOptions($tag, $asString = true)
 {
     $tag = strtolower($tag);
     $options = [];
     switch ($tag) {
         case 'body':
             if (strcasecmp(Metronic::getComponent()->headerOption, 'fixed') === 0) {
                 Html::addCssClass($options, 'page-header-fixed');
             }
             switch (Metronic::getComponent()->layoutOption) {
                 case Metronic::LAYOUT_FULL_WIDTH:
                     Html::addCssClass($options, Metronic::LAYOUT_FULL_WIDTH);
                     break;
                 case Metronic::LAYOUT_BOXED:
                     Html::addCssClass($options, Metronic::LAYOUT_BOXED);
                     break;
             }
             break;
         case 'header':
             Html::addCssClass($options, 'header navbar');
             if (strcasecmp(Metronic::getComponent()->headerOption, 'fixed') === 0) {
                 Html::addCssClass($options, 'navbar-fixed-top');
             } else {
                 Html::addCssClass($options, 'navbar-static-top');
             }
             break;
     }
     return $asString ? Html::renderTagAttributes($options) : $options;
 }
Example #23
-1
    public function registerJs()
    {
        AssetsCallBack::register($this->getView());
        $js = "mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(file, id){\n                \$('#' + id).val(file.url); return true;\n            });\n            \$('#" . $this->buttonOptions['id'] . "').click(function(){\n                mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");});";
        $this->getView()->registerJs($js);
        $this->getView()->registerJs("mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(file, id){\n                var img;\n                if((\"url\" in file )){\n                    img = templateItem.replace('{src}', file.url).replace('{src}', file.url);\n                    \$('#{$this->previewId}').append(img);\n                } else {\n                    file.forEach(function(item){\n                        img = templateItem.replace('{src}', item.url).replace('{src}', item.url);\n                        \$('#{$this->previewId}').append(img);\n                    });\n                }\n                return true;}); ");
        $hiddenInput = Html::activeHiddenInput($this->model, $this->attribute . '[]', ['value' => '{src}']);
        $templateJS = 'var templateItem = \'<div class="image-preview-wrap">
  <div class="image-preview">
    <img src="{src}" alt="">
  </div>
  <div class="delete-button">
    <a class="delete-image">
      <span class="glyphicon glyphicon-remove"></span>
    </a>
  </div>
  ' . $hiddenInput . '
</div>\';';
        $this->getView()->registerJs(str_replace(["\r", "\n"], '', $templateJS), \yii\web\View::POS_END);
        $deleteJs = '$(document).on("click", ".delete-button", function(){$(this).parent().remove()});';
        $this->getView()->registerJs($deleteJs);
        $this->view->registerCss('.form-img-preview {max-width:100px;}');
        $this->view->registerCss('.image-preview img {max-width:200px;}');
        $this->view->registerCss('.image-preview-wrap {position: relative;display: inline-block;max-width: 200px;margin: 10px;}');
        $this->view->registerCss('.delete-button {top: 0;position: absolute;right: 0;}');
    }
Example #24
-1
 public function init()
 {
     \kartik\base\InputWidget::init();
     $this->pluginOptions['theme'] = $this->theme;
     if (!empty($this->addon) || empty($this->pluginOptions['width'])) {
         $this->pluginOptions['width'] = '100%';
     }
     $multiple = ArrayHelper::getValue($this->pluginOptions, 'multiple', false);
     unset($this->pluginOptions['multiple']);
     $multiple = ArrayHelper::getValue($this->options, 'multiple', $multiple);
     $this->options['multiple'] = $multiple;
     if ($this->hideSearch) {
         $css = ArrayHelper::getValue($this->pluginOptions, 'dropdownCssClass', '');
         $css .= ' kv-hide-search';
         $this->pluginOptions['dropdownCssClass'] = $css;
     }
     $this->initPlaceholder();
     if ($this->data == null) {
         if (!isset($this->value) && !isset($this->initValueText)) {
             $this->data = [];
         } else {
             $key = isset($this->value) ? $this->value : ($multiple ? [] : '');
             $val = isset($this->initValueText) ? $this->initValueText : $key;
             $this->data = $multiple ? array_combine($key, $val) : [$key => $val];
         }
     }
     Html::addCssClass($this->options, 'form-control');
     $this->initLanguage('language', true);
     $this->registerAssets();
     $this->renderInput();
 }
Example #25
-1
 /**
  * @inheritdoc
  */
 public function run()
 {
     if (!empty($this->_fields)) {
         throw new InvalidCallException('Each beginField() should have a matching endField() call.');
     }
     echo Html::endForm();
 }
Example #26
-1
 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();
 }
Example #27
-1
 /**
  * Возвращает массив скартой сайта
  * @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;
 }
Example #28
-1
 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);
 }
 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);
 }
 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());
     }
 }