示例#1
0
 function export_wiki_page($pageName, $nversions = 1, $showLatest = false)
 {
     global $prefs;
     $head = '';
     $head .= 'Date: ' . $this->date_format('%a, %e %b %Y %H:%M:%S %O') . "\r\n";
     $head .= sprintf("Mime-Version: 1.0 (Produced by Tiki)\r\n");
     $info = $this->get_page_info($pageName);
     if ($prefs['flaggedrev_approval'] == 'y') {
         $flaggedrevisionlib = TikiLib::lib('flaggedrevision');
         if (!$showLatest && $flaggedrevisionlib->page_requires_approval($pageName)) {
             $data = $flaggedrevisionlib->get_version_with($pageName, 'moderation', 'OK');
             $info['data'] = '';
             if ($data) {
                 $info['data'] = $data['data'];
             }
         }
     }
     $parts = array();
     $parts[] = MimeifyPageRevision($info);
     if ($nversions > 1 || $nversions == 0) {
         $iter = $this->get_page_history($pageName);
         foreach ($iter as $revision) {
             $parts[] = MimeifyPageRevision($revision);
             if ($nversions > 0 && count($parts) >= $nversions) {
                 break;
             }
         }
     }
     if (count($parts) > 1) {
         return $head . MimeMultipart($parts);
     }
     assert($parts);
     return $head . $parts[0];
 }
示例#2
0
 function export_wiki_page($page_id, $nversions = 1)
 {
     global $gBitSystem;
     $head = '';
     $head .= "Date: " . $gBitSystem->mServerTimestamp->get_rfc2822_datetime() . "\r\n";
     $head .= sprintf("Mime-Version: 1.0 (Produced by Tiki)\r\n");
     $iter = $this->get_page_history($page_id);
     $gWikiPage = new BitPage($page_id);
     $gWikiPage->load();
     $info = $gWikiPage->mInfo;
     $parts = array();
     $parts[] = MimeifyPageRevision($info);
     if ($nversions > 1 || $nversions == 0) {
         foreach ($iter as $revision) {
             $parts[] = MimeifyPageRevision($revision);
             if ($nversions > 0 && count($parts) >= $nversions) {
                 break;
             }
         }
     }
     if (count($parts) > 1) {
         return $head . MimeMultipart($parts);
     }
     assert($parts);
     return $head . $parts[0];
 }
示例#3
0
 function export_wiki_page($pageName, $nversions = 1)
 {
     $head = '';
     $head .= "Date: " . $this->get_rfc2822_datetime() . "\r\n";
     $head .= sprintf("Mime-Version: 1.0 (Produced by Tiki)\r\n");
     $iter = $this->get_page_history($pageName);
     $info = $this->get_page_info($pageName);
     $parts = array();
     $parts[] = MimeifyPageRevision($info);
     if ($nversions > 1 || $nversions == 0) {
         foreach ($iter as $revision) {
             $parts[] = MimeifyPageRevision($revision);
             if ($nversions > 0 && count($parts) >= $nversions) {
                 break;
             }
         }
     }
     if (count($parts) > 1) {
         return $head . MimeMultipart($parts);
     }
     assert($parts);
     return $head . $parts[0];
 }
