Commits

Bogdan Savluk committed 0b76329

FormGenerator - inputWidget config now is optional, StaticPage editor - hide content fieldset if it is empty, shrink left sidebar to span2 on all layouts,

Comments (0)

Files changed (13)

 syntax: glob
 testapp/assets
 .git
-testapp/protected/modules/admin/extensions/elFinder2/vendors/elFinder
-testapp/protected/modules/admin/extensions/elFinder/vendors/elFinder
 testapp/protected/runtime
 testapp/uploads
 .idea
-testapp/protected/modules/admin/extensions/galleryManager/vendors/jQuery-File-Upload
 testapp/gallery
-testapp/protected/extensions/elFinder2/vendors
-testapp/protected/extensions/elFinder/vendors
 testapp/protected/config/main.php

testapp/protected/modules/admin/components/StaticPageEditor.php

         }
         $form = $this->getController()->beginWidget('BHorizontalForm', array());
 
+        $formConfig = array(
+            array(
+                'type' => 'fieldset',
+                'legend' => 'Параметры',
+                'config' => array(
+                    array(
+                        'type' => 'simpleInput',
+                        'name' => 'textField',
+                        'attribute' => 'name',
+                        'options' => array('class' => 'input-xxlarge'),
+                    ),
+                    //  array(
+                    //      'type' => 'simpleInput',
+                    //      'name' => 'textField',
+                    //      'attribute' => 'link',
+                    //      'options' => array('class' => 'input-xxlarge'),
+                    //  ),
+                ),
+            ),
+        );
+        if (!empty($this->form))
+            $formConfig[] = array(
+                'type' => 'fieldset',
+                'legend' => 'Содержимое',
+                'config' => array(
+                    array(
+                        'type' => 'widget',
+                        'class' => 'FormGenerator',
+                        'config' => array(
+                            'form' => $form,
+                            'model' => $dataModel,
+                            'config' => $this->form,
+                        ),
+                    )
+                ),
+            );
+        $formConfig[] = array(
+            'type' => 'fieldset',
+            'legend' => 'Параметры для поисковой оптимизации',
+            'config' => array(
+                array(
+                    'type' => 'simpleInput',
+                    'name' => 'textField',
+                    'attribute' => 'title',
+                    'options' => array('class' => 'input-xxlarge'),
+                ),
+                array(
+                    'type' => 'simpleInput',
+                    'name' => 'textArea',
+                    'attribute' => 'description',
+                    'options' => array('class' => 'input-xxlarge'),
+                ),
+                array(
+                    'type' => 'simpleInput',
+                    'name' => 'textArea',
+                    'attribute' => 'keywords',
+                    'options' => array('class' => 'input-xxlarge'),
+                ),
+
+                //'last_change',
+                //'priority',
+                //'change_freq',
+            ),
+        );
         $this->getController()->widget('FormGenerator', array(
             'form' => $form,
             'model' => $model,
-            'config' => array(
-                array(
-                    'type' => 'fieldset',
-                    'legend' => 'Параметры',
-                    'config' => array(
-                        array(
-                            'type' => 'simpleInput',
-                            'name' => 'textField',
-                            'attribute' => 'name',
-                            'options' => array('class' => 'input-xxlarge'),
-                        ),
-                        //  array(
-                        //      'type' => 'simpleInput',
-                        //      'name' => 'textField',
-                        //      'attribute' => 'link',
-                        //      'options' => array('class' => 'input-xxlarge'),
-                        //  ),
-                    ),
-                ),
-                array(
-                    'type' => 'fieldset',
-                    'legend' => 'Содержимое',
-                    'config' => array(
-                        array(
-                            'type' => 'widget',
-                            'class' => 'FormGenerator',
-                            'config' => array(
-                                'form' => $form,
-                                'model' => $dataModel,
-                                'config' => $this->form,
-                            ),
-                        )
-                    ),
-                ),
-                array(
-                    'type' => 'fieldset',
-                    'legend' => 'Параметры для поисковой оптимизации',
-                    'config' => array(
-                        array(
-                            'type' => 'simpleInput',
-                            'name' => 'textField',
-                            'attribute' => 'title',
-                            'options' => array('class' => 'input-xxlarge'),
-                        ),
-                        array(
-                            'type' => 'simpleInput',
-                            'name' => 'textArea',
-                            'attribute' => 'description',
-                            'options' => array('class' => 'input-xxlarge'),
-                        ),
-                        array(
-                            'type' => 'simpleInput',
-                            'name' => 'textArea',
-                            'attribute' => 'keywords',
-                            'options' => array('class' => 'input-xxlarge'),
-                        ),
-
-                        //'last_change',
-                        //'priority',
-                        //'change_freq',
-                    ),
-                ),
-            ),
+            'config' => $formConfig,
         ));
 
         echo '<div class="form-actions"><button type="submit" class="btn btn-large btn-primary">',

