public function testA() { $this->assertEquals('<a href="http://google.com">test</a>', Html::a('test', 'http://google.com')); $this->assertEquals('<a href="http://google.com">текст для ссылки</a>', Html::a('link text', 'http://google.com')); $this->assertEquals('<a href="http://google.com">текст для ссылки</a>', Html::a('link text', 'http://google.com'), ['raw' => false]); $this->assertEquals('<a href="http://google.com">link text</a>', Html::a('link text', 'http://google.com', ['raw' => true])); }
/** * Prepares data for [Jasny file input plugin](http://www.jasny.net/bootstrap/javascript/#fileinput). * @param null $path Path to the image. * @param array $options * @return $this */ public function image($path = null, $options = []) { $options = array_merge($this->inputOptions, $options); $this->adjustLabelFor($options); $this->parts['{input}'] = Html::tag('div', Html::tag('div', Html::tag('div', $path ? Html::img($path . '?' . time()) : '', ['class' => 'fileinput-preview thumbnail', 'data-trigger' => 'fileinput']) . Html::tag('div', Html::tag('div', Html::tag('span', Yii::tr('Select image'), ['class' => 'fileinput-new']) . Html::tag('span', Yii::tr('Change'), ['class' => 'fileinput-exists']) . Html::activeFileInput($this->model, $this->attribute), ['class' => 'btn btn-default btn-file']) . Html::a(Yii::tr('Remove'), '#', ['class' => 'btn btn-default fileinput-exists', 'data-dismiss' => 'fileinput'])), ['class' => 'fileinput fileinput-new', 'data-provides' => 'fileinput']), ['class' => 'image']); $this->enableLabel = false; return $this; }
/** * Creates list items (li tag) for display in (un)ordered list. * @param string $type Messages type to use as base for creating list. * @return mixed */ public function getListItems($type = 'ok') { $array = $type == 'ok' ? $this->oks : $this->errors; $list = []; foreach ($array as $key => $value) { $list[] = Html::a($key, $value); } return $list; }