/**
  * Render <places> 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 renderPlacesTag($content, array $attributes, Parser $parser, PPFrame $frame)
 {
     wfProfileIn(__METHOD__);
     // parse attributes
     $height = !empty($attributes['height']) && is_numeric($attributes['height']) ? $attributes['height'] : 400;
     $categories = !empty($attributes['category']) ? explode('|', $attributes['category']) : false;
     $animate = !empty($attributes['animate']) ? is_numeric($attributes['animate']) ? intval($attributes['animate']) : 5 : false;
     // get all places on this wiki
     $placesModel = new PlacesModel();
     $markers = empty($categories) ? $placesModel->getAll() : $placesModel->getFromCategories($categories);
     // render parser hook
     $html = F::app()->sendRequest('Places', 'renderMarkers', array('markers' => $markers, 'height' => $height, 'options' => array('animate' => $animate)))->toString();
     wfProfileOut(__METHOD__);
     return $html;
 }
 /**
  * Get markers from articles "related" to a given article
  *
  * Returns data to be rendered on the client-side
  */
 public function getMarkersRelatedToCurrentTitle()
 {
     $sTitle = $this->getVal('title', '');
     $sCategoriesText = $this->getVal('category', '');
     $oTitle = Title::newFromText($sTitle);
     if ($oTitle instanceof Title) {
         $oPlacesModel = new PlacesModel();
         $oMarker = PlaceStorage::newFromTitle($oTitle)->getModel();
         $oMarker->setCategories($sCategoriesText);
         if (!empty($sCategoriesText)) {
             $aMarkers = $oPlacesModel->getFromCategories($oMarker->getCategories());
         } else {
             $aMarkers = $oPlacesModel->getFromCategoriesByTitle($oTitle);
         }
         $oMarker = PlaceStorage::newFromTitle($oTitle)->getModel();
         $this->setVal('center', $oMarker->getForMap());
         $this->setVal('markers', $this->prepareMarkers($aMarkers));
         // generate modal caption
         $this->setVal('caption', wfMessage('places-modal-go-to-special', count($this->markers))->parse());
     }
 }
 public function execute()
 {
     wfProfileIn(__METHOD__);
     $placesModel = new PlacesModel();
     $params = $this->extractRequestParams();
     $places = array();
     // get geodata from article by its ID
     if (isset($params['pageid'])) {
         $storage = PlaceStorage::newFromId($params['pageid']);
         $places = array($storage->getModel());
     } elseif (isset($params['title'])) {
         $title = Title::newFromText($params['title']);
         if ($title instanceof Title) {
             $storage = PlaceStorage::newFromTitle($title);
             $places = array($storage->getModel());
         }
     } elseif (isset($params['category'])) {
         $categories = explode('|', $params['category']);
         $places = $placesModel->getFromCategories($categories);
     } elseif (isset($params['related'])) {
         $title = Title::newFromText($params['related']);
         if ($title instanceof Title) {
             $places = $placesModel->getFromCategoriesByTitle($title);
         }
     } else {
         $places = $placesModel->getAll();
     }
     // generate results
     $rows = array();
     foreach ($places as $place) {
         $title = Title::newFromID($place->getPageId());
         $rows[] = array('pageid' => $place->getPageId(), 'title' => $title instanceof Title ? $title->getPrefixedText() : '', 'lat' => $place->getLat(), 'lan' => $place->getLon());
     }
     $results = $this->getResult();
     $results->setIndexedTagName($rows, 'place');
     $results->addValue('query', 'places', $rows);
     wfProfileOut(__METHOD__);
 }
 protected function allPlaces()
 {
     $placesModel = new PlacesModel();
     return $placesModel->getAll(500);
     // limit number of places for special pages
 }