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


PHP Tree::getNewXref方法代碼示例

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


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

示例1: createMediaObject

 /**
  * Create a new media object, from inline media data.
  *
  * @param int    $level
  * @param string $gedrec
  * @param Tree   $tree
  *
  * @return string
  */
 public static function createMediaObject($level, $gedrec, Tree $tree)
 {
     if (preg_match('/\\n\\d FILE (.+)/', $gedrec, $file_match)) {
         $file = $file_match[1];
     } else {
         $file = '';
     }
     if (preg_match('/\\n\\d TITL (.+)/', $gedrec, $file_match)) {
         $titl = $file_match[1];
     } else {
         $titl = '';
     }
     // Have we already created a media object with the same title/filename?
     $xref = Database::prepare("SELECT m_id FROM `##media` WHERE m_filename = ? AND m_titl = ? AND m_file = ?")->execute(array($file, $titl, $tree->getTreeId()))->fetchOne();
     if (!$xref) {
         $xref = $tree->getNewXref('OBJE');
         // renumber the lines
         $gedrec = preg_replace_callback('/\\n(\\d+)/', function ($m) use($level) {
             return "\n" . ($m[1] - $level);
         }, $gedrec);
         // convert to an object
         $gedrec = str_replace("\n0 OBJE\n", '0 @' . $xref . "@ OBJE\n", $gedrec);
         // Fix Legacy GEDCOMS
         $gedrec = preg_replace('/\\n1 FORM (.+)\\n1 FILE (.+)\\n1 TITL (.+)/', "\n1 FILE \$2\n2 FORM \$1\n2 TITL \$3", $gedrec);
         // Fix FTB GEDCOMS
         $gedrec = preg_replace('/\\n1 FORM (.+)\\n1 TITL (.+)\\n1 FILE (.+)/', "\n1 FILE \$3\n2 FORM \$1\n2 TITL \$2", $gedrec);
         // Create new record
         $record = new Media($xref, $gedrec, null, $tree);
         Database::prepare("INSERT INTO `##media` (m_id, m_ext, m_type, m_titl, m_filename, m_file, m_gedcom) VALUES (?, ?, ?, ?, ?, ?, ?)")->execute(array($xref, $record->extension(), $record->getMediaType(), $record->getTitle(), $record->getFilename(), $tree->getTreeId(), $gedrec));
     }
     return "\n" . $level . ' OBJE @' . $xref . '@';
 }
開發者ID:tronsmit,項目名稱:webtrees,代碼行數:41,代碼來源:FunctionsImport.php


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