示例#4
0
 function _savePageData($pagename, $data)
 {
     $type = 'page_data';
     $version = 1;
     $filename = $this->_pagename2filename($type, $pagename, $version);
     // Construct a dummy page_revision object
     $page = new WikiDB_Page($this->_wikidb, $pagename);
     // data may be pagedate or versiondata updates
     if (USECACHE and empty($data['pagedata'])) {
         $cache =& $this->_wikidb->_cache;
         if (!empty($cache->_pagedata_cache[$pagename]) and is_array($cache->_pagedata_cache[$pagename])) {
             $cachedata =& $cache->_pagedata_cache[$pagename];
             foreach ($data as $key => $val) {
                 $cachedata[$key] = $val;
             }
         } else {
             $cache->_pagedata_cache[$pagename] = $data;
         }
     }
     //unset ($data['pagedata']);
     //if (empty($data['versiondata']))
     //    $data['versiondata'] = $data;
     // TODO:
     //   with versiondata merge it with previous pagedata, not to overwrite with empty pagedata
     //   with pagedata merge it with previous versiondata, not to overwrite with empty versiondata (content)
     $olddata = $this->_loadPageData($pagename);
     if (isset($data['version'])) {
         $version = $data['version'];
         $latestversion = $this->_getLatestVersion($pagename);
         if ($latestversion < $version) {
             $oldversiondata = $this->_loadVersionData($pagename, $latestversion);
             if ($oldversiondata) {
                 $olddata['versiondata'] = array_merge($oldversiondata, $olddata['versiondata']);
             }
         }
     }
     $data['pagedata'] = array_merge($olddata['pagedata'], $data['pagedata']);
     $data['versiondata'] = array_merge($olddata['versiondata'], $data['versiondata']);
     if (empty($data['versiondata']['%content'])) {
         $data['versiondata']['%content'] = $olddata['content'];
     }
     $current = new WikiDB_PageRevision($this->_wikidb, $pagename, $version, $data['versiondata']);
     unset($data['versiondata']);
     foreach ($data as $k => $v) {
         if ($k == 'pagedata') {
             $current->_data = array_merge($current->_data, $v);
         } elseif ($k == 'versiondata') {
             $current->_data = array_merge($current->_data, $v);
         } else {
             $current->_data[$k] = $v;
         }
     }
     $this->_page_data = $current->_data;
     $pagedata = "Date: " . Rfc2822DateTime($current->get('mtime')) . "\r\n";
     $pagedata .= sprintf("Mime-Version: 1.0 (Produced by PhpWiki %s)\r\n", PHPWIKI_VERSION);
     $pagedata .= MimeifyPageRevision($page, $current);
     if ($fd = fopen($filename, 'a+b')) {
         $locked = flock($fd, 2);
         // Exclusive blocking lock
         if (!$locked) {
             ExitWiki("Timeout while obtaining lock. Please try again");
         }
         rewind($fd);
         ftruncate($fd, 0);
         $len = strlen($pagedata);
         $num = fwrite($fd, $pagedata, $len);
         assert($num == $len);
         fclose($fd);
     } else {
         ExitWiki("Error while writing page '{$pagename}'");
     }
 }
示例#5
0
/**
 * For reference see:
 * http://www.nacs.uci.edu/indiv/ehood/MIME/2045/rfc2045.html
 * http://www.faqs.org/rfcs/rfc2045.html
 * (RFC 1521 has been superceeded by RFC 2045 & others).
 *
 * Also see http://www.faqs.org/rfcs/rfc2822.html
 */
function MailifyPage($page, $nversions = 1)
{
    $current = $page->getCurrentRevision();
    $head = '';
    if (STRICT_MAILABLE_PAGEDUMPS) {
        $from = defined('SERVER_ADMIN') ? SERVER_ADMIN : 'foo@bar';
        //This is for unix mailbox format: (not RFC (2)822)
        // $head .= "From $from  " . CTime(time()) . "\r\n";
        $head .= "Subject: " . rawurlencode($page->getName()) . "\r\n";
        $head .= "From: {$from} (PhpWiki)\r\n";
        // RFC 2822 requires only a Date: and originator (From:)
        // field, however the obsolete standard RFC 822 also
        // requires a destination field.
        $head .= "To: {$from} (PhpWiki)\r\n";
    }
    $head .= "Date: " . Rfc2822DateTime($current->get('mtime')) . "\r\n";
    $head .= sprintf("Mime-Version: 1.0 (Produced by PhpWiki %s)\r\n", PHPWIKI_VERSION);
    // This should just be entered by hand (or by script?)
    // in the actual pgsrc files, since only they should have
    // RCS ids.
    //$head .= "X-Rcs-Id: \$Id\$\r\n";
    $iter = $page->getAllRevisions();
    $parts = array();
    while ($revision = $iter->next()) {
        $parts[] = MimeifyPageRevision($page, $revision);
        if ($nversions > 0 && count($parts) >= $nversions) {
            break;
        }
    }
    if (count($parts) > 1) {
        return $head . MimeMultipart($parts);
    }
    assert($parts);
    return $head . $parts[0];
}