Index: trunk/extensions/SemanticForms/specials/SF_CreateCategory.php |
— | — | @@ -8,11 +8,22 @@ |
9 | 9 | |
10 | 10 | if (!defined('MEDIAWIKI')) die(); |
11 | 11 | |
12 | | -global $IP; |
13 | | -require_once( "$IP/includes/SpecialPage.php" ); |
| 12 | +class SFCreateCategory extends SpecialPage { |
14 | 13 | |
15 | | -SpecialPage::addPage( new SpecialPage('CreateCategory','',true,'doSpecialCreateCategory',false) ); |
| 14 | + /** |
| 15 | + * Constructor |
| 16 | + */ |
| 17 | + function SFCreateCategory() { |
| 18 | + SpecialPage::SpecialPage('CreateCategory'); |
| 19 | + wfLoadExtensionMessages('SemanticForms'); |
| 20 | + } |
16 | 21 | |
| 22 | + function execute() { |
| 23 | + $this->setHeaders(); |
| 24 | + doSpecialCreateCategory(); |
| 25 | + } |
| 26 | +} |
| 27 | + |
17 | 28 | function createCategoryText($default_form, $category_name, $parent_category) { |
18 | 29 | global $sfgContLang; |
19 | 30 | |
Index: trunk/extensions/SemanticForms/specials/SF_AddData.php |
— | — | @@ -6,30 +6,34 @@ |
7 | 7 | */ |
8 | 8 | if (!defined('MEDIAWIKI')) die(); |
9 | 9 | |
10 | | -global $sfgIP; |
11 | | -require_once( $sfgIP . "/includes/SF_FormPrinter.inc" ); |
| 10 | +class SFAddData extends SpecialPage { |
12 | 11 | |
13 | | -global $IP; |
14 | | -require_once( "$IP/includes/SpecialPage.php" ); |
| 12 | + /** |
| 13 | + * Constructor |
| 14 | + */ |
| 15 | + function SFAddData() { |
| 16 | + SpecialPage::SpecialPage('AddData'); |
| 17 | + wfLoadExtensionMessages('SemanticForms'); |
| 18 | + } |
15 | 19 | |
16 | | -SpecialPage::addPage( new SpecialPage('AddData','',true,'doSpecialAddData',false) ); |
| 20 | + function execute($query = '') { |
| 21 | + global $wgRequest; |
17 | 22 | |
18 | | -function doSpecialAddData($query = '') { |
19 | | - global $wgRequest; |
| 23 | + $this->setHeaders(); |
| 24 | + $form_name = $wgRequest->getVal('form'); |
| 25 | + $target_name = $wgRequest->getVal('target'); |
20 | 26 | |
21 | | - $form_name = $wgRequest->getVal('form'); |
22 | | - $target_name = $wgRequest->getVal('target'); |
| 27 | + // if query string did not contain these variables, try the URL |
| 28 | + if (! $form_name && ! $target_name) { |
| 29 | + $queryparts = explode('/', $query, 2); |
| 30 | + $form_name = isset($queryparts[0]) ? $queryparts[0] : ''; |
| 31 | + $target_name = isset($queryparts[1]) ? $queryparts[1] : ''; |
| 32 | + } |
23 | 33 | |
24 | | - // if query string did not contain these variables, try the URL |
25 | | - if (! $form_name && ! $target_name) { |
26 | | - $queryparts = explode('/', $query, 2); |
27 | | - $form_name = isset($queryparts[0]) ? $queryparts[0] : ''; |
28 | | - $target_name = isset($queryparts[1]) ? $queryparts[1] : ''; |
| 34 | + $alt_forms = $wgRequest->getArray('alt_form'); |
| 35 | + |
| 36 | + printAddForm($form_name, $target_name, $alt_forms); |
29 | 37 | } |
30 | | - |
31 | | - $alt_forms = $wgRequest->getArray('alt_form'); |
32 | | - |
33 | | - printAddForm($form_name, $target_name, $alt_forms); |
34 | 38 | } |
35 | 39 | |
36 | 40 | function printAltFormsList($alt_forms, $target_name) { |
Index: trunk/extensions/SemanticForms/specials/SF_AddPage.php |
— | — | @@ -9,11 +9,22 @@ |
10 | 10 | */ |
11 | 11 | if (!defined('MEDIAWIKI')) die(); |
12 | 12 | |
13 | | -global $IP; |
14 | | -require_once( "$IP/includes/SpecialPage.php" ); |
| 13 | +class SFAddPage extends SpecialPage { |
15 | 14 | |
16 | | -SpecialPage::addPage( new SpecialPage('AddPage','',true,'doSpecialAddPage',false) ); |
| 15 | + /** |
| 16 | + * Constructor |
| 17 | + */ |
| 18 | + function SFAddPage() { |
| 19 | + SpecialPage::SpecialPage('AddPage'); |
| 20 | + wfLoadExtensionMessages('SemanticForms'); |
| 21 | + } |
17 | 22 | |
| 23 | + function execute($query = '') { |
| 24 | + $this->setHeaders(); |
| 25 | + doSpecialAddPage($query); |
| 26 | + } |
| 27 | +} |
| 28 | + |
18 | 29 | function doSpecialAddPage($query = '') { |
19 | 30 | global $wgOut, $wgRequest, $sfgScriptPath; |
20 | 31 | |
Index: trunk/extensions/SemanticForms/specials/SF_Forms.php |
— | — | @@ -7,11 +7,24 @@ |
8 | 8 | |
9 | 9 | if (!defined('MEDIAWIKI')) die(); |
10 | 10 | |
11 | | -global $IP; |
12 | | -require_once( "$IP/includes/SpecialPage.php" ); |
| 11 | +class SFForms extends SpecialPage { |
13 | 12 | |
14 | | -SpecialPage::addPage( new SpecialPage('Forms','',true,'doSpecialForms',false) ); |
| 13 | + /** |
| 14 | + * Constructor |
| 15 | + */ |
| 16 | + function SFForms() { |
| 17 | + SpecialPage::SpecialPage('Forms'); |
| 18 | + wfLoadExtensionMessages('SemanticForms'); |
| 19 | + } |
15 | 20 | |
| 21 | + function execute() { |
| 22 | + $this->setHeaders(); |
| 23 | + list( $limit, $offset ) = wfCheckLimits(); |
| 24 | + $rep = new FormsPage(); |
| 25 | + return $rep->doQuery( $offset, $limit ); |
| 26 | + } |
| 27 | +} |
| 28 | + |
16 | 29 | class FormsPage extends QueryPage { |
17 | 30 | function getName() { |
18 | 31 | return "Forms"; |
— | — | @@ -57,9 +70,3 @@ |
58 | 71 | return $skin->makeLinkObj( $title, $title->getText() ); |
59 | 72 | } |
60 | 73 | } |
61 | | - |
62 | | -function doSpecialForms() { |
63 | | - list( $limit, $offset ) = wfCheckLimits(); |
64 | | - $rep = new FormsPage(); |
65 | | - return $rep->doQuery( $offset, $limit ); |
66 | | -} |
Index: trunk/extensions/SemanticForms/specials/SF_CreateForm.php |
— | — | @@ -8,12 +8,22 @@ |
9 | 9 | |
10 | 10 | if (!defined('MEDIAWIKI')) die(); |
11 | 11 | |
12 | | -global $IP, $sfgIP; |
13 | | -require_once( "$IP/includes/SpecialPage.php" ); |
14 | | -require_once( "$sfgIP/includes/SF_FormClasses.inc" ); |
| 12 | +class SFCreateForm extends SpecialPage { |
15 | 13 | |
16 | | -SpecialPage::addPage( new SpecialPage('CreateForm','',true,'doSpecialCreateForm',false) ); |
| 14 | + /** |
| 15 | + * Constructor |
| 16 | + */ |
| 17 | + function SFCreateForm() { |
| 18 | + SpecialPage::SpecialPage('CreateForm'); |
| 19 | + wfLoadExtensionMessages('SemanticForms'); |
| 20 | + } |
17 | 21 | |
| 22 | + function execute() { |
| 23 | + $this->setHeaders(); |
| 24 | + doSpecialCreateForm(); |
| 25 | + } |
| 26 | +} |
| 27 | + |
18 | 28 | function doSpecialCreateForm() { |
19 | 29 | global $wgOut, $wgRequest, $wgUser, $sfgScriptPath, $wgContLang; |
20 | 30 | $db = wfGetDB( DB_SLAVE ); |
Index: trunk/extensions/SemanticForms/specials/SF_CreateProperty.php |
— | — | @@ -6,20 +6,24 @@ |
7 | 7 | * @author Yaron Koren |
8 | 8 | */ |
9 | 9 | |
10 | | -/** |
11 | | - * Protect against register_globals vulnerabilities. |
12 | | - * This line must be present before any global variable is referenced. |
13 | | - */ |
14 | 10 | if (!defined('MEDIAWIKI')) die(); |
15 | 11 | |
16 | | -include_once $sfgIP . "/includes/SF_TemplateField.inc"; |
| 12 | +class SFCreateProperty extends SpecialPage { |
17 | 13 | |
| 14 | + /** |
| 15 | + * Constructor |
| 16 | + */ |
| 17 | + function SFCreateProperty() { |
| 18 | + SpecialPage::SpecialPage('CreateProperty'); |
| 19 | + wfLoadExtensionMessages('SemanticForms'); |
| 20 | + } |
18 | 21 | |
19 | | -global $IP; |
20 | | -require_once( "$IP/includes/SpecialPage.php" ); |
| 22 | + function execute() { |
| 23 | + $this->setHeaders(); |
| 24 | + doSpecialCreateProperty(); |
| 25 | + } |
| 26 | +} |
21 | 27 | |
22 | | -SpecialPage::addPage( new SpecialPage('CreateProperty','',true,'doSpecialCreateProperty',false) ); |
23 | | - |
24 | 28 | function createPropertyText($property_type, $allowed_values_str) { |
25 | 29 | global $smwgContLang; |
26 | 30 | |
— | — | @@ -81,7 +85,7 @@ |
82 | 86 | } |
83 | 87 | } |
84 | 88 | |
85 | | - $all_properties = getSemanticProperties(); |
| 89 | + $all_properties = sffGetAllProperties(); |
86 | 90 | $datatype_labels = $smwgContLang->getDatatypeLabels(); |
87 | 91 | |
88 | 92 | $javascript_text =<<<END |
Index: trunk/extensions/SemanticForms/specials/SF_UploadWindow.php |
— | — | @@ -14,11 +14,22 @@ |
15 | 15 | */ |
16 | 16 | if (!defined('MEDIAWIKI')) die(); |
17 | 17 | |
18 | | -global $IP; |
19 | | -require_once( "$IP/includes/SpecialPage.php" ); |
| 18 | +class SFUploadWindow extends SpecialPage { |
20 | 19 | |
21 | | -SpecialPage::addPage( new SpecialPage('UploadWindow','',true,'doSpecialUploadWindow',false) ); |
| 20 | + /** |
| 21 | + * Constructor |
| 22 | + */ |
| 23 | + function SFUploadWindow() { |
| 24 | + SpecialPage::SpecialPage('UploadWindow'); |
| 25 | + wfLoadExtensionMessages('SemanticForms'); |
| 26 | + } |
22 | 27 | |
| 28 | + function execute() { |
| 29 | + $this->setHeaders(); |
| 30 | + doSpecialUploadWindow(); |
| 31 | + } |
| 32 | +} |
| 33 | + |
23 | 34 | /** |
24 | 35 | * Entry point |
25 | 36 | */ |
Index: trunk/extensions/SemanticForms/specials/SF_Templates.php |
— | — | @@ -7,11 +7,24 @@ |
8 | 8 | |
9 | 9 | if (!defined('MEDIAWIKI')) die(); |
10 | 10 | |
11 | | -global $IP; |
12 | | -require_once( "$IP/includes/SpecialPage.php" ); |
| 11 | +class SFTemplates extends SpecialPage { |
13 | 12 | |
14 | | -SpecialPage::addPage( new SpecialPage('Templates','',true,'doSpecialTemplates',false) ); |
| 13 | + /** |
| 14 | + * Constructor |
| 15 | + */ |
| 16 | + function SFTemplates() { |
| 17 | + SpecialPage::SpecialPage('Templates'); |
| 18 | + wfLoadExtensionMessages('SemanticForms'); |
| 19 | + } |
15 | 20 | |
| 21 | + function execute() { |
| 22 | + $this->setHeaders(); |
| 23 | + list( $limit, $offset ) = wfCheckLimits(); |
| 24 | + $rep = new TemplatesPage(); |
| 25 | + return $rep->doQuery( $offset, $limit ); |
| 26 | + } |
| 27 | +} |
| 28 | + |
16 | 29 | class TemplatesPage extends QueryPage { |
17 | 30 | function getName() { |
18 | 31 | return "Templates"; |
— | — | @@ -72,9 +85,3 @@ |
73 | 86 | return $text; |
74 | 87 | } |
75 | 88 | } |
76 | | - |
77 | | -function doSpecialTemplates() { |
78 | | - list( $limit, $offset ) = wfCheckLimits(); |
79 | | - $rep = new TemplatesPage(); |
80 | | - return $rep->doQuery( $offset, $limit ); |
81 | | -} |
Index: trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php |
— | — | @@ -12,49 +12,20 @@ |
13 | 13 | */ |
14 | 14 | if (!defined('MEDIAWIKI')) die(); |
15 | 15 | |
16 | | -include_once $sfgIP . "/includes/SF_TemplateField.inc"; |
| 16 | +class SFCreateTemplate extends SpecialPage { |
17 | 17 | |
18 | | - |
19 | | -global $IP; |
20 | | -require_once( "$IP/includes/SpecialPage.php" ); |
21 | | - |
22 | | -SpecialPage::addPage( new SpecialPage('CreateTemplate','',true,'doSpecialCreateTemplate',false) ); |
23 | | - |
24 | | -// Custom sort function, used in getSemanticProperties() |
25 | | -function cmp($a, $b) { |
26 | | - if ($a == $b) { |
27 | | - return 0; |
28 | | - } elseif ($a < $b) { |
29 | | - return -1; |
30 | | - } else { |
31 | | - return 1; |
| 18 | + /** |
| 19 | + * Constructor |
| 20 | + */ |
| 21 | + function SFCreateTemplate() { |
| 22 | + SpecialPage::SpecialPage('CreateTemplate'); |
| 23 | + wfLoadExtensionMessages('SemanticForms'); |
32 | 24 | } |
33 | | -} |
34 | 25 | |
35 | | -function getSemanticProperties() { |
36 | | - $all_properties = array(); |
37 | | - |
38 | | - // set limit on results - a temporary fix until SMW's getProperties() |
39 | | - // functions stop requiring a limit |
40 | | - global $smwgIP; |
41 | | - include_once($smwgIP . '/includes/storage/SMW_Store.php'); |
42 | | - $options = new SMWRequestOptions(); |
43 | | - $options->limit = 10000; |
44 | | - $used_properties = smwfGetStore()->getPropertiesSpecial($options); |
45 | | - foreach ($used_properties as $property) { |
46 | | - $property_name = $property[0]->getText(); |
47 | | - $all_properties[$property_name . "::"] = $property_name; |
| 26 | + function execute() { |
| 27 | + $this->setHeaders(); |
| 28 | + doSpecialCreateTemplate(); |
48 | 29 | } |
49 | | - $unused_properties = smwfGetStore()->getUnusedPropertiesSpecial($options); |
50 | | - foreach ($unused_properties as $property) { |
51 | | - $property_name = $property->getText(); |
52 | | - $all_properties[$property_name . "::"] = $property_name; |
53 | | - } |
54 | | - |
55 | | - // sort properties list alphabetically - custom sort function is needed |
56 | | - // because the regular sort function destroys the "keys" of the array |
57 | | - uasort($all_properties, "cmp"); |
58 | | - return $all_properties; |
59 | 30 | } |
60 | 31 | |
61 | 32 | function printPropertiesDropdown($all_properties, $id, $property) { |
— | — | @@ -91,7 +62,7 @@ |
92 | 63 | function doSpecialCreateTemplate() { |
93 | 64 | global $wgOut, $wgRequest, $wgUser, $sfgScriptPath, $wgContLang; |
94 | 65 | |
95 | | - $all_properties = getSemanticProperties(); |
| 66 | + $all_properties = sffGetAllProperties(); |
96 | 67 | |
97 | 68 | $template_name = $wgRequest->getVal('template_name'); |
98 | 69 | $template_name_error_str = ""; |
Index: trunk/extensions/SemanticForms/specials/SF_EditData.php |
— | — | @@ -11,14 +11,22 @@ |
12 | 12 | */ |
13 | 13 | if (!defined('MEDIAWIKI')) die(); |
14 | 14 | |
15 | | -require_once( $sfgIP . "/includes/SF_FormPrinter.inc" ); |
| 15 | +class SFEditData extends SpecialPage { |
16 | 16 | |
| 17 | + /** |
| 18 | + * Constructor |
| 19 | + */ |
| 20 | + function SFEditData() { |
| 21 | + SpecialPage::SpecialPage('EditData'); |
| 22 | + wfLoadExtensionMessages('SemanticForms'); |
| 23 | + } |
17 | 24 | |
18 | | -global $IP; |
19 | | -require_once( "$IP/includes/SpecialPage.php" ); |
| 25 | + function execute($query = '') { |
| 26 | + $this->setHeaders(); |
| 27 | + doSpecialEditData($query); |
| 28 | + } |
| 29 | +} |
20 | 30 | |
21 | | -SpecialPage::addPage( new SpecialPage('EditData','',true,'doSpecialEditData',false) ); |
22 | | - |
23 | 31 | function doSpecialEditData($query = '') { |
24 | 32 | global $wgRequest; |
25 | 33 | |
— | — | @@ -35,36 +43,6 @@ |
36 | 44 | printEditForm($form_name, $target_name); |
37 | 45 | } |
38 | 46 | |
39 | | -global $wgHooks; |
40 | | -$wgHooks[ 'UnknownAction' ][] = 'sffEmbeddedEditForm'; |
41 | | - |
42 | | -/** |
43 | | - * The function called if we're in index.php (as opposed to one of the special |
44 | | - * pages) |
45 | | - */ |
46 | | -function sffEmbeddedEditForm($action, $article) { |
47 | | - // for some reason, the code calling the 'UnknownAction' hook wants |
48 | | - // "true" if the hook failed, and "false" otherwise... this is |
49 | | - // probably a bug, but we'll just work with it |
50 | | - if ($action != 'formedit') { |
51 | | - return true; |
52 | | - } |
53 | | - |
54 | | - $form_name = sffGetFormForArticle($article); |
55 | | - if ($form_name == '') { |
56 | | - return true; |
57 | | - } |
58 | | - |
59 | | - $target_title = $article->getTitle(); |
60 | | - $target_name = sffTitleString($target_title); |
61 | | - if ($target_title->exists()) { |
62 | | - printEditForm($form_name, $target_name); |
63 | | - } else { |
64 | | - printAddForm($form_name, $target_name, array()); |
65 | | - } |
66 | | - return false; |
67 | | -} |
68 | | - |
69 | 47 | function printEditForm($form_name, $target_name) { |
70 | 48 | global $wgOut, $wgRequest, $sfgScriptPath, $sfgFormPrinter, $sfgYUIBase; |
71 | 49 | |