예제 #1
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());
 }
예제 #2
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";
 }
예제 #3
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;
 }
예제 #4
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);
 }
예제 #5
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()));
}
예제 #6
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);
 }
예제 #7
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";
 }
예제 #8
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;
     }
 }