/**
  * Render <place> tag
  *
  * @param string $content tag content (will be ignored)
  * @param array $attributes tag attributes
  * @param Parser $parser MW parser instance
  * @param PPFrame $frame parent frame with the context
  * @return string HTML output of the tag
  */
 public static function renderPlaceTag($content, array $attributes, Parser $parser, PPFrame $frame)
 {
     wfProfileIn(__METHOD__);
     // wrap data in a model object
     $placeModel = PlaceModel::newFromAttributes($attributes);
     // are we rendering for RTE?
     $inRTE = !empty(F::app()->wg->RTEParserEnabled);
     if ($inRTE) {
         $wikitext = RTEData::get('wikitext', self::$lastWikitextId);
         $data = array('wikitext' => $wikitext, 'placeholder' => 1);
         $rteData = RTEData::convertDataToAttributes($data);
     } else {
         $rteData = false;
     }
     // render parser hook
     $html = F::app()->sendRequest('Places', 'placeFromModel', array('model' => $placeModel, 'rteData' => $rteData))->toString();
     // add JS snippets code
     if (!$inRTE) {
         $html .= self::getJSSnippet();
     }
     // add model to be stored in database
     (new PlacesHooks())->setModelToSave($placeModel);
     $html = self::cleanHTML($html);
     wfProfileOut(__METHOD__);
     return $html;
 }
예제 #2
0
 protected function setUp()
 {
     $this->setupFile = __DIR__ . '/../Places.setup.php';
     parent::setUp();
     $this->attribs = array('align' => 'right', 'width' => 300, 'caption' => 'Foo', 'lat' => '52.406878', 'lon' => '16.922124');
     $this->model = PlaceModel::newFromAttributes($this->attribs);
     // use main page as an article for this place
     $mainPage = Title::newMainPage();
     $this->model->setPageId($mainPage->getArticleId());
 }
예제 #3
0
 /**
  * Get geo data of all "nearby" articles (within given distance in kilometres)
  *
  * TODO: implement
  *
  * @param PlaceModel $center place to find nearby places for
  * @param int $distance define nearby distance (in km)
  * @return array set of PlaceModel objects
  */
 public function getNearby(PlaceModel $center, $distance = 10)
 {
     wfProfileIn(__METHOD__);
     $models = $this->query(array('nearby' => $center->getLatLon(), 'distance' => intval($distance)));
     wfProfileOut(__METHOD__);
     return $models;
 }
예제 #4
0
 /**
  * Create a new place based on geo data provided and store it in the database
  */
 public function saveNewPlaceToArticle()
 {
     $oPlaceModel = new PlaceModel();
     $oPlaceModel->setPageId($this->getVal('articleId', 0));
     if ($oPlaceModel->getPageId() == 0) {
         $this->setVal('error', wfMsg('places-error-no-article'));
         $this->setVal('success', false);
     } else {
         $oStorage = PlaceStorage::newFromId($oPlaceModel->getPageId());
         if ($oStorage->getModel()->isEmpty() == false) {
             $this->setVal('error', wfMsg('places-error-place-already-exists'));
             $this->setVal('success', false);
         } else {
             $oPlaceModel->setAlign($this->getVal('align', false));
             $oPlaceModel->setWidth($this->getVal('width', false));
             $oPlaceModel->setHeight($this->getVal('height', false));
             $oPlaceModel->setLat($this->getVal('lat', false));
             $oPlaceModel->setLon($this->getVal('lon', false));
             $oPlaceModel->setZoom($this->getVal('zoom', false));
             $sText = $this->sendRequest('PlacesController', 'getPlaceWikiTextFromModel', array('model' => $oPlaceModel))->toString();
             $oTitle = Title::newFromID($oPlaceModel->getPageId());
             if ($oTitle instanceof Title && $oTitle->exists()) {
                 $oArticle = new Article($oTitle);
                 $sNewContent = $sText . $oArticle->getContent();
                 $status = $oArticle->doEdit($sNewContent, wfMsg('places-updated-geolocation'), EDIT_UPDATE);
                 $this->setVal('success', true);
             } else {
                 $this->setVal('error', wfMsg('places-error-no-article'));
                 $this->setVal('success', false);
             }
         }
     }
 }
예제 #5
0
 public function ArchivePlaceByAdmin($param)
 {
     parent::ArchiveAllCommentProcess($param);
     parent::ArchiveAllPostProcess($param);
     parent::ArchivePlaceProcess($param);
 }