Ejemplo n.º 1
0
 function rendered(&$event, $param)
 {
     global $ID;
     global $PROJECT_FILES;
     if (isset($PROJECT_FILES) && isset($PROJECT_FILES[$ID])) {
         return;
     }
     Projects_file::remove($ID);
 }
Ejemplo n.º 2
0
 public function auto_dependency($file)
 {
     $pdf = $this->pdf_file($file->id());
     $pdffile = Projects_file::file($pdf);
     if (!$pdffile) {
         return array();
     }
     return array($pdffile->id());
 }
Ejemplo n.º 3
0
 public function xhtml()
 {
     global $ID;
     $ns = getNS($ID);
     list($files, $subprojects) = Projects_file::project_files($ns);
     $generated = array();
     $source = array();
     foreach ($files as $id => $file) {
         if ($file->type() == 'source') {
             $source[$id] = $file;
         } elseif ($file->type() == 'generated') {
             $generated[$id] = $file;
         }
     }
     ksort($generated);
     ksort($source);
     sort($subprojects);
     echo '<h1>Source files</h1>' . DOKU_LF;
     echo '<ul>' . DOKU_LF;
     echo '<li>' . create_button('source') . '</li>' . DOKU_LF;
     foreach ($source as $id => $file) {
         echo '<li>' . html_wikilink($id) . ': ' . download_button($id) . ', ' . delete_button($id) . '</li>' . DOKU_LF;
     }
     echo '</ul>' . DOKU_LF;
     echo '<h1>Generated files</h1>' . DOKU_LF;
     echo '<ul>' . DOKU_LF;
     echo '<li>' . create_button('generated') . '</li>' . DOKU_LF;
     foreach ($generated as $id => $file) {
         $make = make_button($id, $file->status() == PROJECTS_MADE);
         echo '<li>' . html_wikilink($id) . ': ' . download_button($id) . ', ' . delete_button($id) . ', ' . $make . '</li>' . DOKU_LF;
     }
     echo '</ul>' . DOKU_LF;
     echo '<h1>Subprojects</h1>' . DOKU_LF;
     echo '<ul>' . DOKU_LF;
     echo '<li>' . create_button($ID, 'project') . '</li>' . DOKU_LF;
     foreach ($subprojects as $sub) {
         echo '<li><a href="' . wl($sub . ':', array('do' => 'manage_files')) . '">' . noNS($sub) . '</a></li>' . DOKU_LF;
     }
     echo '</ul>' . DOKU_LF;
     if ($ns) {
         $name = getNS($ns);
         $id = $name . ':';
         if (!$name) {
             $id = '/';
             $name = '/ (root)';
         }
         echo '<h1>Parent projects</h1>' . DOKU_LF;
         echo '<ul><li><a href="' . wl($id, array('do' => 'manage_files')) . '">' . $name . '</a></li></ul>' . DOKU_LF;
     }
 }
Ejemplo n.º 4
0
 public function handle()
 {
     global $INPUT;
     global $ID;
     if ($INPUT->has('id')) {
         $id = $INPUT->str('id');
     } else {
         $id = $ID;
     }
     $file = Projects_file::file($id);
     if ($file->is_making()) {
         system('kill ' . $file->status()->pid());
         $file->killed();
     }
     return "show";
 }
Ejemplo n.º 5
0
 /**
  * intercept page deletion
  *
  */
 function toWrite(&$event, $param)
 {
     $rev = $event->data[3];
     // only handle the event if it is the current revision
     if ($rev) {
         return;
     }
     $content = $event->data[0][1];
     if ($content) {
         return;
     }
     $namespace = $event->data[1];
     $name = $event->data[2];
     if ($namespace) {
         $id = $namespace . ':' . $name;
     } else {
         $id = $name;
     }
     Projects_file::remove($id);
 }
Ejemplo n.º 6
0
 public static function dependence($id)
 {
     $file = Projects_file::file($id);
     if ($file) {
         return $file;
     }
     $file = new Projects_file_generated($id);
     $file->analyze();
     if (!$file->maker()) {
         return NULL;
     }
     return $file;
 }
