wiki
[ class tree: wiki ] [ index: wiki ] [ all elements ]

Source for file article_history.php

Documentation is available at article_history.php

  1. <?php
  2. /**
  3.  * $Header: /cvsroot/bitweaver/_bit_wiki/page_history.php,v 1.14 2006/05/12 20:33:25 sylvieg Exp $
  4.  *
  5.  * Copyright (c) 2004 bitweaver.org
  6.  * Copyright (c) 2003 tikwiki.org
  7.  * Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
  8.  * All Rights Reserved. See copyright.txt for details and a complete list of authors.
  9.  * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
  10.  *
  11.  * $Id: page_history.php,v 1.14 2006/05/12 20:33:25 sylvieg Exp $
  12.  * @package wiki
  13.  * @subpackage functions
  14.  */
  15.  
  16. /**
  17.  * required setup
  18.  */
  19. require_once'../bit_setup_inc.php' );
  20. require_onceARTICLES_PKG_PATH.'BitArticle.php' );
  21.  
  22. $gBitSystem->verifyPackage'articles' );
  23. $gBitSystem->verifyPermission'p_articles_read'tra"Permission denied you cannot browse this article history" ) );
  24. $gBitSystem->verifyPermission'p_articles_read_history'tra"Permission denied you cannot browse this article history" ) );
  25.  
  26. if!isset$_REQUEST["article_id") ) {
  27.     $gBitSmarty->assign'msg'tra"No article indicated" ) );
  28.     $gBitSystem->display"error.tpl" );
  29.     die;
  30. }
  31.  
  32. include_onceARTICLES_PKG_PATH.'lookup_article_inc.php' );
  33.  
  34. //vd($gContent->mPageId);vd($gContent->mInfo);
  35. if!$gContent->isValid(|| empty$gContent->mInfo ) ) {
  36.     $gBitSystem->fatalError"Unknown article" );
  37. }
  38.  
  39. // additionally we need to check if this article is a submission and see if user has perms to view it.
  40. if$gContent->getField'status_id' != ARTICLE_STATUS_APPROVED && !$gBitUser->hasPermission'p_articles_edit_submission' || $gBitUser->hasPermission'p_articles_edit_submission' || $gBitUser->hasPermission'p_articles_edit_submission' || $gBitUser->isAdmin() ) ) {
  41.     $gBitSmarty->assign'msg'tra"Permission denied you cannot view this article" ) );
  42.     $gBitSystem->display"error.tpl" );
  43.     die;
  44. }
  45.  
  46. $gBitSmarty->assign('source'0);
  47. // If we have to include a preview please show it
  48. $gBitSmarty->assign('preview'false);
  49. $gBitSmarty->assign('compare''n');
  50. $gBitSmarty->assign('diff2''n');
  51. if (isset($_REQUEST["delete"]&& isset($_REQUEST["hist"])) {
  52.     foreach (array_keys($_REQUEST["hist"])as $version{
  53.         $gContent->expungeVersion$version );
  54.     }
  55. elseif (isset($_REQUEST['source'])) {
  56.     $gBitSmarty->assign('source'$_REQUEST['source']);
  57.     if ($_REQUEST['source'== 'current'{
  58.         $gBitSmarty->assign('sourcev'nl2br(htmlentities($gContent->mInfo['data'])));
  59.     else {
  60.         $version $gContent->getHistory($_REQUEST["source"]);
  61.         $gBitSmarty->assign('sourcev'nl2br(htmlentities($version[0]["data"])));
  62.     }
  63. elseif (isset($_REQUEST["preview"])) {
  64.     if$version $gContent->load($_REQUEST["preview"])) {
  65.         $gContent->parseData();
  66.         //$gBitSmarty->assign_by_ref('parsed', $gContent->parseData( $version[0] ) );
  67.         $gBitSmarty->assign_by_ref('version'$_REQUEST["preview"]);
  68.         $gBitSmarty->assign_by_ref('article'$gContent->mInfo );
  69.  
  70.     }
  71. elseifisset$_REQUEST["diff2") ) {
  72.     $from_version $_REQUEST["diff2"];
  73.     $from_page $gContent->getHistory$from_version );
  74.     $from_lines explode("\n",$from_page[0]["data"]);
  75.     $to_version $gContent->mInfo["version"];
  76.     $to_lines explode("\n",$gContent->mInfo["data"]);
  77.  
  78.     include_onceWIKI_PKG_PATH.'diff.php');
  79.     $diffx new WikiDiff($from_lines,$to_lines);
  80.     $fmt new WikiUnifiedDiffFormatter;
  81.     $html $fmt->format($diffx$from_lines);
  82.     $gBitSmarty->assign('diffdata'$html);
  83.     $gBitSmarty->assign('diff2''y');
  84.     $gBitSmarty->assign('version_from'$from_version);
  85.     $gBitSmarty->assign('version_to'$to_version);
  86.  
  87. elseifisset$_REQUEST["compare") ) {
  88.     $from_version $_REQUEST["compare"];
  89.     $from_page $gContent->getHistory($from_version);
  90.     $gBitSmarty->assign('compare''y');
  91.     $gBitSmarty->assign_by_ref('diff_from'$gContent->parseData$from_page[0) );
  92.     $gBitSmarty->assign_by_ref('diff_to'$gContent->parseData() );
  93.     $gBitSmarty->assign_by_ref('version_from'$from_version);
  94. elseif (isset($_REQUEST["rollback"])) {
  95.     if$version $gContent->getHistory$_REQUEST["preview") ) {
  96.         $gBitSmarty->assign_by_ref('parsed'$gContent->parseData$version[0) );
  97.         $gBitSmarty->assign_by_ref('version'$_REQUEST["preview"]);
  98.     }
  99. }
  100.  
  101. // pagination stuff
  102. $gBitSmarty->assign'page'$page !empty$_REQUEST['page'$_REQUEST['page');
  103. $offset $page $gBitSystem->getConfig'max_records' );
  104. $history $gContent->getHistoryNULLNULL$offset$gBitSystem->getConfig'max_records' ) );
  105. $gBitSmarty->assign_by_ref'history'$history );
  106.  
  107. //vd($gContent->getHistoryCount());
  108. // calculate page number
  109.  
  110. $numPages ceil$gContent->getHistoryCount($gBitSystem->getConfig('max_records'20) );
  111. $gBitSmarty->assign'numPages'$numPages );
  112.  
  113.  
  114. // Display the template
  115. $gBitSmarty->assign_by_ref'gContent'$gContent );
  116. $gBitSystem->display'bitpackage:articles/article_history.tpl');
  117. ?>

Documentation generated on Thu, 15 Feb 2007 20:28:32 +0000 by phpDocumentor 1.3.0