Index: branches/RL2/extensions/Gadgets/sql/gadgets.sql |
— | — | @@ -1,8 +1,8 @@ |
2 | 2 | -- Add gadgets table |
3 | 3 | |
4 | 4 | CREATE TABLE /*_*/gadgets ( |
5 | | - -- Name of gadget. Cannot be changed, ever. |
6 | | - gd_name varchar(255) binary NOT NULL PRIMARY KEY, |
| 5 | + -- Unique id of gadget. Cannot be changed, ever. |
| 6 | + gd_id varchar(255) binary NOT NULL PRIMARY KEY, |
7 | 7 | -- JSON blob with gadget properties. See Gadget::__construct() for documentation on the format |
8 | 8 | gd_blob mediumblob NOT NULL, |
9 | 9 | -- Whether or not this gadget is allowed to be shared through a foreign repository |
— | — | @@ -11,8 +11,8 @@ |
12 | 12 | gd_timestamp binary(14) NOT NULL |
13 | 13 | ) /*$wgDBTableOptions*/; |
14 | 14 | |
15 | | -CREATE INDEX /*i*/gd_shared_name ON /*_*/gadgets (gd_shared, gd_name); |
16 | | -CREATE INDEX /*i*/gd_name_timestamp ON /*_*/gadgets (gd_name, gd_timestamp); |
| 15 | +CREATE INDEX /*i*/gd_shared_id ON /*_*/gadgets (gd_shared, gd_id); |
| 16 | +CREATE INDEX /*i*/gd_id_timestamp ON /*_*/gadgets (gd_id, gd_timestamp); |
17 | 17 | |
18 | 18 | -- Table tracking .js and .css pages to make efficient prefix searches by extension possible |
19 | 19 | -- (used for AJAX autocompletion) |
Index: branches/RL2/extensions/Gadgets/tests/GadgetsTest.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | |
21 | 21 | function testSimpleCases() { |
22 | 22 | $g = $this->create( '* foo bar| foo.css|foo.js|foo.bar' ); |
23 | | - $this->assertEquals( 'foo_bar', $g->getName() ); |
| 23 | + $this->assertEquals( 'foo_bar', $g->getId() ); |
24 | 24 | $this->assertEquals( 'ext.gadget.foo_bar', $g->getModuleName() ); |
25 | 25 | $this->assertEquals( array( 'Gadget-foo.js' ), $g->getScripts() ); |
26 | 26 | $this->assertEquals( array( 'Gadget-foo.css' ), $g->getStyles() ); |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | |
34 | 34 | function testRLtag() { |
35 | 35 | $g = $this->create( '*foo [ResourceLoader]|foo.js|foo.css' ); |
36 | | - $this->assertEquals( 'foo', $g->getName() ); |
| 36 | + $this->assertEquals( 'foo', $g->getId() ); |
37 | 37 | $this->assertTrue( $g->supportsResourceLoader() ); |
38 | 38 | $this->assertEquals(0, count( $g->getLegacyScripts() ) ); |
39 | 39 | } |
Index: branches/RL2/extensions/Gadgets/Gadgets.php |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | $wgNamespaceProtection[NS_GADGET][] = 'gadgets-edit'; |
83 | 83 | $wgNamespaceProtection[NS_GADGET_DEFINITION][] = 'gadgets-definition-edit'; |
84 | 84 | |
85 | | -// Page titles in this namespace should match gadget names, |
| 85 | +// Page titles in this namespace should match gadget ids, |
86 | 86 | // which historically may start both lowercase or uppercase. |
87 | 87 | $wgCapitalLinkOverrides[NS_GADGET_DEFINITION] = false; |
88 | 88 | |
Index: branches/RL2/extensions/Gadgets/GadgetHooks.php |
— | — | @@ -30,11 +30,11 @@ |
31 | 31 | if ( $title->getNamespace() !== NS_GADGET_DEFINITION || !preg_match( '!\.js$!u', $name ) ) { |
32 | 32 | return true; |
33 | 33 | } |
34 | | - // Trim .js from the page name to obtain the gadget name |
35 | | - $name = substr( $name, 0, -3 ); |
| 34 | + // Trim .js from the page name to obtain the gadget id |
| 35 | + $id = substr( $name, 0, -3 ); |
36 | 36 | |
37 | 37 | $repo = new LocalGadgetRepo( array() ); |
38 | | - $repo->deleteGadget( $name ); |
| 38 | + $repo->deleteGadget( $id ); |
39 | 39 | // deleteGadget() may return an error if the Gadget didn't exist, but we don't care here |
40 | 40 | return true; |
41 | 41 | } |
— | — | @@ -62,8 +62,8 @@ |
63 | 63 | if ( $title->getNamespace() !== NS_GADGET_DEFINITION || !preg_match( '!\.js$!u', $name ) || !$revision ) { |
64 | 64 | return true; |
65 | 65 | } |
66 | | - // Trim .js from the page name to obtain the gadget name |
67 | | - $name = substr( $name, 0, -3 ); |
| 66 | + // Trim .js from the page name to obtain the gadget id |
| 67 | + $id = substr( $name, 0, -3 ); |
68 | 68 | |
69 | 69 | $previousRev = $revision->getPrevious(); |
70 | 70 | $prevTs = $previousRev instanceof Revision ? $previousRev->getTimestamp() : wfTimestampNow(); |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | // Update the database entry for this gadget |
73 | 73 | $repo = new LocalGadgetRepo( array() ); |
74 | 74 | // TODO: Timestamp in the constructor is ugly |
75 | | - $gadget = new Gadget( $name, $repo, $text, $prevTs ); |
| 75 | + $gadget = new Gadget( $id, $repo, $text, $prevTs ); |
76 | 76 | $repo->modifyGadget( $gadget, $revision->getTimestamp() ); |
77 | 77 | |
78 | 78 | // modifyGadget() returns a Status object with an error if there was a conflict, |
— | — | @@ -94,13 +94,13 @@ |
95 | 95 | if ( $title->getNamespace() !== NS_GADGET_DEFINITION || !preg_match( '!\.js$!u', $name ) ) { |
96 | 96 | return true; |
97 | 97 | } |
98 | | - // Trim .js from the page name to obtain the gadget name |
99 | | - $name = substr( $name, 0, -3 ); |
| 98 | + // Trim .js from the page name to obtain the gadget id |
| 99 | + $id = substr( $name, 0, -3 ); |
100 | 100 | |
101 | 101 | // Check whether this undeletion changed the latest revision of the page, by comparing |
102 | 102 | // the timestamp of the latest revision with the timestamp in the DB |
103 | 103 | $repo = new LocalGadgetRepo( array() ); |
104 | | - $gadget = $repo->getGadget( $name ); |
| 104 | + $gadget = $repo->getGadget( $id ); |
105 | 105 | $gadgetTS = $gadget ? $gadget->getTimestamp() : 0; |
106 | 106 | |
107 | 107 | $rev = Revision::newFromTitle( $title ); |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | } |
113 | 113 | |
114 | 114 | // Update the database entry for this gadget |
115 | | - $newGadget = new Gadget( $name, $repo, $rev->getRawText(), $gadgetTS ); |
| 115 | + $newGadget = new Gadget( $id, $repo, $rev->getRawText(), $gadgetTS ); |
116 | 116 | $repo->modifyGadget( $newGadget, $rev->getTimestamp() ); |
117 | 117 | |
118 | 118 | // modifyGadget() returns a Status object with an error if there was a conflict, |
— | — | @@ -190,11 +190,11 @@ |
191 | 191 | // TODO: Part of this is duplicated from registerModules(), factor out into the repo |
192 | 192 | $repo = new LocalGadgetRepo( array() ); |
193 | 193 | |
194 | | - $gadgets = $repo->getGadgetNames(); |
| 194 | + $gadgets = $repo->getGadgetIds(); |
195 | 195 | $categories = array(); // array( category => array( desc => name ) ) |
196 | | - $default = array(); // array of Gadget names |
197 | | - foreach ( $gadgets as $name ) { |
198 | | - $gadget = $repo->getGadget( $name ); |
| 196 | + $default = array(); // array of Gadget ids |
| 197 | + foreach ( $gadgets as $id ) { |
| 198 | + $gadget = $repo->getGadget( $id ); |
199 | 199 | if ( !$gadget->isAllowed( $user ) || $gadget->isHidden() ) { |
200 | 200 | continue; |
201 | 201 | } |
— | — | @@ -209,14 +209,14 @@ |
210 | 210 | } else { |
211 | 211 | $text = wfMessage( 'gadgets-preference-description' )->rawParams( $title, $description )->parse(); |
212 | 212 | } |
213 | | - $categories[$category][$text] = $name; |
| 213 | + $categories[$category][$text] = $id; |
214 | 214 | // Add the Gadget to the default list if enabled |
215 | 215 | if ( $gadget->isEnabledForUser( $user ) ) { |
216 | | - $default[] = $name; |
| 216 | + $default[] = $id; |
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | | - $options = array(); // array( desc1 => name1, category1 => array( desc2 => name2 ) ) |
| 220 | + $options = array(); // array( desc1 => gadget1, category1 => array( desc2 => gadget2 ) ) |
221 | 221 | foreach ( $categories as $category => $gadgets ) { |
222 | 222 | if ( $category !== '' ) { |
223 | 223 | $categoryMsg = wfMsgExt( "gadgetcategory-$category", 'parseinline' ); |
— | — | @@ -260,9 +260,9 @@ |
261 | 261 | unset( $params['class'] ); |
262 | 262 | $repo = new $repoClass( $params ); |
263 | 263 | |
264 | | - $gadgets = $repo->getGadgetNames(); |
265 | | - foreach ( $gadgets as $name ) { |
266 | | - $gadget = $repo->getGadget( $name ); |
| 264 | + $gadgets = $repo->getGadgetIds(); |
| 265 | + foreach ( $gadgets as $id ) { |
| 266 | + $gadget = $repo->getGadget( $id ); |
267 | 267 | $resourceLoader->register( $gadget->getModuleName(), $gadget->getModule() ); |
268 | 268 | } |
269 | 269 | } |
— | — | @@ -283,9 +283,9 @@ |
284 | 284 | unset( $params['class'] ); |
285 | 285 | $repo = new $repoClass( $params ); |
286 | 286 | |
287 | | - $gadgets = $repo->getGadgetNames(); |
288 | | - foreach ( $gadgets as $name ) { |
289 | | - $gadget = $repo->getGadget( $name ); |
| 287 | + $gadgets = $repo->getGadgetIds(); |
| 288 | + foreach ( $gadgets as $id ) { |
| 289 | + $gadget = $repo->getGadget( $id ); |
290 | 290 | if ( $gadget->isEnabledForUser( $wgUser ) && $gadget->isAllowed( $wgUser ) ) { |
291 | 291 | $out->addModules( $gadget->getModuleName() ); |
292 | 292 | } |
Index: branches/RL2/extensions/Gadgets/SpecialGadgets.php |
— | — | @@ -85,16 +85,16 @@ |
86 | 86 | } |
87 | 87 | |
88 | 88 | foreach ( $entries as $gadget ) { |
89 | | - $t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-{$gadget->getName()}$lang" ); |
| 89 | + $t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-{$gadget->getId()}$lang" ); |
90 | 90 | if ( !$t ) continue; |
91 | 91 | |
92 | 92 | $links = array(); |
93 | 93 | if ( $editInterfaceAllowed ) { |
94 | 94 | $links[] = $skin->link( $t, wfMsgHTML( 'edit' ), array(), array( 'action' => 'edit' ) ); |
95 | 95 | } |
96 | | - $links[] = $skin->link( $this->getTitle( "export/{$gadget->getName()}" ), wfMsgHtml( 'gadgets-export' ) ); |
| 96 | + $links[] = $skin->link( $this->getTitle( "export/{$gadget->getId()}" ), wfMsgHtml( 'gadgets-export' ) ); |
97 | 97 | |
98 | | - $ttext = wfMsgExt( "gadget-{$gadget->getName()}", $msgOpt ); |
| 98 | + $ttext = wfMsgExt( "gadget-{$gadget->getId()}", $msgOpt ); |
99 | 99 | |
100 | 100 | if( !$listOpen ) { |
101 | 101 | $listOpen = true; |
Index: branches/RL2/extensions/Gadgets/backend/Gadget.php |
— | — | @@ -28,8 +28,8 @@ |
29 | 29 | * } |
30 | 30 | */ |
31 | 31 | class Gadget { |
32 | | - /** Gadget name (string) */ |
33 | | - protected $name; |
| 32 | + /** Gadget id (string) */ |
| 33 | + protected $id; |
34 | 34 | |
35 | 35 | /** Gadget repository this gadget came from (GadgetRepo object) */ |
36 | 36 | protected $repo; |
— | — | @@ -54,13 +54,13 @@ |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Constructor |
58 | | - * @param $name string Name |
| 58 | + * @param $id string Unique id of the gadget |
59 | 59 | * @param $repo GadgetRepo that this gadget came from |
60 | 60 | * @param $properties mixed Array or JSON blob (string) with settings and module info |
61 | 61 | * @param $timestamp string Timestamp (TS_MW) this gadget's metadata was last touched |
62 | 62 | * @throws MWException if $properties is invalid |
63 | 63 | */ |
64 | | - public function __construct( $name, $repo, $properties, $timestamp ) { |
| 64 | + public function __construct( $id, $repo, $properties, $timestamp ) { |
65 | 65 | if ( is_string( $properties ) ) { |
66 | 66 | $properties = FormatJson::decode( $properties, true ); |
67 | 67 | } |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | throw new MWException( 'Invalid property array passed to ' . __METHOD__ ); |
72 | 72 | } |
73 | 73 | |
74 | | - $this->name = $name; |
| 74 | + $this->id = $id; |
75 | 75 | $this->repo = $repo; |
76 | 76 | $this->timestamp = $timestamp; |
77 | 77 | $this->settings = $properties['settings']; |
— | — | @@ -94,12 +94,13 @@ |
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
98 | | - * Get the name of the gadget. This name must be unique within its repository and must never change. |
99 | | - * It is only used internally; the name displayed to the user is controlled by getNameMsg(). |
| 98 | + * Get the id of the gadget. This id must be unique within its repository and must never change. |
| 99 | + * It is only used internally; the title displayed to the user is controlled by |
| 100 | + * getTitleMessage() and getTitleMessageKey(). |
100 | 101 | * @return string |
101 | 102 | */ |
102 | | - public function getName() { |
103 | | - return $this->name; |
| 103 | + public function getId() { |
| 104 | + return $this->id; |
104 | 105 | } |
105 | 106 | |
106 | 107 | /** |
— | — | @@ -120,17 +121,17 @@ |
121 | 122 | |
122 | 123 | /** |
123 | 124 | * Get the key of the title message for this gadget. This is the interface message that |
124 | | - * controls the name of the gadget as shown to the user. |
| 125 | + * controls the title of the gadget as shown to the user. |
125 | 126 | * @return string Message key |
126 | 127 | */ |
127 | 128 | public function getTitleMessageKey() { |
128 | | - return "gadget-{$this->name}-title"; |
| 129 | + return "gadget-{$this->id}-title"; |
129 | 130 | } |
130 | 131 | |
131 | 132 | /** |
132 | 133 | * Get the title message for this gadget |
133 | 134 | * @param $langcode string Language code. If null, user language is used |
134 | | - * @return The title message in the given language, or the name of the gadget if the message doesn't exist |
| 135 | + * @return The title message in the given language, or the id of the gadget if the message doesn't exist |
135 | 136 | */ |
136 | 137 | public function getTitleMessage( $langcode = null ) { |
137 | 138 | $msg = wfMessage( $this->getTitleMessageKey() ); |
— | — | @@ -138,10 +139,10 @@ |
139 | 140 | $msg = $msg->inLanguage( $langcode ); |
140 | 141 | } |
141 | 142 | if ( !$msg->exists() ) { |
142 | | - // Fallback: return the name of the gadget |
| 143 | + // Fallback: return the id of the gadget |
143 | 144 | global $wgLang; |
144 | 145 | $lang = $langcode === null ? $wgLang : Language::factory( $langcode ); |
145 | | - return $lang->ucfirst( $this->name ); |
| 146 | + return $lang->ucfirst( $this->id ); |
146 | 147 | } |
147 | 148 | return $msg->plain(); |
148 | 149 | |
— | — | @@ -152,7 +153,7 @@ |
153 | 154 | * @return string Message key |
154 | 155 | */ |
155 | 156 | public function getDescriptionMessageKey() { |
156 | | - return "gadget-{$this->name}-desc"; |
| 157 | + return "gadget-{$this->id}-desc"; |
157 | 158 | } |
158 | 159 | |
159 | 160 | /** |
— | — | @@ -244,7 +245,7 @@ |
245 | 246 | * @return string Module name |
246 | 247 | */ |
247 | 248 | public function getModuleName() { |
248 | | - return "gadget.{$this->name}"; |
| 249 | + return "gadget.{$this->id}"; |
249 | 250 | } |
250 | 251 | |
251 | 252 | public function getScripts() { |
— | — | @@ -267,8 +268,8 @@ |
268 | 269 | * @return bool |
269 | 270 | */ |
270 | 271 | public function isEnabledForUser( $user ) { |
271 | | - $name = $this->getName(); |
272 | | - return (bool)$user->getOption( "gadget-$name", $this->isEnabledByDefault() ); |
| 272 | + $id = $this->getId(); |
| 273 | + return (bool)$user->getOption( "gadget-$id", $this->isEnabledByDefault() ); |
273 | 274 | } |
274 | 275 | |
275 | 276 | /** |
Index: branches/RL2/extensions/Gadgets/backend/LocalGadgetRepo.php |
— | — | @@ -18,17 +18,17 @@ |
19 | 19 | // FIXME if there are none, drop the mandatory param |
20 | 20 | } |
21 | 21 | |
22 | | - public function getGadgetNames() { |
| 22 | + public function getGadgetIds() { |
23 | 23 | $this->loadData(); |
24 | 24 | return array_keys( $this->data ); |
25 | 25 | } |
26 | 26 | |
27 | | - public function getGadget( $name ) { |
| 27 | + public function getGadget( $id ) { |
28 | 28 | $this->loadData(); |
29 | | - if ( !isset( $this->data[$name] ) ) { |
| 29 | + if ( !isset( $this->data[$id] ) ) { |
30 | 30 | return null; |
31 | 31 | } |
32 | | - return new Gadget( $name, $this, $this->data[$name]['json'], $this->data[$name]['timestamp'] ); |
| 32 | + return new Gadget( $id, $this, $this->data[$id]['json'], $this->data[$id]['timestamp'] ); |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function getSource() { |
— | — | @@ -50,12 +50,12 @@ |
51 | 51 | |
52 | 52 | $dbw = $this->getMasterDB(); |
53 | 53 | $this->loadData(); |
54 | | - $name = $gadget->getName(); |
| 54 | + $id = $gadget->getId(); |
55 | 55 | $json = $gadget->getJSON(); |
56 | 56 | $ts = $dbw->timestamp( $gadget->getTimestamp() ); |
57 | 57 | $newTs = $dbw->timestamp( $timestamp ); |
58 | 58 | $row = array( |
59 | | - 'gd_name' => $name, |
| 59 | + 'gd_id' => $id, |
60 | 60 | 'gd_blob' => $json, |
61 | 61 | 'gd_shared' => $gadget->isShared(), |
62 | 62 | 'gd_timestamp' => $newTs |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | // Then UPDATE it if it did already exist |
71 | 71 | if ( !$created ) { |
72 | 72 | $dbw->update( 'gadgets', $row, array( |
73 | | - 'gd_name' => $name, |
| 73 | + 'gd_id' => $id, |
74 | 74 | 'gd_timestamp <= ' . $dbw->addQuotes( $ts ) // for conflict detection |
75 | 75 | ), __METHOD__ |
76 | 76 | ); |
— | — | @@ -79,7 +79,7 @@ |
80 | 80 | // Detect conflicts |
81 | 81 | if ( $dbw->affectedRows() === 0 ) { |
82 | 82 | // Some conflict occurred |
83 | | - return Status::newFatal( 'gadgets-manager-modify-conflict', $name, $ts ); |
| 83 | + return Status::newFatal( 'gadgets-manager-modify-conflict', $id, $ts ); |
84 | 84 | } |
85 | 85 | |
86 | 86 | // Update our in-object cache |
— | — | @@ -87,26 +87,26 @@ |
88 | 88 | // to keep $this->data in a consistent format and have getGadget() always return |
89 | 89 | // a clone. If it returned a reference to a cached object, the caller could change |
90 | 90 | // that object and cause weird things to happen. |
91 | | - $this->data[$name] = array( 'json' => $json, 'timestamp' => $newTs ); |
| 91 | + $this->data[$id] = array( 'json' => $json, 'timestamp' => $newTs ); |
92 | 92 | |
93 | 93 | return Status::newGood(); |
94 | 94 | } |
95 | 95 | |
96 | | - public function deleteGadget( $name ) { |
| 96 | + public function deleteGadget( $id ) { |
97 | 97 | if ( !$this->isWriteable() ) { |
98 | 98 | return Status::newFatal( 'gadget-manager-readonly-repository' ); |
99 | 99 | } |
100 | 100 | |
101 | 101 | $this->loadData(); |
102 | | - if ( !isset( $this->data[$name] ) ) { |
103 | | - return Status::newFatal( 'gadgets-manager-nosuchgadget', $name ); |
| 102 | + if ( !isset( $this->data[$id] ) ) { |
| 103 | + return Status::newFatal( 'gadgets-manager-nosuchgadget', $id ); |
104 | 104 | } |
105 | 105 | |
106 | | - unset( $this->data[$name] ); |
| 106 | + unset( $this->data[$id] ); |
107 | 107 | $dbw = $this->getMasterDB(); |
108 | | - $dbw->delete( 'gadgets', array( 'gd_name' => $name ), __METHOD__ ); |
| 108 | + $dbw->delete( 'gadgets', array( 'gd_id' => $id ), __METHOD__ ); |
109 | 109 | if ( $dbw->affectedRows() === 0 ) { |
110 | | - return Status::newFatal( 'gadgets-manager-nosuchgadget', $name ); |
| 110 | + return Status::newFatal( 'gadgets-manager-nosuchgadget', $id ); |
111 | 111 | } |
112 | 112 | return Status::newGood(); |
113 | 113 | } |
— | — | @@ -150,7 +150,7 @@ |
151 | 151 | $query['options'], $query['join_conds'] ); |
152 | 152 | |
153 | 153 | foreach ( $res as $row ) { |
154 | | - $this->data[$row->gd_name] = array( 'json' => $row->gd_blob, 'timestamp' => $row->gd_timestamp ); |
| 154 | + $this->data[$row->gd_id] = array( 'json' => $row->gd_blob, 'timestamp' => $row->gd_timestamp ); |
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
— | — | @@ -161,7 +161,7 @@ |
162 | 162 | protected function getLoadDataQuery() { |
163 | 163 | return array( |
164 | 164 | 'tables' => 'gadgets', |
165 | | - 'fields' => array( 'gd_name', 'gd_blob', 'gd_timestamp' ), |
| 165 | + 'fields' => array( 'gd_id', 'gd_blob', 'gd_timestamp' ), |
166 | 166 | 'conds' => '', // no WHERE clause |
167 | 167 | 'options' => array(), |
168 | 168 | 'join_conds' => array(), |
Index: branches/RL2/extensions/Gadgets/backend/GadgetRepo.php |
— | — | @@ -20,21 +20,21 @@ |
21 | 21 | abstract public function getSource(); |
22 | 22 | |
23 | 23 | /** |
24 | | - * Get the names of the gadgets provided by this repository |
25 | | - * @return array of names (strings) |
| 24 | + * Get the ids of the gadgets provided by this repository |
| 25 | + * @return array of ids (strings) |
26 | 26 | */ |
27 | | - abstract public function getGadgetNames(); |
| 27 | + abstract public function getGadgetIds(); |
28 | 28 | |
29 | 29 | /** |
30 | | - * Get a Gadget object for a given gadget name |
31 | | - * @param $name string Gadget name |
| 30 | + * Get a Gadget object for a given gadget id |
| 31 | + * @param $id string Gadget id |
32 | 32 | * @return Gadget object or null if no such gadget |
33 | 33 | */ |
34 | | - abstract public function getGadget( $name ); |
| 34 | + abstract public function getGadget( $id ); |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Clear any in-object caches this repository may have. In particular, |
38 | | - * the return values of getGadgetNames() and getGadget() may be cached. |
| 38 | + * the return values of getGadgetIds() and getGadget() may be cached. |
39 | 39 | * Callers may wish to clear this cache and reobtain a Gadget object |
40 | 40 | * when they get a conflict error. |
41 | 41 | */ |
— | — | @@ -57,8 +57,8 @@ |
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Modify a gadget, replacing its metadata with the |
61 | | - * metadata in the provided Gadget object. The name is taken |
62 | | - * from the Gadget object as well. If no Gadget exists by that name, |
| 61 | + * metadata in the provided Gadget object. The id is taken |
| 62 | + * from the Gadget object as well. If no Gadget exists by that id, |
63 | 63 | * it will be created. |
64 | 64 | * @param $gadget Gadget object |
65 | 65 | * @param $timestamp Timestamp to record for this action, or current timestamp if null |
— | — | @@ -68,11 +68,11 @@ |
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Irrevocably delete a gadget from the repository. Will fail |
72 | | - * if there is no gadget by the given name. |
73 | | - * @param $name string Name of the gadget to delete |
| 72 | + * if there is no gadget by the given id. |
| 73 | + * @param $id string Unique id of the gadget to delete |
74 | 74 | * @return Status |
75 | 75 | */ |
76 | | - abstract public function deleteGadget( $name ); |
| 76 | + abstract public function deleteGadget( $id ); |
77 | 77 | |
78 | 78 | // TODO: cache purging |
79 | 79 | } |
Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.gadgetmanager.api.js |
— | — | @@ -73,8 +73,8 @@ |
74 | 74 | format: 'json', |
75 | 75 | action: 'query', |
76 | 76 | list: 'gadgets', |
77 | | - gaprop: 'name|metadata|desc', |
78 | | - ganames: id, |
| 77 | + gaprop: 'id|metadata|desc', |
| 78 | + gaids: id, |
79 | 79 | galanguage: mw.config.get( 'wgUserLanguage' ) |
80 | 80 | }, |
81 | 81 | type: 'GET', |
Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.gadgetmanager.ui.js |
— | — | @@ -108,7 +108,7 @@ |
109 | 109 | e.preventDefault(); |
110 | 110 | var $el = $( this ); |
111 | 111 | var gadget = { |
112 | | - id: $el.data( 'gadgetname' ), |
| 112 | + id: $el.data( 'gadget-id' ), |
113 | 113 | displayTitle: $el.text(), |
114 | 114 | metadata: null |
115 | 115 | }; |
Index: branches/RL2/extensions/Gadgets/api/ApiQueryGadgets.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | class ApiQueryGadgets extends ApiQueryBase { |
24 | 24 | private $props, |
25 | 25 | $category, |
26 | | - $neededNames, |
| 26 | + $neededIds, |
27 | 27 | $listAllowed, |
28 | 28 | $listEnabled; |
29 | 29 | |
— | — | @@ -37,8 +37,8 @@ |
38 | 38 | $this->categories = isset( $params['categories'] ) |
39 | 39 | ? array_flip( $params['categories'] ) |
40 | 40 | : false; |
41 | | - $this->neededNames = isset( $params['names'] ) |
42 | | - ? $params['names'] |
| 41 | + $this->neededIds = isset( $params['ids'] ) |
| 42 | + ? $params['ids'] |
43 | 43 | : false; |
44 | 44 | $this->listAllowed = isset( $params['allowedonly'] ) && $params['allowedonly']; |
45 | 45 | $this->listEnabled = isset( $params['enabledonly'] ) && $params['enabledonly']; |
— | — | @@ -54,18 +54,18 @@ |
55 | 55 | $repo = new LocalGadgetRepo( array() ); |
56 | 56 | $result = array(); |
57 | 57 | |
58 | | - if ( $this->neededNames !== false ) { |
59 | | - // Get all requested gadgets by name |
60 | | - $names = $this->neededNames; |
| 58 | + if ( $this->neededIds !== false ) { |
| 59 | + // Get all requested gadgets by id |
| 60 | + $ids = $this->neededIds; |
61 | 61 | } else { |
62 | 62 | // Get them all |
63 | | - $names = $repo->getGadgetNames(); |
| 63 | + $ids = $repo->getGadgetIds(); |
64 | 64 | } |
65 | 65 | |
66 | | - foreach ( $names as $name ) { |
67 | | - $gadget = $repo->getGadget( $name ); |
| 66 | + foreach ( $ids as $id ) { |
| 67 | + $gadget = $repo->getGadget( $id ); |
68 | 68 | if ( $gadget && $this->isNeeded( $gadget ) ) { |
69 | | - $result[$name] = $gadget; |
| 69 | + $result[$id] = $gadget; |
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
— | — | @@ -76,10 +76,10 @@ |
77 | 77 | $data = array(); |
78 | 78 | $result = $this->getResult(); |
79 | 79 | |
80 | | - foreach ( $gadgets as $name => $g ) { |
| 80 | + foreach ( $gadgets as $id => $g ) { |
81 | 81 | $row = array(); |
82 | | - if ( isset( $this->props['name'] ) ) { |
83 | | - $row['name'] = $name; |
| 82 | + if ( isset( $this->props['id'] ) ) { |
| 83 | + $row['id'] = $id; |
84 | 84 | } |
85 | 85 | if ( isset( $this->props['metadata'] ) ) { |
86 | 86 | $row['metadata'] = $g->getMetadata(); |
— | — | @@ -145,10 +145,10 @@ |
146 | 146 | public function getAllowedParams() { |
147 | 147 | return array( |
148 | 148 | 'prop' => array( |
149 | | - ApiBase::PARAM_DFLT => 'name|metadata', |
| 149 | + ApiBase::PARAM_DFLT => 'id|metadata', |
150 | 150 | ApiBase::PARAM_ISMULTI => true, |
151 | 151 | ApiBase::PARAM_TYPE => array( |
152 | | - 'name', |
| 152 | + 'id', |
153 | 153 | 'metadata', |
154 | 154 | 'timestamp', |
155 | 155 | 'definitiontimestamp', |
— | — | @@ -163,7 +163,7 @@ |
164 | 164 | ApiBase::PARAM_ISMULTI => true, |
165 | 165 | ApiBase::PARAM_TYPE => 'string', |
166 | 166 | ), |
167 | | - 'names' => array( |
| 167 | + 'ids' => array( |
168 | 168 | ApiBase::PARAM_TYPE => 'string', |
169 | 169 | ApiBase::PARAM_ISMULTI => true, |
170 | 170 | ), |
— | — | @@ -182,7 +182,7 @@ |
183 | 183 | return array( |
184 | 184 | 'prop' => array( |
185 | 185 | 'What gadget information to get:', |
186 | | - ' name - Internal gadget name', |
| 186 | + ' id - Internal gadget id', |
187 | 187 | ' metadata - The gadget metadata', |
188 | 188 | ' timestamp - Last changed timestamp of the gadget module, including any files it references', |
189 | 189 | ' definitiontimestamp - Last changed timestamp of the gadget metadata', |
— | — | @@ -193,7 +193,7 @@ |
194 | 194 | ), |
195 | 195 | 'language' => "Language code to use for {$p}prop=desc and {$p}prop=title. Defaults to the user language", |
196 | 196 | 'categories' => 'Gadgets from what categories to retrieve', |
197 | | - 'names' => 'Name(s) of gadgets to retrieve', |
| 197 | + 'ids' => 'Id(s) of gadgets to retrieve', |
198 | 198 | 'allowedonly' => 'List only gadgets allowed to current user', |
199 | 199 | 'enabledonly' => 'List only gadgets enabled by current user', |
200 | 200 | 'sharedonly' => 'Only list shared gadgets', |
— | — | @@ -205,13 +205,13 @@ |
206 | 206 | $allProps = implode( '|', $params['prop'][ApiBase::PARAM_TYPE] ); |
207 | 207 | return array( |
208 | 208 | 'Get a list of gadgets along with their descriptions:', |
209 | | - ' api.php?action=query&list=gadgets&gaprop=name|desc', |
| 209 | + ' api.php?action=query&list=gadgets&gaprop=id|desc', |
210 | 210 | 'Get a list of gadgets with all possble properties:', |
211 | 211 | " api.php?action=query&list=gadgets&gaprop=$allProps", |
212 | 212 | 'Get a list of gadgets belonging to caregory "foo":', |
213 | 213 | ' api.php?action=query&list=gadgets&gacategories=foo', |
214 | | - 'Get information about gadgets named "foo" and "bar":', |
215 | | - ' api.php?action=query&list=gadgets&ganames=foo|bar&gaprop=name|desc|metadata', |
| 214 | + 'Get information about gadgets "foo" and "bar":', |
| 215 | + ' api.php?action=query&list=gadgets&gaids=foo|bar&gaprop=id|desc|metadata', |
216 | 216 | 'Get a list of gadgets enabled by current user:', |
217 | 217 | ' api.php?action=query&list=gadgets&gaenabledonly', |
218 | 218 | ); |
Index: branches/RL2/extensions/Gadgets/api/ApiGadgetManager.php |
— | — | @@ -53,7 +53,7 @@ |
54 | 54 | } |
55 | 55 | |
56 | 56 | // FIXME: Passing lasttimestamp into the constructor like this is a bit hacky |
57 | | - $gadget = new Gadget( $params['name'], $repo, $json, $params['edittimestamp'] ); |
| 57 | + $gadget = new Gadget( $params['id'], $repo, $json, $params['edittimestamp'] ); |
58 | 58 | } |
59 | 59 | |
60 | 60 | if ( $op === 'create' ) { |
— | — | @@ -61,7 +61,7 @@ |
62 | 62 | } else if ( $op === 'modify' ) { |
63 | 63 | $status = $repo->modifyGadget( $gadget ); |
64 | 64 | } else if ( $op === 'delete' ) { |
65 | | - $status = $repo->deleteGadget( $params['name'] ); |
| 65 | + $status = $repo->deleteGadget( $params['id'] ); |
66 | 66 | } |
67 | 67 | |
68 | 68 | if ( !$status->isGood() ) { |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | $this->dieUsageMsg( $errors[0] ); // TODO: Actually register all the error messages in ApiBase::$messageMap somehow |
71 | 71 | } |
72 | 72 | |
73 | | - $r = array( 'result' => 'success', 'name' => $params['name'], 'op' => $op ); |
| 73 | + $r = array( 'result' => 'success', 'id' => $params['id'], 'op' => $op ); |
74 | 74 | $this->getResult()->addValue( null, $this->getModuleName(), $r ); |
75 | 75 | } |
76 | 76 | |
— | — | @@ -87,7 +87,7 @@ |
88 | 88 | ApiBase::PARAM_TYPE => array( 'create', 'modify', 'delete' ), |
89 | 89 | ApiBase::PARAM_REQUIRED => true |
90 | 90 | ), |
91 | | - 'name' => array( |
| 91 | + 'id' => array( |
92 | 92 | ApiBase::PARAM_TYPE => 'string', |
93 | 93 | ApiBase::PARAM_REQUIRED => true |
94 | 94 | ), |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | public function getParamDescription() { |
106 | 106 | return array( |
107 | 107 | 'op' => 'Operation to carry out', |
108 | | - 'name' => 'Gadget name', |
| 108 | + 'id' => 'Gadget id', |
109 | 109 | 'json' => 'If op=create or op=modify, JSON blob with the new gadget metadata. Ignored if op=delete', |
110 | 110 | 'edittimestamp' => 'If op=modify, the last modified timestamp of the gadget metadata, exactly as given by list=gadgets', |
111 | 111 | 'token' => 'Edit token', |
Index: branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php |
— | — | @@ -44,12 +44,12 @@ |
45 | 45 | $data = array(); |
46 | 46 | $result = $this->getResult(); |
47 | 47 | $repo = new LocalGadgetRepo( array() ); |
48 | | - $gadgets = $repo->getGadgetNames(); |
| 48 | + $gadgets = $repo->getGadgetIds(); |
49 | 49 | |
50 | 50 | // TODO: Put the grouping in the repo |
51 | 51 | $gadgetsByCategory = array(); |
52 | | - foreach ( $gadgets as $name ) { |
53 | | - $gadget = $repo->getGadget( $name ); |
| 52 | + foreach ( $gadgets as $id ) { |
| 53 | + $gadget = $repo->getGadget( $id ); |
54 | 54 | $gadgetsByCategory[$gadget->getCategory()][] = $gadget; |
55 | 55 | } |
56 | 56 | |
— | — | @@ -116,7 +116,7 @@ |
117 | 117 | ' title - Category title, translated in the given language', |
118 | 118 | ' members - Number of gadgets in category', |
119 | 119 | ), |
120 | | - 'names' => 'Name(s) of gadgets to retrieve', |
| 120 | + 'names' => 'Name(s) of categories to retrieve', |
121 | 121 | 'language' => "Language to use for {$p}prop=title", |
122 | 122 | ); |
123 | 123 | } |
Index: branches/RL2/extensions/Gadgets/SpecialGadgetManager.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | } |
15 | 15 | |
16 | 16 | /** |
17 | | - * @param $par String: Optionally the gadgetname to show info for. |
| 17 | + * @param $par String: Optionally the id of the gadget to show info for. |
18 | 18 | */ |
19 | 19 | public function execute( $par ) { |
20 | 20 | $out = $this->getOutput(); |
— | — | @@ -44,10 +44,10 @@ |
45 | 45 | global $wgGadgetEnableSharing; |
46 | 46 | |
47 | 47 | $repo = new LocalGadgetRepo( array() ); |
48 | | - $gadgetNames = $repo->getGadgetNames(); |
| 48 | + $gadgetIds = $repo->getGadgetIds(); |
49 | 49 | |
50 | 50 | // If there there are no gadgets at all, exit early. |
51 | | - if ( !count( $gadgetNames ) ) { |
| 51 | + if ( !count( $gadgetIds ) ) { |
52 | 52 | $noGadgetsMsgHtml = Html::element( 'p', |
53 | 53 | array( |
54 | 54 | 'class' => 'mw-gadgetmanager-nogadgets' |
— | — | @@ -62,9 +62,9 @@ |
63 | 63 | |
64 | 64 | // Sort gadgets by category |
65 | 65 | $gadgetsByCategory = array(); |
66 | | - foreach ( $gadgetNames as $gadgetName ) { |
67 | | - $gadget = $repo->getGadget( $gadgetName ); |
68 | | - $gadgetsByCategory[$gadget->getCategory()][$gadgetName] = $gadget; |
| 66 | + foreach ( $gadgetIds as $gadgetId ) { |
| 67 | + $gadget = $repo->getGadget( $gadgetId ); |
| 68 | + $gadgetsByCategory[$gadget->getCategory()][$gadgetId] = $gadget; |
69 | 69 | } |
70 | 70 | |
71 | 71 | // Sort categories alphabetically |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | $html .= '<th>' . wfMessage( 'gadgetmanager-tablehead-lastmod' )->escaped() . '</th></tr>'; |
101 | 101 | |
102 | 102 | // Populate table rows for the current category |
103 | | - foreach ( $gadgets as $gadgetName => $gadget ) { |
| 103 | + foreach ( $gadgets as $gadgetId => $gadget ) { |
104 | 104 | $html .= '<tr>'; |
105 | 105 | |
106 | 106 | $tickedCheckboxHtml = Html::element( 'input', array( |
— | — | @@ -111,9 +111,9 @@ |
112 | 112 | |
113 | 113 | // Title |
114 | 114 | $titleLink = Linker::link( |
115 | | - $this->getTitle( $gadget->getName() ), |
| 115 | + $this->getTitle( $gadget->getId() ), |
116 | 116 | $gadget->getTitleMessage(), |
117 | | - array( 'data-gadgetname' => $gadget->getName() ) |
| 117 | + array( 'data-gadget-id' => $gadget->getId() ) |
118 | 118 | ); |
119 | 119 | $html .= "<td class=\"mw-gadgetmanager-gadgets-title\">$titleLink</td>"; |
120 | 120 | // Default |
— | — | @@ -130,7 +130,7 @@ |
131 | 131 | |
132 | 132 | // Last modified |
133 | 133 | $lastModText = ''; |
134 | | - $definitionTitle = Title::makeTitleSafe( NS_GADGET_DEFINITION, $gadget->getName() . '.js' ); |
| 134 | + $definitionTitle = Title::makeTitleSafe( NS_GADGET_DEFINITION, $gadget->getId() . '.js' ); |
135 | 135 | if ( $definitionTitle ) { |
136 | 136 | $definitionRev = Revision::newFromTitle( $definitionTitle ); |
137 | 137 | if ( $definitionRev ) { |
— | — | @@ -174,9 +174,9 @@ |
175 | 175 | /** |
176 | 176 | * @return String: HTML |
177 | 177 | */ |
178 | | - public function generateGadgetView( $gadgetName ) { |
| 178 | + public function generateGadgetView( $gadgetId ) { |
179 | 179 | return 'TODO - This page is about "' |
180 | | - . htmlspecialchars( $gadgetName ) |
| 180 | + . htmlspecialchars( $gadgetId ) |
181 | 181 | . '". Also used as permalink from other places.'; |
182 | 182 | } |
183 | 183 | } |