From 03c2c1e0f114228b8fb175c368cc206357d33e39 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Thu, 23 May 2013 18:33:43 +0400 Subject: [PATCH 1/5] YiiBase jQuery UI alias --- framework/yii/YiiBase.php | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/yii/YiiBase.php b/framework/yii/YiiBase.php index df5f631..4fe0e77 100644 --- a/framework/yii/YiiBase.php +++ b/framework/yii/YiiBase.php @@ -616,6 +616,7 @@ class YiiBase YiiBase::$aliases = array( '@yii' => array( '@yii/bootstrap' => __DIR__ . '/bootstrap', + '@yii/jui' => __DIR__ . '/jui', '@yii' => __DIR__, ), ); From 9d3fe87230c26803c88f3d730924acb50c084a81 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Thu, 23 May 2013 18:49:00 +0400 Subject: [PATCH 2/5] assets.php css dependency fixes --- framework/yii/jui/assets.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/yii/jui/assets.php b/framework/yii/jui/assets.php index 1d27cee..c292050 100644 --- a/framework/yii/jui/assets.php +++ b/framework/yii/jui/assets.php @@ -775,7 +775,7 @@ return array( 'css' => array( 'themes/base/jquery.ui.autocomplete.css', ), - 'depends' => array('yii/jui/theme/base/core'), + 'depends' => array('yii/jui/theme/base/core', 'yii/jui/theme/base/menu'), ), 'yii/jui/theme/base/button' => array( 'sourcePath' => __DIR__ . '/assets', @@ -796,7 +796,7 @@ return array( 'css' => array( 'themes/base/jquery.ui.dialog.css', ), - 'depends' => array('yii/jui/theme/base/core'), + 'depends' => array('yii/jui/theme/base/core', 'yii/jui/theme/base/button', 'yii/jui/theme/base/resizeable'), ), 'yii/jui/theme/base/menu' => array( 'sourcePath' => __DIR__ . '/assets', @@ -838,7 +838,7 @@ return array( 'css' => array( 'themes/base/jquery.ui.spinner.css', ), - 'depends' => array('yii/jui/theme/base/core'), + 'depends' => array('yii/jui/theme/base/core', 'yii/jui/theme/base/button'), ), 'yii/jui/theme/base/tabs' => array( 'sourcePath' => __DIR__ . '/assets', From 792d548cd07f43d060f8a7e474264367f56169b8 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Thu, 23 May 2013 19:28:34 +0400 Subject: [PATCH 3/5] jQuery Accordeon widget --- framework/yii/jui/Accordion.php | 107 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 framework/yii/jui/Accordion.php diff --git a/framework/yii/jui/Accordion.php b/framework/yii/jui/Accordion.php new file mode 100644 index 0000000..0deab15 --- /dev/null +++ b/framework/yii/jui/Accordion.php @@ -0,0 +1,107 @@ + array( + * 'Section 1' => array( + * '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...', + * 'headerOptions' => array(...), + * ), + * ), + * )); + * ``` + * + * @see http://api.jqueryui.com/accordion/ + * @author Alexander Kochetov + * @since 2.0 + */ +class Accordion extends Widget +{ + /** + * @var array list of groups in the collapse widget. Each array element represents a single + * group with the following structure: + * + * ```php + * // item key is the actual group header + * 'Section' => array( + * // required, the content (HTML) of the group + * 'content' => 'Mauris mauris ante, blandit et, ultrices a, suscipit eget...', + * // optional the HTML attributes of the content group + * 'contentOptions'=> array(...), + * // optional the HTML attributes of the header group + * 'headerOptions'=> array(...), + * ) + * ``` + */ + public $items = array(); + + + /** + * Renders the widget. + */ + public function run() + { + echo Html::beginTag('div', $this->options) . "\n"; + echo $this->renderItems() . "\n"; + echo Html::endTag('div') . "\n"; + $this->registerWidget('accordion'); + } + + /** + * Renders collapsible items as specified on [[items]]. + * @return string the rendering result. + */ + public function renderItems() + { + $items = array(); + foreach ($this->items as $header => $item) { + $items[] = $this->renderItem($header, $item); + } + + return implode("\n", $items); + } + + /** + * Renders a single collapsible item group. + * @param string $header a label of the item group [[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."); + } + + $group = array(); + $headerOptions = ArrayHelper::getValue($item, 'headerOptions', array()); + $group[] = Html::tag('h3', $header, $headerOptions); + $group[] = Html::tag('div', $content, $contentOptions); + + return implode("\n", $group); + } +} From aa3bfa5a8afa42068cbf4b3fdf99087bf7d89cca Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Thu, 23 May 2013 19:32:40 +0400 Subject: [PATCH 4/5] Comments fixes --- framework/yii/jui/Accordion.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/framework/yii/jui/Accordion.php b/framework/yii/jui/Accordion.php index 0deab15..df9ba20 100644 --- a/framework/yii/jui/Accordion.php +++ b/framework/yii/jui/Accordion.php @@ -38,17 +38,17 @@ use yii\helpers\Html; class Accordion extends Widget { /** - * @var array list of groups in the collapse widget. Each array element represents a single - * group with the following structure: + * @var array list of sections in the accordion widget. Each array element represents a single + * section with the following structure: * * ```php - * // item key is the actual group header + * // item key is the actual section header * 'Section' => array( - * // required, the content (HTML) of the group + * // required, the content (HTML) of the section * 'content' => 'Mauris mauris ante, blandit et, ultrices a, suscipit eget...', - * // optional the HTML attributes of the content group + * // optional the HTML attributes of the content section * 'contentOptions'=> array(...), - * // optional the HTML attributes of the header group + * // optional the HTML attributes of the header section * 'headerOptions'=> array(...), * ) * ``` @@ -82,8 +82,8 @@ class Accordion extends Widget } /** - * Renders a single collapsible item group. - * @param string $header a label of the item group [[items]]. + * 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. From caf9948c5428025ab9a2914930ebc67f763c4fdd Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 23 May 2013 19:51:47 +0400 Subject: [PATCH 5/5] fixes #377 --- framework/yii/console/controllers/HelpController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/yii/console/controllers/HelpController.php b/framework/yii/console/controllers/HelpController.php index c40ea66..a729f78 100644 --- a/framework/yii/console/controllers/HelpController.php +++ b/framework/yii/console/controllers/HelpController.php @@ -13,7 +13,7 @@ use yii\base\InlineAction; use yii\console\Controller; use yii\console\Exception; use yii\console\Request; -use yii\helpers\StringHelper; +use yii\helpers\Inflector; /** * This command provides help information about console commands. @@ -96,7 +96,7 @@ class HelpController extends Controller foreach ($class->getMethods() as $method) { $name = $method->getName(); if ($method->isPublic() && !$method->isStatic() && strpos($name, 'action') === 0 && $name !== 'actions') { - $actions[] = StringHelper::camel2id(substr($name, 6)); + $actions[] = Inflector::camel2id(substr($name, 6)); } } sort($actions);