Example #1
0
 function compose($o)
 {
     patchworkPath('zcache/', $o->zcacheDepth);
     $app = array();
     foreach ($GLOBALS['patchwork_path'] as $k => $v) {
         pStudio::isAuthApp($v) && ($app[$k] = $v);
     }
     $o->apps = new loop_array($app, array($this, 'filterApp'));
     return $o;
 }
 protected function getSubpaths($dirpath, $low, $high)
 {
     $paths = array();
     $depth = $high;
     $isTop = 1;
     do {
         if (!pStudio::isAuthApp($GLOBALS['patchwork_path'][PATCHWORK_PATH_LEVEL - $depth])) {
             --$depth;
             continue;
         }
         if ('' !== $dirpath) {
             $path = patchworkPath($dirpath, $depth, $depth, 0);
         } else {
             if ($depth < 0) {
                 if (!pStudio::isAuthRead('class')) {
                     break;
                 }
                 if (isset($paths['class'])) {
                     ++$paths['class']['ancestorsNb'];
                 } else {
                     $paths['class'] = array('name' => 'class', 'isTop' => $isTop, 'isDir' => 1, 'ancestorsNb' => 0, 'depth' => $depth);
                 }
                 break;
             } else {
                 $path = $GLOBALS['patchwork_path'][PATCHWORK_PATH_LEVEL - $depth];
             }
         }
         if (!$path || $depth < $low) {
             break;
         }
         $h = @opendir($path);
         if (!$h) {
             break;
         }
         while (false !== ($file = readdir($h))) {
             if ('.' !== $file && '..' !== $file) {
                 if (isset($paths[$file])) {
                     ++$paths[$file]['ancestorsNb'];
                 } else {
                     $isDir = is_dir($path . $file) - 0;
                     if (!pStudio::isAuthRead($dirpath . $file . ($isDir ? '/' : ''))) {
                         continue;
                     }
                     $paths[$file] = array('name' => $file, 'isTop' => $isTop, 'isDir' => $isDir, 'path' => $path . $file, 'ancestorsNb' => 0, 'depth' => $depth, 'appname' => pStudio::getAppname($depth), 'isApp' => $isDir && file_exists($path . $file . '/config.patchwork.php'));
                 }
             }
         }
         closedir($h);
         --$depth;
         $isTop = 0;
     } while ($depth >= $low);
     usort($paths, array($this, 'pathCmp'));
     return $paths;
 }