Author: michkinn
Date: 2010-01-15 15:59:32 +0100 (Fri, 15 Jan 2010)
New Revision: 26680

Modified:
   
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/actions/actions.class.php
   
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/actions/components.class.php
   
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/lib/BasesfJqueryTreeDoctrineManagerActions.class.php
   
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/lib/BasesfJqueryTreeDoctrineManagerComponents.class.php
   
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_list_actions_tree.php
   
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_manager.php
   
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_manager_roots.php
   
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_manager_tree.php
   
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_nested_set_list.php
Log:
Fix Format
Resolve commit mistake

Modified: 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/actions/actions.class.php
===================================================================
--- 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/actions/actions.class.php
       2010-01-15 13:54:24 UTC (rev 26679)
+++ 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/actions/actions.class.php
       2010-01-15 14:59:32 UTC (rev 26680)
@@ -1,122 +1,24 @@
 <?php
 
+/*
+ * This file is part of the symfony package.
+ * (c) 2004-2006 Fabien Potencier <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
 
+require_once(dirname(__FILE__).'/../lib/BasesfJqueryTreeDoctrineManagerActions.class.php');
+
 /**
- * sfJsTreeDoctrine actions.
+ * sfJqueryTreeDoctrineManager actions.
  * 
- * @package    sfJsTreeDoctrinePlugin
- * @subpackage sfJsTreeDoctrine
- * @author     Your name here
- * @version    SVN: $Id: actions.class.php 12534 2008-11-01 13:38:27Z 
Kris.Wallsmith $
+ * @package    symfony
+ * @subpackage plugin
+ * @author     Gregory Schurgast <[email protected]>
+ * @author     Gordon Franke <[email protected]>
+ * @version    SVN: $Id: BasesfGuardForgotPasswordActions.class.php 18401 
2009-05-18 14:12:09Z gimler $
  */
-class sfJqueryTreeDoctrineManagerActions extends sfActions
+class sfJqueryTreeDoctrineManagerActions extends 
BasesfJqueryTreeDoctrineManagerActions
 {
-
-
-
-  public function getTree($model, $rootId = 0)
-  {
-    if( $rootId )
-    {
-      $root = Doctrine_Core::getTable($model)->getTree()->findRoot($rootId);
-      return 
Doctrine_Core::getTable($model)->getTree()->fetchBranch($root->getId()); 
-    } else {
-      return Doctrine_Core::getTable($model)->getTree()->fetchTree();
-    }
-  }
-
-  public function executeAdd_child()
-  {
-    $parent_id = $this->getRequestParameter('parent_id');
-    $model = $this->getRequestParameter('model');
-    $field = $this->getRequestParameter('field');
-    $value = $this->getRequestParameter('value');
-    $record = Doctrine_Core::getTable($model)->find($parent_id);
-
-    $child = new $model;
-    $child->set($field, $value);
-    $record->getNode()->addChild($child);
-    
-    $this->json = json_encode($child->toArray());
-    
-    $this->getResponse()->setHttpHeader('Content-type', 'application/json');
-    $this->setTemplate('json');
-  }
-  
-  public function executeAdd_root()
-  {
-    $model = $this->getRequestParameter('model');
-    $data = $this->getRequestParameter( strtolower($model) );
-    $tree = $this->getTree($model);
-
-    $root = new $model;
-    $root->synchronizeWithArray( $data );
-               $root->save();
-               
-    Doctrine_Core::getTable($model)->getTree()->createRoot($root);
-    $this->records = $this->getTree($model);
-    return sfView::NONE;
-  }
-
-  public function executeEdit_field()
-  {
-    $id = $this->getRequestParameter('id');
-    $model = $this->getRequestParameter('model');
-    $field = $this->getRequestParameter('field');
-    $value = $this->getRequestParameter('value');
-
-    $record = Doctrine_Core::getTable($model)->find($id);
-    $record->set($field, $value);
-    $record->save();
-
-    $this->json = json_encode($record->toArray());
-    
-    $this->getResponse()->setHttpHeader('Content-type', 'application/json');
-    $this->setTemplate('json');
-  }
-
-  public function executeDelete()
-  {
-    $id = $this->getRequestParameter('id');
-    $model = $this->getRequestParameter('model');
-    
-    $record = Doctrine_Core::getTable($model)->find($id);
-    $record->getNode()->delete();
-    $this->json = json_encode(array());
-    $this->getResponse()->setHttpHeader('Content-type', 'application/json');
-    $this->setTemplate('json');
-    
-  }
-
-  public function executeMove()
-  {
-    $id = $this->getRequestParameter('id');
-    $to_id = $this->getRequestParameter('to_id');
-    $model = $this->getRequestParameter('model');
-    $movetype = $this->getRequestParameter('movetype');
-    
-    $record = Doctrine_Core::getTable($model)->find($id);
-    $dest = Doctrine_Core::getTable($model)->find($to_id);
-    
-    if( $movetype == 'inside' )
-    {
-      //$prev = $record->getNode()->getPrevSibling();
-      $record->getNode()->moveAsLastChildOf($dest);
-    }
-    else if( $movetype == 'after' )
-    {
-      $record->getNode()->moveAsNextSiblingOf($dest);
-    }
-    
-    else if( $movetype == 'before' )
-    {
-      //$next = $record->getNode()->getNextSibling();
-      $record->getNode()->moveAsPrevSiblingOf($dest);
-    }
-    $this->json = json_encode($record->toArray());
-    $this->getResponse()->setHttpHeader('Content-type', 'application/json');
-    $this->setTemplate('json');
-  }
-
- 
 }

