Пример #1
0
 /**
  * Dumps a <revision> section on the output stream, with
  * data filled in from the given database row.
  *
  * @param object $row
  * @return string
  * @access private
  */
 function writeRevision($row, $parse = false)
 {
     global $wgOut, $wgServer, $wgTitle;
     $fname = 'WikiExporter::dumpRev';
     wfProfileIn($fname);
     $out = "    <revision>\n";
     $out .= "      " . wfElement('id', null, strval($row->rev_id)) . "\n";
     $ts = wfTimestamp(TS_ISO_8601, $row->rev_timestamp);
     $out .= "      " . wfElement('timestamp', null, $ts) . "\n";
     if ($row->rev_deleted & Revision::DELETED_USER) {
         $out .= "      " . wfElement('contributor', array('deleted' => 'deleted')) . "\n";
     } else {
         $out .= "      <contributor>\n";
         if ($row->rev_user) {
             $out .= "        " . wfElementClean('username', null, strval($row->rev_user_text)) . "\n";
             $out .= "        " . wfElement('id', null, strval($row->rev_user)) . "\n";
         } else {
             $out .= "        " . wfElementClean('ip', null, strval($row->rev_user_text)) . "\n";
         }
         $out .= "      </contributor>\n";
     }
     if ($row->rev_minor_edit) {
         $out .= "      <minor/>\n";
     }
     if ($row->rev_deleted & Revision::DELETED_COMMENT) {
         $out .= "      " . wfElement('comment', array('deleted' => 'deleted')) . "\n";
     } elseif ($row->rev_comment != '') {
         $out .= "      " . wfElementClean('comment', null, strval($row->rev_comment)) . "\n";
     }
     if ($row->rev_deleted & Revision::DELETED_TEXT) {
         $out .= "      " . wfElement('text', array('deleted' => 'deleted')) . "\n";
     } elseif (isset($row->old_text)) {
         // Raw text from the database may have invalid chars
         $text = strval(Revision::getRevisionText($row));
         //XXADDED html output for syndication
         if ($parse) {
             $head = "<a href=\"" . Title::newMainPage()->getFullUrl() . "\"><img border=\"0\" src=\"http://www.wikihow.com/skins/WikiHow/wikiHow.gif\"></a>\n";
             $head .= "<h1 style='margin-bottom: 0px;'><a href=\"" . $wgServer . "/" . $row->page_title . "\">" . wfMsg('howto', preg_replace('/-/', ' ', $row->page_title)) . "</a></h1>\n";
             $head .= wfMsg('republish_taglinelink', Title::newMainPage()->getFullUrl()) . "<br/>\n";
             $title = Title::makeTitle($row->page_namespace, $row->page_title);
             $wgTitle = $title;
             //XXADDED Categories in HTML PArse section
             $categories = $title->getParentCategories();
             $keys = array_keys($categories);
             $category = str_replace("Category:", "", $keys[0]);
             $head .= "Category: <a href=\"" . $wgServer . "/" . $keys[0] . "\">" . $category . "</a><br/>\n";
             #if (preg_match_all('/\[\[Category:(.*?)\]\]/', $text, $matches)) {
             #	for ($i=1; $i<count($matches); $i++) {
             #		$category = str_replace(" ", "-", $matches[$i][0]);
             #		$head .= "Category: <a href=\"". $wgServer ."/Category:". $category ."\">". $category ."</a><br/>\n";
             #	}
             #}
             $user = new User();
             $parser = new Parser();
             $options = ParserOptions::newFromUser($user);
             $pout = $parser->parse($text, $title, $options);
             $text = str_replace('href="/', 'href="' . $wgServer . '/', $pout->getText());
             $text = strip_tags($text, '<b><i><h1><h2><ol><ul><li><a>');
             $text = $text . "\n" . wfMsg('republish_footer', wfMsg('howto', preg_replace('/-/', ' ', $row->page_title)), $wgServer . "/" . $row->page_title);
             $text = "<![CDATA[\n" . $head . "\n" . $text . "\n]]>";
             $out .= "      " . '<text>' . "\n";
             $out .= $text;
             $out .= "\n      " . '</text>' . "\n";
         } else {
             $out .= "      " . wfElementClean('text', array('xml:space' => 'preserve'), strval($text)) . "\n";
         }
     } else {
         // Stub output
         $out .= "      " . wfElement('text', array('id' => $row->rev_text_id), "") . "\n";
     }
     $out .= "    </revision>\n";
     wfProfileOut($fname);
     return $out;
 }
 /**
  * Dumps a <revision> section on the output stream, with
  * data filled in from the given database row.
  *
  * @param object $row
  * @access private
  */
 function dumpRev($row)
 {
     $fname = 'WikiExporter::dumpRev';
     wfProfileIn($fname);
     print "    <revision>\n";
     print "      " . wfElement('id', null, $row->rev_id) . "\n";
     $ts = wfTimestamp2ISO8601($row->rev_timestamp);
     print "      " . wfElement('timestamp', null, $ts) . "\n";
     print "      <contributor>";
     if ($row->rev_user) {
         print wfElementClean('username', null, $row->rev_user_text);
         print wfElement('id', null, $row->rev_user);
     } else {
         print wfElementClean('ip', null, $row->rev_user_text);
     }
     print "</contributor>\n";
     if ($row->rev_minor_edit) {
         print "      <minor/>\n";
     }
     if ($row->rev_comment != '') {
         print "      " . wfElementClean('comment', null, $row->rev_comment) . "\n";
     }
     $text = Revision::getRevisionText($row);
     print "      " . wfElementClean('text', array('xml:space' => 'preserve'), $text) . "\n";
     print "    </revision>\n";
     wfProfileOut($fname);
     if (isset($this->revCallback)) {
         call_user_func($this->revCallback, $row);
     }
 }
