コード例 #1
0
ファイル: Family.php プロジェクト: k-hasan-19/wiki
 protected function fromPerson($request, $name)
 {
     $result = '';
     $seenTitles = array();
     for ($i = 0; $request->getVal("{$name}_id{$i}"); $i++) {
         $titleString = urldecode($request->getVal("{$name}{$i}"));
         if (!$this->isGedcomPage && $titleString) {
             $title = Title::newFromText($titleString, NS_PERSON);
             if ($title) {
                 $title = StructuredData::getRedirectToTitle($title);
                 // ok to read from slave here; mistakes will be corrected in propagate
                 $titleString = $title->getText();
             } else {
                 $titleString = '';
             }
         }
         if ($titleString && !in_array($titleString, $seenTitles)) {
             $seenTitles[] = $titleString;
             if (!$this->isGedcomPage && !StructuredData::titleStringHasId($titleString)) {
                 $titleString = StructuredData::standardizeNameCase($titleString);
             }
             $result .= Family::formatFamilyMemberElement($name, $titleString, $this->prevFamilyMembers);
         }
     }
     return $result;
 }
コード例 #2
0
ファイル: Transcript.php プロジェクト: k-hasan-19/wiki
 protected function formatSurname($value)
 {
     $value = StructuredData::standardizeNameCase(trim($value), false);
     $escapedValue =& StructuredData::escapeXml($value);
     return "<surname>{$escapedValue}</surname>";
 }
コード例 #3
0
/**
 * constructor
 */
