Example #1
0
 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     global $wgSitename;
     $result = '';
     if ($outputmode == SMW_OUTPUT_FILE) {
         // make file
         if ($this->m_title == '') {
             $this->m_title = $wgSitename;
         }
         $items = array();
         while ($row = $res->getNext()) {
             $items[] = $this->getItemForResultRow($row)->text();
         }
         $result = implode('', $items);
     } else {
         // just make link to export
         if ($this->getSearchLabel($outputmode)) {
             $label = $this->getSearchLabel($outputmode);
         } else {
             $label = wfMsgForContent('srf_bibtex_link');
         }
         $link = $res->getQueryLink($label);
         $link->setParameter('bibtex', 'format');
         if ($this->getSearchLabel(SMW_OUTPUT_WIKI) != '') {
             $link->setParameter($this->getSearchLabel(SMW_OUTPUT_WIKI), 'searchlabel');
         }
         $result .= $link->getText($outputmode, $this->mLinker);
         $this->isHTML = $outputmode == SMW_OUTPUT_HTML;
         // yes, our code can be viewed as HTML if requested, no more parsing needed
     }
     return $result;
 }
Example #2
0
function efFastCatSelector(&$categories)
{
    global $wgTitle, $wgArticle;
    // BugId:26491
    if (empty($wgTitle) || empty($wgArticle)) {
        return true;
    }
    $artname = $wgTitle->getText();
    $artid = $wgArticle->getID();
    $spice = sha1("Kroko-katMeNot-" . $artid . "-" . $artname . "-NotMekat-Schnapp");
    $catUrl = Title::newFromText('FastCat', NS_SPECIAL)->getFullURL();
    $ret = "<form action=\"{$catUrl}\" method='post'>\n<p><b>" . wfMsg('fastcat-box-title') . "</b><br>\n<small>" . wfMsg('fastcat-box-intro') . "</small>\n</p>\n<input type='hidden' name='id' value='{$artid}'>\n<input type='hidden' name='spice' value='{$spice}'>\n<input type='hidden' name='artname' value='{$artname}'>\n<p style=\"text-indent:-1em;margin-left:1em\">";
    $kat = explode("\n", wfMsgForContent('fastcat-categories-list'));
    foreach ($kat as $k) {
        if (strpos($k, '* ') === 0) {
            $k = trim($k, '* ');
            $ret .= "</p><p style=\"text-indent:-1em;margin-left:1em\">\n";
            $ret .= "<button style=\"font-size:smaller;\" name=\"cat\" value=\"{$k}\"><b>{$k}</b></button>\n";
        } else {
            $k = trim($k, '* ');
            $ret .= "<button style=\"font-size:smaller;\" name=\"cat\" value=\"{$k}\">{$k}</button>\n";
        }
    }
    $ret .= <<<EORET
\t\t</p>
\t\t</form>
EORET;
    $categories = $ret;
    return true;
}
Example #3
0
 /**
  * Constructor
  *
  * @param $params array
  */
 public function __construct($params)
 {
     parent::__construct($params);
     $this->msg = empty($params['licenses']) ? wfMsgForContent('licenses') : $params['licenses'];
     $this->selected = null;
     $this->makeLicenses();
 }
	/**
	 * Return a clause with the list of disambiguation templates.
	 * This function was copied verbatim from specials/SpecialDisambiguations.php
	 */
	function disambiguation_templates( $dbr ) {
		$dMsgText = wfMsgForContent('disambiguationspage');

		$linkBatch = new LinkBatch;

		# If the text can be treated as a title, use it verbatim.
		# Otherwise, pull the titles from the links table
		$dp = Title::newFromText($dMsgText);
		if( $dp ) {
			if($dp->getNamespace() != NS_TEMPLATE) {
				# FIXME we assume the disambiguation message is a template but
				# the page can potentially be from another namespace :/
				wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
			}
			$linkBatch->addObj( $dp );
		} else {
			# Get all the templates linked from the Mediawiki:Disambiguationspage
			$disPageObj = Title::makeTitleSafe( NS_MEDIAWIKI, 'disambiguationspage' );
			$res = $dbr->select(
				array('pagelinks', 'page'),
				'pl_title',
				array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE,
					'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()),
				__METHOD__ );

			foreach ( $res as $row ) {
				$linkBatch->addObj( Title::makeTitle( NS_TEMPLATE, $row->pl_title ));
			}
		}
		return $linkBatch->constructSet( 'tl', $dbr );
	}
