Difference between revisions of "Copy.php"

From Organic Design wiki
m
(add help to the form)
Line 2: Line 2:
  
 
# Get copy-target and summary-text from form
 
# Get copy-target and summary-text from form
xwGetProperty( $properties, 'copy/target', $target );
+
xwGetProperty($properties, 'copy/target', $target);
xwGetProperty( $properties, 'copy/summary', $summary );
+
xwGetProperty($properties, 'copy/summary', $summary);
xwGetProperty( $properties, 'copy/xml', $xml );
+
xwGetProperty($properties, 'copy/xml', $xml); # move/copy properties too?
xwGetProperty( $properties, 'copy/talk', $talk );
+
xwGetProperty($properties, 'copy/talk', $talk); # move/copy talk too?
xwGetProperty( $properties, 'copy/action', $action);
+
xwGetProperty($properties, 'copy/action', $action);
xwGetProperty( $properties, 'copy/redir', $redir );
 
  
 
if ( $target ) {
 
if ( $target ) {
 
# Do the copy if target defined
 
# Do the copy if target defined
if ( $summary ) $summary = ": $summary";
+
if ($summary) $summary = " : $summary";
$target = ucfirst( eregi_replace( '[^a-z0-9_]+', '_', $target ) );
+
$target = ucfirst(eregi_replace( '[^a-z0-9_]+', '_', $target));
$a = new Article( $t = Title::newFromText( $target ) );
+
$a = new Article($t = Title::newFromText($target));
if ( $t->getArticleID() ) xwMessage( "Copy failed! \"$target\" already exists!", 'red' );
+
if ($t->getArticleID()) xwMessage("Copy failed! \"$target\" already exists!", 'red');
else $a->insertNewArticle( $article, "Copied from [[$title]]$summary", false, false );
+
else $a->insertNewArticle($article, "[[copy.php|Copied]] from [[$title]]$summary", false, false);
 
}
 
}
 
else {
 
else {
 
# Define the form
 
# Define the form
$form = "<h3>Move/copy article:</h3><form action=\"/wiki/index.php\">
+
$form = "<h3>Rename/copy article:</h3><form action=\"/wiki/index.php\">
 
<input type=hidden name=title value=\"$title\">
 
<input type=hidden name=title value=\"$title\">
 
<input type=hidden name=\"xpath:/properties:data\" value=\"$tTitle\">
 
<input type=hidden name=\"xpath:/properties:data\" value=\"$tTitle\">
Line 27: Line 26:
 
<tr><td align=right>Reason:<td><input type=text name=\"xpath:/properties/copy:summary\">
 
<tr><td align=right>Reason:<td><input type=text name=\"xpath:/properties/copy:summary\">
 
<tr><td align=right>Action:
 
<tr><td align=right>Action:
<td><input type=radio name=\"xpath:/properties/copy:action\" value=move checked>Move
+
<td><input type=radio name=\"xpath:/properties/copy:action\" value=rename checked>Rename
&nbsp;&nbsp;<input type=radio name=\"xpath:/properties/copy:action\" value=alias>Alias
+
&nbsp;&nbsp;<input type=radio name=\"xpath:/properties/copy:action\" value=redir>Redirect
 
&nbsp;&nbsp;<input type=radio name=\"xpath:/properties/copy:action\" value=copy>Copy
 
&nbsp;&nbsp;<input type=radio name=\"xpath:/properties/copy:action\" value=copy>Copy
 
<tr><td><td><input type=checkbox checked=checked value=1 name=\"xpath:/properties/copy:xml\">
 
<tr><td><td><input type=checkbox checked=checked value=1 name=\"xpath:/properties/copy:xml\">
Also move/copy properties
+
Also apply to properties
 
<tr><td><td><input type=checkbox checked=checked value=1 name=\"xpath:/properties/copy:talk\">
 
<tr><td><td><input type=checkbox checked=checked value=1 name=\"xpath:/properties/copy:talk\">
Also move discussion
+
Also apply to discussion
 
<tr><td><td><input type=submit value=\"  Commit  \">
 
<tr><td><td><input type=submit value=\"  Commit  \">
<tr><td colspan=2><br><br><i>Note, \"alias\" is the default MediaWiki action, but we use \"move\"<br>(Also note, that this isn't working yet! :-)</i>
+
<tr><td colspan=2><br><br><i>Note, \"redirect\" is the default MediaWiki action, but we use \"rename\"<br>
 +
(Also note, that this isn't working yet! :-)</i><br><br>
 +
<h3>Help</h3>
 +
<p><b>Rename:</b> Changes the title of the article applying to current content and all the history.
 +
The original title becomes unused and all links to that title will become red creation links.</p>
 +
<p><b>Redirect:</b> Changes the title of the article applying to current content and all the history.
 +
Any links referring to the original title are automatically redirected to the new title (unless ''redir=no'' is included in the query-string).</p>
 +
<p><b>Copy:</b> Creates a new article with the same content as the original, but exhibiting no history. The original title is left unaffected by this operation.</p>
 
</table></form>";
 
</table></form>";
  

Revision as of 02:01, 25 October 2006

<?

  1. 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 ) { # Do the copy if target defined if ($summary) $summary = " : $summary"; $target = ucfirst(eregi_replace( '[^a-z0-9_]+', '_', $target)); $a = new Article($t = Title::newFromText($target)); if ($t->getArticleID()) xwMessage("Copy failed! \"$target\" already exists!", 'red'); else $a->insertNewArticle($article, "Copied from $title$summary", false, false); } 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 \">


Note, \"redirect\" is the default MediaWiki action, but we use \"rename\"

(Also note, that this isn't working yet! :-)

Help

Rename: Changes the title of the article applying to current content and all the history. The original title becomes unused and all links to that title will become red creation links.

Redirect: Changes the title of the article applying to current content and all the history. Any links referring to the original title are automatically redirected to the new title (unless redir=no is included in the query-string).

Copy: Creates a new article with the same content as the original, but exhibiting no history. The original title is left unaffected by this operation.

</form>";

# Replace article content with form $article = preg_replace('/(?<=).+(?=)/s',$form,$article); }

?>