[MediaWiki-l] Extension which creates a Wikipage with content

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[MediaWiki-l] Extension which creates a Wikipage with content

Manuela
Hi alltogether,
I hope this is the correct mailing list, please excuse if it is not (and
excuse my English, please).

I run a private Wiki and I am trying to create an extension where the user
can enter the title and some content in a form, similar to the extension
InputBox https://www.mediawiki.org/wiki/Extension:InputBox (you cannot enter
page content into the form created by this extension).
I studied the code of several extensions and created something like this:

#*** begin code ***
$pageTitleText = "my new wikipage";
$pageTitle = Title::newFromText( $pageTitleText );
$pageContentText = "my new page content";
$pageContent = new WikitextContent( $pageContentText );
$newWikiPage->doEditContent( $pageContent, $pageContent, EDIT_NEW );
#*** end code ***

Actually this is not working and creates an internal error.
I tried something different

#*** begin code ***
#...
$me = User::newFromSession();
$newWikiPage->doCreate($pageContent,EDIT_NEW,$me,"summary",array());
#*** end code ***

This code creates an internal error, too. array() should be an array with
meta-information which I could not figure out until now.
I have studied the internal documentian
https://doc.wikimedia.org/mediawiki-core/REL1_31/php/ and the code of
several exentions, and now I am lost in classes and PHP-Code, maybe someone
can help me out?
Thank you for reading this,
Manuela




--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Robert Vogel
Hi Manuela,


please have a look at "Extension:PageForms" [1]. Maybe it already provides the functionality you need.


Looks like in your first example the second parameter to "doEditContent" should be $pageContentText (type string) and not $pageContent (type WikitextContent). I think "doCreate" is not necessary.


If this does not work, can you please share the excalt error message?


[1] https://www.mediawiki.org/wiki/Extension:Page_Forms


--

Robert


________________________________
Von: MediaWiki-l <[hidden email]> im Auftrag von Manuela <[hidden email]>
Gesendet: Montag, 28. Januar 2019 07:06
An: [hidden email]
Betreff: [MediaWiki-l] Extension which creates a Wikipage with content

Hi alltogether,
I hope this is the correct mailing list, please excuse if it is not (and
excuse my English, please).

I run a private Wiki and I am trying to create an extension where the user
can enter the title and some content in a form, similar to the extension
InputBox https://www.mediawiki.org/wiki/Extension:InputBox (you cannot enter
page content into the form created by this extension).
I studied the code of several extensions and created something like this:

#*** begin code ***
$pageTitleText = "my new wikipage";
$pageTitle = Title::newFromText( $pageTitleText );
$pageContentText = "my new page content";
$pageContent = new WikitextContent( $pageContentText );
$newWikiPage->doEditContent( $pageContent, $pageContent, EDIT_NEW );
#*** end code ***

Actually this is not working and creates an internal error.
I tried something different

#*** begin code ***
#...
$me = User::newFromSession();
$newWikiPage->doCreate($pageContent,EDIT_NEW,$me,"summary",array());
#*** end code ***

This code creates an internal error, too. array() should be an array with
meta-information which I could not figure out until now.
I have studied the internal documentian
https://doc.wikimedia.org/mediawiki-core/REL1_31/php/ and the code of
several exentions, and now I am lost in classes and PHP-Code, maybe someone
can help me out?
Thank you for reading this,
Manuela




--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Manuela
Hi Robert,

thanks for your answer, I will check out the extension Page_Forms.

The second parameter of "doEditContent" was a typo when I wrote the message,
in my Wiki-code it is a string (should be "summary")

Thank you
Manuela



--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Manuela
Hi Robert,

I checked extension Page_Forms, it is way too complex for my purpuses.

Here the error message from the following code:

$pageTitleText = "my new wikipage";
$pageTitle = Title::newFromText( $pageTitleText );
$pageContentText = "my new page content";
$pageContent = new WikitextContent( $pageContentText );
$newWikiPage->doEditContent( $pageContent, "summary", EDIT_NEW );

[1ad3dc9e94053cf14fada5a0] 2019-01-28 14:25:01: Fataler Ausnahmefehler des
Typs „Error“

Does this code actually mean something to you? It seems like a random number
to me, it is different every time. The previous steps are working, I have
checked this, the wikipage "my new wikipage" does not exist.

