本文整理汇总了PHP中SpecialPage::getOutput方法的典型用法代码示例。如果您正苦于以下问题:PHP SpecialPage::getOutput方法的具体用法?PHP SpecialPage::getOutput怎么用?PHP SpecialPage::getOutput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpecialPage
的用法示例。
在下文中一共展示了SpecialPage::getOutput方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHTMLFromSpecialPage
/**
* @param SpecialPage $page
* @param string $subPage
*
* @throws Exception
* @return string HTML
*/
private function getHTMLFromSpecialPage(SpecialPage $page, $subPage)
{
ob_start();
try {
$page->execute($subPage);
$output = $page->getOutput();
if ($output->getRedirect() !== '') {
$output->output();
$html = ob_get_contents();
} elseif ($output->isDisabled()) {
$html = ob_get_contents();
} else {
$html = $output->getHTML();
}
} catch (Exception $ex) {
ob_end_clean();
// Re-throw exception after "finally" handling because PHP 5.3 doesn't have "finally".
throw $ex;
}
ob_end_clean();
return $html;
}
示例2: fetchRequestInformations
/**
* Fetch informations about the user uploading, prepare prefixes list content, and
* set the default item to select. It also updates the special page DestFileName
* attribute. Attached to hooks:
* <ul>
* <li>$wgHooks['UploadForm:initial']</li>
* <li>$wgHooks['UploadForm:BeforeProcessing']</li>
* </ul>
* @param SpecialPage $specialUploadObj current SpecialUpload page object
* @todo if the user cannot upload a new file, maybe this function should
* however return true, as seen in SpecialUpload page code comments (but if
* true returned, the form is displayed with our error message on top)
*/
public static function fetchRequestInformations($specialUploadObj)
{
$user = $specialUploadObj->getUser();
self::$USER_IS_WP_ADMIN = $user->isAllowed(WP_ADMIN_RIGHT);
if (self::$USER_IS_WP_ADMIN || !self::$DISPLAY_UPLOAD_MOD) {
return true;
// no informations to fetch and nothing to prepare, using standard form
}
$full_title = $specialUploadObj->getFullTitle();
$request = $specialUploadObj->getRequest();
// update special page DestFileName attribute
$final_wp_filename = self::getDestinationFileName($request);
if ($final_wp_filename != null) {
$specialUploadObj->mDesiredDestName = $final_wp_filename;
wfDebugLog('wikiplaces-debug', 'fetchRequestInformations, mDesiredDestName set to "' . $final_wp_filename . '"');
}
$final_wp_file_title = Title::newFromText($final_wp_filename, NS_FILE);
// is the user re uploading a new version of an existing file or followed a "upload a file with this name" link ?
if ($request->getText('wpDestFile') && !$request->getText('wpDestFileMainPart')) {
$result = true;
wfRunHooks('userCan', array(&$final_wp_file_title, &$user, 'upload', &$result));
if ($result !== true) {
wfDebugLog('wikiplaces-debug', 'WikiplaceUpload::fetchRequestInformations userCan returned ' . print_r($result, true));
$specialUploadObj->getOutput()->showErrorPage('sorry', wfMessage('badaccess-group0'));
// not allowed
return false;
// break SpecialUpload page init/processing
}
// Check getUserPermissionsErrors hook (this behavior is suitable for nonessential UI
// controls because it skips potentially expensive cascading permission checks, but may
// provide false positives)
wfRunHooks('getUserPermissionsErrors', array(&$final_wp_file_title, &$user, 'upload', &$result));
if ($result !== true) {
wfDebugLog('wikiplaces-debug', print_r($result, true));
// WikiplacesHooks::getUserPermissionsErrors($final_wp_file_title, $user, 'upload', $result);
if (is_array($result) && !empty($result)) {
$key = array_shift($result);
$specialUploadObj->getOutput()->showErrorPage('sorry', wfMessage($key, $result));
return false;
// break SpecialUpload page init/processing
} else {
$specialUploadObj->getOutput()->showErrorPage('sorry', wfMessage('badaccess-group0'));
// not allowed
return false;
// break SpecialUpload page init/processing
}
}
// she is reuploading or has followed a "upload a file with this name" link
wfDebugLog('wikiplaces-debug', 'fetchRequestInformations: reuploading, so disabling mod');
self::$WPDESTFILE_READONLY = true;
// ensure that the filename field is readonly when create link followed
self::$DISPLAY_UPLOAD_MOD = false;
return true;
// no informations to fetch and nothing to prepare
}
// ( if we arrive here, we are uploading a new file )
// is there a wikiplace specified in the url ?
// search a GET parameter, as seen in SpecialPageFactory around line 408
$db_key = $full_title->getDBkey();
$bits = explode('/', $db_key, 2);
$param = null;
if (isset($bits[1])) {
$param = $bits[1];
}
// is the user trying to upload a public file ?
if ($param === WP_PUBLIC_FILE_PREFIX || $final_wp_file_title instanceof Title && WpPage::isPublic(NS_FILE, $final_wp_file_title->getDBkey())) {
// there is a "Public" param, there will be only one choice in the listbox
wfDebugLog('wikiplaces-debug', 'fetchRequestInformations: only public prefix will be visible');
self::$FILE_PREFIXES[$param] = WP_PUBLIC_FILE_PREFIX;
self::$FILE_PREFIXES_DEFAULT = $param;
} else {
// get all wikiplaces the user has access to
$wikiplacesOwner = WpWikiplace::factoryAllOwnedByUserId($user->getId());
$wikiplacesMember = WpWikiplace::factoryAllWhereUserIsMember($user->getId());
// check if the user has access to at least one wikiplace
if (count($wikiplacesOwner) + count($wikiplacesMember) == 0) {
$specialUploadObj->getOutput()->showErrorPage('sorry', wfMessage('wp-create-wp-first'));
return false;
// break SpecialUpload page init/processing
}
// multiple choice: prepare full prefixes list
foreach ($wikiplacesOwner as $wikiplace) {
$wpw_name = $wikiplace->getName();
self::$FILE_PREFIXES[$wpw_name] = $wpw_name;
}
foreach ($wikiplacesMember as $wikiplace) {
$wpw_name = $wikiplace->getName();
//.........这里部分代码省略.........
示例3: onSpecialContributionsBeforeMainOutput
/**
* @param $id user_id integer
* @param User $user
* @param SpecialPage $sp
*/
static function onSpecialContributionsBeforeMainOutput($id, User $user, SpecialPage $sp)
{
if ($user->isAnon()) {
return true;
}
$centralUser = CentralAuthUser::getInstance($user);
if (!$centralUser->exists() || !$centralUser->isAttached() || !$centralUser->isLocked() || $centralUser->isHidden()) {
return true;
}
$out = $sp->getOutput();
$count = LogEventsList::showLogExtract($out, array('globalauth'), MWNamespace::getCanonicalName(NS_USER) . ":{$user}@global", '', array('lim' => 1, 'showIfEmpty' => false, 'msgKey' => array('centralauth-contribs-locked-log', $user->getName()), 'offset' => ''));
if ($count === 0) {
// we couldn't load the log entry
$out->wrapWikiMsg('<div class="mw-warning-with-logexcerpt">$1</div>', array('centralauth-contribs-locked', $user));
}
return true;
}
示例4: addNewContributionButton
/**
* Hook: SpecialContributionsBeforeMainOutput
* @param int $id
* @param User $user
* @param SpecialPage $page
*/
public static function addNewContributionButton($id, User $user, SpecialPage $page)
{
global $wgContentTranslationEventLogging;
if ($user->getId() === $page->getUser()->getId() && ContentTranslationHooks::isEnabledForUser($user)) {
// If EventLogging integration is enabled, load the event logging functions module
if ($wgContentTranslationEventLogging) {
$page->getOutput()->addModules('ext.cx.eventlogging');
}
$page->getOutput()->addModules('ext.cx.contributions.init');
}
}
示例5: getOutput
/**
* Get the OutputPage being used for this instance.
* SpecialPage extends ContextSource as of 1.18.
*
* @since 0.1
*
* @return OutputPage
*/
public function getOutput()
{
return version_compare($GLOBALS['wgVersion'], '1.18', '>') ? parent::getOutput() : $GLOBALS['wgOut'];
}