Jump to content

Extension talk:CreateArticle

Add topic
From mediawiki.org
Latest comment: 12 years ago by Nakohdo in topic Why it doesn't work on PHP 5.3.2 ?

Valid MediaWiki Versions

[edit]

If you've downloaded and used this extension and it works properly, please add your MediaWiki version to the following list. Thanks!

  • MW 1.6.9
  • MW 1.6.10
  • MW 1.9.3 CreateArticele: works, Inputbox: fails
  • MW 1.12.0
  • MW 1.14.0
  • MW 1.15.1
  • MW 1.16.2 (Apply this Patch)
  • MW 1.16.5 (without patch) PHP 5.2.17
  • MW 1.22.6 (Apply fix 1 here)

Hello there,

I'm using the extension with the prefix parameter. If someone tries to create an article with an pagename which is already existing (e.g there is already a page called "prefix: mypage" and the user entered the title "mypage" at the box) - you'll get a fatal error:

Fatal error: Call to a member function getPrefixedText() on a non-object in .../includes/OutputPage.php on line 816 --Diamondaine



Hi,

i noticed two "problems" when running in Version 1.6.9

1. I had to comment out line 105 (rendering magic word PAGENAME) because of warnings in my html code on the start page rendered in the html code.

For me it is not a real big problem, because we do not need this functionality.

I'm puzzled over this; this line of code came directly from the Inputbox extension, which was the basis of this extension. Is there perhaps a conflict with something specific in your wiki? --Hoggwild5 19:30, 20 March 2007 (UTC)Reply


2. Pressing the button with no text entered, causes an error on line 212 (i guess $title is empty, and ->getArticleID() causes the problem)

Maybe it is not the "best solution" but i added the following to the if statement (line 212)

