当前位置: 首页>>代码示例>>PHP>>正文


PHP Revision::decompressRevisionText方法代码示例

本文整理汇总了PHP中Revision::decompressRevisionText方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::decompressRevisionText方法的具体用法?PHP Revision::decompressRevisionText怎么用?PHP Revision::decompressRevisionText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Revision的用法示例。


在下文中一共展示了Revision::decompressRevisionText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getEdits

 public static function getEdits($articleId)
 {
     $dbr = wfGetDB(DB_SLAVE);
     $gr = 0;
     $gr = $dbr->selectField('good_revision', array('gr_rev'), array('gr_page' => $articleId));
     $edits = self::getSigEdits($gr);
     if ($edits) {
         return $edits;
     }
     $res = $dbr->select(array('revision', 'text'), array('rev_id', 'old_text', 'old_flags', 'rev_timestamp', 'rev_user', 'rev_user_text'), array('rev_page' => $articleId, 'rev_text_id = old_id'), __METHOD__, array('order by' => 'rev_timestamp asc'));
     $txts = array();
     $grTxt = false;
     foreach ($res as $row) {
         $flags = explode(',', $row->old_flags);
         $rowText = Revision::decompressRevisionText($row->old_text, $flags);
         $stepsSection = Wikitext::getStepsSection($rowText);
         //print("Got txt for rev" . $row->rev_id . "\n");
         $txts[] = array('text' => $stepsSection[0], 'rev_page' => $row->rev_page, 'rev_id' => $row->rev_id, 'rev_user' => $row->rev_user, 'rev_user_text' => $row->rev_user_text);
         if ($row->rev_id == $gr) {
             $grTxt = $stepsSection[0];
             break;
         }
     }
     if (!$grText) {
         $grText = $txts[sizeof($txts) - 1]['text'];
         $gr = $txts[sizeof($txts) - 1]['rev_id'];
     }
     global $wgContLang;
     $segmentedGr = $wgContLang->segmentForDiff($grText);
     $grArr = explode("\n", $segmentedGr);
     $grSize = strlen($segmentedGr) - sizeof($grArr) + 1;
     // Amount added
     $added = 0;
     $edits = array();
     $first = true;
     $lastAdds = 0;
     foreach ($txts as $txt) {
         $txtArr = explode("\n", $wgContLang->segmentForDiff($txt['text']));
         //print("diff for rev " . $txt['rev_id'] . " " . wfTimestampNow() . "\n");
         $diffs = new Diff($txtArr, $grArr);
         $adds = 0;
         foreach ($diffs as $diff) {
             foreach ($diff as $d) {
                 if ($d->type == 'copy') {
                     foreach ($d->closing as $cl) {
                         $adds += strlen($cl);
                     }
                 } elseif ($d->type == 'change') {
                     $wld = new WordLevelDiff($d->orig, $d->closing);
                     foreach ($wld->edits as $edit) {
                         if ($edit->type == 'copy') {
                             foreach ($edit->orig as $o) {
                                 $adds += strlen($o);
                             }
                         }
                     }
                 }
             }
         }
         if ($adds > $added) {
             $newAdded = $adds - $added;
             $added = $adds;
         } else {
             $newAdded = 0;
         }
         if ($newAdded > 0) {
             // First edit or didn't add steps
             // This prevents counting the steps section formatting fix as a contributor
             if ($first || $lastAdds != 0) {
                 $edits[] = array('added' => $newAdded, 'gr' => $gr, 'rev' => $txt['rev_id'], 'page' => $txt['page_id'], 'user' => $txt['rev_user'], 'username' => $txt['rev_user_text']);
             }
         }
         $first = false;
         $lastAdds = $adds;
     }
     if ($edits) {
         self::saveSigEdits($edits);
     }
     return $edits;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:80,代码来源:SuccessfulEdit.class.php

示例2: getContentRaw

 /**
  * @return string
  */
 public function getContentRaw()
 {
     if ($this->decompressedContent === null) {
         $this->decompressedContent = \Revision::decompressRevisionText($this->content, $this->flags);
     }
     return $this->decompressedContent;
 }
开发者ID:TarLocesilion,项目名称:mediawiki-extensions-Flow,代码行数:10,代码来源:AbstractRevision.php


注:本文中的Revision::decompressRevisionText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。