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


PHP Individual::getSex方法代码示例

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


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

示例1: generate

 /**
  * Generate the likely value of this census column, based on available information.
  *
  * @param Individual      $individual
  * @param Individual|null $head
  *
  * @return string
  */
 public function generate(Individual $individual, Individual $head = null)
 {
     if ($individual->getSex() === 'F') {
         return '';
     } else {
         return (string) Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0);
     }
 }
开发者ID:tronsmit,项目名称:webtrees,代码行数:16,代码来源:CensusColumnAgeMale.php

示例2: generate

 /**
  * Generate the likely value of this census column, based on available information.
  *
  * @param Individual      $individual
  * @param Individual|null $head
  *
  * @return string
  */
 public function generate(Individual $individual, Individual $head = null)
 {
     $sex = $individual->getSex();
     if ($sex === 'M' || $sex === 'F') {
         return $sex;
     } else {
         return '';
     }
 }
开发者ID:tunandras,项目名称:webtrees,代码行数:17,代码来源:CensusColumnSexMF.php

示例3: generate

 /**
  * Generate the likely value of this census column, based on available information.
  *
  * @param Individual      $individual
  * @param Individual|null $head
  *
  * @return string
  */
 public function generate(Individual $individual, Individual $head = null)
 {
     switch ($individual->getSex()) {
         case 'M':
             return $this->male;
         case 'F':
             return $this->female;
         default:
             return '';
     }
 }
开发者ID:tronsmit,项目名称:webtrees,代码行数:19,代码来源:CensusColumnSexMF.php

示例4: generate

 /**
  * Generate the likely value of this census column, based on available information.
  *
  * @param Individual      $individual
  * @param Individual|null $head
  *
  * @return string
  */
 public function generate(Individual $individual, Individual $head = null)
 {
     if ($individual->getSex() === 'M') {
         return '';
     } else {
         $years = Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0);
         if ($years > 15) {
             $years -= $years % 5;
         }
         return (string) $years;
     }
 }
开发者ID:tunandras,项目名称:webtrees,代码行数:20,代码来源:CensusColumnAgeFemale5Years.php

示例5: generate

 /**
  * Generate the likely value of this census column, based on available information.
  *
  * @param Individual      $individual
  * @param Individual|null $head
  *
  * @return string
  */
 public function generate(Individual $individual, Individual $head = null)
 {
     if ($individual->getSex() !== 'F') {
         return '';
     }
     $count = 0;
     foreach ($individual->getSpouseFamilies() as $family) {
         foreach ($family->getChildren() as $child) {
             if ($child->getBirthDate()->isOK() && Date::compare($child->getBirthDate(), $this->date()) < 0 && $child->getBirthDate() != $child->getDeathDate() && (!$child->getDeathDate()->isOK() || Date::compare($child->getDeathDate(), $this->date()) > 0)) {
                 $count++;
             }
         }
     }
     return (string) $count;
 }
开发者ID:tunandras,项目名称:webtrees,代码行数:23,代码来源:CensusColumnChildrenLiving.php

示例6: getPersonStyle

 /**
  * get the person box stylesheet class for the given person
  *
  * @param Individual $person
  *
  * @return string returns 'person_box', 'person_boxF', or 'person_boxNN'
  */
 public function getPersonStyle($person)
 {
     switch ($person->getSex()) {
         case 'M':
             $class = 'person_box';
             break;
         case 'F':
             $class = 'person_boxF';
             break;
         default:
             $class = 'person_boxNN';
             break;
     }
     if ($person->isPendingDeletion()) {
         $class .= ' old';
     } elseif ($person->isPendingAddtion()) {
         $class .= ' new';
     }
     return $class;
 }
开发者ID:tunandras,项目名称:webtrees,代码行数:27,代码来源:IndividualController.php

示例7: 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