Example #5
0
 protected function parseUserValue($value)
 {
     global $wgContLang;
     if ($this->m_caption === false) {
         $this->m_caption = $value;
     }
     $valueParts = explode(':', $value, 2);
     if (count($valueParts) > 1) {
         $namespace = smwfNormalTitleText($valueParts[0]);
         $value = $valueParts[1];
         $typeNamespace = $wgContLang->getNsText(SMW_NS_TYPE);
         if ($namespace != $typeNamespace) {
             $this->addError(wfMsgForContent('smw_wrong_namespace', $typeNamespace));
         }
     }
     $this->m_givenLabel = smwfNormalTitleText($value);
     $this->m_typeId = SMWDataValueFactory::findTypeID($this->m_givenLabel);
     if ($this->m_typeId === '') {
         $this->addError(wfMsgForContent('smw_unknowntype', $this->m_givenLabel));
         $this->m_realLabel = $this->m_givenLabel;
     } else {
         $this->m_realLabel = SMWDataValueFactory::findTypeLabel($this->m_typeId);
     }
     $this->m_isAlias = $this->m_realLabel === $this->m_givenLabel ? false : true;
     try {
         $this->m_dataitem = self::getTypeUriFromTypeId($this->m_typeId);
     } catch (SMWDataItemException $e) {
         $this->m_dataitem = self::getTypeUriFromTypeId('notype');
         $this->addError(wfMsgForContent('smw_parseerror'));
     }
 }
	/**
	 * Run a pageSchemasCreatePage job
	 * @return boolean success
	 */
	function run() {
		wfProfileIn( __METHOD__ );

		if ( is_null( $this->title ) ) {
			$this->error = "pageSchemasCreatePage: Invalid title";
			wfProfileOut( __METHOD__ );
			return false;
		}
		$article = new Article( $this->title );
		if ( !$article ) {
			$this->error = 'pageSchemasCreatePage: Article not found "' . $this->title->getPrefixedDBkey() . '"';
			wfProfileOut( __METHOD__ );
			return false;
		}

		$page_text = $this->params['page_text'];
		// change global $wgUser variable to the one
		// specified by the job only for the extent of this
		// replacement
		global $wgUser;
		$actual_user = $wgUser;
		$wgUser = User::newFromId( $this->params['user_id'] );
		$edit_summary = wfMsgForContent( 'ps-generatepages-editsummary' );
		$article->doEdit( $page_text, $edit_summary );
		$wgUser = $actual_user;
		wfProfileOut( __METHOD__ );
		return true;
	}
 function getQueryInfo()
 {
     $dbr = wfGetDB(DB_SLAVE);
     $dMsgText = wfMsgForContent('disambiguationspage');
     $linkBatch = new LinkBatch();
     # If the text can be treated as a title, use it verbatim.
     # Otherwise, pull the titles from the links table
     $dp = Title::newFromText($dMsgText);
     if ($dp) {
         if ($dp->getNamespace() != NS_TEMPLATE) {
             # @todo FIXME: We assume the disambiguation message is a template but
             # the page can potentially be from another namespace :/
             wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
         }
         $linkBatch->addObj($dp);
     } else {
         # Get all the templates linked from the Mediawiki:Disambiguationspage
         $disPageObj = Title::makeTitleSafe(NS_MEDIAWIKI, 'disambiguationspage');
         $res = $dbr->select(array('pagelinks', 'page'), 'pl_title', array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE, 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()), __METHOD__);
         foreach ($res as $row) {
             $linkBatch->addObj(Title::makeTitle(NS_TEMPLATE, $row->pl_title));
         }
     }
     $set = $linkBatch->constructSet('tl', $dbr);
     if ($set === false) {
         # We must always return a valid SQL query, but this way
         # the DB will always quickly return an empty result
         $set = 'FALSE';
         wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n");
     }
     // @todo FIXME: What are pagelinks and p2 doing here?
     return array('tables' => array('templatelinks', 'p1' => 'page', 'pagelinks', 'p2' => 'page'), 'fields' => array('p1.page_namespace AS namespace', 'p1.page_title AS title', 'pl_from AS value'), 'conds' => array($set, 'p1.page_id = tl_from', 'pl_namespace = p1.page_namespace', 'pl_title = p1.page_title', 'p2.page_id = pl_from', 'p2.page_namespace' => MWNamespace::getContentNamespaces()));
 }
 /**
  * Callback function to output a restriction
  */
 function formatRow($row)
 {
     global $wgUser, $wgLang, $wgContLang;
     wfProfileIn(__METHOD__);
     static $skin = null;
     if (is_null($skin)) {
         $skin = $wgUser->getSkin();
     }
     $title = Title::makeTitleSafe($row->page_namespace, $row->page_title);
     $link = $skin->makeLinkObj($title);
     $description_items = array();
     $protType = wfMsgHtml('restriction-level-' . $row->pr_level);
     $description_items[] = $protType;
     if ($row->pr_cascade) {
         $description_items[] = wfMsg('protect-summary-cascade');
     }
     $expiry_description = '';
     $stxt = '';
     if ($row->pr_expiry != 'infinity' && strlen($row->pr_expiry)) {
         $expiry = Block::decodeExpiry($row->pr_expiry);
         $expiry_description = wfMsgForContent('protect-expiring', $wgLang->timeanddate($expiry));
         $description_items[] = $expiry_description;
     }
     if (!is_null($size = $row->page_len)) {
         if ($size == 0) {
             $stxt = ' <small>' . wfMsgHtml('historyempty') . '</small>';
         } else {
             $stxt = ' <small>' . wfMsgHtml('historysize', $wgLang->formatNum($size)) . '</small>';
         }
         $stxt = $wgContLang->getDirMark() . $stxt;
     }
     wfProfileOut(__METHOD__);
     return '<li>' . wfSpecialList($link . $stxt, implode($description_items, ', ')) . "</li>\n";
 }
 function __construct()
 {
     global $wgRequest, $wgTitle;
     parent::__construct('CreateFromTemplate', '', true);
     $bits = explode('/', $wgTitle->getDBkey(), 2);
     if (!empty($bits[1])) {
         $this->mType = $bits[1];
     } else {
         $this->mType = $wgRequest->getText('type');
     }
     // setup list of fields for recipe form
     $key = "recipes-template-{$this->mType}-fields";
     $fieldsRaw = wfMsgForContent($key);
     //		if ( wfMsgEmpty( $key, $fieldsRaw ) ) {
     //			return null;
     //		}
     $this->mFields = array();
     $parent = '';
     $fieldsRaw = explode("\n", $fieldsRaw);
     foreach ($fieldsRaw as $row) {
         if (strpos($row, '* ') === 0) {
             $row = trim($row, '* ');
             $this->mFields[$row] = array();
             $parent = $row;
         } elseif (strpos($row, '** ') === 0) {
             $row = trim($row, '** ');
             $row = explode('|', $row);
             $row[1] = $row[1] === 'true' ? true : $row[1];
             $row[1] = $row[1] === 'false' ? false : $row[1];
             $this->mFields[$parent][$row[0]] = $row[1];
         }
         // other cases are ignored
     }
 }
 public function formatRow($row)
 {
     $title = Title::newFromRow($row);
     # Link to page
     $link = Linker::link($title);
     # Link to page configuration
     $config = Linker::linkKnown(SpecialPage::getTitleFor('Stabilization'), wfMsgHtml('configuredpages-config'), array(), 'page=' . $title->getPrefixedUrl());
     # Show which version is the default (stable or draft)
     if (intval($row->fpc_override)) {
         $default = wfMsgHtml('configuredpages-def-stable');
     } else {
         $default = wfMsgHtml('configuredpages-def-draft');
     }
     # Autoreview/review restriction level
     $restr = '';
     if ($row->fpc_level != '') {
         $restr = 'autoreview=' . htmlspecialchars($row->fpc_level);
         $restr = "[{$restr}]";
     }
     # When these configuration settings expire
     if ($row->fpc_expiry != 'infinity' && strlen($row->fpc_expiry)) {
         $expiry_description = " (" . wfMsgForContent('protect-expiring', $this->getLang()->timeanddate($row->fpc_expiry), $this->getLang()->date($row->fpc_expiry), $this->getLang()->time($row->fpc_expiry)) . ")";
     } else {
         $expiry_description = "";
     }
     return "<li>{$link} ({$config}) <b>[{$default}]</b> " . "{$restr}<i>{$expiry_description}</i></li>";
 }
