public function run() { $this->options['class'] = 'ajax-form'; parent::run(); $content = ob_get_clean(); return Html::tag('div', $content, ['class' => 'ajax-form-wrapper', 'style' => "max-width:{$this->maxWidth}px"]); }
public function run() { $this->genButton = Html::a(Icon::show('edit') . Yii::t('app', 'Generate'), '#', ['class' => 'btn btn-success', 'id' => 'btn-generate']); $parent_id = $this->model->main_category_id; $owner_id = $this->model->id; $this->addButton = Html::a(Icon::show('plus') . Yii::t('app', 'Add'), Url::toRoute(['/shop/backend-product/edit', 'parent_id' => $parent_id, 'owner_id' => $owner_id, 'returnUrl' => \app\backend\components\Helper::getReturnUrl()]), ['class' => 'btn btn-success', 'id' => 'btn-add']); if (!empty($this->footer)) { $this->footer = Html::tag('div', $this->addButton . ' ' . $this->genButton, ['class' => 'widget-footer']); } $this->object = Object::getForClass(get_class($this->model)); $rest_pg = (new Query())->select('id, name')->from(PropertyGroup::tableName())->where(['object_id' => $this->object->id])->orderBy('sort_order')->all(); $this->property_groups_to_add = []; foreach ($rest_pg as $row) { $this->property_groups_to_add[$row['id']] = $row['name']; } $optionGenerate = Json::decode($this->model->option_generate); if (null === PropertyGroup::findOne($optionGenerate['group'])) { $this->model->option_generate = $optionGenerate = null; } $groupModel = null; if (isset($optionGenerate['group'])) { $groupModel = PropertyGroup::findOne($optionGenerate['group']); $properties = Property::getForGroupId($optionGenerate['group']); } else { $group_ids = array_keys($this->property_groups_to_add); $group_id = array_shift($group_ids); $groupModel = PropertyGroup::findOne($group_id); $properties = Property::getForGroupId($group_id); } if (is_null($groupModel)) { $groupModel = new PropertyGroup(); } return $this->render($this->viewFile, ['model' => $this->model, 'form' => $this->form, 'groups' => $this->property_groups_to_add, 'groupModel' => $groupModel, 'properties' => $properties, 'optionGenerate' => $optionGenerate, 'footer' => $this->footer]); }
/** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { $value = $this->getDataCellValue($model, $key, $index); $name = $this->getLabelName($model, $key, $index, $value); $class = ArrayHelper::getValue($this->cssCLasses, $value, 'default'); $html = Html::tag('span', Html::encode($name), ['class' => 'label label-' . $class]); return $value === null ? $this->grid->emptyCell : $html; }
protected function renderDataCellContent($model, $key, $index) { $value = $this->getDataCellValue($model, $key, $index); $label = $value ? $this->getRoleLabel($value) : $value; $class = $value == $this->defaultRole ? 'primary' : 'danger'; $html = Html::tag('span', Html::encode($label), ['class' => 'label label-' . $class]); return $value === null ? $this->grid->emptyCell : $html; }
/** * @inheritdoc */ public function renderDataCell($model, $key, $index) { if (!$this->_isContextMenu) { return parent::renderDataCell($model, $key, $index); } else { $options = $this->fetchContentOptions($model, $key, $index); $this->parseExcelFormats($options, $model, $key, $index); $out = $this->renderDataCellContent($model, $key, $index); return Html::tag('td', $out, $options); } }
public function run() { if (!empty($this->footer)) { $this->footer = Html::tag('div', $this->footer, ['class' => 'widget-footer']); } if (!empty($this->icon)) { $this->title = Icon::show($this->icon) . $this->title; } $this->params['title'] = $this->title; $this->params['header_append'] = $this->header_append; $this->params['footer'] = $this->footer; $this->params['_id'] = $this->getId(); return parent::run(); }
protected function renderAddon(&$options, $type = 'picker') { if ($options === false) { return ''; } if (is_string($options)) { return $options; } Html::addCssClass($options, 'input-group-addon'); $icon = $type === 'picker' ? 'date_range' : 'close'; $icon = '<i class="glyphicon-calendar material-icons">' . $icon . '</i>'; if (empty($options['title'])) { $title = $type === 'picker' ? Yii::t('kvdtime', 'Select date & time') : Yii::t('kvdtime', 'Clear field'); if ($title != false) { $options['title'] = $title; } } return Html::tag('span', $icon, $options); }
public function run() { $rb = Yii::$app->user->can(Rbac::PERMISSION_ADMIN_PANEL); $model = new $this->model(); $points = $model::find()->all(); if (count($points) > 0) { $geoObject = ['type' => 'FeatureCollection']; foreach ($points as $point) { if ($rb) { $delete = '<hr>' . Html::a('<i class="material-icons">create</i> Редактировать', ['/admin/default/map-edit', 'id' => $point->id]) . ' ' . Html::a('<i class="material-icons">delete</i> Удалить', ['/admin/default/map-delete', 'id' => $point->id]); } else { $delete = ''; } $geoObject['features'][] = ['type' => 'Feature', 'id' => $point->id, 'geometry' => ['type' => 'Point', 'coordinates' => explode(',', $point->point)], 'properties' => ['balloonContent' => $point->body . $delete, 'iconContent' => $point->title], 'options' => ['id' => $point->id, 'preset' => $point->preset]]; } } else { $geoObject = false; } $view = $this->view; $view->registerJs("var geoObj = " . Json::encode($geoObject) . ";", $view::POS_HEAD); MapInputAsset::register($view); return Html::tag('div', '', ['id' => 'map', 'style' => "height:{$this->height}px"]); }
* @var \app\models\Form $searchModel */ use kartik\dynagrid\DynaGrid; use kartik\helpers\Html; $this->title = Yii::t('app', 'Currencies'); $this->params['breadcrumbs'][] = $this->title; ?> <?php echo app\widgets\Alert::widget(['id' => 'alert']); $this->beginBlock('add-button'); echo \yii\helpers\Html::a(\kartik\icons\Icon::show('plus') . ' ' . Yii::t('app', 'Add'), ['edit', 'returnUrl' => \app\backend\components\Helper::getReturnUrl()], ['class' => 'btn btn-success']); echo \app\backend\widgets\RemoveAllButton::widget(['url' => 'remove-all', 'gridSelector' => '.grid-view', 'htmlOptions' => ['class' => 'btn btn-danger pull-right']]); $this->endBlock(); ?> <div class="row"> <div class="col-md-12"> <?php echo DynaGrid::widget(['options' => ['id' => 'currencies-grid'], 'columns' => [['class' => \app\backend\columns\CheckboxColumn::className()], 'id', 'name', 'iso_code', 'convert_nominal', 'convert_rate', ['attribute' => 'currency_rate_provider_id', 'class' => \kartik\grid\EditableColumn::className(), 'editableOptions' => ['data' => [0 => '-'] + \app\components\Helper::getModelMap(\app\modules\shop\models\CurrencyRateProvider::className(), 'id', 'name'), 'inputType' => 'dropDownList', 'placement' => 'left', 'formOptions' => ['action' => 'update-editable']], 'filter' => \app\components\Helper::getModelMap(\app\modules\shop\models\CurrencyRateProvider::className(), 'id', 'name'), 'format' => 'raw', 'value' => function ($model, $key, $index, $column) { if ($model === null || $model->rateProvider === null) { return null; } return Html::tag('div', $model->rateProvider->name, ['class' => $model->rateProvider->name]); }], ['class' => \app\backend\components\ActionColumn::className()]], 'theme' => 'panel-default', 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'hover' => true, 'panel' => ['heading' => $this->render('_tabs', ['currencies' => true]), 'after' => $this->blocks['add-button']]]]); ?> </div> </div>
public function run() { $options = ['model' => $this->model, 'form' => $this->_form, 'attributes' => $this->attributes] + $this->options; echo Form::widget($options); if ($this->buttons != null) { $tag = ArrayHelper::remove($this->buttonsContainer, 'tag', 'div'); echo Html::tag($tag, $this->_buttons, $this->buttonsContainer); } ActiveForm::end(); }
<?php /** * @var $dataProvider \yii\data\ActiveDataProvider * @var $searchModel \app\components\SearchModel * @var $this \yii\web\View */ use app\backend\components\ActionColumn; use kartik\dynagrid\DynaGrid; use kartik\helpers\Html; use kartik\icons\Icon; $this->title = Yii::t('app', 'Users'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="user-index"> <?php echo DynaGrid::widget(['options' => ['id' => 'users-grid'], 'columns' => [['class' => \kartik\grid\CheckboxColumn::className(), 'options' => ['width' => '10px']], 'id', 'username', 'email:email', ['attribute' => 'status', 'filter' => \app\modules\user\models\User::getStatuses()], 'create_time:datetime', ['class' => ActionColumn::className(), 'options' => ['width' => '95px'], 'buttons' => [['url' => 'update', 'icon' => 'pencil', 'class' => 'btn-primary', 'label' => Yii::t('app', 'Edit')], ['url' => 'delete', 'icon' => 'trash-o', 'class' => 'btn-danger', 'options' => ['data-action' => 'delete'], 'label' => Yii::t('app', 'Delete')]]]], 'theme' => 'panel-default', 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'hover' => true, 'panel' => ['heading' => Html::tag('h3', $this->title, ['class' => 'panel-title']), 'after' => Html::a(Icon::show('plus') . Yii::t('app', 'Add'), ['/user/backend-user/update'], ['class' => 'btn btn-success']) . \app\backend\widgets\RemoveAllButton::widget(['url' => '/user/backend-user/remove-all', 'gridSelector' => '.grid-view', 'htmlOptions' => ['class' => 'btn btn-danger pull-right']])]]]); ?> </div>
* @var $form \yii\widgets\ActiveForm * @var $label string * @var $model \app\properties\AbstractModel * @var $multiple boolean * @var $property_id integer * @var $property_key string * @var $this \yii\web\View * @var $values \app\properties\PropertyValue */ use app\models\Property; use app\modules\shop\models\Product; use yii\helpers\ArrayHelper; use kartik\helpers\Html; $productIds = ArrayHelper::getColumn($values->values, 'value'); /** @var Product[] $products */ $products = Product::findAll($productIds); ?> <dl> <?php if (count($productIds) == 0) { return; } $property = Property::findById($property_id); echo Html::tag('dt', $property->name); foreach ($products as $product) { echo Html::tag('dd', Html::a($product->name, ['@product', 'model' => $product])); } ?> </dl>
<?php use kartik\helpers\Html; use yii\bootstrap\ActiveForm; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ $form = ActiveForm::begin(['id' => 'user-form', 'layout' => 'inline', 'method' => 'POST']); $ka = $rowNr; echo Html::beginTag('table'); echo Html::beginTag('tr', ['data-row' => '1']); echo Html::tag('td', $form->field($auth, '[' . $ka . ']type')->dropDownList($auth->getTypeArr(), ['style' => 'width:120px;', 'prompt' => '--'])); echo Html::tag('td', $form->field($auth, '[' . $ka . ']allowFrom')->textInput(['style' => 'width:120px;'])); echo Html::tag('td', $form->field($auth, '[' . $ka . ']allowTo')->textInput(['style' => 'width:120px;'])); echo Html::endTag('tr'); echo Html::endTag('table'); $form->end();
/** * Register assets */ protected function registerAssets() { $view = $this->getView(); DetailViewAsset::register($view); if (empty($this->alertWidgetOptions['closeButton'])) { $button = '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>'; } else { $opts = $this->alertWidgetOptions['closeButton']; $tag = ArrayHelper::remove($opts, 'tag', 'button'); $label = ArrayHelper::remove($opts, 'label', '×'); if ($tag === 'button' && !isset($opts['type'])) { $opts['type'] = 'button'; } $button = Html::tag($tag, $label, $opts); } $opts = ArrayHelper::getValue($this->alertWidgetOptions, 'options', []); if (!empty($opts['class'])) { $opts['class'] .= ' {class} fade in'; } else { $opts['class'] = '{class} fade in'; } $deleteConfirmMsg = Yii::t('kvdetail', 'Are you sure you want to delete this item?'); $this->pluginOptions = ['fadeDelay' => $this->fadeDelay, 'alertTemplate' => Html::tag('div', $button . '{content}', $opts), 'alertMessageSettings' => $this->alertMessageSettings, 'deleteParams' => ArrayHelper::getValue($this->deleteOptions, 'params', []), 'deleteAjaxSettings' => ArrayHelper::getValue($this->deleteOptions, 'ajaxSettings', []), 'deleteConfirm' => ArrayHelper::remove($this->deleteOptions, 'confirm', $deleteConfirmMsg), 'showErrorStack' => ArrayHelper::remove($this->deleteOptions, 'showErrorStack', false)]; $id = 'jQuery("#' . $this->container['id'] . '")'; if ($this->enableEditMode) { $options['mode'] = $this->mode; } $this->registerPlugin($this->pluginName, $id); if ($this->tooltips) { $view->registerAssetBundle('yii\\bootstrap\\BootstrapPluginAsset'); $view->registerJs($id . '.find("[data-toggle=tooltip]").tooltip();'); } }
/** * @param $id * @return array * @throws BadRequestHttpException * @throws NotFoundHttpException */ public function actionUpdatePaymentType($id) { Yii::$app->response->format = Response::FORMAT_JSON; $post = Yii::$app->request->post(); if (!isset($post['Order']['payment_type_id'])) { throw new BadRequestHttpException(); } $value = $post['Order']['payment_type_id']; $order = $this->findModel($id); $order->payment_type_id = $value; /** @var PaymentType $paymentType */ $paymentType = PaymentType::findOne($value); if ($paymentType === null || !$order->save(true, ['payment_type_id'])) { return ['message' => Yii::t('app', 'Cannot change a payment type')]; } return ['output' => Html::tag('span', $paymentType->name)]; }
/** * Erzeugt einen String mit den Article Infos * - HeftNr * - Datum * - Volume * - Seiten * * @return string * * @author KAS <*****@*****.**> 07.07.2015 */ public function getArticleinfo() { // Erzeugen des Ausgabedatums ------------------------------------------ \Yii::$app->formatter->locale = 'de_DE'; if ($this->metadata !== NULL) { $dateStr = $this->metadata['JAHR'] . "-" . $this->metadata['MONAT']; } else { $dateStr = "2015-07"; } $datum = \Yii::$app->formatter->asDate($dateStr, "php:F Y"); //---------------------------------------------------------------------- $infoStr = Html::a("Heft " . $this->metadata['HEFTNR'], NULL); $infoStr .= ", "; $infoStr .= Html::tag('span', $datum, ['itemprop' => "datePublished"]); $infoStr .= ", "; $infoStr .= $this->metadata['VOLUME'] . ". Jahrgang"; $infoStr .= ", "; $infoStr .= "pp " . $this->metadata['SEITEVON'] . "-" . $this->metadata['SEITEBIS']; //---------------------------------------------------------------------- return $infoStr; }
if ($images[0]['urlAlias'] != 'placeHolder' && $images[0]->isMain) { $image = $model->getImage(); // $sizes = $image->getSizesWhen('x300'); // echo Html::img($image->getUrl('x300'),['class' => 'center-block img-responsive','width'=>$sizes['width'], 'height'=>$sizes['height']]); echo Html::img($image->getUrl('x900'), ['class' => 'center-block img-responsive', 'width' => '100%']); } ?> </div> </div> <div class="news-view well"> <h1 class="text-center"><?php echo Html::encode($this->title); ?> </h1> <?php echo Html::tag('div', $model->content, ['class' => '']); ?> <div class="news-images-block"> <?php if ($images[0]['urlAlias'] != 'placeHolder') { foreach ($images as $img) { echo Html::beginTag('div', ['class' => 'news-images-box', 'style' => 'margin-bottom:20px']); if (!$img->isMain) { echo Html::a(Html::img($img->getUrl('x500'), ['class' => 'center-block img-responsive']), $img->getUrl(''), ['class' => 'lightbox']); } echo Html::endTag('div'); } } ?> </div> </div>
<?php use app\backend\components\ActionColumn; use kartik\dynagrid\DynaGrid; use kartik\helpers\Html; use kartik\icons\Icon; /** * @var $this yii\web\View * @var $searchModel app\components\SearchModel * @var $dataProvider yii\data\ActiveDataProvider */ $this->title = Yii::t('app', 'Warehouse'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="order-status-index"> <?php echo DynaGrid::widget(['options' => ['id' => 'order-statuses-grid'], 'theme' => 'panel-default', 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'hover' => true, 'panel' => ['heading' => Html::tag('h3', $this->title, ['class' => 'panel-title']), 'after' => Html::a(Icon::show('plus') . Yii::t('app', 'Add'), ['edit', 'returnUrl' => \app\backend\components\Helper::getReturnUrl()], ['class' => 'btn btn-success']) . \app\backend\widgets\RemoveAllButton::widget(['url' => '/backend/order-status/remove-all', 'gridSelector' => '.grid-view', 'htmlOptions' => ['class' => 'btn btn-danger pull-right']])]], 'columns' => [['class' => \kartik\grid\CheckboxColumn::className(), 'options' => ['width' => '10px']], 'id', 'name', 'address', ['class' => ActionColumn::className()]]]); ?> </div>
* @var $values array */ use app\models\Property; use kartik\helpers\Html; ?> <?php if (count($values->values) == 0) { return; } ?> <?php $property = Property::findById($property_id); $result = ""; $valuesRendered = 0; foreach ($values->values as $val) { if (isset($val['value'])) { if (!empty(trim($val['value']))) { if ($valuesRendered === 0) { $result .= '<meta itemprop="main" content="True"/>'; } $valuesRendered++; $result .= Html::tag('dd', Html::encode($val['value']), ['itemprop' => 'value']); } } } $result = trim($result); if (!empty($result)) { echo '<dl itemprop="itemListElement" itemscope itemtype="http://schema.org/NameValueStructure">' . Html::tag('dt', $property->name, ['itemprop' => 'name']) . $result . "</dl>\n\n"; }
* @var $model \app\properties\AbstractModel * @var $multiple boolean * @var $property_id integer * @var $property_key string * @var $this \app\properties\handlers\Handler * @var $values array */ use app\models\Property; use kartik\helpers\Html; ?> <?php if (count($values->values) == 0) { return; } ?> <?php $property = Property::findById($property_id); $result = ""; foreach ($values->values as $val) { if (isset($val['value'])) { if (!empty(trim($val['value']))) { $result .= Html::tag('dd', $val['value']); } } } $result = trim($result); if (!empty($result)) { echo '<dl>' . Html::tag('dt', $property->name) . $result . "</dl>\n\n"; }
* @var $multiple boolean * @var $property_id integer * @var $property_key string * @var $this \yii\web\View * @var $values \app\properties\PropertyValue */ use app\models\Property; use app\modules\shop\models\Product; use yii\helpers\ArrayHelper; use kartik\helpers\Html; $productIds = ArrayHelper::getColumn($values->values, 'value'); /** @var Product[] $products */ $products = []; foreach ($productIds as $id) { $products[] = Product::findOne($id); } ?> <dl> <?php if (count($productIds) == 0) { return; } $property = Property::findById($property_id); echo Html::tag('dt', $property->name); foreach ($products as $product) { echo Html::tag('dd', $product->name); } ?> </dl>
<?php /** * @var $attribute_name string * @var $form \yii\widgets\ActiveForm * @var $label string * @var $model \app\properties\AbstractModel * @var $multiple boolean * @var $property_id integer * @var $property_key string * @var $this \app\properties\handlers\Handler * @var $values array */ use app\models\Property; use kartik\helpers\Html; use yii\helpers\Url; ?> <dl> <?php if (count($values->values) == 0) { return; } $property = Property::findById($property_id); echo Html::tag('dt', $property->name); foreach ($values->values as $val) { if (isset($val['value'])) { echo Html::tag('dd', $val['value']); } } ?> </dl>
<?php /** * @var yii\web\View $this * @var yii\data\ActiveDataProvider $dataProvider * @var \app\models\Form $searchModel */ use app\backend\components\ActionColumn; use kartik\dynagrid\DynaGrid; use kartik\grid\BooleanColumn; use kartik\helpers\Html; use kartik\icons\Icon; $this->title = Yii::t('app', 'Content Blocks'); $this->params['breadcrumbs'][] = $this->title; ?> <?php echo app\widgets\Alert::widget(['id' => 'alert']); ?> <?php echo DynaGrid::widget(['options' => ['id' => 'backend-chunk-grid'], 'columns' => [['class' => \kartik\grid\CheckboxColumn::className(), 'options' => ['width' => '10px']], ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'id'], 'name', 'key', ['class' => BooleanColumn::className(), 'attribute' => 'preload'], ['class' => ActionColumn::className(), 'options' => ['width' => '95px'], 'buttons' => [['url' => 'edit', 'icon' => 'pencil', 'class' => 'btn-primary', 'label' => Yii::t('app', 'Edit')], ['url' => 'delete', 'icon' => 'trash-o', 'class' => 'btn-danger', 'label' => Yii::t('app', 'Delete')]]]], 'theme' => 'panel-default', 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'hover' => true, 'panel' => ['heading' => Html::tag('h3', $this->title, ['class' => 'panel-title']), 'after' => Html::a(Icon::show('plus') . Yii::t('app', 'Add'), ['/core/backend-chunk/edit', 'returnUrl' => \app\backend\components\Helper::getReturnUrl()], ['class' => 'btn btn-success']) . \app\backend\widgets\RemoveAllButton::widget(['url' => '/core/backend-chunk/remove-all', 'gridSelector' => '.grid-view', 'htmlOptions' => ['class' => 'btn btn-danger pull-right']])]]]);
<?php /** * @var $images \app\modules\image\models\Image[] * @var $this \yii\web\View * @var $thumbnailOnDemand boolean * @var $thumbnailWidth integer * @var $thumbnailHeight integer */ use app\modules\image\models\Image; use kartik\helpers\Html; use yii\helpers\ArrayHelper; use yii\helpers\Url; foreach ($images as $image) { $image_src = $image->file; if ($thumbnailOnDemand === true) { $image_src = $image->getThumbnail("{$thumbnailWidth}x{$thumbnailHeight}", $useWatermark); } $title = $image->image_title; $alt = $image->image_alt; if (empty($image->image_alt) === true) { $alt = $title; } $imgHtml = Html::img($image_src, ['title' => $title, 'alt' => $alt, 'itemprop' => "contentUrl"]); echo Html::tag('div', $imgHtml, ['itemscope' => '', 'itemtype' => 'http://schema.org/ImageObject']); }
$mainCurrency = \app\modules\shop\models\Currency::getMainCurrency(); if (is_null($order)) { $itemsCount = 0; $totalPrice = $mainCurrency->format(0); } else { $itemsCount = $order->items_count; $totalPrice = $mainCurrency->format($order->total_price); } ?> <div class="span3" id="cart-info-widget"> <div class="pull-right"> <span class="btn btn-mini"> <span class="total-price"><?php echo $totalPrice; ?> </span> </span> <a href="<?php echo \yii\helpers\Url::toRoute(['/shop/cart']); ?> "> <span class="btn btn-mini btn-primary"> <i class="fa fa-shopping-cart"></i> <?php echo Yii::t('app', '[ {count} ] Itemes in your cart', ['count' => \kartik\helpers\Html::tag('span', $itemsCount, ['class' => 'items-count'])]); ?> </span> </a> </div> </div>
?> </td> <td> <?php echo $mainCurrency->format($item->price_per_pcs); ?> </td> <td><?php echo $item->quantity; ?> </td> <td> <span class="item-price"> <?php if ($item->discount_amount > 0) { echo Html::tag('span', $mainCurrency->format($item->total_price_without_discount), ['style' => 'text-decoration: line-through;']) . '<br>'; } ?> <?php echo $mainCurrency->format($item->total_price); ?> </span> </td> </tr> <?php if (isset($subItems[$item->product_id])) { ?> <?php echo $this->render('sub-items', ['mainCurrency' => $mainCurrency, 'model' => $model, 'immutable' => $immutable, 'items' => $subItems[$item->product_id]]); ?>
/** * Renders the panel title bar * * @param string $type whether 'heading' or 'footer' * @return string | boolean */ protected function renderPanelTitleBar($type) { $title = ArrayHelper::getValue($this->panel, $type, $type === 'heading' ? '' : false); if ($title === false) { return false; } $tag = ArrayHelper::remove($options, 'tag', $type === 'heading' ? 'h3' : 'h4'); $template = ArrayHelper::remove($options, 'template', $type === 'heading' ? '{buttons}{title}' : '{title}'); $options = ArrayHelper::getValue($this->panel, $type . 'Options', []); Html::addCssClass($options, 'panel-title'); $title = Html::tag($tag, $title, $options); return str_replace('{title}', $title, $template); }
/** * Generates an address block. * * @param string $name the addressee name * @param array $lines the lines of address information * @param array $phone the list of phone numbers - passed as $key => $value, where: * - $key is the phone type could be 'Res', 'Off', 'Cell', 'Fax' * - $value is the phone number * @param array $email the list of email addresses - passed as $key => $value, where: * - $key is the email type could be 'Res', 'Off' * - $value is the email address * @param array $options html options for the address * @param string $phoneLabel the prefix label for each phone - defaults to '(P)' * @param string $emailLabel the prefix label for each email - defaults to '(E)' * * Example(s): * ~~~ * echo Html::address( * 'Twitter, Inc.', * ['795 Folsom Ave, Suite 600', 'San Francisco, CA 94107'], * ['Res' => '(123) 456-7890', 'Off'=> '(456) 789-0123'], * ['Res' => '*****@*****.**', 'Off' => '*****@*****.**'] * ); * $address = Html::address( * 'Twitter, Inc.', * ['795 Folsom Ave, Suite 600', 'San Francisco, CA 94107'], * ['Res' => '(123) 456-7890', 'Off'=> '(456) 789-0123'], * ['Res' => '*****@*****.**', 'Off' => '*****@*****.**'], * Html::icon('phone'), * Html::icon('envelope') * ); * echo Html::well($address, Html::SIZE_TINY); * ~~~ * * @see http://getbootstrap.com/css/#type-addresses */ public static function address($name, $lines = [], $phone = [], $email = [], $options = [], $phoneLabel = '(P)', $emailLabel = '(E)') { Enum::initI18N(); $addresses = ''; if (!empty($lines)) { $addresses = implode('<br>', $lines) . "<br>\n"; } $phones = ''; foreach ($phone as $type => $number) { if (is_numeric($type)) { // no keys were passed to the phone array $type = static::tag('abbr', $phoneLabel, ['title' => Yii::t('kvenum', 'Phone')]) . ': '; } else { $type = static::tag('abbr', $phoneLabel . ' ' . $type, ['title' => Yii::t('kvenum', 'Phone')]) . ': '; } $phones .= "{$type}{$number}<br>\n"; } $emails = ''; foreach ($email as $type => $addr) { if (is_numeric($type)) { // no keys were passed to the email array $type = Html::tag('abbr', $emailLabel, ['title' => Yii::t('kvenum', 'Email')]) . ': '; } else { $type = Html::tag('abbr', $emailLabel . ' ' . $type, ['title' => Yii::t('kvenum', 'Email')]) . ': '; } $emails .= $type . static::mailto($addr, $addr) . "<br>\n"; } return static::tag('address', "<strong>{$name}</strong><br>\n" . $addresses . $phones . $emails, $options); }
* @var $form \yii\widgets\ActiveForm * @var $label string * @var $model \app\properties\AbstractModel * @var $multiple boolean * @var $property_id integer * @var $property_key string * @var $this \app\properties\handlers\Handler * @var $values array */ use app\models\Property; use kartik\helpers\Html; use yii\helpers\Url; ?> <dl> <?php if (count($values->values) == 0) { return; } $property = Property::findById($property_id); echo Html::tag('dt', $property->name); foreach ($values->values as $val) { if (isset($val['value'])) { if ($model->getOwnerModel()->className() === \app\modules\shop\models\Order::className()) { echo Html::tag('dd', Html::a($val['value'], 'http://' . Yii::$app->getModule('core')->serverName . Url::to(['/shop/backend-order/download-file', 'key' => $val['key'], 'orderId' => $values->object_model_id]))); } else { echo Html::tag('dd', Html::a($val['value'], 'http://' . Yii::$app->getModule('core')->serverName . Url::to(['/backend/form/download', 'key' => $val['key'], 'submissionId' => $values->object_model_id]))); } } } ?> </dl>
/** * Convert a PHP array to HTML table. * * Example: * * ~~~ * $data = [ * ['id' => 1, 'name' => 'John', 'birthday' => '01-Jul-1976', 'commission'=>'4,500.50', 'active' => true], * [2, 'Scott', '26-Feb-1980', '1,300.40', true], * [3, 'Mary', '1990-02-10', null, false], * [4, 'Lisa', '17-Dec-1982', '-900.34', true], * ]; * echo Enum::array2table($data); * ~~~ * * @param array $array the associative array to be converted * @param boolean $transpose whether to show keys as rows instead of columns. This parameter should be used only * for a single dimensional associative array. If used for a multidimensional array, the sub array will be imploded * as text. * @param boolean $recursive whether to recursively generate tables for multi-dimensional arrays * @param boolean $typeHint whether to show the data type as a hint * @param string $null the content to display for blank cells * @param array $tableOptions the HTML attributes for the table * @param array $keyOptions the HTML attributes for the array key * @param array $valueOptions the HTML attributes for the array value * * @return string|boolean */ public static function array2table($array, $transpose = false, $recursive = false, $typeHint = true, $tableOptions = ['class' => 'table table-bordered table-striped'], $keyOptions = [], $valueOptions = ['style' => 'cursor: default; border-bottom: 1px #aaa dashed;'], $null = '<span class="not-set">(not set)</span>') { // Sanity check if (empty($array) || !is_array($array)) { return false; } // Start the table $table = Html::beginTag('table', $tableOptions) . "\n"; // The header $table .= "\t<tr>"; if ($transpose) { foreach ($array as $key => $value) { if ($typeHint) { $valueOptions['title'] = self::getType(strtoupper($value)); } if (is_array($value)) { $value = '<pre>' . print_r($value, true) . '</pre>'; } else { $value = Html::tag('span', $value, $valueOptions); } $table .= "\t\t<th>" . Html::tag('span', $key, $keyOptions) . "</th>" . "<td>" . $value . "</td>\n\t</tr>\n"; } $table .= "</table>"; return $table; } if (!isset($array[0]) || !is_array($array[0])) { $array = array($array); } // Take the keys from the first row as the headings foreach (array_keys($array[0]) as $heading) { $table .= '<th>' . Html::tag('span', $heading, $keyOptions) . '</th>'; } $table .= "</tr>\n"; // The body foreach ($array as $row) { $table .= "\t<tr>"; foreach ($row as $cell) { $table .= '<td>'; // Cast objects if (is_object($cell)) { $cell = (array) $cell; } if ($recursive === true && is_array($cell) && !empty($cell)) { // Recursive mode $table .= "\n" . static::array2table($cell, true, true) . "\n"; } else { if (!is_null($cell) && is_bool($cell)) { $val = $cell ? 'true' : 'false'; $type = 'boolean'; } else { $chk = strlen($cell) > 0; $type = $chk ? self::getType($cell) : 'NULL'; $val = $chk ? htmlspecialchars((string) $cell) : $null; } if ($typeHint) { $valueOptions['title'] = $type; } $table .= Html::tag('span', $val, $valueOptions); } $table .= '</td>'; } $table .= "</tr>\n"; } $table .= '</table>'; return $table; }