Modified: 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/actions/components.class.php
===================================================================
--- 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/actions/components.class.php
    2010-01-15 13:54:24 UTC (rev 26679)
+++ 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/actions/components.class.php
    2010-01-15 14:59:32 UTC (rev 26680)
@@ -1,75 +1,24 @@
 <?php
+/*
+ * This file is part of the symfony package.
+ * (c) 2004-2006 Fabien Potencier <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
 
+require_once(dirname(__FILE__).'/../lib/BasesfJqueryTreeDoctrineManagerComponents.class.php');
 
-class sfJqueryTreeDoctrineManagerComponents extends sfComponents
-{
-  
-       public function executeManager(){
-               $this->options = $this->getModelOptions();
-               $this->hasManyRoots = $this->modelHasManyRoots();
-               if ($this->records = $this->executeControl()){
-                       $request = $this->getRequest();
-                       
-                       if (  !$request->hasParameter('root') && 
!$this->modelHasManyRoots() ){
-                               $this->getController()->redirect(url_for(  
$request->getParameter('module') . '/'. $request->getParameter('action') 
.'?root=1'), true);
-                               return sfView::NONE;
-                       }
-                       elseif ( !$request->hasParameter('root') && 
$this->modelHasManyRoots() ){
-                               $this->roots = $this->getRoots( $this->model );
-                       }
-                       else{
-                               $this->records = $this->getTree($this->model, 
$request->getParameter('root'));
-                       }
-                       
-                       
-                       
-               }
-       }
+/**
+ * sfJqueryTreeDoctrineManager components.
+ *
+ * @package    symfony
+ * @subpackage plugin
+ * @author     Gregory Schurgast <[email protected]>
+ * @author     Gordon Franke <[email protected]>
+ * @version    SVN: $Id: sfJqueryTreeDoctrineManagerComponents.class.php 7745 
2008-03-05 11:05:33Z michkinn $
+ */
 