Ejemplo n.º 7
0
 public function __construct($parent, $file)
 {
     global $ID;
     global $REV;
     parent::__construct($parent, 'Summary');
     $list = $this->newElement('ul');
     $this->root->appendChild($list);
     $info = $this->newElement('li');
     $text = ': ' . $file->type() . ' file';
     $info->appendChild($this->loadElement(html_wikilink($ID)));
     $info->appendChild($this->newElement('span', array(), $text));
     $list->appendChild($info);
     $format = 'D M d, Y \\a\\t g:i:s a';
     if (date_default_timezone_get() == 'UTC') {
         $format .= ' e';
     }
     $date = $REV ? $REV : $file->modified_date();
     if (!$date) {
         $meta = Projects_file::file($file->id());
         $date = $meta ? $meta->modified_date() : time();
     }
     $updated = $this->newElement('li', array(), 'modified on: ' . date($format, $date));
     $list->appendChild($updated);
     $actions = $this->newElement('li', array(), "Actions: ");
     $list->appendChild($actions);
     $this->actions = $this->newElement('span');
     $actions->appendChild($this->actions);
     $this->newAction(manage_files_button($ID));
     if (!$REV) {
         $this->newAction(download_button($ID));
     }
     if (auth_quickaclcheck($ID) >= AUTH_DELETE) {
         $this->newAction(delete_button($ID));
     }
     $this->content = $this->newElement('div', array('id' => 'PROJECTS_content'));
     if ($file->is_making()) {
         $time = time() - $file->status()->started();
         $content = '<div id="PROJECTS_progress">The file has been generating for ' . self::format_time($time) . ': ' . kill_button($file->id(), FALSE) . DOKU_LF;
         foreach ($file->status()->made() as $made) {
             $content .= '<div class="success">' . html_wikilink($made) . '</div>' . DOKU_LF;
         }
         $content .= '<div class="notify">' . html_wikilink($file->status()->making()) . '</div>' . DOKU_LF;
         foreach ($file->status()->queue() as $queue) {
             $content .= '<div class="info">' . html_wikilink($queue) . '</div>' . DOKU_LF;
         }
         $this->setContent($content . '</div>');
     } else {
         if (is_array($file->status())) {
             $content = '<div>Error in file generation:' . DOKU_LF;
             foreach ($file->status() as $id => $errors) {
                 foreach ($errors as $error) {
                     $content .= '<div class="error">' . html_wikilink($id) . ': ' . $error . '</div>' . DOKU_LF;
                 }
             }
             $this->setContent($content . '</div>');
         }
     }
     $this->root->appendChild($this->content);
 }
Ejemplo n.º 8
0
 /**
  * a namespace has been deleted
  *
  */
 function deleted(&$event, $param)
 {
     $ns = $event->data[0];
     $path = Projects_file::projects_file_path($ns);
     $this->delete_dir($path);
 }
Ejemplo n.º 9
0
if (!$id) {
    exit;
}
$remake = isset($opts['remake']) ? $opts['remake'] : FALSE;
if (!isset($opts['baseurl'])) {
    exit;
}
define(DOKU_URL, $opts['baseurl']);
define(DOKU_REL, $opts['baseurl']);
require_once dirname(__FILE__) . '/project/file.php';
require_once DOKU_INC . '/inc/init.php';
if (!isset($opts['sectok'])) {
    exit;
}
if (!checkSecurityToken($opts['sectok'])) {
    exit;
}
$user = !isset($opts['user']) ? '' : $opts['user'];
$group = !isset($opts['group']) ? '' : $opts['group'];
$group = explode(':', $group);
if (auth_aclcheck($id, $user, $group) < DOKU_EDIT) {
    exit;
}
$file = Projects_file::file($id);
if ($file->is_making()) {
    return;
}
$result = $file->make(array(), $remake);
if (is_numeric($result)) {
    copy($file->file_path(), mediaFN($file->id()));
}
Ejemplo n.º 10
0
 public function make($file)
 {
     $id = $file->id();
     $command = $this->ld . ' -o ' . $file->file_path();
     $command .= strtolower(substr($id, -2)) == ".a" ? ' -static' : ' -dynamic';
     $os = php_uname("s");
     if ($os == 'Darwin') {
         $command .= ' -macosx_version_min 10.8';
     }
     $deps = array_keys($file->dependency());
     $c = FALSE;
     foreach ($deps as $dep) {
         if (strtolower(substr($dep, -2)) == '.o') {
             $depfile = Projects_file::file($dep);
             if (!$depfile) {
                 return FALSE;
             }
             $dep_deps = $depfile->dependency();
             if ($dep_deps) {
                 foreach ($dep_deps as $depdep => $auto) {
                     if (strtolower(substr($depdep, -2)) == '.c' || strtolower(substr($depdep, -4)) == '.cpp' || strtolower(substr($depdep, -4)) == '.cxx' || strtolower(substr($depdep, -3)) == '.cc') {
                         $c = TRUE;
                         break;
                     }
                 }
             }
         }
         $command .= ' ' . $dep;
     }
     if ($c) {
         $command .= " -lc " . ($os == 'Darwin') ? " -lSystem" : "/lib/crt0.o";
     }
     return $this->run($file, $command);
 }
