Page Table

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

Page Table

Amruta Lonkar-2
Hi,
I want to create a page and have some default text for it on the
'ArticleSaveComplete' event. For this i ma inserting information into the
page, revision and text table. I am enetring the default text into the text
table. I do  not know how to get the length of the page (that is the default
text) to inset it into the page table. Will this actually create a page for
it or do i need ot call Article class for the same?

Thanks,
Amruta
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Page Table

Rob Church
For a good set of pointers on programmatically creating pages, take a
look at the InitialiseMessages.inc file in the maintenance dir. It's
got a chunk of code which demonstrates how to create a new page and
insert it into the database, with revision and text information.


Rob Church

On 17/02/06, Amruta Lonkar <[hidden email]> wrote:

> Hi,
> I want to create a page and have some default text for it on the
> 'ArticleSaveComplete' event. For this i ma inserting information into the
> page, revision and text table. I am enetring the default text into the text
> table. I do  not know how to get the length of the page (that is the default
> text) to inset it into the page table. Will this actually create a page for
> it or do i need ot call Article class for the same?
>
> Thanks,
> Amruta
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Page Table

Amruta Lonkar-2
I guess its the initialiseMessagesReal function right in the file you
mentioned? I have one question though. Is it necessary to do all the
diabling functions that have been done in it for creating the pages that i
want to create. There is a lot of code in that function and i cant exactly
figure out how to use it to code for a new namespace, page and default text.

-Amruta


On 2/17/06, Rob Church <[hidden email]> wrote:

>
> For a good set of pointers on programmatically creating pages, take a
> look at the InitialiseMessages.inc file in the maintenance dir. It's
> got a chunk of code which demonstrates how to create a new page and
> insert it into the database, with revision and text information.
>
>
> Rob Church
>
> On 17/02/06, Amruta Lonkar <[hidden email]> wrote:
> > Hi,
> > I want to create a page and have some default text for it on the
> > 'ArticleSaveComplete' event. For this i ma inserting information into
> the
> > page, revision and text table. I am enetring the default text into the
> text
> > table. I do  not know how to get the length of the page (that is the
> default
> > text) to inset it into the page table. Will this actually create a page
> for
> > it or do i need ot call Article class for the same?
> >
> > Thanks,
> > Amruta
> > _______________________________________________
> > MediaWiki-l mailing list
> > [hidden email]
> > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> >
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Page Table

Rob Church
No, a lot of the stuff in that file you can ignore. For instance, you
aren't going to need to disable $wgOut or fake your $wgUser values.
Concentrate on the bits that instantiate the article class, and the
revision classes, and use the insertOn and updateTo methods.


Rob Church

On 17/02/06, Amruta Lonkar <[hidden email]> wrote:

> I guess its the initialiseMessagesReal function right in the file you
> mentioned? I have one question though. Is it necessary to do all the
> diabling functions that have been done in it for creating the pages that i
> want to create. There is a lot of code in that function and i cant exactly
> figure out how to use it to code for a new namespace, page and default text.
>
> -Amruta
>
>
> On 2/17/06, Rob Church <[hidden email]> wrote:
> >
> > For a good set of pointers on programmatically creating pages, take a
> > look at the InitialiseMessages.inc file in the maintenance dir. It's
> > got a chunk of code which demonstrates how to create a new page and
> > insert it into the database, with revision and text information.
> >
> >
> > Rob Church
> >
> > On 17/02/06, Amruta Lonkar <[hidden email]> wrote:
> > > Hi,
> > > I want to create a page and have some default text for it on the
> > > 'ArticleSaveComplete' event. For this i ma inserting information into
> > the
> > > page, revision and text table. I am enetring the default text into the
> > text
> > > table. I do  not know how to get the length of the page (that is the
> > default
> > > text) to inset it into the page table. Will this actually create a page
> > for
> > > it or do i need ot call Article class for the same?
> > >
> > > Thanks,
> > > Amruta
> > > _______________________________________________
> > > MediaWiki-l mailing list
> > > [hidden email]
> > > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> > >
> > _______________________________________________
> > MediaWiki-l mailing list
> > [hidden email]
> > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> >
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Page Table

Amruta Lonkar-2
I think i can understand it now. So will the $messsageArray used in the
function store my default text to be shown on the page?

-Amruta


On 2/17/06, Rob Church <[hidden email]> wrote:

>
> No, a lot of the stuff in that file you can ignore. For instance, you
> aren't going to need to disable $wgOut or fake your $wgUser values.
> Concentrate on the bits that instantiate the article class, and the
> revision classes, and use the insertOn and updateTo methods.
>
>
> Rob Church
>
> On 17/02/06, Amruta Lonkar <[hidden email]> wrote:
> > I guess its the initialiseMessagesReal function right in the file you
> > mentioned? I have one question though. Is it necessary to do all the
> > diabling functions that have been done in it for creating the pages that
> i
> > want to create. There is a lot of code in that function and i cant
> exactly
> > figure out how to use it to code for a new namespace, page and default
> text.
> >
> > -Amruta
> >
> >
> > On 2/17/06, Rob Church <[hidden email]> wrote:
> > >
> > > For a good set of pointers on programmatically creating pages, take a
> > > look at the InitialiseMessages.inc file in the maintenance dir. It's
> > > got a chunk of code which demonstrates how to create a new page and
> > > insert it into the database, with revision and text information.
> > >
> > >
> > > Rob Church
> > >
> > > On 17/02/06, Amruta Lonkar <[hidden email]> wrote:
> > > > Hi,
> > > > I want to create a page and have some default text for it on the
> > > > 'ArticleSaveComplete' event. For this i ma inserting information
> into
> > > the
> > > > page, revision and text table. I am enetring the default text into
> the
> > > text
> > > > table. I do  not know how to get the length of the page (that is the
> > > default
> > > > text) to inset it into the page table. Will this actually create a
> page
> > > for
> > > > it or do i need ot call Article class for the same?
> > > >
> > > > Thanks,
> > > > Amruta
> > > > _______________________________________________
> > > > MediaWiki-l mailing list
> > > > [hidden email]
> > > > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> > > >
> > > _______________________________________________
> > > MediaWiki-l mailing list
> > > [hidden email]
> > > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> > >
> > _______________________________________________
> > MediaWiki-l mailing list
> > [hidden email]
> > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> >
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Page Table

Rob Church
Well, you customise what actually goes in the revision data according
to what you really want.


Rob Church

On 17/02/06, Amruta Lonkar <[hidden email]> wrote:

> I think i can understand it now. So will the $messsageArray used in the
> function store my default text to be shown on the page?
>
> -Amruta
>
>
> On 2/17/06, Rob Church <[hidden email]> wrote:
> >
> > No, a lot of the stuff in that file you can ignore. For instance, you
> > aren't going to need to disable $wgOut or fake your $wgUser values.
> > Concentrate on the bits that instantiate the article class, and the
> > revision classes, and use the insertOn and updateTo methods.
> >
> >
> > Rob Church
> >
> > On 17/02/06, Amruta Lonkar <[hidden email]> wrote:
> > > I guess its the initialiseMessagesReal function right in the file you
> > > mentioned? I have one question though. Is it necessary to do all the
> > > diabling functions that have been done in it for creating the pages that
> > i
> > > want to create. There is a lot of code in that function and i cant
> > exactly
> > > figure out how to use it to code for a new namespace, page and default
> > text.
> > >
> > > -Amruta
> > >
> > >
> > > On 2/17/06, Rob Church <[hidden email]> wrote:
> > > >
> > > > For a good set of pointers on programmatically creating pages, take a
> > > > look at the InitialiseMessages.inc file in the maintenance dir. It's
> > > > got a chunk of code which demonstrates how to create a new page and
> > > > insert it into the database, with revision and text information.
> > > >
> > > >
> > > > Rob Church
> > > >
> > > > On 17/02/06, Amruta Lonkar <[hidden email]> wrote:
> > > > > Hi,
> > > > > I want to create a page and have some default text for it on the
> > > > > 'ArticleSaveComplete' event. For this i ma inserting information
> > into
> > > > the
> > > > > page, revision and text table. I am enetring the default text into
> > the
> > > > text
> > > > > table. I do  not know how to get the length of the page (that is the
> > > > default
> > > > > text) to inset it into the page table. Will this actually create a
> > page
> > > > for
> > > > > it or do i need ot call Article class for the same?
> > > > >
> > > > > Thanks,
> > > > > Amruta
> > > > > _______________________________________________
> > > > > MediaWiki-l mailing list
> > > > > [hidden email]
> > > > > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> > > > >
> > > > _______________________________________________
> > > > MediaWiki-l mailing list
> > > > [hidden email]
> > > > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> > > >
> > > _______________________________________________
> > > MediaWiki-l mailing list
> > > [hidden email]
> > > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> > >
> > _______________________________________________
> > MediaWiki-l mailing list
> > [hidden email]
> > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> >
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Page Table