Example #11
0
 public function execute()
 {
     global $wgRequest, $wgWikiLoveLogging, $wgParser;
     $params = $this->extractRequestParams();
     $title = Title::newFromText($params['title']);
     if (is_null($title)) {
         $this->dieUsageMsg(array('invaliduser', $params['title']));
     }
     $talk = WikiLoveHooks::getUserTalkPage($title);
     if (is_null($talk)) {
         $this->dieUsageMsg(array('invaliduser', $params['title']));
     }
     if ($wgWikiLoveLogging) {
         $this->saveInDb($talk, $params['subject'], $params['message'], $params['type'], isset($params['email']) ? 1 : 0);
     }
     // not using section => 'new' here, as we like to give our own edit summary
     $api = new ApiMain(new DerivativeRequest($wgRequest, array('action' => 'edit', 'title' => $talk->getFullText(), 'appendtext' => ($talk->exists() ? "\n\n" : '') . wfMsgForContent('newsectionheaderdefaultlevel', $params['subject']) . "\n\n" . $params['text'], 'token' => $params['token'], 'summary' => wfMsgForContent('wikilove-summary', $wgParser->stripSectionName($params['subject'])), 'notminor' => true), false), true);
     $api->execute();
     if (isset($params['email'])) {
         $this->emailUser($talk, $params['subject'], $params['email'], $params['token']);
     }
     $this->getResult()->addValue('redirect', 'pageName', $talk->getPrefixedDBkey());
     $this->getResult()->addValue('redirect', 'fragment', Title::escapeFragmentForURL($params['subject']));
     // note that we cannot use Title::makeTitle here as it doesn't sanitize the fragment
 }
