示例#1
0
/**
 * constructor
 */
function wfSpecialPlaceMap()
{
    global $wgOut, $wgRequest, $wgUser;
    $wgOut->setArticleRelated(false);
    $wgOut->setRobotpolicy('noindex,nofollow');
    $titleText = $wgRequest->getVal('pagetitle');
    $error = '';
    if ($titleText) {
        $title = Title::newFromText($titleText, NS_PLACE);
        if (is_null($title) || $title->getNamespace() != NS_PLACE || !$title->exists()) {
            $error = 'Please enter the title of a place page';
        } else {
            $revision = StructuredData::getRevision($title, true);
            if (!$revision) {
                $error = "Place map revision not found!\n";
            } else {
                $sk = $wgUser->getSkin();
                $text =& $revision->getText();
                $xml = StructuredData::getXml('place', $text);
                $wgOut->setPageTitle('Map of ' . $revision->getTitle()->getText());
                // place map
                $wgOut->addHTML('<H2>Map for ' . $sk->makeKnownLinkObj($revision->getTitle(), $revision->getTitle()->getText()) . '</H2>');
                $wgOut->addHTML('<div id="placemap" style="width: 760px; height: 520px"></div><br>');
                $mapData = SpecialPlaceMap::getContainedPlaceMapData($xml);
                if (!$mapData) {
                    $mapData = SpecialPlaceMap::getSelfMapData($revision->getTitle(), $xml);
                }
                $wgOut->addHTML(SpecialPlaceMap::getMapScripts(1, $mapData));
                $wgOut->addHTML('<div id="latlnginst" style="display: block">Click on the map to see the latitude and longitude at the cursor position.</div>');
                $wgOut->addHTML('<div id="latlngbox" style="display: none">Clicked on Latitude: <span id="latbox"></span> Longitude: <span id="lngbox"></span></div><br>');
                $unmappedPlaces = SpecialPlaceMap::getUnmappedPlaces($sk, $xml);
                if ($unmappedPlaces) {
                    $wgOut->addHTML("<h3>Places not on map</h3>" . $unmappedPlaces);
                }
                return;
            }
        }
    }
    $wgOut->setPageTitle('Place Map');
    if ($error) {
        $wgOut->addHTML("<p><font color=red>{$error}</font></p>");
    }
    $queryBoxStyle = 'width:100%;text-align:center;';
    $form = <<<END
<form name="search" action="/wiki/Special:PlaceMap" method="get">
<div id="searchFormDiv" style="{$queryBoxStyle}">
Place title: <input type="text" name="pagetitle" size=24 maxlength="100" value="{$titleText}" onfocus="select()" />
<input type="submit" value="Go" />
</div>
</form>
END;
    $wgOut->addHTML($form);
}
示例#2
0
 private function loadFamilyMembers()
 {
     $xml = null;
     $this->prevFamilyMembers = array();
     if ($this->isGedcomPage) {
         $dataString = GedcomUtil::getGedcomDataString();
         if ($dataString) {
             $xml = simplexml_load_string($dataString);
         }
     } else {
         $revision = StructuredData::getRevision($this->title);
         if ($revision) {
             $content =& $revision->getText();
             $xml = StructuredData::getXml('family', $content);
         }
     }
     if (isset($xml)) {
         foreach ($xml->husband as $member) {
             $title = (string) $member['title'];
             $this->prevFamilyMembers[$title] = Family::getFamilyMemberAttributes($member);
         }
         foreach ($xml->wife as $member) {
             $title = (string) $member['title'];
             $this->prevFamilyMembers[$title] = Family::getFamilyMemberAttributes($member);
         }
         foreach ($xml->child as $member) {
             $title = (string) $member['title'];
             $this->prevFamilyMembers[$title] = Family::getFamilyMemberAttributes($member);
         }
     }
 }
