當前位置: 首頁>>代碼示例>>PHP>>正文


PHP GedcomRecord::getGedcom方法代碼示例

本文整理匯總了PHP中Fisharebest\Webtrees\GedcomRecord::getGedcom方法的典型用法代碼示例。如果您正苦於以下問題:PHP GedcomRecord::getGedcom方法的具體用法?PHP GedcomRecord::getGedcom怎麽用?PHP GedcomRecord::getGedcom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Fisharebest\Webtrees\GedcomRecord的用法示例。


在下文中一共展示了GedcomRecord::getGedcom方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getActionPreview

 /**
  * Default previewer for plugins with no custom preview.
  *
  * @param GedcomRecord $record
  *
  * @return string
  */
 public function getActionPreview(GedcomRecord $record)
 {
     $old_lines = preg_split('/[\\n]+/', $record->getGedcom());
     $new_lines = preg_split('/[\\n]+/', $this->updateRecord($record->getXref(), $record->getGedcom()));
     // Find matching lines using longest-common-subsequence algorithm.
     $lcs = self::longestCommonSubsequence($old_lines, $new_lines, 0, count($old_lines) - 1, 0, count($new_lines) - 1);
     $diff_lines = array();
     $last_old = -1;
     $last_new = -1;
     while ($lcs) {
         list($old, $new) = array_shift($lcs);
         while ($last_old < $old - 1) {
             $diff_lines[] = self::decorateDeletedText($old_lines[++$last_old]);
         }
         while ($last_new < $new - 1) {
             $diff_lines[] = self::decorateInsertedText($new_lines[++$last_new]);
         }
         $diff_lines[] = $new_lines[$new];
         $last_old = $old;
         $last_new = $new;
     }
     while ($last_old < count($old_lines) - 1) {
         $diff_lines[] = self::decorateDeletedText($old_lines[++$last_old]);
     }
     while ($last_new < count($new_lines) - 1) {
         $diff_lines[] = self::decorateInsertedText($new_lines[++$last_new]);
     }
     return '<pre class="gedcom-data">' . self::createEditLinks(implode("\n", $diff_lines)) . '</pre>';
 }
開發者ID:jflash,項目名稱:webtrees,代碼行數:36,代碼來源:BatchUpdateBasePlugin.php

示例2: addClipping

 /**
  * Inserts a clipping into the clipping cart
  *
  * @param GedcomRecord $record
  */
 public function addClipping(GedcomRecord $record)
 {
     if ($record->canShowName()) {
         $this->cart[$record->getTree()->getTreeId()][$record->getXref()] = true;
         // Add directly linked records
         preg_match_all('/\\n\\d (?:OBJE|NOTE|SOUR|REPO) @(' . WT_REGEX_XREF . ')@/', $record->getGedcom(), $matches);
         foreach ($matches[1] as $match) {
             $this->cart[$record->getTree()->getTreeId()][$match] = true;
         }
     }
 }
開發者ID:tunandras,項目名稱:webtrees,代碼行數:16,代碼來源:ClippingsCartController.php

示例3: getActionPreview

 /**
  * Default previewer for plugins with no custom preview.
  *
  * @param GedcomRecord $record
  *
  * @return string
  */
 public function getActionPreview(GedcomRecord $record)
 {
     $old_lines = preg_split('/[\\n]+/', $record->getGedcom());
     $new_lines = preg_split('/[\\n]+/', $this->updateRecord($record->getXref(), $record->getGedcom()));
     $algorithm = new MyersDiff();
     $differences = $algorithm->calculate($old_lines, $new_lines);
     $diff_lines = array();
     foreach ($differences as $difference) {
         switch ($difference[1]) {
             case MyersDiff::DELETE:
                 $diff_lines[] = self::decorateDeletedText($difference[0]);
                 break;
             case MyersDiff::INSERT:
                 $diff_lines[] = self::decorateInsertedText($difference[0]);
                 break;
             default:
                 $diff_lines[] = $difference[0];
         }
     }
     return '<pre class="gedcom-data">' . self::createEditLinks(implode("\n", $diff_lines)) . '</pre>';
 }
開發者ID:tronsmit,項目名稱:webtrees,代碼行數:28,代碼來源:BatchUpdateBasePlugin.php


注:本文中的Fisharebest\Webtrees\GedcomRecord::getGedcom方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。