Example #12
0
 function execute($par)
 {
     global $wgUser, $wgRequest;
     if (!$this->userCanExecute($wgUser)) {
         $this->displayRestrictionError();
         return;
     }
     $this->setHeaders();
     $this->outputHeader();
     $target = $wgRequest->getText('target', $par);
     // Normalise name
     if ($target !== '') {
         $user = User::newFromName($target);
         if ($user) {
             $target = $user->getName();
         }
     }
     $reason = $wgRequest->getText('wpReason', wfMsgForContent('nuke-defaultreason', $target));
     $posted = $wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'));
     if ($posted) {
         $pages = $wgRequest->getArray('pages');
         if ($pages) {
             return $this->doDelete($pages, $reason);
         }
     }
     if ($target != '') {
         $this->listForm($target, $reason);
     } else {
         $this->promptForm();
     }
 }
Example #13
0
 public static function parserFunction($parser, $vid = null, $img = null)
 {
     global $wgTitle, $wgContLang;
     wfLoadExtensionMessages('WHVid');
     if ($vid === null || $img === null) {
         return '<div class="errorbox">' . wfMsg('missing-params') . '</div>';
     }
     $vid = htmlspecialchars($vid);
     $divId = "whvid-" . md5($vid . mt_rand(1, 1000));
     $vidUrl = self::getVidUrl($vid);
     $imgTitle = Title::newFromURL($img, NS_IMAGE);
     $imgUrl = null;
     if ($imgTitle) {
         $imgFile = RepoGroup::singleton()->findFile($imgTitle);
         $smallImgUrl = '';
         $largeImgUrl = '';
         if ($imgFile) {
             $width = 550;
             $height = 309;
             $thumb = $imgFile->getThumbnail($width, $height);
             $largeImgUrl = wfGetPad($thumb->getUrl());
             $width = 240;
             //$height = 135;
             $thumb = $imgFile->getThumbnail($width);
             $smallImgUrl = wfGetPad($thumb->getUrl());
         }
     }
     return $parser->insertStripItem(wfMsgForContent('embed-html', $divId, $vidUrl, $largeImgUrl, $smallImgUrl));
 }
Example #14
0
 public function execute()
 {
     $prop = null;
     extract($this->extractRequestParams());
     foreach ($prop as $p) {
         switch ($p) {
             case 'general':
                 global $wgSitename, $wgVersion, $wgCapitalLinks;
                 $data = array();
                 $mainPage = Title::newFromText(wfMsgForContent('mainpage'));
                 $data['mainpage'] = $mainPage->getText();
                 $data['base'] = $mainPage->getFullUrl();
                 $data['sitename'] = $wgSitename;
                 $data['generator'] = "MediaWiki {$wgVersion}";
                 $data['case'] = $wgCapitalLinks ? 'first-letter' : 'case-sensitive';
                 // 'case-insensitive' option is reserved for future
                 $this->getResult()->addValue('query', $p, $data);
                 break;
             case 'namespaces':
                 global $wgContLang;
                 $data = array();
                 foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
                     $data[$ns] = array('id' => $ns);
                     ApiResult::setContent($data[$ns], $title);
                 }
                 ApiResult::setIndexedTagName($data, 'ns');
                 $this->getResult()->addValue('query', $p, $data);
                 break;
             default:
                 ApiBase::dieDebug(__METHOD__, "Unknown prop={$p}");
         }
     }
 }