-
-       private function executeControl(){
-               if ( !$this->modelIsNestedSet() ){
-                       throw new Exception('Model "'.$this->model.'" is not a 
NestedSet');
-                       return false;
-               }
-               return true;            
-       }
-       
-       
-       
-       private function getRoots($model){
-               $tree = Doctrine_Core::getTable($model)->getTree();
-    return $tree->fetchRoots();
-  }
-       
-       
-        private function getTree($model, $rootId = 0){
-               $tree = Doctrine_Core::getTable($model)->getTree();
-    if( $rootId ){
-                       $root = $tree->fetchRoot($rootId);
-                       return $root ? $tree->fetchBranch($root->getId()) : 
false; 
-    } else {
-      return $tree->fetchTree();
-    }
-  }
-       
-       /*
-        * Return the options of the model
-        */
-       private function getModelOptions(){
-               $model = $this->model;
-               $record = new $model;
-               return $record->getOptions();
-       }
-       
-       private function modelIsNestedSet(){
-               return $this->options['treeImpl'] == 'NestedSet';
-       }
-       
-       private function modelHasManyRoots(){
-               return isset($this->options['treeOptions']['hasManyRoots']) && 
$this->options['treeOptions']['hasManyRoots'];
-       }
-       
-       
-
+class sfJqueryTreeDoctrineManagerComponents extends 
BasesfJqueryTreeDoctrineManagerComponents
+{
 }
\ No newline at end of file

Modified: 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/lib/BasesfJqueryTreeDoctrineManagerActions.class.php
===================================================================
--- 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/lib/BasesfJqueryTreeDoctrineManagerActions.class.php
    2010-01-15 13:54:24 UTC (rev 26679)
+++ 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/lib/BasesfJqueryTreeDoctrineManagerActions.class.php
    2010-01-15 14:59:32 UTC (rev 26680)
@@ -54,17 +54,18 @@
   {
     $model = $this->getRequestParameter('model');
     $data = $this->getRequestParameter( strtolower($model) );
-    
     $tree = $this->getTree($model);
     
     $root = new $model;
+    $root->synchronizeWithArray( $data );
+               $root->save();
     
-    $root->synchronizeWithArray( $data );    
-    
     Doctrine_Core::getTable($model)->getTree()->createRoot($root);
     $this->records = $this->getTree($model);
 
-    return sfView::NONE;
+    $this->json = json_encode($record->toArray());
+    $this->getResponse()->setHttpHeader('Content-type', 'application/json');
+    $this->setTemplate('json');
   }
 
   public function executeEdit_field()
@@ -79,7 +80,6 @@
     $record->save();
 
     $this->json = json_encode($record->toArray());
-    
     $this->getResponse()->setHttpHeader('Content-type', 'application/json');
     $this->setTemplate('json');
   }

Modified: 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/lib/BasesfJqueryTreeDoctrineManagerComponents.class.php
===================================================================
--- 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/lib/BasesfJqueryTreeDoctrineManagerComponents.class.php
 2010-01-15 13:54:24 UTC (rev 26679)
+++ 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/lib/BasesfJqueryTreeDoctrineManagerComponents.class.php
 2010-01-15 14:59:32 UTC (rev 26680)