Hugh Prior
In reply to this post by Amruta Lonkar-2
I have created a little function (I think based on the same stuff Rob Church
suggested a while back) which does what I need in terms of creating a page
calling other existing stuff.  I offer it here for whatever use you can make
of it:

 /**
  * Create a wiki page
  */
 function createWikiPage($wikiPageName, $pageText="(Page text default in
createWikiPage)") {
  $dbw =& wfGetDB( DB_MASTER );

  # Process each message
  $title = new Title();
  $title = $title->newFromText($wikiPageName);

  $article = new Article( $title );
  $newid = $article->insertOn( $dbw );
  # FIXME: set restrictions
  $revision = new Revision( array(
  'page'      => $newid,
  'text'      => $pageText,
  'user'      => 0,
  'user_text' => "This page automatically created by ".__FILE__,
  'comment'   => '',
  ) );
  $revid = $revision->insertOn( $dbw );
  $article->updateRevisionOn( $dbw, $revision );

  $dbw->commit();

  return $revid;
 }
 



_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Page Table

Amruta Lonkar
Thanks to both of you for your help. I will try it out and see. Thanks!


Quoting Hugh Prior <[hidden email]>:

> I have created a little function (I think based on the same stuff Rob Church
> suggested a while back) which does what I need in terms of creating a page
> calling other existing stuff.  I offer it here for whatever use you can make
> of it:
>
>  /**
>   * Create a wiki page
>   */
>  function createWikiPage($wikiPageName, $pageText="(Page text default in
> createWikiPage)") {
>   $dbw =& wfGetDB( DB_MASTER );
>
>   # Process each message
>   $title = new Title();
>   $title = $title->newFromText($wikiPageName);
>
>   $article = new Article( $title );
>   $newid = $article->insertOn( $dbw );
>   # FIXME: set restrictions
>   $revision = new Revision( array(
>   'page'      => $newid,
>   'text'      => $pageText,
>   'user'      => 0,
>   'user_text' => "This page automatically created by ".__FILE__,
>   'comment'   => '',
>   ) );
>   $revid = $revision->insertOn( $dbw );
>   $article->updateRevisionOn( $dbw, $revision );
>
>   $dbw->commit();
>
>   return $revid;
>  }
>
>
>
>
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>


--
Amruta
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Page Table

Amruta Lonkar-2
In reply to this post by Hugh Prior
So is it not ecessary to insert anything in the page table?. You return the
$revid in your code, will that be necessary if i just want to create a page
with the text?

Thanks,
Amruta


On 2/17/06, Hugh Prior <[hidden email]> wrote:

>
> I have created a little function (I think based on the same stuff Rob
> Church
> suggested a while back) which does what I need in terms of creating a page
> calling other existing stuff.  I offer it here for whatever use you can
> make
> of it:
>
> /**
> * Create a wiki page
> */
> function createWikiPage($wikiPageName, $pageText="(Page text default in
> createWikiPage)") {
> $dbw =& wfGetDB( DB_MASTER );
>
> # Process each message
> $title = new Title();
> $title = $title->newFromText($wikiPageName);
>
> $article = new Article( $title );
> $newid = $article->insertOn( $dbw );
> # FIXME: set restrictions
> $revision = new Revision( array(
> 'page'      => $newid,
> 'text'      => $pageText,
> 'user'      => 0,
> 'user_text' => "This page automatically created by ".__FILE__,
> 'comment'   => '',
> ) );
> $revid = $revision->insertOn( $dbw );
> $article->updateRevisionOn( $dbw, $revision );
>
> $dbw->commit();
>
> return $revid;
> }
>
>
>
>
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Page Table

Amruta Lonkar-2
I forgot to type this in the previous mail. Also i am trying to add the page
to a specific namespace . Can you suggest what i need to add to your code to
do that?

On 2/17/06, Amruta Lonkar <[hidden email]> wrote:

>
> So is it not ecessary to insert anything in the page table?. You return
> the $revid in your code, will that be necessary if i just want to create a
> page with the text?
>
> Thanks,
> Amruta
>
>
>  On 2/17/06, Hugh Prior <[hidden email]> wrote:
> >
> > I have created a little function (I think based on the same stuff Rob
> > Church
> > suggested a while back) which does what I need in terms of creating a
> > page
> > calling other existing stuff.  I offer it here for whatever use you can
> > make
> > of it:
> >
> > /**
> > * Create a wiki page
> > */
> > function createWikiPage($wikiPageName, $pageText="(Page text default in
> > createWikiPage)") {
> > $dbw =& wfGetDB( DB_MASTER );
> >
> > # Process each message
> > $title = new Title();
> > $title = $title->newFromText($wikiPageName);
> >
> > $article = new Article( $title );
> > $newid = $article->insertOn( $dbw );
> > # FIXME: set restrictions
> > $revision = new Revision( array(
> > 'page'      => $newid,
> > 'text'      => $pageText,
> > 'user'      => 0,
> > 'user_text' => "This page automatically created by ".__FILE__,
> > 'comment'   => '',
> > ) );
> > $revid = $revision->insertOn( $dbw );
> > $article->updateRevisionOn( $dbw, $revision );
> >
> > $dbw->commit();
> >
> > return $revid;
> > }
> >
> >
> >
> >
> > _______________________________________________
> > MediaWiki-l mailing list
> > [hidden email]
> > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> >
>
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Page Table