function UW_CatBoxAtTop_Rejig ( &$out, &$text ) {
	global $wgVersion;

	// no categories = no box
	if ( !$out->mCategoryLinks )
		return true;

	

	/* add a category box to the top of the output,
	 * to be dropped into the top right via CSS */
	$catbox = "<div id=\"catbox\"><div>\n";
	$catbox .= "<h5>" . wfMsgForContent( 'catboxattop-categories' ) . "</h5><ul>\n";
	$catlinks = array();

	if ( array_key_exists( 'normal', $out->mCategoryLinks ) ) {
		$catlinks = $out->mCategoryLinks['normal'];
	} else {
		$catlinks = $out->mCategoryLinks;
	}

	foreach ( $catlinks as $cat )
		$catbox .= "<li>$cat</li>\n";
	$catbox .= "</ul></div></div>\n";

	$text = $catbox . $text;
	return true;
}
function wfWhitelistPages() {
	global $wgWhitelistRead, $wgGroupPermissions;

	$message = wfMsgForContent( 'public read whitelist' );

	// If MediaWiki:Public read whitelist is empty, bail out
	if ( wfEmptyMsg( 'public read whitelist', $message ) ) {
		return;
	}

	// If anonymous users can read the wiki, then it's not a private one
	// and we don't need this feature for non-private wikis
	if ( $wgGroupPermissions['*']['read'] ) {
		return;
	}

	// $wgWhitelistRead is *false* by default instead of being an empty array
	if ( $wgWhitelistRead === false ) {
		$wgWhitelistRead = array();
	}

	// Explode along newlines
	$whitelistedPages = explode( "\n", trim( $message ) );

	// Merge with current list
	$wgWhitelistRead = array_merge( $wgWhitelistRead, $whitelistedPages );
}
 /**
  * add some default values
  */
 public function beforeSave()
 {
     if (empty($this->mEditPage->summary)) {
         $this->mEditPage->summary = wfMsgForContent('create-blog-updated');
     }
     $this->mEditPage->recreate = true;
 }
 public function formatRow($row)
 {
     $title = Title::makeTitle($row->page_namespace, $row->page_title);
     // Link to page
     $link = Linker::link($title);
     // Helpful utility links
     $utilLinks = array();
     $utilLinks[] = Linker::link($title, wfMsgHtml('stablepages-config'), array(), array('action' => 'protect'), 'known');
     $utilLinks[] = Linker::link($title, wfMsgHtml('history'), array(), array('action' => 'history'), 'known');
     $utilLinks[] = Linker::link(SpecialPage::getTitleFor('Log', 'stable'), wfMsgHtml('stable-logpage'), array(), array('page' => $title->getPrefixedText()), 'known');
     // Autoreview/review restriction level
     $restr = '';
     if ($row->fpc_level != '') {
         $restr = 'autoreview=' . htmlspecialchars($row->fpc_level);
         $restr = "[{$restr}]";
     }
     // When these configuration settings expire
     if ($row->fpc_expiry != 'infinity' && strlen($row->fpc_expiry)) {
         $expiry_description = " (" . wfMsgForContent('protect-expiring', $this->getLang()->timeanddate($row->fpc_expiry), $this->getLang()->date($row->fpc_expiry), $this->getLang()->time($row->fpc_expiry)) . ")";
     } else {
         $expiry_description = "";
     }
     $utilLinks = $this->getLang()->pipeList($utilLinks);
     return "<li>{$link} ({$utilLinks}) {$restr}<i>{$expiry_description}</i></li>";
 }
Example #19
0
 protected function parseUserValue($value)
 {
     if ($this->m_caption === false) {
         $this->m_caption = $value;
     }
     $this->addError(wfMsgForContent('smw_parseerror'));
 }
Example #20
0
 public function __construct($msg)
 {
     $args = func_get_args();
     array_shift($args);
     array_map('htmlspecialchars', $args);
     $this->message = '<strong class="error">' . wfMsgForContent("pfunc-convert-{$msg}", $args) . '</strong>';
 }
