本文整理汇总了PHP中Hooks类的典型用法代码示例。如果您正苦于以下问题:PHP Hooks类的具体用法?PHP Hooks怎么用?PHP Hooks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Hooks类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: event
/**
* 运行事件
* @param string $which 事件名称
* @param string $type 事件类型 '':pc站 m:手机站
* @return Hooks
*/
public static function event($which, $assets = '', $type = '')
{
if (empty(self::$instance)) {
self::$instance = new static();
}
self::$instance->type = $type;
self::$instance->assets = $assets;
self::$instance->position($which);
self::$instance->type = '';
self::$instance->assets = '';
return self::$instance;
}
开发者ID:jackxiaoxiaoxun,项目名称:emmvc,代码行数:18,代码来源:Hooks.php
示例2: __construct
public function __construct()
{
parent::__construct();
$paths = [];
// Autodiscover extension unit tests
$registry = ExtensionRegistry::getInstance();
foreach ($registry->getAllThings() as $info) {
$paths[] = dirname($info['path']) . '/tests/phpunit';
}
// Extensions can return a list of files or directories
Hooks::run('UnitTestsList', [&$paths]);
foreach (array_unique($paths) as $path) {
if (is_dir($path)) {
// If the path is a directory, search for test cases.
// @since 1.24
$suffixes = ['Test.php'];
$fileIterator = new File_Iterator_Facade();
$matchingFiles = $fileIterator->getFilesAsArray($path, $suffixes);
$this->addTestFiles($matchingFiles);
} elseif (file_exists($path)) {
// Add a single test case or suite class
$this->addTestFile($path);
}
}
if (!$paths) {
$this->addTest(new DummyExtensionsTest('testNothing'));
}
}
开发者ID:paladox,项目名称:mediawiki,代码行数:28,代码来源:ExtensionsTestSuite.php
示例3: getTokenTypes
private function getTokenTypes()
{
// If we're in a mode that breaks the same-origin policy, no tokens can
// be obtained
if ($this->lacksSameOriginSecurity()) {
return [];
}
static $types = null;
if ($types) {
return $types;
}
$types = ['patrol' => ['ApiQueryRecentChanges', 'getPatrolToken']];
$names = ['edit', 'delete', 'protect', 'move', 'block', 'unblock', 'email', 'import', 'watch', 'options'];
foreach ($names as $name) {
$types[$name] = ['ApiQueryInfo', 'get' . ucfirst($name) . 'Token'];
}
Hooks::run('ApiTokensGetTokenTypes', [&$types]);
// For forwards-compat, copy any token types from ApiQueryTokens that
// we don't already have something for.
$user = $this->getUser();
$request = $this->getRequest();
foreach (ApiQueryTokens::getTokenTypeSalts() as $name => $salt) {
if (!isset($types[$name])) {
$types[$name] = function () use($salt, $user, $request) {
return ApiQueryTokens::getToken($user, $request->getSession(), $salt)->toString();
};
}
}
ksort($types);
return $types;
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:31,代码来源:ApiTokens.php
示例4: check_user_identity
function check_user_identity($required = true)
{
$realm = 'OpenMediakit Transcoder';
if ($required && !isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="' . $realm . '"');
header('HTTP/1.0 401 Unauthorized');
echo 'Please authenticate';
exit;
}
/*
* Autre exemple de hook possible:
* Hooks::call('pre_check_user_identity', array($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']));
*/
require_once __DIR__ . '/../modules/users/libs/users.php';
if ($required && isset($_SERVER['PHP_AUTH_USER'])) {
$GLOBALS["me"] = Users::auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
} else {
$GLOBALS["me"] = array();
}
if ($required && !$GLOBALS["me"]) {
header('WWW-Authenticate: Basic realm="' . $realm . '"');
header('HTTP/1.0 401 Unauthorized');
echo 'Login or password incorrect, or account disabled';
exit;
}
Hooks::call('post_check_user_identity', $GLOBALS["me"]);
// mq("UPDATE user SET lastlogin=NOW() WHERE id='".$GLOBALS["me"]["id"]."';");
}
开发者ID:ninetian,项目名称:omk-server,代码行数:28,代码来源:users.php
示例5: setup
protected function setup($par)
{
// Options
$opts = new FormOptions();
$this->opts = $opts;
// bind
$opts->add('hideliu', false);
$opts->add('hidepatrolled', $this->getUser()->getBoolOption('newpageshidepatrolled'));
$opts->add('hidebots', false);
$opts->add('hideredirs', true);
$opts->add('limit', $this->getUser()->getIntOption('rclimit'));
$opts->add('offset', '');
$opts->add('namespace', '0');
$opts->add('username', '');
$opts->add('feed', '');
$opts->add('tagfilter', '');
$opts->add('invert', false);
$this->customFilters = [];
Hooks::run('SpecialNewPagesFilters', [$this, &$this->customFilters]);
foreach ($this->customFilters as $key => $params) {
$opts->add($key, $params['default']);
}
// Set values
$opts->fetchValuesFromRequest($this->getRequest());
if ($par) {
$this->parseParams($par);
}
// Validate
$opts->validateIntBounds('limit', 0, 5000);
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:30,代码来源:SpecialNewpages.php
示例6: setup
public function setup()
{
global $wgOut, $wgExtensionAssetsPath, $IP, $wgResourceModules, $wgAutoloadClasses, $wgHooks, $wgParser, $wgJQUploadFileMagic;
// If attachments allowed in this page, add the module into the page
if ($title = array_key_exists('title', $_GET) ? Title::newFromText($_GET['title']) : false) {
$this->id = $title->getArticleID();
}
// Set up the #file parser-function
$wgParser->setFunctionHook($wgJQUploadFileMagic, array($this, 'expandFile'), SFH_NO_HASH);
// Allow overriding of the file ID
Hooks::run('jQueryUploadSetId', array($title, &$this->id));
// If attachments allowed in this page, add the module into the page
$attach = is_object($title) && $this->id && !$title->isRedirect() && !array_key_exists('action', $_REQUEST) && $title->getNamespace() != 6;
if ($attach) {
Hooks::run('jQueryUploadAddAttachLink', array($title, &$attach));
}
if ($attach) {
$this->head();
$wgHooks['BeforePageDisplay'][] = $this;
}
// Add the extensions own js
$path = $wgExtensionAssetsPath . str_replace("{$IP}/extensions", '', dirname($wgAutoloadClasses[__CLASS__]));
$wgResourceModules['ext.jqueryupload']['remoteExtPath'] = $path;
$wgOut->addModules('ext.jqueryupload');
$wgOut->addStyle("{$path}/styles/jqueryupload.css");
}
开发者ID:saper,项目名称:organic-extensions,代码行数:26,代码来源:jQueryUpload_body.php
示例7: instance
/**
* Returns the globally available instance of a Hooks
* @return object The Hooks object.
*/
public static function instance()
{
if (!isset(self::$instance) && !self::$instance instanceof self) {
self::$instance = new self();
}
return self::$instance;
}
开发者ID:BassemN,项目名称:PHP-Hooks,代码行数:11,代码来源:php-hooks.php
示例8: setupHooks
public static function setupHooks()
{
$rsObj = new self();
\Hooks::register('UserSetCookies', $rsObj);
\Hooks::register('UserLoadFromSession', $rsObj);
\Hooks::register('UserLogout', $rsObj);
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:RestrictSessionsHooks.class.php
示例9: onRegistration
public static function onRegistration()
{
global $wgEmailPageGroup, $wgGroupPermissions, $wgEmailPageAllowRemoteAddr, $wgEmailPageToolboxLink, $wgEmailPageActionLink;
if ($wgEmailPageGroup) {
$wgGroupPermissions['sysop'][$wgEmailPageGroup] = true;
}
if (isset($_SERVER['SERVER_ADDR'])) {
$wgEmailPageAllowRemoteAddr[] = $_SERVER['SERVER_ADDR'];
}
// If form has been posted, include the phpmailer class
if (isset($_REQUEST['ea-send'])) {
if ($files = glob("{$dir}/*/class.phpmailer.php")) {
require_once $files[0];
} else {
die("PHPMailer class not found!");
}
}
// Add toolbox and action links
if ($wgEmailPageToolboxLink) {
Hooks::register('SkinTemplateToolboxEnd', __CLASS__ . '::onSkinTemplateToolboxEnd');
}
if ($wgEmailPageActionLink) {
Hooks::register('SkinTemplateTabs', __CLASS__ . '::onSkinTemplateTabs');
Hooks::register('SkinTemplateNavigation', __CLASS__ . '::onSkinTemplateNavigation');
}
}
开发者ID:saper,项目名称:organic-extensions,代码行数:26,代码来源:EmailPage_body.php
示例10: replaceSection
/**
* @param string|number|null|bool $sectionId
* @param Content $with
* @param string $sectionTitle
*
* @throws MWException
* @return Content
*
* @see Content::replaceSection()
*/
public function replaceSection($sectionId, Content $with, $sectionTitle = '')
{
$myModelId = $this->getModel();
$sectionModelId = $with->getModel();
if ($sectionModelId != $myModelId) {
throw new MWException("Incompatible content model for section: " . "document uses {$myModelId} but " . "section uses {$sectionModelId}.");
}
$oldtext = $this->getNativeData();
$text = $with->getNativeData();
if (strval($sectionId) === '') {
return $with;
# XXX: copy first?
}
if ($sectionId === 'new') {
# Inserting a new section
$subject = $sectionTitle ? wfMessage('newsectionheaderdefaultlevel')->rawParams($sectionTitle)->inContentLanguage()->text() . "\n\n" : '';
if (Hooks::run('PlaceNewSection', array($this, $oldtext, $subject, &$text))) {
$text = strlen(trim($oldtext)) > 0 ? "{$oldtext}\n\n{$subject}{$text}" : "{$subject}{$text}";
}
} else {
# Replacing an existing section; roll out the big guns
global $wgParser;
$text = $wgParser->replaceSection($oldtext, $sectionId, $text);
}
$newContent = new static($text);
return $newContent;
}
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:37,代码来源:WikitextContent.php
示例11: execute
public function execute($par)
{
$this->setHeaders();
$this->getOutput()->addModuleStyles('mediawiki.special');
$this->edits = SiteStats::edits();
$this->good = SiteStats::articles();
$this->images = SiteStats::images();
$this->total = SiteStats::pages();
$this->users = SiteStats::users();
$this->activeUsers = SiteStats::activeUsers();
$this->hook = '';
$text = Xml::openElement('table', ['class' => 'wikitable mw-statistics-table']);
# Statistic - pages
$text .= $this->getPageStats();
# Statistic - edits
$text .= $this->getEditStats();
# Statistic - users
$text .= $this->getUserStats();
# Statistic - usergroups
$text .= $this->getGroupStats();
# Statistic - other
$extraStats = [];
if (Hooks::run('SpecialStatsAddExtra', [&$extraStats, $this->getContext()])) {
$text .= $this->getOtherStats($extraStats);
}
$text .= Xml::closeElement('table');
# Customizable footer
$footer = $this->msg('statistics-footer');
if (!$footer->isBlank()) {
$text .= "\n" . $footer->parse();
}
$this->getOutput()->addHTML($text);
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:33,代码来源:SpecialStatistics.php
示例12: execute
function execute($par)
{
/**
* Some satellite ISPs use broken precaching schemes that log people out straight after
* they're logged in (bug 17790). Luckily, there's a way to detect such requests.
*/
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '&') !== false) {
wfDebug("Special:Userlogout request {$_SERVER['REQUEST_URI']} looks suspicious, denying.\n");
throw new HttpError(400, $this->msg('suspicious-userlogout'), $this->msg('loginerror'));
}
$this->setHeaders();
$this->outputHeader();
// Make sure it's possible to log out
$session = MediaWiki\Session\SessionManager::getGlobalSession();
if (!$session->canSetUser()) {
throw new ErrorPageError('cannotlogoutnow-title', 'cannotlogoutnow-text', [$session->getProvider()->describe(RequestContext::getMain()->getLanguage())]);
}
$user = $this->getUser();
$oldName = $user->getName();
$user->logout();
$loginURL = SpecialPage::getTitleFor('Userlogin')->getFullURL($this->getRequest()->getValues('returnto', 'returntoquery'));
$out = $this->getOutput();
$out->addWikiMsg('logouttext', $loginURL);
// Hook.
$injected_html = '';
Hooks::run('UserLogoutComplete', [&$user, &$injected_html, $oldName]);
$out->addHTML($injected_html);
$out->returnToMain();
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:29,代码来源:SpecialUserlogout.php
示例13: getConfigSettings
/**
* @param ResourceLoaderContext $context
* @return array
*/
protected function getConfigSettings($context)
{
$hash = $context->getHash();
if (isset($this->configVars[$hash])) {
return $this->configVars[$hash];
}
global $wgContLang;
$mainPage = Title::newMainPage();
/**
* Namespace related preparation
* - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
* - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
*/
$namespaceIds = $wgContLang->getNamespaceIds();
$caseSensitiveNamespaces = array();
foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
$namespaceIds[$wgContLang->lc($name)] = $index;
if (!MWNamespace::isCapitalized($index)) {
$caseSensitiveNamespaces[] = $index;
}
}
$conf = $this->getConfig();
// Build list of variables
$vars = array('wgLoadScript' => wfScript('load'), 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $conf->get('StylePath'), 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $conf->get('ArticlePath'), 'wgScriptPath' => $conf->get('ScriptPath'), 'wgScriptExtension' => '.php', 'wgScript' => wfScript(), 'wgSearchType' => $conf->get('SearchType'), 'wgVariantArticlePath' => $conf->get('VariantArticlePath'), 'wgActionPaths' => (object) $conf->get('ActionPaths'), 'wgServer' => $conf->get('Server'), 'wgServerName' => $conf->get('ServerName'), 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgTranslateNumerals' => $conf->get('TranslateNumerals'), 'wgVersion' => $conf->get('Version'), 'wgEnableAPI' => $conf->get('EnableAPI'), 'wgEnableWriteAPI' => $conf->get('EnableWriteAPI'), 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $conf->get('Sitename'), 'wgDBname' => $conf->get('DBname'), 'wgExtraSignatureNamespaces' => $conf->get('ExtraSignatureNamespaces'), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $conf->get('ExtensionAssetsPath'), 'wgCookiePrefix' => $conf->get('CookiePrefix'), 'wgCookieDomain' => $conf->get('CookieDomain'), 'wgCookiePath' => $conf->get('CookiePath'), 'wgCookieExpiration' => $conf->get('CookieExpiration'), 'wgResourceLoaderMaxQueryLength' => $conf->get('ResourceLoaderMaxQueryLength'), 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgResourceLoaderStorageVersion' => $conf->get('ResourceLoaderStorageVersion'), 'wgResourceLoaderStorageEnabled' => $conf->get('ResourceLoaderStorageEnabled'), 'wgResourceLoaderLegacyModules' => self::getLegacyModules(), 'wgForeignUploadTargets' => $conf->get('ForeignUploadTargets'), 'wgEnableUploads' => $conf->get('EnableUploads'));
Hooks::run('ResourceLoaderGetConfigVars', array(&$vars));
$this->configVars[$hash] = $vars;
return $this->configVars[$hash];
}
开发者ID:OrBin,项目名称:mediawiki,代码行数:32,代码来源:ResourceLoaderStartUpModule.php
示例14: showReturnToPage
/**
* Show a return link or redirect to it.
* Extensions can change where the link should point or inject content into the page
* (which will change it from redirect to link mode).
*
* @param string $type One of the following:
* - error: display a return to link ignoring $wgRedirectOnLogin
* - success: display a return to link using $wgRedirectOnLogin if needed
* - successredirect: send an HTTP redirect using $wgRedirectOnLogin if needed
* @param string $returnTo
* @param array|string $returnToQuery
* @param bool $stickHTTPS Keep redirect link on HTTPS
*/
public function showReturnToPage($type, $returnTo = '', $returnToQuery = '', $stickHTTPS = false)
{
global $wgRedirectOnLogin, $wgSecureLogin;
if ($type !== 'error' && $wgRedirectOnLogin !== null) {
$returnTo = $wgRedirectOnLogin;
$returnToQuery = [];
} elseif (is_string($returnToQuery)) {
$returnToQuery = wfCgiToArray($returnToQuery);
}
// Allow modification of redirect behavior
Hooks::run('PostLoginRedirect', [&$returnTo, &$returnToQuery, &$type]);
$returnToTitle = Title::newFromText($returnTo) ?: Title::newMainPage();
if ($wgSecureLogin && !$stickHTTPS) {
$options = ['http'];
$proto = PROTO_HTTP;
} elseif ($wgSecureLogin) {
$options = ['https'];
$proto = PROTO_HTTPS;
} else {
$options = [];
$proto = PROTO_RELATIVE;
}
if ($type === 'successredirect') {
$redirectUrl = $returnToTitle->getFullURL($returnToQuery, false, $proto);
$this->getOutput()->redirect($redirectUrl);
} else {
$this->getOutput()->addReturnTo($returnToTitle, $returnToQuery, null, $options);
}
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:42,代码来源:LoginHelper.php
示例15: applyDefaultParameters
/**
* @param array $params
* @param Config $mainConfig
* @return array
*/
public static function applyDefaultParameters(array $params, Config $mainConfig)
{
$logger = LoggerFactory::getInstance('Mime');
$params += ['typeFile' => $mainConfig->get('MimeTypeFile'), 'infoFile' => $mainConfig->get('MimeInfoFile'), 'xmlTypes' => $mainConfig->get('XMLMimeTypes'), 'guessCallback' => function ($mimeAnalyzer, &$head, &$tail, $file, &$mime) use($logger) {
// Also test DjVu
$deja = new DjVuImage($file);
if ($deja->isValid()) {
$logger->info(__METHOD__ . ": detected {$file} as image/vnd.djvu\n");
$mime = 'image/vnd.djvu';
return;
}
// Some strings by reference for performance - assuming well-behaved hooks
Hooks::run('MimeMagicGuessFromContent', [$mimeAnalyzer, &$head, &$tail, $file, &$mime]);
}, 'extCallback' => function ($mimeAnalyzer, $ext, &$mime) {
// Media handling extensions can improve the MIME detected
Hooks::run('MimeMagicImproveFromExtension', [$mimeAnalyzer, $ext, &$mime]);
}, 'initCallback' => function ($mimeAnalyzer) {
// Allow media handling extensions adding MIME-types and MIME-info
Hooks::run('MimeMagicInit', [$mimeAnalyzer]);
}, 'logger' => $logger];
if ($params['infoFile'] === 'includes/mime.info') {
$params['infoFile'] = __DIR__ . "/libs/mime/mime.info";
}
if ($params['typeFile'] === 'includes/mime.types') {
$params['typeFile'] = __DIR__ . "/libs/mime/mime.types";
}
$detectorCmd = $mainConfig->get('MimeDetectorCommand');
if ($detectorCmd) {
$params['detectCallback'] = function ($file) use($detectorCmd) {
return wfShellExec("{$detectorCmd} " . wfEscapeShellArg($file));
};
}
return $params;
}
开发者ID:paladox,项目名称:mediawiki,代码行数:39,代码来源:MimeMagic.php
示例16: execute
public function execute()
{
if (!class_exists('CentralAuthUser')) {
$this->error("CentralAuth isn't enabled on this wiki\n", 1);
}
$username = $this->getArg(0);
$user = User::newFromName($username);
if ($user === false) {
$this->error("'{$username}' is an invalid username\n", 1);
}
// Normalize username
$username = $user->getName();
if ($user->getId()) {
$this->error("User '{$username}' already exists\n", 1);
} else {
global $wgAuth;
$central = CentralAuthUser::getInstance($user);
if (!$central->exists()) {
$this->error("No such global user: '{$username}'\n", 1);
}
$user->loadDefaults($username);
$user->addToDatabase();
$wgAuth->initUser($user, true);
$wgAuth->updateUser($user);
# Notify hooks (e.g. Newuserlog)
Hooks::run('AuthPluginAutoCreate', array($user));
# Update user count
$ssUpdate = new SiteStatsUpdate(0, 0, 0, 0, 1);
$ssUpdate->doUpdate();
$this->output("User '{$username}' created\n");
}
}
开发者ID:NDKilla,项目名称:mediawiki-extensions-CentralAuth,代码行数:32,代码来源:createLocalAccount.php
示例17: recentChangesLine
/**
* Format a line using the old system (aka without any javascript).
*
* @param RecentChange $rc Passed by reference
* @param bool $watched (default false)
* @param int $linenumber (default null)
*
* @return string|bool
*/
public function recentChangesLine(&$rc, $watched = false, $linenumber = null)
{
$classes = array();
// use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
if ($linenumber) {
if ($linenumber & 1) {
$classes[] = 'mw-line-odd';
} else {
$classes[] = 'mw-line-even';
}
}
// Indicate watched status on the line to allow for more
// comprehensive styling.
$classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
$html = $this->formatChangeLine($rc, $classes, $watched);
if ($this->watchlist) {
$classes[] = Sanitizer::escapeClass('watchlist-' . $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title']);
}
if (!Hooks::run('OldChangesListRecentChangesLine', array(&$this, &$html, $rc, &$classes))) {
return false;
}
$dateheader = '';
// $html now contains only <li>...</li>, for hooks' convenience.
$this->insertDateHeader($dateheader, $rc->mAttribs['rc_timestamp']);
return "{$dateheader}<li class=\"" . implode(' ', $classes) . "\">" . $html . "</li>\n";
}
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:35,代码来源:OldChangesList.php
示例18: load
/**
* Converts an XML url or string to a PHP array format
*
* @static
* @access public
* @param string $data Either an url to an xml file, or a raw XML string. Peachy will autodetect which is which.
* @return array Parsed XML
* @throws BadEntryError
* @throws DependencyError
* @throws HookError
* @throws XMLError
*/
public static function load($data)
{
$http = HTTP::getDefaultInstance();
if (!function_exists('simplexml_load_string')) {
throw new DependencyError("SimpleXML", "http://us.php.net/manual/en/book.simplexml.php");
}
libxml_use_internal_errors(true);
if (in_string("<?xml", $data)) {
$xmlout = $data;
} else {
$xmlout = $http->get($data);
}
Hooks::runHook('PreSimpleXMLLoad', array(&$xmlout));
$xml = simplexml_load_string($xmlout);
Hooks::runHook('PostSimpleXMLLoad', array(&$xml));
if (!$xml) {
foreach (libxml_get_errors() as $error) {
throw new XMLError($error);
}
}
$outArr = array();
$namespaces = $xml->getNamespaces(true);
$namespaces['default'] = '';
self::recurse($xml, $outArr, $namespaces);
libxml_clear_errors();
return $outArr;
}
开发者ID:emijrp,项目名称:Peachy,代码行数:39,代码来源:XMLParse.php
示例19: execute
public function execute()
{
if (!$this->getUser()->isLoggedIn()) {
$this->dieUsage('Must be logged in to remove authentication data', 'notloggedin');
}
$params = $this->extractRequestParams();
$manager = AuthManager::singleton();
// Check security-sensitive operation status
ApiAuthManagerHelper::newForModule($this)->securitySensitiveOperation($this->operation);
// Fetch the request. No need to load from the request, so don't use
// ApiAuthManagerHelper's method.
$blacklist = $this->authAction === AuthManager::ACTION_REMOVE ? array_flip($this->getConfig()->get('RemoveCredentialsBlacklist')) : [];
$reqs = array_filter($manager->getAuthenticationRequests($this->authAction, $this->getUser()), function ($req) use($params, $blacklist) {
return $req->getUniqueId() === $params['request'] && !isset($blacklist[get_class($req)]);
});
if (count($reqs) !== 1) {
$this->dieUsage('Failed to create change request', 'badrequest');
}
$req = reset($reqs);
// Perform the removal
$status = $manager->allowsAuthenticationDataChange($req, true);
Hooks::run('ChangeAuthenticationDataAudit', [$req, $status]);
if (!$status->isGood()) {
$this->dieStatus($status);
}
$manager->changeAuthenticationData($req);
$this->getResult()->addValue(null, $this->getModuleName(), ['status' => 'success']);
}
开发者ID:paladox,项目名称:mediawiki,代码行数:28,代码来源:ApiRemoveAuthenticationData.php
示例20: finalSetup
public function finalSetup()
{
parent::finalSetup();
global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgMainWANCache;
global $wgLanguageConverterCacheType, $wgUseDatabaseMessages;
global $wgLocaltimezone, $wgLocalisationCacheConf;
global $wgDevelopmentWarnings;
// Inject test autoloader
require_once __DIR__ . '/../TestsAutoLoader.php';
// wfWarn should cause tests to fail
$wgDevelopmentWarnings = true;
// Make sure all caches and stashes are either disabled or use
// in-process cache only to prevent tests from using any preconfigured
// cache meant for the local wiki from outside the test run.
// See also MediaWikiTestCase::run() which mocks CACHE_DB and APC.
// Disabled in DefaultSettings, override local settings
$wgMainWANCache = $wgMainCacheType = CACHE_NONE;
// Uses CACHE_ANYTHING in DefaultSettings, use hash instead of db
$wgMessageCacheType = $wgParserCacheType = $wgSessionCacheType = $wgLanguageConverterCacheType = 'hash';
// Uses db-replicated in DefaultSettings
$wgMainStash = 'hash';
$wgUseDatabaseMessages = false;
# Set for future resets
// Assume UTC for testing purposes
$wgLocaltimezone = 'UTC';
$wgLocalisationCacheConf['storeClass'] = 'LCStoreNull';
// Bug 44192 Do not attempt to send a real e-mail
Hooks::clear('AlternateUserMailer');
Hooks::register('AlternateUserMailer', function () {
return false;
});
// xdebug's default of 100 is too low for MediaWiki
ini_set('xdebug.max_nesting_level', 1000);
}
开发者ID:ngertrudiz,项目名称:mediawiki,代码行数:34,代码来源:phpunit.php
注:本文中的Hooks类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论