<?php // -*-php-*- ?>
<!-- $Id: info.tmpl,v 1.18 2005/02/02 19:02:10 rurban Exp $ -->
<?php

$modifed = $WikiTheme->formatDateTime($revision->get('mtime'));

$dbi = $request->getDbh();
$author = $revision->get('author');
$authorLink = $author;
if ($dbi->isWikiPage($author))
    $authorLink = WikiLink($author);

$authorId = $revision->get('author_id');
$version = $revision->getVersion();
$hits = $page->get('hits');

$is_minor_edit = $revision->get('is_minor_edit') ? _("minor edit") : false;
if ($minor_flag = $is_minor_edit) {
    $minor_flag = HTML(" ",
                       HTML::span(array('class' => 'pageinfo-minoredit'),
                                  "(" . _("minor edit") . ")"));
}

/* better way to do this? */
$bytes = strlen($revision->_data['%content']);
$size = ByteFormatter($bytes, /* $longformat = */true);
// Count words
preg_match_all('/\\w+\\W*/', $revision->_data['%content'], $whitespacematches);
if (1 == ($c = count_all($whitespacematches)))
  $wordcount = fmt("1 word");
else
  $wordcount = fmt("%s words", $c);


$markupVersion = ($markupVersion = $revision->get('markup'))
               ? fmt("Version %s", $markupVersion)
               : _("Original (1.2 or 1.0)");

$summary = HTML::textarea(array('name' => 'summary',
                                'class' => 'summary',
                                /* use fixed dimensions? */
                                'rows' => $request->getPref('editHeight')/4,
                                'cols' => $request->getPref('editWidth')/2,
                                'readonly' => 'readonly',
                                'wrap' => 'virtual'), /* for Netscape 4 */
                          $revision->get('summary'));

if ($is_current = $revision->isCurrent()) {

    $LOCKED_CB = HTML::input(array('type' => 'checkbox',
                                   'name' => 'edit[locked]',
                                   'disabled' => !$user->isadmin(),
                                   'checked'  => $page->get('locked')));

    // Not sure if I want to keep this... --Carsten
    if ($user->isAdmin()) {
        $lockunlock = $page->get('locked') ? 'unlock' : 'lock';
        $clickcheckbUrl = WikiURL($revision, array('action' => $lockunlock));
        $clickcheckb = "location.href='$clickcheckbUrl'";

        $LOCKED_CB->setAttr('onclick', $clickcheckb);
    }

    $label['date'] = _("Last Modified").':';
    $label['author'] = _("Last Author").':';
    $label['summary'] = _("Last Summary").':';

} else {
    $label['date'] = _("Saved on:");
    $label['author'] = _("Author").':';
    $label['summary'] = _("Summary").':';
}

$tableSummary = fmt("Statistics about %s.", $page->getName());
$Sep = $WikiTheme->getButtonSeparator();

?>

<!-- FIXME: move table formatting to css -->
<table summary="<?= $tableSummary ?>" class="pageinfo"
       border="0" cellspacing="0" cellpadding="3">

<?php if (!$is_current) { ?>
  <tr>
    <td align="right" class="pageinfo"><?=_("Supplanted on:")?></td>
    <td><?= $WikiTheme->formatDateTime($revision->get('_supplanted')) ?></td>
  </tr>
<?php } ?>

  <tr>
    <td align="right" nowrap="nowrap" class="pageinfo"><?= $label['date'] ?></td>
    <td><?= $modifed ?><?= $minor_flag ?></td>
  </tr>
  <tr>
    <td align="right" class="pageinfo"><?= $label['author'] ?></td>
    <td><?= $authorLink ?>
<?php if (! ($author == $authorId)) { 
    if ($dbi->isWikiPage($authorId)) $authorId = WikiLink($authorId); ?>
        <span class="pageinfo-authorid">(<?= $authorId ?>)</span>
      <?php } ?></td>
  </tr>
  <tr>
    <td align="right" class="pageinfo"><?=_("Page Version:")?></td>
    <td><?= $version ?></td>
  </tr>
  <tr>
    <td align="right" class="pageinfo"><?=_("Markup:")?></td>
    <td><?= $markupVersion ?></td>
  </tr>
  <tr>
    <td align="right" class="pageinfo"><?=_("Size:")?></td>
    <td><?= $wordcount ?>, <?= $size ?></td>
  </tr>
<?php if ($is_current) { ?>
  <tr>
    <td align="right" class="pageinfo"><?= _("Hits:") ?></td>
    <td><?= $hits ?></td>
  </tr>
<?php } ?>
  <tr>
    <td align="right" valign="top" class="pageinfo"><?= $label['summary'] ?></td>
    <td><?= $summary ?></td>
  </tr>
<?php if ($is_current) { ?>
  <tr>
    <td align="right"><?= $LOCKED_CB ?></td>
    <td class="pageinfo"><?=_("Locked")?></td>
  </tr>
<?php } ?>

<?php // determine page type
if (HOME_PAGE == $page->getName()) {
    $pagetype []= sprintf('%s %s', WIKI_NAME, _("home page"));
}
if ($page->isUserPage($include_empty=true)) {
    $pagetype []= _("User page");
}
if (@$request->isActionPage($page->getName())) {
    $pagetype []= _("Action page");
}
if ($page->get('pagetype') == 'wikiblog') {
    $pagetype []= _("Blog page");
}
if ($page->getName() == _("InterWikiMap")) {
    $pagetype []= _("InterWikiMap");
}
if (isSubPage($page->getName())) {
    $pagetype []= _("Subpage");
} ?>

<?php if (!empty($pagetype)) { $pagetype = implode(", ", $pagetype); ?>
  <tr>
    <td align="right" class="pageinfo"><?=_("Page Type:")?></td>
    <td align="left"><?=$pagetype?></td>
  </tr>
<?php } ?>

</table>

<?php
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -                         
// $Log: info.tmpl,v $
// Revision 1.18  2005/02/02 19:02:10  rurban
// link author
//
// Revision 1.17  2004/06/14 11:26:52  rurban
// renamed global $Theme to $WikiTheme (gforge nameclash)
//
// Revision 1.16  2004/05/18 14:47:21  rurban
// Simplified strings for easier translation
//
// Revision 1.15  2003/12/11 19:38:29  carstenklapp
// Internal change: Fix PHP Warning: Call-time pass-by-reference has been deprecated
//
// Revision 1.14  2003/11/29 20:13:38  carstenklapp
// Internal change: Refactored ByteFormatter code into a new function in
// stdlib (now used by PageList too).
//
// Revision 1.13  2003/02/21 04:24:48  dairiki
// Fix <td> </td> nesting. (Was generating invalid HTML.)
//
// Revision 1.12  2003/01/11 22:54:28  carstenklapp
// Added Page type field displayed for special pages.
//
?>
