public static function onPageHeaderIndexExtraButtons($response) { $app = F::app(); $extraButtons = $response->getVal('extraButtons'); if ($app->wg->title->getNamespace() == NS_CATEGORY && $app->wg->user->isAllowed('places-enable-category-geolocation')) { $isGeotaggingEnabled = PlaceCategory::newFromTitle($app->wg->title->getFullText())->isGeoTaggingEnabled(); $commonClasses = 'secondary geoEnableButton'; $extraButtons[] = F::app()->renderView('MenuButton', 'Index', array('action' => array("href" => "#", "text" => wfMsg('places-category-switch')), 'class' => !$isGeotaggingEnabled ? $commonClasses . ' disabled' : $commonClasses, 'name' => 'places-category-switch-on')); $extraButtons[] = F::app()->renderView('MenuButton', 'Index', array('action' => array("href" => "#", "text" => wfMsg('places-category-switch-off')), 'class' => $isGeotaggingEnabled ? $commonClasses . ' disabled' : $commonClasses, 'name' => 'places-category-switch-off')); } $response->setVal('extraButtons', $extraButtons); return true; }
public function disableGeoTagging() { if (!wfReadOnly() && $this->app->wg->user->isAllowed('places-enable-category-geolocation')) { $sTitle = $this->getVal('pageName', null); if (!empty($sTitle)) { $oPlacesCategory = PlaceCategory::newFromTitle($sTitle); $oPlacesCategory->disableGeoTagging(); $this->setVal('error', 0); } else { $this->setVal('error', 1); } } else { $this->setVal('error', 1); } }
public function isGeoTaggingEnabledForArticle(Title $oTitle) { $oArticle = $this->app->wg->article; if (is_object($oArticle) && is_object($oArticle->mParserOutput) && is_object($oArticle->mParserOutput->mCategories)) { $aCategories = $oArticle->mParserOutput->mCategories; } else { return false; } if (!empty($aCategories)) { $aCategories = array_keys($aCategories); foreach ($aCategories as $sCategory) { $oTmpTitle = Title::newFromText($sCategory, NS_CATEGORY); if (PlaceCategory::newFromTitle($oTmpTitle->getFullText())->isGeoTaggingEnabled()) { return true; } } } return false; }
/** * Renders the geolocation button for adding coordinates to a page */ public function getGeolocationButton() { if ($this->app->wg->title->isContentPage() && PlaceStorage::newFromTitle($this->app->wg->title)->getModel()->isEmpty() && PlaceCategory::newFromTitle($this->app->wg->title->getFullText())->isGeoTaggingEnabledForArticle($this->app->wg->title)) { $this->setVal('geolocationParams', $this->getGeolocationButtonParams()); $this->response->setVal('jsSnippet', PlacesParserHookHandler::getJSSnippet()); (new JSMessages())->enqueuePackage('PlacesGeoLocationModal', JSMessages::INLINE); } else { $this->skipRendering(); } }