当前位置: 首页>>代码示例>>PHP>>正文


PHP Wiki::apiQuery方法代码示例

本文整理汇总了PHP中Wiki::apiQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Wiki::apiQuery方法的具体用法?PHP Wiki::apiQuery怎么用?PHP Wiki::apiQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Wiki的用法示例。


在下文中一共展示了Wiki::apiQuery方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load

 /**
  * Loads list of all SiteMatrix wikis
  *
  * @static
  * @access public
  * @param  Wiki &$wikiClass The Wiki class object
  * @return array List of all wikis
  * @throws AssertFailure
  * @throws DependencyError
  * @throws LoggedOut
  * @throws MWAPIError
  */
 public static function load(Wiki &$wikiClass)
 {
     if (!array_key_exists('SiteMatrix', $wikiClass->get_extensions())) {
         throw new DependencyError("SiteMatrix");
     }
     $SMres = $wikiClass->apiQuery(array('action' => 'sitematrix'));
     $wikis = $SMres['sitematrix'];
     //return $wikis;
     $retarray = array('raw' => $wikis, 'urls' => array(), 'langs' => array(), 'names' => array(), 'privates' => array());
     foreach ($wikis as $site) {
         if (is_array($site)) {
             if (isset($site['site'])) {
                 $retarray['langs'][] = $site['code'];
                 $retarray['names'][$site['code']] = $site['name'];
                 foreach ($site['site'] as $site2) {
                     $retarray['urls'][] = $site2['url'];
                     if (isset($site2['private'])) {
                         $retarray['privates'][] = $site2;
                     }
                 }
             } else {
                 foreach ($site as $site2) {
                     $sites2['urls'][] = $site2['url'];
                     if (isset($site2['private'])) {
                         $retarray['privates'][] = $site2;
                     }
                 }
             }
         }
     }
     return $retarray;
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:44,代码来源:SiteMatrix.php

示例2: userrights

 public function userrights($add = array(), $remove = array(), $reason = '')
 {
     global $pgNotag, $pgTag;
     $tokens = $this->wiki->get_tokens();
     if (!$pgNotag) {
         $reason .= $pgTag;
     }
     $apiArr = array('action' => 'userrights', 'user' => $this->username, 'token' => $tokens['userrights'], 'add' => implode('|', $add), 'remove' => implode('|', $remove), 'reason' => $reason);
     Hooks::runHook('StartUserrights', array(&$apiArr));
     pecho("Assigning user rights to {$this->username}...\n\n", PECHO_NOTICE);
     try {
         $this->preEditChecks("Rights");
     } catch (EditError $e) {
         pecho("Error: {$e}\n\n", PECHO_FATAL);
         return false;
     }
     $result = $this->wiki->apiQuery($apiArr, true);
     if (isset($result['userrights'])) {
         if (isset($result['userrights']['user'])) {
             $this->__construct($this->wiki, $this->username);
             return true;
         } else {
             pecho("Userrights error...\n\n" . print_r($result['userrights'], true) . "\n\n", PECHO_FATAL);
             return false;
         }
     } else {
         pecho("Userrights error...\n\n" . print_r($result, true), PECHO_FATAL);
         return false;
     }
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:30,代码来源:User.php

示例3: DependencyError

 /**
  * Construction method for the GlobalUserInfo class
  *
  * @access public
  * @param Wiki &$wikiClass The Wiki class object
  * @param mixed $pgUsername Username
  * @throws APIError
  * @throws AssertFailure
  * @throws DependencyError
  * @throws LoggedOut
  * @throws MWAPIError
  */
 function __construct(Wiki &$wikiClass, $pgUsername)
 {
     if (!array_key_exists('Central Auth', $wikiClass->get_extensions())) {
         throw new DependencyError("CentralAuth", "http://www.mediawiki.org/wiki/Extension:CentralAuth");
     }
     $this->username = ucfirst($pgUsername);
     $this->wiki = $wikiClass;
     $guiRes = $this->wiki->apiQuery(array('action' => 'query', 'meta' => 'globaluserinfo', 'guiuser' => ucfirst($pgUsername), 'guiprop' => 'groups|merged|unattached'), false, false);
     if (!isset($guiRes['query']['globaluserinfo'])) {
         $this->exists = false;
         if (isset($guiRes['error']) && $guiRes['error']['code'] != 'guinosuchuser') {
             throw new MWAPIError($guiRes['error']);
         } elseif (@$guiRes['error']['code'] != 'guinosuchuser') {
             throw new MWAPIError(array('code' => 'UnknownError', 'info' => 'Unknown API Error'));
         }
     } else {
         $this->groups = $guiRes['query']['globaluserinfo']['groups'];
         $this->merged = $guiRes['query']['globaluserinfo']['merged'];
         $this->merged = $guiRes['query']['globaluserinfo']['unattached'];
         $this->id = $guiRes['query']['globaluserinfo']['id'];
         $this->registration = $guiRes['query']['globaluserinfo']['registration'];
     }
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:35,代码来源:GlobalUserInfo.php

示例4: delete

 /**
  * Delete a page title from the rped_page table
  *
  * @static
  * @access public
  * @param string $page
  * @return void
  */
 public function delete($page)
 {
     $this->wiki->apiQuery(array('action' => 'rped', 'delete' => $page), true);
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:12,代码来源:RPED.php

示例5: api_upload

 /**
  * Upload an image to the wiki using api.php
  *
  * @access public
  * @param mixed $file Absolute path to the image, a URL, or an array containing file chunks for a chunk upload.
  * @param string $text Text on the image file page (default: '')
  * @param string $comment Comment for inthe upload in logs (default: '')
  * @param bool $watch Should the upload be added to the watchlist (default: false)
  * @param bool $ignorewarnings Ignore warnings about the upload (default: true)
  * @param bool $async Make potentially large file operations asynchronous when possible.  Default false.
  * @param string $filekey Key that identifies a previous upload that was stashed temporarily. Default null.
  * @notice This feature is not yet fully developed.  Manual stashing is not allowed at this time.  This will be corrected during the final release of Peachy 2.
  * @return bool
  */
 public function api_upload($file, $text = '', $comment = '', $watch = null, $ignorewarnings = true, $async = false, $filekey = null)
 {
     $tokens = $this->wiki->get_tokens();
     $apiArr = array('action' => 'upload', 'filename' => $this->rawtitle, 'comment' => $comment, 'text' => $text, 'token' => $tokens['edit'], 'ignorewarnings' => intval($ignorewarnings));
     if (!is_null($filekey)) {
         $apiArr['filekey'] = $filekey;
     }
     if (!is_null($watch)) {
         if ($watch) {
             $apiArr['watchlist'] = 'watch';
         } elseif (!$watch) {
             $apiArr['watchlist'] = 'nochange';
         } elseif (in_array($watch, array('watch', 'unwatch', 'preferences', 'nochange'))) {
             $apiArr['watchlist'] = $watch;
         } else {
             pecho("Watch parameter set incorrectly.  Omitting...\n\n", PECHO_WARN);
         }
     }
     if (!is_array($file)) {
         if (is_file($file)) {
             if ($async) {
                 $apiArr['async'] = 'yes';
             }
             $localfile = $file;
             $apiArr['file'] = "@{$localfile}";
         } else {
             $apiArr['url'] = $file;
             if ($async) {
                 $apiArr['asyncdownload'] = 'yes';
                 $apiArr['leavemessage'] = 'yes';
             }
         }
     } else {
         $apiArr['stash'] = 'yes';
         $apiArr['offset'] = 0;
         $apiArr['filesize'] = 0;
         foreach ($file as $chunk) {
             $apiArr['filesize'] = $apiArr['filesize'] + filesize($chunk);
         }
         foreach ($file as $chunk) {
             $apiArr['chunk'] = "@{$chunk}";
             pecho("Uploading {$chunk}\n\n", PECHO_NOTICE);
             $result = $this->wiki->apiQuery($apiArr, true);
             if (isset($result['upload']['result']) && $result['upload']['result'] == "Continue") {
                 $apiArr['filekey'] = $result['upload']['filekey'];
                 $apiArr['offset'] = $result['upload']['offset'];
             } elseif (isset($result['upload']['result']) && $result['upload']['result'] == "Success") {
                 $apiArr['filekey'] = $result['upload']['filekey'];
                 unset($apiArr['offset']);
                 unset($apiArr['chunk']);
                 unset($apiArr['stash']);
                 unset($apiArr['filesize']);
                 pecho("Chunks uploaded successfully!\n\n", PECHO_NORMAL);
                 break;
             } else {
                 pecho("Upload error...\n\n" . print_r($result, true) . "\n\n", PECHO_FATAL);
                 return false;
             }
         }
     }
     Hooks::runHook('APIUpload', array(&$apiArr));
     $result = $this->wiki->apiQuery($apiArr, true);
     if (isset($result['upload'])) {
         if (isset($result['upload']['result']) && $result['upload']['result'] == "Success") {
             $this->__construct($this->wiki, $this->title);
             return true;
         } else {
             pecho("Upload error...\n\n" . print_r($result['upload'], true) . "\n\n", PECHO_FATAL);
             return false;
         }
     } else {
         pecho("Upload error...\n\n" . print_r($result, true), PECHO_FATAL);
         return false;
     }
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:89,代码来源:Image.php

示例6: rollback

 public function rollback($force = false, $summary = null, $markbot = false, $watch = null)
 {
     global $pgNotag, $pgTag;
     if (!in_array('rollback', $this->wiki->get_userrights())) {
         pecho("User is not allowed to rollback edits", PECHO_FATAL);
         return false;
     }
     if (!$force) {
         try {
             $this->preEditChecks();
         } catch (EditError $e) {
             pecho("Error: {$e}\n\n", PECHO_FATAL);
             return false;
         }
     }
     $history = $this->history(1, 'older', false, null, true);
     $params = array('action' => 'rollback', 'title' => $this->title, 'user' => $history[0]['user'], 'token' => $history[0]['rollbacktoken']);
     if (!is_null($summary)) {
         if (mb_strlen($summary, '8bit') > 255) {
             pecho("Summary is over 255 bytes, the maximum allowed.\n\n", PECHO_FATAL);
             return false;
         }
         if (!$pgNotag) {
             $summary .= $pgTag;
         }
         $params['summary'] = $summary;
     }
     if ($markbot) {
         $params['markbot'] = 'yes';
     }
     if (!is_null($watch)) {
         if ($watch) {
             $params['watchlist'] = 'watch';
         } elseif (!$watch) {
             $params['watchlist'] = 'nochange';
         } elseif (in_array($watch, array('watch', 'unwatch', 'preferences', 'nochange'))) {
             $params['watchlist'] = $watch;
         } else {
             pecho("Watch parameter set incorrectly.  Omitting...\n\n", PECHO_WARN);
         }
     }
     try {
         $this->preEditChecks("Rollback");
     } catch (EditError $e) {
         pecho("Error: {$e}\n\n", PECHO_FATAL);
         return false;
     }
     Hooks::runHook('PreRollback', array(&$params));
     pecho("Rolling back {$this->title}...\n\n", PECHO_NOTICE);
     $result = $this->wiki->apiQuery($params, true);
     if (isset($result['rollback'])) {
         if (isset($result['rollback']['title'])) {
             $this->__construct($this->wiki, $this->title);
             return true;
         } else {
             pecho("Rollback error...\n\n" . print_r($result['rollback'], true) . "\n\n", PECHO_FATAL);
             return false;
         }
     } else {
         pecho("Rollback error...\n\n" . print_r($result, true), PECHO_FATAL);
         return false;
     }
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:63,代码来源:Page.php


注:本文中的Wiki::apiQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。