示例8: getRelationshipNameFromPath

 /**
  * Convert a relationship path into a relationship name.
  *
  * @param string $path
  * @param Individual $person1
  * @param Individual $person2
  *
  * @return string
  */
 public static function getRelationshipNameFromPath($path, Individual $person1 = null, Individual $person2 = null)
 {
     if (!preg_match('/^(mot|fat|par|hus|wif|spo|son|dau|chi|bro|sis|sib)*$/', $path)) {
         // TODO: Update all the “3 RELA ” values in class_person
         return '<span class="error">' . $path . '</span>';
     }
     // The path does not include the starting person.  In some languages, the
     // translation for a man’s (relative) is different from a woman’s (relative),
     // due to inflection.
     $sex1 = $person1 ? $person1->getSex() : 'U';
     // The sex of the last person in the relationship determines the name in
     // many cases.  e.g. great-aunt / great-uncle
     if (preg_match('/(fat|hus|son|bro)$/', $path)) {
         $sex2 = 'M';
     } elseif (preg_match('/(mot|wif|dau|sis)$/', $path)) {
         $sex2 = 'F';
     } else {
         $sex2 = 'U';
     }
     switch ($path) {
         case '':
             return I18N::translate('self');
             //  Level One relationships
         //  Level One relationships
         case 'mot':
             return I18N::translate('mother');
         case 'fat':
             return I18N::translate('father');
         case 'par':
             return I18N::translate('parent');
         case 'hus':
             if ($person1 && $person2) {
                 foreach ($person1->getSpouseFamilies() as $family) {
                     if ($person2 === $family->getSpouse($person1)) {
                         if ($family->getFacts('_NMR')) {
                             if ($family->getFacts(WT_EVENTS_DIV)) {
                                 return I18N::translateContext('MALE', 'ex-partner');
                             } else {
                                 return I18N::translateContext('MALE', 'partner');
                             }
                         } elseif ($family->getFacts(WT_EVENTS_DIV)) {
                             return I18N::translate('ex-husband');
                         }
                     }
                 }
             }
             return I18N::translate('husband');
         case 'wif':
             if ($person1 && $person1) {
                 foreach ($person1->getSpouseFamilies() as $family) {
                     if ($person2 === $family->getSpouse($person1)) {
                         if ($family->getFacts('_NMR')) {
                             if ($family->getFacts(WT_EVENTS_DIV)) {
                                 return I18N::translateContext('FEMALE', 'ex-partner');
                             } else {
                                 return I18N::translateContext('FEMALE', 'partner');
                             }
                         } elseif ($family->getFacts(WT_EVENTS_DIV)) {
                             return I18N::translate('ex-wife');
                         }
                     }
                 }
             }
             return I18N::translate('wife');
         case 'spo':
             if ($person1 && $person2) {
                 foreach ($person1->getSpouseFamilies() as $family) {
                     if ($person2 === $family->getSpouse($person1)) {
                         if ($family->getFacts('_NMR')) {
                             if ($family->getFacts(WT_EVENTS_DIV)) {
                                 return I18N::translateContext('MALE/FEMALE', 'ex-partner');
                             } else {
                                 return I18N::translateContext('MALE/FEMALE', 'partner');
                             }
                         } elseif ($family->getFacts(WT_EVENTS_DIV)) {
                             return I18N::translate('ex-spouse');
                         }
                     }
                 }
             }
             return I18N::translate('spouse');
         case 'son':
             return I18N::translate('son');
         case 'dau':
             return I18N::translate('daughter');
         case 'chi':
             return I18N::translate('child');
         case 'bro':
             if ($person1 && $person2) {
                 $dob1 = $person1->getBirthDate();
                 $dob2 = $person2->getBirthDate();
//.........这里部分代码省略.........
开发者ID:jflash,项目名称:webtrees,代码行数:101,代码来源:Functions.php

示例9: individualBoxSmall

 /**
  * Display an individual in a box - for charts, etc.
  *
  * @param Individual $individual
  *
  * @return string
  */
 public function individualBoxSmall(Individual $individual)
 {
     $personBoxClass = array_search($individual->getSex(), array('person_box' => 'M', 'person_boxF' => 'F', 'person_boxNN' => 'U'));
     if ($individual->getTree()->getPreference('SHOW_HIGHLIGHT_IMAGES')) {
         $thumbnail = $individual->displayImage();
     } else {
         $thumbnail = '';
     }
     return '<div data-pid="' . $individual->getXref() . '" class="person_box_template ' . $personBoxClass . ' iconz box-style0" style="width: ' . $this->parameter('compact-chart-box-x') . 'px; min-height: ' . $this->parameter('compact-chart-box-y') . 'px">' . '<div class="compact_view">' . $thumbnail . '<a href="' . $individual->getHtmlUrl() . '">' . '<span class="namedef name0">' . $individual->getFullName() . '</span>' . '</a>' . '<div class="inout2 details0">' . $individual->getLifeSpan() . '</div>' . '</div>' . '<div class="inout"></div>' . '</div>';
 }
开发者ID:tronsmit,项目名称:webtrees,代码行数:17,代码来源:AbstractTheme.php

示例10: drawPersonName

 /**
  * Draw a person name preceded by sex icon, with parents as tooltip
  *
  * @param Individual $individual an individual
  * @param string        $dashed     if = 'dashed' print dashed top border to separate multiple spuses
  *
  * @return string
  */
 private function drawPersonName(Individual $individual, $dashed = '')
 {
     if ($this->all_partners === 'true') {
         $family = $individual->getPrimaryChildFamily();
         if ($family) {
             $family_name = strip_tags($family->getFullName());
         } else {
             $family_name = I18N::translateContext('unknown family', 'unknown');
         }
         switch ($individual->getSex()) {
             case 'M':
                 $title = ' title="' . I18N::translate('Son of %s', $family_name) . '"';
                 break;
             case 'F':
                 $title = ' title="' . I18N::translate('Daughter of %s', $family_name) . '"';
                 break;
             default:
                 $title = ' title="' . I18N::translate('Child of %s', $family_name) . '"';
                 break;
         }
     } else {
         $title = '';
     }
     $sex = $individual->getSex();
     return '<div class="tv' . $sex . ' ' . $dashed . '"' . $title . '><a href="' . $individual->getHtmlUrl() . '"></a>' . $individual->getFullName() . ' <span class="dates">' . $individual->getLifeSpan() . '</span></div>';
 }
开发者ID:tunandras,项目名称:webtrees,代码行数:34,代码来源:TreeView.php

示例11: importRecord

 /**
  * import record into database
  *
  * this function will parse the given gedcom record and add it to the database
  *
  * @param string $gedrec the raw gedcom record to parse
  * @param Tree   $tree   import the record into this tree
  * @param bool   $update whether or not this is an updated record that has been accepted
  */
 public static function importRecord($gedrec, Tree $tree, $update)
 {
     $tree_id = $tree->getTreeId();
     // Escaped @ signs (only if importing from file)
     if (!$update) {
         $gedrec = str_replace('@@', '@', $gedrec);
     }
     // Standardise gedcom format
     $gedrec = self::reformatRecord($gedrec, $tree);
     // import different types of records
     if (preg_match('/^0 @(' . WT_REGEX_XREF . ')@ (' . WT_REGEX_TAG . ')/', $gedrec, $match)) {
         list(, $xref, $type) = $match;
         // check for a _UID, if the record doesn't have one, add one
         if ($tree->getPreference('GENERATE_UIDS') && !strpos($gedrec, "\n1 _UID ")) {
             $gedrec .= "\n1 _UID " . GedcomTag::createUid();
         }
     } elseif (preg_match('/0 (HEAD|TRLR)/', $gedrec, $match)) {
         $type = $match[1];
         $xref = $type;
         // For HEAD/TRLR, use type as pseudo XREF.
     } else {
         echo I18N::translate('Invalid GEDCOM format'), '<br><pre>', $gedrec, '</pre>';
         return;
     }
     // If the user has downloaded their GEDCOM data (containing media objects) and edited it
     // using an application which does not support (and deletes) media objects, then add them
     // back in.
     if ($tree->getPreference('keep_media') && $xref) {
         $old_linked_media = Database::prepare("SELECT l_to FROM `##link` WHERE l_from=? AND l_file=? AND l_type='OBJE'")->execute(array($xref, $tree_id))->fetchOneColumn();
         foreach ($old_linked_media as $media_id) {
             $gedrec .= "\n1 OBJE @" . $media_id . "@";
         }
     }
     switch ($type) {
         case 'INDI':
             // Convert inline media into media objects
             $gedrec = self::convertInlineMedia($tree, $gedrec);
             $record = new Individual($xref, $gedrec, null, $tree);
             if (preg_match('/\\n1 RIN (.+)/', $gedrec, $match)) {
                 $rin = $match[1];
             } else {
                 $rin = $xref;
             }
             Database::prepare("INSERT INTO `##individuals` (i_id, i_file, i_rin, i_sex, i_gedcom) VALUES (?, ?, ?, ?, ?)")->execute(array($xref, $tree_id, $rin, $record->getSex(), $gedrec));
             // Update the cross-reference/index tables.
             self::updatePlaces($xref, $tree_id, $gedrec);
             self::updateDates($xref, $tree_id, $gedrec);
             self::updateLinks($xref, $tree_id, $gedrec);
             self::updateNames($xref, $tree_id, $record);
             break;
         case 'FAM':
             // Convert inline media into media objects
             $gedrec = self::convertInlineMedia($tree, $gedrec);
             if (preg_match('/\\n1 HUSB @(' . WT_REGEX_XREF . ')@/', $gedrec, $match)) {
                 $husb = $match[1];
             } else {
                 $husb = '';
             }
             if (preg_match('/\\n1 WIFE @(' . WT_REGEX_XREF . ')@/', $gedrec, $match)) {
                 $wife = $match[1];
             } else {
                 $wife = '';
             }
             $nchi = preg_match_all('/\\n1 CHIL @(' . WT_REGEX_XREF . ')@/', $gedrec, $match);
             if (preg_match('/\\n1 NCHI (\\d+)/', $gedrec, $match)) {
                 $nchi = max($nchi, $match[1]);
             }
             Database::prepare("INSERT INTO `##families` (f_id, f_file, f_husb, f_wife, f_gedcom, f_numchil) VALUES (?, ?, ?, ?, ?, ?)")->execute(array($xref, $tree_id, $husb, $wife, $gedrec, $nchi));
             // Update the cross-reference/index tables.
             self::updatePlaces($xref, $tree_id, $gedrec);
             self::updateDates($xref, $tree_id, $gedrec);
             self::updateLinks($xref, $tree_id, $gedrec);
             break;
         case 'SOUR':
             // Convert inline media into media objects
             $gedrec = self::convertInlineMedia($tree, $gedrec);
             $record = new Source($xref, $gedrec, null, $tree);
             if (preg_match('/\\n1 TITL (.+)/', $gedrec, $match)) {
                 $name = $match[1];
             } elseif (preg_match('/\\n1 ABBR (.+)/', $gedrec, $match)) {
                 $name = $match[1];
             } else {
                 $name = $xref;
             }
             Database::prepare("INSERT INTO `##sources` (s_id, s_file, s_name, s_gedcom) VALUES (?, ?, LEFT(?, 255), ?)")->execute(array($xref, $tree_id, $name, $gedrec));
             // Update the cross-reference/index tables.
             self::updateLinks($xref, $tree_id, $gedrec);
             self::updateNames($xref, $tree_id, $record);
             break;
         case 'REPO':
             // Convert inline media into media objects
//.........这里部分代码省略.........
开发者ID:tronsmit,项目名称:webtrees,代码行数:101,代码来源:FunctionsImport.php


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