コード例 #1
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);
             }
         }
     }
 }