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


PHP GedcomRecord::compare方法代码示例

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


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

示例1: eventSortName

 /**
  * Sort a list events for the today/upcoming blocks
  *
  * @param array $a
  * @param array $b
  *
  * @return int
  */
 public static function eventSortName($a, $b)
 {
     if ($a['jd'] == $b['jd']) {
         return GedcomRecord::compare($a['record'], $b['record']);
     } else {
         return $a['jd'] - $b['jd'];
     }
 }
开发者ID:jflash,项目名称:webtrees,代码行数:16,代码来源:Functions.php

示例2: eventsList

 /**
  * Print a list of events
  *
  * This performs the same function as print_events_table(), but formats the output differently.
  *
  * @param int $startjd
  * @param int $endjd
  * @param string $events
  * @param bool $only_living
  * @param string $sort_by
  *
  * @return string
  */
 public static function eventsList($startjd, $endjd, $events = 'BIRT MARR DEAT', $only_living = false, $sort_by = 'anniv')
 {
     global $WT_TREE;
     // Did we have any output?  Did we skip anything?
     $output = 0;
     $filter = 0;
     $filtered_events = array();
     $html = '';
     foreach (FunctionsDb::getEventsList($startjd, $endjd, $events, $WT_TREE) as $fact) {
         $record = $fact->getParent();
         //-- only living people ?
         if ($only_living) {
             if ($record instanceof Individual && $record->isDead()) {
                 $filter++;
                 continue;
             }
             if ($record instanceof Family) {
                 $husb = $record->getHusband();
                 if (is_null($husb) || $husb->isDead()) {
                     $filter++;
                     continue;
                 }
                 $wife = $record->getWife();
                 if (is_null($wife) || $wife->isDead()) {
                     $filter++;
                     continue;
                 }
             }
         }
         $output++;
         $filtered_events[] = $fact;
     }
     // Now we've filtered the list, we can sort by event, if required
     switch ($sort_by) {
         case 'anniv':
             // Data is already sorted by anniversary date
             break;
         case 'alpha':
             uasort($filtered_events, function (Fact $x, Fact $y) {
                 return GedcomRecord::compare($x->getParent(), $y->getParent());
             });
             break;
     }
     foreach ($filtered_events as $fact) {
         $record = $fact->getParent();
         $html .= '<a href="' . $record->getHtmlUrl() . '" class="list_item name2">' . $record->getFullName() . '</a>';
         if ($record instanceof Individual) {
             $html .= $record->getSexImage();
         }
         $html .= '<br><div class="indent">';
         $html .= $fact->getLabel() . ' — ' . $fact->getDate()->display(true);
         if ($fact->anniv) {
             $html .= ' (' . I18N::translate('%s year anniversary', I18N::number($fact->anniv)) . ')';
         }
         if (!$fact->getPlace()->isEmpty()) {
             $html .= ' — <a href="' . $fact->getPlace()->getURL() . '">' . $fact->getPlace()->getFullName() . '</a>';
         }
         $html .= '</div>';
     }
     // Print a final summary message about restricted/filtered facts
     $summary = '';
     if ($endjd == WT_CLIENT_JD) {
         // We're dealing with the Today’s Events block
         if ($output == 0) {
             if ($filter == 0) {
                 $summary = I18N::translate('No events exist for today.');
             } else {
                 $summary = I18N::translate('No events for living individuals exist for today.');
             }
         }
     } else {
         // We're dealing with the Upcoming Events block
         if ($output == 0) {
             if ($filter == 0) {
                 if ($endjd == $startjd) {
                     $summary = I18N::translate('No events exist for tomorrow.');
                 } else {
                     // I18N: translation for %s==1 is unused; it is translated separately as “tomorrow”
                     $summary = I18N::plural('No events exist for the next %s day.', 'No events exist for the next %s days.', $endjd - $startjd + 1, I18N::number($endjd - $startjd + 1));
                 }
             } else {
                 if ($endjd == $startjd) {
                     $summary = I18N::translate('No events for living individuals exist for tomorrow.');
                 } else {
                     // I18N: translation for %s==1 is unused; it is translated separately as “tomorrow”
                     $summary = I18N::plural('No events for living people exist for the next %s day.', 'No events for living people exist for the next %s days.', $endjd - $startjd + 1, I18N::number($endjd - $startjd + 1));
                 }
//.........这里部分代码省略.........
开发者ID:tunandras,项目名称:webtrees,代码行数:101,代码来源:FunctionsPrintLists.php

示例3: sortByNameAndChangeDate

 /**
  * Sort the records by (1) name and (2) last change date
  *
  * @param GedcomRecord $a
  * @param GedcomRecord $b
  *
  * @return int
  */
 private static function sortByNameAndChangeDate(GedcomRecord $a, GedcomRecord $b)
 {
     return GedcomRecord::compare($a, $b) ?: $b->lastChangeTimestamp(true) - $a->lastChangeTimestamp(true);
 }
开发者ID:tronsmit,项目名称:webtrees,代码行数:12,代码来源:RecentChangesModule.php

示例4: compareClippings

 /**
  * Helper function to sort records by type/name
  *
  * @param string $a
  * @param string $b
  *
  * @return int
  */
 private static function compareClippings($a, $b)
 {
     global $WT_TREE;
     $a = GedcomRecord::getInstance($a, $WT_TREE);
     $b = GedcomRecord::getInstance($b, $WT_TREE);
     if ($a && $b) {
         switch ($a::RECORD_TYPE) {
             case 'INDI':
                 $t1 = 1;
                 break;
             case 'FAM':
                 $t1 = 2;
                 break;
             case 'SOUR':
                 $t1 = 3;
                 break;
             case 'REPO':
                 $t1 = 4;
                 break;
             case 'OBJE':
                 $t1 = 5;
                 break;
             case 'NOTE':
                 $t1 = 6;
                 break;
             default:
                 $t1 = 7;
                 break;
         }
         switch ($b::RECORD_TYPE) {
             case 'INDI':
                 $t2 = 1;
                 break;
             case 'FAM':
                 $t2 = 2;
                 break;
             case 'SOUR':
                 $t2 = 3;
                 break;
             case 'REPO':
                 $t2 = 4;
                 break;
             case 'OBJE':
                 $t2 = 5;
                 break;
             case 'NOTE':
                 $t2 = 6;
                 break;
             default:
                 $t2 = 7;
                 break;
         }
         if ($t1 != $t2) {
             return $t1 - $t2;
         } else {
             return GedcomRecord::compare($a, $b);
         }
     } else {
         return 0;
     }
 }
开发者ID:tunandras,项目名称:webtrees,代码行数:69,代码来源:ClippingsCartController.php


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