Example #21
0
 protected function getResultText($res, $outputmode)
 {
     $result = '';
     if ($outputmode == SMW_OUTPUT_FILE) {
         // make CSV file
         $result .= parent::getResultText($res, $outputmode);
     } else {
         // just make link to feed
         if ($this->getSearchLabel($outputmode)) {
             $label = $this->getSearchLabel($outputmode);
         } else {
             wfLoadExtensionMessages('SemanticMediaWiki');
             $label = wfMsgForContent('smw_csv_link');
         }
         $link = $res->getQueryLink($label);
         $link->setParameter('csv', 'format');
         $link->setParameter($this->m_sep, 'sep');
         if (array_key_exists('limit', $this->m_params)) {
             $link->setParameter($this->m_params['limit'], 'limit');
         } else {
             // use a reasonable default limit
             $link->setParameter(100, 'limit');
         }
         // KK: support merge option
         if (array_key_exists('merge', $this->m_params)) {
             $link->setParameter($this->m_params['merge'], 'merge');
         }
         $result .= $link->getText($outputmode, $this->mLinker);
         $this->isHTML = $outputmode == SMW_OUTPUT_HTML;
         // yes, our code can be viewed as HTML if requested, no more parsing needed
     }
     return $result;
 }
Example #22
0
function wfNewuserlogHook($user)
{
    global $wgUser, $wgContLang, $wgVersion;
    if (is_null($user)) {
        // Compatibility with old versions which didn't pass the parameter
        $user = $wgUser;
    }
    $talk = $wgContLang->getFormattedNsText(NS_TALK);
    $contribs = wfMsgForContent('contribslink');
    $block = wfMsgForContent('blocklink');
    if ($user->getName() == $wgUser->getName()) {
        $message = '';
        $action = 'create';
    } else {
        // Links not necessary for self-creations, they will appear already in
        // recentchanges and special:log view for the creating user.
        // For compatability: From 1.10alpha the 'user tools' are used at special:log
        // see bug 4756: Long usernames break block link in new user log entries
        $action = 'create2';
        if (version_compare($wgVersion, '1.10alpha', '>=')) {
            $message = '';
        } else {
            $message = wfMsgForContent('newuserlog-create-text', $user->getName(), $talk, $contribs, $block);
        }
    }
    $log = new LogPage('newusers');
    $log->addEntry($action, $user->getUserPage(), $message);
    return true;
}
Example #23
0
function WidgetCategoryCloud($id, $params)
{
    $output = "";
    wfProfileIn(__METHOD__);
    global $wgMemc;
    $key = wfMemcKey("WidgetCategoryCloud", "data");
    $data = $wgMemc->get($key);
    if (is_null($data)) {
        $data = WidgetCategoryCloudCloudizeData(WidgetCategoryCloudGetData());
        $wgMemc->set($key, $data, 3600);
    }
    if (empty($data)) {
        wfProfileOut(__METHOD__);
        return wfMsgForContent("widget-categorycloud-empty");
    }
    foreach ($data as $name => $value) {
        $category = Title::newFromText($name, NS_CATEGORY);
        if (is_object($category)) {
            $class = "cloud" . $value;
            $output .= Xml::openElement("li", array("class" => $class));
            // FIXME fix Wikia:link and use it here
            $output .= Xml::element("a", array("class" => $class, "href" => $category->getLocalURL(), "title" => $category->getFullText()), $category->getBaseText());
            $output .= Xml::closeElement("li");
            $output .= "\n";
        }
    }
    if (empty($output)) {
        wfProfileOut(__METHOD__);
        return wfMsgForContent("widget-categorycloud-empty");
    }
    $output = Xml::openElement("ul") . $output . Xml::closeElement("ul");
    wfProfileOut(__METHOD__);
    return $output;
}
/**
 * Send the message if the UserBoard class exists (duh!) and the welcome
 * message has some content.
 *
 * @param $user User: the new User object being created
 * @param $byEmail Boolean: true if the account was created by e-mail
 * @return Boolean: true
 */
