Difference between revisions of "Copy.php"

From Organic Design wiki
m
m
Line 1: Line 1:
 
<?
 
<?
  
# Get article name and content 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 );
  
# If both are set, create/edit the article
 
 
if ( $target ) {
 
if ( $target ) {
 +
# 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 ) );
Line 14: Line 14:
 
}
 
}
 
else {
 
else {
 +
# No target defined, render the copy form
 
$article = "<h3>Copy article:</h3><form action=\"/wiki/index.php\">
 
$article = "<h3>Copy article:</h3><form action=\"/wiki/index.php\">
 
<input type=hidden name=title value=\"$title\">
 
<input type=hidden name=title value=\"$title\">

Revision as of 09:39, 9 March 2006

<?

  1. Get copy-target and summary-text from form

xwGetProperty( $properties, 'copy/target', $target ); xwGetProperty( $properties, 'copy/summary', $summary );

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 { # No target defined, render the copy form

$article = "

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\">
Summary:<input type=text name=\"xpath:/properties/copy:summary\">
<input type=submit value=\" Copy \">

</form>";

}

?>