',
85 | * ]);
86 | *
87 | * ActiveForm::end();
88 | * ```
89 | *
90 | * @see \yii\bootstrap\ActiveForm
91 | * @see http://getbootstrap.com/css/#forms
92 | *
93 | * @author Michael Härtl
94 | * @since 2.0
95 | */
96 | class ActiveField extends \yii\widgets\ActiveField
97 | {
98 | /**
99 | * @var array the default options for the help tags. The parameter passed to [[help()]] will be
100 | * merged with this property when rendering the help tag.
101 | * The following special options are recognized:
102 | *
103 | * - tag: the tag name of the container element. Defaults to "i".
104 | *
105 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
106 | */
107 | public $helpOptions = ['class' => 'uk-icon-question-circle uk-text-muted', 'data' => ['uk-tooltip' => ["cls" => 'help', "offset" => 10]]];
108 |
109 | /**
110 | * @var bool whether to render [[checkboxList()]] and [[radioList()]] inline.
111 | */
112 | public $inline = false;
113 | /**
114 | * @var string|null optional template to render the `{input}` placeholder content
115 | */
116 | public $inputTemplate;
117 | /**
118 | * @var array options for the wrapper tag, used in the `{beginWrapper}` placeholder
119 | */
120 | public $wrapperOptions = [];
121 |
122 | public $options = ['class' => 'uk-form-row'];
123 | public $labelOptions = ['class' => 'uk-form-label'];
124 |
125 | /**
126 | * @var null|array CSS grid classes for horizontal layout. This must be an array with these keys:
127 | * - 'offset' the offset grid class to append to the wrapper if no label is rendered
128 | * - 'label' the label grid class
129 | * - 'wrapper' the wrapper grid class
130 | * - 'error' the error grid class
131 | * - 'hint' the hint grid class
132 | */
133 | public $horizontalCssClasses;
134 | /**
135 | * @var string the template for checkboxes in default layout
136 | */
137 | public $checkboxTemplate = "
";
157 | }
158 | return Html::tag('div', $header . $content . $footer, $options);
159 |
160 | //return Html::errorSummary($models, $options);
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/AjaxButton.php:
--------------------------------------------------------------------------------
1 |
15 | * = Select2::widget([
16 | * 'name' => 'country_code',
17 | * 'data' => Country::getAllCountries(),
18 | * 'options' => [
19 | * 'id' => 'country_select',
20 | * 'multiple' => false,
21 | * 'placeholder' => 'Select country...',
22 | * 'class' => 'uk-width-medium-7-10'
23 | * ]
24 | * ]);?>
25 | *
26 | * 'Проверить',
28 | * 'ajaxOptions'=>
29 | * [
30 | * 'type'=>'POST',
31 | * 'url'=>'country/getinfo',
32 | * 'cache' => false,
33 | * 'success' => new \yii\web\JsExpression('function(html){
34 | * $("#output").html(html);
35 | * }'),
36 | * ],
37 | * 'options' => ['type' => 'submit'],
38 | * ]);
39 | * AjaxButton::end();?>
40 | *
41 | * = Html::endForm(); ?>
42 | * ```
43 | *
44 | * @author Oleg Martemjanov
45 | * @since 2.0
46 | */
47 |
48 | class AjaxButton extends Button
49 | {
50 | public $ajaxOptions = [];
51 |
52 | public function run()
53 | {
54 | parent::run();
55 |
56 | if (!empty($this->ajaxOptions))
57 | $this->registerAjaxScript();
58 | }
59 |
60 | protected function registerAjaxScript()
61 | {
62 | $view = $this->getView();
63 |
64 | if(!isset($this->ajaxOptions['data']) && isset($this->ajaxOptions['type']))
65 | $this->ajaxOptions['data'] = new \yii\web\JsExpression('$(this).parents("form").serialize()');
66 |
67 | $this->ajaxOptions= Json::encode($this->ajaxOptions);
68 | $view->registerJs("$( '#".$this->options['id']."' ).click(function() {
69 | $.ajax(". $this->ajaxOptions .");
70 | return false;
71 | });");
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/Alert.php:
--------------------------------------------------------------------------------
1 | [
16 | * 'class' => 'alert-info',
17 | * ],
18 | * 'body' => 'Say hello...',
19 | * ]);
20 | * ```
21 | *
22 | * The following example will show the content enclosed between the [[begin()]]
23 | * and [[end()]] calls within the alert box:
24 | *
25 | * ```php
26 | * Alert::begin([
27 | * 'options' => [
28 | * 'class' => 'alert-warning',
29 | * ],
30 | * ]);
31 | *
32 | * echo 'Say hello...';
33 | *
34 | * Alert::end();
35 | * ```
36 | *
37 | * @author Oleg Martemjanov
38 | * @since 2.0
39 | *
40 | */
41 | class Alert extends Widget
42 | {
43 | /**
44 | * @var string the body content in the alert component. Note that anything between
45 | * the [[begin()]] and [[end()]] calls of the Alert widget will also be treated
46 | * as the body content, and will be rendered before this.
47 | */
48 | public $body;
49 | /**
50 | * @var array the options for rendering the close button tag.
51 | * The close button is displayed in the header of the modal window. Clicking
52 | * on the button will hide the modal window. If this is null, no close button will be rendered.
53 | *
54 | * The following special options are supported:
55 | *
56 | * - tag: string, the tag name of the button. Defaults to 'button'.
57 | * - label: string, the label of the button. Defaults to '×'.
58 | *
59 | * The rest of the options will be rendered as the HTML attributes of the button tag.
60 | * Please refer to the [Alert documentation](http://getbootstrap.com/components/#alerts)
61 | * for the supported HTML attributes.
62 | */
63 | public $closeButton = [];
64 |
65 | /**
66 | * Initializes the widget.
67 | */
68 | public function init()
69 | {
70 | parent::init();
71 |
72 | $this->initOptions();
73 |
74 | echo Html::beginTag('div', $this->options) . "\n";
75 | echo $this->renderBodyBegin() . "\n";
76 | }
77 |
78 | /**
79 | * Renders the widget.
80 | */
81 | public function run()
82 | {
83 | echo "\n" . $this->renderBodyEnd();
84 | echo "\n" . Html::endTag('div');
85 |
86 | $this->registerAsset();
87 | }
88 |
89 | /**
90 | * Renders the close button if any before rendering the content.
91 | * @return string the rendering result
92 | */
93 | protected function renderBodyBegin()
94 | {
95 | return $this->renderCloseButton();
96 | }
97 |
98 | /**
99 | * Renders the alert body (if any).
100 | * @return string the rendering result
101 | */
102 | protected function renderBodyEnd()
103 | {
104 | return $this->body . "\n";
105 | }
106 |
107 | /**
108 | * Renders the close button.
109 | * @return string the rendering result
110 | */
111 | protected function renderCloseButton()
112 | {
113 | if ($this->closeButton !== null) {
114 | $tag = ArrayHelper::remove($this->closeButton, 'tag', 'a');
115 | $label = ArrayHelper::remove($this->closeButton, 'label', '');
116 |
117 | if ($tag === 'button' && !isset($this->closeButton['type'])) {
118 | $this->closeButton['type'] = 'button';
119 | }
120 |
121 | if ($tag === 'a' && !isset($this->closeButton['href'])) {
122 | $this->closeButton['href'] = '';
123 | }
124 |
125 | return Html::tag($tag, $label, $this->closeButton);
126 | } else {
127 | return null;
128 | }
129 | }
130 |
131 | /**
132 | * Initializes the widget options.
133 | * This method sets the default values for various options.
134 | */
135 | protected function initOptions()
136 | {
137 | Html::addCssClass($this->options, 'uk-alert');
138 | $this->options['data-uk-alert'] = '';
139 |
140 | if ($this->closeButton !== null) {
141 | $this->closeButton = array_merge([
142 | 'class' => 'uk-alert-close uk-close',
143 | ], $this->closeButton);
144 | }
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/Article.php:
--------------------------------------------------------------------------------
1 | [
16 | * 'class' => 'uk-panel uk-panel-box',
17 | * ],
18 | * 'body' => '
Say hello...
',
19 | * ]);
20 | * ```
21 | *
22 | * The following example will show the content enclosed between the [[begin()]]
23 | * and [[end()]] calls within the alert box:
24 | *
25 | * ```php
26 | * Article::begin([
27 | * 'title' => 'First Article',
28 | * 'meta' => '09 May 2014',
29 | * 'lead' => 'This is my first article',
30 | * 'options' => ['class' => 'uk-panel uk-panel-box']
31 | * ]);
32 | *
33 | * echo '
Say hello...
';
34 | *
35 | * Article::end();
36 | * ```
37 | *
38 | * @author Oleg Martemjanov
39 | * @since 2.0
40 | *
41 | */
42 | class Article extends Widget
43 | {
44 |
45 |
46 | /**
47 | * @var string the title of the article.
48 | */
49 | public $title;
50 |
51 | /**
52 | * @var string the meta data of the article.
53 | */
54 | public $meta;
55 |
56 | /**
57 | * @var string the lead of the article.
58 | */
59 | public $lead;
60 |
61 | /**
62 | * @var string the body content in the article component. Note that anything between
63 | * the [[begin()]] and [[end()]] calls of the Article widget will also be treated
64 | * as the body content, and will be rendered before this.
65 | */
66 | public $body;
67 |
68 | /**
69 | * Initializes the widget.
70 | */
71 | public function init()
72 | {
73 | parent::init();
74 |
75 | $this->initOptions();
76 |
77 | echo Html::beginTag('article', $this->options) . "\n";
78 | echo $this->renderTitle() . "\n";
79 | echo $this->renderMeta() . "\n";
80 | echo $this->renderLead() . "\n";
81 | }
82 |
83 | /**
84 | * Renders the widget.
85 | */
86 | public function run()
87 | {
88 | echo "\n" . $this->renderBody();
89 | echo "\n" . Html::endTag('article');
90 |
91 | $this->registerAsset();
92 | }
93 |
94 | /**
95 | * Renders the title of the article.
96 | * @return string the rendering result
97 | */
98 | protected function renderTitle()
99 | {
100 | if ($this->title !== null) {
101 | return Html::tag('h1', $this->title, ['class' => 'uk-article-title']);
102 | } else {
103 | return null;
104 | }
105 | }
106 |
107 | /**
108 | * Renders the meta data.
109 | * @return string the rendering result
110 | */
111 | protected function renderMeta()
112 | {
113 | if ($this->meta !== null) {
114 | return Html::tag('p', $this->meta, ['class' => 'uk-article-meta']);
115 | } else {
116 | return null;
117 | }
118 | }
119 |
120 | /**
121 | * Renders the lead data.
122 | * @return string the rendering result
123 | */
124 | protected function renderLead()
125 | {
126 | if ($this->lead !== null) {
127 | return Html::tag('p', $this->lead, ['class' => 'uk-article-lead']);
128 | } else {
129 | return null;
130 | }
131 | }
132 |
133 | /**
134 | * Renders the article body (if any).
135 | * @return string the rendering result
136 | */
137 | protected function renderBody()
138 | {
139 | return $this->body . "\n";
140 | }
141 |
142 | /**
143 | * Initializes the widget options.
144 | * This method sets the default values for various options.
145 | */
146 | protected function initOptions()
147 | {
148 | Html::addCssClass($this->options, 'uk-article');
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/Badge.php:
--------------------------------------------------------------------------------
1 | [
16 | * 'class' => 'uk-badge-success',
17 | * ],
18 | * 'body' => 'Say hello...',
19 | * ]);
20 | * ```
21 | *
22 | * The following example will show the content enclosed between the [[begin()]]
23 | * and [[end()]] calls within the Badge box:
24 | *
25 | * ```php
26 | * Badge::begin([
27 | * 'isNotification' => true,
28 | * 'options' => [
29 | * 'class' => 'uk-badge-success',
30 | * ],
31 | * ]);
32 | *
33 | * echo 'Say hello...';
34 | *
35 | * Badge::end();
36 | * ```
37 | *
38 | * @author Oleg Martemjanov
39 | * @since 2.0
40 | *
41 | */
42 | class Badge extends Widget
43 | {
44 | /**
45 | * @var string the body content in the Badge component. Note that anything between
46 | * the [[begin()]] and [[end()]] calls of the Badge widget will also be treated
47 | * as the body content, and will be rendered before this.
48 | */
49 | public $body;
50 |
51 | /**
52 | * @var boolean use the notification type of the Badge component.
53 | */
54 | public $isNotification = false;
55 |
56 | /**
57 | * Initializes the widget.
58 | */
59 | public function init()
60 | {
61 | parent::init();
62 |
63 | $this->initOptions();
64 |
65 | echo Html::beginTag('div', $this->options) . "\n";
66 | }
67 |
68 | /**
69 | * Renders the widget.
70 | */
71 | public function run()
72 | {
73 | echo "\n" . $this->body;
74 | echo "\n" . Html::endTag('div');
75 |
76 | $this->registerAsset();
77 | }
78 |
79 | /**
80 | * Initializes the widget options.
81 | * This method sets the default values for various options.
82 | */
83 | protected function initOptions()
84 | {
85 | Html::addCssClass($this->options, 'uk-badge');
86 |
87 | if($this->isNotification)
88 | Html::addCssClass($this->options, 'uk-badge-notification');
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/Breadcrumbs.php:
--------------------------------------------------------------------------------
1 | [
21 | * ['label' => 'Sample Post', 'url' => ['post/edit', 'id' => 1]],
22 | * 'Edit',
23 | * ],
24 | * ]);
25 | * ~~~
26 | *
27 | * Because breadcrumbs usually appears in nearly every page of a website, you may consider placing it in a layout view.
28 | * You can use a view parameter (e.g. `$this->params['breadcrumbs']`) to configure the links in different
29 | * views. In the layout view, you assign this view parameter to the [[links]] property like the following:
30 | *
31 | * ~~~
32 | * // $this is the view object currently being used
33 | * echo Breadcrumbs::widget([
34 | * 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
35 | * ]);
36 | * ~~~
37 | *
38 | * @see http://www.getuikit.com/docs/breadcrumb.html
39 | * @author Nikolay Kostyurin
40 | * @since 2.0
41 | */
42 | class Breadcrumbs extends \yii\widgets\Breadcrumbs
43 | {
44 | /**
45 | * @var string the name of the breadcrumb container tag.
46 | */
47 | public $tag = 'ul';
48 | /**
49 | * @var array the HTML attributes for the breadcrumb container tag.
50 | */
51 | public $options = ['class' => 'uk-breadcrumb'];
52 | /**
53 | * @var boolean whether to HTML-encode the link labels.
54 | */
55 | public $encodeLabels = true;
56 | /**
57 | * @var string the first hyperlink in the breadcrumbs (called home link).
58 | * If this property is not set, it will default to a link pointing to [[\yii\web\Application::homeUrl]]
59 | * with the label 'Home'. If this property is false, the home link will not be rendered.
60 | */
61 | public $homeLink;
62 | /**
63 | * @var array list of links to appear in the breadcrumbs. If this property is empty,
64 | * the widget will not render anything. Each array element represents a single link in the breadcrumbs
65 | * with the following structure:
66 | *
67 | * ~~~
68 | * [
69 | * 'label' => 'label of the link', // required
70 | * 'url' => 'url of the link', // optional, will be processed by Html::url()
71 | * ]
72 | * ~~~
73 | *
74 | * If a link is active, you only need to specify its "label", and instead of writing `['label' => $label]`,
75 | * you should simply use `$label`.
76 | */
77 | public $links = [];
78 | /**
79 | * @var string the template used to render each inactive item in the breadcrumbs. The token `{link}`
80 | * will be replaced with the actual HTML link for each inactive item.
81 | */
82 | public $itemTemplate = "
{link}
\n";
83 | /**
84 | * @var string the template used to render each active item in the breadcrumbs. The token `{link}`
85 | * will be replaced with the actual HTML link for each active item.
86 | */
87 | public $activeItemTemplate = "
{link}
\n";
88 |
89 | /**
90 | * Renders a single breadcrumb item.
91 | * @param array $link the link to be rendered. It must contain the "label" element. The "url" element is optional.
92 | * @param string $template the template to be used to rendered the link. The token "{link}" will be replaced by the link.
93 | * @return string the rendering result
94 | * @throws InvalidConfigException if `$link` does not have "label" element.
95 | */
96 | protected function renderItem($link, $template)
97 | {
98 | if (isset($link['label'])) {
99 | $label = $this->encodeLabels ? Html::encode($link['label']) : $link['label'];
100 | } else {
101 | throw new InvalidConfigException('The "label" element is required for each link.');
102 | }
103 | if (isset($link['url'])) {
104 | return strtr($template, ['{link}' => Html::a($label, $link['url'])]);
105 | } else {
106 | return strtr($template, ['{link}' => Html::tag('span', $label)]);
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/Button.php:
--------------------------------------------------------------------------------
1 | 'Action',
16 | * 'options' => ['class' => 'uk-button-primary'],
17 | * ]);
18 | * ```
19 | *
20 | * @see http://www.getuikit.com/docs/button.html
21 | * @author Nikolay Kostyurin
22 | * @since 2.0
23 | */
24 | class Button extends Widget
25 | {
26 | /**
27 | * @var string the tag to use to render the button
28 | */
29 | public $tagName = 'button';
30 | /**
31 | * @var string the button label
32 | */
33 | public $label = 'Button';
34 | /**
35 | * @var boolean whether the label should be HTML-encoded.
36 | */
37 | public $encodeLabel = true;
38 |
39 | /**
40 | * Initializes the widget.
41 | * If you override this method, make sure you call the parent implementation first.
42 | */
43 | public function init()
44 | {
45 | parent::init();
46 | $this->clientOptions = false;
47 | Html::addCssClass($this->options, 'uk-button');
48 | }
49 |
50 | /**
51 | * Renders the widget.
52 | */
53 | public function run()
54 | {
55 | echo Html::tag($this->tagName, $this->encodeLabel ? Html::encode($this->label) : $this->label, $this->options);
56 |
57 | $this->registerAsset();
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/ButtonGroup.php:
--------------------------------------------------------------------------------
1 | ['class' => 'uk-margin-top'],
17 | * ]); ?>
18 | * = Html::a('Южная Америка', \yii\helpers\Url::toRoute(['country/mainland', 'alias' => 'south-america']), ['class' => 'uk-button uk-button-primary'] ) ?>
19 | * = Html::a('Африка', \yii\helpers\Url::toRoute(['country/mainland', 'alias' => 'africa']), ['class' => 'uk-button uk-button-primary'] ) ?>
20 | * = Html::a('Австралия', \yii\helpers\Url::toRoute(['country/mainland', 'alias' => 'australia']), ['class' => 'uk-button uk-button-primary'] ) ?>
21 | *
22 | * ```
23 | *
24 | * @see http://www.getuikit.com/docs/button.html
25 | *
26 | * @author Oleg Martemjanov
27 | * @since 2.0
28 | */
29 | class ButtonGroup extends Widget
30 | {
31 | /**
32 | * @var bool toggle between a group of buttons like a checkbox.
33 | */
34 | public $checkboxButtons = false;
35 |
36 | /**
37 | * @var bool toggle between a group of buttons, like radio buttons.
38 | */
39 | public $radioButtons = false;
40 |
41 | /**
42 | * Initializes the widget.
43 | */
44 | public function init()
45 | {
46 | parent::init();
47 |
48 | Html::addCssClass($this->options, 'uk-button-group');
49 |
50 | if ($this->checkboxButtons)
51 | $this->options = array_merge(['data-uk-button-checkbox' => ''], $this->options);
52 |
53 | if ($this->radioButtons)
54 | if ($this->checkboxButtons)
55 | throw new InvalidConfigException("Options 'checkboxButtons' and 'radioButtons' cannot be used at the same time.");
56 | else
57 | $this->options = array_merge(['data-uk-button-radio' => ''], $this->options);
58 |
59 | echo Html::beginTag('div', $this->options) . "\n";
60 | }
61 |
62 | /**
63 | * Renders the widget.
64 | */
65 | public function run()
66 | {
67 | echo Html::endTag('div');
68 | $this->registerAsset();
69 | }
70 |
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/Close.php:
--------------------------------------------------------------------------------
1 | 'button']);
13 | * ]);
14 | * ```
15 | * @see http://www.getuikit.com/docs/close.html
16 | * @author Oleg Martemjanov
17 | * @since 2.0
18 | */
19 | class Close extends Widget
20 | {
21 |
22 | /**
23 | * @var string the tag to be used. an or