From 0f6a7080971566e268c593ea2005ca02af4e2d15 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Thu, 23 May 2013 22:34:07 +0400 Subject: [PATCH 01/16] jQuery Tabs widget raw --- framework/yii/jui/Tabs.php | 85 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 framework/yii/jui/Tabs.php diff --git a/framework/yii/jui/Tabs.php b/framework/yii/jui/Tabs.php new file mode 100644 index 0000000..314aa25 --- /dev/null +++ b/framework/yii/jui/Tabs.php @@ -0,0 +1,85 @@ + array( + * 'One' => array( + * 'content' => 'Mauris mauris ante, blandit et, ultrices a, suscipit eget...', + * 'contentOptions' => array(...), + * ), + * 'Two' => array( + * 'content' => 'Sed non urna. Phasellus eu ligula. Vestibulum sit amet purus...', + * 'headerOptions' => array(...), + * ), + * ), + * )); + * ``` + * + * @see http://api.jqueryui.com/tabs/ + * @author Alexander Kochetov + * @since 2.0 + */ +class Tabs extends Widget +{ + /** + * @var array list of tabs in the tabs widget. Each array element represents a single + * tab with the following structure: + * + * ```php + * // item key is the actual tab header label + * 'Tab header label' => array( + * // required, the content (HTML) of the tab + * 'content' => 'Mauris mauris ante, blandit et, ultrices a, suscipit eget...', + * // optional the HTML attributes of the tab content container + * 'contentOptions'=> array(...), + * // optional the HTML attributes of the tab header container + * 'headerOptions'=> array(...), + * ) + * ``` + */ + public $items = array(); + + + /** + * Renders the widget. + */ + public function run() + { + echo Html::beginTag('div', $this->options) . "\n"; + $headers = array(); + $contents = array(); + $index = 0; + foreach ($this->items as $header => $item) { + $id = $this->options['id'] . '-tab' . ++$index; + $headerOptions = ArrayHelper::getValue($item, 'headerOptions', array()); + $headers[] = Html::tag('li', Html::tag('a', $header, array('href' => "#$id")), $headerOptions); + if (isset($item['content'])) { + $contentOptions = ArrayHelper::getValue($item, 'contentOptions', array()); + $contentOptions['id'] = $id; + $contents[] = Html::tag('div', $item['content'], $contentOptions); + } else { + throw new InvalidConfigException("The 'content' option is required."); + } + } + echo Html::tag('ul', implode("\n", $headers)) . "\n"; + echo implode("\n", $contents) . "\n"; + echo Html::endTag('div') . "\n"; + $this->registerWidget('tabs'); + } +} From 153e51df94c93d8d4d925c9c2a8b5967489225b9 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Thu, 23 May 2013 23:34:12 +0400 Subject: [PATCH 02/16] Html::url() fix for anchors --- framework/yii/helpers/base/Html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/yii/helpers/base/Html.php b/framework/yii/helpers/base/Html.php index f601772..90396ec 100644 --- a/framework/yii/helpers/base/Html.php +++ b/framework/yii/helpers/base/Html.php @@ -1364,7 +1364,7 @@ class Html return Yii::$app->getRequest()->getUrl(); } else { $url = Yii::getAlias($url); - if ($url[0] === '/' || strpos($url, '://')) { + if ($url[0] === '/' || $url[0] === '#' || strpos($url, '://')) { return $url; } else { return Yii::$app->getRequest()->getBaseUrl() . '/' . $url; From 646161e01ce38876f7290e5589c8bdeeb62d9bd7 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Fri, 24 May 2013 00:02:40 +0400 Subject: [PATCH 03/16] Refactoring --- framework/yii/jui/Tabs.php | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/framework/yii/jui/Tabs.php b/framework/yii/jui/Tabs.php index 314aa25..258a3a4 100644 --- a/framework/yii/jui/Tabs.php +++ b/framework/yii/jui/Tabs.php @@ -12,7 +12,7 @@ use yii\helpers\base\ArrayHelper; use yii\helpers\Html; /** - * Tabs renders an tabs jQuery UI widget. + * Tabs renders a tabs jQuery UI widget. * * For example: * @@ -62,24 +62,49 @@ class Tabs extends Widget public function run() { echo Html::beginTag('div', $this->options) . "\n"; + echo $this->renderHeaders() . "\n"; + echo $this->renderItems() . "\n"; + echo Html::endTag('div') . "\n"; + $this->registerWidget('tabs'); + } + + /** + * Renders tabs headers as specified on [[items]]. + * @return string the rendering result. + */ + protected function renderHeaders() + { $headers = array(); - $contents = array(); $index = 0; foreach ($this->items as $header => $item) { $id = $this->options['id'] . '-tab' . ++$index; $headerOptions = ArrayHelper::getValue($item, 'headerOptions', array()); - $headers[] = Html::tag('li', Html::tag('a', $header, array('href' => "#$id")), $headerOptions); + $headers[] = Html::tag('li', Html::a($header, "#$id"), $headerOptions); + } + + return Html::tag('ul', implode("\n", $headers)); + } + + /** + * Renders tabs items as specified on [[items]]. + * @return string the rendering result. + * @throws InvalidConfigException. + */ + protected function renderItems() + { + $items = array(); + $index = 0; + foreach ($this->items as $item) { + $id = $this->options['id'] . '-tab' . ++$index; if (isset($item['content'])) { $contentOptions = ArrayHelper::getValue($item, 'contentOptions', array()); $contentOptions['id'] = $id; - $contents[] = Html::tag('div', $item['content'], $contentOptions); + $items[] = Html::tag('div', $item['content'], $contentOptions); } else { throw new InvalidConfigException("The 'content' option is required."); } } - echo Html::tag('ul', implode("\n", $headers)) . "\n"; - echo implode("\n", $contents) . "\n"; - echo Html::endTag('div') . "\n"; - $this->registerWidget('tabs'); + + return implode("\n", $items); } } From f50e8f6bfced26f2d9dfaf5d71d7b6e45d8b56ce Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Fri, 24 May 2013 00:34:56 +0400 Subject: [PATCH 04/16] Final --- framework/yii/jui/Tabs.php | 55 +++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/framework/yii/jui/Tabs.php b/framework/yii/jui/Tabs.php index 258a3a4..4007d4b 100644 --- a/framework/yii/jui/Tabs.php +++ b/framework/yii/jui/Tabs.php @@ -19,13 +19,15 @@ use yii\helpers\Html; * ```php * echo Tabs::widget(array( * 'items' => array( - * 'One' => array( + * array( + * 'header' => 'One', * 'content' => 'Mauris mauris ante, blandit et, ultrices a, suscipit eget...', - * 'contentOptions' => array(...), * ), - * 'Two' => array( - * 'content' => 'Sed non urna. Phasellus eu ligula. Vestibulum sit amet purus...', + * array( + * 'header' => 'Two', * 'headerOptions' => array(...), + * 'content' => 'Sed non urna. Phasellus eu ligula. Vestibulum sit amet purus...', + * 'options' => array(...), * ), * ), * )); @@ -42,12 +44,13 @@ class Tabs extends Widget * tab with the following structure: * * ```php - * // item key is the actual tab header label - * 'Tab header label' => array( + * array( + * // required, the header (HTML) of the tab + * 'header' => 'Tab label', * // required, the content (HTML) of the tab * 'content' => 'Mauris mauris ante, blandit et, ultrices a, suscipit eget...', * // optional the HTML attributes of the tab content container - * 'contentOptions'=> array(...), + * 'options'=> array(...), * // optional the HTML attributes of the tab header container * 'headerOptions'=> array(...), * ) @@ -63,7 +66,7 @@ class Tabs extends Widget { echo Html::beginTag('div', $this->options) . "\n"; echo $this->renderHeaders() . "\n"; - echo $this->renderItems() . "\n"; + echo $this->renderContents() . "\n"; echo Html::endTag('div') . "\n"; $this->registerWidget('tabs'); } @@ -71,40 +74,46 @@ class Tabs extends Widget /** * Renders tabs headers as specified on [[items]]. * @return string the rendering result. + * @throws InvalidConfigException. */ protected function renderHeaders() { $headers = array(); - $index = 0; - foreach ($this->items as $header => $item) { - $id = $this->options['id'] . '-tab' . ++$index; - $headerOptions = ArrayHelper::getValue($item, 'headerOptions', array()); - $headers[] = Html::tag('li', Html::a($header, "#$id"), $headerOptions); + foreach ($this->items as $n => $item) { + $options = ArrayHelper::getValue($item, 'options', array()); + $id = isset($options['id']) ? $options['id'] : $this->options['id'] . '-tab' . $n; + if (isset($item['header'])) { + $headerOptions = ArrayHelper::getValue($item, 'headerOptions', array()); + $headers[] = Html::tag('li', Html::a($item['header'], "#$id"), $headerOptions); + } else { + throw new InvalidConfigException("The 'header' option is required."); + } } return Html::tag('ul', implode("\n", $headers)); } /** - * Renders tabs items as specified on [[items]]. + * Renders tabs contents as specified on [[items]]. * @return string the rendering result. * @throws InvalidConfigException. */ - protected function renderItems() + protected function renderContents() { - $items = array(); - $index = 0; - foreach ($this->items as $item) { - $id = $this->options['id'] . '-tab' . ++$index; + $contents = array(); + foreach ($this->items as $n => $item) { + $id = $this->options['id'] . '-tab' . $n; if (isset($item['content'])) { - $contentOptions = ArrayHelper::getValue($item, 'contentOptions', array()); - $contentOptions['id'] = $id; - $items[] = Html::tag('div', $item['content'], $contentOptions); + $options = ArrayHelper::getValue($item, 'options', array()); + if (!isset($options['id'])) { + $options['id'] = $id; + } + $contents[] = Html::tag('div', $item['content'], $options); } else { throw new InvalidConfigException("The 'content' option is required."); } } - return implode("\n", $items); + return implode("\n", $contents); } } From cc5981e2e2ddd4c4783081bcf5aa823c07773e69 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Fri, 24 May 2013 00:38:37 +0400 Subject: [PATCH 05/16] Post final ;) --- framework/yii/jui/Tabs.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/framework/yii/jui/Tabs.php b/framework/yii/jui/Tabs.php index 4007d4b..171b7fe 100644 --- a/framework/yii/jui/Tabs.php +++ b/framework/yii/jui/Tabs.php @@ -80,14 +80,13 @@ class Tabs extends Widget { $headers = array(); foreach ($this->items as $n => $item) { - $options = ArrayHelper::getValue($item, 'options', array()); - $id = isset($options['id']) ? $options['id'] : $this->options['id'] . '-tab' . $n; - if (isset($item['header'])) { - $headerOptions = ArrayHelper::getValue($item, 'headerOptions', array()); - $headers[] = Html::tag('li', Html::a($item['header'], "#$id"), $headerOptions); - } else { + if (!isset($item['header'])) { throw new InvalidConfigException("The 'header' option is required."); } + $options = ArrayHelper::getValue($item, 'options', array()); + $id = isset($options['id']) ? $options['id'] : $this->options['id'] . '-tab' . $n; + $headerOptions = ArrayHelper::getValue($item, 'headerOptions', array()); + $headers[] = Html::tag('li', Html::a($item['header'], "#$id"), $headerOptions); } return Html::tag('ul', implode("\n", $headers)); @@ -102,16 +101,15 @@ class Tabs extends Widget { $contents = array(); foreach ($this->items as $n => $item) { - $id = $this->options['id'] . '-tab' . $n; - if (isset($item['content'])) { - $options = ArrayHelper::getValue($item, 'options', array()); - if (!isset($options['id'])) { - $options['id'] = $id; - } - $contents[] = Html::tag('div', $item['content'], $options); - } else { + if (!isset($item['content'])) { throw new InvalidConfigException("The 'content' option is required."); } + $id = $this->options['id'] . '-tab' . $n; + $options = ArrayHelper::getValue($item, 'options', array()); + if (!isset($options['id'])) { + $options['id'] = $id; + } + $contents[] = Html::tag('div', $item['content'], $options); } return implode("\n", $contents); From 7724b5f5e4faa0fb8a6c78d5f4d7dc3f3a10b968 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Fri, 24 May 2013 00:44:36 +0400 Subject: [PATCH 06/16] Cosmetic change --- framework/yii/jui/Tabs.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/framework/yii/jui/Tabs.php b/framework/yii/jui/Tabs.php index 171b7fe..ca0b3da 100644 --- a/framework/yii/jui/Tabs.php +++ b/framework/yii/jui/Tabs.php @@ -104,10 +104,9 @@ class Tabs extends Widget if (!isset($item['content'])) { throw new InvalidConfigException("The 'content' option is required."); } - $id = $this->options['id'] . '-tab' . $n; $options = ArrayHelper::getValue($item, 'options', array()); if (!isset($options['id'])) { - $options['id'] = $id; + $options['id'] = $this->options['id'] . '-tab' . $n; } $contents[] = Html::tag('div', $item['content'], $options); } From df025fc2bfa27c775cd523d361f9b13db10d51b7 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Fri, 24 May 2013 01:18:38 +0400 Subject: [PATCH 07/16] jQuery Accordion rework --- framework/yii/jui/Accordion.php | 65 ++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/framework/yii/jui/Accordion.php b/framework/yii/jui/Accordion.php index df9ba20..9b68a7e 100644 --- a/framework/yii/jui/Accordion.php +++ b/framework/yii/jui/Accordion.php @@ -19,13 +19,15 @@ use yii\helpers\Html; * ```php * echo Accordion::widget(array( * 'items' => array( - * 'Section 1' => array( + * array( + * 'header' => 'Section 1', * 'content' => 'Mauris mauris ante, blandit et, ultrices a, suscipit eget...', - * 'contentOptions' => array(...), * ), - * 'Section 2' => array( - * 'content' => 'Sed non urna. Phasellus eu ligula. Vestibulum sit amet purus...', + * array( + * 'header' => 'Section 2', * 'headerOptions' => array(...), + * 'content' => 'Sed non urna. Phasellus eu ligula. Vestibulum sit amet purus...', + * 'options' => array(...), * ), * ), * )); @@ -42,12 +44,13 @@ class Accordion extends Widget * section with the following structure: * * ```php - * // item key is the actual section header - * 'Section' => array( + * array( + * // required, the header (HTML) of the section + * 'header' => 'Section label', * // required, the content (HTML) of the section * 'content' => 'Mauris mauris ante, blandit et, ultrices a, suscipit eget...', * // optional the HTML attributes of the content section - * 'contentOptions'=> array(...), + * 'options'=> array(...), * // optional the HTML attributes of the header section * 'headerOptions'=> array(...), * ) @@ -62,46 +65,36 @@ class Accordion extends Widget public function run() { echo Html::beginTag('div', $this->options) . "\n"; - echo $this->renderItems() . "\n"; + echo $this->renderSections() . "\n"; echo Html::endTag('div') . "\n"; $this->registerWidget('accordion'); } /** - * Renders collapsible items as specified on [[items]]. + * Renders collapsible sections as specified on [[items]]. * @return string the rendering result. + * @throws InvalidConfigException. */ - public function renderItems() + protected function renderSections() { - $items = array(); - foreach ($this->items as $header => $item) { - $items[] = $this->renderItem($header, $item); - } + $sections = array(); + foreach ($this->items as $item) { + if (!isset($item['header'])) { + throw new InvalidConfigException("The 'header' option is required."); + } - return implode("\n", $items); - } + $headerOptions = ArrayHelper::getValue($item, 'headerOptions', array()); + $sections[] = Html::tag('h3', $item['header'], $headerOptions); - /** - * Renders a single collapsible item section. - * @param string $header a label of the item section [[items]]. - * @param array $item a single item from [[items]]. - * @return string the rendering result. - * @throws InvalidConfigException. - */ - public function renderItem($header, $item) - { - if (isset($item['content'])) { - $contentOptions = ArrayHelper::getValue($item, 'contentOptions', array()); - $content = Html::tag('div', $item['content']) . "\n"; - } else { - throw new InvalidConfigException("The 'content' option is required."); - } + if (!isset($item['content'])) { + throw new InvalidConfigException("The 'content' option is required."); + } + + $options = ArrayHelper::getValue($item, 'options', array()); + $sections[] = Html::tag('div', $item['content'], $options);; - $group = array(); - $headerOptions = ArrayHelper::getValue($item, 'headerOptions', array()); - $group[] = Html::tag('h3', $header, $headerOptions); - $group[] = Html::tag('div', $content, $contentOptions); + } - return implode("\n", $group); + return implode("\n", $sections); } } From be82ee81dbcbe4c3dca4914256d7f28e1c505ee6 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Fri, 24 May 2013 01:26:31 +0400 Subject: [PATCH 08/16] Comment fixes --- framework/yii/jui/Accordion.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/yii/jui/Accordion.php b/framework/yii/jui/Accordion.php index 9b68a7e..a4bae15 100644 --- a/framework/yii/jui/Accordion.php +++ b/framework/yii/jui/Accordion.php @@ -49,9 +49,9 @@ class Accordion extends Widget * 'header' => 'Section label', * // required, the content (HTML) of the section * 'content' => 'Mauris mauris ante, blandit et, ultrices a, suscipit eget...', - * // optional the HTML attributes of the content section + * // optional the HTML attributes of the section content container * 'options'=> array(...), - * // optional the HTML attributes of the header section + * // optional the HTML attributes of the section header container * 'headerOptions'=> array(...), * ) * ``` From fb9dbdb236d532820d8924131ef1576559abb892 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Fri, 24 May 2013 01:29:41 +0400 Subject: [PATCH 09/16] Cosmetic code move --- framework/yii/jui/Accordion.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/framework/yii/jui/Accordion.php b/framework/yii/jui/Accordion.php index a4bae15..6c5dd97 100644 --- a/framework/yii/jui/Accordion.php +++ b/framework/yii/jui/Accordion.php @@ -82,17 +82,13 @@ class Accordion extends Widget if (!isset($item['header'])) { throw new InvalidConfigException("The 'header' option is required."); } - - $headerOptions = ArrayHelper::getValue($item, 'headerOptions', array()); - $sections[] = Html::tag('h3', $item['header'], $headerOptions); - if (!isset($item['content'])) { throw new InvalidConfigException("The 'content' option is required."); } - + $headerOptions = ArrayHelper::getValue($item, 'headerOptions', array()); + $sections[] = Html::tag('h3', $item['header'], $headerOptions); $options = ArrayHelper::getValue($item, 'options', array()); $sections[] = Html::tag('div', $item['content'], $options);; - } return implode("\n", $sections); From 5f6700183959338a66bc2645964a603cf276b5c6 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Fri, 24 May 2013 01:56:51 +0400 Subject: [PATCH 10/16] jQuery UI effects dependencies --- framework/yii/jui/assets.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/framework/yii/jui/assets.php b/framework/yii/jui/assets.php index c292050..285026c 100644 --- a/framework/yii/jui/assets.php +++ b/framework/yii/jui/assets.php @@ -20,7 +20,7 @@ return array( 'js' => array( 'jquery.ui.accordion.js', ), - 'depends' => array('yii/jui/core', 'yii/jui/widget'), + 'depends' => array('yii/jui/core', 'yii/jui/widget', 'yii/jui/effect/all'), ), 'yii/jui/autocomplete' => array( 'sourcePath' => __DIR__ . '/assets', @@ -41,7 +41,7 @@ return array( 'js' => array( 'jquery.ui.datepicker.js', ), - 'depends' => array('yii/jui/core'), + 'depends' => array('yii/jui/core', 'yii/jui/effect/all'), ), 'yii/jui/datepicker/i18n/af' => array( 'sourcePath' => __DIR__ . '/assets', @@ -559,7 +559,7 @@ return array( 'js' => array( 'jquery.ui.dialog.js', ), - 'depends' => array('yii/jui/core', 'yii/jui/widget', 'yii/jui/button', 'yii/jui/draggable', 'yii/jui/mouse', 'yii/jui/position', 'yii/jui/resizeable'), + 'depends' => array('yii/jui/core', 'yii/jui/widget', 'yii/jui/button', 'yii/jui/draggable', 'yii/jui/mouse', 'yii/jui/position', 'yii/jui/resizeable', 'yii/jui/effect/all'), ), 'yii/jui/draggable' => array( 'sourcePath' => __DIR__ . '/assets', @@ -582,6 +582,13 @@ return array( ), 'depends' => array('yii/jquery'), ), + 'yii/jui/effect/all' => array( + 'sourcePath' => __DIR__ . '/assets', + 'js' => array( + 'jquery.ui.effect.js', + ), + 'depends' => array('yii/jui/effect/blind', 'yii/jui/effect/bounce', 'yii/jui/effect/clip', 'yii/jui/effect/drop', 'yii/jui/effect/explode', 'yii/jui/effect/fade', 'yii/jui/effect/fold', 'yii/jui/effect/highlight', 'yii/jui/effect/pulsate', 'yii/jui/effect/scale', 'yii/jui/effect/shake', 'yii/jui/effect/slide', 'yii/jui/effect/transfer'), + ), 'yii/jui/effect/blind' => array( 'sourcePath' => __DIR__ . '/assets', 'js' => array( @@ -741,14 +748,14 @@ return array( 'js' => array( 'jquery.ui.tabs.js', ), - 'depends' => array('yii/jui/core', 'yii/jui/widget'), + 'depends' => array('yii/jui/core', 'yii/jui/widget', 'yii/jui/effect/all'), ), 'yii/jui/tooltip' => array( 'sourcePath' => __DIR__ . '/assets', 'js' => array( 'jquery.ui.tooltip.js', ), - 'depends' => array('yii/jui/core', 'yii/jui/widget', 'yii/jui/position'), + 'depends' => array('yii/jui/core', 'yii/jui/widget', 'yii/jui/position', 'yii/jui/effect/all'), ), 'yii/jui/theme/base' => array( 'sourcePath' => __DIR__ . '/assets', From 7614450fa7e19e962d6c984dad1823cd2125a83c Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Fri, 24 May 2013 02:41:00 +0400 Subject: [PATCH 11/16] jQuery UI menu widget --- framework/yii/jui/Menu.php | 86 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 framework/yii/jui/Menu.php diff --git a/framework/yii/jui/Menu.php b/framework/yii/jui/Menu.php new file mode 100644 index 0000000..0a84acf --- /dev/null +++ b/framework/yii/jui/Menu.php @@ -0,0 +1,86 @@ + + * @since 2.0 + */ +class Menu extends \yii\widgets\Menu +{ + /** + * @var array the options for the underlying jQuery UI widget. + * Please refer to the corresponding jQuery UI widget Web page for possible options. + * For example, [this page](http://api.jqueryui.com/accordion/) shows + * how to use the "Accordion" widget and the supported options (e.g. "header"). + */ + public $clientOptions = array(); + /** + * @var array the event handlers for the underlying jQuery UI widget. + * Please refer to the corresponding jQuery UI widget Web page for possible events. + * For example, [this page](http://api.jqueryui.com/accordion/) shows + * how to use the "Accordion" widget and the supported events (e.g. "create"). + */ + public $clientEvents = array(); + + + /** + * Initializes the widget. + * If you override this method, make sure you call the parent implementation first. + */ + public function init() + { + parent::init(); + if (!isset($this->options['id'])) { + $this->options['id'] = $this->getId(); + } + } + + /** + * Renders the widget. + */ + public function run() + { + parent::run(); + $this->registerWidget('menu'); + } + + /** + * Registers a specific jQuery UI widget and the related events + * @param string $name the name of the jQuery UI widget + */ + protected function registerWidget($name) + { + $id = $this->options['id']; + $view = $this->getView(); + $view->registerAssetBundle("yii/jui/$name"); + $view->registerAssetBundle(Widget::$theme . "/$name"); + + if ($this->clientOptions !== false) { + $options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions); + $js = "jQuery('#$id').$name($options);"; + $view->registerJs($js); + } + + if (!empty($this->clientEvents)) { + $js = array(); + foreach ($this->clientEvents as $event => $handler) { + $js[] = "jQuery('#$id').on('$name$event', $handler);"; + } + $view->registerJs(implode("\n", $js)); + } + } +} From 133edb2352ce88f9f10b5568ceff8470dede05b6 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 23 May 2013 21:01:01 -0400 Subject: [PATCH 12/16] Added documentation to AccessControl. --- framework/yii/web/AccessControl.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/framework/yii/web/AccessControl.php b/framework/yii/web/AccessControl.php index c4efd19..ce64533 100644 --- a/framework/yii/web/AccessControl.php +++ b/framework/yii/web/AccessControl.php @@ -13,6 +13,39 @@ use yii\base\ActionFilter; use yii\base\HttpException; /** + * AccessControl provides simple access control based on a set of rules. + * + * AccessControl is an action filter. It will check its [[rules]] to find + * the first rule that matches the current context variables (such as user IP address, user role). + * The matching rule will dictate whether to allow or deny the access to the requested controller + * action. + * + * To use AccessControl, declare it in the `behaviors()` method of your controller class. + * For example, the following declarations will allow authenticated users to access the "create" + * and "update" actions and deny all other users from accessing these two actions. + * + * ~~~ + * public function behaviors() + * { + * return array( + * 'access' => array( + * 'class' => \yii\web\AccessControl::className(), + * 'only' => array('create', 'update'), + * 'rules' => array( + * // allow authenticated users + * array( + * 'allow' => true, + * 'roles' => array('@'), + * ), + * // deny all + * array( + * 'allow' => false, + * ), + * ), + * ), + * ); + * } + * ~~~ * * @author Qiang Xue * @since 2.0 From 9a13ddb8a655828af6cd836b2fd1c5518f413455 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 24 May 2013 15:14:36 +0400 Subject: [PATCH 13/16] Moved Smarty and Twig renderers into extensions --- extensions/smarty/composer.json | 27 +++++++ extensions/smarty/yii/smarty/ViewRenderer.php | 99 ++++++++++++++++++++++++++ extensions/twig/composer.json | 27 +++++++ extensions/twig/yii/twig/ViewRenderer.php | 73 +++++++++++++++++++ framework/yii/renderers/SmartyViewRenderer.php | 99 -------------------------- framework/yii/renderers/TwigViewRenderer.php | 73 ------------------- 6 files changed, 226 insertions(+), 172 deletions(-) create mode 100644 extensions/smarty/composer.json create mode 100644 extensions/smarty/yii/smarty/ViewRenderer.php create mode 100644 extensions/twig/composer.json create mode 100644 extensions/twig/yii/twig/ViewRenderer.php delete mode 100644 framework/yii/renderers/SmartyViewRenderer.php delete mode 100644 framework/yii/renderers/TwigViewRenderer.php diff --git a/extensions/smarty/composer.json b/extensions/smarty/composer.json new file mode 100644 index 0000000..3a74f41 --- /dev/null +++ b/extensions/smarty/composer.json @@ -0,0 +1,27 @@ +{ + "name": "yiisoft/yii2-smarty", + "description": "The Smarty integration for the Yii framework", + "keywords": ["yii", "smarty", "renderer"], + "type": "library", + "license": "BSD-3-Clause", + "support": { + "issues": "https://github.com/yiisoft/yii2/issues?state=open", + "forum": "http://www.yiiframework.com/forum/", + "wiki": "http://www.yiiframework.com/wiki/", + "irc": "irc://irc.freenode.net/yii", + "source": "https://github.com/yiisoft/yii2" + }, + "authors": [ + { + "name": "Alenxader Makarov", + "email": "sam@rmcreative.ru" + } + ], + "minimum-stability": "dev", + "require": { + "yiisoft/yii2": "*" + }, + "autoload": { + "psr-0": { "yii\\smarty": "" } + } +} diff --git a/extensions/smarty/yii/smarty/ViewRenderer.php b/extensions/smarty/yii/smarty/ViewRenderer.php new file mode 100644 index 0000000..d8c5d30 --- /dev/null +++ b/extensions/smarty/yii/smarty/ViewRenderer.php @@ -0,0 +1,99 @@ + + * @since 2.0 + */ +class ViewRenderer extends BaseViewRenderer +{ + /** + * @var string the directory or path alias pointing to where Smarty cache will be stored. + */ + public $cachePath = '@app/runtime/Smarty/cache'; + + /** + * @var string the directory or path alias pointing to where Smarty compiled templates will be stored. + */ + public $compilePath = '@app/runtime/Smarty/compile'; + + /** + * @var Smarty + */ + public $smarty; + + public function init() + { + $this->smarty = new Smarty(); + $this->smarty->setCompileDir(Yii::getAlias($this->compilePath)); + $this->smarty->setCacheDir(Yii::getAlias($this->cachePath)); + + $this->smarty->registerPlugin('function', 'path', array($this, 'smarty_function_path')); + } + + /** + * Smarty template function to get a path for using in links + * + * Usage is the following: + * + * {path route='blog/view' alias=$post.alias user=$user.id} + * + * where route is Yii route and the rest of parameters are passed as is. + * + * @param $params + * @param \Smarty_Internal_Template $template + * + * @return string + */ + public function smarty_function_path($params, \Smarty_Internal_Template $template) + { + if (!isset($params['route'])) { + trigger_error("path: missing 'route' parameter"); + } + + array_unshift($params, $params['route']) ; + unset($params['route']); + + return Html::url($params); + } + + /** + * Renders a view file. + * + * This method is invoked by [[View]] whenever it tries to render a view. + * Child classes must implement this method to render the given view file. + * + * @param View $view the view object used for rendering the file. + * @param string $file the view file. + * @param array $params the parameters to be passed to the view file. + * + * @return string the rendering result + */ + public function render($view, $file, $params) + { + $ext = pathinfo($file, PATHINFO_EXTENSION); + /** @var \Smarty_Internal_Template $template */ + $template = $this->smarty->createTemplate($file, null, null, $params, true); + + $template->assign('app', \Yii::$app); + $template->assign('this', $view); + + return $template->fetch(); + } +} diff --git a/extensions/twig/composer.json b/extensions/twig/composer.json new file mode 100644 index 0000000..624f8bd --- /dev/null +++ b/extensions/twig/composer.json @@ -0,0 +1,27 @@ +{ + "name": "yiisoft/yii2-twig", + "description": "The Twig integration for the Yii framework", + "keywords": ["yii", "twig", "renderer"], + "type": "library", + "license": "BSD-3-Clause", + "support": { + "issues": "https://github.com/yiisoft/yii2/issues?state=open", + "forum": "http://www.yiiframework.com/forum/", + "wiki": "http://www.yiiframework.com/wiki/", + "irc": "irc://irc.freenode.net/yii", + "source": "https://github.com/yiisoft/yii2" + }, + "authors": [ + { + "name": "Alenxader Makarov", + "email": "sam@rmcreative.ru" + } + ], + "minimum-stability": "dev", + "require": { + "yiisoft/yii2": "*" + }, + "autoload": { + "psr-0": { "yii\\twig": "" } + } +} diff --git a/extensions/twig/yii/twig/ViewRenderer.php b/extensions/twig/yii/twig/ViewRenderer.php new file mode 100644 index 0000000..7498d86 --- /dev/null +++ b/extensions/twig/yii/twig/ViewRenderer.php @@ -0,0 +1,73 @@ + + * @since 2.0 + */ +class ViewRenderer extends BaseViewRenderer +{ + /** + * @var string the directory or path alias pointing to where Twig cache will be stored. + */ + public $cachePath = '@app/runtime/Twig/cache'; + + /** + * @var array Twig options + * @see http://twig.sensiolabs.org/doc/api.html#environment-options + */ + public $options = array(); + + /** + * @var \Twig_Environment + */ + public $twig; + + public function init() + { + $loader = new \Twig_Loader_String(); + + $this->twig = new \Twig_Environment($loader, array_merge(array( + 'cache' => Yii::getAlias($this->cachePath), + ), $this->options)); + + $this->twig->addFunction('path', new \Twig_Function_Function(function($path, $args = array()){ + return Html::url(array_merge(array($path), $args)); + })); + + $this->twig->addGlobal('app', \Yii::$app); + } + + /** + * Renders a view file. + * + * This method is invoked by [[View]] whenever it tries to render a view. + * Child classes must implement this method to render the given view file. + * + * @param View $view the view object used for rendering the file. + * @param string $file the view file. + * @param array $params the parameters to be passed to the view file. + * + * @return string the rendering result + */ + public function render($view, $file, $params) + { + $this->twig->addGlobal('this', $view); + return $this->twig->render(file_get_contents($file), $params); + } +} diff --git a/framework/yii/renderers/SmartyViewRenderer.php b/framework/yii/renderers/SmartyViewRenderer.php deleted file mode 100644 index ac66e0d..0000000 --- a/framework/yii/renderers/SmartyViewRenderer.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @since 2.0 - */ -class SmartyViewRenderer extends ViewRenderer -{ - /** - * @var string the directory or path alias pointing to where Smarty cache will be stored. - */ - public $cachePath = '@app/runtime/Smarty/cache'; - - /** - * @var string the directory or path alias pointing to where Smarty compiled templates will be stored. - */ - public $compilePath = '@app/runtime/Smarty/compile'; - - /** - * @var Smarty - */ - public $smarty; - - public function init() - { - $this->smarty = new Smarty(); - $this->smarty->setCompileDir(Yii::getAlias($this->compilePath)); - $this->smarty->setCacheDir(Yii::getAlias($this->cachePath)); - - $this->smarty->registerPlugin('function', 'path', array($this, 'smarty_function_path')); - } - - /** - * Smarty template function to get a path for using in links - * - * Usage is the following: - * - * {path route='blog/view' alias=$post.alias user=$user.id} - * - * where route is Yii route and the rest of parameters are passed as is. - * - * @param $params - * @param \Smarty_Internal_Template $template - * - * @return string - */ - public function smarty_function_path($params, \Smarty_Internal_Template $template) - { - if (!isset($params['route'])) { - trigger_error("path: missing 'route' parameter"); - } - - array_unshift($params, $params['route']) ; - unset($params['route']); - - return Html::url($params); - } - - /** - * Renders a view file. - * - * This method is invoked by [[View]] whenever it tries to render a view. - * Child classes must implement this method to render the given view file. - * - * @param View $view the view object used for rendering the file. - * @param string $file the view file. - * @param array $params the parameters to be passed to the view file. - * - * @return string the rendering result - */ - public function render($view, $file, $params) - { - $ext = pathinfo($file, PATHINFO_EXTENSION); - /** @var \Smarty_Internal_Template $template */ - $template = $this->smarty->createTemplate($file, null, null, $params, true); - - $template->assign('app', \Yii::$app); - $template->assign('this', $view); - - return $template->fetch(); - } -} diff --git a/framework/yii/renderers/TwigViewRenderer.php b/framework/yii/renderers/TwigViewRenderer.php deleted file mode 100644 index de561d3..0000000 --- a/framework/yii/renderers/TwigViewRenderer.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @since 2.0 - */ -class TwigViewRenderer extends ViewRenderer -{ - /** - * @var string the directory or path alias pointing to where Twig cache will be stored. - */ - public $cachePath = '@app/runtime/Twig/cache'; - - /** - * @var array Twig options - * @see http://twig.sensiolabs.org/doc/api.html#environment-options - */ - public $options = array(); - - /** - * @var \Twig_Environment - */ - public $twig; - - public function init() - { - $loader = new \Twig_Loader_String(); - - $this->twig = new \Twig_Environment($loader, array_merge(array( - 'cache' => Yii::getAlias($this->cachePath), - ), $this->options)); - - $this->twig->addFunction('path', new \Twig_Function_Function(function($path, $args = array()){ - return Html::url(array_merge(array($path), $args)); - })); - - $this->twig->addGlobal('app', \Yii::$app); - } - - /** - * Renders a view file. - * - * This method is invoked by [[View]] whenever it tries to render a view. - * Child classes must implement this method to render the given view file. - * - * @param View $view the view object used for rendering the file. - * @param string $file the view file. - * @param array $params the parameters to be passed to the view file. - * - * @return string the rendering result - */ - public function render($view, $file, $params) - { - $this->twig->addGlobal('this', $view); - return $this->twig->render(file_get_contents($file), $params); - } -} From e5dfce19c6b4e5017313687a8f6f7a387bee1f04 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 24 May 2013 15:22:04 +0400 Subject: [PATCH 14/16] Reorganized Twig and Smarty dependencies --- extensions/smarty/composer.json | 3 ++- extensions/twig/composer.json | 3 ++- framework/composer.json | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/smarty/composer.json b/extensions/smarty/composer.json index 3a74f41..b1e1681 100644 --- a/extensions/smarty/composer.json +++ b/extensions/smarty/composer.json @@ -19,7 +19,8 @@ ], "minimum-stability": "dev", "require": { - "yiisoft/yii2": "*" + "yiisoft/yii2": "*", + "smarty/smarty": "v3.1.13" }, "autoload": { "psr-0": { "yii\\smarty": "" } diff --git a/extensions/twig/composer.json b/extensions/twig/composer.json index 624f8bd..0ff7437 100644 --- a/extensions/twig/composer.json +++ b/extensions/twig/composer.json @@ -19,7 +19,8 @@ ], "minimum-stability": "dev", "require": { - "yiisoft/yii2": "*" + "yiisoft/yii2": "*", + "twig/twig": "v1.13.0" }, "autoload": { "psr-0": { "yii\\twig": "" } diff --git a/framework/composer.json b/framework/composer.json index 2f0e85f..31e31ed 100644 --- a/framework/composer.json +++ b/framework/composer.json @@ -73,8 +73,6 @@ }, "suggest": { "michelf/php-markdown": "Required for Markdown helper.", - "twig/twig": "Required for TwigViewRenderer.", - "smarty/smarty": "Required for SmartyViewRenderer.", "ezyang/htmlpurifier": "Required for Purifier helper." } } From 9948aec147fdc55886497ecd7c74d8fdf1dfc407 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 24 May 2013 15:33:07 +0400 Subject: [PATCH 15/16] Removed "yii app" in favor of Composer application templates --- .../yii/console/controllers/AppController.php | 316 --------------------- 1 file changed, 316 deletions(-) delete mode 100644 framework/yii/console/controllers/AppController.php diff --git a/framework/yii/console/controllers/AppController.php b/framework/yii/console/controllers/AppController.php deleted file mode 100644 index 6baf019..0000000 --- a/framework/yii/console/controllers/AppController.php +++ /dev/null @@ -1,316 +0,0 @@ - - * @author Alexander Makarov - * @since 2.0 - */ -class AppController extends Controller -{ - private $_rootPath; - private $_config; - - /** - * @var string custom template path. If specified, templates will be - * searched there additionally to `framework/console/webapp`. - */ - public $templatesPath; - - /** - * @var string application type. If not specified default application - * skeleton will be used. - */ - public $type = 'default'; - - public function init() - { - parent::init(); - - if ($this->templatesPath && !is_dir($this->templatesPath)) { - throw new Exception('--templatesPath "'.$this->templatesPath.'" does not exist or can not be read.'); - } - } - - public function globalOptions() - { - return array('templatesPath', 'type'); - } - - public function actionIndex() - { - $this->forward('help/index', array('-args' => array('app/create'))); - } - - /** - * Generates Yii application at the path specified via appPath parameter. - * - * @param string $path the directory where the new application will be created. - * If the directory does not exist, it will be created. After the application - * is created, please make sure the directory has enough permissions. - * - * @throws \yii\base\Exception if path specified is not valid - * @return integer the exit status - */ - public function actionCreate($path) - { - $path = strtr($path, '/\\', DIRECTORY_SEPARATOR); - if (strpos($path, DIRECTORY_SEPARATOR) === false) { - $path = '.'.DIRECTORY_SEPARATOR.$path; - } - $dir = rtrim(realpath(dirname($path)), '\\/'); - if ($dir === false || !is_dir($dir)) { - throw new Exception("The directory '$path' is not valid. Please make sure the parent directory exists."); - } - - if (basename($path) === '.') { - $this->_rootPath = $path = $dir; - } else { - $this->_rootPath = $path = $dir.DIRECTORY_SEPARATOR.basename($path); - } - - if ($this->confirm("Create \"$this->type\" application under '$path'?")) { - $sourceDir = $this->getSourceDir(); - $config = $this->getConfig(); - - $list = $this->buildFileList($sourceDir, $path); - - if (is_array($config)) { - foreach ($config as $file => $settings) { - if (isset($settings['handler'])) { - $list[$file]['callback'] = $settings['handler']; - } - } - } - - $this->copyFiles($list); - - if (is_array($config)) { - foreach ($config as $file => $settings) { - if (isset($settings['permissions'])) { - @chmod($path.'/'.$file, $settings['permissions']); - } - } - } - - echo "\nYour application has been created successfully under {$path}.\n"; - } - } - - /** - * @throws \yii\base\Exception if source directory wasn't located - * @return string - */ - protected function getSourceDir() - { - $customSource = realpath($this->templatesPath.'/'.$this->type); - $defaultSource = realpath($this->getDefaultTemplatesPath().'/'.$this->type); - - if ($customSource) { - return $customSource; - } elseif ($defaultSource) { - return $defaultSource; - } else { - throw new Exception('Unable to locate the source directory for "'.$this->type.'".'); - } - } - - /** - * @return string default templates path - */ - protected function getDefaultTemplatesPath() - { - return realpath(__DIR__.'/../webapp'); - } - - /** - * @return array|null template configuration - */ - protected function getConfig() - { - if ($this->_config === null) { - $this->_config = require $this->getDefaultTemplatesPath() . '/config.php'; - if ($this->templatesPath && file_exists($this->templatesPath)) { - $this->_config = array_merge($this->_config, require $this->templatesPath . '/config.php'); - } - } - if (isset($this->_config[$this->type])) { - return $this->_config[$this->type]; - } - } - - /** - * @param string $source path to source file - * @param string $pathTo path to file we want to get relative path for - * @param string $varName variable name w/o $ to replace value with relative path for - * - * @return string target file contents - */ - public function replaceRelativePath($source, $pathTo, $varName) - { - $content = file_get_contents($source); - $relativeFile = str_replace($this->getSourceDir(), '', $source); - - $relativePath = $this->getRelativePath($pathTo, $this->_rootPath.$relativeFile); - $relativePath = str_replace('\\', '\\\\', $relativePath); - - return preg_replace('/\$'.$varName.'\s*=(.*?);/', "\$".$varName."=$relativePath;", $content); - } - - /** - * @param string $path1 absolute path - * @param string $path2 absolute path - * - * @return string relative path - */ - protected function getRelativePath($path1, $path2) - { - $segs1 = explode(DIRECTORY_SEPARATOR, $path1); - $segs2 = explode(DIRECTORY_SEPARATOR, $path2); - $n1 = count($segs1); - $n2 = count($segs2); - - for ($i = 0; $i < $n1 && $i < $n2; ++$i) { - if ($segs1[$i] !== $segs2[$i]) { - break; - } - } - - if ($i === 0) { - return "'" . $path1 . "'"; - } - $up = ''; - for ($j = $i; $j < $n2 - 1; ++$j) { - $up .= '/..'; - } - for(; $i < $n1 - 1; ++$i) { - $up .= '/' . $segs1[$i]; - } - - return '__DIR__.\'' . $up . '/' . basename($path1) . '\''; - } - - - /** - * Copies a list of files from one place to another. - * @param array $fileList the list of files to be copied (name => spec). - * The array keys are names displayed during the copy process, and array values are specifications - * for files to be copied. Each array value must be an array of the following structure: - *
    - *
  • source: required, the full path of the file/directory to be copied from
  • - *
  • target: required, the full path of the file/directory to be copied to
  • - *
  • callback: optional, the callback to be invoked when copying a file. The callback function - * should be declared as follows: - *
    -	 *   function foo($source, $params)
    -	 *   
    - * where $source parameter is the source file path, and the content returned - * by the function will be saved into the target file.
  • - *
  • params: optional, the parameters to be passed to the callback
  • - *
