Список ревизий


Автор документа

Имя
Сергей

Сайт
http://sergey.vilgelm.googlepages.com/

Взял идею сниппета и написал свой. Этот сниппет выведет список всех ревизий и их авторов. Код нужно вставит в файл node.tpl.php.

<?php
  $revision_view_permission
= FALSE;
  if (
user_access('view revisions') || user_access('administer nodes')) {
   
$revision_view_permission = TRUE;
  }
 
$nr = $node;
  if (
$nr->nid) {
   
$revisions = node_revision_list($nr);
   
$list = array ();
    foreach (
$revisions as $revision) {
     
$list[] = t('!date by !username', array('!date' => (($revision->current_vid > 0 || !$revision_view_permission) ? format_date($revision->timestamp, 'small') : l(format_date($revision->timestamp, 'small'), 'node/'.$nr->nid.'/revisions/'.$revision->vid.'/view')), '!username' => theme('username', $revision)))
        .((
$revision->log != '') ? '<p class="revision-log">'.filter_xss($revision->log).'</p>' : '');
    }
  }
  if (
count($list)) {
   
$output  = '<div class = "node-revisions-list"><span class = "node-revisions-list-header">'.t('Revisions').':</span>';
   
$output .= theme('item_list', $list);
   
$output .= '</div>';

    print
$output;
  }
?>

Выводит текст в виде списка:

* 02/06/2008 - 10:33 от Separator
тест ревизий
* 12/28/2007 - 14:21 от Separator
* 12/26/2007 - 15:51 от Separator
* 12/14/2007 - 18:13 от Separator
* 12/14/2007 - 14:03 от Separator

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.