Index: trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php |
— | — | @@ -62,8 +62,6 @@ |
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
66 | | - //$wgOut->addHTML( Html::element( 'h3', array(), wfMsg( '' ) ) ); |
67 | | - |
68 | 66 | $groupsHtml = array(); |
69 | 67 | |
70 | 68 | foreach ( SWLGroups::getAll() as $group ) { |
— | — | @@ -134,7 +132,7 @@ |
135 | 133 | $namespaces = $group->getNamespaces(); |
136 | 134 | |
137 | 135 | foreach ( $namespaces as &$ns ) { |
138 | | - $ns = MWNamespace::getCanonicalName( $ns ); |
| 136 | + $ns = $ns == 0 ? 'Main' : MWNamespace::getCanonicalName( $ns ); |
139 | 137 | } |
140 | 138 | |
141 | 139 | return Html::rawElement( |
Index: trunk/extensions/SemanticWatchlist/includes/SWL_Group.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | |
21 | 21 | protected $categories; |
22 | 22 | |
23 | | - protected $namespaces; |
| 23 | + protected $namespaces = array(); |
24 | 24 | |
25 | 25 | protected $properties; |
26 | 26 | |
— | — | @@ -27,26 +27,70 @@ |
28 | 28 | |
29 | 29 | protected $watchingUsers = false; |
30 | 30 | |
| 31 | + /** |
| 32 | + * Creates a new instance of SWLGroup from a DB result. |
| 33 | + * |
| 34 | + * @since 0.1 |
| 35 | + * |
| 36 | + * @param $group |
| 37 | + * |
| 38 | + * @return SWLGroup |
| 39 | + */ |
31 | 40 | public static function newFromDBResult( $group ) { |
32 | 41 | return new SWLGroup( |
33 | 42 | $group->group_id, |
34 | 43 | $group->group_name, |
35 | 44 | $group->group_categories == '' ? array() : explode( '|', $group->group_categories ), |
36 | | - $group->group_namespaces == '' ? array() : array_map( 'intval', explode( '|', $group->group_namespaces ) ), |
| 45 | + $group->group_namespaces == '' ? array() : explode( '|', $group->group_namespaces ), |
37 | 46 | $group->group_properties == '' ? array() : explode( '|', $group->group_properties ), |
38 | 47 | $group->group_concepts == '' ? array() : explode( '|', $group->group_group_concepts ) |
39 | 48 | ); |
40 | 49 | } |
41 | 50 | |
| 51 | + /** |
| 52 | + * Constructor. |
| 53 | + * |
| 54 | + * @since 0.1 |
| 55 | + * |
| 56 | + * @param integer $id Can be null for new groups |
| 57 | + * @param string $name |
| 58 | + * @param array $categories List of category names |
| 59 | + * @param array $namespaces List of namespace names or IDs |
| 60 | + * @param array $properties List of property names |
| 61 | + * @param array $concepts List of concept names |
| 62 | + */ |
42 | 63 | public function __construct( $id, $name, array $categories, array $namespaces, array $properties, array $concepts ) { |
43 | 64 | $this->id = $id; |
44 | 65 | $this->name = $name; |
45 | 66 | $this->categories = $categories; |
46 | | - $this->namespaces = $namespaces; |
47 | 67 | $this->properties = $properties; |
48 | | - $this->concepts = $concepts; |
| 68 | + $this->concepts = $concepts; |
| 69 | + |
| 70 | + foreach ( $namespaces as $ns ) { |
| 71 | + if ( preg_match( "/^-?([0-9])+$/", $ns ) ) { |
| 72 | + $this->namespaces[] = $ns; |
| 73 | + } |
| 74 | + elseif ( $ns == '' || strtolower( $ns ) == 'main' ) { |
| 75 | + $this->namespaces[] = 0; |
| 76 | + } |
| 77 | + else { |
| 78 | + $ns = MWNamespace::getCanonicalIndex( strtolower( $ns ) ); |
| 79 | + |
| 80 | + if ( !is_null( $ns ) ) { |
| 81 | + $this->namespaces[] = $ns; |
| 82 | + } |
| 83 | + } |
| 84 | + } |
49 | 85 | } |
50 | 86 | |
| 87 | + /** |
| 88 | + * Writes the group to the database, either updating it |
| 89 | + * when it already exists, or inserting it when it doesn't. |
| 90 | + * |
| 91 | + * @since 0.1 |
| 92 | + * |
| 93 | + * @return boolean Success indicator |
| 94 | + */ |
51 | 95 | public function writeToDB() { |
52 | 96 | if ( is_null( $this->id ) ) { |
53 | 97 | return $this->insertIntoDB(); |
— | — | @@ -56,6 +100,13 @@ |
57 | 101 | } |
58 | 102 | } |
59 | 103 | |
| 104 | + /** |
| 105 | + * Updates the group in the database. |
| 106 | + * |
| 107 | + * @since 0.1 |
| 108 | + * |
| 109 | + * @return boolean Success indicator |
| 110 | + */ |
60 | 111 | protected function updateInDB() { |
61 | 112 | $dbr = wfGetDB( DB_MASTER ); |
62 | 113 | |
— | — | @@ -72,6 +123,13 @@ |
73 | 124 | ); |
74 | 125 | } |
75 | 126 | |
| 127 | + /** |
| 128 | + * Inserts the group into the database. |
| 129 | + * |
| 130 | + * @since 0.1 |
| 131 | + * |
| 132 | + * @return boolean Success indicator |
| 133 | + */ |
76 | 134 | protected function insertIntoDB() { |
77 | 135 | $dbr = wfGetDB( DB_MASTER ); |
78 | 136 | |