Index: trunk/extensions/Wikidata/App.php |
— | — | @@ -153,7 +153,6 @@ |
154 | 154 | |
155 | 155 | # FIXME: Should be renamed to prefix with wd rather than wg. |
156 | 156 | $wgShowClassicPageTitles = false; |
157 | | -$wgDefinedMeaningPageTitlePrefix = ''; |
158 | 157 | $wgExpressionPageTitlePrefix = 'Multiple meanings'; |
159 | 158 | |
160 | 159 | # The site prefix allows us to have multiple sets of customized |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php |
— | — | @@ -11,52 +11,21 @@ |
12 | 12 | global |
13 | 13 | $wgOut, $wgTitle, $wgRequest, $wdCurrentContext; |
14 | 14 | |
15 | | - // Split title into defining expression and ID |
16 | 15 | $titleText = $wgTitle->getText(); |
17 | | - $dmInfo = DefinedMeaningModel::splitTitleText( $titleText ); |
18 | 16 | |
| 17 | + $dmNumber = (int)$titleText ; |
| 18 | + |
19 | 19 | // Title doesn't have an ID in it (or ID 0) |
20 | | - if ( is_null( $dmInfo ) || !$dmInfo["id"] ) { |
| 20 | + if ( !$dmNumber ) { |
21 | 21 | $wgOut->showErrorPage( 'errorpagetitle', 'ow_dm_badtitle' ); |
22 | 22 | return false; |
23 | 23 | } |
24 | 24 | parent::view(); |
25 | | - $definedMeaningModel = new DefinedMeaningModel( $dmInfo["id"], $this->viewInformation ); |
| 25 | + $definedMeaningModel = new DefinedMeaningModel( $dmNumber, $this->viewInformation ); |
26 | 26 | $this->definedMeaningModel = $definedMeaningModel; # TODO if I wasn't so sleepy I'd make this consistent |
27 | 27 | |
28 | | - $copyTo = $wgRequest->getText( 'CopyTo' ); |
29 | | - if ( $copyTo ) { |
30 | | - $definedMeaningModel->copyTo( $copyTo ); |
31 | | - } |
32 | | - |
33 | | - if ( !empty( $dmInfo["expression"] ) ) { |
34 | | - $definedMeaningModel->setDefiningExpression( $dmInfo["expression"] ); |
35 | | - } |
36 | | - |
37 | | - // Search for this DM in all data-sets, beginning with the current one. |
38 | | - // Switch dataset context if found elsewhere. |
| 28 | + // check that the constructed DM actually exists in the database |
39 | 29 | $match = $definedMeaningModel->checkExistence( true, true ); |
40 | | - |
41 | | - // The defining expression is likely incorrect for some reason. Let's just |
42 | | - // try looking up the number. |
43 | | - if ( is_null( $match ) && !empty( $dmInfo["expression"] ) ) { |
44 | | - $definedMeaningModel->setDefiningExpression( null ); |
45 | | - $dmInfo["expression"] = null; |
46 | | - $match = $definedMeaningModel->checkExistence( true, true ); |
47 | | - } |
48 | | - |
49 | | - // The defining expression is either bad or missing. Let's redirect |
50 | | - // to the correct URL. |
51 | | - if ( empty( $dmInfo["expression"] ) && !is_null( $match ) ) { |
52 | | - $definedMeaningModel->loadRecord(); |
53 | | - $title = Title::newFromText( $definedMeaningModel->getWikiTitle() ); |
54 | | - $url = $title->getFullURL(); |
55 | | - $wgOut->disable(); |
56 | | - header( "Location: $url" ); |
57 | | - return false; |
58 | | - } |
59 | | - |
60 | | - // Bad defining expression AND bad ID! :-( |
61 | 30 | if ( is_null( $match ) ) { |
62 | 31 | $wgOut->showErrorPage( 'errorpagetitle', 'ow_dm_missing' ); |
63 | 32 | return false; |
— | — | @@ -76,24 +45,40 @@ |
77 | 46 | $this->outputViewHeader(); |
78 | 47 | // concept panel is annoying and useless |
79 | 48 | // $wgOut->addHTML( $this->getConceptPanel() ); |
| 49 | + $expressionTranslated = definedMeaningExpression( $this->definedMeaningModel->getId() ) ; |
| 50 | + $wgOut->setPageTitle( $wgTitle->getFullText() . " - $expressionTranslated" ) ; |
| 51 | + |
80 | 52 | $editor = getDefinedMeaningEditor( $this->viewInformation ); |
81 | 53 | $idStack = $this->getIdStack( $definedMeaningModel->getId() ); |
82 | 54 | $html = $editor->view( $idStack, $definedMeaningModel->getRecord() ); |
83 | 55 | $wgOut->addHTML( $html ); |
84 | 56 | $this->outputViewFooter(); |
85 | 57 | } |
86 | | - |
| 58 | + |
87 | 59 | public function edit() { |
88 | 60 | global |
89 | 61 | $wgOut, $wgTitle; |
90 | 62 | |
91 | 63 | if ( !parent::edit() ) return false; |
92 | 64 | |
93 | | - $definedMeaningId = $this->getDefinedMeaningIdFromTitle( $wgTitle->getText() ); |
| 65 | + $definedMeaningId = (int)$wgTitle->getText(); |
94 | 66 | |
| 67 | + // Title doesn't have an ID in it (or ID 0) |
| 68 | + if ( !$definedMeaningId ) { |
| 69 | + $wgOut->showErrorPage( 'errorpagetitle', 'ow_dm_badtitle' ); |
| 70 | + return false; |
| 71 | + } |
| 72 | + |
95 | 73 | $this->outputEditHeader(); |
96 | 74 | $dmModel = new DefinedMeaningModel( $definedMeaningId, $this->viewInformation ); |
97 | | - |
| 75 | + |
| 76 | + // check that the constructed DM actually exists in the database |
| 77 | + $match = $dmModel->checkExistence( true, true ); |
| 78 | + if ( is_null( $match ) ) { |
| 79 | + $wgOut->showErrorPage( 'errorpagetitle', 'ow_dm_missing' ); |
| 80 | + return false; |
| 81 | + } |
| 82 | + |
98 | 83 | if ( is_null( $dmModel->getRecord() ) ) { |
99 | 84 | $wgOut->addHTML( wfMsgSc( "db_consistency__not_found" ) . " ID:$definedMeaningId" ); |
100 | 85 | return; |
— | — | @@ -112,10 +97,24 @@ |
113 | 98 | global |
114 | 99 | $wgOut, $wgTitle ; |
115 | 100 | |
| 101 | + $definedMeaningId = (int)$wgTitle->getText(); |
| 102 | + // Title doesn't have an ID in it (or ID 0) |
| 103 | + if ( !$definedMeaningId ) { |
| 104 | + $wgOut->showErrorPage( 'errorpagetitle', 'ow_dm_badtitle' ); |
| 105 | + return false; |
| 106 | + } |
| 107 | + |
116 | 108 | parent::history(); |
117 | 109 | |
118 | | - $definedMeaningId = $this->getDefinedMeaningIdFromTitle( $wgTitle->getText() ); |
119 | 110 | $dmModel = new DefinedMeaningModel( $definedMeaningId, $this->viewInformation ); |
| 111 | + |
| 112 | + // check that the constructed DM actually exists in the database |
| 113 | + $match = $dmModel->checkExistence( true, true ); |
| 114 | + if ( is_null( $match ) ) { |
| 115 | + $wgOut->showErrorPage( 'errorpagetitle', 'ow_dm_missing' ); |
| 116 | + return false; |
| 117 | + } |
| 118 | + |
120 | 119 | $wgOut->addHTML( |
121 | 120 | getDefinedMeaningEditor( $this->viewInformation )->view( |
122 | 121 | new IdStack( WD_DEFINED_MEANING ), |
— | — | @@ -132,10 +131,15 @@ |
133 | 132 | $wgTitle; |
134 | 133 | |
135 | 134 | parent::save( $referenceQueryTransactionInformation ); |
136 | | - $definedMeaningId = $this->getDefinedMeaningIdFromTitle( $wgTitle->getText() ); |
137 | | - |
| 135 | + |
| 136 | + $definedMeaningId = (int)$wgTitle->getText(); |
| 137 | + if ( !$definedMeaningId ) { |
| 138 | + // Title doesn't have an ID in it (or ID 0) |
| 139 | + $wgOut->showErrorPage( 'errorpagetitle', 'ow_dm_badtitle' ); |
| 140 | + return false; |
| 141 | + } |
| 142 | + |
138 | 143 | $dmModel = new DefinedMeaningModel( $definedMeaningId, $this->viewInformation ); |
139 | | - $definedMeaningId = $this->getDefinedMeaningIdFromTitle( $wgTitle->getText() ); |
140 | 144 | |
141 | 145 | getDefinedMeaningEditor( $this->viewInformation )->save( |
142 | 146 | $this->getIdStack( $definedMeaningId ), |
— | — | @@ -157,33 +161,7 @@ |
158 | 162 | |
159 | 163 | return $idStack; |
160 | 164 | } |
161 | | - |
162 | | - /** @deprecated, use DefinedMeaningData.setTitle instead */ |
163 | | - protected function getDefinedMeaningIdFromTitle( $title ) { |
164 | | - // get id from title: DefinedMeaning:expression (id) |
165 | | - $bracketPosition = strrpos( $title, "(" ); |
166 | | - $definedMeaningId = substr( $title, $bracketPosition + 1, strlen( $title ) - $bracketPosition - 2 ); |
167 | | - return $definedMeaningId; |
168 | | - } |
169 | | - |
170 | | - public function getTitle() { |
171 | | - global |
172 | | - $wgTitle, $wgDefinedMeaningPageTitlePrefix; |
173 | | - |
174 | | - if ( $wgDefinedMeaningPageTitlePrefix != "" ) |
175 | | - $prefix = $wgDefinedMeaningPageTitlePrefix . ": "; |
176 | | - else |
177 | | - $prefix = ""; |
178 | | - |
179 | | - return $prefix . definedMeaningExpression( $this->getDefinedMeaningIdFromTitle( $wgTitle->getText() ) ); |
180 | | - } |
181 | 165 | |
182 | | - public function getDefinedMeaningId() { |
183 | | - global |
184 | | - $wgTitle; |
185 | | - return $this->getDefinedMeaningIdFromTitle( $wgTitle->getText() ); |
186 | | - } |
187 | | - |
188 | 166 | /** |
189 | 167 | * Creates sidebar HTML for indicating concepts which exist |
190 | 168 | * in multiple datasets, and providing a link to add new |
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataGlobals.php |
— | — | @@ -65,13 +65,8 @@ |
66 | 66 | |
67 | 67 | // Page titles |
68 | 68 | |
69 | | -global |
70 | | - $wgDefinedMeaningPageTitlePrefix, |
71 | | - // $wgExpressionPageTitlePrefix; |
72 | | - $wgUseExpressionPageTitlePrefix; |
73 | | - |
74 | | -$wgDefinedMeaningPageTitlePrefix = ""; |
75 | | -// $wgExpressionPageTitlePrefix = "Multiple meanings"; # Now it's localizable |
| 69 | +global $wgUseExpressionPageTitlePrefix; |
| 70 | + |
76 | 71 | $wgUseExpressionPageTitlePrefix = true; # malafaya: Use the expression prefix "Multiple meanings:" from message ow_Multiple_meanings |
77 | 72 | |
78 | 73 | // Search page |
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php |
— | — | @@ -795,8 +795,7 @@ |
796 | 796 | |
797 | 797 | // wfDebug( "addDefinedMeaning(): after $definedMeaningId has been inserted in the database" ); |
798 | 798 | |
799 | | - $expression = getExpression( $definingExpressionId ); |
800 | | - $pageId = createPage( NS_DEFINEDMEANING, getPageTitle( "$expression->spelling ($definedMeaningId)" ) ); |
| 799 | + $pageId = createPage( NS_DEFINEDMEANING, getPageTitle( $definedMeaningId ) ); |
801 | 800 | createInitialRevisionForPage( $pageId, 'Created by adding defined meaning' ); |
802 | 801 | |
803 | 802 | return $definedMeaningId; |
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php |
— | — | @@ -62,11 +62,12 @@ |
63 | 63 | |
64 | 64 | $title = $wgTitle->getPrefixedText(); |
65 | 65 | |
66 | | - if ( !$this->showClassicPageTitles ) |
| 66 | + if ( !$this->showClassicPageTitles ) { |
67 | 67 | $title = $this->getTitle(); |
| 68 | + } |
68 | 69 | |
69 | 70 | $wgOut->setPageTitle( $title ); |
70 | | - |
| 71 | + |
71 | 72 | $this->queryTransactionInformation = new QueryLatestTransactionInformation(); |
72 | 73 | |
73 | 74 | $viewInformation = new ViewInformation(); |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
— | — | @@ -35,6 +35,7 @@ |
36 | 36 | |
37 | 37 | if ( !$definedMeaningId ) throw new Exception( "DM needs at least a DMID!" ); |
38 | 38 | $this->setId( $definedMeaningId ); |
| 39 | + |
39 | 40 | if ( is_null( $viewInformation ) ) { |
40 | 41 | $viewInformation = new ViewInformation(); |
41 | 42 | $viewInformation->queryTransactionInformation = new QueryLatestTransactionInformation(); |
— | — | @@ -119,19 +120,7 @@ |
120 | 121 | if ( !$dmRow || !$dmRow->defined_meaning_id ) { |
121 | 122 | return null; |
122 | 123 | } |
123 | | - if ( is_null( $definingExpression ) ) { |
124 | | - return $dc; |
125 | | - } else { |
126 | | - $expid = (int)$dmRow->expression_id; |
127 | | - $storedExpression = getExpression( $expid, $dc ); |
128 | | - if ( is_null( $storedExpression ) ) return null; |
129 | | - if ( $storedExpression->spelling != $definingExpression ) { |
130 | | - // Defining expression does not match, but check was requested! |
131 | | - return null; |
132 | | - } else { |
133 | | - return $dc; |
134 | | - } |
135 | | - } |
| 124 | + return $dc; |
136 | 125 | } |
137 | 126 | /** |
138 | 127 | * Load the associated record object. |
— | — | @@ -399,14 +388,13 @@ |
400 | 389 | */ |
401 | 390 | public function getTitleObject() { |
402 | 391 | if ( $this->titleObject == null ) { |
403 | | - $definingExpression = $this->getDefiningExpression(); |
404 | 392 | $id = $this->getId(); |
405 | 393 | |
406 | | - if ( is_null( $definingExpression ) or is_null( $id ) ) |
| 394 | + if ( is_null( $id ) ) { |
407 | 395 | return null; |
| 396 | + } |
408 | 397 | |
409 | | - $definingExpressionAsTitle = str_replace( " ", "_", $definingExpression ); |
410 | | - $text = "DefinedMeaning:" . $definingExpressionAsTitle . "_($id)"; |
| 398 | + $text = "DefinedMeaning:" . $id; |
411 | 399 | $titleObject = Title::newFromText( $text ); |
412 | 400 | $this->titleObject = $titleObject; |
413 | 401 | } |
— | — | @@ -434,33 +422,6 @@ |
435 | 423 | } |
436 | 424 | |
437 | 425 | /** |
438 | | - * |
439 | | - * Splits title of the form "Abc (123)" into text and number |
440 | | - * components. |
441 | | - * |
442 | | - * @param String the title to analyze |
443 | | - * @return Array of the two components or null. |
444 | | - * |
445 | | - */ |
446 | | - public static function splitTitleText( $titleText ) { |
447 | | - $bracketPosition = strrpos( $titleText, "(" ); |
448 | | - if ( $bracketPosition === false ) |
449 | | - return null; # Defined Meaning ID is missing from title string |
450 | | - $rv = array(); |
451 | | - if ( $bracketPosition > 0 ) { |
452 | | - $definingExpression = substr( $titleText, 0, $bracketPosition - 1 ); |
453 | | - $definingExpression = str_replace( "_", " ", $definingExpression ); |
454 | | - } else { |
455 | | - $definingExpression = null; |
456 | | - } |
457 | | - $definedMeaningId = substr( $titleText, $bracketPosition + 1, strlen( $titleText ) - $bracketPosition - 2 ); |
458 | | - |
459 | | - $rv["expression"] = $definingExpression; |
460 | | - $rv["id"] = (int)$definedMeaningId; |
461 | | - return $rv; |
462 | | - } |
463 | | - |
464 | | - /** |
465 | 426 | * @return full text representation of title |
466 | 427 | */ |
467 | 428 | public function getTitleText() { |
— | — | @@ -488,12 +449,9 @@ |
489 | 450 | } |
490 | 451 | |
491 | 452 | public function getWikiTitle() { |
492 | | - $dmEx = $this->getDefiningExpression(); |
493 | 453 | $dmId = $this->getId(); |
494 | | - $dmTitle = "DefinedMeaning:$dmEx ($dmId)"; |
495 | | - $dmTitle = str_replace( " ", "_", $dmTitle ); |
| 454 | + $dmTitle = "DefinedMeaning:$dmId"; |
496 | 455 | return $dmTitle; |
497 | | - |
498 | 456 | } |
499 | 457 | |
500 | 458 | public function setDefiningExpression( $definingExpression ) { |
Index: trunk/extensions/Wikidata/OmegaWiki/type.php |
— | — | @@ -60,12 +60,8 @@ |
61 | 61 | return $title->getLocalURL( $query ) ; |
62 | 62 | } |
63 | 63 | |
64 | | -function definedMeaningReferenceAsURL( $definedMeaningId, $definingExpression ) { |
65 | | - return pageAsURL( "DefinedMeaning", "$definingExpression ($definedMeaningId)" ); |
66 | | -} |
67 | | - |
68 | 64 | function definedMeaningIdAsURL( $definedMeaningId ) { |
69 | | - return definedMeaningReferenceAsURL( $definedMeaningId, definingExpression( $definedMeaningId ) ); |
| 65 | + return pageAsURL( "DefinedMeaning", "$definedMeaningId" ); |
70 | 66 | } |
71 | 67 | |
72 | 68 | function createLink( $url, $text ) { |
— | — | @@ -77,7 +73,7 @@ |
78 | 74 | } |
79 | 75 | |
80 | 76 | function definedMeaningReferenceAsLink( $definedMeaningId, $definingExpression, $label ) { |
81 | | - return createLink( definedMeaningReferenceAsURL( $definedMeaningId, $definingExpression ), $label ); |
| 77 | + return createLink( definedMeaningIdAsURL( $definedMeaningId ), $label ); |
82 | 78 | } |
83 | 79 | |
84 | 80 | function languageIdAsText( $languageId ) { |
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php |
— | — | @@ -1248,7 +1248,7 @@ |
1249 | 1249 | $isMetaDescSet = 1 ; |
1250 | 1250 | } |
1251 | 1251 | |
1252 | | - $DMPageName = definingExpression( $value ) . " (" . $value . ")" ; |
| 1252 | + $DMPageName = $value ; |
1253 | 1253 | $DMTitle = Title::makeTitle( NS_DEFINEDMEANING , $DMPageName ); |
1254 | 1254 | $editURL = $DMTitle->getLocalURL( 'action=edit' ) ; |
1255 | 1255 | $editLink = '<div style="float:right; font-size:60%;"><sup>[' |