Example #1
0
 public static function formatFamilyMemberElement($tag, $titleString, $prevFamilyMembers = array())
 {
     // TODO If the family member used to be a child of this family and now it is a spouse of this family, and it has another set of parents,
     // those parents won't appear in this person's spouse element in this family.  Have to include this check in our periodic audit.
     $title = Title::newFromText($titleString, NS_PERSON);
     if ($title) {
         if (isset($prevFamilyMembers[$title->getText()])) {
             $person = $prevFamilyMembers[$title->getText()];
         } else {
             $person = Family::loadFamilyMember($title->getText());
         }
         $result = "<{$tag} title=\"" . StructuredData::escapeXml($title->getText()) . '"';
         foreach (self::$FAMILY_MEMBER_ATTRS as $attr) {
             if (isset($person[$attr]) && !($tag == 'child' && $attr == 'child_of_family')) {
                 $attrValue = trim($person[$attr]);
                 if (strlen($attrValue) > 0) {
                     $result .= " {$attr}=\"" . StructuredData::escapeXml($attrValue) . '"';
                 }
             }
         }
         $result .= "/>\n";
     } else {
         $result = '';
     }
     return $result;
 }
Example #2
0
 private function formatPageElement($tag, $titleString, $ns)
 {
     $title = Title::newFromText($titleString, $ns);
     if (!$title) {
         return '';
     }
     $title = StructuredData::getRedirectToTitle($title);
     // ok to read from slave here; mistakes will get corrected in propagate
     if ($ns == NS_PERSON) {
         if (isset($this->prevPeople[$title->getText()])) {
             $page = $this->prevPeople[$title->getText()];
         } else {
             $page = Family::loadFamilyMember($title->getText());
         }
         $attrs = self::$PERSON_ATTRS;
     } else {
         // NS_FAMILY
         if (isset($this->prevFamilies[$title->getText()])) {
             $page = $this->prevFamilies[$title->getText()];
         } else {
             $page = array();
         }
         $attrs = self::$FAMILY_ATTRS;
     }
     $result = "<{$tag} title=\"" . StructuredData::escapeXml($title->getText()) . '"';
     foreach ($attrs as $attr) {
         if (isset($page[$attr])) {
             $attrValue = trim($page[$attr]);
             if (strlen($attrValue) > 0) {
                 $result .= " {$attr}=\"" . StructuredData::escapeXml($attrValue) . '"';
             }
         }
     }
     $result .= "/>\n";
     return $result;
 }