r91462 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91461‎ | r91462 | r91463 >
Date:16:32, 5 July 2011
Author:ankitgarg833
Status:deferred
Tags:
Comment:
re-structuring the code.Moving the logic to the Hook code.
passing the complete PSSchema obj to the hook.
Modified paths:
  • /trunk/extensions/PageSchemas/PageSchemas.classes.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageSchemas/PageSchemas.classes.php
@@ -111,7 +111,7 @@
112112 function __construct ( $category_name ) {
113113 $this->categoryName = $category_name;
114114 $title = Title::newFromText( $category_name, NS_CATEGORY );
115 - $pageId = $title->getArticleID();
 115+ $this->pageId = $title->getArticleID();
116116 $dbr = wfGetDB( DB_SLAVE );
117117 //get the result set, query : slect page_props
118118 $res = $dbr->select( 'page_props',
@@ -121,17 +121,14 @@
122122 'pp_value'
123123 ),
124124 array(
125 - 'pp_page' => $pageId,
 125+ 'pp_page' => $this->pageId,
126126 'pp_propname' => 'PageSchema'
127127 )
128128 );
129 -
130129 //first row of the result set
131130 $row = $dbr->fetchRow( $res );
132 -
133131 //retrievimg the third attribute which is pp_value
134132 $pageXmlstr = $row[2];
135 -
136133 $pageXml = simplexml_load_string ( $pageXmlstr );
137134 $this->pageName = (string)$pageXml->attributes()->name;
138135 /* index for template objects */
@@ -145,46 +142,15 @@
146143 $this->formName = (string)$child;
147144 }
148145 }
149 -
150146 }
151 -
152147 /* function to generate all pages based on the Xml contained in the page */
153 - function generateAllPages () {
154 - //Get templates
155 - $template_all = $this->getTemplates();
156 - /*obj. to create form Page */
157 - $form_templates = array();
158 - $genFormObj = array();
159 - foreach ( $template_all as $template ) {
160 - $template_array = array();
161 - $template_array['name'] = $template->getName();
162 - $template_array['category_name'] = $this->categoryName;
163 - $field_all = $template->getFields();
164 - $genPageObject = array();
165 - $field_count = 0; //counts the number of fields
166 - foreach( $field_all as $field ) { //for each Field, retrieve smw properties and fill $prop_name , $prop_type
167 - $field_count++;
168 - $prop_array = $field->getObject('Property'); //this returns an array with property values filled
169 - $genPageObject['Property'] = $prop_array;
170 - $template_array['Field'.$field_count] = $field;
171 - $form_input_array = $field->getObject('FormInput'); //this returns an array with property values filled
172 - $genPageObject['FormInput'] = $form_input_array;
173 - wfRunHooks( 'PageSchemasGeneratePages', array( $genPageObject ));
174 - }
175 - $genPageObject['Template'] = $template_array ;
176 - wfRunHooks( 'PageSchemasGeneratePages', array( $genPageObject ));
177 - $form_templates[] = $template_array;
178 - }
179 - $genFormObj['Form'] = $form_templates;
180 - $genFormObj['FormName'] = $this->getFormName();
181 - wfRunHooks( 'PageSchemasGeneratePages', array( $genFormObj ));
 148+ function generateAllPages () {
 149+ wfRunHooks( 'PageSchemasGeneratePages', array( $this ));
182150 }
183 -
184151 /*return an array of PSTemplate Objects */
185152 function getTemplates () {
186153 return $this->PSTemplates;
187 - }
188 -
 154+ }
189155 /*returns the name of the PageSchema object */
190156 function getName(){
191157 return $this->pageName;
@@ -192,6 +158,10 @@
193159 function getFormName(){
194160 return $this->formName;
195161 }
 162+ function getCategoryName(){
 163+ return $this->categoryName;
 164+ }
 165+
196166 }
197167 class PSTemplate {
198168 /* Stores the field objects */

Status & tagging log