if(isset($title) && $title->getArticleID() == 0) {

in this case, it will be handled as an aricitle that exists.

193.19.114.132--

I have to do some additions.

In my case, the statement at line 201 does not work.

if(is_null($title)){

i changed it into !isset($title) and it works

193.19.114.132--

The above errors were corrected with new source code posted on 20 Mar 2007 --Hoggwild5 22:57, 20 March 2007 (UTC)Reply

Is it possible to have templates other than in the Mediawiki namespace on this? Or is it easy to create new templates in the mediawiki namespace?

if you have edit privileges to the MediaWiki namespace, creating a new template there is easy. I'll look at the possibility of using templates from other namespaces as well. The logic I used here is the same as the Inputbox extension, so I'll need to take a look at source code to see if this is easily implemented. --Hoggwild5 23:01, 20 March 2007 (UTC)Reply

Another thought: What if this create article triggered a form entry rather just adding the template to the edit view? -j --198.70.22.217 17:40, 19 March 2007 (UTC)Reply

I am working on a form entry extension, and the primary purpose of this extension with the ability to add namespaces and/or subpages to an article title without user intervention is to set up the appropriate triggers for a form entry screen. This capability is under development. --Hoggwild5 23:01, 20 March 2007 (UTC)Reply
Will you be posting that here or keeping a log of progress somewhere? -j --198.70.22.217 13:45, 26 March 2007 (UTC)Reply

Problem in MW 1.9.3 with PHP 5.1.6

[edit]

If you get 'createbox: type not defined.', the culprit is the 'htmlspecialchars' function below:

/* Parses tag input arguments */
function getCreateBoxOption(&$value,&$input,$name,$isNumber=false) {
      if(preg_match("/^\s*$name\s*=\s*(.*)/mi",$input,$matches)) {
                if($isNumber) {
                        $value=intval($matches[1]);
                } else {
                        $value=htmlspecialchars($matches[1]);
                }
        }
}

Then try the following:

/* Parses tag input arguments */
function getCreateBoxOption(&$value,&$input,$name,$isNumber=false) {
      if(preg_match("/^\s*$name\s*=\s*(.*)/mi",$input,$matches)) {
                if($isNumber) {
                        $value=intval($matches[1]);
                } else {
                        $value=trim(htmlspecialchars($matches[1]));
                }
        }
}

Hope this helps, Jean-Lou Dupont 14:08, 26 March 2007 (UTC)Reply

Preload, supage and prefix do not work in Version 0.91 beta (20 Mar 2007) of the extension

[edit]

Workaround:

function accRedirect($title, $action)
{
   global $wgRequest, $wgOut;
   $query = "action=edit&section=" . $wgRequest->getVal('section') .
       "&createintro=" . $wgRequest->getVal('createintro') .
/* New code*/
       "&prefix=" . $wgRequest->getVal('prefix') .
       "&preload=" . $wgRequest->getVal('preload') .
       "&subpage=" . $wgRequest->getVal('subpage') .
       "&editintro=" . $wgRequest->getVal('editintro') ;
   $wgOut->setSquidMaxage( 1200 );
   $wgOut->redirect($title->getFullURL( $query ), '301');
}

Basic error checking

[edit]

Can you add some javascript and/or PHP (fallback) error checking to verify/validate the input field isn't empty and, optionally, to verify the prefix isn't entered? Thanks. -EepÂČ 19:02, 30 July 2007 (UTC)Reply

More suggestions

[edit]
  • If a page already exists, go into edit mode instead of giving an error.
  • An option to call templates - I want to create automated pages and just want to enter the name in and have the template apply the name to various fields in the template. Eventually I don't even want the newly created page to be editable once it's created by certain users, but that's another issue...

-EepÂČ 12:50, 3 August 2007 (UTC)Reply

  • Preload plain text and formatted text without having to have it in a template. -EepÂČ 07:36, 7 August 2007 (UTC)Reply
  • It would be very nice to have a "suffix" option so we could use article names that end on a given name (naming convention). For example to create xxx_sales or xxx_documentation

dynamic preload

[edit]

I would like to preload text that is inserted by the user in the form. More specifically, I would like to let users insert a title and a date, create a new page with the inserted title as page-name and the inserted date as a category. like so:

form:

-title

-date

result:

editing title

Category:''date''

Is that somehow possible? — Preceding unsigned comment added by Robert Buzink (talk ‱ contribs) 15:39, August 12, 2007

need some support

[edit]

Hi,

i wanna use some parts of your extension to finish my wizard extension.

So at the last step of the wizard - which leeds users to write new articles - the title comes from a session var.

The crate article box has to be added to a pageobject


       $page=array
           (
           "step" => "4",
           "title" => wfMsg('naw_title_page_4', '4', '4'),
           "caption" => utf8_encode(wfMsg('naw_caption_page_4')),
           "body" => $this->renderCreatebox()
           );
       $this->addWizardPage($page);

But function renderCreatebox($input, $params,&$parser) assumes 3 params. So is there a way I can handle this

Thanks mic (info@hafenvolleyballer.de)

[RESOLVED] Problem: Template for new article in categories

[edit]

I thought this would solve a big problem of mine but it doesn't. For preload= I want to use a template that already adds the article into categories, so template text reads [[Category:Whatever]] already. That means the template will be listed in [[Category:Whatever]]. That's not what I want :( I also can't add <noinclude>[[Category:Whatever]]</noinclude> since I would have to tell my users to remove this... So what to do since all namespaces are shown in categories? --Subfader 21:41, 17 March 2008 (UTC)Reply


Finally found the solution Manual:Creating pages with preloaded text. The preloaded template text must be inside includeonly tags, so the page won't be categorized, instead of include tags as I tried (well, very confusing, innit!). Example: You create Template:XYZpage with this text:

<includeonly>
== Heading ==

Text

[[Category:Example]]
</includeonly>

Template:XYZpage will preload everything inside the includeonly tags without including the tags theirself. Template:XYZpage will not be listed in Catgeory:Example. --Subfader 14:55, 25 March 2008 (UTC)Reply

Little variation on display

[edit]

I wanted the prefix (e.g. the namespace) displayed before the input field. And maybe some want the sufix displayed after...

I submit the variant CreateArticle/variant pre and post

There are two more parameters :

pre
If the value is the name one of the existing parameters, the value of this parameter is displayed before the field. If not, the value passed to pre is displayed.
post
If the value is the name one of the existing parameters, the value of this parameter is displayed before the field. If not, the value passed to pre is displayed.

example

[edit]
<createarticle>
type=createarticle
break=yes
width=24
buttonlabel=créer la référence
prefix=Référence:
editintro=Wikitau:Référence/Création/editintro
preload=Wikitau:Référence/Création/preload
pre=prefix
</createarticle>

gives :

Changes

[edit]

Maybe it would be better to send the name of the parameter by the way @prefix, and to make more test (allowed fields in an array...) before reading the value... But I'm not skillful enough... FrViPofm 16:27, 16 June 2008 (UTC)Reply

Using CreateArticle in a template

[edit]

In order to create many similar CreateArticle boxes, CreateArticle can be used in a template. However, passing template parameters to CreateArticle parameters only works if the <CreateArticle>...</CreateArticle> tag is written as {{#tag:CreateArticle| ...}} inside the template.

The following example is a template to create a new wiki page from a named template:

{{#tag:CreateArticle|
type=createarticle
buttonlabel=Create new {{{1|article}}}
preload={{{2|Template:Article}}} }}

When instantiating the template, the first parameter gives the item that is created (default: article) as spelled out in the button, the second parameter gives the name of the template used to create the item (default: Template:Article).

E.g., the code for an input box to create a new project from a project template might look like this:

{{Template:CreateNew|project|Template:Project}}

Source: Extension:Inputbox

Dynamic parameters with magic words

[edit]

The same technique works when using a magic word for dynamically changing parameters, e.g. creating a subpage for the current page:

{{#tag:CreateArticle| 
 type       = createarticle
 prefix     = {{FULLPAGENAME}}/
}}

--Nakohdo 12:48, 28 January 2011 (UTC)Reply

A few quick fixes

[edit]

Luckily they were easy to fix in 1.15.1 on PHP 5.3.0.

Create Article Box Missing

[edit]
  • The create box never showed up.
  • Displayed this error: Parameter 3 in renderCreateBox expected reference. Value was sent.
  • To fix it just edit line:
function renderCreatebox($input, $params, &$parser) {

to

function renderCreatebox($input, $params, $parser) {

Display edit page instead of error when article already exists

[edit]
  • Change these or uncomment these lines
$wgTitle = Title::newFromText( wfMsgForContent( 'createarticle' ) );
        $wgOut->errorpage( 'error', 'articleexists' ); 

and replace with this line

accRedirect($title, 'createarticle');

--dk01 1/2/10

Why it doesn't work on PHP 5.3.2 ?

[edit]

Hello, it doesn't work on php5, why ? I use: PHP Version 5.3.2-1ubuntu4.2 Apache/2.2.14 (Ubuntu)

Maybe something needs to be configured ? Help me please.

It does not work for me either

[edit]

To my mind it worked with Mediawiki 1.14.1, but after upgrading to 1.15.4, it does not work any more. It's on FreeBSD, Apache 2.2.16 and PHP 5.3.3. The plugin does not throw any errors into http-log, but the input just does not appear on pages.

See Installation for the PHP requirements of MediaWiki:
PHP version 5.2.3 or later. PHP 5.3.1 is incompatible with MediaWiki due to a bug.
Due to a security issue with PHP it is strongly advised to use PHP 5.2.17+ or PHP 5.3.5+ 
hth --Nakohdo 16:42, 10 June 2011 (UTC)Reply
I get the following error message (MediaWiki 1.17.0, PHP 5.3.13):
Warning: Parameter 3 to renderCreatebox() expected to be a reference, 
value given in .../mediawiki/includes/parser/Parser.php on line 3470
See http://www.mediawiki.org/wiki/Extension:CreateArticle/sourcecode#Fixes for a suggested fix. --Nakohdo (talk) 17:17, 26 July 2012 (UTC)Reply

Create page without visual elements

[edit]

Hi. What I need to change to your extension to create articles without visual elements? For example, when parsing the page with text
<createarticle> type=createarticle title=New </createarticle> I want the page "New" was created automatically, if it does not exists.
Thanks, Taras, Kyyiv, Ukraine.

Not working for me..

[edit]

i tried it, and failed at it. what does:
?UNIQ1136e00e5edcd741-createarticle-00000001-QINU?
mean?
i used:
"#tag:CreateArticle| type=createarticle buttonlabel=Create new article preload=Template:Article"
with }} and {{ at the end
i have no idea whats going on..
thanks,
Flipp0 17 sept. 2010 at 13:44

Added Dynamic Language loading

[edit]

Hi I made this change for http://test.cablegatewiki.org so that it will search for the preload that is the same language as is being created.

I.E. You choose to create an article in French (ArticleName/fr) then it will use (PreloadArticle/fr) for the preload.

This code was added to accRedirect()

Before code:

function accRedirect($title, $action) {
    global $wgRequest, $wgOut;

    $query = "action=edit&section=" . $wgRequest->getVal('section') .
        "&createintro=" . $wgRequest->getVal('createintro') . "&preload=" .   
        $wgRequest->getVal('preload') . "&editintro=" . $wgRequest->getVal('editintro');
 
    $wgOut->setSquidMaxage( 1200 );
    $wgOut->redirect($title->getFullURL( $query ), '301');
}

After code:

function accRedirect($title, $action) {
    global $wgRequest, $wgOut;
	
/**
******** Checks which language article is being created then tries to get the preload in that same language *****/
	$langSuffix = substr( $wgRequest->getVal('title'), strrpos( $wgRequest->getVal('title'), '/' ) );
	$preloadTitle = Title::newFromText($wgRequest->getVal('preload') .$langSuffix);
	if ( $preloadTitle->isKnown() ) {
		$languageSpecificPreload = $wgRequest->getVal('preload') .$langSuffix;
	} else {
		$languageSpecificPreload = $wgRequest->getVal('preload');
	}
/******* If it can't find that language preload, uses the preload given *******************************************/
	
    $query = "action=edit&section=" . $wgRequest->getVal('section') .
        "&createintro=" . $wgRequest->getVal('createintro') . "&preload=" .   
        $languageSpecificPreload . "&editintro=" . $wgRequest->getVal('editintro');
 
    $wgOut->setSquidMaxage( 1200 );
    $wgOut->redirect($title->getFullURL( $query ), '301');
}

Add it if you want, could maybe put another argument in "dynamiclanguage" or something. --202.27.47.11 14:10, 25 February 2011 (UTC)Reply

Creating two pages at once?

[edit]

Is it possible to create two (or even more) pages in one go? From the page name in the input field I want to create [[My page]] and a template with the same name [[Template:My page]]. --Nakohdo 16:37, 10 June 2011 (UTC)Reply

If page exists, redirect to page

[edit]

Below

    $title = Title::newFromText( $title );

add

    //MANUAL FIX: if page exists, redirect to page
    if($title->getArticleID() !== 0) {
       $wgOut->redirect( $title->getFullURL() );
       return false;
    }

If the page you're trying to create exists, this will redirect to it. --Subfader 18:24, 5 December 2011 (UTC)Reply

Cannot handle UTF characters

[edit]

When a page is created using a title (with the inputbox) which contains a character such as "Ăž", the creation fails with a MediWiki internal error, which causes MediaWiki to become unresponsive.

Creating a page with title "SĂžren" does work on my wiki (MediaWiki 1.17.0; PHP 5.2.17; CreateArticle 0.9 beta) --Nakohdo (talk) 08:20, 24 July 2012 (UTC)Reply
Works on 1.16.1 and 1.18.0 - must be you. --Subfader (talk) 11:43, 24 July 2012 (UTC)Reply

1.19.x upgrade issues...

[edit]

I have been running this extension on 1.18.x and it worked well, however I have upgraded to 1.19 and now the whole site throws an HTTP 500 Error.

Anyone have any suggestions to correct this?

I've got it to work now... There were other issues with the Wiki and it looks like this extension works fine on 1.19...