testapp/protected/modules/admin/components/widgets/FormGenerator.php

                     break;
 
                 case 'inputWidget':
-                    $config = $item['config'];
+                    $config = isset($item['config'])?$item['config']:array();
                     if (isset($this->suffix)) {
                         $attr = '[' . $this->suffix . ']' . $item['attribute'];
                     } else {

testapp/protected/modules/admin/config/mainMenu.php

         'items' => array(
             array(
                 'label' => 'Статические страницы',
-                'url' => array('/admin/service/web'),
+                'url' => array('/admin/staticPage/index'),
                 'activateOn' => array(
-                    array('route' => '/admin\/service/',),
+                    array('route' => '/admin\/staticPage/',),
                 ),
             ),
             array(
                 'activateOn' => array(
                     array('route' => '/admin\/params\/index/',),
                 ),
-                'roles' => 'developer'
             ),
         ),
     ),
             array(
                 'label' => 'Gallery Manager',
                 'url' => array('/admin/test/gallery'),
+                'roles' => 'developer',
             ),
             array(
                 'label' => 'Widgets',
                 'url' => array('/admin/test/widgets'),
+                'roles' => 'developer',
             ),
             array(
                 'label' => 'Data',
                 'url' => array('/admin/test/index'),
+                'roles' => 'developer',
             ),
         )
     )

testapp/protected/modules/admin/controllers/DefaultController.php

 
     public function actionIndex()
     {
-//        $this->layout = 'base';
-//        $this->render('index');
-        $this->redirect(array('/admin/service/web'));
+        // $this->layout = 'base';
+        // $this->render('index');
+        $this->redirect(array('/admin/staticPage/web'));
     }
 
     public function actionChangePassword()

testapp/protected/modules/admin/controllers/ServiceController.php

-<?php
-/**
- * Created by JetBrains PhpStorm.
- * User: z_bodya
- * Date: 4/5/12
- * Time: 4:59 PM
- * To change this template use File | Settings | File Templates.
- */
-class ServiceController extends AdminController
-{
-    public function actions()
-    {
-        $model = array(
-            'schema' => array(
-                'content' => array(
-                    'label' => 'Контент',
-                    'default' => null,
-                ),
-            ),
-            'rules' => array(),
-        );
-        $tinyFull = array(
-            'htmlOptions' => array(
-                'rows' => 6,
-                'cols' => 60,
-            ),
-        );
-        $web = array(
-            'class' => 'StaticPageEditor',
-
-            'submitLabel' => 'Сохранить',
-            'section' => 'service',
-            'key' => 'web',
-            'view' => '/static_editor',
-            'model' => $model,
-            'form' => array(
-                array(
-                    'type' => 'inputWidget',
-                    'class' => 'ext.tinymce.TinyMce',
-                    'attribute' => 'content',
-                    'config' => $tinyFull,
-                ),
-            ),
-        );
-        $mobile = $web;
-        $mobile['key'] = 'mobile';
-        $promo = $web;
-        $promo['key'] = 'promo';
-        $style = $web;
-        $style['key'] = 'style';
-        return array(
-            'web' => $web,
-            'mobile' => $mobile,
-            'promo' => $promo,
-            'style' => $style,
-        );
-    }
-
-    public function getSideMenu()
-    {
-        $res = array(
-            array(
-                'label' => 'Страницы',
-                'items' => array(
-                    array(
-                        'label' => 'Разработка веб-сайтов',
-                        'url' => array('/admin/service/web'),
-                        'icon' => 'icon-file',
-                        'active' => '/\/service\/web/',
-                    ),
-                    array(
-                        'label' => 'Разработка мобильных приложений',
-                        'url' => array('/admin/service/mobile'),
-                        'icon' => 'icon-file',
-                        'active' => '/\/service\/mobile/',
-                    ),
-                    array(
-                        'label' => 'Оптимизация, продвижение и реклама',
-                        'url' => array('/admin/service/promo'),
-                        'icon' => 'icon-file',
-                        'active' => '/\/service\/promo/',
-                    ),
-                    array(
-                        'label' => 'Разработка фирменного стиля',
-                        'url' => array('/admin/service/style'),
-                        'icon' => 'icon-file',
-                        'active' => '/\/service\/style/',
-                    ),
-                ),
-            ),
-        );
-        return $res;
-    }
-}
-

testapp/protected/modules/admin/controllers/StaticPageController.php

