/** * Sets parameters for more complex options in preferences * @param string $sAdapterName Name of the adapter, e.g. MW * @param BsConfig $oVariable Instance of variable * @return array Preferences options */ public function runPreferencePlugin($sAdapterName, $oVariable) { $aPrefs = array(); switch ($oVariable->getName()) { case 'DefaultTemplate': $aParams = array('template-path' => BsConfig::get('MW::UEModulePDF::TemplatePath')); $aPrefs = array('type' => 'select', 'options' => BsPDFTemplateProvider::getTemplatesForSelectOptions($aParams)); break; default: break; } return $aPrefs; }
/** * Renders a form field that allows to create a new blog entry. * @return string HTML of form. */ public function renderShowNewEntryField() { global $wgScriptPath, $wgUser; $sId = 'blog' . self::$iFormElementCount; self::$iFormElementCount++; $sParentpage = $this->getOption('parentpage') ? $this->getOption('parentpage') : ''; $aOut = array(); $aOut[] = '<script type="text/javascript">'; $aOut[] = 'hw_' . $sId . '_submit = function() {'; $aOut[] = ' pagename = "' . $sParentpage . '" + document.getElementById("' . $sId . 'Input").value;'; //$aOut[] = ' if(!check_pagename(pagename)) return false;'; $aOut[] = ' pagename = pagename.replace(" ", "_");'; if ($wgUser->isLoggedIn() || BsConfig::get('MW::Blog::ShowTagFormWhenNotLoggedIn') != true) { $aOut[] = ' url = unescape("' . $wgScriptPath . '/index.php?title=' . ($this->getOption('namespace') ? $this->getOption('namespace') . ':' : '') . '"+pagename+"%26action"+"=edit"+"%26blogcat=' . $this->getOption('blogcat') . '");'; } else { $aOut[] = ' url = unescape("' . $wgScriptPath . '/index.php%3Ftitle=special:userlogin%26returnto=' . $this->getOption('namespace') . ':"+pagename);'; } $aOut[] = ' window.location.href = url;'; $aOut[] = '}'; $aOut[] = '</script>'; $aOut[] = '<div class="bs-blog-wrapper clearfix">'; $aOut[] = ' <form action="#" id="' . $sId . 'form" action="get" onsubmit="hw_' . $sId . '_submit();return false;">'; $aOut[] = ' <div class="bs-blog-form-center">'; $aOut[] = ' <h2 class="bs-blog-header">' . wfMessage('bs-blog-form-title-text')->plain() . '</h2>'; $aOut[] = ' <input id="' . $sId . 'Input" class="bs-blog-newentry-input" name="newpage" type="text" value="' . wfMessage('bs-blog-form-inline-text')->plain() . '" onfocus="if (this.value==\'' . wfMessage('bs-blog-form-inline-text')->plain() . '\') this.value=\'\';" />'; $aOut[] = ' <input type="hidden" name="blogcat" value="' . $this->getOption('blogcat') . '" />'; $aOut[] = ' <input type="submit" name="go" class="bs-blog-newentry-submit" id="' . $sId . 'Button" value="' . wfMessage('bs-blog-form-button-text')->plain() . '" onclick="hw_' . $sId . '_submit(); return false;"/> '; $aOut[] = ' </div>'; $aOut[] = ' </form>'; $aOut[] = '</div>'; return implode("", $aOut); }
/** * Initialization of ContextMenu extension */ protected function initExt() { $this->setHook('BeforePageDisplay'); $this->setHook('LinkEnd'); $this->setHook('ThumbnailBeforeProduceHTML'); BsConfig::registerVar('MW::ContextMenu::Modus', 'ctrl', BsConfig::LEVEL_USER | BsConfig::TYPE_STRING | BsConfig::USE_PLUGIN_FOR_PREFS, 'bs-contextmenu-pref-modus', 'radio'); }
/** * Initialization of UniversalExport extension */ protected function initExt() { wfProfileIn('BS::' . __METHOD__); //Hooks $this->setHook('ParserFirstCallInit', 'onParserFirstCallInit'); $this->setHook('BSWidgetBarGetDefaultWidgets'); $this->setHook('BSWidgetListHelperInitKeyWords'); $this->setHook('BSStateBarAddSortBodyVars', 'onStatebarAddSortBodyVars'); $this->setHook('BSStateBarBeforeBodyViewAdd'); $this->setHook('BSInsertMagicAjaxGetData', 'onBSInsertMagicAjaxGetData'); $this->setHook('BeforePageDisplay'); global $wgBlueSpiceExtInfo; //Configuration variables $aMetadataDefaults = array('creator' => 'Hallo Welt! Medienwerkstatt GmbH'); $aMetadataOverrides = array('producer' => 'UniversalExport ' . $wgBlueSpiceExtInfo['version'] . ' (BlueSpice for MediaWiki)'); BsConfig::registerVar('MW::UniversalExport::CategoryWhitelist', $this->aCategoryWhitelist, BsConfig::LEVEL_PRIVATE | BsConfig::TYPE_ARRAY_STRING); BsConfig::registerVar('MW::UniversalExport::CategoryBlacklist', $this->aCategoryBlacklist, BsConfig::LEVEL_PRIVATE | BsConfig::TYPE_ARRAY_STRING); BsConfig::registerVar('MW::UniversalExport::MetadataDefaults', json_encode($aMetadataDefaults), BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_STRING | BsConfig::USE_PLUGIN_FOR_PREFS, 'bs-universalexport-pref-metadatadefaults', 'textarea'); BsConfig::registerVar('MW::UniversalExport::MetadataOverrides', json_encode($aMetadataOverrides), BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_STRING | BsConfig::USE_PLUGIN_FOR_PREFS, 'bs-universalexport-pref-metadataoverrides', 'textarea'); BsConfig::registerVar('MW::UniversalExport::ParamsDefaults', $this->aParamsDefaults, BsConfig::LEVEL_PRIVATE | BsConfig::TYPE_ARRAY_MIXED); BsConfig::registerVar('MW::UniversalExport::ParamsOverrides', $this->aParamsOverrides, BsConfig::LEVEL_PRIVATE | BsConfig::TYPE_ARRAY_MIXED); //Permissions $this->mCore->registerPermission('universalexport-export', array(), array('type' => 'namespace')); wfProfileOut('BS::' . __METHOD__); }
/** * Constructor of BsFilterCategory class * @param BsDiagram $oDiagram Instance of diagram the filter is used with. * @param array $aDefaultValues List of strings */ public function __construct($oDiagram, $aDefaultValues = null) { parent::__construct($oDiagram, $aDefaultValues); $this->sLabel = wfMsg('bs-statistics-filter-user'); $this->aAvailableValues = $this->loadAvailableValues(); $this->aDefaultValues = BsConfig::get('MW::Statistics::ExcludeUsers'); }
/** * Initialization of BoilerPlate extension */ protected function initExt() { // Bind on hook BeforePageDisplay with the method onBeforePageDisplay. $this->setHook('BeforePageDisplay'); // Register system and user preferences. BsConfig::registerVar('MW::BoilerPlate::Mode', 1, BsConfig::LEVEL_USER | BsConfig::TYPE_INT | BsConfig::USE_PLUGIN_FOR_PREFS | BsConfig::RENDER_AS_JAVASCRIPT, 'bs-boilerplate-pref-mode', 'radio'); }
public static function format_header($aConfig, $sNewId) { $aReturn = array(); BsConfig::set("MW::Flexiskin::Logo", $aConfig->logo); BsConfig::saveSettings(); wfRunHooks("BSFlexiskinFormatterHeader", array(&$aConfig, &$aReturn)); return implode(" \n", $aReturn); }
/** * This method actually generates the output * @param array $params List of parameters * @return string HTML output */ public function execute($params = false) { $sTargetId = $this->getTargetId() . '-target'; $sLink = Html::element('a', array('class' => 'bs-tooltip-link', 'id' => $this->getTargetId(), 'data-bs-tt-title' => wfMessage('bs-whoisonline-widget-title')->plain(), 'data-bs-tt-target' => $sTargetId, 'data-bs-tt-maxheight' => BsConfig::get('MW::WhoIsOnline::LimitCount') * 20), $this->getOption('title')); $sTarget = Html::rawElement('div', array('class' => 'bs-tooltip-body bs-whoisonline-portlet', 'id' => $sTargetId), $this->oPortlet ? $this->oPortlet->execute() : ''); $sOut = $sLink . '<div class="bs-tooltip">' . $sTarget . '</div>'; return $sOut; }
/** * The default contructor of the SpecialUniversalExport class */ function __construct() { parent::__construct('UniversalExport', 'universalexport-export', true); $this->oOutputPage = $this->getOutput(); //Set up default parameters and metadata $this->aParams = BsConfig::get('MW::UniversalExport::ParamsDefaults'); $this->aParams['webroot-filesystempath'] = BsCore::getMediaWikiWebrootPath(); $this->aMetadata = FormatJson::decode(BsConfig::get('MW::UniversalExport::MetadataDefaults'), true); //Set up Black- and Whitelists $this->aCategoryWhitelist = BsConfig::get('MW::UniversalExport::CategoryWhitelist'); $this->aCategoryBlacklist = BsConfig::get('MW::UniversalExport::CategoryBlacklist'); }
/** * Extracts the parameters from the querystring and merges it wir the * default and overrige settings of the UniversalExport Extension. * @param array $aParams */ public static function getParamsFromQueryString(&$aParams) { global $wgRequest; $aParamsOverrides = BsConfig::get('MW::UniversalExport::ParamsOverrides'); $aParams = array_merge($aParams, $wgRequest->getArray('ue', array())); $aParams = array_merge($aParams, $aParamsOverrides); $aParams['oldid'] = $wgRequest->getVal('oldid', 0); $sDirection = $wgRequest->getVal('direction', ''); if (!empty($sDirection)) { $aParams['direction'] = $sDirection; } }
/** * Initialization of Dashboards extension */ public function initExt() { wfProfileIn('BS::' . __METHOD__); BsConfig::registerVar('MW::Dashboards::UserDashboardOnLogo', false, BsConfig::LEVEL_USER | BsConfig::TYPE_BOOL, 'bs-dashboards-pref-userdashboardonlogo', 'toggle'); $this->setHook('BeforePageDisplay'); $this->setHook('ParserFirstCallInit'); $this->setHook('PersonalUrls'); $this->setHook('BSDashboardsUserDashboardPortalConfig'); $this->setHook('BSDashboardsUserDashboardPortalPortlets'); //$this->setHook( 'BSInsertMagicAjaxGetData' ); wfProfileOut('BS::' . __METHOD__); }
/** * Initialization of WidgetBar extension */ protected function initExt() { wfProfileIn('BS::' . __METHOD__); $this->setHook('BS:UserPageSettings', 'onUserPageSettings'); $this->setHook('SkinTemplateOutputPageBeforeExec'); $this->setHook('userCan', 'onUserCan'); $this->setHook('GetPreferences'); $this->setHook('BeforePageDisplay'); $this->setHook('EditFormPreloadText'); BsConfig::registerVar('MW::WidgetBar::LinkToEdit', array('href' => '', 'content' => ''), BsConfig::LEVEL_USER | BsConfig::NO_DEFAULT, 'bs-widgetbar-userpagesettings-link-title', 'link'); wfProfileOut('BS::' . __METHOD__); }
/** * Initialization of TopMenuBarCustomizer class */ public function initExt() { //TODO: Add some error massages on article save (more than 5 entrys etc.) $this->setHook('SkinTemplateOutputPageBeforeExec'); $this->setHook('BeforePageDisplay'); $this->setHook('EditFormPreloadText'); $this->setHook('PageContentSaveComplete', 'invalidateCacheOnArticleChange'); $this->setHook('ArticleDeleteComplete', 'invalidateCacheOnArticleChange'); $this->setHook('TitleMoveComplete', 'invalidateCacheOnTitleChange'); BsConfig::registerVar('MW::TopMenuBarCustomizer::NuberOfLevels', 2, BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_INT, 'bs-topmenubarcustomizer-pref-numberoflevels'); BsConfig::registerVar('MW::TopMenuBarCustomizer::NumberOfMainEntries', 10, BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_INT, 'bs-topmenubarcustomizer-pref-numberofmainentries', 'int'); BsConfig::registerVar('MW::TopMenuBarCustomizer::NumberOfSubEntries', 25, BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_INT, 'bs-topmenubarcustomizer-pref-numberofsubentries', 'int'); }
/** * Initiate URLs so they use the correct protocol. */ protected function _initUrls() { wfProfileIn('BS::' . __METHOD__); $this->_morelikethisUrl = $this->_constructUrl(BsConfig::get('MW::ExtendedSearch::SolrCore') . self::MORELIKETHIS_SERVLET); $this->_spellcheckUrl = $this->_constructUrl(BsConfig::get('MW::ExtendedSearch::SolrCore') . self::SPELLCHECK_SERVLET); parent::_initUrls(); if ($this->bUseDifferentProtocolThanHttp) { $this->_updateUrl = str_ireplace('http://', $this->sProtocol . '://', $this->_updateUrl); $this->_searchUrl = str_ireplace('http://', $this->sProtocol . '://', $this->_searchUrl); $this->_threadsUrl = str_ireplace('http://', $this->sProtocol . '://', $this->_threadsUrl); $this->_spellcheckUrl = str_ireplace('http://', $this->sProtocol . '://', $this->_spellcheckUrl); $this->_morelikethisUrl = str_ireplace('http://', $this->sProtocol . '://', $this->_morelikethisUrl); } wfProfileOut('BS::' . __METHOD__); }
/** * Renders the form that is used to enter new shouts * @return string HTML of the form */ protected function renderMessageForm() { global $wgScriptPath; $aOut = array(); $aOut[] = '<form id="bs-sb-form" class="clearfix">'; $aOut[] = '<textarea id="bs-sb-message" maxlength="' . BsConfig::get('MW::ShoutBox::MaxMessageLength') . '">' . wfMessage('bs-shoutbox-message')->plain() . '</textarea>'; $aOut[] = '<br />'; $aOut[] = '<img id="bs-sb-loading" src="' . $wgScriptPath . '/extensions/BlueSpiceFoundation/resources/bluespice/images/bs-ajax-loader-bar-blue.gif" alt="Loading..."/>'; $aOut[] = '<input id="bs-sb-send" type="submit" value="' . wfMessage('bs-shoutbox-shout')->plain() . '" />'; $aOut[] = '<p class="bs-sb-textarea-additionalinfo">'; $aOut[] = '<span id="bs-sb-charactercounter"></span>'; $aOut[] = '</p>'; $aOut[] = '</form>'; return implode("\n", $aOut); }
/** * Initialization of UserSidebar extension */ protected function initExt() { wfProfileIn('BS::' . __METHOD__); global $wgAPIModules; $this->setHook('BS:UserPageSettings', 'onUserPageSettings'); $this->setHook('SkinTemplateOutputPageBeforeExec'); $this->setHook('userCan', 'onUserCan'); $this->setHook('GetPreferences'); $this->setHook('EditFormPreloadText'); $this->setHook('BeforePageDisplay'); $this->setHook('PageContentSaveComplete'); $wgAPIModules['sidebar'] = 'ApiSidebar'; BsConfig::registerVar('MW::UserSidebar::LinkToEdit', array('href' => '', 'content' => ''), BsConfig::LEVEL_USER | BsConfig::NO_DEFAULT, 'bs-usersidebar-userpagesettings-link-title', 'link'); wfProfileOut('BS::' . __METHOD__); }
/** * Prepares array of files to be indexed * @return true. */ public function crawl() { $sDirectories = BsConfig::get('MW::ExtendedSearch::ExternalRepo'); if ($sDirectories === '') { return $sDirectories; } $aDirectories = explode(',', $sDirectories); foreach ($aDirectories as $sDirectory) { $sDir = trim($sDirectory); if (!is_dir($sDir)) { continue; } $this->readInFiles($sDir); } return $this->aFiles; }
/** * Getter for $aNavigationSites array * @param boolean $bForceReload * @return array */ public static function getNavigationSites($bForceReload = false) { if (!$bForceReload && !is_null(self::$aNavigationSites)) { return self::$aNavigationSites; } self::$aNavigationSites = array(); $oTopBarMenuTitle = Title::makeTitle(NS_MEDIAWIKI, 'TopBarMenu'); if (is_null($oTopBarMenuTitle) || !$oTopBarMenuTitle->exists()) { return self::$aNavigationSites; } $sContent = BsPageContentProvider::getInstance()->getContentFromTitle($oTopBarMenuTitle); $aLines = explode("\n", trim($sContent)); $iMaxMainEntries = BsConfig::get('MW::TopMenuBarCustomizer::NumberOfMainEntries'); $iMaxSubEntries = BsConfig::get('MW::TopMenuBarCustomizer::NumberOfSubEntries'); $iAllowedLevels = BsConfig::get('MW::TopMenuBarCustomizer::NuberOfLevels'); self::$aNavigationSites = self::parseArticleContentLines($aLines, $iAllowedLevels, $iMaxMainEntries, $iMaxSubEntries); return self::$aNavigationSites; }
/** * Constructor of BsDiagramNumberOfUsers class */ public function __construct() { parent::__construct(); BsConfig::get('MW::Statistics::ExcludeUsers'); $this->sTitle = wfMessage('bs-statistics-diag-number-of-users')->plain(); $this->sDescription = wfMessage('bs-statistics-diag-number-of-users-desc')->plain(); $this->sTitlex = wfMessage('bs-statistics-label-time')->plain(); $this->sTitley = wfMessage('bs-statistics-label-count')->plain(); $this->sActualGrain = "m"; $this->sModLabel = "M y"; $this->iDataSource = BsDiagram::DATASOURCE_DATABASE; $this->bListable = true; $this->sSqlWhatForDiagram = "count(user_id)"; $this->sSqlWhatForList = "user_name, user_registration"; $this->sSqlFromWhere = "FROM #__user\n\t\t\t\t\t\t\t\tWHERE user_registration @period\n\t\t\t\t\t\t\t\tAND user_id NOT IN (\n\t\t\t\t\t\t\t\t\tSELECT ug_user\n\t\t\t\t\t\t\t\t\tFROM #__user_groups\n\t\t\t\t\t\t\t\t\tWHERE ug_group = 'bot'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tAND NOT user_name IN (@BsFilterUsers)"; $this->sListLabel = array(wfMessage('bs-statistics-label-name')->plain(), wfMessage('bs-statistics-label-registration')->plain()); $this->sMode = BsDiagram::MODE_AGGREGATED; $this->addFilter(new BsFilterUsers($this)); }
/** * Gets a DOMDocument, searches it for files, uploads files and markus to webservice and generated PDF. * @param DOMDocument $oHtmlDOM The source markup * @return string The resulting PDF as bytes */ public function createPDF(&$oHtmlDOM) { $this->findFiles($oHtmlDOM); $this->uploadFiles(); //HINT: http://www.php.net/manual/en/class.domdocument.php#96055 //But: Formated Output is evil because is will destroy formatting in <pre> Tags! $sHtmlDOM = $oHtmlDOM->saveXML($oHtmlDOM->documentElement); //Save temporary $sTmpHtmlFile = BSDATADIR . DS . 'UEModulePDF' . DS . $this->aParams['document-token'] . '.html'; $sTmpPDFFile = BSDATADIR . DS . 'UEModulePDF' . DS . $this->aParams['document-token'] . '.pdf'; file_put_contents($sTmpHtmlFile, $sHtmlDOM); $aOptions = array('timeout' => 120, 'postData' => array('fileType' => '', 'documentToken' => $this->aParams['document-token'], 'sourceHtmlFile_name' => basename($sTmpHtmlFile), 'sourceHtmlFile' => '@' . $sTmpHtmlFile, 'wikiId' => wfWikiID())); if (BsConfig::get('MW::TestMode')) { $aOptions['postData']['debug'] = "true"; } global $bsgUEModulePDFCURLOptions; $aOptions = array_merge_recursive($aOptions, $bsgUEModulePDFCURLOptions); wfRunHooks('BSUEModulePDFCreatePDFBeforeSend', array($this, &$aOptions, $oHtmlDOM)); $vHttpEngine = Http::$httpEngine; Http::$httpEngine = 'curl'; //HINT: http://www.php.net/manual/en/function.curl-setopt.php#refsect1-function.curl-setopt-notes //Upload HTML source //TODO: Handle $sResponse $sResponse = Http::post($this->aParams['soap-service-url'] . '/UploadAsset', $aOptions); //Now do the rendering //We re-send the paramters but this time without the file. unset($aOptions['postData']['sourceHtmlFile']); unset($aOptions['postData']['fileType']); //We do not want the request to be multipart/formdata because that's more difficult to handle on Servlet-side $aOptions['postData'] = wfArrayToCgi($aOptions['postData']); $vPdfByteArray = Http::post($this->aParams['soap-service-url'] . '/RenderPDF', $aOptions); Http::$httpEngine = $vHttpEngine; if ($vPdfByteArray == false) { wfDebugLog('BS::UEModulePDF', 'BsPDFServlet::createPDF: Failed creating "' . $this->aParams['document-token'] . '"'); } file_put_contents($sTmpPDFFile, $vPdfByteArray); //Remove temporary file if (!BsConfig::get('MW::TestMode')) { unlink($sTmpHtmlFile); unlink($sTmpPDFFile); } return $vPdfByteArray; }
public function __construct($oMainControl) { parent::__construct($oMainControl); // Set file types to be indexed $vTempFileTypes = BsConfig::get('MW::ExtendedSearch::IndexFileTypes'); $vTempFileTypes = str_replace(array(' ', ';'), array('', ','), $vTempFileTypes); $vTempFileTypes = explode(',', $vTempFileTypes); foreach ($vTempFileTypes as $value) { $this->aFileTypes[$value] = true; } unset($vTempFileTypes); // Maximum file size in MB $iMaxFileSize = (int) ini_get('post_max_size'); if (empty($iMaxFileSize) || $iMaxFileSize <= 0) { $iMaxFileSize = 32; } $this->iMaxDocSize = $iMaxFileSize * 1024 * 1024; // Make bytes out of it }
/** * This method actually generates the output * @return string HTML output */ public function execute($params = false) { $aSearchBoxKeyValues = array(); $sInputFields[] = Xml::input('title', false, SpecialPage::getTitleFor('SpecialExtendedSearch')->getFullText(), array('type' => 'hidden')); if (BsConfig::get('MW::ExtendedSearch::SearchFiles')) { $sInputFields[] = Xml::input('search_files', false, 1, array('type' => 'hidden')); } $sValue = isset($this->oSearchRequest->sInput) ? $this->oSearchRequest->sInput : wfMessage('searchsuggest-search')->plain(); $sInputFields[] = Xml::input('q', false, $sValue, array('id' => 'bs-extendedsearch-inputfieldtext-specialpage', 'defaultvalue' => wfMessage('searchsuggest-search')->text())); $sScope = BsConfig::get('MW::ExtendedSearch::DefScopeUser'); $sInputFields[] = Xml::input('search_scope', false, $sScope, array('type' => 'hidden', 'id' => 'bs-search-button-hidden-specialpage')); $sImageTitleButton = Xml::element('div', array('id' => 'bs-extendedsearch-titlebuttonimage-specialpage', 'class' => 'bs-extendedsearch-buttonimage-specialpage'), '', false); $sInputFields[] = Xml::openElement('button', array('type' => 'button', 'title' => wfMessage('bs-extendedsearch-pref-scope-title')->plain(), 'id' => 'bs-search-button-specialpage', 'class' => 'bs-search-button-specialpage')); $sInputFields[] = $sImageTitleButton; $sInputFields[] = Xml::closeElement('button'); $sImageFulltextButton = Xml::element('div', array('id' => 'bs-extendedsearch-fulltextbuttonimage-specialpage', 'class' => 'bs-extendedsearch-buttonimage-specialpage'), '', false); $sInputFields[] = Xml::openElement('button', array('type' => 'button', 'title' => wfMessage('bs-extendedsearch-pref-scope-text')->plain(), 'id' => 'bs-search-fulltext-specialpage', 'class' => 'bs-search-button-specialpage')); $sInputFields[] = $sImageFulltextButton; $sInputFields[] = Xml::closeElement('button'); $sLinkToExtendedPage = Xml::element('a', array('href' => $this->getOption('linkToExtendedPageUri'), 'id' => 'bs-extendedsearch-linktoextendedpage'), wfMessage($this->getOption('linkToExtendedPageMessageKey'))->plain(), false); if ($this->hasItems() === 0) { $sDivSearchDomains = ''; } else { $itemsOut = ''; foreach ($this->_mItems as $item) { $itemsOut .= $item->execute(); } $sDivSearchDomains = Xml::openElement('div', array('class' => 'bs-extendedsearch-domaindiv')) . $itemsOut . Xml::closeElement('div'); } global $wgScript; $aFormAttributes = array('class' => 'bs-search-form', 'id' => 'bs-extendedsearch-form-specialpage', 'action' => $wgScript, 'method' => 'get'); $aForm = array(); $aForm[] = $sLinkToExtendedPage; $aForm[] = Html::openElement('form', $aFormAttributes); $aForm[] = implode("\n", $sInputFields) . $sDivSearchDomains; $aForm[] = Xml::closeElement('form'); return implode("\n", $aForm); }
/** * This method actually generates the output * @param array $aParams not used here * @return string HTML output */ public function execute($aParams = false) { global $wgUser; $sUserName = $this->oUser->getName(); $sUserRealName = $this->oUser->getRealName(); //Fallback for old entries without user_id if ($this->oUser->isAnon()) { $sUserName = $this->sUsername; } $aOut = array(); $aOut[] = '<li class="bs-sb-listitem clearfix" id="bs-sb-' . $this->iShoutID . '">'; $aOut[] = ' <div class="bs-user-image">'; if ($this->oMiniProfile instanceof ViewUserMiniProfile) { $aOut[] = $this->oMiniProfile->execute(); } $aOut[] = ' </div>'; $aOut[] = ' <div class="bs-sb-message">'; $aOut[] = ' <div class="bs-sb-message-head">'; $aOut[] = ' <strong>' . $sUserName . '</strong>'; if (!empty($sUserRealName)) { $aOut[] = ' <span class="bs-sb-meassage-head-small">' . $sUserRealName . '</span>'; } $aOut[] = ' </div>'; if (isset($this->sDate)) { $aOut[] = '<div class="bs-sb-message-time">' . $this->sDate; $aOut[] = '</div> '; } $aOut[] = ' <div class="bs-sb-message-text">' . nl2br($this->sMessage); $aOut[] = ' </div> '; $aOut[] = ' </div>'; $sArchiveButton = ''; $sArchiveButtonEnabled = ' <div class="bs-sb-archive"></div>'; //set button if user has the right to archive if (BsCore::checkAccessAdmission('archiveshoutbox')) { $sArchiveButton = $sArchiveButtonEnabled; } //if setting for "allow own entries to be archived" is set + username == shoutbox-entry-username => set button if (BsConfig::get('MW::ShoutBox::AllowArchive') && $wgUser->getName() == $sUserName) { $sArchiveButton = $sArchiveButtonEnabled; } $aOut[] = $sArchiveButton; $aOut[] = '</li>'; return implode("\n", $aOut); }
/** * Get subscribers for the echo notifications * @param EchoEvent $event * @param type $users * @return boolean */ public function onEchoGetDefaultNotifiedUsers($event, &$users) { $aTmpUsers = array_unique(array_merge(BsConfig::getUsersForVar($this->aEchoPrefix['web'] . $event->getType() . '-cat', '1', false, false), BsConfig::getUsersForVar($this->aEchoPrefix['email'] . $event->getType() . '-cat', '1', false, false))); foreach ($aTmpUsers as $index => $user) { if (!$user->getOption('MW::Notifications::Active', false)) { continue; } if ($event->getTitle() instanceof Title) { if (!$event->getTitle()->userCan('read', $user)) { continue; } if (is_array($user->getOption('MW::Notifications::NotifyNS', array()))) { if (!in_array($event->getTitle()->getNamespace(), $user->getOption('MW::Notifications::NotifyNS', array()))) { continue; } } } if ($event->getAgent() instanceof User) { if ($event->getAgent()->getRequest()->getVal('wpMinoredit', false) && $user->getOption('MW::Notifications::NotifyNoMinor', false)) { continue; } } $users[] = $user; } return true; }
/** * * @param Title $oTitle * @return false|\ViewStateBarTopElement */ private function makeStateBarTopSubPages($oTitle) { if ($oTitle->hasSubpages() == false) { return false; } wfProfileIn('BS::' . __METHOD__); $oSubpageIcons = new ViewStateBarTopElement(); $oSubpageIcons->setKey('Subpages'); $oSubpageIcons->setIconSrc($this->getImagePath(true) . BsConfig::get('MW::ArticleInfo::ImageSubpages')); $oSubpageIcons->setIconAlt(wfMessage('bs-articleinfo-subpages-available')->plain()); $oSubpageIcons->setIconTogglesBody(true); $oSubpageIcons->setText(wfMessage('bs-articleinfo-subpages')->plain()); $oSubpageIcons->setTextLinkTitle(wfMessage('bs-articleinfo-subpages')->plain()); $oSubpageIcons->setTextLink('#'); wfRunHooks('BSArticleInfoBeforeSubpagesTopView', array($this, &$oSubpageIcons)); return $oSubpageIcons; }
/** * Processes incoming search request */ public function readInSearchRequest() { global $wgCanonicalNamespaceNames, $wgExtraNamespaces, $wgContentNamespaces; $this->aOptions['searchStringRaw'] = $this->oSearchRequest->sInput; $this->aOptions['searchStringOrig'] = ExtendedSearchBase::preprocessSearchInput($this->oSearchRequest->sInput); self::$searchStringRaw = $this->aOptions['searchStringRaw']; $sCustomerId = $this->getCustomerId(); $sLogOp = ' OR '; $aFq = array(); $aBq = array(); $oRequest = RequestContext::getMain()->getRequest(); $scope = $oRequest->getVal('search_scope', BsConfig::get('MW::ExtendedSearch::DefScopeUser')) == 'title' ? 'title' : 'text'; $this->aOptions['scope'] = $scope; $vNamespace = $this->checkSearchstringForNamespace($this->aOptions['searchStringRaw'], $this->aOptions['searchStringOrig'], $aFq, BsConfig::get('MW::ExtendedSearch::ShowFacets')); $this->aOptions['searchStringWildcarded'] = SearchService::wildcardSearchstring($this->aOptions['searchStringOrig']); $this->aOptions['searchStringForStatistics'] = $this->aOptions['searchStringWildcarded']; $aSearchTitle = array('title:(' . $this->aOptions['searchStringOrig'] . ')^5', 'titleWord:(' . $this->aOptions['searchStringOrig'] . ')^2', 'titleReverse:(' . $this->aOptions['searchStringWildcarded'] . ')', 'redirects:(' . $this->aOptions['searchStringOrig'] . ')'); $aSearchText = array('textWord:(' . $this->aOptions['searchStringOrig'] . ')^2', 'textReverse:(' . $this->aOptions['searchStringWildcarded'] . ')', 'sections:(' . $this->aOptions['searchStringOrig'] . ')'); $sSearchStringTitle = implode($sLogOp, $aSearchTitle); $sSearchStringText = implode($sLogOp, $aSearchText); $this->aOptions['searchStringFinal'] = $this->aOptions['scope'] === 'title' ? $sSearchStringTitle : $sSearchStringTitle . $sLogOp . $sSearchStringText; // filter query $aFq[] = 'redirect:0'; $aFq[] = 'special:0'; $aFq[] = 'wiki:(' . $sCustomerId . ')'; // $this->aOptions['namespaces'] HAS TO BE an array with numeric indices of type string! $this->aOptions['namespaces'] = $this->oSearchRequest->aNamespaces; $aNamespaces = array_slice($wgCanonicalNamespaceNames, 2); $aNamespaces = $aNamespaces + $wgExtraNamespaces; $bTagNamespace = false; if ($vNamespace === false) { $this->aOptions['files'] = $this->oSearchRequest->bSearchFiles === true ? true : false; $oUser = RequestContext::getMain()->getUser(); if (!$oUser->getOption('searcheverything')) { if (empty($this->aOptions['namespaces']) && $this->oSearchRequest->bNoSelect === false) { $this->aOptions['namespaces'] = array(); $aOptions = $oUser->getOptions(); foreach ($aOptions as $sOpt => $sValue) { if (strpos($sOpt, 'searchNs') !== false && $sValue == true) { $this->aOptions['namespaces'][] = '' . str_replace('searchNs', '', $sOpt); } } $aAllowedTypes = explode(',', BsConfig::get('MW::ExtendedSearch::IndexFileTypes')); $aAllowedTypes = array_map('trim', $aAllowedTypes); $aSearchFilesFacet = array_intersect($this->oSearchRequest->aType, $aAllowedTypes); if (($this->aOptions['files'] === true || !empty($aSearchFilesFacet)) && $oUser->isAllowed('searchfiles')) { $this->aOptions['namespaces'][] = '999'; $this->aOptions['namespaces'][] = '998'; } } else { $bTagNamespace = true; $aTmp = array(); foreach ($this->aOptions['namespaces'] as $iNs) { if (BsNamespaceHelper::checkNamespacePermission($iNs, 'read') === true) { $aTmp[] = $iNs; } } $this->aOptions['namespaces'] = $aTmp; } } else { if (empty($this->aOptions['namespaces'])) { $aTmp = array(); foreach ($aNamespaces as $iNs) { if (BsNamespaceHelper::checkNamespacePermission($iNs, 'read') === true) { $this->aOptions['namespaces'][] = $iNs; } } } else { $bTagNamespace = true; $aTmp = array(); foreach ($this->aOptions['namespaces'] as $iNs) { if (!BsNamespaceHelper::checkNamespacePermission($iNs, 'read')) { $aTmp[] = $iNs; } } if (!empty($aTmp)) { $this->aOptions['namespaces'] = array_diff($this->aOptions['namespaces'], $aTmp); } } } } else { $bTagNamespace = true; $this->aOptions['namespaces'][] = '' . $vNamespace; } $this->aOptions['namespaces'] = array_unique($this->aOptions['namespaces']); if (!empty($this->aOptions['namespaces'])) { $aFqNamespaces = array(); foreach ($this->aOptions['namespaces'] as $sNamespace) { $aFqNamespaces[] = $sNamespace; if ($sNamespace == '999') { $filesAlreadyAddedInLoopBefore = true; } } if (!isset($filesAlreadyAddedInLoopBefore) && $this->aOptions['files'] === true && $oUser->isAllowed('searchfiles')) { $aFqNamespaces[] = '999'; } $bTagNamespace = true; $aFq[] = BsConfig::get('MW::ExtendedSearch::ShowFacets') ? '{!tag=na}namespace:("' . implode('" "', $aFqNamespaces) . '")' : 'namespace:("' . implode('" "', $aFqNamespaces) . '")'; } // $this->aOptions['cats'] = $this->oSearchRequest->sCat; // string, defaults to '' if 'search_cat' not set in REQUEST $this->aOptions['cats'] = $this->oSearchRequest->sCategories; // array of strings or empty array if (!empty($this->aOptions['cats'])) { if (isset($this->oSearchRequest->sOperator)) { switch ($this->oSearchRequest->sOperator) { case 'AND': $sLogOp = ' AND '; break; default: } } $sFqCategories = BsConfig::get('MW::ExtendedSearch::ShowFacets') ? '{!tag=ca}' : ''; $sFqCategories .= 'cat:("' . implode('"' . $sLogOp . '"', $this->aOptions['cats']) . '")'; $aFq[] = $sFqCategories; } $this->aOptions['type'] = $this->oSearchRequest->aType; if (!empty($this->aOptions['type'])) { $sFqType = BsConfig::get('MW::ExtendedSearch::ShowFacets') ? '{!tag=ty}' : ''; $sFqType .= 'type:("' . implode('"' . $sLogOp . '"', $this->aOptions['type']) . '")'; $aFq[] = $sFqType; } $this->aOptions['editor'] = $this->oSearchRequest->sEditor; if (!empty($this->aOptions['editor'])) { // there may be spaces in name of editor. solr analyses those to two // terms (editor's names) thus we wrap the name into quotation marks // todo: better: in schema.xml define field editor not to be tokenized // at whitespace // but: +editor:("Robert V" "Mathias S") is already split correctly! $sFqEditor = BsConfig::get('MW::ExtendedSearch::ShowFacets') ? '{!tag=ed}' : ''; $sFqEditor .= 'editor:("' . implode('"' . $sLogOp . '"', $this->aOptions['editor']) . '")'; $aFq[] = $sFqEditor; } // Boost query foreach ($wgContentNamespaces as $iNs) { $aBq[] = "namespace:{$iNs}^2"; } // We want that files are also seen as a content namespace $aBq[] = "namespace:999^2"; $searchLimit = BsConfig::get('MW::ExtendedSearch::LimitResults'); $this->aOptions['offset'] = $this->oSearchRequest->iOffset; $this->aOptions['order'] = $this->oSearchRequest->sOrder; $this->aOptions['asc'] = $this->oSearchRequest->sAsc; $this->aOptions['searchLimit'] = $searchLimit == 0 ? 15 : $searchLimit; $this->aOptions['titleExists'] = ExtendedSearchBase::titleExists($this->oSearchRequest->sInput, $this->aOptions); $this->aOptions['bExtendedForm'] = $this->oSearchRequest->bExtendedForm; $this->aSearchOptions['defType'] = 'edismax'; $this->aSearchOptions['fl'] = 'uid,type,title,path,namespace,cat,ts,redirects,overall_type'; $this->aSearchOptions['fq'] = $aFq; $this->aSearchOptions['sort'] = $this->aOptions['order'] . ' ' . $this->aOptions['asc']; $this->aSearchOptions['hl'] = 'on'; $this->aSearchOptions['hl.fl'] = 'titleWord, titleReverse, sections, textWord, textReverse'; $this->aSearchOptions['hl.snippets'] = BsConfig::get('MW::ExtendedSearch::HighlightSnippets'); $this->aSearchOptions['bq'] = implode(' ', $aBq); if (BsConfig::get('MW::ExtendedSearch::ShowFacets')) { $this->aSearchOptions['facet'] = 'on'; $this->aSearchOptions['facet.sort'] = 'false'; $this->aSearchOptions['facet.mincount'] = '1'; $this->aSearchOptions['facet.missing'] = 'true'; $this->aSearchOptions['facet.field'] = array(); $this->aSearchOptions['facet.field'][] = $bTagNamespace === true ? '{!ex=na}namespace' : 'namespace'; $this->aSearchOptions['facet.field'][] = isset($sFqCategories) ? '{!ex=ca}cat' : 'cat'; $this->aSearchOptions['facet.field'][] = isset($sFqType) ? '{!ex=ty}type' : 'type'; $this->aSearchOptions['facet.field'][] = isset($sFqEditor) ? '{!ex=ed}editor' : 'editor'; } }
/** * Checks wether to set Context or not. * @return bool */ private function checkContext() { if (BsConfig::get('MW::Authors::Show') === false) { return false; } $oTitle = $this->getTitle(); if (!is_object($oTitle)) { return false; } if (!$oTitle->exists()) { return false; } // Do only display when user is allowed to read if (!$oTitle->userCan('read')) { return false; } // Do only display in view mode if ($this->getRequest()->getVal('action', 'view') != 'view') { return false; } // Do not display on SpecialPages, CategoryPages or ImagePages if (in_array($oTitle->getNamespace(), array(NS_SPECIAL, NS_CATEGORY, NS_FILE))) { return false; } // Do not display if __NOAUTHORS__ keyword is found $vNoAuthors = BsArticleHelper::getInstance($oTitle)->getPageProp('bs_noauthors'); if ($vNoAuthors === '') { return false; } return true; }
/** * Collects metadata and additional resources for this page * @param Title $oTitle * @param DOMDocument $oPageDOM * @param array $aParams * @return array array( 'meta' => ..., 'resources' => ...); */ private static function collectData($oTitle, $oPageDOM, $aParams) { $aMeta = array(); $aResources = array('ATTACHMENT' => array(), 'STYLESHEET' => array(), 'IMAGE' => array()); // TODO RBV (01.02.12 13:51): Handle oldid $aCategories = array(); if ($oTitle->exists()) { // TODO RBV (27.06.12 11:47): Throws an exception. Maybe better use try ... catch instead of $oTitle->exists() $aAPIParams = new FauxRequest(array('action' => 'parse', 'page' => $oTitle->getPrefixedText(), 'prop' => 'images|categories|links')); $oAPI = new ApiMain($aAPIParams); $oAPI->execute(); if (defined('ApiResult::META_CONTENT')) { $aResult = $oAPI->getResult()->getResultData(null, array('BC' => array(), 'Types' => array(), 'Strip' => 'all')); } else { $aResult = $oAPI->getResultData(); } foreach ($aResult['parse']['categories'] as $aCat) { $aCategories[] = $aCat['*']; } } /* //For future use... foreach($aResult['parse']['images'] as $sFileName ) { $oImage = RepoGroup::singleton()->getLocalRepo()->newFile( Title::newFromText( $sFileName, NS_FILE ) ); if( $oImage->exists() ) { $sAbsoluteFileSystemPath = $oImage->getFullPath(); } } */ //Dublin Core: $aMeta['DC.title'] = $oTitle->getPrefixedText(); $aMeta['DC.date'] = wfTimestamp(TS_ISO_8601); // TODO RBV (14.12.10 14:01): Check for conformity. Maybe there is a better way to acquire than wfTimestamp()? //Custom global $wgLang; $sCurrentTS = $wgLang->userAdjust(wfTimestampNow()); $aMeta['title'] = $oTitle->getPrefixedText(); $aMeta['exportdate'] = $wgLang->sprintfDate('d.m.Y', $sCurrentTS); $aMeta['exporttime'] = $wgLang->sprintfDate('H:i', $sCurrentTS); $aMeta['exporttimeexact'] = $wgLang->sprintfDate('H:i:s', $sCurrentTS); //Custom - Categories->Keywords $aMeta['keywords'] = implode(', ', $aCategories); $oDOMXPath = new DOMXPath($oPageDOM); $oMetadataElements = $oDOMXPath->query("//div[@class='bs-universalexport-meta']"); foreach ($oMetadataElements as $oMetadataElement) { if ($oMetadataElement->hasAttributes()) { foreach ($oMetadataElement->attributes as $oAttribute) { if ($oAttribute->name !== 'class') { $aMeta[$oAttribute->name] = $oAttribute->value; } } } $oMetadataElement->parentNode->removeChild($oMetadataElement); } //If it's a normal article if (!in_array($oTitle->getNamespace(), array(NS_SPECIAL, NS_IMAGE, NS_CATEGORY))) { $oArticle = new Article($oTitle); $aMeta['author'] = $oArticle->getUserText(); // TODO RBV (14.12.10 12:19): Realname/Username -> DisplayName $aMeta['date'] = $wgLang->sprintfDate('d.m.Y', $oArticle->getTouched()); } wfRunHooks('BSUEModulePDFcollectMetaData', array($oTitle, $oPageDOM, &$aParams, $oDOMXPath, &$aMeta)); $aMetaDataOverrides = json_decode(BsConfig::get('MW::UniversalExport::MetadataOverrides'), true); $aMeta = array_merge($aMeta, $aMetaDataOverrides); return array('meta' => $aMeta, 'resources' => $aResources); }
/** * Creates the facets */ private function createFacets() { $sSiteUri = $this->oSearchUriBuilder->buildUri(SearchUriBuilder::ALL, SearchUriBuilder::MLT); // possible orders: count, name, checked // possible directions: 1 = desc, -1 = asc $aOrder = BsConfig::get('MW::SortAlph') ? array('name' => -1) : array('count' => 1); $this->setData('sortorder', $aOrder); $aBaseFacets = array('namespace' => array('param' => 'na', 'option' => 'namespaces', 'i18n' => 'bs-extendedsearch-facet-namespace', 'url' => $this->oSearchUriBuilder->buildUri(SearchUriBuilder::ALL, SearchUriBuilder::NAMESPACES | SearchUriBuilder::FILES)), 'cat' => array('param' => 'ca', 'option' => 'cats', 'i18n' => 'bs-extendedsearch-facet-category', 'url' => $this->oSearchUriBuilder->buildUri(SearchUriBuilder::ALL, SearchUriBuilder::CATS)), 'editor' => array('param' => 'ed', 'option' => 'editor', 'i18n' => 'bs-extendedsearch-facet-editors', 'url' => $this->oSearchUriBuilder->buildUri(SearchUriBuilder::ALL, SearchUriBuilder::NAMESPACES | SearchUriBuilder::EDITOR)), 'type' => array('param' => 'ty', 'option' => 'type', 'i18n' => 'bs-extendedsearch-facet-type', 'url' => $this->oSearchUriBuilder->buildUri(SearchUriBuilder::ALL, SearchUriBuilder::NAMESPACES | SearchUriBuilder::TYPE))); wfRunHooks('BSExtendedSearchBeforeCreateFacets', array(&$aBaseFacets)); foreach ($aBaseFacets as $sFacet => $aConfig) { $oFacet = new ViewSearchFacet(); if (!is_null($this->oResponse->facet_counts->facet_fields->{$sFacet})) { $oFacet->setOption('title', $aConfig['i18n']); /* alters to: * array( * 0 => array( 'checked' => true ), * 1 => array( 'count' => 15 ), * 999 => array( 'checked' => true, 'count' => 2 ) * )*/ $aFacets = array(); $aData = $this->oSearchOptions->getOption($aConfig['option']); if (!empty($aData)) { foreach ($aData as $key => $value) { $aFacets[$value]['checked'] = true; } unset($aData); } // Get all available facets $aFacetsInRespsonse = $this->oResponse->facet_counts->facet_fields->{$sFacet}; foreach ($aFacetsInRespsonse as $key => $count) { if ($key == '_empty_') { continue; } if ($sFacet === 'namespace') { if (BsNamespaceHelper::checkNamespacePermission($key, 'read') === false || $count == '0') { unset($aFacets[$key]); continue; } } elseif ($sFacet === 'type') { if ($key != 'wiki' && !$this->oContext->getUser()->isAllowed('searchfiles')) { continue; } } $aFacets[$key]['count'] = $count; } // Prepare available facets. Add some information for each facet foreach ($aFacets as $key => $attributes) { if (!isset($aFacets[$key]['count'])) { unset($aFacets[$key]); continue; } if ($sFacet === 'namespace') { if ($key == '999') { $sTitle = wfMessage('bs-extendedsearch-facet-namespace-files')->plain(); } elseif ($key == '998') { $sTitle = wfMessage('bs-extendedsearch-facet-namespace-extfiles')->plain(); } elseif ($key == '0') { $sTitle = wfMessage('bs-ns_main')->plain(); } else { $sTitle = BsNamespaceHelper::getNamespaceName($key, false); if (empty($sTitle)) { unset($aFacets[$key]); continue; } } } elseif ($sFacet === 'cat') { $sTitle = $key == 'notcategorized' ? wfMessage('bs-extendedsearch-facet-uncategorized')->plain() : $key; } elseif ($sFacet === 'editor') { $sTitle = $key === 'unknown' ? wfMessage('bs-extendedsearch-unknown')->plain() : $key; } elseif ($sFacet === 'type') { $sTitle = $key; } $aFacets[$key]['title'] = $this->getFacetTitle($sTitle); $aFacets[$key]['name'] = $this->reduceMaxFacetLength($sTitle); } uasort($aFacets, array($this, 'compareEntries')); $aFacetAll = array(); foreach ($aFacets as $key => $attributes) { $aDataSet = array(); if (isset($attributes['checked'])) { $aDataSet['checked'] = true; } if ($sFacet === 'namespace') { if ($key == '999') { $uri = $this->oSearchUriBuilder->buildUri(SearchUriBuilder::ALL, SearchUriBuilder::NAMESPACES | SearchUriBuilder::FILES); $uri .= '&search_files=' . isset($attributes['checked']) ? '0' : '1'; } else { $uri = $this->oSearchUriBuilder->buildUri(SearchUriBuilder::ALL, SearchUriBuilder::NAMESPACES); } } elseif ($sFacet === 'cat') { $uri = $this->oSearchUriBuilder->buildUri(SearchUriBuilder::ALL, SearchUriBuilder::CATS); } elseif ($sFacet === 'editor') { $uri = $this->oSearchUriBuilder->buildUri(SearchUriBuilder::ALL, SearchUriBuilder::EDITOR); } elseif ($sFacet === 'type') { $uri = $this->oSearchUriBuilder->buildUri(SearchUriBuilder::ALL, SearchUriBuilder::TYPE); } foreach ($aFacets as $namespaceUrl => $attributesUrl) { $bOwnUrlAndNotAlreadyChecked = $key == $namespaceUrl && !isset($attributesUrl['checked']); $bOtherUrlAndAlreadyChecked = $key != $namespaceUrl && isset($attributesUrl['checked']); if ($bOwnUrlAndNotAlreadyChecked || $bOtherUrlAndAlreadyChecked) { $uri .= "&{$aConfig['param']}[]=" . $namespaceUrl; } } $aDataSet['uri'] = $uri; $aDataSet['diff'] = "{$aConfig['param']}[]=" . $key; $aDataSet['name'] = $attributes['name']; $aDataSet['title'] = $attributes['title']; $aDataSet['count'] = (int) $attributes['count']; $oFacet->setData($aDataSet); $aFacetAll[] = "{$aConfig['param']}[]=" . $key; } if ($sFacet === 'namespace') { $aReqNs = $this->oSearchOptions->getOption('namespaces'); foreach ($aReqNs as $ikey => $value) { if (!array_key_exists($value, $aFacets)) { $aFacetAll[] = "{$aConfig['param']}[]=" . $value; $sSiteUri = str_replace("&{$aConfig['param']}[]={$value}", '', $sSiteUri); } } } $sFacetAll = implode('&', $aFacetAll); $oFacet->setOption('uri-facet-all-diff', $sFacetAll); } $this->vSearchResult->setFacet($oFacet); } $this->vSearchResult->setOption('siteUri', $sSiteUri); }
/** * Hook handler for LinkBegin * @param Linker $oLinker * @param Title $oTarget * @param string $sHtml * @param array $aCustomAttribs * @param array $aQuery * @param array $aOptions * @param string $sRet * @return boolean Always true to keep hook running */ public function onLinkBegin($oLinker, $oTarget, &$sHtml, &$aCustomAttribs, &$aQuery, &$aOptions, &$sRet) { if (in_array('known', $aOptions)) { return true; } if (!in_array('broken', $aOptions)) { //It's not marked as "known" and not as "broken" so we have to check if ($oTarget->isKnown()) { return true; } } $aExNs = BsConfig::get('MW::PageTemplates::ExcludeNs'); if (in_array($oTarget->getNamespace(), $aExNs)) { return true; } if (!isset($aQuery['preload'])) { $aQuery['action'] = 'view'; } return true; }