/** * offers the formular for the group manager * @return string the formular code */ public function getForm() { $this->getOutput()->addModules('ext.bluespice.groupManager'); BsExtensionManager::setContext('MW::GroupManagerShow'); $sForm = '<div id="bs-groupmanager-grid"></div>'; return $sForm; }
/** * Renders the main form. Called by WikiAdmin * @return string rendered HTML */ public function getForm() { $this->getOutput()->addModuleStyles('ext.bluespice.extensioninfo.styles'); $this->getOutput()->addModules('ext.bluespice.extensioninfo'); BsExtensionManager::setContext('MW::ExtensionInfoShow'); $oViewExtensionInfoTable = new ViewExtensionInfoTable(); $aInfos = BsExtensionManager::getExtensionInformation(); ksort($aInfos); $oViewExtensionInfoTable->setExtensions($aInfos); return $oViewExtensionInfoTable->execute(); }
/** * Initialization of ExtendedEditBar extension */ protected function initExt() { wfProfileIn('BS::' . __METHOD__); BsExtensionManager::setContext('MW::SecureFileStore::Active'); BsConfig::registerVar('MW::SecureFileStore::Active', true, BsConfig::LEVEL_PRIVATE | BsConfig::TYPE_BOOL | BsConfig::RENDER_AS_JAVASCRIPT); BsConfig::registerVar('MW::SecureFileStore::DefaultDisposition', 'inline', BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_STRING | BsConfig::USE_PLUGIN_FOR_PREFS, 'bs-securefilestore-pref-defaultdisposition', 'select'); BsConfig::registerVar('MW::SecureFileStore::DispositionInline', array('pdf'), BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_ARRAY_STRING, 'bs-securefilestore-pref-dispositioninline', 'multiselectplusadd'); BsConfig::registerVar('MW::SecureFileStore::DispositionAttachment', array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'), BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_ARRAY_STRING, 'bs-securefilestore-pref-dispositionattachment', 'multiselectplusadd'); BsConfig::registerVar('MW::SecureFileStore::FileExtensionWhitelist', array(), BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_ARRAY_STRING | BsConfig::RENDER_AS_JAVASCRIPT, 'bs-securefilestore-pref-fileextensionwhitelist', 'multiselectplusadd'); $this->setHook('SkinTemplateOutputPageBeforeExec', 'secureImages'); $this->setHook('ExtendedSearchBeforeAjaxResponse', 'secureImages'); $this->setHook('SiteNoticeAfter', 'onSiteNoticeAfter'); $this->mCore->registerPermission('viewfiles', array('user'), array('type' => 'global')); wfProfileOut('BS::' . __METHOD__); }
public function noArticleInfoCallback() { BsExtensionManager::setContext('MW::ArticleInfo::Hide'); }
/** * Renders the blog. Called by parser function for bs:blog tag and also from Blog::onUnknownAction. * @param string $input Inner HTML of bs:blog tag. Not used. * @param array $args List of tag attributes. * @param Parser $parser MediaWiki parser object * @return string HTML output that is to be displayed. */ public function onBlog($input, $args, $parser) { $oTitle = null; if ($parser instanceof Parser) { $oTitle = $parser->getTitle(); $parser->disableCache(); } else { $oTitle = $this->getTitle(); } $sKey = BsCacheHelper::getCacheKey('BlueSpice', 'Blog', $oTitle->getArticleID()); $aData = BsCacheHelper::get($sKey); if ($aData !== false) { return $aData; } // initialize local variables $oErrorListView = new ViewTagErrorList($this); BsExtensionManager::setContext('MW::Blog::ShowBlog'); // get all config options $iShowLimit = BsConfig::get('MW::Blog::ShowLimit'); //$blogShowTrackback = BsConfig::get('MW::Blog::ShowTrackback'); // see comment below $bShowPermalink = BsConfig::get('MW::Blog::ShowPermalink'); $bShowInfo = BsConfig::get('MW::Blog::ShowInfo'); $sSortBy = BsConfig::get('MW::Blog::SortBy'); $bMoreInNewWindow = BsConfig::get('MW::Blog::MoreInNewWindow'); $bShowAll = BsConfig::get('MW::Blog::ShowAll'); $bMoreAtEndOfEntry = BsConfig::get('MW::Blog::MoreAtEndOfEntry'); $bShowNewEntryField = BsConfig::get('MW::Blog::ShowNewEntryField'); $bNewEntryFieldPosition = BsConfig::get('MW::Blog::NewEntryFieldPosition'); $sImageRenderMode = BsConfig::get('MW::Blog::ImageRenderMode'); $sImageFloatDirection = BsConfig::get('MW::Blog::ThumbFloatDirection'); $iMaxEntryCharacters = BsConfig::get('MW::Blog::MaxEntryCharacters'); // Trackbacks are not supported the way we intend it to be. From http://www.mediawiki.org/wiki/Manual:$wgUseTrackbacks // When MediaWiki receives a trackback ping, a box will show up at the bottom of the article containing a link to the originating page //if (!$wgUseTrackbacks) $bShowTrackback = false; // get tag attributes $argsIShowLimit = BsCore::sanitizeArrayEntry($args, 'count', $iShowLimit, BsPARAMTYPE::NUMERIC | BsPARAMOPTION::DEFAULT_ON_ERROR); $argsSCategory = BsCore::sanitizeArrayEntry($args, 'cat', false, BsPARAMTYPE::STRING); $argsINamespace = BsNamespaceHelper::getNamespaceIndex(BsCore::sanitizeArrayEntry($args, 'ns', NS_BLOG, BsPARAMTYPE::STRING)); $argsBNewEntryField = BsCore::sanitizeArrayEntry($args, 'newentryfield', $bShowNewEntryField, BsPARAMTYPE::BOOL); $argsSNewEntryFieldPosition = BsCore::sanitizeArrayEntry($args, 'newentryfieldposition', $bNewEntryFieldPosition, BsPARAMTYPE::STRING); $argsSImageRenderMode = BsCore::sanitizeArrayEntry($args, 'imagerendermode', $sImageRenderMode, BsPARAMTYPE::STRING); $argsSImageFloatDirection = BsCore::sanitizeArrayEntry($args, 'imagefloatdirection', $sImageFloatDirection, BsPARAMTYPE::STRING); $argsIMaxEntryCharacters = BsCore::sanitizeArrayEntry($args, 'maxchars', $iMaxEntryCharacters, BsPARAMTYPE::INT); $argsSSortBy = BsCore::sanitizeArrayEntry($args, 'sort', $sSortBy, BsPARAMTYPE::STRING); $argsBShowInfo = BsCore::sanitizeArrayEntry($args, 'showinfo', $bShowInfo, BsPARAMTYPE::BOOL); $argsBMoreInNewWindow = BsCore::sanitizeArrayEntry($args, 'moreinnewwindow', $bMoreInNewWindow, BsPARAMTYPE::BOOL); $argsBShowPermalink = BsCore::sanitizeArrayEntry($args, 'showpermalink', $bShowPermalink, BsPARAMTYPE::BOOL); $argsModeNamespace = BsCore::sanitizeArrayEntry($args, 'mode', null, BsPARAMTYPE::STRING); if ($argsModeNamespace === 'ns' && is_object($oTitle)) { $argsINamespace = $oTitle->getNamespace(); } // validate tag attributes $validateIShowLimit = BsValidator::isValid('ArgCount', $argsIShowLimit, array('fullResponse' => true)); if ($validateIShowLimit->getErrorCode()) { $oErrorListView->addItem(new ViewTagError($validateIShowLimit->getI18N())); } if ($argsSCategory) { $validateSCategory = BsValidator::isValid('Category', $argsSCategory, array('fullResponse' => true)); if ($validateSCategory->getErrorCode()) { $oErrorListView->addItem(new ViewTagError($validateSCategory->getI18N())); } } $oValidationResult = BsValidator::isValid('SetItem', $argsSImageRenderMode, array('fullResponse' => true, 'setname' => 'imagerendermode', 'set' => array('full', 'thumb', 'none'))); if ($oValidationResult->getErrorCode()) { $oErrorListView->addItem(new ViewTagError($oValidationResult->getI18N())); } $oValidationResult = BsValidator::isValid('SetItem', $argsSImageFloatDirection, array('fullResponse' => true, 'setname' => 'imagefloatdirection', 'set' => array('left', 'right', 'none'))); if ($oValidationResult->getErrorCode()) { $oErrorListView->addItem(new ViewTagError($oValidationResult->getI18N())); } $oValidationResult = BsValidator::isValid('SetItem', $argsSSortBy, array('fullResponse' => true, 'setname' => 'sort', 'set' => array('title', 'creation'))); if ($oValidationResult->getErrorCode()) { $oErrorListView->addItem(new ViewTagError($oValidationResult->getI18N())); } // if there are errors, abort with a message if ($oErrorListView->hasEntries()) { return $oErrorListView->execute(); } if (BsConfig::get('MW::Blog::ShowTagFormWhenNotLoggedIn') != true) { $oPermissionTest = Title::newFromText('PermissionTest', $argsINamespace); if (!$oPermissionTest->userCan('edit')) { $argsBNewEntryField = false; } } // get array of article ids from Blog/subpages $oBlogTitle = Title::makeTitleSafe($oTitle->getNamespace(), 'Blog'); $aSubpages = $oBlogTitle->getSubpages(); $iLimit = 0; // for later use $aArticleIds = array(); foreach ($aSubpages as $oSubpage) { $aArticleIds[] = $oSubpage->getArticleID(); $iLimit++; // for later use } if (count($aArticleIds) < 1) { $aArticleIds = 0; } $aTables = array('page'); $aFields = array('entry_page_id' => 'page_id'); $aConditions = array(); $aOptions = array(); $aJoins = array(); $dbr = wfGetDB(DB_SLAVE); // get blog entries if ($argsSSortBy == 'title') { $aOptions['ORDER BY'] = 'page_title ASC'; } else { //Creation: Also fetch possible custom timestamps from page_props table $aOptions['ORDER BY'] = 'entry_timestamp DESC'; $aOptions['GROUP BY'] = 'page_id'; global $wgDBtype; switch ($wgDBtype) { case 'oracle': $aFields['entry_timestamp'] = "NVL( pp_value, rev_timestamp )"; $aConditions[] = "NVL( pp_value, rev_timestamp ) < " . wfTimestampNow(); break; case 'mssql': $aFields['entry_timestamp'] = "ISNULL( pp_value, rev_timestamp )"; $aConditions[] = "ISNULL( pp_value, rev_timestamp ) < " . wfTimestampNow(); break; case 'postgres': $aFields['entry_timestamp'] = "NULLIF( pp_value, rev_timestamp )"; $aConditions[] = "NULLIF( pp_value, rev_timestamp ) < " . wfTimestampNow(); break; default: //MySQL, SQLite //use pp_value if exists $aFields['entry_timestamp'] = "IFNULL( pp_value, rev_timestamp )"; //also do not list future entries $aConditions[] = "IFNULL( pp_value, rev_timestamp ) < " . wfTimestampNow(); } $aTables[] = 'revision'; $aTables[] = 'page_props'; $aConditions[] = 'rev_page = page_id'; $aJoins['page_props'] = array('LEFT JOIN', "pp_page = rev_page AND pp_propname = 'blogtime'"); } if ($argsSCategory) { $aTables[] = 'categorylinks'; $aConditions['cl_to'] = $argsSCategory; $aConditions[] = 'cl_from = page_id'; } else { if ($argsModeNamespace === 'ns') { $aConditions['page_id'] = $aArticleIds; } $aConditions['page_namespace'] = $argsINamespace; } $res = $dbr->select($aTables, $aFields, $aConditions, __METHOD__, $aOptions, $aJoins); $iNumberOfEntries = $dbr->numRows($res); $iLimit = $iNumberOfEntries; //All // Sole importance is the existence of param 'showall' $paramBShowAll = $this->getRequest()->getFuzzyBool('showall', false); if ($paramBShowAll == false) { $iLimit = $argsIShowLimit; } // abort if there are no entries if ($iNumberOfEntries < 1) { $oBlogView = new ViewBlog(); $oBlogView->setOption('shownewentryfield', $argsBNewEntryField); $oBlogView->setOption('newentryfieldposition', $argsSNewEntryFieldPosition); $oBlogView->setOption('namespace', BsNamespaceHelper::getNamespaceName($argsINamespace)); if ($argsSCategory) { $oBlogView->setOption('blogcat', $argsSCategory); } // actually create blog output $sOut = $oBlogView->execute(); $sOut .= wfMessage('bs-blog-no-entries')->plain(); return $sOut; } $oBlogView = new ViewBlog(); // prepare views per blog item $iLoop = 0; foreach ($res as $row) { // prepare data for view class $oEntryTitle = Title::newFromID($row->entry_page_id); if (!$oEntryTitle->userCan('read')) { $iNumberOfEntries--; continue; } $bMore = false; $aContent = preg_split('#<(bs:blog:)?more */>#', BsPageContentProvider::getInstance()->getContentFromTitle($oEntryTitle)); if (sizeof($aContent) > 1) { $bMore = true; } $aContent = trim($aContent[0]); // Prevent recursive rendering of blog tag $aContent = preg_replace('/<(bs:)blog[^>]*?>/', '', $aContent); // Thumbnail images $sNamespaceRegEx = implode('|', BsNamespaceHelper::getNamespaceNamesAndAliases(NS_IMAGE)); switch ($argsSImageRenderMode) { case 'none': $aContent = preg_replace('/(\\[\\[(' . $sNamespaceRegEx . '):[^\\|\\]]*)(\\|)?(.*?)(\\]\\])/', '', $aContent); break; case 'full': // do nothing break; case 'thumb': default: $aContent = preg_replace('/(\\[\\[(' . $sNamespaceRegEx . '):[^\\|\\]]*)(\\|)?(.*?)(\\]\\])/', "\$1|thumb|{$argsSImageFloatDirection}\$3\$4|150px\$5", $aContent); break; } if (strlen($aContent) > $argsIMaxEntryCharacters) { $bMore = true; } $aContent = BsStringHelper::shorten($aContent, array('max-length' => $argsIMaxEntryCharacters, 'ignore-word-borders' => false, 'position' => 'end')); $resComment = $dbr->selectRow('revision', 'COUNT( rev_id ) AS cnt', array('rev_page' => $oEntryTitle->getTalkPage()->getArticleID())); $iCount = $resComment->cnt; // set data for view class $oBlogItemView = new ViewBlogItem(); // use magic set $oBlogItemView->setOption('showInfo', $argsBShowInfo); $oBlogItemView->setOption('showLimit', $argsIShowLimit); $oBlogItemView->setOption('showTrackback', $bShowTrackback); $oBlogItemView->setOption('showPermalink', $argsBShowPermalink); $oBlogItemView->setOption('moreInNewWindow', $argsBMoreInNewWindow); $oBlogItemView->setOption('showAll', $bShowAll); $oBlogItemView->setOption('moreAtEndOfEntry', $bMoreAtEndOfEntry); $oBlogItemView->setOption('more', $bMore); //TODO: magic_call? if ($argsModeNamespace === 'ns') { $sTitle = substr($oEntryTitle->getText(), 5); } else { $sTitle = $oEntryTitle->getText(); } $aTalkParams = array(); if (!$oEntryTitle->getTalkPage()->exists()) { $aTalkParams = array('action' => 'edit'); } $oRevision = Revision::newFromTitle($oEntryTitle); $oBlogItemView->setTitle($sTitle); $oBlogItemView->setRevId($oRevision->getId()); $oBlogItemView->setURL($oEntryTitle->getLocalURL()); $oBlogItemView->setTalkURL($oEntryTitle->getTalkPage()->getLocalURL($aTalkParams)); $oBlogItemView->setTalkCount($iCount); $oBlogItemView->setTrackbackUrl($oEntryTitle->getLocalURL()); if ($bShowInfo) { $oFirstRevision = $oEntryTitle->getFirstRevision(); $sTimestamp = $oFirstRevision->getTimestamp(); $sLocalDateTimeString = BsFormatConverter::timestampToAgeString(wfTimestamp(TS_UNIX, $sTimestamp)); $oBlogItemView->setEntryDate($sLocalDateTimeString); $iUserId = $oFirstRevision->getUser(); if ($iUserId != 0) { $oAuthorUser = User::newFromId($iUserId); $oBlogItemView->setAuthorPage($oAuthorUser->getUserPage()->getPrefixedText()); $oBlogItemView->setAuthorName($this->mCore->getUserDisplayName($oAuthorUser)); } else { $oBlogItemView->setAuthorName($oFirstRevision->getUserText()); } } $oBlogItemView->setContent($aContent); $oBlogView->addItem($oBlogItemView); $iLoop++; if ($iLoop >= $iLimit) { break; } } $dbr->freeResult($res); // prepare complete blog output if ($bShowAll && !$paramBShowAll && $iNumberOfEntries > $argsIShowLimit) { $oBlogView->setOption('showall', true); } $oBlogView->setOption('shownewentryfield', $argsBNewEntryField); $oBlogView->setOption('newentryfieldposition', $argsSNewEntryFieldPosition); $oBlogView->setOption('namespace', BsNamespaceHelper::getNamespaceName($argsINamespace, false)); $oBlogView->setOption('blogcat', $argsSCategory); if ($argsModeNamespace === 'ns') { $oBlogView->setOption('parentpage', 'Blog/'); } // actually create blog output $sOut = $oBlogView->execute(); //Use cache only in NS_BLOG - there is curently no functionality to //figure out in what type of blog tag a entry is showen and why //(coditions). Possible blog by categories or subpages... //Needs rework. if (in_array($oTitle->getNamespace(), array(NS_BLOG, NS_BLOG_TALK))) { $aKey = array($sKey); $sTagsKey = BsCacheHelper::getCacheKey('BlueSpice', 'Blog', 'Tags'); $aTagsData = BsCacheHelper::get($sTagsKey); if ($aTagsData !== false) { if (!in_array($sKey, $aTagsData)) { $aTagsData = array_merge($aTagsData, $aKey); } } else { $aTagsData = $aKey; } BsCacheHelper::set($sTagsKey, $aTagsData, 60 * 1440); // one day BsCacheHelper::set($sKey, $sOut, 60 * 1440); // one day } return $sOut; }
/** * Hook-Handler for MediaWiki 'BeforePageDisplay' hook. Sets context if needed. * @param OutputPage $oOutputPage * @param Skin $oSkin * @return bool */ public function onBeforePageDisplay(&$oOutputPage, &$oSkin) { if (!$this->getTitle()->userCan('read')) { return true; } BsExtensionManager::setContext('MW::WhoIsOnline::Show'); $oOutputPage->addModules('ext.bluespice.whoisonline'); return true; }
/** * Provides the form content for the WikiAdmin special page. * @return string the form content */ public function getForm() { $this->getOutput()->addModules('ext.bluespice.namespaceManager'); BsExtensionManager::setContext('MW::NamespaceManagerShow'); $aMetaFields = array(array('name' => 'id', 'type' => 'int', 'sortable' => true, 'label' => wfMessage('bs-namespacemanager-label-id')->plain()), array('name' => 'name', 'sortable' => true, 'label' => wfMessage('bs-namespacemanager-label-namespaces')->plain())); wfRunHooks('NamespaceManager::getMetaFields', array(&$aMetaFields)); $this->getOutput()->addJsConfigVars('bsNamespaceManagerMetaFields', $aMetaFields); return '<div id="bs-namespacemanager-grid"></div>'; }
public function onOutputPageBeforeHTML($oParserOutput, $sText) { global $wgScriptPath; // TODO RBV (13.07.11 15:44): Better recognition... if (strpos($sText, '<pre class="brush:') === false) { return true; } BsExtensionManager::setContext('MW::CSyntaxHighlight'); $sBrushScriptPath = $wgScriptPath . '/extensions/BlueSpiceExtensions/CSyntaxHighlight/resources'; $sTheme = BsConfig::get('MW::CSyntaxHighlight::Theme'); $sStyleBlock = '<link rel="stylesheet" href="' . $sBrushScriptPath . '/shTheme' . $sTheme . '.css" />'; $sStyleBlock .= '<link rel="stylesheet" href="' . $sBrushScriptPath . '/shCore.css" />'; $this->getOutput()->addHeadItem('BrushTheme', $sStyleBlock); return true; }
/** * * @param OutputPage $oOutputPage * @param SkinTemplate $oSkinTemplate * @return boolean */ public function onBeforePageDisplay($oOutputPage, $oSkinTemplate) { if (BsConfig::get('MW::ShoutBox::Show') === false) { return true; } $oTitle = $oOutputPage->getTitle(); if ($oOutputPage->isPrintable()) { return true; } if (is_object($oTitle) && $oTitle->exists() == false) { return true; } if (!$oTitle->userCan('readshoutbox')) { return true; } if ($this->getRequest()->getVal('action', 'view') != 'view') { return true; } if ($oTitle->isSpecialPage()) { return true; } if (!$oTitle->userCan('read')) { return true; } $aNamespacesToDisplayShoutBox = BsConfig::get('MW::ShoutBox::ShowShoutBoxByNamespace'); if (!in_array($oTitle->getNsText(), $aNamespacesToDisplayShoutBox)) { return true; } $vNoShoutbox = BsArticleHelper::getInstance($oTitle)->getPageProp('bs_noshoutbox'); if ($vNoShoutbox === '') { return true; } $oOutputPage->addModuleStyles('ext.bluespice.shoutbox.styles'); $oOutputPage->addModules('ext.bluespice.shoutbox'); $oOutputPage->addModules('ext.bluespice.shoutbox.mention'); BsExtensionManager::setContext('MW::ShoutboxShow'); return true; }
/** * Hook-Handler for MediaWiki 'BeforePageDisplay' hook. Sets context if needed. * @param OutputPage $oOutputPage * @param Skin $oSkin * @return bool */ public function onBeforePageDisplay(&$oOutputPage, &$oSkin) { if (BsConfig::get('MW::StateBar::Show') === false) { return true; } global $wgTitle; //PW(24.06.2014): //make sure to use wgTitle to get possible redirect as early as possible! //also prevents from get wrong data in redirect redirect //please do not change! $oTitle = $this->checkContext($wgTitle); /* PLEASE DO NOT CHANGE !!!! $oTitle = $this->checkContext( $this->getTitle() ); */ if (is_null($oTitle)) { return true; } $oOutputPage->addModules('ext.bluespice.statebar'); $oOutputPage->addModuleStyles('ext.bluespice.statebar.style'); BsExtensionManager::setContext('MW::StateBarShow'); return true; }
/** * Hook-Handler for MW hook BeforeInitialize - Used to set Context * @param Title $oTitle * @param Article $oArticle * @param OutPutpage $oOutput * @param User $oUser * @param WebRequest $oRequest * @param MediaWiki $oMediaWiki * @return boolean - always true */ public function onBeforeInitialize(&$oTitle, $oArticle, &$oOutput, &$oUser, $oRequest, $oMediaWiki) { if (!is_object($oTitle) || !$oTitle->userCan('read') || $oTitle->getNamespace() === NS_SPECIAL) { return true; } $sAction = $oRequest->getVal('action', 'view'); if (!in_array($sAction, array('edit', 'submit', 'view'))) { return true; } BsExtensionManager::setContext('MW::SaferEdit'); if (!$oTitle->userCan('edit') || !in_array($sAction, array('edit', 'submit'))) { return true; } BsExtensionManager::setContext('MW::SaferEditEditMode'); return true; }