r91745 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91744‎ | r91745 | r91746 >
Date:18:42, 8 July 2011
Author:ankitgarg833
Status:deferred
Tags:
Comment:
adding support for list of pages to be generated as check-box list.
USer can choose the pages to be generted
modified generate_pages and related functions.
Modified paths:
  • /trunk/extensions/PageSchemas/specials/GeneratePages.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageSchemas/specials/GeneratePages.php
@@ -18,9 +18,8 @@
1919 $generate_page_desc = wfMsg( 'ps-generate-pages-desc' );
2020 $param = $wgRequest->getText('param');
2121 $text_1 = '<p>All pages will be generated! </p>';
22 - $text_2 = '<p>'.$generate_page_desc.'</p> <form method="post"> <input type="hidden" name="param" value="'.$category.'" /><br /> <input type="submit" value="'.$generate_page_text.'" /> </form>';
23 - if ( $param != "" && $category != "" ) {
24 - $this->generate_pages($param);
 22+ if ( $param != "" && $category != "" ) {
 23+ $this->generate_pages( $param, $_POST['page'] );
2524 $wgOut->addHTML($text_1);
2625 }else {
2726 if( $category == ""){
@@ -69,25 +68,30 @@
7069 'pp_page' => $pageId,
7170 'pp_propname' => 'PageSchema'
7271 )
73 - );
 72+ );
7473 //first row of the result set
7574 $row = $dbr->fetchRow( $res );
7675 if( $row != null ){
 76+ $text_2 = '<p>'.$generate_page_desc.'</p> <form method="post"> <input type="hidden" name="param" value="'.$category.'" /><br /> ';
 77+ //add code to generate a list of check-box for pages to be generated.
 78+ $pageSchemaObj = new PSSchema( $category );
 79+ $pageList = array();
 80+ wfRunHooks( 'PageSchemasGetPageList', array( $pageSchemaObj, &$pageList )); //will return an array of string, with each value as a title of the page to be created.
 81+ foreach( $pageList as $page ){
 82+ $text_2 .= '<input type="checkbox" name="page[]" value="'.$page.'" /> '.$page.' <br />';
 83+ }
 84+ $text_2 .= '<br /> <input type="submit" value="'.$generate_page_text.'" /> <br /> <br /></form>';
7785 $wgOut->addHTML($text_2);
7886 }else {
7987 $text = "<p>Error: there is no page schema defined for that category in the wiki. </p>";
8088 $wgOut->addHTML( $text );
81 - }
 89+ }
8290 }
83 -
84 - }
85 - }
86 -
87 - function generate_pages ( $categoryName ) {
88 - global $wgRequest, $wgOut;
 91+ }
 92+ }
 93+ function generate_pages ( $categoryName, $toGenPageList ) {
 94+ global $wgRequest, $wgOut;
8995 $pageSchema = new PSSchema( $categoryName );
90 - $pageSchema->generateAllPages();
91 -
92 -
93 - }
94 -}
\ No newline at end of file
 96+ $pageSchema->generateAllPages( $toGenPageList );
 97+ }
 98+}

Status & tagging log