Of course I could create the wikipage by directly accessing the database
with an "INSERT", but I think this is not the best method.

Manuela



--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Robert Vogel
Hi Manuela,


you will need to enable proper error reporting. Please set


$wgShowSQLErrors = true;
$wgDebugDumpSql  = true;
$wgShowExceptionDetails = true;
$wgShowDBErrorBacktrace = true;


in your LocalSettings.php file. Also, have a look at https://www.mediawiki.org/wiki/Manual:How_to_debug


--

Robert


________________________________
Von: MediaWiki-l <[hidden email]> im Auftrag von Manuela <[hidden email]>
Gesendet: Montag, 28. Januar 2019 15:30
An: [hidden email]
Betreff: Re: [MediaWiki-l] Extension which creates a Wikipage with content

Hi Robert,

I checked extension Page_Forms, it is way too complex for my purpuses.

Here the error message from the following code:

$pageTitleText = "my new wikipage";
$pageTitle = Title::newFromText( $pageTitleText );
$pageContentText = "my new page content";
$pageContent = new WikitextContent( $pageContentText );
$newWikiPage->doEditContent( $pageContent, "summary", EDIT_NEW );

[1ad3dc9e94053cf14fada5a0] 2019-01-28 14:25:01: Fataler Ausnahmefehler des
Typs „Error“

Does this code actually mean something to you? It seems like a random number
to me, it is different every time. The previous steps are working, I have
checked this, the wikipage "my new wikipage" does not exist.

Of course I could create the wikipage by directly accessing the database
with an "INSERT", but I think this is not the best method.

Manuela



--
Sent from: http://mediawiki-i.429.n8.nabble.com/
MediaWiki-I | Mailing List Archive<http://mediawiki-i.429.n8.nabble.com/>
mediawiki-i.429.n8.nabble.com
MediaWiki-I forum and mailing list archive. MediaWiki announcements and site admin list This is a multilingual list for help/support with running/configuring MediaWiki. It is intended for people who...



_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Manuela
Hi Robert,
thanks for the hints.

Here are the error messages:

[b27d3822820814f7b9f0e484] /disk2/index.php/Sendung Error from line 162 of
/var/www/html/disk2/extensions/Lilypond/Sendung.php: Call to a member
function doEditContent() on null

Backtrace:

#0 /var/www/html/disk2/includes/parser/Parser.php(3888):
Sendung->hookSendung(string, array, Parser, PPFrame_DOM)
#1 /var/www/html/disk2/includes/parser/Preprocessor_DOM.php(1362):
Parser->extensionSubstitution(array, PPFrame_DOM)
#2 /var/www/html/disk2/includes/parser/Parser.php(2942):
PPFrame_DOM->expand(DOMElement, integer)
#3 /var/www/html/disk2/includes/parser/Parser.php(1293):
Parser->replaceVariables(string)
#4 /var/www/html/disk2/includes/parser/Parser.php(443):
Parser->internalParse(string)
#5 /var/www/html/disk2/includes/content/WikitextContent.php(323):
Parser->parse(string, Title, ParserOptions, boolean, boolean, integer)
#6 /var/www/html/disk2/includes/content/AbstractContent.php(516):
WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean,
ParserOutput)
#7 /var/www/html/disk2/includes/poolcounter/PoolWorkArticleView.php(144):
AbstractContent->getParserOutput(Title, integer, ParserOptions)
#8 /var/www/html/disk2/includes/poolcounter/PoolCounterWork.php(123):
PoolWorkArticleView->doWork()
#9 /var/www/html/disk2includes/page/Article.php(604):
PoolCounterWork->execute()
#10 /var/www/html/disk2/includes/actions/ViewAction.php(68): Article->view()
#11 /var/www/html/disk2/includes/MediaWiki.php(500): ViewAction->show()
#12 /var/www/html/disk2/includes/MediaWiki.php(294):
MediaWiki->performAction(Article, Title)
#13 /var/www/html/disk2/includes/MediaWiki.php(861):
MediaWiki->performRequest()
#14 /var/www/html/disk2/includes/MediaWiki.php(524): MediaWiki->main()
#15 /var/www/html/disk2/index.php(42): MediaWiki->run()
#16 {main}


Robert Vogel wrote




--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Manuela
I tried something a little bit different:



which caused these errors:








--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Robert Vogel
Hi Manuela,



so the issue is not *how* you call ´doEditContent´, but *what* you call it on.