- * @see buildFileList - */ - protected function copyFiles($fileList) - { - $overwriteAll = false; - foreach ($fileList as $name => $file) { - $source = strtr($file['source'], '/\\', DIRECTORY_SEPARATOR); - $target = strtr($file['target'], '/\\', DIRECTORY_SEPARATOR); - $callback = isset($file['callback']) ? $file['callback'] : null; - $params = isset($file['params']) ? $file['params'] : null; - - if (is_dir($source)) { - if (!is_dir($target)) { - mkdir($target, 0777, true); - } - continue; - } - - if ($callback !== null) { - $content = call_user_func($callback, $source, $params); - } else { - $content = file_get_contents($source); - } - if (is_file($target)) { - if ($content === file_get_contents($target)) { - echo " unchanged $name\n"; - continue; - } - if ($overwriteAll) { - echo " overwrite $name\n"; - } - else { - echo " exist $name\n"; - echo " ...overwrite? [Yes|No|All|Quit] "; - $answer = trim(fgets(STDIN)); - if (!strncasecmp($answer, 'q', 1)) { - return; - } elseif (!strncasecmp($answer, 'y', 1)) { - echo " overwrite $name\n"; - } elseif (!strncasecmp($answer, 'a', 1)) { - echo " overwrite $name\n"; - $overwriteAll = true; - } else { - echo " skip $name\n"; - continue; - } - } - } - else { - if (!is_dir(dirname($target))) { - mkdir(dirname($target), 0777, true); - } - echo " generate $name\n"; - } - file_put_contents($target, $content); - } - } - - /** - * Builds the file list of a directory. - * This method traverses through the specified directory and builds - * a list of files and subdirectories that the directory contains. - * The result of this function can be passed to {@link copyFiles}. - * @param string $sourceDir the source directory - * @param string $targetDir the target directory - * @param string $baseDir base directory - * @param array $ignoreFiles list of the names of files that should - * be ignored in list building process. - * @param array $renameMap hash array of file names that should be - * renamed. Example value: array('1.old.txt' => '2.new.txt'). - * @return array the file list (see {@link copyFiles}) - */ - protected function buildFileList($sourceDir, $targetDir, $baseDir='', $ignoreFiles=array(), $renameMap=array()) - { - $list = array(); - $handle = opendir($sourceDir); - while (($file = readdir($handle)) !== false) { - if (in_array($file, array('.', '..', '.svn', '.gitignore', '.hgignore')) || in_array($file, $ignoreFiles)) { - continue; - } - $sourcePath = $sourceDir.DIRECTORY_SEPARATOR.$file; - $targetPath = $targetDir.DIRECTORY_SEPARATOR.strtr($file, $renameMap); - $name = $baseDir === '' ? $file : $baseDir.'/'.$file; - $list[$name] = array( - 'source' => $sourcePath, - 'target' => $targetPath, - ); - if (is_dir($sourcePath)) { - $list = array_merge($list, self::buildFileList($sourcePath, $targetPath, $name, $ignoreFiles, $renameMap)); - } - } - closedir($handle); - return $list; - } -} From 9be83188f796a650f372bd9c5aeeb19ef7a3ceed Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Fri, 24 May 2013 16:53:18 +0400 Subject: [PATCH 16/16] jQuery UI dialog widget --- framework/yii/jui/Dialog.php | 53 ++++++++++++++++++++++++++++++++++++++++++++ framework/yii/jui/assets.php | 4 ++-- 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 framework/yii/jui/Dialog.php diff --git a/framework/yii/jui/Dialog.php b/framework/yii/jui/Dialog.php new file mode 100644 index 0000000..921758e --- /dev/null +++ b/framework/yii/jui/Dialog.php @@ -0,0 +1,53 @@ + array( + * 'modal' => true, + * ), + * )); + * + * echo 'Dialog contents here...'; + * + * Dialog::end(); + * ``` + * + * @see http://api.jqueryui.com/dialog/ + * @author Alexander Kochetov + * @since 2.0 + */ +class Dialog extends Widget +{ + /** + * Initializes the widget. + */ + public function init() + { + parent::init(); + echo Html::beginTag('div', $this->options) . "\n"; + } + + /** + * Renders the widget. + */ + public function run() + { + echo Html::endTag('div') . "\n"; + $this->registerWidget('dialog'); + } +} diff --git a/framework/yii/jui/assets.php b/framework/yii/jui/assets.php index 285026c..d2d8f7c 100644 --- a/framework/yii/jui/assets.php +++ b/framework/yii/jui/assets.php @@ -559,7 +559,7 @@ return array( 'js' => array( 'jquery.ui.dialog.js', ), - 'depends' => array('yii/jui/core', 'yii/jui/widget', 'yii/jui/button', 'yii/jui/draggable', 'yii/jui/mouse', 'yii/jui/position', 'yii/jui/resizeable', 'yii/jui/effect/all'), + 'depends' => array('yii/jui/core', 'yii/jui/widget', 'yii/jui/button', 'yii/jui/draggable', 'yii/jui/mouse', 'yii/jui/position', 'yii/jui/resizable', 'yii/jui/effect/all'), ), 'yii/jui/draggable' => array( 'sourcePath' => __DIR__ . '/assets', @@ -803,7 +803,7 @@ return array( 'css' => array( 'themes/base/jquery.ui.dialog.css', ), - 'depends' => array('yii/jui/theme/base/core', 'yii/jui/theme/base/button', 'yii/jui/theme/base/resizeable'), + 'depends' => array('yii/jui/theme/base/core', 'yii/jui/theme/base/button', 'yii/jui/theme/base/resizable'), ), 'yii/jui/theme/base/menu' => array( 'sourcePath' => __DIR__ . '/assets',