當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ApiMain::Modules方法代碼示例

本文整理匯總了PHP中ApiMain::Modules方法的典型用法代碼示例。如果您正苦於以下問題:PHP ApiMain::Modules方法的具體用法?PHP ApiMain::Modules怎麽用?PHP ApiMain::Modules使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ApiMain的用法示例。


在下文中一共展示了ApiMain::Modules方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Constructs an instance of ApiMain that utilizes the module and format specified by $request.
  *
  * @param $request object - if this is an instance of FauxRequest, errors are thrown and no printing occurs
  * @param $enableWrite bool should be set to true if the api may modify data
  */
 public function __construct($request, $enableWrite = false)
 {
     $this->mInternalMode = $request instanceof FauxRequest;
     // Special handling for the main module: $parent === $this
     parent::__construct($this, $this->mInternalMode ? 'main_int' : 'main');
     if (!$this->mInternalMode) {
         // Impose module restrictions.
         // If the current user cannot read,
         // Remove all modules other than login
         global $wgUser;
         if (!$wgUser->isAllowed('read')) {
             self::$Modules = array('login' => self::$Modules['login'], 'help' => self::$Modules['help']);
         }
     }
     $this->mModules = self::$Modules;
     $this->mModuleNames = array_keys($this->mModules);
     // todo: optimize
     $this->mFormats = self::$Formats;
     $this->mFormatNames = array_keys($this->mFormats);
     // todo: optimize
     $this->mResult = new ApiResult($this);
     $this->mShowVersions = false;
     $this->mEnableWrite = $enableWrite;
     $this->mRequest =& $request;
     $this->mSquidMaxage = 0;
 }
開發者ID:mediawiki-extensions,項目名稱:bizzwiki,代碼行數:32,代碼來源:ApiMain.php

示例2: __construct

 /**
  * Constructs an instance of ApiMain that utilizes the module and format specified by $request.
  *
  * @param $request object - if this is an instance of FauxRequest, errors are thrown and no printing occurs
  * @param $enableWrite bool should be set to true if the api may modify data
  */
 public function __construct($request, $enableWrite = false)
 {
     $this->mInternalMode = $request instanceof FauxRequest;
     // Special handling for the main module: $parent === $this
     parent::__construct($this, $this->mInternalMode ? 'main_int' : 'main');
     if (!$this->mInternalMode) {
         // Impose module restrictions.
         // If the current user cannot read,
         // Remove all modules other than login
         global $wgUser;
         if ($request->getVal('callback') !== null) {
             // JSON callback allows cross-site reads.
             // For safety, strip user credentials.
             wfDebug("API: stripping user credentials for JSON callback\n");
             $wgUser = new User();
         }
         if (!$wgUser->isAllowed('read')) {
             self::$Modules = array('login' => self::$Modules['login'], 'logout' => self::$Modules['logout'], 'help' => self::$Modules['help']);
         }
     }
     global $wgAPIModules, $wgEnableWriteAPI;
     // extension modules
     $this->mModules = $wgAPIModules + self::$Modules;
     if ($wgEnableWriteAPI) {
         $this->mModules += self::$WriteModules;
     }
     $this->mModuleNames = array_keys($this->mModules);
     // todo: optimize
     $this->mFormats = self::$Formats;
     $this->mFormatNames = array_keys($this->mFormats);
     // todo: optimize
     $this->mResult = new ApiResult($this);
     $this->mShowVersions = false;
     $this->mEnableWrite = $enableWrite;
     $this->mRequest =& $request;
     $this->mSquidMaxage = 0;
 }
開發者ID:BackupTheBerlios,項目名稱:shoutwiki-svn,代碼行數:43,代碼來源:ApiMain.php


注:本文中的ApiMain::Modules方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。