Assembla home | Assembla project page
 

Changeset 67

Show
Ignore:
Timestamp:
06/14/07 16:48:54 (1 year ago)
Author:
digitalspaghetti
Message:

Improved some forms and methods. Started testing AJAX forms

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branch/controllers/galleries_controller.php

    r63 r67  
    114114                        $this->data = $this->Gallery->read(null, $id); 
    115115                } 
    116                 $images = $this->Gallery->Image->generateList(); 
     116                $images = $this->Gallery->Image->generateList(null,null,null, '{n}.Image.id', '{n}.Image.alt'); 
    117117                $subjects = $this->Gallery->Subject->generateList(); 
    118118                $this->set(compact('images','subjects')); 
  • branch/controllers/menus_controller.php

    r60 r67  
    11<?php 
    2 class MenusController extends AppController { 
     2class menusController extends AppController { 
    33 
    4         var $name = 'Menus'; 
     4        var $name = 'menus'; 
     5        var $helpers = array('Html', 'Form' ); 
     6         
    57        var $uses = array('Menu','Group'); 
    68 
     
    1820  } 
    1921 
    20         function view($id = null) { 
     22        function admin_index() { 
     23                $this->Menu->recursive = 0; 
     24                $this->set('menus', $this->paginate()); 
     25        } 
     26 
     27        function admin_view($id = null) { 
    2128                if(!$id) { 
    2229                        $this->Session->setFlash('Invalid Menu.'); 
     
    2633        } 
    2734 
    28         function add() { 
     35        function admin_add() { 
     36                 
     37                $sections = $this->Menu->Section->generateList(); 
     38                $this->set(compact('sections')); 
     39                 
     40                $access_levels = $this->Group->generateList(null,null,null,'{n}.Group.level', '{n}.Group.name'); 
     41                $this->set(compact('access_levels')); 
     42                 
     43                $data = $this->Menu->findAllThreaded(array(null, null, 'Menu.position')); 
     44                $this->set(compact('data')); 
     45                 
    2946                if(!empty($this->data)) { 
    3047                        $this->cleanUpFields(); 
     
    3754                        } 
    3855                } 
    39                 $parents = $this->Menu->Parent->generateList(); 
    40                 $sections = $this->Menu->Section->generateList(); 
    41                 $this->set(compact('parents', 'sections')); 
    4256        } 
    4357 
    44         function edit($id = null) { 
     58        function admin_edit($id = null) { 
     59                 
     60                $sections = $this->Menu->Section->generateList(); 
     61                $this->set(compact('sections')); 
     62                 
     63                $access_levels = $this->Group->generateList(null,null,null,'{n}.Group.level', '{n}.Group.name'); 
     64                $this->set(compact('access_levels')); 
     65 
     66                $data = $this->Menu->findAllThreaded(array(null, null, 'Menu.position')); 
     67                $this->set(compact('data')); 
     68                 
    4569                if(!$id && empty($this->data)) { 
    4670                        $this->Session->setFlash('Invalid Menu'); 
     
    5983                        $this->data = $this->Menu->read(null, $id); 
    6084                } 
    61                 $parents = $this->Menu->Parent->generateList(); 
    62                 $sections = $this->Menu->Section->generateList(); 
    63                 $this->set(compact('parents','sections')); 
    64         } 
    65  
    66         function delete($id = null) { 
    67                 if(!$id) { 
    68                         $this->Session->setFlash('Invalid id for Menu'); 
    69                         $this->redirect(array('action'=>'index'), null, true); 
    70                 } 
    71                 if($this->Menu->del($id)) { 
    72                         $this->Session->setFlash('Menu #'.$id.' deleted'); 
    73                         $this->redirect(array('action'=>'index'), null, true); 
    74                 } 
    75         } 
    76  
    77  
    78         function admin_index() { 
    79                 $this->Menu->recursive = 0; 
    80                 $this->set('menus', $this->paginate()); 
    81         } 
    82  
    83         function admin_view($id = null) { 
    84                 if(!$id) { 
    85                         $this->Session->setFlash('Invalid Menu.'); 
    86                         $this->redirect(array('action'=>'index'), null, true); 
    87                 } 
    88                 $this->set('menu', $this->Menu->read(null, $id)); 
    89         } 
    90  
    91         function admin_add() { 
    92                 if(!empty($this->data)) { 
    93                         $this->cleanUpFields(); 
    94                         $this->Menu->create(); 
    95                         if($this->Menu->save($this->data)) { 
    96                                 $this->Session->setFlash('The Menu has been saved'); 
    97                                 $this->redirect(array('action'=>'index'), null, true); 
    98                         } else { 
    99                                 $this->Session->setFlash('The Menu could not be saved. Please, try again.'); 
    100                         } 
    101                 } 
    102                 $parents = $this->Menu->Parent->generateList(); 
    103                 $sections = $this->Menu->Section->generateList(); 
    104                 $this->set(compact('parents', 'sections')); 
    105         } 
    106  
    107         function admin_edit($id = null) { 
    108                 if(!$id && empty($this->data)) { 
    109                         $this->Session->setFlash('Invalid Menu'); 
    110                         $this->redirect(array('action'=>'index'), null, true); 
    111                 } 
    112                 if(!empty($this->data)) { 
    113                         $this->cleanUpFields(); 
    114                         if($this->Menu->save($this->data)) { 
    115                                 $this->Session->setFlash('The Menu saved'); 
    116                                 $this->redirect(array('action'=>'index'), null, true); 
    117                         } else { 
    118                                 $this->Session->setFlash('The Menu could not be saved. Please, try again.'); 
    119                         } 
    120                 } 
    121                 if(empty($this->data)) { 
    122                         $this->data = $this->Menu->read(null, $id); 
    123                 } 
    124                 $parents = $this->Menu->Parent->generateList(); 
    125                 $sections = $this->Menu->Section->generateList(); 
    126                 $this->set(compact('parents','sections')); 
    12785        } 
    12886 
  • branch/controllers/posts_controller.php

    r60 r67  
    111111                        $this->Post->create(); 
    112112                        if($this->Post->save($this->data)) { 
    113                                 $this->Session->setFlash('The Post has been saved'); 
    114                                 $this->redirect(array('action'=>'index'), null, true); 
     113                                //$this->Session->setFlash('The Post has been saved'); 
     114                                //$this->redirect(array('action'=>'index'), null, true); 
    115115                        } else { 
    116116                                $this->Session->setFlash('The Post could not be saved. Please, try again.'); 
  • branch/views/elements/js_include.ctp

    r63 r67  
    11<?php e($javascript->link('jquery'));?> 
    2 <?php e($javascript->link('jamal'));?> 
     2<?php e($javascript->link('jquery.cookie'));?> 
     3<?php e($javascript->link('jquery.form'));?> 
     4<?php e($javascript->link('treeview/jquery.treeview.pack'));?> 
    35<?php e($javascript->link('wymeditor/jquery.wymeditor'));?> 
    46<?php e($javascript->link('wymeditor/plugins/tidy/jquery.wymeditor.tidy'));?> 
  • branch/views/elements/mainnav.ctp

    r57 r67  
    1 <?php e($javascript->link('treeview/jquery.treeview'));?> 
    21<?php $menus = $this->requestAction('/menus/index/1');?> 
    32<div id="mainnav" class="primarynav"> 
  • branch/views/galleries/admin_add.ctp

    r63 r67  
    22<h2>New Gallery</h2> 
    33        <?php echo $form->create('Gallery');?> 
    4                 <?php echo $form->input('title', array('class' => 'required'));?> 
    5                 <?php echo $form->input('primary_image', array('options' => $images, 'class' => 'required'));?> 
    6                 <?php echo $form->input('subject_id', array('class' => 'required', 'options' => $subjects));?> 
    7                 <?php echo $form->input('published', array('class' => 'required'));?> 
    8                 <?php echo $form->input('tags', array('type'=>'text', 'class' => 'required'));?> 
    9                 <?php echo $form->input('Image/Image', array('options' => $images, 'multiple' => 'multiple'));?> 
     4                <fieldset id="main-content"> 
     5                        <legend>Main Content</legend> 
     6                        <?php echo $form->input('title', array('class' => 'required'));?> 
     7                        <?php echo $form->input('primary_image', array('options' => $images, 'class' => 'required'));?> 
     8                        <?php echo $form->input('Image/Image', array('options' => $images, 'multiple' => 'multiple'));?> 
     9                </fieldset> 
     10                 
     11                <fieldset id="meta-content"> 
     12                        <legend>Meta Data</legend> 
     13                        <?php echo $form->input('subject_id', array('class' => 'required', 'options' => $subjects));?> 
     14                        <?php echo $form->input('tags', array('type'=>'text', 'class' => 'required'));?> 
     15                </fieldset> 
     16                 
     17                <fieldset id="publishing-options"> 
     18                        <legend>Publishing Options</legend> 
     19                        <?php echo $form->input('published', array('class' => 'required'));?> 
     20                </fieldset> 
     21                 
    1022                <?php echo $form->submit('Add');?> 
    1123        </form> 
    1224</div> 
    13 <div class="actions"> 
    14         <ul> 
    15                 <li><?php echo $html->link('List Galleries', array('action'=>'index')); ?></li> 
    16                 <li><?php echo $html->link('View Subjects', array('controller'=> 'subjects', 'action'=>'view'));?></li> 
    17                 <li><?php echo $html->link('Add Subjects', array('controller'=> 'subjects', 'action'=>'add')); ?></li> 
    18         </ul> 
    19 </div> 
  • branch/views/galleries/admin_edit.ctp

    r55 r67  
    22<h2>Edit Gallery</h2> 
    33        <?php echo $form->create('Gallery');?> 
    4                 <?php echo $form->input('id');?> 
    5                 <?php echo $form->input('title', array('class' => 'required'));?> 
    6                 <?php echo $form->input('url', array('class' => 'required'));?> 
    7                 <?php echo $form->input('primary_image', array('class' => 'required'));?> 
    8                 <?php echo $form->input('subject_id', array('class' => 'required', 'options' => $subjects));?> 
    9                 <?php echo $form->input('published', array('class' => 'required'));?> 
    10                 <?php echo $form->input('Image/Image', array('options' => $images, 'multiple' => 'multiple'));?> 
     4                <fieldset id="main-content"> 
     5                        <legend>Main Content</legend> 
     6                        <?php echo $form->input('id');?> 
     7                        <?php echo $form->input('title', array('class' => 'required'));?> 
     8                        <?php echo $form->input('primary_image', array('options' => $images, 'class' => 'required'));?> 
     9                        <?php echo $form->input('Image/Image', array('options' => $images, 'multiple' => 'multiple'));?> 
     10                </fieldset> 
     11                 
     12                <fieldset id="meta-content"> 
     13                        <legend>Meta Data</legend> 
     14                        <?php echo $form->input('subject_id', array('class' => 'required', 'options' => $subjects));?> 
     15                        <?php echo $form->input('tags', array('type'=>'text', 'class' => 'required'));?> 
     16                </fieldset> 
     17                 
     18                <fieldset id="publishing-options"> 
     19                        <legend>Publishing Options</legend> 
     20                        <?php echo $form->input('published', array('class' => 'required'));?> 
     21                </fieldset> 
     22                 
    1123                <?php echo $form->submit('Update');?> 
     24                <?php echo $html->link('Delete', array('action'=>'delete', $html->tagValue('Gallery/id')), null, 'Are you sure you want to delete #' . $html->tagValue('Gallery/id')); ?> 
    1225        </form> 
    1326</div> 
    14 <div class="actions"> 
    15         <ul> 
    16                 <li><?php echo $html->link('Delete', array('action'=>'delete', $html->tagValue('Gallery/id')), null, 'Are you sure you want to delete #' . $html->tagValue('Gallery/id')); ?> 
    17                 <li><?php echo $html->link('List Galleries', array('action'=>'index')); ?></li> 
    18                 <li><?php echo $html->link('View Subjects', array('controller'=> 'subjects', 'action'=>'view')); ?></li> 
    19                 <li><?php echo $html->link('Add Subjects', array('controller'=> 'subjects', 'action'=>'add')); ?></li> 
    20         </ul> 
    21 </div> 
  • branch/views/menus/admin_add.ctp

    r55 r67  
    1 <div class="menu"> 
    2 <h2>New Menu</h2> 
    3         <?php echo $form->create('Menu');?> 
    4                 <?php echo $form->input('name', array('class' => 'required'));?> 
    5                 <?php echo $form->input('url', array('class' => 'required'));?> 
    6                 <?php echo $form->input('position', array('class' => 'required'));?> 
    7                 <?php echo $form->input('icon');?> 
    8                 <?php echo $form->input('parent_id', array('class' => 'required', 'options' => $parents));?> 
    9                 <?php echo $form->input('section_id', array('class' => 'required', 'options' => $sections));?> 
    10                 <?php echo $form->input('access_level', array('class' => 'required'));?> 
    11                 <?php echo $form->input('published', array('class' => 'required'));?> 
    12                 <?php echo $form->submit('Add');?> 
    13         </form> 
     1<div id="post"> 
     2        <h2>Add New Menu</h2> 
     3        <?php e($form->create('Menu'));?> 
     4                <fieldset id="post-main"> 
     5                        <legend>Menu Details:</legend> 
     6                        <?php echo $form->input('name');?> 
     7                        <?php echo $form->input('url');?> 
     8                        <?php echo $form->input('position');?> 
     9                        <?php echo $form->input('icon');?> 
     10                        <?php echo $treeMenu->select($data);?> 
     11                        <?php echo $form->input('section_id', array('options' => $sections));?> 
     12                        <?php echo $form->input('access_level', array('options'=>$access_levels));?> 
     13                        <?php echo $form->input('published', array('type'=>'checkbox'));?> 
     14                </fieldset> 
     15                <?php e($form->submit('Save Menu'));?> <?php e($html->link('Cancel', '/admin/menus', array('class'=>'cancel')));?> 
     16        <?php e($form->end());?> 
    1417</div> 
    15 <div class="actions"> 
    16         <ul> 
    17                 <li><?php echo $html->link('List Menuses', array('action'=>'index')); ?></li> 
    18                 <li><?php echo $html->link('View Sections', array('controller'=> 'sections', 'action'=>'view'));?></li> 
    19                 <li><?php echo $html->link('Add Sections', array('controller'=> 'sections', 'action'=>'add')); ?></li> 
    20         </ul> 
    21 </div> 
  • branch/views/menus/admin_edit.ctp

    r55 r67  
    1 <div class="menu"> 
    2 <h2>Edit Menu</h2> 
    3         <?php echo $form->create('Menu');?> 
    4                 <?php echo $form->input('id');?> 
    5                 <?php echo $form->input('name', array('class' => 'required'));?> 
    6                 <?php echo $form->input('url', array('class' => 'required'));?> 
    7                 <?php echo $form->input('position', array('class' => 'required'));?> 
    8                 <?php echo $form->input('icon');?> 
    9                 <?php echo $form->input('parent_id', array('class' => 'required', 'options' => $parents));?> 
    10                 <?php echo $form->input('section_id', array('class' => 'required', 'options' => $sections));?> 
    11                 <?php echo $form->input('access_level', array('class' => 'required'));?> 
    12                 <?php echo $form->input('published', array('class' => 'required'));?> 
    13                 <?php echo $form->submit('Update');?> 
    14         </form> 
     1<div id="post"> 
     2        <h2>Edit Menu</h2> 
     3        <?php e($form->create('Menu'));?> 
     4                <fieldset id="post-main"> 
     5                        <legend>Menu Details:</legend> 
     6                        <?php echo $form->input('id');?> 
     7                        <?php echo $form->input('name');?> 
     8                        <?php echo $form->input('url');?> 
     9                        <?php echo $form->input('position');?> 
     10                        <?php echo $form->input('icon');?> 
     11                        <?php echo $treeMenu->select($data);?> 
     12                        <?php echo $form->input('section_id', array('options' => $sections));?> 
     13                        <?php echo $form->input('access_level', array('options'=>$access_levels));?> 
     14                        <?php echo $form->input('published', array('type'=>'checkbox'));?>               
     15                </fieldset> 
     16                <?php e($form->submit('Save Menu'));?> <?php e($html->link('Cancel', '/admin/menus', array('class'=>'cancel')));?> 
     17        <?php e($form->end());?> 
    1518</div> 
    16 <div class="actions"> 
    17         <ul> 
    18                 <li><?php echo $html->link('Delete', array('action'=>'delete', $html->tagValue('Menu/id')), null, 'Are you sure you want to delete #' . $html->tagValue('Menu/id')); ?> 
    19                 <li><?php echo $html->link('List Menuses', array('action'=>'index')); ?></li> 
    20                 <li><?php echo $html->link('View Sections', array('controller'=> 'sections', 'action'=>'view')); ?></li> 
    21                 <li><?php echo $html->link('Add Sections', array('controller'=> 'sections', 'action'=>'add')); ?></li> 
    22         </ul> 
    23 </div> 
  • branch/views/menus/admin_index.ctp

    r55 r67  
    2222                <td><?php echo $menu['Menu']['position']; ?></td> 
    2323                <td><?php echo $menu['Menu']['icon']; ?></td> 
    24                 <td><?php echo $html->link($menu['Parent']['name'], array('controller'=> 'menus', 'action'=>'view', $menu['Parent']['id'])); ?></td> 
     24                <td><?php echo $html->link($menu['Menu']['parent_id'], array('controller'=> 'menus', 'action'=>'view', $menu['Menu']['parent_id'])); ?></td> 
    2525                <td><?php echo $html->link($menu['Section']['name'], array('controller'=> 'sections', 'action'=>'view', $menu['Section']['id'])); ?></td> 
    2626                <td><?php echo $menu['Menu']['access_level']; ?></td> 
  • branch/views/posts/admin_add.ctp

    r60 r67  
     1<?php //e($javascript->codeBlock('$j.ready(function() {$("#PostAddForm").ajaxSubmit(function() { var options = { target: ".post" }; });});'));?> 
     2 
     3<div class="success" style="display:none;"> 
     4        <h2>Post has successfuly saved.</h2> 
     5</div> 
     6 
    17<div class="post"> 
    28<h2>New Post</h2> 
  • branch/webroot/js/webrocket.js

    r63 r67  
    11var $j = jQuery.noConflict(); 
    2 var $z = jamal.noConflict(); 
     2//var $z = jamal.noConflict(); 
    33 
    44$j(function() { 
     
    4242        $j(".wymsubmit").click(function () {alert($j(this).siblings(".wymeditor").val());}); 
    4343         
    44         $j("ul.mytreemenu").Treeview({speed: "slow", collapsed: true}); 
     44        $j("ul.mytreemenu").Treeview({speed: "slow", collapsed: true, store: true}); 
     45         
     46        /*var options = {  
     47        target:        '#content',   // target element(s) to be updated with server response  
     48        //beforeSubmit:  showRequest,  // pre-submit callback  
     49        success:       showResponse  // post-submit callback  
     50    }; */ 
     51         
     52        /*$j("#PostAddForm").submit(function(){  
     53                $(this).ajaxSubmit(options); 
     54                $(".post").fadeOut("fast"); 
     55                return false; 
     56        });*/ 
     57         
     58        /*function showResponse()  {  
     59                $(".success").fadeIn("slow"); 
     60        };*/ 
    4561});