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

Source for file export_lib.php

Documentation is available at export_lib.php

  1. <?php
  2. /**
  3.  * Copyright (c) 2004 bitweaver.org
  4.  * Copyright (c) 2003 tikwiki.org
  5.  * Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
  6.  * All Rights Reserved. See below for details and a complete list of authors.
  7.  * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
  8.  *
  9.  * @package wiki
  10.  */
  11.  
  12. /**
  13.  * required setup
  14.  */
  15. require_onceKERNEL_PKG_PATH.'BitBase.php' );
  16. require_onceWIKI_PKG_PATH.'BitPage.php' );
  17. /**
  18.  * @package wiki
  19.  * @subpackage ExportLib
  20.  */
  21. class ExportLib extends BitBase {
  22.  
  23.     function MakeWikiZip$pExportFile {
  24.         global $gBitUser,$gBitSystem;
  25.         include_once (UTIL_PKG_PATH."tar.class.php");
  26.         $tar new tar();
  27.         $query "SELECT wp.`page_id` from `".BIT_DB_PREFIX."wiki_pages` wp INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (lc.`content_id` = wp.`content_id`) 
  28.                   ORDER BY lc.".$this->mDb->convertSortmode("title_asc");
  29.         $result $this->mDb->query($query,array());
  30.         while ($res $result->fetchRow()) {
  31.             $page_id $res["page_id"];
  32.             $content $this->export_wiki_page($page_id0);
  33.             $tar->addData($page_id$content$gBitSystem->getUTCTime());
  34.         }
  35.         $tar->toTar$pExportFileFALSE)
  36.         return '';
  37.     }
  38.  
  39.     function export_wiki_page($page_id$nversions 1{
  40.         global $gBitSystem;
  41.         $head '';
  42.         $head .= "Date: " $gBitSystem->mServerTimestamp->get_rfc2822_datetime()"\r\n";
  43.         $head .= sprintf("Mime-Version: 1.0 (Produced by Tiki)\r\n");
  44.         $iter $this->get_page_history($page_id);
  45.         $gWikiPage new BitPage$page_id );
  46.         $gWikiPage->load();
  47.         $info $gWikiPage->mInfo;
  48.         $parts array();
  49.         $parts[MimeifyPageRevision($info);
  50.         if ($nversions || $nversions == 0{
  51.             foreach ($iter as $revision{
  52.                 $parts[MimeifyPageRevision($revision);
  53.                 if ($nversions && count($parts>= $nversions)
  54.                     break;
  55.             }
  56.         }
  57.         if (count($parts1)
  58.             return $head MimeMultipart($parts);
  59.         assert ($parts);
  60.         return $head $parts[0];
  61.     }
  62.  
  63.     // Returns all the versions for this page
  64.     // without the data itself
  65.     function get_page_history($page_id{
  66.         $query "SELECT lc.`title`, th.`description`, th.`version`, th.`last_modified`, th.`user_id`, th.`ip`, th.`data`, th.`history_comment`, uu.`login` as `creator_user`, uu.`real_name` " .
  67.                  "FROM `".BIT_DB_PREFIX."wiki_pages` wp " .
  68.                  "INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (lc.`content_id` = wp.`content_id`) " .
  69.                  "INNER JOIN `".BIT_DB_PREFIX."liberty_content_history` th ON (th.`page_id` = th.`page_id`) " .
  70.                  "INNER JOIN `".BIT_DB_PREFIX."users_users` uu ON (uu.`user_id` = th.`user_id`) " .
  71.                  "WHERE wp.`page_id`=? order by th.".$this->mDb->convertSortmode("version_desc");
  72.         $result $this->mDb->query($query,array($page_id));
  73.         $ret array();
  74.         while ($res $result->fetchRow()) {
  75.             array_push$ret$res );
  76.         }
  77.         return $ret;
  78.     }
  79. }
  80. $exportlib new ExportLib();
  81. ?>

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