Difference between revisions of "Copy.php"

From Organic Design wiki
m
m
Line 9: Line 9:
 
if ( $summary ) $summary = ": $summary";
 
if ( $summary ) $summary = ": $summary";
 
$newTitle = ucfirst( eregi_replace( '[^a-z0-9_]+', '_', $newTitle ) );
 
$newTitle = ucfirst( eregi_replace( '[^a-z0-9_]+', '_', $newTitle ) );
$a = new Article( $t = Title::makeTitleSafe( 0, $newTitle ) );
+
$a = new Article( $t = Title::newFromText( $newTitle ) );
$id = $t->getArticleID();
+
if ( $t->getArticleID() ) xwMessage( "Copy failed! \"$target\" already exists!", 'red' );
if ( $id ) xwMessage( "Could not copy article, target \"$target\" already exists!", 'red' );
 
 
else $a->insertNewArticle( $article, "Copied from [[$title]]$summary", false, false );
 
else $a->insertNewArticle( $article, "Copied from [[$title]]$summary", false, false );
 
xwMessage( 'Article copied successfully', 'green' );
 
xwMessage( 'Article copied successfully', 'green' );

Revision as of 09:10, 9 March 2006

<?

  1. Get article name and content from form

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

  1. If both are set, create/edit the article

if ( $target ) { if ( $summary ) $summary = ": $summary"; $newTitle = ucfirst( eregi_replace( '[^a-z0-9_]+', '_', $newTitle ) ); $a = new Article( $t = Title::newFromText( $newTitle ) ); if ( $t->getArticleID() ) xwMessage( "Copy failed! \"$target\" already exists!", 'red' ); else $a->insertNewArticle( $article, "Copied from $title$summary", false, false ); xwMessage( 'Article copied successfully', 'green' ); } else {

$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/example:summary\">


<input type=submit value=\" Copy \">

</form>";

}

?>