/** * @return array [[DropDownList]] */ public static function getOrderStatusArray($asHtml = false) { $cacheKey = 'OrderStatusItems:' . implode(':', [intval($asHtml)]); $items = Yii::$app->cache->get($cacheKey); if ($items !== false) { return $items; } $data = self::find()->select(['order_status_id', 'name', 'color'])->orderBy('name ASC')->asArray()->all(); $cache_tags = [ActiveRecordHelper::getCommonTag(static::className())]; foreach ($data as $val) { $key = $val['order_status_id']; $items[$key] = $asHtml ? Html::badge($val['name'], ['class' => 'btn btn-xs btn-block ' . $val['color']]) : $val['name']; $cache_tags[] = ActiveRecordHelper::getObjectTag(static::className(), $key); } Yii::$app->cache->set($cacheKey, $items, 86400, new TagDependency(['tags' => $cache_tags])); return $items; }
/** * * @param type $name * @param array $config */ public static function getIcon($input, array $config = []) { //Lookup DB Value corresponding to input $model = models\IconRegister::findOne(['name' => $input]); $icon = NULL; if (!isset($model) || $model->framework_id == 'bdg') { $icon = isset($model) ? $model->icon : $input; $config['as_badge'] = TRUE; } else { $icon = Html::icon($model->icon, $config, $model->framework_id == 'bsg' ? 'glyphicon glyphicon-' : 'fa fa-fw fa-'); } $output = $icon; if (isset($config['as_badge']) && $config['as_badge'] == TRUE) { $output = Html::badge($output . ' ' . (isset($config['label']) && isset($config['label_as_badge']) ? $config['label'] : ''), $config); } $label = isset($config['label']) && !isset($config['label_as_badge']) ? ' ' . $config['label'] : ''; return $output . $label; }
public function getNameColor() { return Html::badge($this->name, ['class' => 'btn btn-xs btn-block ' . $this->color]); }
<h3 class="panel-title">APIs to see</h3> </div> <ul class="recommendation-list list-group"> <?php foreach ($recommend['hits']['hits'] as $rec) { echo '<li class="list-group-item">'; echo Html::a($rec['fields']['name'][0], ['view', 'id' => $rec['_id']]); if (array_key_exists('inner_hits', $rec)) { $show_objects_to_fork = false; foreach ($rec['inner_hits'] as $innner_hitsRec) { if ($innner_hitsRec['hits']['total'] > 0) { $show_objects_to_fork = true; } } if ($show_objects_to_fork) { echo Html::a(Html::badge(Html::icon('chevron-right', ['class' => 'badge-success'])), null, ['class' => 'pull-right', 'id' => str_replace(' ', '', $rec['fields']['name'][0])]); } } echo '</li>'; } ?> </ul> </div> </div> <?php foreach ($recommend['hits']['hits'] as $key => $rec) { $recDivID = 'recommendation-object-block-' . str_replace(' ', '', $rec['fields']['name'][0]); if (array_key_exists('inner_hits', $rec)) { $objectsToShowNoDupsNames = []; $objectsToShowNoDupsIds = []; foreach ($rec['inner_hits'] as $innner_hitsRec) {