/** * @inheritdoc */ public function run() { $template = trim(ob_get_clean()); if ($this->itemView === null && !empty($template)) { $current = $this->getView()->getViewFile(); $file = sprintf('%x/%x-%s', crc32(dirname($current)) % 0x100, crc32($current), $this->options['id']); $this->_templateFile = Yii::getAlias("@runtime/mdm-tabular/{$file}.php"); if (!is_file($this->_templateFile) || filemtime($current) >= filemtime($this->_templateFile)) { FileHelper::createDirectory(dirname($this->_templateFile)); $template = str_replace(array_keys($this->tags), array_values($this->tags), $template); file_put_contents($this->_templateFile, $template, LOCK_EX); } } if (empty($this->clientOptions['itemSelector']) && ($tag = ArrayHelper::getValue($this->itemOptions, 'tag', 'div'))) { Html::addCssClass($this->itemOptions, "mdm-item{$this->level}"); $this->clientOptions['itemSelector'] = "{$tag}.mdm-item{$this->level}"; } parent::run(); }
/** * @inheritdoc */ public function init() { parent::init(); if (!$this->model instanceof Model) { $property = __CLASS__ . '::$model'; throw new InvalidConfigException("Value of \"{$property}\" must be specified."); } foreach ($this->columns as $i => $column) { if (is_string($column)) { $column = Yii::createObject(['class' => $this->defaultColumnClass, 'attribute' => $column, 'grid' => $this]); } elseif (is_array($column)) { if (!isset($column['class'])) { $column['class'] = $this->defaultColumnClass; } $column['grid'] = $this; $column = Yii::createObject($column); } $this->columns[$i] = $column; } $this->containerOptions['tag'] = 'tbody'; $this->clientOptions = array_merge(['container' => "tbody.mdm-container{$this->level}", 'itemSelector' => "tr.mdm-item{$this->level}"], $this->clientOptions); Html::addCssClass($this->itemOptions, "mdm-item{$this->level}"); Html::addCssClass($this->containerOptions, "mdm-container{$this->level}"); }