function wfSpecialGotoPageOld()
{
    global $wgOut, $wgRequest, $wgUser;
    $error = '';
    $titleList = '';
    $addPersonFamily = false;
    $title = null;
    $namespace = $wgRequest->getVal('namespace');
    $titleText = $wgRequest->getVal('pagetitle');
    if ($namespace == 'person') {
        $addPersonFamily = true;
        $titleText = wrConstructName($wgRequest->getVal('personGiven'), $wgRequest->getVal('personSurname'));
        if ($titleText) {
            $title = Title::newFromText($titleText, NS_PERSON);
        }
    } else {
        if ($namespace == 'family') {
            $addPersonFamily = true;
            $husbandText = wrConstructName($wgRequest->getVal('husbandGiven'), $wgRequest->getVal('husbandSurname'));
            $wifeText = wrConstructName($wgRequest->getVal('wifeGiven'), $wgRequest->getVal('wifeSurname'));
            $titleText = '';
            if ($husbandText && $wifeText) {
                $titleText = $husbandText . ' and ' . $wifeText;
            } else {
                if ($husbandText) {
                    $titleText = $husbandText . ' and Unknown';
                } else {
                    if ($wifeText) {
                        $titleText = 'Unknown and ' . $wifeText;
                    }
                }
            }
            if ($titleText) {
                $title = Title::newFromText($titleText, NS_FAMILY);
            }
        } else {
            if ($titleText) {
                $title = Title::newFromText($titleText, $namespace);
                if (is_null($title)) {
                    $error = wfmsg('invalidtitle');
                } else {
                    if ($wgRequest->getVal('add') && ($title->getNamespace() == NS_USER || $title->getNamespace() == NS_USER_TALK)) {
                        // user must exist if we're adding a page for them
                        $pos = strpos($title->getText(), '/');
                        if ($pos !== false) {
                            $userName = substr($title->getText(), 0, $pos);
                        } else {
                            $userName = $title->getText();
                        }
                        if (!User::isIP($userName) && User::idFromName($userName) == 0) {
                            $error = 'User does not exist.  Is the name spelled correctly?';
                            $title = null;
                        }
                    }
                }
            }
        }
    }
    if ($title) {
        if ($wgRequest->getVal('goto')) {
            if ($title->getNamespace() == NS_SPECIAL || $title->exists()) {
                $wgOut->redirect($title->getFullURL());
                return;
            } else {
                $error = 'Title not found.';
                $skin = $wgUser->getSkin();
                $n = 0;
                $moreLink = false;
                $dbr =& wfGetDB(DB_SLAVE);
                $res = $dbr->select('page', array('page_title', 'page_namespace', 'page_is_redirect'), 'page_namespace=' . $title->getNamespace() . ' and page_title like "' . $title->getDBkey() . '%"', 'wfSpecialGotoPageOld', array('LIMIT' => 31, 'ORDER BY' => 'page_title'));
                while ($row = $dbr->fetchObject($res)) {
                    if ($n == 30) {
                        $moreLink = true;
                        break;
                    }
                    if (!$titleList) {
                        $titleList = '<h2>Titles starting with ' . $titleText . '</h2><table style="background: inherit;" border="0" width="100%">';
                    }
                    $t = Title::makeTitle($row->page_namespace, $row->page_title);
                    if ($t) {
                        $link = ($row->page_is_redirect ? '<div class="allpagesredirect">' : '') . $skin->makeKnownLinkObj($t, htmlspecialchars($t->getPrefixedText())) . ($row->page_is_redirect ? '</div>' : '');
                    } else {
                        $link = '[[' . htmlspecialchars($row->page_title) . ']]';
                    }
                    if ($n % 3 == 0) {
                        $titleList .= '<tr>';
                    }
                    $titleList .= "<td>{$link}</td>";
                    $n++;
                    if ($n % 3 == 0) {
                        $titleList .= '</tr>';
                    }
                }
                $dbr->freeResult($res);
                if ($n % 3 != 0) {
                    $titleList .= '</tr>';
                }
                if ($titleList) {
                    $titleList .= '</table>';
                    $error .= " All pages starting with {$titleText} are listed below.";
                }
                if ($moreLink) {
                    $t = Title::makeTitle(NS_SPECIAL, 'Allpages');
                    $titleList .= '<p>More not shown (' . $skin->makeKnownLinkObj($t, 'show all', "from={$title->getText()}&namespace={$title->getNamespace()}") . ')</p>';
                }
            }
        } else {
            if ($wgRequest->getVal('add')) {
                // PERSON and FAMILY pages must have a unique id
                if (($title->getNamespace() == NS_PERSON || $title->getNamespace() == NS_FAMILY) && !StructuredData::titleStringHasId($title->getText())) {
                    // standardize name case and append a unique id
                    $title = StructuredData::appendUniqueId(Title::newFromText((string) StructuredData::standardizeNameCase($title->getText()), $title->getNamespace()));
                }
                if ($title != null) {
                    $wgOut->redirect($title->getFullURL('action=edit'));
                }
                return;
            }
        }
    }
    // set up page
    $wgOut->setPagetitle('Go to / Add page');
    $wgOut->setArticleRelated(false);
    $wgOut->setRobotpolicy('noindex,nofollow');
    if ($error) {
        $wgOut->addHTML("<p><font color=red>{$error}</font></p>");
    }
    $wgOut->addHTML("<center>" . getGotoPageForm($namespace, $titleText) . "</center>");
    if (!$addPersonFamily) {
        if ($titleList) {
            $wgOut->addHTML($titleList);
        } else {
            $wgOut->addWikiText("\n\n" . wfmsg('gotopageend'));
        }
    }
}
コード例 #4
0
ファイル: StructuredData.php プロジェクト: k-hasan-19/wiki
 public static function addCategories($surnames, $places, $addPlaceCategories = true, $titleString = '', $ns = NS_MAIN, $displayCats = false)
 {
     global $wrStdSurnames, $wrStdPlaces, $wgParser;
     // TODO figure out how to not disable caching
     // disable caching because we're passing wrStdSurnames and wrStdPlaces as globals
     $wgParser->disableCache();
     $result = '';
     $titleString = mb_strtolower($titleString);
     $wrStdSurnames = array();
     $wrStdPlaces = array();
     $hlPlaces = array();
     // standardize names and make them unique
     foreach ($surnames as $surname) {
         $s = (string) $surname;
         if ($s) {
             // add an entry for the entire surname as well as separate entries for each piece
             $wrStdSurnames[] = StructuredData::standardizeNameCase($s);
             $surnamePieces = StructuredData::parseSurnamePieces($s);
             foreach ($surnamePieces as $surnamePiece) {
                 $wrStdSurnames[] = StructuredData::standardizeNameCase($surnamePiece);
             }
         }
     }
     $wrStdSurnames = array_unique($wrStdSurnames);
     // standardize places and make them unique
     foreach ($places as $place) {
         $p = (string) $place;
         if ($p) {
             // if you change the transformation for titleText, change it also in UserPage.formatResearchLinks
             $fields = explode('|', $p);
             $titleText = trim($fields[0]);
             $t = Title::newFromText($titleText, NS_PLACE);
             if ($t) {
                 $t = StructuredData::getRedirectToTitle($t);
                 $titleText = $t->getText();
             }
             $wrStdPlaces[] = $titleText;
             $fields = explode(',', $titleText);
             $hlPlace = trim($fields[count($fields) - 1]);
             if (count($fields) > 1 && strcasecmp($hlPlace, 'united states') == 0) {
                 $hlPlace = trim($fields[count($fields) - 2]);
             }
             $hlPlaces[] = $hlPlace;
         }
     }
     $wrStdPlaces = array_unique($wrStdPlaces);
     $hlPlaces = array_unique($hlPlaces);
     // write out categories
     $colon = $displayCats ? ':' : '';
     //	   foreach ($stdSurnames as $surname) {
     //	      if ($result && $displayCats) {
     //	         $result .= ', ';
     //	      }
     //		   $result .= "[[{$colon}Category:$surname surname" . ($displayCats ? "|$surname surname" : '') ."]]";
     //		}
     if ($addPlaceCategories) {
         foreach ($wrStdPlaces as $place) {
             if ($result && $displayCats) {
                 $result .= ', ';
             }
             $result .= "[[{$colon}Category:{$place}" . ($displayCats ? "|{$place}" : '') . "]]";
         }
     }
     //		foreach ($hlPlaces as $place) {
     //		   foreach ($stdSurnames as $surname) {
     //		      $catName = "$surname in $place";
     //		      if (!$displayCats && $titleString && $ns == NS_MAIN && mb_strtolower($catName) == $titleString) { // main Surname in Place article
     //		         $catName .= "|*";
     //		      }
     //   	      if ($result && $displayCats) {
     //   	         $result .= ', ';
     //   	      }
     //		      $result .= "[[{$colon}Category:$catName" . ($displayCats ? "|$catName" : '') ."]]";
     //		   }
     //		}
     return $result;
 }