Ejemplo n.º 11
0
 public function handle()
 {
     global $ID;
     global $INPUT;
     $this->file = Projects_file::file($ID);
     $old_text = $INPUT->post->str($this->old_input_name(), '');
     $old = $this->split($old_text);
     $new_text = $INPUT->post->str($this->new_input_name(), '');
     $new = $this->split($new_text);
     $diff = new Diff($old, $new);
     $now = $this->now();
     if ($new == $now) {
         return "show";
     }
     if ($old != $now) {
         $check = new Diff($old, $now);
         $merged = merge3($diff->edits, $check->edits);
         if ($merged['conflict']) {
             global $MERGED_DIFF;
             $MERGED_DIFF = $merged['merged'];
             return $this->action();
         }
         $diff->edits = $merged['merged'];
         $new = $diff->closing();
     }
     lock($ID);
     $text = $this->update($this->merge($new));
     if ($text === FALSE) {
         msg('file has been changed, cannot save!', -1);
     } else {
         saveWikiText($ID, $text, "");
     }
     unlock($ID);
     return "show";
 }
Ejemplo n.º 12
0
 protected function render_meta(&$renderer, $file)
 {
     // check if the project path exists
     global $ID;
     $ns = getNS($ID);
     $path = Projects_file::projects_file_path($ns, false);
     if (!file_exists($path)) {
         mkdir($path, 0700, true);
     }
     $file = Projects_file::file($ID, $renderer->meta['projectfile']);
     // auto dependency
     $file->analyze();
     $old = Projects_file::file($ID);
     $file->update_from($old);
     unset($renderer->meta['projectfile']);
     global $PROJECT_FILES;
     if (!isset($PROJECT_FILES)) {
         $PROJECT_FILES = array($ID => $file);
     } else {
         $PROJECT_FILES[$ID] = $file;
     }
 }
Ejemplo n.º 13
0
 public function make($history, $force)
 {
     // make the dependencies
     if (is_array($this->status) || $this->status == PROJECTS_MODIFIED) {
         $force = TRUE;
     }
     $result = parent::make($history, $force);
     if (is_array($result)) {
         $this->status = $result;
         $this->modified = TRUE;
         $this->save();
         return $result;
     }
     // now the status has to be PROJECTS_MODIFIED, i.e., it needs to be made.
     if (!$force && $date == $this->modified_date) {
         $this->status = PROJECTS_MADE;
         $this->modified = TRUE;
         $this->save();
         return $this->modified_date;
     }
     $this->rm();
     $this->save();
     if ($this->maker) {
         $maker = Projects_Maker_Manager::manager()->maker($this->maker);
     } else {
         $maker = NULL;
     }
     if (!$maker) {
         $this->add_error('no available maker');
     } else {
         if (!$maker->make($this)) {
             $this->add_error('make failed');
         } else {
             $this->modified_date = time();
             $this->status = PROJECTS_MADE;
             // analyze the content for autodependency
             $deps = Projects_Analyzer_Manager::manager()->auto_dependency($this);
             foreach ($deps as $dep) {
                 $this->dependency[$dep] = TRUE;
             }
         }
     }
     $this->modified = TRUE;
     $this->save();
     return $this->modified_date;
 }