Looks like the `$newWikiPage` variable in your example is `null`. Make sure you construct you `WikiPage` object properly. E.g. by using `$newWikiPage = WikiPage::factory( $newTitle )`. Also make sure that `$newTitle` is a valid `Title` object. There are some limitations on what characters a title can contain in MediaWiki (https://www.mediawiki.org/wiki/Manual:$wgLegalTitleChars).


--

Robert


________________________________
Von: MediaWiki-l <[hidden email]> im Auftrag von Manuela <[hidden email]>
Gesendet: Montag, 28. Januar 2019 18:33
An: [hidden email]
Betreff: Re: [MediaWiki-l] Extension which creates a Wikipage with content

I tried something a little bit different:



which caused these errors:








--
Sent from: http://mediawiki-i.429.n8.nabble.com/


_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Manuela
Hi Robert,

thank you for your patience. Error messages are getting more and more
interesting ;-)

Code:


Error message:







--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Manuela
Unfortunately all error messages and code are gone, maybe because I enclosed
them in raw-Tags.


The last code with message (without tags):

Code:

$pageTitleText = "my new wikipage";
$pageTitle = Title::newFromText( $pageTitleText );
$pageContentText = "my new page content";
$newWikiPage = WikiPage::factory( $pageTitle );
if (is_null ($newWikiPage )) return "is null";
$pageContent = new WikitextContent( $pageContentText );
if ( is_null ($pageContent)) return "kein content";
$exists = !$newWikiPage->exists();
$newWikiPage->doEditContent( $pageContent, "summary", EDIT_NEW );


Error messages:

[98217b478daf6bb32df82e4d] /disk2/index.php/Sendung MWException from line
6115 of /var/www/html/disk2/includes/parser/Parser.php: Parser state cleared
while parsing. Did you call Parser::parse recursively? Lock is held by: #0
/var/www/html/disk2/includes/parser/Parser.php(412): Parser->lock()
#1 /var/www/html/disk2/includes/content/WikitextContent.php(323):
Parser->parse('<sendung par1="...', Object(Title), Object(ParserOptions),
true, true, 326)
#2 /var/www/html/disk2/includes/content/AbstractContent.php(516):
WikitextContent->fillParserOutput(Object(Title), 326, Object(ParserOptions),
true, Object(ParserOutput))
#3 /var/www/html/disk2/includes/poolcounter/PoolWorkArticleView.php(144):
AbstractContent->getParserOutput(Object(Title), 326, Object(ParserOptions))
#4 /var/www/html/disk2/includes/poolcounter/PoolCounterWork.php(123):
PoolWorkArticleView->doWork()
#5 /var/www/html/disk2/includes/page/Article.php(604):
PoolCounterWork->execute()
#6 /var/www/html/disk2/includes/actions/ViewAction.php(68): Article->view()
#7 /var/www/html/disk2/includes/MediaWiki.php(500): ViewAction->show()
#8 /var/www/html/disk2/includes/MediaWiki.php(294):
MediaWiki->performAction(Object(Article), Object(Title))
#9 /var/www/html/disk2/includes/MediaWiki.php(861):
MediaWiki->performRequest()
#10 /var/www/html/disk2/includes/MediaWiki.php(524): MediaWiki->main()
#11 /var/www/html/disk2/index.php(42): MediaWiki->run()
#12 {main}

Backtrace:

#0 /var/www/html/disk2/includes/parser/Parser.php(4447): Parser->lock()
#1 /var/www/html/disk2/includes/content/WikitextContent.php(139):
Parser->preSaveTransform(string, Title, User, ParserOptions)
#2 /var/www/html/disk2/includes/page/WikiPage.php(2089):
WikitextContent->preSaveTransform(Title, User, ParserOptions)
#3 /var/www/html/disk2/includes/page/WikiPage.php(1655):
WikiPage->prepareContentForEdit(WikitextContent, NULL, User, string,
boolean)
#4 /var/www/html/disk2/extensions/Lilypond/Sendung.php(175):
WikiPage->doEditContent(WikitextContent, string, integer)
#5 /var/www/html/disk2/includes/parser/Parser.php(3888):
Sendung->hookSendung(string, array, Parser, PPFrame_DOM)
#6 /var/www/html/disk2/includes/parser/Preprocessor_DOM.php(1362):
Parser->extensionSubstitution(array, PPFrame_DOM)
#7 /var/www/html/disk2/includes/parser/Parser.php(2942):
PPFrame_DOM->expand(DOMElement, integer)
#8 /var/www/html/disk2/includes/parser/Parser.php(1293):
Parser->replaceVariables(string)
#9 /var/www/html/disk2/includes/parser/Parser.php(443):
Parser->internalParse(string)
#10 /var/www/html/disk2/includes/content/WikitextContent.php(323):
Parser->parse(string, Title, ParserOptions, boolean, boolean, integer)
#11 /var/www/html/disk2/includes/content/AbstractContent.php(516):
WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean,
ParserOutput)
#12 /var/www/html/disk2/includes/poolcounter/PoolWorkArticleView.php(144):
AbstractContent->getParserOutput(Title, integer, ParserOptions)
#13 /var/www/html/disk2/includes/poolcounter/PoolCounterWork.php(123):
PoolWorkArticleView->doWork()
#14 /var/www/html/disk2/includes/page/Article.php(604):
PoolCounterWork->execute()
#15 /var/www/html/disk2/includes/actions/ViewAction.php(68): Article->view()
#16 /var/www/html/disk2/includes/MediaWiki.php(500): ViewAction->show()
#17 /var/www/html/disk2/includes/MediaWiki.php(294):
MediaWiki->performAction(Article, Title)
#18 /var/www/html/disk2/includes/MediaWiki.php(861):
MediaWiki->performRequest()
#19 /var/www/html/disk2/includes/MediaWiki.php(524): MediaWiki->main()
#20 /var/www/html/disk2/index.php(42): MediaWiki->run()
#21 {main}

Manuela wrote
> ur patience. Error messages are getting more and more
> interesting ;-)
>
> Code:
>
> Error message:





--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Robert Vogel
Hello Manuela,


it looks like the source of the issue is, that you try to create a wiki page from within a parser hook callback. This is very uncommon. It somehow messes with the global state of the Parser.

Do you have your code online somewhere? Maybe github.com? This would probably be a better place to discuss implementation details. Or maybe you could give some details of your use case.


--

Robert


________________________________
Von: MediaWiki-l <[hidden email]> im Auftrag von Manuela <[hidden email]>
Gesendet: Dienstag, 29. Januar 2019 05:30
An: [hidden email]
Betreff: Re: [MediaWiki-l] Extension which creates a Wikipage with content

Unfortunately all error messages and code are gone, maybe because I enclosed
them in raw-Tags.


The last code with message (without tags):

Code:

$pageTitleText = "my new wikipage";
$pageTitle = Title::newFromText( $pageTitleText );
$pageContentText = "my new page content";
$newWikiPage = WikiPage::factory( $pageTitle );
if (is_null ($newWikiPage )) return "is null";
$pageContent = new WikitextContent( $pageContentText );
if ( is_null ($pageContent)) return "kein content";
$exists = !$newWikiPage->exists();
$newWikiPage->doEditContent( $pageContent, "summary", EDIT_NEW );


Error messages:

[98217b478daf6bb32df82e4d] /disk2/index.php/Sendung MWException from line
6115 of /var/www/html/disk2/includes/parser/Parser.php: Parser state cleared
while parsing. Did you call Parser::parse recursively? Lock is held by: #0
/var/www/html/disk2/includes/parser/Parser.php(412): Parser->lock()
#1 /var/www/html/disk2/includes/content/WikitextContent.php(323):
Parser->parse('<sendung par1="...', Object(Title), Object(ParserOptions),
true, true, 326)
#2 /var/www/html/disk2/includes/content/AbstractContent.php(516):
WikitextContent->fillParserOutput(Object(Title), 326, Object(ParserOptions),
true, Object(ParserOutput))
#3 /var/www/html/disk2/includes/poolcounter/PoolWorkArticleView.php(144):
AbstractContent->getParserOutput(Object(Title), 326, Object(ParserOptions))
#4 /var/www/html/disk2/includes/poolcounter/PoolCounterWork.php(123):
PoolWorkArticleView->doWork()
#5 /var/www/html/disk2/includes/page/Article.php(604):
PoolCounterWork->execute()
#6 /var/www/html/disk2/includes/actions/ViewAction.php(68): Article->view()
#7 /var/www/html/disk2/includes/MediaWiki.php(500): ViewAction->show()
#8 /var/www/html/disk2/includes/MediaWiki.php(294):
MediaWiki->performAction(Object(Article), Object(Title))
#9 /var/www/html/disk2/includes/MediaWiki.php(861):
MediaWiki->performRequest()
#10 /var/www/html/disk2/includes/MediaWiki.php(524): MediaWiki->main()
#11 /var/www/html/disk2/index.php(42): MediaWiki->run()
#12 {main}