Пример #3
0
 /**
  * Dumps a <revision> section on the output stream, with
  * data filled in from the given database row.
  *
  * @param object $row
  * @return string
  * @access private
  */
 function writeRevision($row)
 {
     $fname = 'WikiExporter::dumpRev';
     wfProfileIn($fname);
     $out = "    <revision>\n";
     $out .= "      " . wfElement('id', null, strval($row->rev_id)) . "\n";
     $ts = wfTimestamp(TS_ISO_8601, $row->rev_timestamp);
     $out .= "      " . wfElement('timestamp', null, $ts) . "\n";
     if ($row->rev_deleted & Revision::DELETED_USER) {
         $out .= "      " . wfElement('contributor', array('deleted' => 'deleted')) . "\n";
     } else {
         $out .= "      <contributor>\n";
         if ($row->rev_user) {
             $out .= "        " . wfElementClean('username', null, strval($row->rev_user_text)) . "\n";
             $out .= "        " . wfElement('id', null, strval($row->rev_user)) . "\n";
         } else {
             $out .= "        " . wfElementClean('ip', null, strval($row->rev_user_text)) . "\n";
         }
         $out .= "      </contributor>\n";
     }
     if ($row->rev_minor_edit) {
         $out .= "      <minor/>\n";
     }
     if ($row->rev_deleted & Revision::DELETED_COMMENT) {
         $out .= "      " . wfElement('comment', array('deleted' => 'deleted')) . "\n";
     } elseif ($row->rev_comment != '') {
         $out .= "      " . wfElementClean('comment', null, strval($row->rev_comment)) . "\n";
     }
     if ($row->rev_deleted & Revision::DELETED_TEXT) {
         $out .= "      " . wfElement('text', array('deleted' => 'deleted')) . "\n";
     } elseif (isset($row->old_text)) {
         // Raw text from the database may have invalid chars
         $text = strval(Revision::getRevisionText($row));
         $out .= "      " . wfElementClean('text', array('xml:space' => 'preserve'), strval($text)) . "\n";
     } else {
         // Stub output
         $out .= "      " . wfElement('text', array('id' => $row->rev_text_id), "") . "\n";
     }
     $out .= "    </revision>\n";
     wfProfileOut($fname);
     return $out;
 }