Example #1
0
 /**
  * Returns the upload history of the image. If function was already called earlier in the script, it will return the local cache unless $force is set to true.
  *
  * @access public
  * @param string $dir Which direction to go. Default 'older'
  * @param int $limit Number of revisions to get. Default null (all revisions)
  * @param bool $force Force generation of the cache. Default false (use cache).
  * @return array Upload history.
  */
 public function get_history($dir = 'older', $limit = null, $force = false)
 {
     if (!count($this->history) || $force) {
         $this->history = $this->page->history($limit, $dir);
     }
     return $this->history;
 }
Example #2
0
}
$page->read($_REQUEST['page'], $stamp);
$stamp = $page->meta['stamp'];
// Check for alias:
if ($page->meta['type'] == "alias") {
    pieError("AliasRedirect", array('page' => htmlspecialchars($page->meta['original']), 'alias' => htmlspecialchars($_REQUEST['page'])));
}
// Prepare output:
$data = array('page_count' => 0, 'file_count' => 0);
$data['date'] = date($GLOBALS['pie']['time_format'], $page->meta['stamp']);
$data['author'] = htmlspecialchars($page->meta['author']);
$data['comment'] = "—";
if ($page->meta['comment']) {
    $data['comment'] = htmlspecialchars($page->meta['comment']);
}
$history = $page->history($page->name);
$data['history_count'] = count($history);
$t = 0;
ksort($history);
foreach ($history as $k => $v) {
    $n++;
    if ($stamp == $k) {
        break;
    }
}
$data['history_index'] = $n;
$data['page_count'] = '—';
$data['file_count'] = '—';
if ($page->meta['pages']) {
    $t = explode(" ", $page->meta['pages']);
    $data['page_count'] = count($t);
Example #3
0
 function readPage($name, $stamp)
 {
     $page = new Page();
     if (!$page->isValidName($name)) {
         return false;
     }
     if (!$page->exists($name)) {
         return false;
     }
     if (!$page->read($name, $stamp)) {
         return false;
     }
     if ($page->meta['type'] != 'diff') {
         $page->meta['source'] = $page->source;
         return $page->meta;
     }
     // The specified version is a diff.
     // Track down the latest full version and apply all diffs.
     $work = new Page();
     $meta = $page->meta;
     $meta['source'] = $page->source;
     $todo = array($meta);
     while ($meta['type'] != 'full') {
         if (!isset($meta['parent'])) {
             // Manually determine the predecessor.
             if (!is_array($timeline)) {
                 $history = $work->history($name);
                 ksort($history);
                 $timeline = array_keys($history);
                 unset($history);
             }
             if (!($k = array_search($meta['stamp'], $timeline))) {
                 return false;
             }
             $k--;
             $meta['parent'] = $timeline[$k];
         }
         if (!$work->read($name, $meta['parent'])) {
             return false;
         }
         $meta = $work->meta;
         $meta['source'] = $work->source;
         array_unshift($todo, $meta);
     }
     array_shift($todo);
     $source = $meta['source'];
     foreach ($todo as $meta) {
         $source = $this->undiff($source, $meta['source']);
     }
     $page->meta['source'] = $source;
     return $page->meta;
 }
Example #4
0
    $resource = new Page();
    $resource->name = $_REQUEST['page'];
    if (!$resource->isValidName($_REQUEST['page'])) {
        pieError("PageNameInvalid");
    }
    if (!$resource->exists($_REQUEST['page'])) {
        pieError("PageNotFound");
    }
    if (!$resource->read($_REQUEST['page'], 0)) {
        pieError("SourceReadError");
    }
    if ($resource->meta['type'] == "alias") {
        pieError("AliasRedirect", array('page' => htmlspecialchars($resource->meta['original']), 'alias' => htmlspecialchars($_REQUEST['page'])));
    }
    $context = 'page';
    $history = $resource->history($_REQUEST['page']);
} elseif (@$_REQUEST['file']) {
    // Preparations for files.
    $_REQUEST['file'] = pieGetOption($_REQUEST['file']);
    $resource = new File();
    $resource->name = $_REQUEST['file'];
    if (!$resource->isValidName($_REQUEST['file'])) {
        pieError("FileNameInvalid");
    }
    if (!$resource->exists($_REQUEST['file'])) {
        pieError("FileNotFound");
    }
    if (!$resource->read($_REQUEST['file'], 0)) {
        pieError("FileReadError");
    }
    if ($resource->meta['type'] == "alias") {
Example #5
0
                break;
            default:
                pieError('FormatError');
                break;
        }
    }
    $_REQUEST['from_date'] = date($GLOBALS['pie']['time_format'], $_REQUEST['old']);
    $_REQUEST['to_date'] = date($GLOBALS['pie']['time_format'], $_REQUEST['new']);
    pieNotice('DiffHead', array('from_date' => date($GLOBALS['pie']['time_format'], $_REQUEST['old']), 'from_author' => $old['author'], 'from_comment' => $old['comment'], 'to_date' => date($GLOBALS['pie']['time_format'], $_REQUEST['new']), 'to_author' => $new['author'], 'to_comment' => $new['comment']));
    for ($i = 0; $i < count($from); $i++) {
        print '<tr>' . '<td' . ($from[$i] ? '' : ' class="noChange"') . '>' . $from[$i] . "</td>\n" . '<td' . ($to[$i] ? '' : ' class="noChange"') . '>' . $to[$i] . '</td>' . "</tr>\n";
    }
    pieNotice('DiffTail');
} else {
    // No versions specified => display a history of the page.
    $history = $page->history($_REQUEST['page']);
    $max = count($history);
    if ($_REQUEST['sort'] == 'ascending') {
        ksort($history);
        $n = 1;
        end($history);
        $current = current($history);
        $current = $current['stamp'];
        $previous = prev($history);
        $previous = $previous['stamp'];
    } else {
        krsort($history);
        $n = $max;
        reset($history);
        $current = current($history);
        $current = $current['stamp'];