Backtrace:

#0 /var/www/html/disk2/includes/parser/Parser.php(4447): Parser->lock()
#1 /var/www/html/disk2/includes/content/WikitextContent.php(139):
Parser->preSaveTransform(string, Title, User, ParserOptions)
#2 /var/www/html/disk2/includes/page/WikiPage.php(2089):
WikitextContent->preSaveTransform(Title, User, ParserOptions)
#3 /var/www/html/disk2/includes/page/WikiPage.php(1655):
WikiPage->prepareContentForEdit(WikitextContent, NULL, User, string,
boolean)
#4 /var/www/html/disk2/extensions/Lilypond/Sendung.php(175):
WikiPage->doEditContent(WikitextContent, string, integer)
#5 /var/www/html/disk2/includes/parser/Parser.php(3888):
Sendung->hookSendung(string, array, Parser, PPFrame_DOM)
#6 /var/www/html/disk2/includes/parser/Preprocessor_DOM.php(1362):
Parser->extensionSubstitution(array, PPFrame_DOM)
#7 /var/www/html/disk2/includes/parser/Parser.php(2942):
PPFrame_DOM->expand(DOMElement, integer)
#8 /var/www/html/disk2/includes/parser/Parser.php(1293):
Parser->replaceVariables(string)
#9 /var/www/html/disk2/includes/parser/Parser.php(443):
Parser->internalParse(string)
#10 /var/www/html/disk2/includes/content/WikitextContent.php(323):
Parser->parse(string, Title, ParserOptions, boolean, boolean, integer)
#11 /var/www/html/disk2/includes/content/AbstractContent.php(516):
WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean,
ParserOutput)
#12 /var/www/html/disk2/includes/poolcounter/PoolWorkArticleView.php(144):
AbstractContent->getParserOutput(Title, integer, ParserOptions)
#13 /var/www/html/disk2/includes/poolcounter/PoolCounterWork.php(123):
PoolWorkArticleView->doWork()
#14 /var/www/html/disk2/includes/page/Article.php(604):
PoolCounterWork->execute()
#15 /var/www/html/disk2/includes/actions/ViewAction.php(68): Article->view()
#16 /var/www/html/disk2/includes/MediaWiki.php(500): ViewAction->show()
#17 /var/www/html/disk2/includes/MediaWiki.php(294):
MediaWiki->performAction(Article, Title)
#18 /var/www/html/disk2/includes/MediaWiki.php(861):
MediaWiki->performRequest()
#19 /var/www/html/disk2/includes/MediaWiki.php(524): MediaWiki->main()
#20 /var/www/html/disk2/index.php(42): MediaWiki->run()
#21 {main}

Manuela wrote
> ur patience. Error messages are getting more and more
> interesting ;-)
>
> Code:
>
> Error message:





--
Sent from: http://mediawiki-i.429.n8.nabble.com/
MediaWiki-I | Mailing List Archive<http://mediawiki-i.429.n8.nabble.com/>
mediawiki-i.429.n8.nabble.com
MediaWiki-I forum and mailing list archive. MediaWiki announcements and site admin list This is a multilingual list for help/support with running/configuring MediaWiki. It is intended for people who...



_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Manuela
Robert Vogel wrote
> it looks like the source of the issue is, that you try to create a wiki
> page from within a parser hook callback. This is very uncommon. It somehow
> messes with the global state of the Parser.
>
> Do you have your code online somewhere? Maybe github.com? This would
> probably be a better place to discuss implementation details. Or maybe you
> could give some details of your use case.

Hi Robert,

thank you for your answer. I have already thought about that. What would be
a better way, a Special-Page Extension?

I had the idea of entering a page title and some initial content into a form
and creating a new page from that. This is the way how many users would
expect it to work, and obviously there is no simple way in MediaWiki to do
so.

My code is really simple, just creating the hook, defining a test page title
and test content and trying to create a page from that. I will post the full
code this evening.

