Author: michkinn
Date: 2010-03-22 19:19:58 +0100 (Mon, 22 Mar 2010)
New Revision: 28682

Modified:
   
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/lib/helper/sfJqueryTreeDoctrineHelper.php
   
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/lib/BasesfJqueryTreeDoctrineManagerComponents.class.php
Log:


Modified: 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/lib/helper/sfJqueryTreeDoctrineHelper.php
===================================================================
--- 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/lib/helper/sfJqueryTreeDoctrineHelper.php
   2010-03-22 16:05:36 UTC (rev 28681)
+++ 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/lib/helper/sfJqueryTreeDoctrineHelper.php
   2010-03-22 18:19:58 UTC (rev 28682)
@@ -4,8 +4,8 @@
         
sfContext::getInstance()->getResponse()->addStylesheet('/sfJqueryTreeDoctrineManagerPlugin/jsTree/themes/default/style.css');
         
sfContext::getInstance()->getResponse()->addStylesheet('/sfJqueryTreeDoctrineManagerPlugin/css/screen.css');
         
sfContext::getInstance()->getResponse()->addJavascript('/sfJqueryTreeDoctrineManagerPlugin/jsTree/jquery.js');
-                               
sfContext::getInstance()->getResponse()->addJavascript('/sfJqueryTreeDoctrineManagerPlugin/jsTree/jquery.cookie.js');
+        
sfContext::getInstance()->getResponse()->addJavascript('/sfJqueryTreeDoctrineManagerPlugin/jsTree/jquery.cookie.js');
         
sfContext::getInstance()->getResponse()->addJavascript('/sfJqueryTreeDoctrineManagerPlugin/jsTree/jquery.tree.min.js');
-                               
sfContext::getInstance()->getResponse()->addJavascript('/sfJqueryTreeDoctrineManagerPlugin/jsTree/plugins/jquery.tree.cookie.js');
+        
sfContext::getInstance()->getResponse()->addJavascript('/sfJqueryTreeDoctrineManagerPlugin/jsTree/plugins/jquery.tree.cookie.js');
         return get_component('sfJqueryTreeDoctrineManager', 'manager', 
array('model' => $model, 'field' => $field, 'root' => $root));
     }
\ No newline at end of file

Modified: 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/lib/BasesfJqueryTreeDoctrineManagerComponents.class.php
===================================================================
--- 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/lib/BasesfJqueryTreeDoctrineManagerComponents.class.php
 2010-03-22 16:05:36 UTC (rev 28681)
+++ 
plugins/sfJqueryTreeDoctrineManagerPlugin/trunk/modules/sfJqueryTreeDoctrineManager/lib/BasesfJqueryTreeDoctrineManagerComponents.class.php
 2010-03-22 18:19:58 UTC (rev 28682)
@@ -20,16 +20,19 @@
 class BasesfJqueryTreeDoctrineManagerComponents extends sfComponents
 {
   public function executeManager(){
-               $this->options = $this->getModelOptions();
-               $this->hasManyRoots = $this->modelHasManyRoots();
-               if ($this->records = $this->executeControl()){
+               
+               if ($this->records = $this->executeControl())
+        {
+            $this->hasManyRoots = $this->modelHasManyRoots();
                        $request = $this->getRequest();
                        
-                       if (  !$request->hasParameter('root') && 
!$this->modelHasManyRoots() ){
+                       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() ){
+                       elseif ( !$request->hasParameter('root') && 
$this->modelHasManyRoots() )
+            {
                                $this->roots = $this->getRoots( $this->model );
                        }
                        else{
@@ -42,7 +45,8 @@
         * return exception if Model is not defined as NestedSet
        */
        private function executeControl(){
-               if ( !$this->modelIsNestedSet() ){
+               if ( ! Doctrine_Core::getTable($this->model)->isTree() )
+        {
                        throw new Exception('Model "'.$this->model.'" is not a 
NestedSet');
                        return false;
                }
@@ -54,37 +58,27 @@
        * Returns the roots
        */
        private function getRoots($model){
-               $tree = Doctrine_Core::getTable($model)->getTree();
-    return $tree->fetchRoots();
-  }
+        $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)
-    {
-      $options['root_id'] = $rootId;
+    private function getTree($model, $rootId = null){
+        $tree = Doctrine_Core::getTable($model)->getTree();
+        $options = array();
+        if($rootId !== null)
+        {
+            $options['root_id'] = $rootId;
+        }
+        return $tree->fetchTree($options);
     }
 
-    return $tree->fetchTree($options);
-  }
-       
-       /*
-        * 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'];
+               $template = 
Doctrine_Core::getTable($this->model)->getTemplate('NestedSet');
+        $options = $template->option('treeOptions');
+        return isset($options['hasManyRoots']) && $options['hasManyRoots'];
        }
 }

-- 
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