public function current()
 {
     return parent::getFileName();
 }
Example #2
0
 /**
  * Remove orphan repositories.
  */
 public static function removeOrphanRepositories()
 {
     $path = Pluf::f('idf_plugin_syncgit_base_repositories', '/home/git/repositories');
     if (!is_dir($path) || is_link($path)) {
         throw new Pluf_Exception_SettingError(sprintf('Directory %s does not exist! Setting "idf_plugin_syncgit_base_repositories not set.', $path));
     }
     if (!is_writable($path)) {
         throw new Exception(sprintf('Repository %s is not writable.', $path));
     }
     $projects = array();
     foreach (Pluf::factory('IDF_Project')->getList() as $project) {
         $projects[] = $project->shortname;
     }
     unset($project);
     $it = new DirectoryIterator($path);
     $orphans = array();
     while ($it->valid()) {
         if (!$it->isDot() && $it->isDir() && !in_array(basename($it->getFileName(), '.git'), $projects)) {
             $orphans[] = $it->getPathName();
         }
         $it->next();
     }
     if (count($orphans)) {
         $cmd = Pluf::f('idf_exec_cmd_prefix', '') . 'rm -rf ' . implode(' ', $orphans);
         exec($cmd);
         clearstatcache();
         while (list(, $project) = each($orphans)) {
             if (is_dir($project)) {
                 throw new Exception(sprintf('Cannot remove %s directory.', $project));
             }
         }
     }
 }
Example #3
0
 /**
  *  This function is where all the lookup of the manual entry is.
  *
  *  We are very lazy here: we suppress any errors that the Dom might throw at
  *  us, and we load the XML data as HTML - we're just interested in a particular
  *  node - no need to have a whole document that is valid, as long as we are able
  *  to get to the "methodsynopsis" node.
  *
  *  @param object $file A DirectoryIterator instance
  *  @access private
  *  @return void
  */
 private function processFile(DirectoryIterator $file)
 {
     $dom = new DomDocument();
     @$dom->loadHTML(file_get_contents($file->getPathName()));
     $xpath = new DomXpath($dom);
     // Get the node where the description of the function call is:
     $result = @$xpath->query("//methodsynopsis");
     // Make sure we find a node:
     if ($result->item(0)) {
         $item = $result->item(0);
         if ($this->settings->debug == 1) {
             echo "\tparsing: " . $file->getFileName() . "\n";
         }
         /*
          *	Get the first para in the documentation, this might come
          *	out wrong for some of the functions, but: it's the closest
          *	we can come to something useful.
          */
         $result = @$xpath->query("//para");
         if ($result->item(0)) {
             $para = simplexml_import_dom($result->item(0));
             $desc = $para->asXml();
             // defenently don't need tags for the terminal :)
             $desc = htmlentities(strip_tags($desc));
             // We don't need all the space/newlines around either
             $desc = preg_replace("/[\r\n][\\s]+/", " ", $desc);
             // Some of the functions are undocumented:
             if (strstr($desc, "warn.undocumented.func;")) {
                 $desc = "Undocumented";
             }
             $item->appendChild($dom->createElement("desc", $desc));
         }
         $xml = simplexml_import_dom($item);
         // Set the "function" attribute - this is what we will look for later.
         $xml['function'] = (string) $xml->methodname;
         $result = @$xpath->query("//para");
         $this->buffer .= "\n" . $xml->asXml();
     }
 }
Example #4
0
 public function valid()
 {
     if (!parent::valid()) {
         return false;
     }
     if ($this->isFile() and substr(parent::getFileName(), -4) == '.xml') {
         return false;
     }
     if ($this->isFile() and substr(parent::getFileName(), -8) != '_inserts') {
         return true;
     }
     parent::next();
     return $this->valid();
 }
Example #5
0
 public function readDir()
 {
     $this->processRequest();
     $path = $this->base_path . $this->rel_area . $this->rel_path;
     if (file_exists($path)) {
         $directory = new DirectoryIterator($path);
     } else {
         $this->errorMsg = "{$path} does not exist<br/>";
         return -1;
     }
     $result = array();
     $this->entry_n = 0;
     $this->dir_n = 0;
     $this->file_n = 0;
     $this->entry_max = 0;
     $this->dir_max = 0;
     $this->file_max = 0;
     $param = array($this->param_area => $this->rel_area, $this->param_path => '');
     while ($directory->valid()) {
         $filename = $directory->getFileName();
         if ($directory->isDir()) {
             if ($filename == '..') {
                 if ($this->rel_path == '') {
                     $filename = '.';
                     // don't show
                 } else {
                     $pos = strrpos(trim($this->rel_path, '/'), '/');
                     if ($pos === false) {
                         $dir = '';
                     } else {
                         $dir = substr($this->rel_path, 0, $pos);
                     }
                 }
             } else {
                 $dir = $this->rel_path . $filename;
             }
             if ($filename != '.') {
                 $param[$this->param_path] = $dir;
                 $this->entries[$this->entry_max++] = array('type' => 'dir', 'param' => $param, 'filename' => $filename);
             }
         } else {
             $param[$this->param_path] = $this->rel_path;
             $this->entries[$this->entry_max++] = array('type' => 'file', 'param' => $param, 'filename' => $filename);
         }
         $directory->next();
     }
     if ($this->sort) {
         usort($this->entries, array($this, '_entrySort'));
     }
     for ($i = 0; $i < $this->entry_max; $i++) {
         if ($this->entries[$i]['type'] == 'dir') {
             $this->dirs[$this->dir_max++] = $i;
         } else {
             $this->files[$this->file_max++] = $i;
         }
     }
     return $this->entry_max;
 }