If there is no simple way I must go the hard (and dirty) way and use SQL for
directly accessing the database,

greetings
Manuela



--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Robert Vogel
Hi Manuela,


I am sure you can do this by using the standard object model and extension interface of MediaWiki. I really advice against manipulating the database directly. Maybe you could even use the "Action API" of MediaWiki:


  1.  Use the parser hook / special page to create the desired form (https://www.mediawiki.org/wiki/HTMLForm)
  2.  Create a resourceloader module to load javascript (https://www.mediawiki.org/wiki/ResourceLoader/Developing_with_ResourceLoader#Server-side)
  3.  When the user submits the form, assemble the wikitext from the form fields and use the "Action API" to create/edit the wikipage (https://www.mediawiki.org/wiki/API:Edit, https://doc.wikimedia.org/mediawiki-core/REL1_31/js/#!/api/mw.Api.plugin.edit and https://doc.wikimedia.org/mediawiki-core/REL1_31/js/#!/api/mw.Api )


--

Robert


________________________________
Von: MediaWiki-l <[hidden email]> im Auftrag von Manuela <[hidden email]>
Gesendet: Dienstag, 29. Januar 2019 12:54
An: [hidden email]
Betreff: Re: [MediaWiki-l] Extension which creates a Wikipage with content

Robert Vogel wrote
> it looks like the source of the issue is, that you try to create a wiki
> page from within a parser hook callback. This is very uncommon. It somehow
> messes with the global state of the Parser.
>
> Do you have your code online somewhere? Maybe github.com? This would
> probably be a better place to discuss implementation details. Or maybe you
> could give some details of your use case.

Hi Robert,

thank you for your answer. I have already thought about that. What would be
a better way, a Special-Page Extension?

I had the idea of entering a page title and some initial content into a form
and creating a new page from that. This is the way how many users would
expect it to work, and obviously there is no simple way in MediaWiki to do
so.

My code is really simple, just creating the hook, defining a test page title
and test content and trying to create a page from that. I will post the full
code this evening.

If there is no simple way I must go the hard (and dirty) way and use SQL for
directly accessing the database,

greetings
Manuela



--
Sent from: http://mediawiki-i.429.n8.nabble.com/
MediaWiki-I | Mailing List Archive<http://mediawiki-i.429.n8.nabble.com/>
mediawiki-i.429.n8.nabble.com
MediaWiki-I forum and mailing list archive. MediaWiki announcements and site admin list This is a multilingual list for help/support with running/configuring MediaWiki. It is intended for people who...



_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Manuela
Robert, thank you for the detailled instructions, I will study the links and
try to follow the instructions,

greetings,
Manuela






--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Manuela
API:Edit seems promising, but I have to figure out how to use it.
Unfortunately are the programming samples written in Python and not in PHP.
I want to learn Python, anyway (PHP is really hard to read for me, the
greater-than-signs and the $-sign are piercing my eyeballs ;-), I wonder who
designed this language )

Thanks again, Robert,
greetings
Manuela



--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Tobias Oetterer
In reply to this post by Manuela
Hey

Probably a little bit late to chip in, but did you look at the extension AutoCreatePage [0]? You can use its source as a template for your code.

You already said it is too complicated for you, but if you want to have another look at PageForms, I could give you an example on the semantic sandbox wiki [1]. It is THE go-to extension for guided user created content.

Another alternative is to create the page externally using a bot that utilizes the mediawiki api [2]. However that would mean that your users would somehow feed the bot to create a page and then go to your wiki to read/edit. Be sure you want that. If, on the other hand, your "feeder" is it-system with witch you want to sync regularly this would be the best way.

Cheers,
Tobi

[0]: https://www.mediawiki.org/wiki/Extension:AutoCreatePage
[1]: https://sandbox.semantic-mediawiki.org
[2]: https://www.mediawiki.org/wiki/Manual:Bots

--
If this email is rather brief, it is not meant to be impolite but to respect your time.
http://five.sentenc.es
No trees were killed to send this message, but a large number of electrons were terribly inconvenienced

Paderborn University
Zentrum IMT
Warburger Straße 100
33098 Paderborn

Office: N5.338
Phone: 05251/60-2194
Internet: http://imt.uni-paderborn.de


-----Ursprüngliche Nachricht-----
Von: MediaWiki-l <[hidden email]> Im Auftrag von Manuela
Gesendet: Montag, 28. Januar 2019 07:06
An: [hidden email]
Betreff: [MediaWiki-l] Extension which creates a Wikipage with content

Hi alltogether,
I hope this is the correct mailing list, please excuse if it is not (and excuse my English, please).

I run a private Wiki and I am trying to create an extension where the user can enter the title and some content in a form, similar to the extension InputBox https://www.mediawiki.org/wiki/Extension:InputBox (you cannot enter page content into the form created by this extension).
I studied the code of several extensions and created something like this:

#*** begin code ***
$pageTitleText = "my new wikipage";
$pageTitle = Title::newFromText( $pageTitleText ); $pageContentText = "my new page content"; $pageContent = new WikitextContent( $pageContentText ); $newWikiPage->doEditContent( $pageContent, $pageContent, EDIT_NEW );
#*** end code ***

Actually this is not working and creates an internal error.
I tried something different

#*** begin code ***
#...
$me = User::newFromSession();
$newWikiPage->doCreate($pageContent,EDIT_NEW,$me,"summary",array());
#*** end code ***

This code creates an internal error, too. array() should be an array with meta-information which I could not figure out until now.
I have studied the internal documentian
https://doc.wikimedia.org/mediawiki-core/REL1_31/php/ and the code of several exentions, and now I am lost in classes and PHP-Code, maybe someone can help me out?
Thank you for reading this,
Manuela




--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Manuela
Tobias Oetterer wrote
> Hey
>
> Probably a little bit late to chip in, but did you look at the extension
> AutoCreatePage [0]? You can use its source as a template for your code.

It is never too late ;-)

Thank you Tobi for your answer, I appreciate it very much. I will look into
it,

Greetings
Manuela



--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Robert Vogel
In reply to this post by Manuela
Hi Manuela,


my proposed approach would use JavaScript to access the MediaWiki Action API. There is no need to call the API from PHP or Python.


Just register a JavaScript using ResourceLoader and do something like


$( '#content' ).on( 'submit', '.mycreatepageform', function() {

    var api = new mw.Api();

    api.postWithToken( 'csrf', {

        action: 'edit',

        ...

    } )

    .done(...);

} );


--

Robert


________________________________
Von: MediaWiki-l <[hidden email]> im Auftrag von Manuela <[hidden email]>
Gesendet: Mittwoch, 30. Januar 2019 22:21
An: [hidden email]
Betreff: Re: [MediaWiki-l] Extension which creates a Wikipage with content

API:Edit seems promising, but I have to figure out how to use it.
Unfortunately are the programming samples written in Python and not in PHP.
I want to learn Python, anyway (PHP is really hard to read for me, the
greater-than-signs and the $-sign are piercing my eyeballs ;-), I wonder who
designed this language )

