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

Source for file content_history_inc.php

Documentation is available at content_history_inc.php

  1. <?php
  2. /**
  3.  * @version  $Revision$
  4.  * @package  liberty
  5.  * @subpackage functions
  6.  */
  7.  
  8.  
  9. $gBitSmarty->assign( 'source', 0 );
  10. // If we have to include a preview please show it
  11. $gBitSmarty->assign( 'preview', FALSE );
  12. $gBitSmarty->assign( 'compare', 'n' );
  13. $gBitSmarty->assign( 'diff2', 'n' );
  14.  
  15. if( isset( $_REQUEST["delete"] ) && isset( $_REQUEST["hist"] )) {
  16.     foreach( array_keys( $_REQUEST["hist"] ) as $version ) {
  17.         $gContent->expungeVersion( $version );
  18.     }
  19.  
  20. } elseif( isset( $_REQUEST['source'] )) {
  21.     $gBitSmarty->assign( 'source', $_REQUEST['source'] );
  22.     if( $_REQUEST['source'] == 'current' ) {
  23.         $gBitSmarty->assign( 'sourcev', nl2br( htmlentities( $gContent->mInfo["data"] )));
  24.     } else {
  25.         $version = $gContent->getHistory( $_REQUEST["source"] );
  26.         $gBitSmarty->assign( 'sourcev', nl2br( htmlentities( $version["data"][0]["data"] )));
  27.     }
  28.  
  29. } elseif( @BitBase::verifyId( $_REQUEST["preview"] )) {
  30.     if( $version = $gContent->getHistory( $_REQUEST["preview"] )) {
  31.         $version['data'][0]['no_cache'] = TRUE;
  32.         $version['data'][0]['parsed_data'] = $gContent->parseData( $version["data"][0] );
  33.         $gBitSmarty->assign_by_ref( $smartyContentRef, $version['data'][0] );
  34.         $gBitSmarty->assign_by_ref( 'version', $_REQUEST["preview"] );
  35.     }
  36.  
  37. } elseif( @BitBase::verifyId( $_REQUEST["diff2"] ) ) {
  38.     $from_version = $_REQUEST["diff2"];
  39.     $from_page = $gContent->getHistory( $from_version );
  40.     $from_lines = explode( "\n",$from_page["data"][0]["data"] );
  41.     if( isset( $_REQUEST["diff_to"] ) && $_REQUEST["diff_to"] != $gContent->mInfo["version"] ) {
  42.         $to_version = $_REQUEST["diff_to"];
  43.         $to_page = $gContent->getHistory( $to_version );
  44.         $to_lines = explode( "\n",$to_page["data"][0]["data"] );
  45.     } else {
  46.         $to_version = $gContent->mInfo["version"];
  47.         $to_lines = explode( "\n",$gContent->mInfo["data"] );
  48.     }
  49.     /**
  50.      * run 'pear install Text_Diff' to install the library,
  51.      */
  52.     if( $gBitSystem->isFeatureActive( 'liberty_inline_diff' ) && @include_once( 'Text/Diff.php' )) {
  53.         include_once( 'Text/Diff/Renderer/inline.php' );
  54.         $diff = new Text_Diff( $from_lines, $to_lines );
  55.         $renderer = new Text_Diff_Renderer_inline();
  56.         $html = $renderer->render( $diff );
  57.     } else {
  58.         include_once( UTIL_PKG_PATH.'diff.php');
  59.         $diffx = new WikiDiff( $from_lines,$to_lines );
  60.         $fmt = new WikiUnifiedDiffFormatter;
  61.         $html = $fmt->format( $diffx, $from_lines );
  62.     }
  63.     $gBitSmarty->assign( 'diffdata', $html );
  64.     $gBitSmarty->assign( 'diff2', 'y' );
  65.     $gBitSmarty->assign( 'version_from', $from_version );
  66.     $gBitSmarty->assign( 'version_to', $to_version );
  67.  
  68. } elseif( @BitBase::verifyId( $_REQUEST["compare"] )) {
  69.     $from_version = $_REQUEST["compare"];
  70.     $from_page = $gContent->getHistory( $from_version );
  71.     $from_page['data'][0]['no_cache'] = TRUE;
  72.     $gBitSmarty->assign( 'compare', 'y' );
  73.     $gBitSmarty->assign_by_ref( 'diff_from', $gContent->parseData( $from_page['data'][0] ) );
  74.     $gBitSmarty->assign_by_ref( 'diff_to', $gContent->parseData() );
  75.     $gBitSmarty->assign_by_ref( 'version_from', $from_version );
  76.  
  77. } elseif( @BitBase::verifyId( $_REQUEST["rollback"] )) {
  78.     $gContent->verifyUserPermission( !empty( $rollbackPerm ) ? $rollbackPerm : $gContent->mUpdateContentPerm );
  79.     if( !isset( $_REQUEST["rollback_comment"] )) {
  80.         $_REQUEST["rollback_comment"] = '';
  81.     }
  82.     if( $gContent->rollbackVersion( $_REQUEST["rollback"], $_REQUEST["rollback_comment"] )) {
  83.         bit_redirect( $gContent->getDisplayUrl() );
  84.     }
  85. }
  86.  
  87. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:15 +0000 by phpDocumentor 1.5.0-lsces