本文整理汇总了PHP中IContextSource::getOutput方法的典型用法代码示例。如果您正苦于以下问题:PHP IContextSource::getOutput方法的具体用法?PHP IContextSource::getOutput怎么用?PHP IContextSource::getOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContextSource
的用法示例。
在下文中一共展示了IContextSource::getOutput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor.
*
* @param IContextSource $context
* @param array $conds
* @param string $className
*/
public function __construct(IContextSource $context, array $conds, $className)
{
$this->conds = $conds;
$this->className = $className;
$this->context = $context;
$this->mDefaultDirection = true;
parent::__construct($context);
$this->context->getOutput()->addModules('ep.pager');
}
示例2: displayPager
/**
* Display a pager with articles.
*
* @since 0.1
*
* @param IContextSource $context
* @param array $conditions
*/
public static function displayPager(IContextSource $context, array $conditions = array())
{
$pager = new EPArticlePager($context, $conditions);
if ($pager->getNumRows()) {
$context->getOutput()->addHTML($pager->getFilterControl() . $pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar() . $pager->getMultipleItemControl());
} else {
$context->getOutput()->addHTML($pager->getFilterControl(true));
$context->getOutput()->addWikiMsg('ep-articles-noresults');
}
}
示例3: includeAssets
public function includeAssets()
{
TranslationHelpers::addModules($this->context->getOutput());
$pages = array();
foreach ($this->collection->getTitles() as $title) {
$pages[] = $title->getPrefixedDBKey();
}
$vars = array('trlKeys' => $pages);
$this->context->getOutput()->addScript(Skin::makeVariablesScript($vars));
}
示例4: addNavigationLinks
/**
* @param $context IContextSource
* @param $pageType
*/
public static function addNavigationLinks(IContextSource $context, $pageType)
{
$linkDefs = array('home' => 'Special:AbuseFilter', 'recentchanges' => 'Special:AbuseFilter/history', 'examine' => 'Special:AbuseFilter/examine', 'log' => 'Special:AbuseLog');
if ($context->getUser()->isAllowed('abusefilter-modify')) {
$linkDefs = array_merge($linkDefs, array('test' => 'Special:AbuseFilter/test', 'tools' => 'Special:AbuseFilter/tools', 'import' => 'Special:AbuseFilter/import'));
}
// Save some translator work
$msgOverrides = array('recentchanges' => 'abusefilter-filter-log');
$links = array();
foreach ($linkDefs as $name => $page) {
// Give grep a chance to find the usages:
// abusefilter-topnav-home, abusefilter-topnav-test, abusefilter-topnav-examine
// abusefilter-topnav-log, abusefilter-topnav-tools, abusefilter-topnav-import
$msgName = "abusefilter-topnav-{$name}";
if (isset($msgOverrides[$name])) {
$msgName = $msgOverrides[$name];
}
$msg = wfMessage($msgName)->parse();
$title = Title::newFromText($page);
if ($name == $pageType) {
$links[] = Xml::tags('strong', null, $msg);
} else {
$links[] = Linker::link($title, $msg);
}
}
$linkStr = wfMessage('parentheses', $context->getLanguage()->pipeList($links))->text();
$linkStr = wfMessage('abusefilter-topnav')->parse() . " {$linkStr}";
$linkStr = Xml::tags('div', array('class' => 'mw-abusefilter-navigation'), $linkStr);
$context->getOutput()->setSubtitle($linkStr);
}
示例5: main
private function main()
{
global $wgUseFileCache, $wgTitle, $wgUseAjax;
wfProfileIn(__METHOD__);
$request = $this->context->getRequest();
// Send Ajax requests to the Ajax dispatcher.
if ($wgUseAjax && $request->getVal('action', 'view') == 'ajax') {
// Set a dummy title, because $wgTitle == null might break things
$title = Title::makeTitle(NS_MAIN, 'AJAX');
$this->context->setTitle($title);
$wgTitle = $title;
$dispatcher = new AjaxDispatcher();
$dispatcher->performAction();
wfProfileOut(__METHOD__);
return;
}
// Get title from request parameters,
// is set on the fly by parseTitle the first time.
$title = $this->getTitle();
$action = $this->getAction();
$wgTitle = $title;
if ($wgUseFileCache && $title->getNamespace() >= 0) {
wfProfileIn('main-try-filecache');
if (HTMLFileCache::useFileCache($this->context)) {
// Try low-level file cache hit
$cache = HTMLFileCache::newFromTitle($title, $action);
if ($cache->isCacheGood()) {
// Check incoming headers to see if client has this cached
$timestamp = $cache->cacheTimestamp();
if (!$this->context->getOutput()->checkLastModified($timestamp)) {
$cache->loadFromFileCache($this->context);
}
// Do any stats increment/watchlist stuff
$this->context->getWikiPage()->doViewUpdates($this->context->getUser());
// Tell OutputPage that output is taken care of
$this->context->getOutput()->disable();
wfProfileOut('main-try-filecache');
wfProfileOut(__METHOD__);
return;
}
}
wfProfileOut('main-try-filecache');
}
$this->performRequest();
// Now commit any transactions, so that unreported errors after
// output() don't roll back the whole DB transaction
wfGetLBFactory()->commitMasterChanges();
// Output everything!
$this->context->getOutput()->output();
wfProfileOut(__METHOD__);
}
示例6: main
private function main()
{
global $wgUseFileCache, $wgTitle, $wgUseAjax;
wfProfileIn(__METHOD__);
$request = $this->context->getRequest();
// Send Ajax requests to the Ajax dispatcher.
if ($wgUseAjax && $request->getVal('action', 'view') == 'ajax') {
// Set a dummy title, because $wgTitle == null might break things
// Wikia change - start
// @author macbre, wladek
$title = Wikia::createTitleFromRequest($request);
// Wikia change - end
$this->context->setTitle($title);
$wgTitle = $title;
$dispatcher = new AjaxDispatcher();
$dispatcher->performAction();
wfProfileOut(__METHOD__);
return;
}
// Get title from request parameters,
// is set on the fly by parseTitle the first time.
$title = $this->getTitle();
$action = $this->getAction();
$wgTitle = $title;
if ($wgUseFileCache && $title->getNamespace() >= 0) {
wfProfileIn('main-try-filecache');
if (HTMLFileCache::useFileCache($this->context)) {
// Try low-level file cache hit
$cache = HTMLFileCache::newFromTitle($title, $action);
if ($cache->isCacheGood()) {
// Check incoming headers to see if client has this cached
$timestamp = $cache->cacheTimestamp();
if (!$this->context->getOutput()->checkLastModified($timestamp)) {
$cache->loadFromFileCache($this->context);
}
// Do any stats increment/watchlist stuff
$this->context->getWikiPage()->doViewUpdates($this->context->getUser());
// Tell OutputPage that output is taken care of
$this->context->getOutput()->disable();
wfProfileOut('main-try-filecache');
wfProfileOut(__METHOD__);
return;
}
}
wfProfileOut('main-try-filecache');
}
$this->performRequest();
$this->finalCleanup();
wfProfileOut(__METHOD__);
}
示例7: main
private function main()
{
global $wgUseFileCache, $wgTitle, $wgUseAjax;
wfProfileIn(__METHOD__);
# Set title from request parameters
$wgTitle = $this->getTitle();
$action = $this->getAction();
$user = $this->context->getUser();
# Send Ajax requests to the Ajax dispatcher.
if ($wgUseAjax && $action == 'ajax') {
$dispatcher = new AjaxDispatcher();
$dispatcher->performAction();
wfProfileOut(__METHOD__);
return;
}
if ($wgUseFileCache && $wgTitle->getNamespace() != NS_SPECIAL) {
wfProfileIn('main-try-filecache');
// Raw pages should handle cache control on their own,
// even when using file cache. This reduces hits from clients.
if (HTMLFileCache::useFileCache()) {
/* Try low-level file cache hit */
$cache = new HTMLFileCache($wgTitle, $action);
if ($cache->isFileCacheGood()) {
/* Check incoming headers to see if client has this cached */
$timestamp = $cache->fileCacheTime();
if (!$this->context->getOutput()->checkLastModified($timestamp)) {
$cache->loadFromFileCache();
}
# Do any stats increment/watchlist stuff
$article = WikiPage::factory($wgTitle);
$article->doViewUpdates($user);
# Tell OutputPage that output is taken care of
$this->context->getOutput()->disable();
wfProfileOut('main-try-filecache');
wfProfileOut(__METHOD__);
return;
}
}
wfProfileOut('main-try-filecache');
}
$this->performRequest();
$this->finalCleanup();
wfProfileOut(__METHOD__);
}
示例8: getHtml
/**
* @param IContextSource $context
*
* @return string HTML
*/
public function getHtml(IContextSource $context)
{
$context->getOutput()->addModules('ext.translate.statsbar');
$total = $this->stats[MessageGroupStats::TOTAL];
$proofread = $this->stats[MessageGroupStats::PROOFREAD];
$translated = $this->stats[MessageGroupStats::TRANSLATED];
$fuzzy = $this->stats[MessageGroupStats::FUZZY];
if (!$total) {
$untranslated = null;
$wproofread = $wtranslated = $wfuzzy = $wuntranslated = 0;
} else {
// Proofread is subset of translated
$untranslated = $total - $translated - $fuzzy;
$wproofread = round(100 * $proofread / $total, 2);
$wtranslated = round(100 * ($translated - $proofread) / $total, 2);
$wfuzzy = round(100 * $fuzzy / $total, 2);
$wuntranslated = round(100 - $wproofread - $wtranslated - $wfuzzy, 2);
}
return Html::rawElement('div', array('class' => 'tux-statsbar', 'data-total' => $total, 'data-group' => $this->group, 'data-language' => $this->language), Html::element('span', array('class' => 'tux-proofread', 'style' => "width: {$wproofread}%", 'data-proofread' => $proofread)) . Html::element('span', array('class' => 'tux-translated', 'style' => "width: {$wtranslated}%", 'data-translated' => $translated)) . Html::element('span', array('class' => 'tux-fuzzy', 'style' => "width: {$wfuzzy}%", 'data-fuzzy' => $fuzzy)) . Html::element('span', array('class' => 'tux-untranslated', 'style' => "width: {$wuntranslated}%", 'data-untranslated' => $untranslated)));
}
示例9: main
private function main()
{
global $wgUseFileCache, $wgTitle, $wgUseAjax;
wfProfileIn(__METHOD__);
$request = $this->context->getRequest();
// Send Ajax requests to the Ajax dispatcher.
if ($wgUseAjax && $request->getVal('action', 'view') == 'ajax') {
// Set a dummy title, because $wgTitle == null might break things
$title = Title::makeTitle(NS_MAIN, 'AJAX');
$this->context->setTitle($title);
$wgTitle = $title;
$dispatcher = new AjaxDispatcher();
$dispatcher->performAction();
wfProfileOut(__METHOD__);
return;
}
// Get title from request parameters,
// is set on the fly by parseTitle the first time.
$title = $this->getTitle();
$action = $this->getAction();
$wgTitle = $title;
// If the user has forceHTTPS set to true, or if the user
// is in a group requiring HTTPS, or if they have the HTTPS
// preference set, redirect them to HTTPS.
// Note: Do this after $wgTitle is setup, otherwise the hooks run from
// isLoggedIn() will do all sorts of weird stuff.
if (($request->getCookie('forceHTTPS', '') || $request->getCookie('forceHTTPS') || $this->context->getUser()->isLoggedIn() && $this->context->getUser()->requiresHTTPS()) && $request->getProtocol() == 'http') {
$oldUrl = $request->getFullRequestURL();
$redirUrl = str_replace('http://', 'https://', $oldUrl);
if ($request->wasPosted()) {
// This is weird and we'd hope it almost never happens. This
// means that a POST came in via HTTP and policy requires us
// redirecting to HTTPS. It's likely such a request is going
// to fail due to post data being lost, but let's try anyway
// and just log the instance.
//
// @todo @fixme See if we could issue a 307 or 308 here, need
// to see how clients (automated & browser) behave when we do
wfDebugLog('RedirectedPosts', "Redirected from HTTP to HTTPS: {$oldUrl}");
}
// Setup dummy Title, otherwise OutputPage::redirect will fail
$title = Title::newFromText(NS_MAIN, 'REDIR');
$this->context->setTitle($title);
$output = $this->context->getOutput();
// Since we only do this redir to change proto, always send a vary header
$output->addVaryHeader('X-Forwarded-Proto');
$output->redirect($redirUrl);
$output->output();
wfProfileOut(__METHOD__);
return;
}
if ($wgUseFileCache && $title->getNamespace() >= 0) {
wfProfileIn('main-try-filecache');
if (HTMLFileCache::useFileCache($this->context)) {
// Try low-level file cache hit
$cache = HTMLFileCache::newFromTitle($title, $action);
if ($cache->isCacheGood()) {
// Check incoming headers to see if client has this cached
$timestamp = $cache->cacheTimestamp();
if (!$this->context->getOutput()->checkLastModified($timestamp)) {
$cache->loadFromFileCache($this->context);
}
// Do any stats increment/watchlist stuff
// Assume we're viewing the latest revision (this should always be the case with file cache)
$this->context->getWikiPage()->doViewUpdates($this->context->getUser());
// Tell OutputPage that output is taken care of
$this->context->getOutput()->disable();
wfProfileOut('main-try-filecache');
wfProfileOut(__METHOD__);
return;
}
}
wfProfileOut('main-try-filecache');
}
// Actually do the work of the request and build up any output
$this->performRequest();
// Either all DB and deferred updates should happen or none.
// The later should not be cancelled due to client disconnect.
ignore_user_abort(true);
// Now commit any transactions, so that unreported errors after
// output() don't roll back the whole DB transaction
wfGetLBFactory()->commitMasterChanges();
// Output everything!
$this->context->getOutput()->output();
wfProfileOut(__METHOD__);
}
示例10: getOutput
/**
* Get the OutputPage being used for this instance.
* IndexPager extends ContextSource as of 1.19.
*
* @since 0.1
*
* @return OutputPage
*/
public function getOutput()
{
return $this->context->getOutput();
}
示例11: main
private function main()
{
global $wgTitle;
$request = $this->context->getRequest();
// Send Ajax requests to the Ajax dispatcher.
if ($this->config->get('UseAjax') && $request->getVal('action') === 'ajax') {
// Set a dummy title, because $wgTitle == null might break things
$title = Title::makeTitle(NS_SPECIAL, 'Badtitle/performing an AJAX call in ' . __METHOD__);
$this->context->setTitle($title);
$wgTitle = $title;
$dispatcher = new AjaxDispatcher($this->config);
$dispatcher->performAction($this->context->getUser());
return;
}
// Get title from request parameters,
// is set on the fly by parseTitle the first time.
$title = $this->getTitle();
$action = $this->getAction();
$wgTitle = $title;
$trxProfiler = Profiler::instance()->getTransactionProfiler();
$trxProfiler->setLogger(LoggerFactory::getInstance('DBPerformance'));
// Aside from rollback, master queries should not happen on GET requests.
// Periodic or "in passing" updates on GET should use the job queue.
if (!$request->wasPosted() && in_array($action, array('view', 'edit', 'history'))) {
$trxProfiler->setExpectation('masterConns', 0, __METHOD__);
$trxProfiler->setExpectation('writes', 0, __METHOD__);
} else {
$trxProfiler->setExpectation('maxAffected', 500, __METHOD__);
}
// If the user has forceHTTPS set to true, or if the user
// is in a group requiring HTTPS, or if they have the HTTPS
// preference set, redirect them to HTTPS.
// Note: Do this after $wgTitle is setup, otherwise the hooks run from
// isLoggedIn() will do all sorts of weird stuff.
if ($request->getProtocol() == 'http' && ($request->getCookie('forceHTTPS', '') || $request->getCookie('forceHTTPS') || $this->context->getUser()->isLoggedIn() && $this->context->getUser()->requiresHTTPS())) {
$oldUrl = $request->getFullRequestURL();
$redirUrl = preg_replace('#^http://#', 'https://', $oldUrl);
// ATTENTION: This hook is likely to be removed soon due to overall design of the system.
if (Hooks::run('BeforeHttpsRedirect', array($this->context, &$redirUrl))) {
if ($request->wasPosted()) {
// This is weird and we'd hope it almost never happens. This
// means that a POST came in via HTTP and policy requires us
// redirecting to HTTPS. It's likely such a request is going
// to fail due to post data being lost, but let's try anyway
// and just log the instance.
//
// @todo FIXME: See if we could issue a 307 or 308 here, need
// to see how clients (automated & browser) behave when we do
wfDebugLog('RedirectedPosts', "Redirected from HTTP to HTTPS: {$oldUrl}");
}
// Setup dummy Title, otherwise OutputPage::redirect will fail
$title = Title::newFromText('REDIR', NS_MAIN);
$this->context->setTitle($title);
$output = $this->context->getOutput();
// Since we only do this redir to change proto, always send a vary header
$output->addVaryHeader('X-Forwarded-Proto');
$output->redirect($redirUrl);
$output->output();
return;
}
}
if ($this->config->get('UseFileCache') && $title->getNamespace() >= 0) {
if (HTMLFileCache::useFileCache($this->context)) {
// Try low-level file cache hit
$cache = new HTMLFileCache($title, $action);
if ($cache->isCacheGood()) {
// Check incoming headers to see if client has this cached
$timestamp = $cache->cacheTimestamp();
if (!$this->context->getOutput()->checkLastModified($timestamp)) {
$cache->loadFromFileCache($this->context);
}
// Do any stats increment/watchlist stuff
// Assume we're viewing the latest revision (this should always be the case with file cache)
$this->context->getWikiPage()->doViewUpdates($this->context->getUser());
// Tell OutputPage that output is taken care of
$this->context->getOutput()->disable();
return;
}
}
}
// Actually do the work of the request and build up any output
$this->performRequest();
// Either all DB and deferred updates should happen or none.
// The later should not be cancelled due to client disconnect.
ignore_user_abort(true);
// Now commit any transactions, so that unreported errors after
// output() don't roll back the whole DB transaction
wfGetLBFactory()->commitMasterChanges();
// Output everything!
$this->context->getOutput()->output();
}
示例12: capturePath
/**
* Just like executePath() but will override global variables and execute
* the page in "inclusion" mode. Returns true if the execution was
* successful or false if there was no such special page, or a title object
* if it was a redirect.
*
* Also saves the current $wgTitle, $wgOut, $wgRequest, $wgUser and $wgLang
* variables so that the special page will get the context it'd expect on a
* normal request, and then restores them to their previous values after.
*
* @param $title Title
* @param $context IContextSource
*
* @return String: HTML fragment
*/
static function capturePath(Title $title, IContextSource $context)
{
global $wgOut, $wgTitle, $wgRequest, $wgUser, $wgLang;
// Save current globals
$oldTitle = $wgTitle;
$oldOut = $wgOut;
$oldRequest = $wgRequest;
$oldUser = $wgUser;
$oldLang = $wgLang;
// Set the globals to the current context
$wgTitle = $title;
$wgOut = $context->getOutput();
$wgRequest = $context->getRequest();
$wgUser = $context->getUser();
$wgLang = $context->getLanguage();
// The useful part
$ret = self::executePath($title, $context, true);
// And restore the old globals
$wgTitle = $oldTitle;
$wgOut = $oldOut;
$wgRequest = $oldRequest;
$wgUser = $oldUser;
$wgLang = $oldLang;
return $ret;
}
示例13: displayAddNewControl
/**
* Adds a control to add a term org to the provided context.
* Additional arguments can be provided to set the default values for the control fields.
*
* @since 0.1
*
* @param IContextSource $context
* @param array $args
*
* @return boolean
*/
public static function displayAddNewControl(IContextSource $context, array $args)
{
if (!$context->getUser()->isAllowed('ep-course')) {
return false;
}
$out = $context->getOutput();
$out->addModules('ep.addcourse');
$out->addHTML(Html::openElement('form', array('method' => 'post', 'action' => self::getTitleFor('NAME_PLACEHOLDER')->getLocalURL(array('action' => 'edit')))));
$out->addHTML('<fieldset>');
$out->addHTML('<legend>' . wfMsgHtml('ep-courses-addnew') . '</legend>');
$out->addElement('p', array(), wfMsg('ep-courses-namedoc'));
$out->addElement('label', array('for' => 'neworg'), wfMsg('ep-courses-neworg'));
$select = new XmlSelect('neworg', 'neworg', array_key_exists('org', $args) ? $args['org'] : false);
$select->addOptions(EPOrg::getOrgOptions());
$out->addHTML($select->getHTML());
$out->addHTML(' ' . Xml::inputLabel(wfMsg('ep-courses-newname'), 'newname', 'newname', 20, array_key_exists('name', $args) ? $args['name'] : false));
$out->addHTML(' ' . Xml::inputLabel(wfMsg('ep-courses-newterm'), 'newterm', 'newterm', 10, array_key_exists('term', $args) ? $args['term'] : false));
$out->addHTML(' ' . Html::input('addnewcourse', wfMsg('ep-courses-add'), 'submit', array('disabled' => 'disabled', 'class' => 'ep-course-add')));
$out->addHTML(Html::hidden('isnew', 1));
$out->addHTML('</fieldset></form>');
return true;
}
示例14: displayNavigation
/**
* Adds a navigation menu with the provided links.
* Links should be provided in an array with:
* label => Title (object)
*
* @since 0.1
*
* @param IContextSource $context
* @param array $items
*/
public static function displayNavigation(IContextSource $context, array $items = array())
{
$links = array();
foreach ($items as $label => $data) {
if (is_array($data)) {
$target = array_shift($data);
$attribs = $data;
} else {
$target = $data;
$attribs = array();
}
$links[] = Linker::linkKnown($target, htmlspecialchars($label), $attribs);
}
$context->getOutput()->addHTML(Html::rawElement('p', array(), $context->getLanguage()->pipeList($links)));
}
示例15: getToolLinks
/**
* Returns the tool links for this mentor.
*
* @since 0.1
*
* @param IContextSource $context
* @param EPCourse|null $course
*
* @return string
*/
public function getToolLinks(IContextSource $context, EPCourse $course = null)
{
$links = array();
$links[] = Linker::userTalkLink($this->getUser()->getId(), $this->getUser()->getName());
$links[] = Linker::link(SpecialPage::getTitleFor('Contributions', $this->getUser()->getName()), wfMsgHtml('contribslink'));
if (!is_null($course) && ($context->getUser()->isAllowed('ep-instructor') || $this->getUser()->getId() == $context->getUser()->getId())) {
$links[] = Html::element('a', array('href' => '#', 'class' => 'ep-instructor-remove', 'data-courseid' => $course->getId(), 'data-coursename' => $course->getField('name'), 'data-userid' => $this->getUser()->getId(), 'data-username' => $this->getUser()->getName(), 'data-bestname' => $this->getName()), wfMsg('ep-instructor-remove'));
$context->getOutput()->addModules('ep.instructor');
}
return ' <span class="mw-usertoollinks">(' . $context->getLanguage()->pipeList($links) . ')</span>';
}