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]); }
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]); }]); }]]]; }
public function run() { if ($this->encode) { $this->text = Html::encode($this->text); } if (!$this->minimal) { $maxOembedCount = 3; // Maximum OEmbeds $oembedCount = 0; // OEmbeds used $this->text = preg_replace_callback('/(https?:\\/\\/.*?)(\\s|$)/i', function ($match) use(&$oembedCount, &$maxOembedCount) { // Try use oembed if ($maxOembedCount > $oembedCount) { $oembed = UrlOembed::GetOembed($match[0]); if ($oembed) { $oembedCount++; return $oembed; } } return Html::a($match[1], Html::decode($match[1]), array('target' => '_blank')) . $match[2]; }, $this->text); } // get user and space details from guids $this->text = self::translateMentioning($this->text, $this->minimal ? false : true); // create image tag for emojis $this->text = self::translateEmojis($this->text, $this->minimal ? false : true); if ($this->maxLength != 0) { $this->text = \humhub\libs\Helpers::truncateText($this->text, $this->maxLength); } return nl2br($this->text); }
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); }
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; }
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); }
/** * @param Model $model * @return string */ public static function getCategoryParentsLinks(Model $model) { $parents = array_map(function (Model $model) { return Html::a($model->title, ['view', 'id' => $model->id]); }, $model->parents); return implode(', ', $parents); }
public function init() { parent::init(); $this->content = function (ModelBase $model, $key, $index, DataColumn $column) { return Html::a($model->{$column->attribute}, ['view', 'id' => $model->primaryKey], ['title' => Yii::t('common', 'View')]); }; }
public function run() { return Html::ul($this->flatPageList, ['class' => $this->htmlClass, 'item' => function ($flatPage, $index) { $class = $flatPage->url == Yii::$app->controller->action->id ? $this->activeLiClass : null; return Html::tag('li', Html::a($flatPage->anchor, [$flatPage->url]), ['class' => $class]); }]); }
public function renderCategory($category) { $catRender = '<li>'; $catRender .= Html::a($category->name . ' (' . count($category->blogTermRelationships) . ')', ['blogposts/category', 'id' => $category->id, 'category' => $category->name]); $catRender .= '</li>'; return $catRender; }
/** * Hide link if user hasn't access to it * * @inheritdoc */ public static function a($text, $url = null, $options = []) { if (in_array($url, [null, '', '#'])) { return parent::a($text, $url, $options); } return User::canRoute($url) ? parent::a($text, $url, $options) : ''; }
/** * @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; }
public function api_widget($width, $height, $clientOptions = []) { if (!count($this->_items)) { return LIVE_EDIT ? Html::a(Yii::t('easyii/carousel/api', 'Create carousel'), ['/admin/carousel/a/create'], ['target' => '_blank']) : ''; } if (count($clientOptions)) { $this->clientOptions = array_merge($this->clientOptions, $clientOptions); } $items = []; foreach ($this->_items as $item) { $temp = ['content' => Html::img($item->thumb($width, $height)), 'caption' => '']; if ($item->link) { $temp['content'] = Html::a($temp['content'], $item->link); } if ($item->title) { $temp['caption'] .= '<h3>' . $item->title . '</h3>'; } if ($item->text) { $temp['caption'] .= '<p>' . $item->text . '</p>'; } $items[] = $temp; } $widget = \yii\bootstrap\Carousel::widget(['options' => ['class' => 'slide'], 'clientOptions' => $this->clientOptions, 'items' => $items]); return LIVE_EDIT ? API::liveEdit($widget, Url::to(['/admin/carousel']), 'div') : $widget; }
/** * Renders the widget. * @return string */ public function run() { echo Html::a('', false, ['name' => 'footer']); echo Html::beginTag('footer', ['class' => 'c-layout-footer c-layout-footer-4 c-bg-footer-8']); echo Html::beginTag('div', ['class' => 'c-footer']); echo Html::beginTag('div', ['class' => 'container']); echo Html::beginTag('div', ['class' => 'row']); echo Html::beginTag('div', ['class' => 'col-md-6 c-footer-4-p-right']); echo Html::beginTag('div', ['class' => 'c-content-title-1']); echo Html::tag('h3', $this->title, ['class' => 'c-font-uppercase c-font-bold c-font-white c-border']); echo Html::endTag('div'); echo Html::tag('p', $this->about, ['class' => 'c-about']); echo Html::tag('ul', $this->social, ['class' => 'c-socials']); echo Html::endTag('div'); echo Html::beginTag('div', ['class' => 'col-md-6 c-footer-4-p-right']); echo Html::beginTag('div', ['class' => 'c-feedback']); echo Html::tag('h3', 'CONTACT', ['class' => 'c-font-thin']); echo Html::tag('p', $this->contact, ['class' => 'c-contact c-font-white']); echo Html::endTag('div'); echo Html::endTag('div'); echo Html::endTag('div'); echo Html::endTag('div'); echo Html::endTag('div'); echo Html::endTag('footer'); }
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); }
private static function checkPagesSetup() { if (!\Yii::$app->getModule('pages')->getLocalizedRootNode()) { $link = Html::a('pages module', ['/pages']); \Yii::$app->session->addFlash('warning', "There is no navigation root node, visit {$link} to create a root node."); } }
/** * @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; }
function run() { foreach ($this->data as $n => $v) { if (isset($this->{$n})) { $this->{$n} = $v; } } $this->view->registerCssFile('http://code.ionicframework.com/ionicons/1.5.2/css/ionicons.min.css'); $link = $this->link; if (is_array($link)) { $link = Url::to($link); } if ($this->link_text === null) { $this->link_text = \Yii::t('app', 'More info'); } $html = "<!-- small box -->\n"; $html .= "<div class=\"col-lg-3 col-xs-6\">\n"; $html .= " <div class=\"small-box {$this->color}\">\n"; $html .= " <div class=\"inner\">"; $html .= Html::tag('h3', $this->count . Html::tag('sup', $this->count_type, ['style' => "font-size: 20px"])); $html .= Html::tag('p', $this->text); $html .= "</div>\n"; $html .= " <div class=\"icon\">"; $html .= Html::tag('i', '', ['class' => 'ion ' . $this->icon]); $html .= "</div>\n"; $html .= " "; $html .= Html::a($this->link_text . " <i class=\"fa fa-arrow-circle-right\"></i>", $link, ['class' => 'small-box-footer']); $html .= " </div>"; $html .= "</div>"; return $html; }
public function run() { $html = ''; foreach ($this->files as $file) { if (!isset($file['thumb']) || !isset($file['original'])) { continue; } $attributes = ['data-title' => isset($file['title']) ? $file['title'] : '']; if (isset($file['group'])) { $attributes['data-lightbox'] = $file['group']; } else { $attributes['data-lightbox'] = 'image-' . uniqid(); } if (is_array($file['thumb'])) { $src = $file['thumb']['src']; $options = $file['thumb']['htmlOptions']; } else { $src = $file['thumb']; $options = []; } $img = Html::img($src, $options); if (is_array($file['original'])) { $src = $file['original']['src']; $options = $attributes + $file['original']['htmlOptions']; } else { $src = $file['original']; $options = $attributes; } $a = Html::a($img, $src, $options); $html .= $a; } return $html; }
/** * Creates a new ProyectoDistribucionPresupuestaria model. * For ajax request will return json object * and for non-ajax request if creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($proyecto) { $request = Yii::$app->request; $model = new ProyectoDistribucionPresupuestaria(); $model->id_proyecto = $proyecto; if ($request->isAjax) { /* * Process for ajax request */ Yii::$app->response->format = Response::FORMAT_JSON; if ($request->isGet) { return ['title' => "Create new ProyectoDistribucionPresupuestaria", 'content' => $this->renderPartial('create', ['model' => $model]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])]; } else { if ($model->load($request->post()) && $model->save()) { return ['forceReload' => 'true', 'title' => "Create new ProyectoDistribucionPresupuestaria", 'content' => '<span class="text-success">Create ProyectoDistribucionPresupuestaria success</span>', 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::a('Create More', ['create'], ['class' => 'btn btn-primary', 'role' => 'modal-remote'])]; } else { return ['title' => "Create new ProyectoDistribucionPresupuestaria", 'content' => $this->renderPartial('create', ['model' => $model]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])]; } } } else { /* * Process for non-ajax request */ if ($model->load($request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } } }
public function run() { if ($this->text === null) { $this->text = $this->email; } $encodedMail = base64_encode('mailto:' . $this->email); $encodedText = base64_encode($this->text); $this->view->registerJs(<<<JS function d(s) { var e={},i,b=0,c,x,l=0,a,r='',w=String.fromCharCode,L=s.length; var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; for(i=0;i<64;i++){e[A.charAt(i)]=i;} for(x=0;x<L;x++){ c=e[s.charAt(x)];b=(b<<6)+c;l+=6; while(l>=8){((a=(b>>>(l-=8))&0xff)||(x<(L-2)))&&(r+=w(a));} } return r; } var a = document.getElementById('{$this->id}'); var m = d('{$encodedMail}'); a.href = m; a.innerHTML = d('{$encodedText}'); JS ); $this->options = array_merge(['id' => $this->id], $this->options); echo Html::a('', null, $this->options); }
/** * @inheritdoc */ public function apply($model) { if ($this->isDue() && in_array($model->ClassID, [6, 12])) { $userID = $model->contractor->id; \Yii::info('Проверка и применение акции "' . self::$name . '"' . "({$this->getModel()->id})" . ' для пользователя ' . Html::a($userID, ['/user/admin/update', 'id' => $userID]), 'info'); $settings = $this->getModel()->parseSettings(); if (empty($settings['attributes'])) { return false; } ArrayHelper::multisort($settings['attributes'], 'payment', SORT_DESC); $account = $model->contractor->account; foreach ($settings['attributes'] as $attributes) { $discount = $this->getModel()->getDiscount(); $discount->setAttributes($attributes); if ($model->CashSum >= $discount->payment) { \Yii::info('Применение акции с атрибутами: ' . Json::encode($attributes), 'info'); $account->BonusGames = $account->BonusGames + $discount->bonusGamesCount; if ($account->save(false, ['BonusGames'])) { $finance = new FinanceRecord(); $finance->CashSum = 0; $finance->ClassID = 21; //Начисление бонусов $finance->ContractorID = $model->ContractorID; $finance->Comment = $this->getDescription(); $finance->save(); return true; } } } } else { // var_export(in_array($model->ClassID, [6, 12])); } return false; }
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]); }
public function getHint() { if ($this->owner->isNewRecord || !$this->file) { return ''; } return Html::a(Yii::t('app', 'View attached file'), $this->fileUrl, ['target' => '_blank']); }
public function run() { $elements = $this->cart->elements; if (empty($elements)) { $cart = Html::tag('div', yii::t('cart', 'Your cart empty'), ['class' => 'pistol88-cart pistol88-empty-cart']); } else { $cart = Html::ul($elements, ['item' => function ($item, $index) { return $this->_row($item); }, 'class' => 'pistol88-cart-list']); } if (!empty($elements)) { $bottomPanel = ''; if ($this->showTotal) { $bottomPanel .= Html::tag('div', Yii::t('cart', 'Total') . ': ' . yii::$app->cart->cost . ' ' . yii::$app->cart->currency, ['class' => 'pistol88-cart-total-row']); } if ($this->offerUrl && $this->showOffer) { $bottomPanel .= Html::a(yii::t('cart', 'Offer'), $this->offerUrl, ['class' => 'pistol88-cart-offer-button btn btn-success']); } if ($this->showTruncate) { $bottomPanel .= TruncateButton::widget(); } $cart .= Html::tag('div', $bottomPanel, ['class' => 'pistol88-cart-bottom-panel']); } $cart = Html::tag('div', $cart, ['class' => 'pistol88-cart']); if ($this->type == self::TYPE_DROPDOWN) { $button = Html::button($this->textButton . Html::tag('span', '', ["class" => "caret"]), ['class' => 'btn dropdown-toggle', 'id' => 'pistol88-cart-drop', 'type' => "button", 'data-toggle' => "dropdown", 'aria-haspopup' => 'true', 'aria-expanded' => "false"]); $list = Html::tag('div', $cart, ['class' => 'dropdown-menu', 'aria-labelledby' => 'pistol88-cart-drop']); $cart = Html::tag('div', $button . $list, ['class' => 'pistol88-cart-dropdown dropdown']); } return Html::tag('div', $cart, ['class' => 'pistol88-cart-block']); }
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(); }
protected function initDefaultButtons() { if (!isset($this->buttons['update'])) { $this->buttons['update'] = function ($url, $model, $key) { return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['title' => \Yii::t('yii', 'Update'), 'data-pjax' => '0', 'ajax' => 'false', 'class' => 'btn btn-sm btn-primary', 'id' => 'button-update']); }; } if (!isset($this->buttons['delete'])) { $this->buttons['delete'] = function ($url, $model, $key) { return '<a id="button-delete" class="btn btn-sm btn-danger" href="' . $url . '" title="' . \Yii::t('yii', 'Delete') . '" data-confirm="' . \Yii::t('yii', 'Are you sure you want to delete this item?') . '" data-method="post" data-pjax=0><span class="fa fa-minus-circle"></span></a>'; /* return Html::tag('a', '<span class="fa fa-minus-circle"></span>', [ 'href' => $url, 'title' => \Yii::t('yii', 'Delete'), 'data-confirm' => \Yii::t('yii', 'Are you sure you want to delete this item?'), 'class' => 'btn btn-sm btn-danger', 'data-method' => 'post', 'data-pjax' => '0', 'id' => 'button-delete', ]);*/ }; } if (!isset($this->buttons['create'])) { $this->buttons['create'] = function ($url) { return Html::a('<span class="fa fa-plus-circle"></span>', $url, ['title' => \Yii::t('yii', 'Create'), 'class' => 'btn btn-sm btn-primary', 'data-method' => 'post', 'data-pjax' => '0', 'id' => 'button-create']); }; } }
/** * @throws InvalidConfigException */ public function init() { if (!$this->key) { throw new InvalidConfigException(); } $cacheKey = [WidgetCarousel::className(), $this->key]; $items = \Yii::$app->cache->get($cacheKey); if ($items === false) { $items = []; $query = WidgetCarouselItem::find()->joinWith('carousel')->where(['{{%widget_carousel_item}}.status' => 1, '{{%widget_carousel}}.status' => WidgetCarousel::STATUS_ACTIVE, '{{%widget_carousel}}.key' => $this->key])->orderBy(['order' => SORT_ASC]); foreach ($query->all() as $k => $item) { /** @var $item \common\models\WidgetCarouselItem */ if ($item->path) { $items[$k]['content'] = Html::img($item->getImageUrl()); } if ($item->url) { $items[$k]['content'] = Html::a($items[$k]['content'], $item->url, ['target' => '_blank']); } if ($item->caption) { $items[$k]['caption'] = $item->caption; } } \Yii::$app->cache->set($cacheKey, $items, 60 * 60 * 24 * 365); } $this->items = $items; parent::init(); }
public function renderItem($item) { $label = null; $url = $item['url']; $urlOptions = isset($item['urlOptions']) ? $item['urlOptions'] : null; $options = []; // Check whether label is required if ($this->label) { if (!isset($item['label'])) { throw new InvalidConfigException("The 'label' option is required."); } $label = $item['label']; } // Check whether icon is required if ($this->icon) { if (!isset($item['icon'])) { throw new InvalidConfigException("The 'icon' option is required."); } $icon = Html::tag('i', null, ['class' => $item['icon']]); $label = "<span class='wrap-icon'>{$icon}</span><span class='wrap-text'>{$label}</span>"; } if (isset($item['options'])) { $options = $item['options']; } return Html::tag('li', Html::a($label, $url, $urlOptions), $options); }