function wfSendUserBoardMessageOnRegistration($user, $byEmail)
{
    if (class_exists('UserBoard') && $user instanceof User) {
        $message = trim(wfMsgForContent('user-board-welcome-message'));
        // If the welcome message is empty, short-circuit right away.
        if (wfEmptyMsg('user-board-welcome-message', $message)) {
            return true;
        }
        // Just quit if we're in read-only mode
        if (wfReadOnly()) {
            return true;
        }
        $dbr = wfGetDB(DB_SLAVE);
        // Get all users who are in the 'sysop' group and aren't blocked from
        // the database
        $res = $dbr->select(array('user_groups', 'ipblocks'), array('ug_group', 'ug_user'), array('ug_group' => 'sysop', 'ipb_user' => null), __METHOD__, array(), array('ipblocks' => array('LEFT JOIN', 'ipb_user = ug_user')));
        $adminUids = array();
        foreach ($res as $row) {
            $adminUids[] = $row->ug_user;
        }
        // Pick one UID from the array of admin user IDs
        $random = array_rand(array_flip($adminUids), 1);
        $sender = User::newFromId($random);
        $senderUid = $sender->getId();
        $senderName = $sender->getName();
        // Send the message
        $b = new UserBoard();
        $b->sendBoardMessage($senderUid, $senderName, $user->getId(), $user->getName(), wfMsgForContent('user-board-welcome-message', $senderName));
    }
    return true;
}
Example #25
0
 public function hUnwatchArticleComplete(&$user, &$article)
 {
     $message = wfMsgForContent('watchlog-unwatch-text', $article->mTitle->getPrefixedText());
     $log = new LogPage('watchlog');
     $log->addEntry('unwatchok', $user->getUserPage(), $message);
     return true;
 }
