/** * Hook-Handler for MediaWiki 'BeforePageDisplay' hook. Sets context if needed. * @param OutputPage $oOutputPage * @param Skin $oSkin * @return bool */ public function onBeforePageDisplay(&$oOutputPage, &$oSkin) { if (BsExtensionManager::isContextActive('MW::SaferEdit') === false) { return true; } $oOutputPage->addModules('ext.bluespice.saferedit.general'); if (BsExtensionManager::isContextActive('MW::SaferEditEditMode') === false) { return true; } $oOutputPage->addModules('ext.bluespice.saferedit.editmode'); return true; }
/** * This method actually generates the output * @param mixed $params Comes from base class definition. Not used in this implementation. * @return string HTML output */ public function execute($params = false) { $this->initFields(); wfRunHooks('BsAuthorPageProfileImageAfterInitFields', array(&$this, $this->oUser)); // CR RBV (03.06.11 08:39): Hook/Event! if (BsExtensionManager::isContextActive('MW::SecureFileStore::Active')) { $this->sImagePath = SecureFileStore::secureStuff($this->sImagePath, true); } $aOut = array(); $aOut[] = '<div id="bs-authors-imageform" class="bs-userpagesettings-item">'; $aOut[] = $this->renderLink(array('href' => htmlspecialchars($this->sImageUploadPath), 'title' => wfMessage('bs-authors-profileimage-change')->plain()), '<img src="' . $this->sImagePath . '" alt="' . $this->sUserDisplayName . '" width="64" title="' . wfMessage('bs-authors-profileimage')->plain() . '" />' . '<div class="bs-user-label">' . wfMessage('bs-authors-profileimage-change')->plain() . '</div>'); $aOut[] = '</div>'; return implode("\n", $aOut); }
/** * Hook-Handler for Hook 'BSStateBarBeforeBodyViewAdd' * @param StateBar $oStateBar * @param array $aBodyViews * @return boolean Always true to keep hook running */ public function onStateBarBeforeBodyViewAdd($oStateBar, &$aBodyViews, $oUser, $oTitle) { if (BsExtensionManager::isContextActive('MW::ArticleInfo::Hide')) { return true; } wfProfileIn('BS::' . __METHOD__); $aBodyElements = array('statebarbodysubpages' => $this->makeStateBarBodySubPages($oTitle), 'statebarbodycategories' => $this->makeStateBarBodyCategories($oTitle), 'statebarbodytemplates' => $this->makeStateBarBodyTemplates($oTitle)); foreach ($aBodyElements as $sKey => $oBodyView) { if (!$oBodyView) { continue; } $aBodyViews[$sKey] = $oBodyView; } wfProfileOut('BS::' . __METHOD__); return true; }
/** * Adds entry to navigation sites * @global string $wgScriptPath * @param array $aNavigationSites * @return boolean - always true */ public function onBSTopMenuBarCustomizerRegisterNavigationSites(&$aNavigationSites) { global $wgScriptPath; // Reset all other active markers if Blog is active if (BsExtensionManager::isContextActive('MW::Blog::ShowBlog')) { for ($i = 0; $i < sizeof($aNavigationSites); $i++) { $aNavigationSites[$i]["active"] = false; } } $aNavigationSites[] = array('id' => 'nt-blog', 'href' => wfAppendQuery($wgScriptPath . '/index.php', array('action' => 'blog')), 'active' => BsExtensionManager::isContextActive('MW::Blog::ShowBlog'), 'text' => wfMessage('bs-blog-blog')->plain()); return true; }
/** * Adds the shoutbox output to be rendered from skin. * @param SkinTemplate $sktemplate a collection of views. Add the view that needs to be displayed * @param BaseTemplate $tpl currently logged in user. Not used in this context. * @return bool always true */ public function onSkinTemplateOutputPageBeforeExec(&$sktemplate, &$tpl) { if (!BsExtensionManager::isContextActive('MW::ShoutboxShow')) { return true; } $tpl->data['bs_dataAfterContent']['bs-shoutbox'] = array('position' => 30, 'label' => wfMessage('bs-shoutbox-title')->text(), 'content' => $this->getShoutboxViewForAfterContent($sktemplate)); return true; }
/** * Get the Users for specialpage, called via ajax * @param string $sPage page title * @return bool Always true */ public static function getUsers($sPage) { $oTitle = Title::newFromText($sPage); if (!$oTitle->exists()) { return json_encode(array()); } $iArticleID = $oTitle->getArticleID(); $oStoreParams = BsExtJSStoreParams::newFromRequest(); $iLimit = $oStoreParams->getLimit(); $iStart = $oStoreParams->getStart(); $sSort = $oStoreParams->getSort('MAX(readers_ts)'); $sDirection = $oStoreParams->getDirection(); if ($sSort == 'user_name') { $sSort = 'readers_user_name'; } elseif ($sSort == 'user_ts') { $sSort = 'readers_ts'; } elseif ($sSort == 'user_readers') { $sSort = 'readers_user_name'; } $oDbr = wfGetDB(DB_SLAVE); $res = $oDbr->select(array('bs_readers'), array('readers_user_id', 'MAX(readers_ts) as readers_ts'), array('readers_page_id' => $iArticleID), __METHOD__, array('GROUP BY' => 'readers_user_id', 'ORDER BY' => $sSort . ' ' . $sDirection, 'LIMIT' => $iLimit, 'OFFSET' => $iStart)); $aUsers = array(); if ($oDbr->numRows($res) > 0) { $aParams = array(); $oLanguage = RequestContext::getMain()->getLanguage(); foreach ($res as $row) { $oUser = User::newFromId((int) $row->readers_user_id); $oTitle = Title::makeTitle(NS_USER, $oUser->getName()); $oUserMiniProfile = BsCore::getInstance()->getUserMiniProfile($oUser, $aParams); $sImage = $oUserMiniProfile->getUserImageSrc(); if (BsExtensionManager::isContextActive('MW::SecureFileStore::Active')) { $sImage = SecureFileStore::secureStuff($sImage, true); } $aTmpUser = array(); $aTmpUser['user_image'] = $sImage; $aTmpUser['user_name'] = $oUser->getName(); $aTmpUser['user_page'] = $oTitle->getLocalURL(); $aTmpUser['user_readers'] = SpecialPage::getTitleFor('Readers', $oTitle->getPrefixedText())->getLocalURL(); $aTmpUser['user_ts'] = $row->readers_ts; $aTmpUser['user_date'] = $oLanguage->timeanddate($row->readers_ts); $aUsers['users'][] = $aTmpUser; } } $rowCount = $oDbr->select('bs_readers', 'readers_user_id', array('readers_page_id' => $iArticleID), __METHOD__, array('GROUP BY' => 'readers_user_id')); $aUsers['totalCount'] = $oDbr->numRows($rowCount); return json_encode($aUsers); }
/** * Creates the StateBar. on articles. * @param SkinTemplate $sktemplate * @param BaseTemplate $tpl * @return boolean Always true to keep hook running */ public function onSkinTemplateOutputPageBeforeExec(&$sktemplate, &$tpl) { if (BsExtensionManager::isContextActive('MW::StateBarShow') === false) { return true; } if (!is_null($this->oRedirectTargetTitle)) { $oTitle = $this->oRedirectTargetTitle; } wfRunHooks('BSStateBarBeforeTopViewAdd', array($this, &$this->aTopViews, $sktemplate->getUser(), $sktemplate->getTitle(), $sktemplate)); if (count($this->aTopViews) == 0) { // TODO RBV (01.07.11 18:26): Ain't this too late? BsExtensionManager::removeContext('MW::StateBarShow'); return true; } $aSortTopVars = BsConfig::get('MW::StateBar::SortTopVars'); if (!empty($aSortTopVars)) { $this->aTopViews = $this->reorderViews($this->aTopViews, $aSortTopVars); } $oViewStateBar = new ViewStateBar(); foreach ($this->aTopViews as $mKey => $oTopView) { $oViewStateBar->addStateBarTopView($oTopView); } if ($tpl instanceof BsBaseTemplate) { $tpl->data['bs_dataBeforeContent']['bs-statebar'] = array('position' => 20, 'label' => wfMessage('prefs-statebar')->text(), 'content' => $oViewStateBar); } else { //this is the case when BlueSpice Skin is not active, so use vector methods. $tpl->data['prebodyhtml'] .= $oViewStateBar; } return true; }