Index: trunk/extensions/SemanticForms/specials/SF_AddData.php |
— | — | @@ -23,8 +23,8 @@ |
24 | 24 | // if query string did not contain these variables, try the URL |
25 | 25 | if (! $form_name && ! $target_name) { |
26 | 26 | $queryparts = explode('/', $query, 2); |
27 | | - $form_name = $queryparts[0]; |
28 | | - $target_name = $queryparts[1]; |
| 27 | + $form_name = isset($queryparts[0]) ? $queryparts[0] : ''; |
| 28 | + $target_name = isset($queryparts[1]) ? $queryparts[1] : ''; |
29 | 29 | } |
30 | 30 | |
31 | 31 | // get contents of template |
— | — | @@ -34,8 +34,9 @@ |
35 | 35 | |
36 | 36 | // target_title should be null - we shouldn't be adding a page that |
37 | 37 | // already exists |
38 | | - // TODO - handle this contingency |
39 | 38 | if ($target_title && $target_title->exists()) { |
| 39 | + $wgOut->addWikiText( "<p class='error'>" . wfMsg('articleexists') . '</p>'); |
| 40 | + return; |
40 | 41 | } else { |
41 | 42 | $page_title = str_replace('_', ' ', $target_name); |
42 | 43 | } |
— | — | @@ -94,6 +95,7 @@ |
95 | 96 | )); |
96 | 97 | $wgOut->addScript('<script src="' . $sfgScriptPath . '/libs/scriptaculous-js-1.7.0/lib/prototype.js" type="text/javascript"></script>' . "\n"); |
97 | 98 | $wgOut->addScript(' <script src="' . $sfgScriptPath . '/libs/scriptaculous-js-1.7.0/src/scriptaculous.js" type="text/javascript"></script>' . "\n"); |
98 | | - $wgOut->addScript(' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n"); |
| 99 | + if (! empty($javascript_text)) |
| 100 | + $wgOut->addScript(' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n"); |
99 | 101 | $wgOut->addHTML($text); |
100 | 102 | } |
Index: trunk/extensions/SemanticForms/specials/SF_Forms.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | |
38 | 38 | function getSQL() { |
39 | 39 | $NSform = SF_NS_FORM; |
40 | | - $dbr =& wfGetDB( DB_SLAVE ); |
| 40 | + $dbr = wfGetDB( DB_SLAVE ); |
41 | 41 | $page = $dbr->tableName( 'page' ); |
42 | 42 | // QueryPage uses the value from this SQL in an ORDER clause, |
43 | 43 | // so return page_title as title. |
Index: trunk/extensions/SemanticForms/specials/SF_CreateForm.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | |
10 | 10 | if (!defined('MEDIAWIKI')) die(); |
11 | 11 | |
12 | | -global $IP; |
| 12 | +global $IP, $sfgIP; |
13 | 13 | require_once( "$IP/includes/SpecialPage.php" ); |
14 | 14 | require_once( "$sfgIP/includes/SF_FormClasses.inc" ); |
15 | 15 | |
— | — | @@ -16,8 +16,7 @@ |
17 | 17 | |
18 | 18 | function doSpecialCreateForm() { |
19 | 19 | global $wgOut, $wgRequest, $wgUser; |
20 | | - $fname = "CreateForm::doSpecialCreateForm()"; |
21 | | - $db =& wfGetDB( DB_SLAVE ); |
| 20 | + $db = wfGetDB( DB_SLAVE ); |
22 | 21 | |
23 | 22 | # get the names of all templates on this site |
24 | 23 | $all_templates = array(); |
— | — | @@ -37,18 +36,21 @@ |
38 | 37 | # handle inputs |
39 | 38 | $form_name = $wgRequest->getVal('form_name'); |
40 | 39 | foreach ($wgRequest->getValues() as $var => $val) { |
41 | | - # get the template declarations and work from there |
42 | | - list ($action, $id) = explode("_", $var); |
43 | | - if ($action == "template") { |
44 | | - # if the button was pressed to remove this template, just don't |
45 | | - # add it to the array |
46 | | - if ($wgRequest->getVal("del_$id") != "Remove template") { |
47 | | - $form_template = SFTemplateInForm::create($val, |
48 | | - $wgRequest->getVal("label_$id"), |
49 | | - $wgRequest->getVal("allow_multiple_$id")); |
50 | | - $form_templates[] = $form_template; |
51 | | - } else { |
52 | | - $deleted_template_loc = $id; |
| 40 | + # ignore variables that are not of the right form |
| 41 | + if (strpos($var, "_") != false) { |
| 42 | + # get the template declarations and work from there |
| 43 | + list ($action, $id) = explode("_", $var, 2); |
| 44 | + if ($action == "template") { |
| 45 | + # if the button was pressed to remove this template, just don't |
| 46 | + # add it to the array |
| 47 | + if ($wgRequest->getVal("del_$id") != "Remove template") { |
| 48 | + $form_template = SFTemplateInForm::create($val, |
| 49 | + $wgRequest->getVal("label_$id"), |
| 50 | + $wgRequest->getVal("allow_multiple_$id")); |
| 51 | + $form_templates[] = $form_template; |
| 52 | + } else { |
| 53 | + $deleted_template_loc = $id; |
| 54 | + } |
53 | 55 | } |
54 | 56 | } |
55 | 57 | } |
— | — | @@ -127,7 +129,10 @@ |
128 | 130 | $text .= ' <form action="" method="get">' . "\n"; |
129 | 131 | // set 'title' field, in case there's no URL niceness |
130 | 132 | $text .= ' <input type="hidden" name="title" value="Special:CreateForm">' . "\n"; |
131 | | - $text .= ' <p>' . wfMsg('sf_createform_nameinput') . ' <input size=25 name="form_name" value="' . $form_name . '"> <font color="red">' . $form_name_error_str . '</font></p>' . "\n"; |
| 133 | + $text .= ' <p>' . wfMsg('sf_createform_nameinput') . ' <input size=25 name="form_name" value="' . $form_name . '">'; |
| 134 | + if (! empty($form_name_error_str)) |
| 135 | + $text .= ' <font color="red">' . $form_name_error_str . '</font>'; |
| 136 | + $text .= "</p>\n"; |
132 | 137 | |
133 | 138 | $text .= $form->creationHTML(); |
134 | 139 | |
Index: trunk/extensions/SemanticForms/specials/SF_Templates.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | |
38 | 38 | function getSQL() { |
39 | 39 | $NStemp = NS_TEMPLATE; |
40 | | - $dbr =& wfGetDB( DB_SLAVE ); |
| 40 | + $dbr = wfGetDB( DB_SLAVE ); |
41 | 41 | $page = $dbr->tableName( 'page' ); |
42 | 42 | // QueryPage uses the value from this SQL in an ORDER clause, |
43 | 43 | // so return page_title as title. |
Index: trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | } |
29 | 29 | } |
30 | 30 | function getSemanticProperties() { |
31 | | - $dbr =& wfGetDB( DB_SLAVE ); |
| 31 | + $dbr = wfGetDB( DB_SLAVE ); |
32 | 32 | $all_properties = array(); |
33 | 33 | |
34 | 34 | $res = $dbr->query("SELECT page_title FROM " . $dbr->tableName('page') . |
Index: trunk/extensions/SemanticForms/includes/SF_TemplateField.inc |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | // this whole section of code could be made much simpler if it were |
32 | 32 | // to use the SMWTypeHandlerFactory class; but that would mean it |
33 | 33 | // would require SMW 0.7, which it might be too early for |
34 | | - $db =& wfGetDB( DB_SLAVE ); |
| 34 | + $db = wfGetDB( DB_SLAVE ); |
35 | 35 | // value has underscores in the database |
36 | 36 | $semantic_field_db_str = str_replace(' ', '_', $f->semantic_field); |
37 | 37 | $conditions = "subject_namespace = " . SMW_NS_ATTRIBUTE . " AND subject_title = '$semantic_field_db_str' AND property_id = 1"; |
Index: trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * @author Yaron Koren |
7 | 7 | */ |
8 | 8 | |
9 | | -define('SF_VERSION','0.5.3'); |
| 9 | +define('SF_VERSION','0.5.4'); |
10 | 10 | |
11 | 11 | $wgExtensionFunctions[] = 'sfgSetupExtension'; |
12 | 12 | $wgExtensionFunctions[] = 'sfgParserFunctions'; |
— | — | @@ -222,7 +222,7 @@ |
223 | 223 | // get all relations that have this page as an object, |
224 | 224 | // and see if any of them have a default form specified |
225 | 225 | $fname = 'sffAddDataLink'; |
226 | | - $db =& wfGetDB( DB_SLAVE ); |
| 226 | + $db = wfGetDB( DB_SLAVE ); |
227 | 227 | $sql = "SELECT DISTINCT relation_title FROM {$db->tableName('smw_relations')} WHERE object_title = '" . $db->strencode($title->getDBkey()) . "' AND object_namespace = '" . $title->getNamespace() . "'"; |
228 | 228 | $res = $db->query( $sql ); |
229 | 229 | if ($db->numRows( $res ) > 0) { |
— | — | @@ -244,7 +244,7 @@ |
245 | 245 | |
246 | 246 | function sffFormDropdownHTML() { |
247 | 247 | // create a dropdown of possible form names |
248 | | - $dbr =& wfGetDB( DB_SLAVE ); |
| 248 | + $dbr = wfGetDB( DB_SLAVE ); |
249 | 249 | $query = "SELECT page_title FROM " . $dbr->tableName( 'page' ) . |
250 | 250 | " WHERE page_namespace = " . SF_NS_FORM . |
251 | 251 | " AND page_is_redirect = 0"; |
Index: trunk/extensions/SemanticForms/includes/SF_FormEditTab.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | $fname = 'SFFormEditTab::getCategoriesForArticle()'; |
12 | 12 | $categories = array(); |
13 | 13 | $titlekey = $article->mTitle->getArticleId(); |
14 | | - $db =& wfGetDB( DB_SLAVE ); |
| 14 | + $db = wfGetDB( DB_SLAVE ); |
15 | 15 | $conditions = "cl_from='$titlekey'"; |
16 | 16 | $res = $db->select( $db->tableName('categorylinks'), |
17 | 17 | 'cl_to', |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | */ |
33 | 33 | function sffFormEditTab($obj, $content_actions) { |
34 | 34 | $fname = 'SFFormEditTab'; |
35 | | - $db =& wfGetDB( DB_SLAVE ); |
| 35 | + $db = wfGetDB( DB_SLAVE ); |
36 | 36 | // make sure that this is not itself a category page, and that the user |
37 | 37 | // is allowed to edit it |
38 | 38 | if (($obj->mTitle != null) && ($obj->mTitle->getNamespace() != NS_CATEGORY)) { |