/** * [[@doctodo method_description:generateStart]]. * * @return [[@doctodo return_type:generateStart]] [[@doctodo return_description:generateStart]] */ public function generateStart() { $parts = []; $parts[] = Html::tag('div', '', ['id' => 'section-' . $this->systemId, 'class' => 'scroll-mark']); $parts[] = parent::generateStart(); return implode('', $parts); }
/** * [[@doctodo method_description:generateEnd]]. * * @return [[@doctodo return_type:generateEnd]] [[@doctodo return_description:generateEnd]] */ public function generateEnd() { $parts = []; $parts[] = Html::endTag('div'); // panel return implode("", $parts); }
/** * [[@doctodo method_description:generateFooter]]. * * @return [[@doctodo return_type:generateFooter]] [[@doctodo return_description:generateFooter]] */ public function generateFooter() { $parts = []; $parts[] = Html::endTag('div'); // panel-body return implode("", $parts); }
/** * @inheritdoc */ public function getListItemOptions($model, $key, $index) { $options = array_merge(parent::getListItemOptions($model, $key, $index), ['tag' => 'a', 'href' => Url::to($model->getUrl('view'))]); if (!$model->can('read')) { Html::addCssClass($options, 'disabled'); $options['href'] = '#'; } return $options; }
/** * Get cell. * * @return [[@doctodo return_type:getCell]] [[@doctodo return_description:getCell]] */ public function getCell() { $widgetCell = $this->singleWidget; if ($widgetCell) { $widgetCell->prepend(Html::tag('div', '', ['id' => 'section-' . $this->systemId, 'class' => 'scroll-mark'])); return $widgetCell; } return false; }
/** * [[@doctodo method_description:renderItem]]. * * @param [[@doctodo param_type:storageEngine]] $storageEngine [[@doctodo param_description:storageEngine]] * * @return [[@doctodo return_type:renderItem]] [[@doctodo return_description:renderItem]] */ public function renderItem($storageEngine) { $item = $this->prepareItem($storageEngine); $rendered = $storageEngine->storageHandler->object->generate($item); if (!$rendered) { return false; } $hiddenItem = clone $item; $hiddenItem->attribute = Html::changeAttribute($hiddenItem->attribute, 'storageEngine'); $item->model->storageEngine = $storageEngine->primaryKey; $rendered .= Html::activeHiddenInput($item->model, $hiddenItem->attribute, $item->inputOptions); return $rendered; }
/** * Renders a page button. * You may override this method to customize the generation of page buttons. * * @param string $label the text label for the button * @param integer $page the page number * @param string $class the CSS class for the page button. * @param boolean $disabled whether this page button is disabled * @param boolean $active whether this page button is active * * @return string the rendering result */ protected function renderPageButton($label, $page, $class, $disabled, $active) { if ($active) { $class .= ' ' . $this->activePageCssClass; } if ($disabled) { $class .= ' ' . $this->disabledPageCssClass; } $state = $this->getState(); $state['page'] = $page + 1; $jsonState = json_encode($state); $class .= ' stateful'; $class = trim($class); $options = ['data-state' => $jsonState, 'class' => $class === '' ? null : $class]; return Html::tag('li', Html::a($label, $this->pagination->createUrl($page), ['data-page' => $page]), $options); }
/** * @inheritdoc */ public function generateContent() { if (empty(Yii::$app->request->object)) { return false; } if (!($detailFields = Yii::$app->request->object->getDetailFields()) || empty($detailFields)) { return false; } $parts = []; Html::addCssClass($this->contentHtmlOptions, 'dl-horizontal'); $parts[] = Html::beginTag('dl', $this->contentHtmlOptions); foreach ($detailFields as $key => $field) { $parts[] = Html::tag('dt', $field->label, $this->termHtmlOptions); $parts[] = Html::tag('dd', $field->formattedValue, $this->valueHtmlOptions); } $parts[] = Html::endTag('dl'); return implode($parts); }
use canis\web\grid\Grid; use yii\helpers\Url; $js = []; $this->title = 'Dashboard'; $refreshable = ['url' => Url::to(['/app/stream']), 'stream' => true, 'data' => ['baseInstructions' => []]]; $this->bodyHtmlOptions['data-refreshable'] = json_encode($refreshable); echo Html::beginTag('div', ['class' => 'ic-dashboard row']); Yii::beginProfile("Build Grid"); $widgets = Yii::$app->collectors['widgets']->getLocation('front'); ArrayHelper::multisort($widgets, ['priority', 'name'], [SORT_ASC, SORT_ASC]); $topGrid = new Grid(); $watchingWidget = Yii::$app->collectors['widgets']->getOne('WatchingContent'); $watchingCell = Yii::$app->collectors['widgets']->build(null, $watchingWidget, [], ['columns' => 6]); $topGrid->currentRow->addCell($watchingCell); $itemsCell = $topGrid->currentRow->addCell(new Cell(['columns' => 6])); $widgetGrid = new Grid(); Html::addCssClass($widgetGrid->htmlOptions, 'ic-front-side'); $js[] = '$("#' . $widgetGrid->id . '").canisAffix();'; $widgetGrid->baseRow = ['trueWidth' => 6]; $cells = []; Yii::beginProfile("Collect Widgets"); foreach ($widgets as $item => $widget) { $cells[] = Yii::$app->collectors['widgets']->build(null, $widget, [], []); } Yii::endProfile("Collect Widgets"); $widgetGrid->cells = $cells; Yii::endProfile("Build Grid"); $itemsCell->content = $widgetGrid->generate(); echo $topGrid->generate(); echo Html::endTag('div'); $this->registerJs(implode("\n", $js));
/** * [[@doctodo method_description:generate]]. * * @return unknown */ public function generate() { if (empty($this->_items)) { return ''; } $result = []; $formOptions = ['options' => ['class' => ''], 'enableClientValidation' => false]; if (Yii::$app->request->isAjax) { Html::addCssClass($formOptions['options'], 'ajax'); } if ($this->hasFile() && !isset($formOptions['options']['enctype'])) { $formOptions['options']['enctype'] = 'multipart/form-data'; } list($this->form, $formStartRow) = ActiveForm::begin($formOptions, false); $result[] = $formStartRow; // $result[] = Html::beginForm('', 'post', array('class' => $this->class)); $result[] = Html::beginTag('div', ['class' => '']); foreach ($this->_items as $item) { $result[] = $item->generate(); } //if (!Yii::$app->request->isAjax) { $result[] = Html::beginTag('div', ['class' => 'row form-group submit-group']); $result[] = Html::beginTag('div', ['class' => 'col-sm-12']); $result[] = Html::submitButton('Save', ['class' => 'btn btn-primary']); $result[] = Html::endTag('div'); $result[] = Html::endTag('div'); //} $result[] = Html::endTag('div'); $result[] = ActiveForm::end(false); return implode("\n", $result); }
public function getViewLink() { if ($this->can('read')) { return Html::a($this->descriptor, $this->getUrl('view')); } else { return $this->descriptor; } }
$htmlOptions = []; } $roleSet = isset($objectRoles[$requestorObject->primaryKey]) ? $objectRoles[$requestorObject->primaryKey] : []; $role = isset($roleSet['role']) ? $roleSet['role'] : null; $roleObject = isset($role) ? $role->object : null; Html::addCssClass($htmlOptions, 'list-group-item'); $requestorOptions = []; $requestorOptions['id'] = $requestorObject->primaryKey; $requestorOptions['label'] = $requestorObject->descriptor; $requestorOptions['maxRoleLevel'] = isset($maxRoleLevel) ? $maxRoleLevel : false; $requestorOptions['type'] = $requestorObject->objectType->systemId; $requestorOptions['editable'] = true; if (isset($role) && isset($roleSet['inherited']) && $roleSet['inherited'] && !$role->inheritedEditable) { $requestorOptions['editable'] = false; } $htmlOptions['data-requestor'] = json_encode($requestorOptions); if (!$requestorOptions['editable']) { Html::addCssClass($htmlOptions, 'uneditable'); } echo Html::beginTag('li', $htmlOptions); echo $this->renderFile('@cascade/views/object/access_role.php', ['roles' => $roles, 'role' => $roleObject, 'objectAccess' => $objectAccess, 'disableFields' => $disableFields, 'editable' => $requestorOptions['editable']], $this); echo Html::tag('h4', $requestorObject->descriptor, ['class' => 'list-group-item-heading']); if (!isset($helpText)) { $helpText = $requestorObject->objectType->title->upperSingular; } echo Html::tag('p', $helpText, ['class' => 'list-group-item-text help-text']); if (isset($errors[$requestorObject->primaryKey])) { echo Html::tag('p', $errors[$requestorObject->primaryKey], ['class' => 'alert alert-danger']); } echo Html::endTag('li');
<?php use canis\helpers\Html; use yii\helpers\Url; \canis\web\assetBundles\CanisLogViewerAsset::register($this); $this->title = "View Service Log"; //$package = []; echo Html::tag('div', '', ['data-log' => json_encode($package)]);
/** * [[@doctodo method_description:generate]]. * * @return unknown */ public function generate() { $this->getFields(); $result = []; if (!empty($this->_settings['title'])) { $result[] = Html::beginTag('fieldset'); $result[] = Html::tag('legend', $this->_settings['title']); } $result[] = $this->grid->generate(); if (!empty($this->_settings['title'])) { $result[] = Html::endTag('fieldset'); } return implode("\n", $result); }
public function getListItemOptions($model, $key, $index) { $options = self::getListItemOptionsBase($model, $key, $index); //return $options; $objectType = $model->objectType; $queryRole = ArrayHelper::getValue($this->settings, 'queryRole', false); $relationship = ArrayHelper::getValue($this->settings, 'relationship', false); if (!$relationship) { return $options; } if ($queryRole === 'children') { $baseUrl['object_relation'] = 'child'; $primaryRelation = $relationship->getPrimaryObject(Yii::$app->request->object, $model, 'child'); $key = 'child_object_id'; } else { $baseUrl['object_relation'] = 'parent'; $primaryRelation = $relationship->getPrimaryObject(Yii::$app->request->object, $model, 'parent'); $key = 'parent_object_id'; } if ($primaryRelation && $primaryRelation->{$key} === $model->primaryKey) { Html::addCssClass($options, 'active'); } $options['data-object-id'] = $model->primaryKey; return $options; }
echo Html::beginTag('ul', ['class' => 'list-group']); echo Html::beginTag('li', ['class' => 'list-group-item']); echo Html::tag('span', $stats['total'], ['class' => 'badge']); echo 'Total'; echo Html::endTag('li'); if (!empty($stats['top_contributors'])) { echo Html::beginTag('li', ['class' => 'list-group-item']); echo '<h5>Top Contributors</h5>'; echo Html::beginTag('ul', ['class' => 'list-group']); foreach ($stats['top_contributors'] as $id => $contrib) { echo Html::beginTag('li', ['class' => 'list-group-item']); echo Html::tag('span', $contrib['sum'], ['class' => 'badge']); echo Html::a($contrib['label'], ['/object/view', 'id' => $id, 'p' => Yii::$app->request->object->primaryKey]); echo Html::endTag('li'); } echo Html::endTag('ul'); } if (!empty($stats['month_summary'])) { echo Html::beginTag('li', ['class' => 'list-group-item']); echo '<h5>Month Summaries</h5>'; echo Html::beginTag('ul', ['class' => 'list-group']); foreach ($stats['month_summary'] as $month => $sum) { echo Html::beginTag('li', ['class' => 'list-group-item']); echo Html::tag('span', $sum['sum'], ['class' => 'badge']); echo date('F Y', strtotime($month . '-01')); echo Html::endTag('li'); } echo Html::endTag('ul'); } echo Html::endTag('ul');
/** * Renders the pager. * * @return string the rendering result */ public function renderPager() { $pagination = $this->dataProvider->getPagination(); //\d([get_class($this), $pagination]); if ($pagination === false || $pagination->getPageCount() <= 1) { return false; } /* @var LinkPager $class */ $pager = $this->pagerSettings; $class = ArrayHelper::remove($pager, 'class', 'canis\\widgets\\LinkPager'); $pager['pagination'] = $pagination; if (!isset($pager['options'])) { $pager['options'] = []; } $pager['maxButtonCount'] = 6; Html::addCssClass($pager['options'], 'pagination pull-right'); return $class::widget($pager); }
/** * @inheritdoc */ public function generateContent() { if (!isset(Yii::$app->request->object)) { return false; } $object = Yii::$app->request->object; $content = []; $content[] = Html::beginTag('div', ['class' => 'well ic-masthead']); if (Yii::$app->request->previousObject) { $content[] = Html::beginTag('div', ['class' => 'ic-object-previous']); $content[] = Html::tag('span', '', ['class' => 'fa fa-reply']) . ' ' . Html::a('Go back to <em>' . Yii::$app->request->previousObject->descriptor . '</em>', Yii::$app->request->previousObject->getUrl('view', [], false)); $content[] = Html::endTag('div'); } if ($object->getBehavior('Photo')) { $photoHtmlOptions = []; $img = $object->getPhotoUrl(200); if ($img) { Html::addCssClass($photoHtmlOptions, 'ic-object-photo ic-object-photo-image'); $photoHtmlOptions['style'] = 'background-image: url("' . $img . '");'; } else { Html::addCssClass($photoHtmlOptions, 'ic-object-photo ic-object-photo-icon ' . $object->objectType->icon); } $photoContent = ''; $content[] = Html::tag('div', $photoContent, $photoHtmlOptions); } $content[] = Html::beginTag('div', ['class' => 'ic-object-header']); $content[] = $object->descriptor; $objectAccess = $object->objectAccess; $objectVisibility = $objectAccess->visibility; $content[] = Html::endTag('div'); if ($object->archived) { $content[] = Html::tag('div', Html::tag('span', 'Archived', ['class' => 'label label-warning']), ['class' => 'center-block center-text']); } $menu = []; $familiarty = $object->getFamiliarity(); $startWatchingItem = ['label' => Html::tag('span', '', ['class' => 'fa fa-eye']) . ' Watch', 'url' => $object->getUrl('watch'), 'options' => ['title' => 'Watch and get notified with changes', 'data-handler' => 'background', 'class' => 'watch-link', 'data-watch-task' => 'start']]; $stopWatchingItem = ['label' => Html::tag('span', '', ['class' => 'fa fa-check']) . ' Watching', 'url' => $object->getUrl('watch', ['stop' => 1]), 'options' => ['title' => 'Stop receiving change notifications', 'data-handler' => 'background', 'data-watch-task' => 'stop', 'class' => 'watch-link']]; $accessManageUrl = $object->getUrl('access'); $startWatchingItem['companion'] = $stopWatchingItem; $stopWatchingItem['companion'] = $startWatchingItem; if (empty($familiarty->watching)) { $menu[] = $startWatchingItem; } else { $menu[] = $stopWatchingItem; } if ($object->can('update')) { $menu[] = ['label' => Html::tag('span', '', ['class' => 'fa fa-wrench']) . ' Update', 'url' => $object->getUrl('update'), 'options' => ['title' => 'Update', 'data-handler' => 'background']]; } if ($object->can('delete') || $object->can('archive')) { $label = 'Delete'; $icon = 'fa-trash-o'; if ($object->can('archive')) { $icon = 'fa-archive'; if ($object->archived) { $label = 'Unarchive'; } else { $label = 'Archive'; } } $menu[] = ['label' => Html::tag('span', '', ['class' => 'fa ' . $icon]) . ' ' . $label, 'url' => $object->getUrl('delete'), 'options' => ['title' => $label, 'data-handler' => 'background']]; } if ($objectVisibility === 'public') { $accessIcon = 'fa fa-globe'; $accessTitle = $object->objectType->title->upperSingular . ' is public'; $accessLabel = 'Public'; } elseif ($objectVisibility === 'shared') { $accessIcon = 'fa fa-rss'; $accessTitle = $object->objectType->title->upperSingular . ' is shared'; $accessLabel = 'Shared'; } elseif ($objectVisibility === 'internal') { $accessIcon = 'fa fa-building-o'; $accessTitle = $object->objectType->title->upperSingular . ' is shared internally'; $accessLabel = 'Internal'; } elseif ($objectVisibility === 'admins') { $accessIcon = 'fa fa-lock'; $accessTitle = $object->objectType->title->upperSingular . ' is shared only with administrators'; $accessLabel = 'Administrators'; } else { $accessIcon = 'fa fa-user'; $accessTitle = $object->objectType->title->upperSingular . ' is private'; $accessLabel = 'Private'; } if ($object->can('manageAccess')) { } $menu[] = ['label' => Html::tag('span', '', ['class' => $accessIcon]) . ' ' . $accessLabel, 'url' => $accessManageUrl, 'options' => ['title' => $accessTitle, 'data-handler' => 'background']]; $menu[] = ['label' => Html::tag('span', '', ['class' => 'fa fa-history']) . ' Activity', 'url' => $object->getUrl('activity'), 'options' => ['title' => 'View Activity', 'data-handler' => 'background']]; if (!empty($menu)) { $content[] = Html::beginTag('div', ['class' => 'ic-object-menu columns-' . count($menu)]); $content[] = Html::beginTag('ul', ['class' => 'clearfix']); $menuCount = 0; foreach ($menu as $item) { $menuCount++; if (!isset($item['options'])) { $item['options'] = []; } $companionContent = ''; if (isset($item['companion'])) { $companion = $item['companion']; if (!isset($companion['options'])) { $companion['options'] = []; } Html::addCssClass($companion['options'], 'hidden'); $companionContent = Html::a($companion['label'], $companion['url'], $companion['options']); } $content[] = Html::tag('li', $companionContent . Html::a($item['label'], $item['url'], $item['options']), ['class' => 'item-' . $menuCount]); } $content[] = Html::endTag('ul'); $content[] = Html::endTag('div'); } $content[] = Html::endTag('div'); return implode($content); }
} else { Html::addCssClass($labelOptions, 'btn'); } if ($model->target === $target) { Html::addCssClass($labelOptions, 'active'); } $labelOptions['title'] = ucfirst(strip_tags($label['long'])); echo Html::activeRadio($model, 'target', array_merge($itemOptions, ['value' => $target, 'label' => $label['short'], 'uncheck' => null, 'labelOptions' => $labelOptions])); } echo '</div>'; } return; \d($model->possibleTargets); exit; if (is_null($model->relationModel) || $model->forceObjectDelete) { echo "<div class='confirm'>Are you sure you want to delete the " . $model->object->objectType->title->getSingular(false) . " <em>" . $model->object->descriptor . "</em>?</div>"; } else { if (!empty($model->forceRelationshipDelete)) { echo "<div class='confirm'>Are you sure you want to delete the relationship between " . $model->object->objectType->title->getSingular(false) . " <em>" . $model->object->descriptor . "</em> and <em>" . $model->relationshipWith->descriptor . "</em>?</div>"; } else { echo "<div class='confirm'>Do you want to delete the " . $model->object->objectType->title->getSingular(false) . " <em>" . $model->object->descriptor . "</em> <strong>or</strong> its relationship with <em>" . $model->relationshipWith->descriptor . "</em>?</div>"; echo '<div class="btn-group" data-toggle="buttons">'; $itemOptions = ['container' => false]; echo Html::radio('target', $model->target === 'relationship', array_merge($itemOptions, ['value' => 'relationship', 'label' => 'Relationship', 'labelOptions' => ['class' => 'btn btn-default' . ($model->target === 'relationship' ? ' active' : '')]])); echo Html::radio('target', $model->target === 'object', array_merge($itemOptions, ['value' => 'object', 'label' => $model->object->objectType->title->getSingular(true), 'labelOptions' => ['class' => 'btn btn-danger' . ($model->target === 'object' ? ' active' : '')]])); echo '</div>'; } } echo Html::endTag('div'); echo Html::endForm();
/** * @var yii\base\View * @var yii\widgets\ActiveForm * @var yii\gii\generators\module\Generator */ use canis\helpers\Html; canis\web\assetBundles\FontAwesomeAsset::register($this); canis\web\assetBundles\UnderscoreAsset::register($this); $js = <<<END \$("#generator-icon option").each(function () { \$(this).html(\$(this).text()); console.log(\$(this).text()); }); END; Html::registerJsBlock($js); $css = <<<END #generator-icon option { font-family: 'FontAwesome'; } END; $this->registerCss($css); echo \yii\helpers\Html::activeHiddenInput($generator, 'migrationTimestamp'); ?> <div class="module-form"> <?php // echo $form->field($generator, 'moduleName'); // echo $form->field($generator, 'moduleClass'); // echo $form->field($generator, 'moduleID'); echo $form->field($generator, 'moduleSet')->dropDownList($generator->possibleModuleSets()); echo $form->field($generator, 'tableName');
<?php use canis\helpers\Html; $this->registerMetaTag(['http-equiv' => 'refresh', 'content' => '5']); $interfaceModel = $dataInterfaceLog->dataInterface; $this->title = "View Data Interface Log"; $this->params['breadcrumbs'][] = ['label' => 'Administration', 'url' => ['/admin/dashboard/index']]; $this->params['breadcrumbs'][] = ['label' => 'Interfaces', 'url' => ['admin/interface/index']]; $this->params['breadcrumbs'][] = ['label' => $interfaceModel->name, 'url' => ['admin/interface/view-logs', 'id' => $interfaceModel->primaryKey]]; $this->params['breadcrumbs'][] = $this->title; echo Html::tag('div', 'Please wait while your data interface import task is in the queue.', ['class' => 'alert alert-warning']);
/** * Get download link. * * @param [[@doctodo param_type:label]] $label [[@doctodo param_description:label]] [optional] * @param array $htmlAttributes [[@doctodo param_description:htmlAttributes]] [optional] * * @return [[@doctodo return_type:getDownloadLink]] [[@doctodo return_description:getDownloadLink]] */ public function getDownloadLink($label = null, $htmlAttributes = []) { if (is_null($label)) { $label = $this->descriptor; } return Html::a($label, ['/object/view', 'subaction' => 'download', 'id' => $this->id]); }
/** * Get field. * * @return [[@doctodo return_type:getFieldId]] [[@doctodo return_description:getFieldId]] */ public function getFieldId() { return Html::getInputId($this->model, $this->getModelFieldName()); }
/** * Get link. * * @return [[@doctodo return_type:getWebLink]] [[@doctodo return_description:getWebLink]] */ public function getWebLink() { return Html::a($this->descriptor, $this->url, ['target' => '_blank']); }
/** * Get mail link. * * @return [[@doctodo return_type:getMailLink]] [[@doctodo return_description:getMailLink]] */ public function getMailLink() { return Html::mailto($this->email_address, $this->email_address); }
/** * @inheritdoc */ public function generateContent() { $parts = []; $instructions = []; $instructions['ajax'] = ['url' => Url::to(['/app/activity'])]; $instructions['scope'] = $this->currentScope; $parts[] = Html::tag('div', '', ['data-activity-feed' => json_encode($instructions), 'data-height' => json_encode(['min' => 1000, 'max' => 'body'])]); $parts[] = Html::tag('div', str_repeat(Html::tag('div', '', ['class' => 'widget-lazy-placeholder']), 30), ['class' => 'activity-feed-thinking']); return implode($parts); }
<?php use canis\helpers\Html; use yii\widgets\ActiveForm; $this->title = 'Login'; $this->params['breadcrumbs'][] = $this->title; $formOptions = ['class' => 'form-horizontal']; if (!Yii::$app->request->isAjax) { echo '<div class="col-md-offset-3 col-md-6">'; } else { Html::addCssClass($formOptions, 'ajax'); } $form = ActiveForm::begin(['id' => 'login-form', 'options' => $formOptions, 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-9\">{input}</div>\n<div class=\"col-lg-12\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-3 control-label']]]); echo $form->field($model, 'email'); echo $form->field($model, 'password')->passwordInput(); echo $form->field($model, 'rememberMe', ['template' => "<div class=\"col-md-offset-1 col-lg-9 \">{input}</div>\n<div class=\"col-lg-8\">{error}</div>"])->checkbox(); echo '<div class="submit-group col-md-offset-1 col-lg-9 ">'; echo Html::submitButton('Login', ['class' => 'btn btn-primary']); echo '</div>'; echo '</div>'; ActiveForm::end();
<?php use canis\helpers\Html; \canis\web\assetBundles\LogAsset::register($this); $interfaceModel = $dataInterfaceLog->dataInterface; $this->title = "View Data Interface Log"; $this->params['breadcrumbs'][] = ['label' => 'Administration', 'url' => ['/admin/dashboard/index']]; $this->params['breadcrumbs'][] = ['label' => 'Interfaces', 'url' => ['admin/interface/index']]; $this->params['breadcrumbs'][] = ['label' => $interfaceModel->name, 'url' => ['admin/interface/view-logs', 'id' => $interfaceModel->primaryKey]]; $this->params['breadcrumbs'][] = $this->title; echo Html::tag('div', '', ['data-log' => json_encode($dataInterfaceLog->dataPackage)]);
/** * [[@doctodo method_description:generateRelationField]]. * * @param array $initialSettings [[@doctodo param_description:initialSettings]] [optional] * * @return [[@doctodo return_type:generateRelationField]] [[@doctodo return_description:generateRelationField]] */ protected function generateRelationField($initialSettings = []) { $model = $this->model; $field = $this->getRelationModelField(); $parts = []; $r = $initialSettings; $r['title'] = $this->modelField->label; $r['context'] = []; $r['selector'] = ['browse' => [], 'search' => ['data' => []]]; if ($this->modelField->relationship->temporal && empty($this->model->start)) { $this->model->start = date("m/d/Y"); } $r['context']['relationship'] = $this->modelField->relationship->package(); if ($this->modelField->baseModel && !$this->modelField->baseModel->isNewRecord) { $r['context']['object'] = ['id' => $this->modelField->baseModel->primaryKey, 'descriptor' => $this->modelField->baseModel->descriptor]; } $r['context']['role'] = $role = $this->modelField->relationship->companionRole($this->modelField->modelRole); $companionType = $this->modelField->relationship->companionRoleType($this->modelField->modelRole); $r['selector']['inputLabel'] = 'Select ' . $companionType->title->upperSingular; //\d($r);exit; if ($modelTypeItem = $this->modelField->relationship->{$role}->collectorItem) { $typeBundle = BrowserResponse::handleInstructions(['handler' => 'types', 'relationshipRole' => $role, 'relationship' => $this->modelField->relationship->systemId, 'typeFilters' => ['hasDashboard']]); $r['selector']['browse']['root'] = $typeBundle->package(); } $r['model'] = ['prefix' => $this->model->formName() . $this->model->tabularPrefix, 'attributes' => array_merge($this->model->attributes, ['taxonomy_id' => $this->model->taxonomy_id])]; if (!empty($this->modelField->value->primaryKey)) { $r['select'] = ['id' => $this->modelField->value->primaryKey, 'descriptor' => $this->modelField->value->descriptor, 'subdescriptor' => $this->modelField->value->primarySubdescriptor]; } if (!empty($r['model']['attributes']['start'])) { $r['model']['attributes']['start'] = Yii::$app->formatter->asDate($r['model']['attributes']['start']); } if (!empty($r['model']['attributes']['end'])) { $r['model']['attributes']['end'] = Yii::$app->formatter->asDate($r['model']['attributes']['end']); } $r['lockFields'] = isset($this->relationSettings['lockFields']) ? array_merge($this->relationSettings['lockFields'], $this->lockFields) : $this->lockFields; $r['multiple'] = $this->linkMultiple; // && $this->modelField->relationship->multiple; $this->htmlOptions['data-relationship'] = json_encode($r, JSON_FORCE_OBJECT); Html::addCssClass($this->htmlOptions, 'relationship'); //$model->_moduleHandler = $this->modelField->relationship->companionRole($this->modelField->modelRole) .':'. $this->modelField->relationship->companionRoleType($this->modelField->modelRole)->systemId; $parts[] = Html::activeHiddenInput($model, $this->model->tabularPrefix . '_moduleHandler'); $parts[] = Html::activeHiddenInput($model, $field, $this->htmlOptions); return implode($parts); }
<?php use canis\helpers\Html; if (empty($role)) { $role = 'none'; } elseif (is_object($role)) { $role = $role->primaryKey; } $selectedRole = isset($roles[$role]) ? $roles[$role] : $roles['none']; $isDisabled = $disableFields || !$selectedRole['available'] || !$editable; $htmlOptions = ['type' => 'button']; $roleOptions = $selectedRole; $htmlOptions['data-role'] = json_encode($roleOptions); Html::addCssClass($htmlOptions, 'btn btn-default pull-right'); if ($isDisabled) { Html::addCssClass($htmlOptions, 'disabled'); } if (!$editable) { $selectedRole['label'] = 'Inherited ' . $selectedRole['label']; } echo Html::tag('button', Html::tag('span', $selectedRole['label'], ['class' => 'role-label']) . ' ' . Html::tag('span', '', ['class' => 'caret']), $htmlOptions);