Exemplo n.º 1
0
 protected function composeEditor($o)
 {
     $o = self::composeReader($o);
     if (!empty($o->is_binary)) {
         unset($o->is_binary, $o->is_auth_edit);
         $o = $this->composeReader($o);
     } else {
         $this->editorTemplate && ($this->template = $this->editorTemplate);
         $f = new pForm($o);
         $f->add('textarea', 'code', array('default' => $o->text));
         $send = $f->add('submit', 'save');
         $send->attach('code', '', '');
         if ($send->isOn()) {
             $code = $send->getData();
             $code = $code['code'];
             if ('' !== $code && "\n" !== substr($code, -1)) {
                 $code .= "\n";
             }
             file_put_contents($this->realpath, $code);
             pStudio::syncCache($this->path, $this->depth);
             Patchwork::redirect();
         }
         unset($o->text);
     }
     return $o;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 function filterApp($o)
 {
     $depth = PATCHWORK_PATH_LEVEL - $o->KEY;
     $o = (object) array('name' => pStudio::getAppname($depth), 'depth' => $depth, 'path' => $o->VALUE);
     return $o;
 }