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


PHP Family::getHusband方法代码示例

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


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

示例1: print_indi_form

/**
 * Print a form to add an individual or edit an individual’s name
 *
 * @param string     $nextaction
 * @param Individual $person
 * @param Family     $family
 * @param Fact       $name_fact
 * @param string     $famtag
 * @param string     $gender
 */
function print_indi_form($nextaction, Individual $person = null, Family $family = null, Fact $name_fact = null, $famtag = 'CHIL', $gender = 'U')
{
    global $WT_TREE, $bdm, $controller;
    if ($person) {
        $xref = $person->getXref();
    } elseif ($family) {
        $xref = $family->getXref();
    } else {
        $xref = 'new';
    }
    // Different cultures do surnames differently
    $surname_tradition = SurnameTradition::create($WT_TREE->getPreference('SURNAME_TRADITION'));
    $name_fields = array();
    if ($name_fact) {
        // Editing an existing name
        $name_fact_id = $name_fact->getFactId();
        $name_type = $name_fact->getAttribute('TYPE');
        $namerec = $name_fact->getGedcom();
        foreach (Config::standardNameFacts() as $tag) {
            if ($tag === 'NAME') {
                $name_fields[$tag] = $name_fact->getValue();
            } else {
                $name_fields[$tag] = $name_fact->getAttribute($tag);
            }
        }
        // Populate any missing 2 XXXX fields from the 1 NAME field
        $npfx_accept = implode('|', Config::namePrefixes());
        if (preg_match('/(((' . $npfx_accept . ')\\.? +)*)([^\\n\\/"]*)("(.*)")? *\\/(([a-z]{2,3} +)*)(.*)\\/ *(.*)/i', $name_fields['NAME'], $name_bits)) {
            if (empty($name_fields['NPFX'])) {
                $name_fields['NPFX'] = $name_bits[1];
            }
            if (empty($name_fields['SPFX']) && empty($name_fields['SURN'])) {
                $name_fields['SPFX'] = trim($name_bits[7]);
                // For names with two surnames, there will be four slashes.
                // Turn them into a list
                $name_fields['SURN'] = preg_replace('~/[^/]*/~', ',', $name_bits[9]);
            }
            if (empty($name_fields['GIVN'])) {
                $name_fields['GIVN'] = $name_bits[4];
            }
            if (empty($name_fields['NICK']) && !empty($name_bits[6]) && !preg_match('/^2 NICK/m', $namerec)) {
                $name_fields['NICK'] = $name_bits[6];
            }
        }
    } else {
        // Creating a new name
        $name_fact_id = null;
        $name_type = null;
        $namerec = null;
        // Populate the standard NAME field and subfields
        foreach (Config::standardNameFacts() as $tag) {
            $name_fields[$tag] = '';
        }
        // Inherit surname from parents, spouse or child
        if ($family) {
            $father = $family->getHusband();
            if ($father && $father->getFirstFact('NAME')) {
                $father_name = $father->getFirstFact('NAME')->getValue();
            } else {
                $father_name = '';
            }
            $mother = $family->getWife();
            if ($mother && $mother->getFirstFact('NAME')) {
                $mother_name = $mother->getFirstFact('NAME')->getValue();
            } else {
                $mother_name = '';
            }
        } else {
            $father = null;
            $mother = null;
            $father_name = '';
            $mother_name = '';
        }
        if ($person && $person->getFirstFact('NAME')) {
            $indi_name = $person->getFirstFact('NAME')->getValue();
        } else {
            $indi_name = '';
        }
        switch ($nextaction) {
            case 'add_child_to_family_action':
                $name_fields = $surname_tradition->newChildNames($father_name, $mother_name, $gender) + $name_fields;
                break;
            case 'add_child_to_individual_action':
                if ($person->getSex() === 'F') {
                    $name_fields = $surname_tradition->newChildNames('', $indi_name, $gender) + $name_fields;
                } else {
                    $name_fields = $surname_tradition->newChildNames($indi_name, '', $gender) + $name_fields;
                }
                break;
            case 'add_parent_to_individual_action':
//.........这里部分代码省略.........
开发者ID:jflash,项目名称:webtrees,代码行数:101,代码来源:edit_interface.php

示例2: printFamilyParents

 /**
  * print the parents table for a family
  *
  * @param Family $family family gedcom ID
  * @param int $sosa child sosa number
  * @param string $label indi label (descendancy booklet)
  * @param string $parid parent ID (descendancy booklet)
  * @param string $gparid gd-parent ID (descendancy booklet)
  * @param int $show_full large or small box
  */
 public static function printFamilyParents(Family $family, $sosa = 0, $label = '', $parid = '', $gparid = '', $show_full = 1)
 {
     if ($show_full) {
         $pbheight = Theme::theme()->parameter('chart-box-y') + 14;
     } else {
         $pbheight = Theme::theme()->parameter('compact-chart-box-y') + 14;
     }
     $husb = $family->getHusband();
     if ($husb) {
         echo '<a name="', $husb->getXref(), '"></a>';
     } else {
         $husb = new Individual('M', "0 @M@ INDI\n1 SEX M", null, $family->getTree());
     }
     $wife = $family->getWife();
     if ($wife) {
         echo '<a name="', $wife->getXref(), '"></a>';
     } else {
         $wife = new Individual('F', "0 @F@ INDI\n1 SEX F", null, $family->getTree());
     }
     if ($sosa) {
         echo '<p class="name_head">', $family->getFullName(), '</p>';
     }
     /**
      * husband side
      */
     echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr><td rowspan=\"2\">";
     echo "<table border='0'><tr>";
     if ($parid) {
         if ($husb->getXref() == $parid) {
             self::printSosaNumber($label);
         } else {
             self::printSosaNumber($label, "", "blank");
         }
     } elseif ($sosa) {
         self::printSosaNumber($sosa * 2);
     }
     if ($husb->isPendingAddtion()) {
         echo '<td valign="top" class="facts_value new">';
     } elseif ($husb->isPendingDeletion()) {
         echo '<td valign="top" class="facts_value old">';
     } else {
         echo '<td valign="top">';
     }
     FunctionsPrint::printPedigreePerson($husb, $show_full);
     echo "</td></tr></table>";
     echo "</td>";
     // husband’s parents
     $hfam = $husb->getPrimaryChildFamily();
     if ($hfam) {
         // remove the|| test for $sosa
         echo "<td rowspan=\"2\"><img src=\"" . Theme::theme()->parameter('image-hline') . "\" alt=\"\"></td><td rowspan=\"2\"><img src=\"" . Theme::theme()->parameter('image-vline') . "\" width=\"3\" height=\"" . ($pbheight + 9) . "\" alt=\"\"></td>";
         echo "<td><img class=\"line5\" src=\"" . Theme::theme()->parameter('image-hline') . "\" alt=\"\"></td><td>";
         // husband’s father
         if ($hfam && $hfam->getHusband()) {
             echo "<table border='0'><tr>";
             if ($sosa > 0) {
                 self::printSosaNumber($sosa * 4, $hfam->getHusband()->getXref(), "down");
             }
             if (!empty($gparid) && $hfam->getHusband()->getXref() == $gparid) {
                 self::printSosaNumber(trim(substr($label, 0, -3), ".") . ".");
             }
             echo "<td valign=\"top\">";
             FunctionsPrint::printPedigreePerson($hfam->getHusband(), $show_full);
             echo "</td></tr></table>";
         } elseif ($hfam && !$hfam->getHusband()) {
             // Empty box for grandfather
             echo "<table border='0'><tr>";
             echo '<td valign="top">';
             FunctionsPrint::printPedigreePerson($hfam->getHusband(), $show_full);
             echo '</td></tr></table>';
         }
         echo "</td>";
     }
     if ($hfam && $sosa != -1) {
         echo '<td valign="middle" rowspan="2">';
         self::printUrlArrow($sosa == 0 ? '?famid=' . $hfam->getXref() . '&amp;ged=' . $hfam->getTree()->getNameUrl() : '#' . $hfam->getXref(), $hfam->getXref(), 1);
         echo '</td>';
     }
     if ($hfam) {
         // husband’s mother
         echo "</tr><tr><td><img src=\"" . Theme::theme()->parameter('image-hline') . "\" alt=\"\"></td><td>";
         if ($hfam && $hfam->getWife()) {
             echo "<table border='0'><tr>";
             if ($sosa > 0) {
                 self::printSosaNumber($sosa * 4 + 1, $hfam->getWife()->getXref(), "down");
             }
             if (!empty($gparid) && $hfam->getWife()->getXref() == $gparid) {
                 self::printSosaNumber(trim(substr($label, 0, -3), ".") . ".");
             }
             echo '<td valign="top">';
//.........这里部分代码省略.........
开发者ID:pal-saugstad,项目名称:webtrees,代码行数:101,代码来源:FunctionsCharts.php


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