4 * Created on Sep 2, 2008
6 * API for MediaWiki 1.14+
8 * Copyright (C) 2008 Chad Horohoe
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * http://www.gnu.org/copyleft/gpl.html
26 if (!defined('MEDIAWIKI')) {
27 require_once ('ApiBase.php');
31 * API interface for page purging
34 class ApiPurge
extends ApiBase
{
36 public function __construct($main, $action) {
37 parent
:: __construct($main, $action);
41 * Purges the cache of a page
43 public function execute() {
45 $params = $this->extractRequestParams();
46 if(!$wgUser->isAllowed('purge'))
47 $this->dieUsageMsg(array('cantpurge'));
48 if(!isset($params['titles']))
49 $this->dieUsageMsg(array('missingparam', 'titles'));
51 foreach($params['titles'] as $t) {
53 $title = Title
::newFromText($t);
54 if(!$title instanceof Title
)
61 ApiQueryBase
::addTitleInfo($r, $title);
68 $article = new Article($title);
69 $article->doPurge(); // Directly purge and skip the UI part of purge().
73 $this->getResult()->setIndexedTagName($result, 'page');
74 $this->getResult()->addValue(null, $this->getModuleName(), $result);
77 public function getAllowedParams() {
80 ApiBase
:: PARAM_ISMULTI
=> true
85 public function getParamDescription() {
87 'titles' => 'A list of titles',
91 public function getDescription() {
93 'Purge the cache for the given titles.'
97 protected function getExamples() {
99 'api.php?action=purge&titles=Main_Page|API'
103 public function getVersion() {
104 return __CLASS__
. ': $Id$';