Thanks again, Robert,
greetings
Manuela



--
Sent from: http://mediawiki-i.429.n8.nabble.com/
MediaWiki-I | Mailing List Archive<http://mediawiki-i.429.n8.nabble.com/>
mediawiki-i.429.n8.nabble.com
MediaWiki-I forum and mailing list archive. MediaWiki announcements and site admin list This is a multilingual list for help/support with running/configuring MediaWiki. It is intended for people who...



_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Manuela
Robert Vogel wrote
> my proposed approach would use JavaScript to access the MediaWiki Action
> API. There is no need to call the API from PHP or Python.
>
> Just register a JavaScript using ResourceLoader and do something like

Hi Robert,

I am trying to avoid JavaScript as much as I can. I would strongly prefer a
PHP or Python script. I have never written JavaScipt code in my life, and I
have written lots of code.

First of all I must figure out how the API is working and what it is doing.
I will have to study the manual several days, maybe things become clearer
for me then.

Thank you, I'll be back ;-)
Manuela



--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Extension which creates a Wikipage with content

Manuela
In reply to this post by Manuela
Hi altogether,

thank you for your help so far. I have decided that this problem consumes
too much of my time, so I stopped it for now. I have to get a much better
understanding of the MediaWiki content model.

My hope was that somebody will tell me: this is really simple, studpid, you
have to do this and that and it will be working. This is obviously not the
case, it seems that a MediaWiki page can only update itself and not other
pages as far as I see.

Thank you again,
greetings,

> Manuela





--
Sent from: http://mediawiki-i.429.n8.nabble.com/

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
12