@@ -19,10 +19,49 @@
  */
 class BasesfJqueryTreeDoctrineManagerComponents extends sfComponents
 {
-  public function getTree($model, $rootId = null)
-  {
-    $tree = Doctrine_Core::getTable($model)->getTree();
+  public function executeManager(){
+               $this->options = $this->getModelOptions();
+               $this->hasManyRoots = $this->modelHasManyRoots();
+               if ($this->records = $this->executeControl()){
+                       $request = $this->getRequest();
+                       
+                       if (  !$request->hasParameter('root') && 
!$this->modelHasManyRoots() ){
+                               $this->getController()->redirect(url_for(  
$request->getParameter('module') . '/'. $request->getParameter('action') 
.'?root=1'), true);
+                               return sfView::NONE;
+                       }
+                       elseif ( !$request->hasParameter('root') && 
$this->modelHasManyRoots() ){
+                               $this->roots = $this->getRoots( $this->model );
+                       }
+                       else{
+                               $this->records = $this->getTree($this->model, 
$request->getParameter('root'));
+                       }
+               }
+       }
 
+       /*
+        * return exception if Model is not defined as NestedSet
+       */
+       private function executeControl(){
+               if ( !$this->modelIsNestedSet() ){
+                       throw new Exception('Model "'.$this->model.'" is not a 
NestedSet');
+                       return false;
+               }
+               return true;            
+       }
+       
+       
+       /*
+       * Returns the roots
+       */
+       private function getRoots($model){
+               $tree = Doctrine_Core::getTable($model)->getTree();
+    return $tree->fetchRoots();
+  }
+       
+       
+        private function getTree($model, $rootId = null){
+               $tree = Doctrine_Core::getTable($model)->getTree();
+
     $options = array();
     if($rootId !== null)
     {
@@ -31,11 +70,21 @@
 
     return $tree->fetchTree($options);
   }
-
-  public function executeManager()
-  {
-    $this->records = $this->getTree($this->model, $this->root);
-
-    if (!$this->records){ echo 'pas de racine';}
-  }
+       
+       /*
+        * Return the options of the model
+        */
+       private function getModelOptions(){
+               $model = $this->model;
+               $record = new $model;
+               return $record->getOptions();
+       }
+       
+       private function modelIsNestedSet(){
+               return $this->options['treeImpl'] == 'NestedSet';
+       }
+       
+       private function modelHasManyRoots(){
+               return isset($this->options['treeOptions']['hasManyRoots']) && 
$this->options['treeOptions']['hasManyRoots'];
+       }
 }

Modified: 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_list_actions_tree.php
===================================================================
--- 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_list_actions_tree.php
        2010-01-15 13:54:24 UTC (rev 26679)
+++ 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_list_actions_tree.php
        2010-01-15 14:59:32 UTC (rev 26680)
@@ -15,14 +15,6 @@
        </li>
 </ul>
 
-
-
-
-
-
-
-
-
 <?php echo javascript_tag();?>
     $(document).ready(function(){
 

Modified: 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_manager.php
===================================================================
--- 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_manager.php
  2010-01-15 13:54:24 UTC (rev 26679)
+++ 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_manager.php
  2010-01-15 14:59:32 UTC (rev 26680)
@@ -3,17 +3,11 @@
 <div id="sf_admin_container">
     <h1><?php echo sfInflector::humanize(sfInflector::underscore($model)); ?> 
Nested Set Manager</h1>
     <?php include_partial('sfJqueryTreeDoctrineManager/flashes') ?>
-    
-    
-
-
-                       <?php if ($hasManyRoots && 
!$sf_request->hasParameter('root') ):?>
-                               <?php 
include_partial('sfJqueryTreeDoctrineManager/manager_roots', array('model' => 
$model, 'field' => $field, 'root' => $root, 'roots' => $roots)) ?>
-                       <?php else: ?>
-                               <?php 
include_partial('sfJqueryTreeDoctrineManager/manager_tree', array('model' => 
$model, 'field' => $field, 'root' => $root, 'records' => $records, 
'hasManyRoots' => $hasManyRoots)) ?>
-                       <?php endif;?>
-                       
-                       
+               <?php if ($hasManyRoots && !$sf_request->hasParameter('root') 
):?>
+                       <?php 
include_partial('sfJqueryTreeDoctrineManager/manager_roots', array('model' => 
$model, 'field' => $field, 'root' => $root, 'roots' => $roots)) ?>
+               <?php else: ?>
+                       <?php 
include_partial('sfJqueryTreeDoctrineManager/manager_tree', array('model' => 
$model, 'field' => $field, 'root' => $root, 'records' => $records, 
'hasManyRoots' => $hasManyRoots)) ?>
+               <?php endif;?>  
 </div>
 
 

Modified: 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_manager_roots.php
===================================================================
--- 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_manager_roots.php
    2010-01-15 13:54:24 UTC (rev 26679)
+++ 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_manager_roots.php
    2010-01-15 14:59:32 UTC (rev 26680)
@@ -1,43 +1,34 @@
 <div class="sf_admin_list">
-  <?php if (!$roots->count()): ?>
-    <p><?php echo __('No root', array(), 'sf_admin') ?></p>
-  <?php else: ?>
-    <table cellspacing="0">
-      <thead>
-        <tr>
-          <th id="sf_admin_text sf_admin_list_th_<?php echo 
strtolower($model);?>"><?php echo ucfirst($field);?> </th>
-          <th id="sf_admin_list_th_actions"><?php echo __('Actions', array(), 
'sf_admin') ?></th>
-        </tr>
-      </thead>
-                       
+       <?php if (!$roots->count()): ?>
+               <p><?php echo __('No root', array(), 'sf_admin') ?></p>
+       <?php else: ?>
+               <table cellspacing="0">
+                       <thead>
+                               <tr>
+                                       <th id="sf_admin_text 
sf_admin_list_th_<?php echo strtolower($model);?>"><?php echo 
ucfirst($field);?> </th>
+                                       <th id="sf_admin_list_th_actions"><?php 
echo __('Actions', array(), 'sf_admin') ?></th>
+                               </tr>
+                       </thead>
                        <tfoot>
                                <tr>
-                               <th colspan="2"> <?php echo $roots->count() ;?> 
<?php echo __('Roots');?></th>
+                                       <th colspan="2"> <?php echo 
$roots->count() ;?> <?php echo __('Roots');?></th>
                                </tr>
-                        </tfoot>
-                       
-                       
+                       </tfoot>        
                        <tbody>
-        <?php foreach ($roots as $i => $root): $odd = fmod(++$i, 2) ? 'odd' : 
'even' ?>
-          <tr class="sf_admin_row <?php echo $odd ?>">
-            <td class="sf_admin_text sf_admin_list_td_<?php echo $field ?>">
-                                                 <?php echo $root->$field ?>
-                                               </td>
-                                               
-                                               <td>
-                                                 <ul 
class="sf_admin_td_actions">
-                                                   <li 
class="sf_admin_action_edit"><?php echo link_to( __('Manage Tree') 
,$sf_request->getParameter('module') . '/' . 
$sf_request->getParameter('action') . '?root=' . $root->id);?></li>  </ul>
-                                                
-                                               </td>
-                                               
-                                               
-          </tr>
-        <?php endforeach; ?>
-      </tbody>
-    </table>
-  <?php endif; ?>
+                               <?php foreach ($roots as $i => $root): $odd = 
fmod(++$i, 2) ? 'odd' : 'even' ?>
+                               <tr class="sf_admin_row <?php echo $odd ?>">
+                                       <td class="sf_admin_text 
sf_admin_list_td_<?php echo $field ?>"><?php echo $root->$field ?></td>
+                                       <td>
+                                               <ul class="sf_admin_td_actions">
+                                                       <li 
class="sf_admin_action_edit"><?php echo link_to( __('Manage Tree') 
,$sf_request->getParameter('module') . '/' . 
$sf_request->getParameter('action') . '?root=' . $root->id);?></li>
+                                               </ul>
+                                       </td>
+                               </tr>
+                               <?php endforeach; ?>
+                       </tbody>
+               </table>
+       <?php endif; ?>
 </div>
-
 <div class="sf_admin_actions">
   <?php include_partial('sfJqueryTreeDoctrineManager/list_batch_actions') ?>
        <?php 
include_partial('sfJqueryTreeDoctrineManager/list_actions_no_root', 
array('model' => $model, 'field' => $field, 'root' => $root)) ?>

Modified: 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_manager_tree.php
===================================================================
--- 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_manager_tree.php
     2010-01-15 13:54:24 UTC (rev 26679)
+++ 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_manager_tree.php
     2010-01-15 14:59:32 UTC (rev 26680)
@@ -3,7 +3,6 @@
     <div style="clear:both">&nbsp;</div>
 </div>
 
-
 <div class="sf_admin_actions">
   <?php include_partial('sfJqueryTreeDoctrineManager/list_batch_actions') ?>
   <?php include_partial('sfJqueryTreeDoctrineManager/list_actions', 
array('model' => $model, 'field' => $field, 'root' => $root, 'records' => 
$records, 'hasManyRoots' => $hasManyRoots)); ?>

Modified: 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_nested_set_list.php
===================================================================
--- 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_nested_set_list.php
  2010-01-15 13:54:24 UTC (rev 26679)
+++ 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/templates/_nested_set_list.php
  2010-01-15 14:59:32 UTC (rev 26680)
@@ -14,121 +14,110 @@
     </div>
 <?php endif;?>
 <?php echo javascript_tag();?>
-$(function () { 
-    $("#<?php echo strtolower($model);?>-nested-set").tree({
-        callback: {
-            // activate add and delete node button
-            onchange: function(){ $('.nodeinteraction').attr('disabled','');},
-            
-            onrename : function (NODE, TREE_OBJ, RB) {
-                $('.error').remove();
-                $('.notice').remove();
-                                                               
$('.nested_set_manager_holder').before('<div class="waiting"><?php echo 
__('Sending data to server.');?></div>');
-                if (TREE_OBJ.get_text(NODE) == 'New folder'){
-                    $('.nested_set_manager_holder').before('<div 
class="error">"'+TREE_OBJ.get_text(NODE)+'" <?php echo __('is not a valid 
name');?></div>');
-                    $.tree.focused().rename();
-                }
-                else {
-                    if (NODE.id == ''){ // happen if creation of a new node
-                        $.ajax({
-                            type: "POST",
-                            url : '<?php echo 
url_for('sfJqueryTreeDoctrineManager/Add_child');?>',
-                            //dataType : 'json',
-                            data : 'root=<?php echo $root;?>&model=<?php echo 
$model;?>&field=<?php echo 
$field;?>&value='+TREE_OBJ.get_text(NODE)+'&parent_id=' + 
TREE_OBJ.parent(NODE).attr('id').replace('phtml_',''),
-                            complete : function(){ 
-                                                                               
                                $('.waiting').remove();
-                                                                               
                          },
-                                                                               
                                success : function (data, textStatus) {
-                                $('.nested_set_manager_holder').before('<div 
class="notice"><?php echo __('The item was created successfully.');?></div>');
-                                                                               
                                                
$(NODE).attr('id','phtml_'+data.id);
-                            },
-                            error : function (data, textStatus) {
-                                $('.nested_set_manager_holder').before('<div 
class="error"><?php echo __('Error while creating the item.');?></div>');
-                                $.tree.rollback(RB);
-                            }
-
-                        });
-                        
-                        
-                    }
-                    else { // happen when renaming an existing node
-                        
-                        $.ajax({
-                            type: "POST",
-                            url : '<?php echo 
url_for('sfJqueryTreeDoctrineManager/Edit_field');?>',
-                            //dataType : 'json',
-                            data : 'root=<?php echo $root;?>&model=<?php echo 
$model;?>&field=<?php echo $field;?>&value='+TREE_OBJ.get_text(NODE)+'&id=' + 
NODE.id.replace('phtml_',''),
-                            complete : function(){ 
-                                                                               
                                $('.waiting').remove();
-                                                                               
                          },
-                                                                               
                                success : function (data, textStatus) {
-                                $('.nested_set_manager_holder').before('<div 
class="notice"><?php echo __('The item was renamed successfully.');?></div>');
-                            },
-                            error : function (data, textStatus) {
-                                $('.nested_set_manager_holder').before('<div 
class="error"><?php echo __('Error while renaming the item.');?></div>');
-                                $.tree.rollback(RB);
-                            }
-                        });
- 
-                    }
-                }
-                       },
-            
-            ondblclk : function (NODE, TREE_OBJ){
-                $('.error').remove();
-                $('.notice').remove();
-                $.tree.focused().rename();
-            },
-            
-            onmove: function(NODE, REF_NODE, TYPE, TREE_OBJ, RB){
-                $('.error').remove();
-                $('.notice').remove();
-                $('.nested_set_manager_holder').before('<div 
class="waiting"><?php echo __('Sending data to server.');?></div>');
-                                                                       
-                $.ajax({
-                    type: "POST",
-                    url : '<?php echo 
url_for('sfJqueryTreeDoctrineManager/Move');?>',
-                    //dataType : 'json',
-                    data : 'root=<?php echo $root;?>&model=<?php echo 
$model;?>&id=' + NODE.id.replace('phtml_','') +'&to_id=' + 
REF_NODE.id.replace('phtml_','') + '&movetype=' + TYPE, 
-                    complete : function(){ 
-                                                                               
$('.waiting').remove();
-                                                                         },
-                                                                               
success : function (data, textStatus) {
-                        $('.nested_set_manager_holder').before('<div 
class="notice"><?php echo __('The item was moved successfully.');?></div>');
-                    },
-                    error : function (data, textStatus) {
-                        $('.nested_set_manager_holder').before('<div 
class="error"><?php echo __('Error while moving the item.');?></div>');
-                        $.tree.rollback(RB);
-                    }
-                });
-                
-                
-                
-                    
-                    
-            },
-            ondelete: function(NODE, TREE_OBJ, RB){
-                $('.error').remove();
-                $('.notice').remove();
-                $('.nested_set_manager_holder').before('<div 
class="waiting"><?php echo __('Sending data to server.');?></div>');
-                $.ajax({
-                    type: "POST",
-                    url : '<?php echo 
url_for('sfJqueryTreeDoctrineManager/Delete');?>',
-                    //dataType : 'json',
-                    data : 'root=<?php echo $root;?>&model=<?php echo 
$model;?>&id=' + NODE.id.replace('phtml_','') , 
-                    complete : function(){ 
-                                                                               
$('.waiting').remove();
-                                                                         },
-                                                                               
success : function (data, textStatus) {
-                        $('.nested_set_manager_holder').before('<div 
class="notice"><?php echo __('The item was deleted successfully.');?></div>');
-                    },
-                    error : function (data, textStatus) {
-                        $('.nested_set_manager_holder').before('<div 
class="error"><?php echo __('Error while deleting the item.');?></div>');
-                        $.tree.rollback(RB);
-                    }
-                });
-            } 
+$(function () {
+       $("#<?php echo strtolower($model);?>-nested-set").tree({
+       callback: {// activate add and delete node button
+                       onchange: function(){ 
$('.nodeinteraction').attr('disabled','');},
+      
+                       onrename : function (NODE, TREE_OBJ, RB) {
+       $('.error').remove();
+        $('.notice').remove();
+                               $('.nested_set_manager_holder').before('<div 
class="waiting"><?php echo __('Sending data to server.');?></div>');
+        if (TREE_OBJ.get_text(NODE) == 'New folder'){
+               $('.nested_set_manager_holder').before('<div 
class="error">"'+TREE_OBJ.get_text(NODE)+'" <?php echo __('is not a valid 
name');?></div>');
+          $.tree.focused().rename();
         }
-    });
+        else {
+               if (NODE.id == ''){ // happen if creation of a new node
+               $.ajax({
+               type: "POST",
+              url : '<?php echo 
url_for('sfJqueryTreeDoctrineManager/Add_child');?>',
+              dataType : 'json',
+              data : 'root=<?php echo $root;?>&model=<?php echo 
$model;?>&field=<?php echo 
$field;?>&value='+TREE_OBJ.get_text(NODE)+'&parent_id=' + 
TREE_OBJ.parent(NODE).attr('id').replace('phtml_',''),
+              complete : function(){ 
+                                                               
$('.waiting').remove();
+                                                       },
+                                                       success : function 
(data, textStatus) {
+               $('.nested_set_manager_holder').before('<div 
class="notice"><?php echo __('The item was created successfully.');?></div>');
+                                                               
$(NODE).attr('id','phtml_'+data.id);
+              },
+              error : function (data, textStatus) {
+               $('.nested_set_manager_holder').before('<div 
class="error"><?php echo __('Error while creating the item.');?></div>');
+                $.tree.rollback(RB);
+              }
+            });
+                                       }
+                                       else { // happen when renaming an 
existing node
+                                               $.ajax({
+                                                       type: "POST",
+                                                       url : '<?php echo 
url_for('sfJqueryTreeDoctrineManager/Edit_field');?>',
+                                                       dataType : 'json',
+                                                       data : 'root=<?php echo 
$root;?>&model=<?php echo $model;?>&field=<?php echo 
$field;?>&value='+TREE_OBJ.get_text(NODE)+'&id=' + NODE.id.replace('phtml_',''),
+                                                       complete : function(){ 
+                                                               
$('.waiting').remove();
+                                                       },
+                                                       success : function 
(data, textStatus) {
+                                                               
$('.nested_set_manager_holder').before('<div class="notice"><?php echo __('The 
item was renamed successfully.');?></div>');
+                                                       },
+                                                       error : function (data, 
textStatus) {
+                                                               
$('.nested_set_manager_holder').before('<div class="error"><?php echo __('Error 
while renaming the item.');?></div>');
+                                                               
$.tree.rollback(RB);
+                                                       }
+                                               });
+                                       }
+                               }
+                       },
+                       
+                       ondblclk : function (NODE, TREE_OBJ){
+                               $('.error').remove();
+                               $('.notice').remove();
+                               $.tree.focused().rename();
+                       },
+                       
+                       onmove: function(NODE, REF_NODE, TYPE, TREE_OBJ, RB){
+                               $('.error').remove();
+                               $('.notice').remove();
+                               $('.nested_set_manager_holder').before('<div 
class="waiting"><?php echo __('Sending data to server.');?></div>');
+                               $.ajax({
+                                       type: "POST",
+                                       url : '<?php echo 
url_for('sfJqueryTreeDoctrineManager/Move');?>',
+                                       dataType : 'json',
+                                       data : 'root=<?php echo 
$root;?>&model=<?php echo $model;?>&id=' + NODE.id.replace('phtml_','') 
+'&to_id=' + REF_NODE.id.replace('phtml_','') + '&movetype=' + TYPE,
+                                       complete : function(){
+                                               $('.waiting').remove();
+                                       },
+                                       success : function (data, textStatus) {
+                                               
$('.nested_set_manager_holder').before('<div class="notice"><?php echo __('The 
item was moved successfully.');?></div>');
+                                       },
+                                       error : function (data, textStatus) {
+                                               
$('.nested_set_manager_holder').before('<div class="error"><?php echo __('Error 
while moving the item.');?></div>');
+                                               $.tree.rollback(RB);
+                                       }
+                               });
+                       },
+                       
+                       ondelete: function(NODE, TREE_OBJ, RB){
+                               $('.error').remove();
+                               $('.notice').remove();
+                               $('.nested_set_manager_holder').before('<div 
class="waiting"><?php echo __('Sending data to server.');?></div>');
+                               $.ajax({
+                                       type: "POST",
+                                       url : '<?php echo 
url_for('sfJqueryTreeDoctrineManager/Delete');?>',
+                                       dataType : 'json',
+                                       data : 'root=<?php echo 
$root;?>&model=<?php echo $model;?>&id=' + NODE.id.replace('phtml_',''),
+                                       complete : function(){ 
+                                               $('.waiting').remove();
+                                       },
+                                       success : function (data, textStatus) {
+                                               
$('.nested_set_manager_holder').before('<div class="notice"><?php echo __('The 
item was deleted successfully.');?></div>');
+                                       },
+                                       error : function (data, textStatus) {
+                                               
$('.nested_set_manager_holder').before('<div class="error"><?php echo __('Error 
while deleting the item.');?></div>');
+                                               $.tree.rollback(RB);
+                                       }
+                               });
+                       }
+               }
+       });
 });
 <?php echo end_javascript_tag();?>
\ No newline at end of file

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.


Reply via email to