Difference between revisions of "Extension:AjaxMakePage.php"

From Organic Design wiki
(Works as specified, one bug see Talk)
 
m (Reverted edits by Isojesid (talk) to last revision by Jack)
 
(6 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
/**{{Category:Extensions|AjaxMakePage}}{{php}}{{Category:Extensions created with Template:Extension}}
 
/**{{Category:Extensions|AjaxMakePage}}{{php}}{{Category:Extensions created with Template:Extension}}
  
  * AjaxMakePage extension enables users to create a new page and populate it with text (or replace the text of and exosting page) using two simple inputs and a button - A Mediawiki extension made with [http://www.organicdesign.co.nz/Template:Extension Template:Extension]
+
  * AjaxMakePage extension enables users to create a new page and populate it with text  
 +
(or replace the text of an existing page) using an input, a textbox and two buttons -
 +
made with [http://www.organicdesign.co.nz/Template:Extension Template:Extension]
 
  *
 
  *
 
  * See http://www.mediawiki.org/wiki/Extension:AjaxMakePage for installation and usage details
 
  * See http://www.mediawiki.org/wiki/Extension:AjaxMakePage for installation and usage details
Line 25: Line 27:
 
'name'        => 'AjaxMakePage',
 
'name'        => 'AjaxMakePage',
 
'author'      => '[http://www.flashkiwi.com Jack Henderson]',
 
'author'      => '[http://www.flashkiwi.com Jack Henderson]',
'description' => 'An extension making it possible to enter a new or existing pages name and its contents in textboxes at the bottom of the existing page, without leaving the page, made with [http://www.organicdesign.co.nz/Template:Extension Template:Extension]',
+
'description' => 'An extension making it possible to enter a new or existing pages name  
 +
and its contents in textboxes at the bottom of the existing page, without leaving the page,  
 +
made with [http://www.organicdesign.co.nz/Template:Extension Template:Extension]',
 
'url'        => 'http://www.organicdesign.co.nz/Extension:AjaxMakePage',
 
'url'        => 'http://www.organicdesign.co.nz/Extension:AjaxMakePage',
 
'version'    => AJAXMAKEPAGE_VERSION
 
'version'    => AJAXMAKEPAGE_VERSION
Line 35: Line 39:
 
$wgOut->addHTML('<input id="zajax" type="hidden" value=""/>');
 
$wgOut->addHTML('<input id="zajax" type="hidden" value=""/>');
 
$wgOut->addHTML('<br /><b>Generate a New Page</b><br /><br />');
 
$wgOut->addHTML('<br /><b>Generate a New Page</b><br /><br />');
$wgOut->addHTML('<b><em>Enter New Page Title</em></b><br /><input id="newname" value="" onblur="sajax_do_call(\'crdummy1\',[document.getElementById(\'newname\').value], document.getElementById(\'yajax\'))" /><br /><br />');
+
$wgOut->addHTML('<b><em>Enter New Page Title</em></b><br />
$wgOut->addHTML('<b><em>Enter Page Contents</em></b><br /><textarea rows="5" cols="40" id="newcontent" onblur="sajax_do_call(\'crdummy2\',[document.getElementById(\'newcontent\').value], document.getElementById(\'zajax\'))"></textarea><br /><br />');
+
<input id="newname" value="" onblur="sajax_do_call(\'crdummy1\',
+
[document.getElementById(\'newname\').value],  
$wgOut->addHTML('<input type="button" onclick="sajax_do_call(\'crdummy2\',[document.getElementById(\'newcontent\').value], document.getElementById(\'zajax\'))" id="setupbutton" value="Press This First (Setup)" /><br /><br />');
+
document.getElementById(\'yajax\'))" /><br /><br />');
$wgOut->addHTML('<input type="button" onclick="sajax_do_call(\'crpage\',[document.getElementById(\'yajax\').value,document.getElementById(\'zajax\').value],document.getElementById(\'tajax\'))" id="newbutton" value="Then Press This (Create)" /><br /><br />');
+
$wgOut->addHTML('<b><em>Enter Page Contents</em></b><br />
 +
<textarea rows="5" cols="40" id="newcontent" onblur="sajax_do_call(\'crdummy2\',
 +
[document.getElementById(\'newcontent\').value],  
 +
document.getElementById(\'zajax\'))"></textarea><br /><br />');
 +
$wgOut->addHTML('<input type="button" onclick="sajax_do_call(\'crdummy2\',
 +
[document.getElementById(\'newcontent\').value],  
 +
document.getElementById(\'zajax\'))" id="setupbutton" value="Press This First (Setup)" /><br /><br />');
 +
$wgOut->addHTML('<input type="button" onclick="sajax_do_call(\'crpage\',
 +
[document.getElementById(\'yajax\').value,document.getElementById(\'zajax\').value],
 +
document.getElementById(\'tajax\'))" id="newbutton" value="Then Press This (Create)" /><br /><br />');
 
   $wgOut->addHTML('<label id="tajax" /<br />');
 
   $wgOut->addHTML('<label id="tajax" /<br />');
 
return true;
 
return true;

Latest revision as of 09:28, 24 November 2010

<?php /**

Info.svg These are the MediaWiki extensions we're using and/or developing. Please refer to the information on the mediawiki.org wiki for installation and usage details. Extensions here which have no corresponding mediawiki article are either not ready for use or have been superseded. You can also browse our extension code in our local Subversion repository or our GitHub mirror.

Template:PhpCategory:Extensions created with Template:Extension

* AjaxMakePage extension enables users to create a new page and populate it with text 

(or replace the text of an existing page) using an input, a textbox and two buttons - made with Template:Extension

*
* See http://www.mediawiki.org/wiki/Extension:AjaxMakePage for installation and usage details
*
* @package MediaWiki
* @subpackage Extensions
* @author Jack Henderson
* @copyright © 2008 Jack Henderson
* @licence GNU General Public Licence 2.0 or later
*/

if (!defined('MEDIAWIKI')) die('Not an entry point.');

define('AJAXMAKEPAGE_VERSION', '0.0.1, 2008-12-20');

$wgExtensionFunctions[] = 'efSetupAjaxMakePage';

$wgAjaxExportList[] = "crpage"; $wgAjaxExportList[] = "crdummy1"; $wgAjaxExportList[] = "crdummy2";

$wgExtensionCredits['parserhook'][] = array( 'name' => 'AjaxMakePage', 'author' => 'Jack Henderson', 'description' => 'An extension making it possible to enter a new or existing pages name and its contents in textboxes at the bottom of the existing page, without leaving the page, made with Template:Extension', 'url' => 'http://www.organicdesign.co.nz/Extension:AjaxMakePage', 'version' => AJAXMAKEPAGE_VERSION );

function efAjaxMakePage (&$out,$file) { global $wgOut,$wgServer,$wgScriptPath; $wgOut->addHTML('<input id="yajax" type="hidden" value=""/>'); $wgOut->addHTML('<input id="zajax" type="hidden" value=""/>'); $wgOut->addHTML('
Generate a New Page

'); $wgOut->addHTML('Enter New Page Title
<input id="newname" value="" onblur="sajax_do_call(\'crdummy1\', [document.getElementById(\'newname\').value], document.getElementById(\'yajax\'))" />

'); $wgOut->addHTML('Enter Page Contents
<textarea rows="5" cols="40" id="newcontent" onblur="sajax_do_call(\'crdummy2\', [document.getElementById(\'newcontent\').value], document.getElementById(\'zajax\'))"></textarea>

'); $wgOut->addHTML('<input type="button" onclick="sajax_do_call(\'crdummy2\', [document.getElementById(\'newcontent\').value], document.getElementById(\'zajax\'))" id="setupbutton" value="Press This First (Setup)" />

'); $wgOut->addHTML('<input type="button" onclick="sajax_do_call(\'crpage\', [document.getElementById(\'yajax\').value,document.getElementById(\'zajax\').value], document.getElementById(\'tajax\'))" id="newbutton" value="Then Press This (Create)" />

');

 	$wgOut->addHTML('<label id="tajax" /
');

return true; }

function crpage($arg1,$arg2) { $title = Title::newFromText($arg1); $article = new Article($title); $arg2 = htmlspecialchars($arg2); $article->doEdit($arg2,EDIT_UPDATE|EDIT_MINOR); return "Page $arg1 created"; }

function crdummy1($file1) { return $file1; }

function crdummy2($file2) { return $file2; }

function efSetupAjaxMakePage() { global $wgHooks; $wgHooks['BeforePageDisplay'][] = 'efAjaxMakePage'; }