Rob Church
In reply to this post by Amruta Lonkar-2
Using the built-in methods, you'll automatically create a new article,
save it, then create and save a new revision, then update the article
to point to the correct revision; you don't, in fact, need to touch
the database in manual fashion at all.


Rob Church

On 17/02/06, Amruta Lonkar <[hidden email]> wrote:

> So is it not ecessary to insert anything in the page table?. You return the
> $revid in your code, will that be necessary if i just want to create a page
> with the text?
>
> Thanks,
> Amruta
>
>
> On 2/17/06, Hugh Prior <[hidden email]> wrote:
> >
> > I have created a little function (I think based on the same stuff Rob
> > Church
> > suggested a while back) which does what I need in terms of creating a page
> > calling other existing stuff.  I offer it here for whatever use you can
> > make
> > of it:
> >
> > /**
> > * Create a wiki page
> > */
> > function createWikiPage($wikiPageName, $pageText="(Page text default in
> > createWikiPage)") {
> > $dbw =& wfGetDB( DB_MASTER );
> >
> > # Process each message
> > $title = new Title();
> > $title = $title->newFromText($wikiPageName);
> >
> > $article = new Article( $title );
> > $newid = $article->insertOn( $dbw );
> > # FIXME: set restrictions
> > $revision = new Revision( array(
> > 'page'      => $newid,
> > 'text'      => $pageText,
> > 'user'      => 0,
> > 'user_text' => "This page automatically created by ".__FILE__,
> > 'comment'   => '',
> > ) );
> > $revid = $revision->insertOn( $dbw );
> > $article->updateRevisionOn( $dbw, $revision );
> >
> > $dbw->commit();
> >
> > return $revid;
> > }
> >
> >
> >
> >
> > _______________________________________________
> > MediaWiki-l mailing list
> > [hidden email]
> > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> >
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Page Table

Hugh Prior
In reply to this post by Amruta Lonkar-2
There's nothing different in creating a page in a different namespace.  All
you do is pass the title with the namespace prefix.  So, you use, say
"Category:Alpha" as the title instead of "Alpha".

"Amruta Lonkar" <[hidden email]> wrote in
message news:[hidden email]...
>I forgot to type this in the previous mail. Also i am trying to add the
>page
> to a specific namespace . Can you suggest what i need to add to your code
> to
> do that?



_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Page Table

Rob Church
In reply to this post by Amruta Lonkar-2
When passing the title to the article, use the appropriate function to
build a title given the namespace number and title text, e.g.

$article = new Article( Title::makeTitle( $namespace, $title ) );


Rob Church

On 17/02/06, Amruta Lonkar <[hidden email]> wrote:

> I forgot to type this in the previous mail. Also i am trying to add the page
> to a specific namespace . Can you suggest what i need to add to your code to
> do that?
>
> On 2/17/06, Amruta Lonkar <[hidden email]> wrote:
> >
> > So is it not ecessary to insert anything in the page table?. You return
> > the $revid in your code, will that be necessary if i just want to create a
> > page with the text?
> >
> > Thanks,
> > Amruta
> >
> >
> >  On 2/17/06, Hugh Prior <[hidden email]> wrote:
> > >
> > > I have created a little function (I think based on the same stuff Rob
> > > Church
> > > suggested a while back) which does what I need in terms of creating a
> > > page
> > > calling other existing stuff.  I offer it here for whatever use you can
> > > make
> > > of it:
> > >
> > > /**
> > > * Create a wiki page
> > > */
> > > function createWikiPage($wikiPageName, $pageText="(Page text default in
> > > createWikiPage)") {
> > > $dbw =& wfGetDB( DB_MASTER );
> > >
> > > # Process each message
> > > $title = new Title();
> > > $title = $title->newFromText($wikiPageName);
> > >
> > > $article = new Article( $title );
> > > $newid = $article->insertOn( $dbw );
> > > # FIXME: set restrictions
> > > $revision = new Revision( array(
> > > 'page'      => $newid,
> > > 'text'      => $pageText,
> > > 'user'      => 0,
> > > 'user_text' => "This page automatically created by ".__FILE__,
> > > 'comment'   => '',
> > > ) );
> > > $revid = $revision->insertOn( $dbw );
> > > $article->updateRevisionOn( $dbw, $revision );
> > >
> > > $dbw->commit();
> > >
> > > return $revid;
> > > }
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > MediaWiki-l mailing list
> > > [hidden email]
> > > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> > >
> >
> >
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l