3 Replies Latest reply on Sep 21, 2011 10:36 PM by daslicht

    populating MX:Tree with Directory Structure using PHP

    daslicht Level 2

      Hello,

      I have written the following php function to return the directory structure :

       

           public function get_dir_iterative()
           {
                $dir = 'data'; 
                $exclude = array( 'cgi-bin', '.', '..' );
                $folders = '<?xml version="1.0"?>';
                $folders .= "<node label='Root' path=\"data\">";
                //$folders .= $this->getFolderRecuring("data");
           
                
                $exclude = array_flip($exclude);
                
                $dh = opendir($dir);
                
                //$stack = array($dh);
                //$level = 0;
                          //closedir(array_shift($stack));
      
      
                
                while(count($stack))
                {
                     if(false !== ( $file = readdir( $stack[0] ) ) )
                     {
                          if(!isset($exclude[$file]))
                          {
                               if(is_dir($dir . '/' . $file))
                               {
                                    $dh = opendir($dir . '/' . $file);
                                    if($dh)
                                    {
                                         $folders .= "<node label=\"$file\" path=\"$dir/\" isBranch=\"true\" />";
                                         array_unshift($stack, $dh);
                                         ++$level;
                                    }
                               }
                               else 
                               {
                                    $folders .= "<node label=\"$file\" path=\"$dir/\">";
                               }
                          }
                     }
                     else 
                     {
                          closedir(array_shift($stack));
                          --$level;
                     }
                }
                $folders .= "</node>";
                return $folders;
                
           }
      }
      
      

       

      When I test this function manually it returns the proper structure.

       

      But when I call it with help of ZendAMF there is nothing returned and the sandclock is spinning infinite ?!

       

      here is the flex part:

       

      private var fms:RemoteObject = new RemoteObject();
      protected function initFileManagerService():void
      {
           fms.destination ='zend';
           fms.source='FileManagerService';
           fms.showBusyCursor=true;
           fms.addEventListener( FaultEvent.FAULT, faultListener);          
           fms.get_dir_iterative.addEventListener( ResultEvent.RESULT, load_result );               
           trace('FileManagerService initialized');
                     
      }
      public function load():void
      {
           fms.get_dir_iterative();
           trace('Service / load');
      }
           private function load_result( e:ResultEvent ):void
           {          
                trace('result:'+e.result)                    
           }          
      

       

       

       

      My zend setup is working, any idea what could be wrong ?