本文整理汇总了PHP中Article::doDelete方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::doDelete方法的具体用法?PHP Article::doDelete怎么用?PHP Article::doDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::doDelete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onPowerDelete
/**
* @static
* @param string $action
* @param Article $article
* @return bool
* @throws UserBlockedError
* @throws PermissionsError
*/
static function onPowerDelete($action, $article)
{
global $wgOut, $wgUser, $wgRequest;
if ($action !== 'powerdelete') {
return true;
}
if (!$wgUser->isAllowed('delete') || !$wgUser->isAllowed('powerdelete')) {
throw new PermissionsError('powerdelete');
}
if ($wgUser->isBlocked()) {
throw new UserBlockedError($wgUser->mBlock);
}
if (wfReadOnly()) {
$wgOut->readOnlyPage();
return false;
}
$reason = $wgRequest->getText('reason');
$title = $article->getTitle();
$file = $title->getNamespace() == NS_IMAGE ? wfLocalFile($title) : false;
if ($file) {
$oldimage = null;
FileDeleteForm::doDelete($title, $file, $oldimage, $reason, false);
} else {
$article->doDelete($reason);
}
// this is stupid, but otherwise, WikiPage::doUpdateRestrictions complains about passing by reference
$false = false;
$article->doUpdateRestrictions(array('create' => 'sysop'), array('create' => 'infinity'), $false, $reason, $wgUser);
return false;
}
示例2: deleteTalkPage
/**
*
* @param $article - object with the following fields (page_id and page_title)
* @param $reason - reason for the deletion
*/
function deleteTalkPage($article, $reason)
{
$title = Title::newFromID($article->page_id);
if ($title) {
$article = new Article($title);
if ($article) {
echo $title->getFullURL() . "\n";
$article->doDelete($reason);
}
}
}
示例3: doDelete
function doDelete($pages, $reason)
{
foreach ($pages as $page) {
if ($title = Title::newFromText($page)) {
$article = new Article($title);
$article->doDelete($reason);
} else {
die("Bad title: \"{$page}\"");
}
}
}
示例4: inheritTopic
/**
* Have an existing Topic "inherit" a new version by applying a category
* version tag to it.
*
* @param $topicTitle string The internal mediawiki title of the article.
* @param $version PonyDocsVersion The target Version
* @param $tocSection The TOC section this title resides in.
* @param $tocTitle The toc title that references this topic.
* @param $deleteExisting boolean Should we purge any existing conflicts?
* @returns boolean
*/
static function inheritTopic($topicTitle, $version, $tocSection, $tocTitle, $deleteExisting)
{
global $wgTitle;
// Clear any hooks so no weirdness gets called after we save the inherit
$wgHooks['ArticleSave'] = array();
if (!preg_match('/^' . PONYDOCS_DOCUMENTATION_NAMESPACE_NAME . ':([^:]*):([^:]*):(.*):([^:]*)$/', $topicTitle, $match)) {
throw new Exception("Invalid Title to Inherit From: " . $topicTitle);
}
$productName = $match[1];
$manual = $match[2];
$title = $match[3];
// Get PonyDocsProduct
$product = PonyDocsProduct::GetProductByShortName($productName);
// Get conflicts.
$conflicts = self::getConflicts($product, $topicTitle, $version);
if (!empty($conflicts)) {
if (!$deleteExisting) {
throw new Exception("When calling inheritTitle, there were conflicts and deleteExisting was false.");
}
// We want to purge each conflicting title completely.
foreach ($conflicts as $conflict) {
$article = new Article(Title::newFromText($conflict));
if (!$article->exists()) {
// No big deal. A conflict no longer exists? Continue.
continue;
}
if ($conflict == $topicTitle) {
// Conflict was same as source material. Do nothing with it.
continue;
} else {
$article->doDelete("Requested purge of conficting article when inheriting topic " . $topicTitle . " with version: " . $version->getVersionName(), false);
}
}
}
$title = Title::newFromText($topicTitle);
$wgTitle = $title;
$existingArticle = new Article($title);
if (!$existingArticle->exists()) {
// No such title exists in the system
throw new Exception("Invalid Title to Inherit From: " . $topicTitle);
}
// Okay, source article exists.
// Add the appropriate version cateogry.
// Check for existing category.
$content = $existingArticle->getContent();
if (!preg_match("/\\[\\[Category:V:" . preg_quote($productName . ":" . $version->getVersionName()) . "\\]\\]/", $content)) {
$content .= "[[Category:V:" . $productName . ":" . $version->getVersionName() . "]]";
// Save the article as an edit
$existingArticle->doEdit($content, "Inherited topic " . $topicTitle . " with version: " . $productName . ":" . $version->getVersionName(), EDIT_UPDATE);
}
return $title;
}
示例5: wfGetDB
}
$dbw =& wfGetDB(DB_MASTER);
for ($linenum = 1; !feof($file); $linenum++) {
$line = trim(fgets($file));
if ($line === false) {
break;
}
$page = Title::newFromText($line);
if (is_null($page)) {
print "Invalid title '{$line}' on line {$linenum}\n";
continue;
}
if (!$page->exists()) {
print "Skipping nonexistent page '{$line}'\n";
continue;
}
print $page->getPrefixedText();
$dbw->begin();
if ($page->getNamespace() == NS_IMAGE) {
$art = new ImagePage($page);
} else {
$art = new Article($page);
}
$art->doDelete($reason);
$dbw->immediateCommit();
print "\n";
if ($interval) {
sleep($interval);
}
wfWaitForSlaves(5);
}
示例6: doSubmit
function doSubmit()
{
global $wgOut, $wgUser, $wgMaximumMovedPages, $wgLang;
global $wgFixDoubleRedirects;
if ($wgUser->pingLimiter('move')) {
$wgOut->rateLimited();
return;
}
$ot = $this->oldTitle;
$nt = $this->newTitle;
# Delete to make way if requested
if ($wgUser->isAllowed('delete') && $this->deleteAndMove) {
$article = new Article($nt);
# Disallow deletions of big articles
$bigHistory = $article->isBigDeletion();
if ($bigHistory && !$nt->userCan('bigdelete')) {
global $wgDeleteRevisionsLimit;
$this->showForm(array('delete-toobig', $wgLang->formatNum($wgDeleteRevisionsLimit)));
return;
}
// Delete an associated image if there is
$file = wfLocalFile($nt);
if ($file->exists()) {
$file->delete(wfMsgForContent('delete_and_move_reason'), false);
}
// This may output an error message and exit
$article->doDelete(wfMsgForContent('delete_and_move_reason'));
}
# don't allow moving to pages with # in
if (!$nt || $nt->getFragment() != '') {
$this->showForm('badtitletext');
return;
}
# Show a warning if the target file exists on a shared repo
if ($nt->getNamespace() == NS_FILE && !($this->moveOverShared && $wgUser->isAllowed('reupload-shared')) && !RepoGroup::singleton()->getLocalRepo()->findFile($nt) && wfFindFile($nt)) {
$this->showForm(array('file-exists-sharedrepo'));
return;
}
if ($wgUser->isAllowed('suppressredirect')) {
$createRedirect = $this->leaveRedirect;
} else {
$createRedirect = true;
}
# Do the actual move.
$error = $ot->moveTo($nt, true, $this->reason, $createRedirect);
if ($error !== true) {
# @todo FIXME: Show all the errors in a list, not just the first one
$this->showForm(reset($error));
return;
}
if ($wgFixDoubleRedirects && $this->fixRedirects) {
DoubleRedirectJob::fixRedirects('move', $ot, $nt);
}
wfRunHooks('SpecialMovepageAfterMove', array(&$this, &$ot, &$nt));
$wgOut->setPagetitle(wfMsg('pagemovedsub'));
$oldUrl = $ot->getFullUrl('redirect=no');
$newUrl = $nt->getFullUrl();
$oldText = $ot->getPrefixedText();
$newText = $nt->getPrefixedText();
$oldLink = "<span class='plainlinks'>[{$oldUrl} {$oldText}]</span>";
$newLink = "<span class='plainlinks'>[{$newUrl} {$newText}]</span>";
$msgName = $createRedirect ? 'movepage-moved-redirect' : 'movepage-moved-noredirect';
$wgOut->addWikiMsg('movepage-moved', $oldLink, $newLink, $oldText, $newText);
$wgOut->addWikiMsg($msgName);
# Now we move extra pages we've been asked to move: subpages and talk
# pages. First, if the old page or the new page is a talk page, we
# can't move any talk pages: cancel that.
if ($ot->isTalkPage() || $nt->isTalkPage()) {
$this->moveTalk = false;
}
if (!$ot->userCan('move-subpages')) {
$this->moveSubpages = false;
}
# Next make a list of id's. This might be marginally less efficient
# than a more direct method, but this is not a highly performance-cri-
# tical code path and readable code is more important here.
#
# Note: this query works nicely on MySQL 5, but the optimizer in MySQL
# 4 might get confused. If so, consider rewriting as a UNION.
#
# If the target namespace doesn't allow subpages, moving with subpages
# would mean that you couldn't move them back in one operation, which
# is bad.
# @todo FIXME: A specific error message should be given in this case.
// @todo FIXME: Use Title::moveSubpages() here
$dbr = wfGetDB(DB_MASTER);
if ($this->moveSubpages && (MWNamespace::hasSubpages($nt->getNamespace()) || $this->moveTalk && MWNamespace::hasSubpages($nt->getTalkPage()->getNamespace()))) {
$conds = array('page_title' . $dbr->buildLike($ot->getDBkey() . '/', $dbr->anyString()) . ' OR page_title = ' . $dbr->addQuotes($ot->getDBkey()));
$conds['page_namespace'] = array();
if (MWNamespace::hasSubpages($nt->getNamespace())) {
$conds['page_namespace'][] = $ot->getNamespace();
}
if ($this->moveTalk && MWNamespace::hasSubpages($nt->getTalkPage()->getNamespace())) {
$conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
}
} elseif ($this->moveTalk) {
$conds = array('page_namespace' => $ot->getTalkPage()->getNamespace(), 'page_title' => $ot->getDBkey());
} else {
# Skip the query
$conds = null;
//.........这里部分代码省略.........
示例7: deleteArticleByRule
function deleteArticleByRule($title, $text, $rulesText)
{
global $wgUser, $wgOut;
// return "deletion of articles by DPL is disabled.";
// we use ; as command delimiter; \; stands for a semicolon
// \n is translated to a real linefeed
$rulesText = str_replace(";", '°', $rulesText);
$rulesText = str_replace('\\°', ';', $rulesText);
$rulesText = str_replace("\\n", "\n", $rulesText);
$rules = split('°', $rulesText);
$exec = false;
$message = '';
$reason = '';
foreach ($rules as $rule) {
if (preg_match('/^\\s*#/', $rule) > 0) {
continue;
// # is comment symbol
}
$rule = preg_replace('/^[\\s]*/', '', $rule);
// strip leading white space
$cmd = preg_split("/ +/", $rule, 2);
if (count($cmd) > 1) {
$arg = $cmd[1];
} else {
$arg = '';
}
$cmd[0] = trim($cmd[0]);
if ($cmd[0] == 'reason') {
$reason = $arg;
}
// we execute only if "exec" is given, otherwise we merely show what would be done
if ($cmd[0] == 'exec') {
$exec = true;
}
}
$reason .= "\nbulk delete by DPL query";
$titleX = Title::newFromText($title);
if ($exec) {
# Check permissions
$permission_errors = $titleX->getUserPermissionsErrors('delete', $wgUser);
if (count($permission_errors) > 0) {
$wgOut->showPermissionsErrorPage($permission_errors);
return 'permission error';
} elseif (wfReadOnly()) {
$wgOut->readOnlyPage();
return 'DPL: read only mode';
} else {
$articleX = new Article($titleX);
$articleX->doDelete($reason);
}
} else {
$message .= "set 'exec yes' to delete     <big>'''{$title}'''</big>\n";
}
$message .= '<pre><nowiki>' . "\n" . $text . '</nowiki></pre>';
// <pre><nowiki>\n"; // .$text."\n</nowiki></pre>\n";
return $message;
}
示例8: generate
function generate($take_duration)
{
global $mvgIP;
require_once $mvgIP . '/includes/MV_Index.php';
$s = MV_Stream::newStreamByName($this->name);
if (!$s->db_load_stream()) {
return "An error occured while loading stream info please notify Administrator";
}
$stream_duration = $s->getDuration();
if ($stream_duration === NULL) {
return "Error: Stream Duration not set";
}
$sitting_id = $s->getSittingId();
$editors = $this->getAssignedEditors($sitting_id);
$readers = $this->getAssignedReaders($sitting_id);
$reporters = $this->getAssignedReporters($sitting_id);
$editors_count = count($editors);
$readers_count = count($readers);
$reporters_count = count($reporters);
$html = '';
if ($editors_count == 0) {
$html .= "No Editors Assigned";
return $html;
}
if ($readers_count == 0) {
$html .= "No Readers Assigned";
return $html;
}
if ($reporters_count == 0) {
$html .= "No Reporters Assigned";
return $html;
}
//delete all existing take transcripts
$dbr =& wfGetDB(DB_SLAVE);
$result =& MV_Index::getMVDInRange($s->getStreamId(), 0, $s->getDuration(), $this->mvd_tracks);
while ($row = $dbr->fetchObject($result)) {
$title = Title::newFromText($row->wiki_title, MV_NS_MVD);
$art = new Article($title);
if ($art->exists()) {
$art->doDelete("new takes generated", true);
}
}
$num_editor = 0;
$num_reader = 0;
$num_reporter = 0;
for ($i = 0; $i < $stream_duration; $i = $i + $take_duration) {
$start_time = $i;
$end_time = $i + $take_duration;
$title_text = 'Take_en:' . $this->name . '/' . seconds2ntp($start_time) . '/' . seconds2ntp($end_time);
$title = Title::newFromText($title_text, MV_NS_MVD);
$editor = User::newFromId($editors[$num_editor]);
$editor_name = $editor->getRealName();
$reader = User::newFromId($readers[$num_editor]);
$reader_name = $reader->getRealName();
$reporter = User::newFromId($reporters[$num_editor]);
$reporter_name = $reporter->getRealName();
$article = new Article($title);
$text = '[[Edited By::' . $editor_name . ']], ' . '[[Read By::' . $reader_name . ']], ' . '[[Reported By::' . $reporter_name . ']], ' . '[[Status::Incomplete]]';
$article->doEdit($text, 'Automatically Generated', EDIT_NEW);
if ($num_editor < $editors_count - 1) {
$num_editor++;
} else {
$num_editor = 0;
}
if ($num_reader < $readers_count - 1) {
$num_reader++;
} else {
$num_reader = 0;
}
if ($num_reporter < $reporters_count - 1) {
$num_reporter++;
} else {
$num_reporter = 0;
}
}
$html .= 'Takes Successfully Generated';
return $html;
}
示例9: deletePage
function deletePage($line, $reason, &$db, $multi = false, $linenum = 0, $user = null)
{
global $wgOut, $wgUser;
$page = Title::newFromText($line);
if (is_null($page)) {
/* invalid title? */
$wgOut->addWikiMsg('deletebatch_omitting_invalid', $line);
if (!$multi) {
if (!is_null($user)) {
$wgUser = $user;
}
}
return false;
}
if (!$page->exists()) {
/* no such page? */
$wgOut->addWikiMsg('deletebatch_omitting_nonexistant', $line);
if (!$multi) {
if (!is_null($user)) {
$wgUser = $user;
}
}
return false;
}
$db->begin();
if (NS_MEDIA == $page->getNamespace()) {
$page = Title::makeTitle(NS_IMAGE, $page->getDBkey());
}
/* this stuff goes like Article::newFromTitle() */
if ($page->getNamespace() == NS_IMAGE) {
$art = new ImagePage($page);
} else {
$art = new Article($page);
}
/* what is the generic reason for page deletion?
something about the content, I guess...
*/
$art->doDelete($reason);
$db->immediateCommit();
return true;
}
示例10: Article
function do_remove_mvd($titleKey, $mvd_id)
{
global $wgOut;
$title = Title::newFromText($titleKey, MV_NS_MVD);
$article = new Article($title);
// purge parent article:
MV_MVD::onEdit($this->mvd_pages, $mvd_id);
// run the delete function:
$article->doDelete($_REQUEST['wpReason']);
// check if delete
if ($article->exists()) {
return php2jsObj(array('status' => 'error', 'error_txt' => $wgOut->getHTML()));
} else {
return php2jsObj(array('status' => 'ok'));
}
}
示例11: testDuplicateCreate
function testDuplicateCreate()
{
$this->markTestSkipped('Randomly failing due to master/slave lag');
// FIXME
/** @var $poll WikiaPollAjax */
$poll = WF::build('WikiaPollAjax');
$wgRequest = $this->getMock('WebRequest', array('getVal', 'getArray'));
$wgRequest->expects($this->at(0))->method('getVal')->with($this->equalTo('question'))->will($this->returnValue("Unit Testing"));
$wgRequest->expects($this->any())->method('getArray')->with($this->equalTo('answer'))->will($this->returnValue(array("One", "Two", "Three")));
$wgRequest->expects($this->any())->method('getIP')->will($this->returnValue('127.0.0.1'));
$this->mockGlobalVariable('wgRequest', $wgRequest);
$this->mockApp();
// Create the same poll twice
$result = $poll->create();
$this->assertType("array", $result, "Create duplicate result is array");
$this->assertEquals(false, $result["success"], "Create duplicate Poll success flag is false");
$this->assertType("string", $result["error"], "Create duplicate Poll results in an error");
// clean up
$title = Title::newFromText("Unit Testing", NS_WIKIA_POLL);
$article = new Article($title, NS_WIKIA_POLL);
/* @var $article WikiPage */
if ($article->exists()) {
$article->doDelete("Unit Testing", true);
}
}
示例12: deletePage
static function deletePage($title, $sp = null)
{
$ret = null;
$file = $title->getNamespace() == NS_IMAGE ? wfLocalFile($title) : false;
if ($file) {
$reason = wfMsg("blockandnuke-delete-file");
$oldimage = null;
// Must be passed by reference
$ret = FileDeleteForm::doDelete($title, $file, $oldimage, $reason, false);
} else {
$reason = wfMsg("blockandnuke-delete-article");
if ($title->isKnown()) {
$article = new Article($title);
$ret = $article->doDelete($reason);
if ($ret && $sp) {
$sp->getOutput()->addHTML(wfMessage("blockandnuke-deleted-page", $title));
}
}
}
return $ret;
}
示例13: array
$res = $dbr->select("page_ban", array("pb_namespace", "pb_page"));
$deleted = array();
$wgUser = User::newFromName("EmilyPostBot");
$n = 0;
print "Start :" . wfTimestampNow(TS_MW) . "\n";
$pages = array();
foreach ($res as $row) {
$pages[] = array('name' => $row->pb_page, 'ns' => $row->pb_namespace);
}
foreach ($pages as $page) {
$title = Title::newFromText($page['name'], $page['ns']);
$deletion = false;
if ($title && $title->exists() && $title->getNamespace() != NS_MAIN) {
print 'Deleting article ' . $wgContLang->getNSText($row->pb_namespace) . ':' . $title->getText() . "\n";
$article = new Article($title);
$article->doDelete('Bad page');
$deletion = true;
}
if ($page['ns'] == NS_USER) {
$user = User::newFromName($page['name']);
if ($user && $user->getID() > 0) {
if (ProfileBox::removeUserData($user)) {
print "Removed profilebox for " . $user->getName() . "\n";
$deletion = true;
}
$ra = Avatar::getAvatarRaw($user->getName());
if ($ra['url'] != '') {
if (preg_match("@SUCCESS@", Avatar::removePicture($user->getID()))) {
print "Remove avatar picture for " . $user->getName() . "\n";
$deletion = true;
}
示例14: removeStream
function removeStream($removeMVDs = true)
{
global $mvIndexTableName;
$dbw =& wfGetDB(DB_WRITE);
$dbr =& wfGetDB(DB_SLAVE);
if ($removeMVDs) {
//delete metadata pages:
//@@todo figure out a way to do this quickly/group sql queries.
$res = MV_Index::getMVDInRange($this->getStreamId());
if ($dbr->numRows($res) != 0) {
while ($row = $dbr->fetchObject($res)) {
$title = Title::newFromText($row->wiki_title, MV_NS_MVD);
$article = new Article($title);
$article->doDelete('parent stream removed');
}
}
}
return true;
}
示例15: wfGetDB
<?php
require_once 'commandLine.inc';
$dbr = wfGetDB(DB_SLAVE);
$bad = array();
$wgUser = User::newFromName('Tderouin');
$res = $dbr->select('page', array('page_title', 'page_namespace'), array('page_namespace' => NS_IMAGE));
$count = 0;
while ($row = $dbr->fetchObject($res)) {
$t = Title::makeTitle($row->page_namespace, $row->page_title);
if (preg_match("/[^" . Title::legalChars() . "]|\\?/", $t->getText())) {
#echo "find /var/www/images_en -name '{$t->getText()}' \n";
$img = wfFindFile($t, false);
$oldpath = $img->getPath();
$newtitle = Title::makeTitle(NS_IMAGE, trim(preg_replace("@\\?@", "", $t->getText())));
if (!$newtitle) {
echo "oops! {$row->page_title}\n";
exit;
}
$a = new Article($t);
$a->doDelete("Bad image name");
#echo "{$oldpath}\t{$newpath}\n";
echo "{$t->getText()}\n";
#echo "cp " . wfEscapeShellArg($img->getPath()) . " /tmp/bad \n";
}
$count++;
}