示例#3
0
 /**
  * Propagate an article rollback
  * Sets xml property and calls the abstract function propagateRollbackData($title)
  * @param Article $article contains text being replaced
  * @return bool true if propagate succeeded
  */
 public function propagateRollback($article)
 {
     global $wgUser, $wrBotUserID;
     $result = true;
     // we do propagate bot edits
     //	   if ($wgUser->getID() != $wrBotUserID) {
     $title = $article->getTitle();
     $oldText =& $article->fetchContent();
     // $article contains the text being replaced; $rollbackRevision contains the new text
     $rollbackRevision = StructuredData::getRevision($title, false, true);
     $text =& $rollbackRevision->getText();
     $this->xml = StructuredData::getXml($this->tagName, $text);
     $textChanged = false;
     $result = $this->propagateEditData($oldText, $text, $textChanged);
     if ($result && $textChanged) {
         PropagationManager::enablePropagation(false);
         $result = $article->doEdit($text, self::PROPAGATE_MESSAGE, PROPAGATE_EDIT_FLAGS);
         PropagationManager::enablePropagation(true);
     }
     //	   }
     return $result;
 }
示例#4
0
/**
 * Callback function to propagate data
 * @return bool must return true or other hooks don't get called
 */
function propagatePersonUndelete(&$title, &$user)
{
    $ns = $title->getNamespace();
    if ($ns == NS_PERSON) {
        $person = new Person($title->getText());
        $revision = StructuredData::getRevision($title, false, true);
        $person->propagateUndelete($revision);
    }
    return true;
}
示例#5
0
文件: Place.php 项目: k-hasan-19/wiki
 /**
  * Add contained places from the current version of the article as a string of XML elements
  */
 private function getContainedPlacesElements()
 {
     $result = '';
     $revision = StructuredData::getRevision($this->title);
     if ($revision) {
         // read the existing article for the contained places
         $content =& $revision->getText();
         $xml = StructuredData::getXml('place', $content);
         if (isset($xml)) {
             foreach ($xml->contained_place as $containedPlace) {
                 $place = (string) $containedPlace['place'];
                 $place = StructuredData::escapeXml(trim($place));
                 $type = (string) $containedPlace['type'];
                 $type = StructuredData::escapeXml(trim($type));
                 $lat = (string) $containedPlace['latitude'];
                 $lat = StructuredData::escapeXml(trim($lat));
                 $lng = (string) $containedPlace['longitude'];
                 $lng = StructuredData::escapeXml(trim($lng));
                 $fromYear = (string) $containedPlace['from_year'];
                 $fromYear = StructuredData::escapeXml(trim($fromYear));
                 $toYear = (string) $containedPlace['to_year'];
                 $toYear = StructuredData::escapeXml(trim($toYear));
                 $result .= "<contained_place place=\"{$place}\"" . ($lng ? " longitude=\"{$lng}\"" : '') . ($lat ? " latitude=\"{$lat}\"" : '') . ($type ? " type=\"{$type}\"" : '') . ($fromYear ? " from_year=\"{$fromYear}\"" : '') . ($toYear ? " to_year=\"{$toYear}\"" : '') . "/>\n";
             }
         }
     }
     return $result;
 }
示例#6
0
 private function loadPages()
 {
     $this->prevPeople = array();
     $this->prevFamilies = array();
     $revision = StructuredData::getRevision($this->title);
     if ($revision) {
         $content =& $revision->getText();
         $xml = StructuredData::getXml($this->tagName, $content);
         if (isset($xml)) {
             foreach ($xml->person as $person) {
                 $title = (string) $person['title'];
                 $this->prevPeople[$title] = Family::getFamilyMemberAttributes($person);
             }
             foreach ($xml->family as $family) {
                 $title = (string) $family['title'];
                 $this->prevFamilies[$title] = array();
             }
         }
     }
 }
示例#7
0
文件: Hooks.php 项目: k-hasan-19/wiki
function wrArticleSave(&$article, &$user, $text)
{
    $newTitle = Title::newFromRedirect($text);
    // can't use $article->content or SD:getRedirectToTitle because they return the wrong results
    if ($newTitle != null) {
        // if this article is a redirect
        $newTitle = StructuredData::getRedirectToTitle($newTitle, true);
        // get final redirect; unreliable on the article title for some reason
        $newRevision = StructuredData::getRevision($newTitle, false, true);
        $newText = $newRevision ? $newRevision->getText() : '';
        $summary = StructuredData::getWatchlistSummary($newTitle, $newText);
        WatchedItem::duplicateEntries($article->getTitle(), $newTitle, $summary);
        StructuredData::purgeTitle($newTitle, +1);
        StructuredData::requestIndex($newTitle);
        // remove watchers from redirected titles
        StructuredData::removeAllWatchers($article->getTitle());
    }
    return true;
}