コード例 #5
0
ファイル: Name.php プロジェクト: k-hasan-19/wiki
 /**
  * Return xml elements from data in request
  * @param unknown $request
  */
 protected function fromEditFields($request)
 {
     $related = $request->getVal('related', '');
     $search = array('/ *\\r?\\n */', '/\\|/');
     // add space before bar so things sort right
     $replace = array("\n", ' |');
     $related = trim(preg_replace($search, $replace, $related));
     $relNames = preg_split('/[\\n]+/', $related, -1, PREG_SPLIT_NO_EMPTY);
     sort($relNames, SORT_STRING);
     $prevName = '';
     $result = '';
     foreach ($relNames as $relName) {
         $fields = explode('|', $relName, 2);
         $name = StructuredData::escapeXml(StructuredData::standardizeNameCase(trim(@$fields[0]), false));
         $source = StructuredData::escapeXml(trim(@$fields[1]));
         // remove any space before bar in source: links that would have been added above
         $source = str_replace(' |', '|', $source);
         if ($name != $prevName) {
             $result .= "<related name=\"{$name}\" source=\"{$source}\"/>\n";
         }
         $prevName = $name;
     }
     return $result;
 }
コード例 #6
0
ファイル: SDImage.php プロジェクト: k-hasan-19/wiki
 private function fromPage($request, $name, $ns)
 {
     $result = '';
     $titles = array();
     for ($i = 0; $request->getVal("{$name}_id{$i}"); $i++) {
         $titleString = $request->getVal("{$name}{$i}");
         if ($titleString) {
             if (!StructuredData::titleStringHasId($titleString)) {
                 $titleString = StructuredData::standardizeNameCase($titleString, true);
             }
             if (!in_array($titleString, $titles)) {
                 $result .= $this->formatPageElement($name, $titleString, $ns);
                 $titles[] = $titleString;
             }
         }
     }
     return $result;
 }
コード例 #7
0
ファイル: UserPage.php プロジェクト: k-hasan-19/wiki
 /**
  * Return xml elements from data in request
  * @param unknown $request
  */
 protected function fromEditFields($request)
 {
     $this->correctedPlaceTitles = PlaceSearcher::correctPlaceTitlesMultiLine($request->getVal('places', ''));
     $result = '';
     if ($this->isSubpage) {
         $result .= $this->addMultiLineFieldToXml($request->getVal('surnames', ''), 'formatSurname');
         $result .= $this->addMultiLineFieldToXml($request->getVal('places', ''), 'formatPlace');
         $result .= $this->addSingleLineFieldToXml($request->getVal('fromYear', ''), 'from_year');
         $result .= $this->addSingleLineFieldToXml($request->getVal('toYear', ''), 'to_year');
     } else {
         $placesToCorrect = array();
         for ($i = 0; $request->getVal("researching_id{$i}"); $i++) {
             $place = trim($request->getVal("researching_place{$i}"));
             if ($place && mb_strpos($place, '|') === false) {
                 $placesToCorrect[] = $place;
             }
         }
         $correctedPlaceTitles = PlaceSearcher::correctPlaceTitles($placesToCorrect);
         for ($i = 0; $request->getVal("researching_id{$i}"); $i++) {
             $surname = StructuredData::standardizeNameCase(trim($request->getVal("researching_surname{$i}")), false);
             $place = trim($request->getVal("researching_place{$i}"));
             if ($surname || $place) {
                 // if you change this, you must also change FamilyTreeAjaxFunctions
                 if ($place) {
                     $correctedPlace = @$correctedPlaceTitles[$place];
                     if ($correctedPlace) {
                         $place = $correctedPlace;
                     }
                 }
                 $result .= $this->addMultiAttrFieldToXml(array('surname' => $surname, 'place' => $place), 'researching');
             }
         }
     }
     return $result;
 }