+<?php
+/**
+ * Created by JetBrains PhpStorm.
+ * User: z_bodya
+ * Date: 4/5/12
+ * Time: 4:59 PM
+ * To change this template use File | Settings | File Templates.
+ */
+class StaticPageController extends AdminController
+{
+    public function actions()
+    {
+        $model = array(
+            'schema' => array(
+                'content' => array(
+                    'label' => 'Контент',
+                    'default' => null,
+                ),
+            ),
+            'rules' => array(),
+        );
+        $tinyFull = array(
+            'htmlOptions' => array(
+                'rows' => 6,
+                'cols' => 60,
+            ),
+        );
+        $web = array(
+            'class' => 'StaticPageEditor',
+
+            'submitLabel' => 'Сохранить',
+            'section' => 'service',
+            'key' => 'web',
+            'view' => '/static_editor',
+            'model' => $model,
+            'form' => array(
+                array(
+                    'type' => 'inputWidget',
+                    'class' => 'ext.tinymce.TinyMce',
+                    'attribute' => 'content',
+                    'config' => $tinyFull,
+                ),
+            ),
+        );
+        $mobile = $web;
+        $mobile['key'] = 'mobile';
+        $promo = $web;
+        $promo['key'] = 'promo';
+        $style = $web;
+        $style['key'] = 'style';
+        return array(
+            'web' => $web,
+            'mobile' => $mobile,
+            'promo' => $promo,
+            'style' => $style,
+        );
+    }
+
+    public function getSideMenu()
+    {
+        $res = array(
+            array(
+                'label' => 'Страницы',
+                'items' => array(
+                    array(
+                        'label' => 'Разработка веб-сайтов',
+                        'url' => array('/admin/service/web'),
+                        'icon' => 'icon-file',
+                        'active' => '/\/service\/web/',
+                    ),
+                    array(
+                        'label' => 'Разработка мобильных приложений',
+                        'url' => array('/admin/service/mobile'),
+                        'icon' => 'icon-file',
+                        'active' => '/\/service\/mobile/',
+                    ),
+                    array(
+                        'label' => 'Оптимизация, продвижение и реклама',
+                        'url' => array('/admin/service/promo'),
+                        'icon' => 'icon-file',
+                        'active' => '/\/service\/promo/',
+                    ),
+                    array(
+                        'label' => 'Разработка фирменного стиля',
+                        'url' => array('/admin/service/style'),
+                        'icon' => 'icon-file',
+                        'active' => '/\/service\/style/',
+                    ),
+                ),
+            ),
+        );
+        return $res;
+    }
+}
+

testapp/protected/modules/admin/controllers/TestController.php

 
     public function actionGallery()
     {
-        $gallery = Gallery::model()->findByPk(2);
+        $gallery = Gallery::model()->findByPk(1);
         if (empty($gallery)) {
             $gallery = new Gallery();
             $gallery->name = true;

testapp/protected/modules/admin/gii/bcrud/templates/default/update.php

 
 
 <h1>Редактирование <?php echo $this->modelClass." <?php echo \$model->{$this->tableSchema->primaryKey}; ?>"; ?></h1>
+<br/>
 
 <?php echo "<?php echo \$this->renderPartial('_form', array('model'=>\$model)); ?>"; ?>

testapp/protected/modules/admin/views/layouts/crud_layout.php

 <?php $this->beginContent('/layouts/base'); ?>
 <div class="container">
     <div class="row">
-        <div class="span3">
+        <div class="span2">
             <div class="">
                 <?php
+                $items = array(
+                    array(
+                        'label' => 'Действия',
+                        'items' => $this->actionsMenu
+                    )
+                );
+                if (isset($this->pagesMenu))
+                    $items[] = array(
+                        'label' => 'Страницы',
+                        'items' => $this->pagesMenu
+                    );
                 $this->widget('BSideMenu', array(
-                    'items' => array(
-                        array(
-                            'label' => 'Действия',
-                            'items' => $this->actionsMenu
-                        )
-                    )
+                    'items' => $items,
                 ));?>
             </div>
         </div>
-        <div class="span9">
+        <div class="span10">
             <?php echo $content;?>
         </div>
     </div>

testapp/protected/modules/admin/views/static_editor.php

 ?>
 <div class="container">
     <div class="row">
-        <div class="span3">
+        <div class="span2">
             <div class="">
                 <?php $this->widget('BSideMenu', array('items' => $this->sideMenu));?>
             </div>
         </div>
-        <div class="span9">
+        <div class="span10">
             <?php echo $content;?>
         </div>
     </div>

testapp/protected/modules/admin/views/user/layout.php

 <div class="container">
     <div class="row">
-        <div class="span3">
+        <div class="span2">
             <!--            <br/>-->
             <!--            <br/>-->
 
                 ?>
             </div>
         </div>
-        <div class="span9">
+        <div class="span10">
             <?php echo $content; ?>
         </div>
 
Binary file modified.