Difference between revisions of "Copy.php"
m |
m |
||
Line 25: | Line 25: | ||
: array_push($list,$wgContLang->getNsText($ns|1)); | : array_push($list,$wgContLang->getNsText($ns|1)); | ||
foreach ($list as $title) { | foreach ($list as $title) { | ||
− | if ($nt->getArticleID()) xwMessage("Could not copy to \"$ | + | if ($nt->getArticleID()) xwMessage("Could not copy to \"$title\", already exists!", 'red'); |
else { | else { | ||
if ($action == 'copy') { | if ($action == 'copy') { | ||
xwMessage('making copy'); | xwMessage('making copy'); | ||
if ($summary) $summary = " : $summary"; | if ($summary) $summary = " : $summary"; | ||
− | #$a = new Article($ | + | #$a = new Article(Title::newFromText($title)); |
#$a->insertNewArticle($article, "[[talk:copy.php|Copied]] from [[$title]]$summary", false, false); | #$a->insertNewArticle($article, "[[talk:copy.php|Copied]] from [[$title]]$summary", false, false); | ||
} | } |
Revision as of 02:53, 25 October 2006
<?
- Get copy-target and summary-text from form
xwGetProperty($properties, 'copy/target', $target); xwGetProperty($properties, 'copy/summary', $summary); xwGetProperty($properties, 'copy/xml', $xml); # move/copy properties too? xwGetProperty($properties, 'copy/talk', $talk); # move/copy talk too? xwGetProperty($properties, 'copy/action', $action);
if ($target) { # Perform the operation if target defined
global $wgContLang; $target = ucfirst(str_replace(' ', '_', $target)); $ot = Title::newFromText($title); $nt = Title::newFromText($target);
$ns = $ot->getNamespace();
$list = array($title); if ($xml) ereg('^Xml:',$title) ? xwMessage('Properties not copied, article is already a properties article!','red') : array_push($list,"Xml:$title"); if ($talk) $ns & 1 ? xwMessage('Talk page not copied, article is already a talk page!','red') : array_push($list,$wgContLang->getNsText($ns|1)); foreach ($list as $title) { if ($nt->getArticleID()) xwMessage("Could not copy to \"$title\", already exists!", 'red'); else { if ($action == 'copy') { xwMessage('making copy'); if ($summary) $summary = " : $summary"; #$a = new Article(Title::newFromText($title)); #$a->insertNewArticle($article, "Copied from $title$summary", false, false); } else { xwMessage('todo: call $ot->moveTo($nt)'); if ($action == 'rename') { xwMessage('todo: remove redirect'); } } } } } else { # Define the form
$form = "
Rename/copy article:
<form action=\"/wiki/index.php\">
<input type=hidden name=title value=\"$title\"> <input type=hidden name=\"xpath:/properties:data\" value=\"$tTitle\"> <input type=hidden name=\"xpath:/properties:copy\">
New title: | <input type=text name=\"xpath:/properties/copy:target\"> |
Reason: | <input type=text name=\"xpath:/properties/copy:summary\"> |
Action: | <input type=radio name=\"xpath:/properties/copy:action\" value=rename checked>Rename
<input type=radio name=\"xpath:/properties/copy:action\" value=redir>Redirect <input type=radio name=\"xpath:/properties/copy:action\" value=copy>Copy |
<input type=checkbox checked=checked value=1 name=\"xpath:/properties/copy:xml\">
Also apply to properties | |
<input type=checkbox checked=checked value=1 name=\"xpath:/properties/copy:talk\">
Also apply to discussion | |
<input type=submit value=\" Commit \"> | |
Help Rename |
</form>";
# Replace article content with form $article = preg_replace('/(?<=).+(?=)/s',$form,$article); }
?>