Example #26
0
 public function buildWhiteList()
 {
     wfProfileIn(__METHOD__);
     $whitelist = array();
     $content = wfMsgForContent(self::SPAM_WHITELIST_TITLE);
     if (wfemptyMsg(self::SPAM_WHITELIST_TITLE, $content)) {
         wfProfileOut(__METHOD__);
         return $whitelist;
     }
     $content = array_filter(array_map('trim', preg_replace('/#.*$/', '', explode("\n", $content))));
     if (!empty($content)) {
         foreach ($content as $regex) {
             $regex = str_replace('/', '\\/', preg_replace('|\\\\*/|', '/', $regex));
             $regex = "/https?:\\/\\/+[a-z0-9_.-]*{$regex}/i";
             wfsuppressWarnings();
             $regexValid = preg_match($regex, '');
             wfrestoreWarnings();
             if ($regexValid === false) {
                 continue;
             }
             $whitelist[] = $regex;
         }
     }
     Wikia::log(__METHOD__, __LINE__, count($whitelist) . ' whitelist entries loaded.');
     wfProfileOut(__METHOD__);
     return $whitelist;
 }
 /**
  * Updates wiki specific properties set from wiki creation wizard.
  * Context of this method is on the wiki that the values are changing on.
  * Main wiki creation happens on www, and it will redirect to the newly created wiki.
  * The values are read from the session and only accessible by the admin.
  */
 public function FinishCreate()
 {
     global $wgUser, $wgOut, $wgEnableNjordExt;
     if (!$wgUser->isAllowed('finishcreate')) {
         return false;
     }
     $this->skipRendering();
     $this->LoadState();
     $mainPage = wfMsgForContent('mainpage');
     // set theme
     if (!empty($this->params['color-body'])) {
         $themeSettings = new ThemeSettings();
         $themeSettings->saveSettings($this->params);
     }
     // set description on main page
     if (!empty($this->params['wikiDescription'])) {
         $mainTitle = Title::newFromText($mainPage);
         $mainId = $mainTitle->getArticleID();
         $mainArticle = Article::newFromID($mainId);
         if (!empty($mainArticle)) {
             if (!empty($wgEnableNjordExt)) {
                 $newMainPageText = $this->getMoMMainPage($mainArticle);
             } else {
                 $newMainPageText = $this->getClassicMainPage($mainArticle);
             }
             $mainArticle->doEdit($newMainPageText, '');
             $this->initHeroModule($mainPage);
         }
     }
     $wgOut->enableClientCache(false);
     $this->clearState();
     $wgOut->redirect($mainPage . '?wiki-welcome=1');
 }
 /**
  * Move old stale requests to rejected list. Delete old rejected requests.
  */
 public static function runAutoMaintenance()
 {
     global $wgRejectedAccountMaxAge, $wgConfirmAccountRejectAge, $wgConfirmAccountFSRepos;
     $dbw = wfGetDB(DB_MASTER);
     $repo = new FSRepo($wgConfirmAccountFSRepos['accountreqs']);
     # Select all items older than time $encCutoff
     $encCutoff = $dbw->addQuotes($dbw->timestamp(time() - $wgRejectedAccountMaxAge));
     $res = $dbw->select('account_requests', array('acr_id', 'acr_storage_key'), array("acr_rejected < {$encCutoff}"), __METHOD__);
     # Clear out any associated attachments and delete those rows
     foreach ($res as $row) {
         $key = $row->acr_storage_key;
         if ($key) {
             $path = $repo->getZonePath('public') . '/' . UserAccountRequest::relPathFromKey($key);
             if ($path && file_exists($path)) {
                 unlink($path);
             }
         }
         $dbw->delete('account_requests', array('acr_id' => $row->acr_id), __METHOD__);
     }
     # Select all items older than time $encCutoff
     $encCutoff = $dbw->addQuotes($dbw->timestamp(time() - $wgConfirmAccountRejectAge));
     # Old stale accounts will count as rejected. If the request was held, give it more time.
     $dbw->update('account_requests', array('acr_rejected' => $dbw->timestamp(), 'acr_user' => 0, 'acr_comment' => wfMsgForContent('confirmaccount-autorej'), 'acr_deleted' => 1), array("acr_rejected IS NULL", "acr_registration < {$encCutoff}", "acr_held < {$encCutoff} OR acr_held IS NULL"), __METHOD__);
     # Clear cache for notice of how many account requests there are
     self::clearAccountRequestCountCache();
 }
 function getSQL()
 {
     $dbr =& wfGetDB(DB_SLAVE);
     list($page, $pagelinks, $templatelinks) = $dbr->tableNamesN('page', 'pagelinks', 'templatelinks');
     $dMsgText = wfMsgForContent('disambiguationspage');
     $linkBatch = new LinkBatch();
     # If the text can be treated as a title, use it verbatim.
     # Otherwise, pull the titles from the links table
     $dp = Title::newFromText($dMsgText);
     if ($dp) {
         if ($dp->getNamespace() != NS_TEMPLATE) {
             # FIXME we assume the disambiguation message is a template but
             # the page can potentially be from another namespace :/
             wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
         }
         $linkBatch->addObj($dp);
     } else {
         # Get all the templates linked from the Mediawiki:Disambiguationspage
         $disPageObj = $this->getDisambiguationPageObj();
         $res = $dbr->select(array('pagelinks', 'page'), 'pl_title', array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE, 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()), 'DisambiguationsPage::getSQL');
         while ($row = $dbr->fetchObject($res)) {
             $linkBatch->addObj(Title::makeTitle(NS_TEMPLATE, $row->pl_title));
         }
         $dbr->freeResult($res);
     }
     $set = $linkBatch->constructSet('lb.tl', $dbr);
     if ($set === false) {
         $set = 'FALSE';
         # We must always return a valid sql query, but this way DB will always quicly return an empty result
         wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n");
     }
     $sql = "SELECT 'Disambiguations' AS \"type\", pb.page_namespace AS namespace," . " pb.page_title AS title, la.pl_from AS value" . " FROM {$templatelinks} AS lb, {$page} AS pb, {$pagelinks} AS la, {$page} AS pa" . " WHERE {$set}" . ' AND pa.page_id = la.pl_from' . ' AND pa.page_namespace = ' . NS_MAIN . ' AND pb.page_id = lb.tl_from' . ' AND pb.page_namespace = la.pl_namespace' . ' AND pb.page_title = la.pl_title' . ' ORDER BY lb.tl_namespace, lb.tl_title';
     return $sql;
 }
Example #30
0
 public function getQueryLink($caption = false)
 {
     $params = array(trim($this->mQuery->getQueryString()));
     foreach ($this->mQuery->getExtraPrintouts() as $printout) {
         //$params[] = '?result.'.$printout->getData().'='.$printout->getLabel();
         $params[] = '?result.' . $printout->getData() . '=' . $printout->getLabel();
     }
     if ($caption == false) {
         smwfLoadExtensionMessages('SemanticMediaWiki');
         $caption = ' ' . wfMsgForContent('smw_iq_moreresults');
         // The space is right here, not in the QPs!
     }
     //unset limit and offset parameter since this is explicitly added by special:ask
     if (array_key_exists('limit', $this->mQuery->params)) {
         unset($this->mQuery->params['limit']);
     }
     if (array_key_exists('offset', $this->mQuery->params)) {
         unset($this->mQuery->params['offset']);
     }
     //add other query params like source and webservice to the link
     $params = array_merge($params, $this->mQuery->params);
     // Note: the initial : prevents SMW from reparsing :: in the query string.
     $result = SMWInfolink::newInternalLink($caption, ':Special:Ask', false, $params);
     return $result;
 }