Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -60,8 +60,6 @@ |
61 | 61 | $wgAutoloadClasses['EPSettings'] = dirname( __FILE__ ) . '/EducationProgram.settings.php'; |
62 | 62 | |
63 | 63 | $wgAutoloadClasses['CourseHistoryAction'] = dirname( __FILE__ ) . '/actions/CourseHistoryAction.php'; |
64 | | -//$wgAutoloadClasses['DeleteCourseAction'] = dirname( __FILE__ ) . '/actions/DeleteCourseAction.php'; |
65 | | -//$wgAutoloadClasses['DeleteOrgAction'] = dirname( __FILE__ ) . '/actions/DeleteOrgAction.php'; |
66 | 64 | $wgAutoloadClasses['EditCourseAction'] = dirname( __FILE__ ) . '/actions/EditCourseAction.php'; |
67 | 65 | $wgAutoloadClasses['EditOrgAction'] = dirname( __FILE__ ) . '/actions/EditOrgAction.php'; |
68 | 66 | $wgAutoloadClasses['EPAddArticleAction'] = dirname( __FILE__ ) . '/actions/EPAddArticleAction.php'; |
— | — | @@ -78,10 +76,6 @@ |
79 | 77 | $wgAutoloadClasses['OrgHistoryAction'] = dirname( __FILE__ ) . '/actions/OrgHistoryAction.php'; |
80 | 78 | $wgAutoloadClasses['ViewCourseAction'] = dirname( __FILE__ ) . '/actions/ViewCourseAction.php'; |
81 | 79 | $wgAutoloadClasses['ViewOrgAction'] = dirname( __FILE__ ) . '/actions/ViewOrgAction.php'; |
82 | | -//$wgAutoloadClasses['CourseUndoAction'] = dirname( __FILE__ ) . '/actions/CourseUndoAction.php'; |
83 | | -//$wgAutoloadClasses['OrgUndoAction'] = dirname( __FILE__ ) . '/actions/OrgUndoAction.php'; |
84 | | -//$wgAutoloadClasses['CourseRestoreAction'] = dirname( __FILE__ ) . '/actions/CourseRestoreAction.php'; |
85 | | -//$wgAutoloadClasses['OrgRestoreAction'] = dirname( __FILE__ ) . '/actions/OrgRestoreAction.php'; |
86 | 80 | |
87 | 81 | $wgAutoloadClasses['ApiDeleteEducation'] = dirname( __FILE__ ) . '/api/ApiDeleteEducation.php'; |
88 | 82 | $wgAutoloadClasses['ApiEnlist'] = dirname( __FILE__ ) . '/api/ApiEnlist.php'; |
— | — | @@ -199,7 +193,6 @@ |
200 | 194 | $wgHooks['ArticleFromTitle'][] = 'EPHooks::onArticleFromTitle'; |
201 | 195 | $wgHooks['CanonicalNamespaces'][] = 'EPHooks::onCanonicalNamespaces'; |
202 | 196 | $wgHooks['TitleIsAlwaysKnown'][] = 'EPHooks::onTitleIsAlwaysKnown'; |
203 | | -//$wgHooks['UnknownAction'][] = 'EPHooks::onUnknownAction'; |
204 | 197 | |
205 | 198 | // Actions |
206 | 199 | $wgActions['epremarticle'] = 'EPRemoveArticleAction'; |
Index: trunk/extensions/EducationProgram/pages/CoursePage.php |
— | — | @@ -14,6 +14,20 @@ |
15 | 15 | */ |
16 | 16 | class CoursePage extends EPPage { |
17 | 17 | |
| 18 | + protected static $info = array( |
| 19 | + 'ns' => EP_NS_COURSE, |
| 20 | + 'actions' => array( |
| 21 | + 'view' => false, |
| 22 | + 'edit' => 'ep-course', |
| 23 | + 'history' => false, |
| 24 | + 'enroll' => 'ep-enroll', |
| 25 | + ), |
| 26 | + 'edit-right' => 'ep-course', |
| 27 | + 'identifier' => 'name', |
| 28 | + 'list' => 'Courses', |
| 29 | + 'log-type' => 'course', |
| 30 | + ); |
| 31 | + |
18 | 32 | /** |
19 | 33 | * (non-PHPdoc) |
20 | 34 | * @see EPPage::getActions() |
Index: trunk/extensions/EducationProgram/pages/EPPage.php |
— | — | @@ -2,6 +2,8 @@ |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Abstract Page for interacting with a EPPageObject. |
| 6 | + * |
| 7 | + * Forced to implement a bunch of stuff that better should be in Page... :/ |
6 | 8 | * |
7 | 9 | * @since 0.1 |
8 | 10 | * |
— | — | @@ -49,8 +51,32 @@ |
50 | 52 | $this->page = new WikiPage( $title ); |
51 | 53 | } |
52 | 54 | |
| 55 | + /** |
| 56 | + * Returns a new instance based on the namespace of the provided title, |
| 57 | + * or throws an exception if the namespace is not handled. |
| 58 | + * |
| 59 | + * @since 0.1 |
| 60 | + * |
| 61 | + * @param Title $title |
| 62 | + * |
| 63 | + * @return EPPage |
| 64 | + * @throws MWException |
| 65 | + */ |
| 66 | + public static function factory( Title $title ) { |
| 67 | + switch ( $title->getNamespace() ) { |
| 68 | + case EP_NS_COURSE: |
| 69 | + return new CoursePage( $title ); |
| 70 | + break; |
| 71 | + case EP_NS_INSTITUTION: |
| 72 | + return new OrgPage( $title ); |
| 73 | + break; |
| 74 | + default: |
| 75 | + throw new MWException( 'Namespace not handled by EPPage' ); |
| 76 | + } |
| 77 | + } |
| 78 | + |
53 | 79 | public function view() { |
54 | | - // MediaWiki::articleFromTitle($title, $context) |
| 80 | + |
55 | 81 | } |
56 | 82 | |
57 | 83 | public function setContext( IContextSource $context ) { |
— | — | @@ -131,4 +157,29 @@ |
132 | 158 | return $this->getLanguage(); |
133 | 159 | } |
134 | 160 | |
| 161 | + public function getEditRight() { |
| 162 | + return static::$info['edit-right']; |
| 163 | + } |
| 164 | + |
| 165 | + public function getListPage() { |
| 166 | + return static::$info['list']; |
| 167 | + } |
| 168 | + |
| 169 | + public static function displayDeletionLog( IContextSource $context, $messageKey ) { |
| 170 | + $out = $context->getOutput(); |
| 171 | + |
| 172 | + LogEventsList::showLogExtract( |
| 173 | + $out, |
| 174 | + array( static::$info['log-type'] ), |
| 175 | + $context->getTitle(), |
| 176 | + '', |
| 177 | + array( |
| 178 | + 'lim' => 10, |
| 179 | + 'conds' => array( 'log_action' => 'remove' ), |
| 180 | + 'showIfEmpty' => false, |
| 181 | + 'msgKey' => array( $messageKey ) |
| 182 | + ) |
| 183 | + ); |
| 184 | + } |
| 185 | + |
135 | 186 | } |
Index: trunk/extensions/EducationProgram/pages/OrgPage.php |
— | — | @@ -14,6 +14,19 @@ |
15 | 15 | */ |
16 | 16 | class OrgPage extends EPPage { |
17 | 17 | |
| 18 | + protected static $info = array( |
| 19 | + 'ns' => EP_NS_INSTITUTION, |
| 20 | + 'actions' => array( |
| 21 | + 'view' => false, |
| 22 | + 'edit' => 'ep-org', |
| 23 | + 'history' => false, |
| 24 | + ), |
| 25 | + 'edit-right' => 'ep-org', |
| 26 | + 'identifier' => 'name', |
| 27 | + 'list' => 'Institutions', |
| 28 | + 'log-type' => 'institution', |
| 29 | + ); |
| 30 | + |
18 | 31 | /** |
19 | 32 | * (non-PHPdoc) |
20 | 33 | * @see EPPage::getActions() |
Index: trunk/extensions/EducationProgram/actions/ViewCourseAction.php |
— | — | @@ -83,7 +83,7 @@ |
84 | 84 | $stats = array(); |
85 | 85 | |
86 | 86 | $orgName = EPOrgs::singleton()->selectFieldsRow( 'name', array( 'id' => $course->getField( 'org_id' ) ) ); |
87 | | - $stats['org'] = EPOrgs::singleton()->getLinkFor( $orgName ); |
| 87 | + $stats['org'] = OrgPage::getLinkFor( $orgName ); |
88 | 88 | |
89 | 89 | $lang = $this->getLanguage(); |
90 | 90 | |
Index: trunk/extensions/EducationProgram/actions/EPViewAction.php |
— | — | @@ -70,13 +70,13 @@ |
71 | 71 | if ( $object === false ) { |
72 | 72 | $this->displayNavigation(); |
73 | 73 | |
74 | | - if ( $this->getUser()->isAllowed( $this->table->getEditRight() ) ) { |
| 74 | + if ( $this->getUser()->isAllowed( $this->page->getEditRight() ) ) { |
75 | 75 | $out->redirect( $this->getTitle()->getLocalURL( array( 'action' => 'edit' ) ) ); |
76 | 76 | } |
77 | 77 | else { |
78 | 78 | $out->addWikiMsg( strtolower( get_called_class() ) . '-none', $name ); |
79 | 79 | |
80 | | - $this->table->displayDeletionLog( |
| 80 | + $this->page->displayDeletionLog( |
81 | 81 | $this->getContext(), |
82 | 82 | 'ep-' . strtolower( $this->getName() ) . '-deleted' |
83 | 83 | ); |
Index: trunk/extensions/EducationProgram/actions/EditCourseAction.php |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | $this->getOutput()->addModules( array( 'ep.datepicker', 'ep.combobox' ) ); |
60 | 60 | |
61 | 61 | if ( !$this->isNewPost() && !$this->table->hasIdentifier( $this->getTitle()->getText() ) ) { |
62 | | - $this->table->displayDeletionLog( |
| 62 | + $this->page->displayDeletionLog( |
63 | 63 | $this->getContext(), |
64 | 64 | 'ep-' . strtolower( $this->getName() ) . '-deleted' |
65 | 65 | ); |
Index: trunk/extensions/EducationProgram/actions/EPEditAction.php |
— | — | @@ -100,7 +100,7 @@ |
101 | 101 | } |
102 | 102 | else { |
103 | 103 | if ( $object === false ) { |
104 | | - $this->table->displayDeletionLog( |
| 104 | + $this->page->displayDeletionLog( |
105 | 105 | $this->getContext(), |
106 | 106 | 'ep-' . strtolower( $this->getName() ) . '-deleted' |
107 | 107 | ); |
Index: trunk/extensions/EducationProgram/actions/EPHistoryAction.php |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | protected function displayNoRevisions() { |
58 | 58 | $this->getOutput()->addWikiMsg( 'ep-' . strtolower( $this->getName() ) . '-norevs' ); |
59 | 59 | |
60 | | - $this->table->displayDeletionLog( |
| 60 | + $this->page->displayDeletionLog( |
61 | 61 | $this->getContext(), |
62 | 62 | 'ep-' . strtolower( $this->getName() ) . '-deleted' |
63 | 63 | ); |
Index: trunk/extensions/EducationProgram/actions/EPDeleteAction.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | * @see Action::getRestriction() |
37 | 37 | */ |
38 | 38 | public function getRestriction() { |
39 | | - $this->page->getTable()->getEditRight(); |
| 39 | + $this->page->getEditRight(); |
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | public function getFormattedValue( $name, $value ) { |
64 | 64 | switch ( $name ) { |
65 | 65 | case 'name': |
66 | | - $value = EPOrgs::getLinkFor( $value ); |
| 66 | + $value = OrgPage::getLinkFor( $value ); |
67 | 67 | break; |
68 | 68 | case 'country': |
69 | 69 | $countries = array_flip( EPUtils::getCountryOptions( $this->getLanguage()->getCode() ) ); |
Index: trunk/extensions/EducationProgram/includes/EPOrgs.php |
— | — | @@ -13,19 +13,6 @@ |
14 | 14 | */ |
15 | 15 | class EPOrgs extends EPPageTable { |
16 | 16 | |
17 | | - protected static $info = array( |
18 | | - 'ns' => EP_NS_INSTITUTION, |
19 | | - 'actions' => array( |
20 | | - 'view' => false, |
21 | | - 'edit' => 'ep-org', |
22 | | - 'history' => false, |
23 | | - ), |
24 | | - 'edit-right' => 'ep-org', |
25 | | - 'identifier' => 'name', |
26 | | - 'list' => 'Institutions', |
27 | | - 'log-type' => 'institution', |
28 | | - ); |
29 | | - |
30 | 17 | /** |
31 | 18 | * (non-PHPdoc) |
32 | 19 | * @see DBTable::getDBTable() |
— | — | @@ -141,4 +128,20 @@ |
142 | 129 | return $options; |
143 | 130 | } |
144 | 131 | |
| 132 | + /** |
| 133 | + * (non-PHPdoc) |
| 134 | + * @see EPPageObject::getIdentifierField() |
| 135 | + */ |
| 136 | + public function getIdentifierField() { |
| 137 | + return 'name'; |
| 138 | + } |
| 139 | + |
| 140 | + /** |
| 141 | + * (non-PHPdoc) |
| 142 | + * @see EPPageObject::getNamespace() |
| 143 | + */ |
| 144 | + public function getNamespace() { |
| 145 | + return EP_NS_INSTITUTION; |
| 146 | + } |
| 147 | + |
145 | 148 | } |
Index: trunk/extensions/EducationProgram/includes/EPPageTable.php |
— | — | @@ -13,46 +13,32 @@ |
14 | 14 | */ |
15 | 15 | abstract class EPPageTable extends DBTable { |
16 | 16 | |
17 | | - public function getIdentifierField() { |
18 | | - return static::$info['identifier']; |
19 | | - } |
20 | | - |
21 | | - public function getEditRight() { |
22 | | - return static::$info['edit-right']; |
23 | | - } |
24 | | - |
25 | | - public static function getTitleFor( $identifierValue ) { |
26 | | - return Title::newFromText( |
27 | | - $identifierValue, |
28 | | - static::$info['ns'] |
29 | | - ); |
30 | | - } |
31 | | - |
32 | | - public static function getLinkFor( $identifierValue, $action = 'view', $html = null, $customAttribs = array(), $query = array() ) { |
33 | | - if ( $action !== 'view' ) { |
34 | | - $query['action'] = $action; |
35 | | - } |
36 | | - |
37 | | - return Linker::linkKnown( // Linker has no hook that allows us to figure out if the page actually exists :( |
38 | | - self::getTitleFor( $identifierValue, $action ), |
39 | | - is_null( $html ) ? htmlspecialchars( $identifierValue ) : $html, |
40 | | - $customAttribs, |
41 | | - $query |
42 | | - ); |
43 | | - } |
44 | | - |
| 17 | + /** |
| 18 | + * Returns the field use to identify this object, ie the part used as page title. |
| 19 | + * |
| 20 | + * @since 0.1 |
| 21 | + * |
| 22 | + * @return string |
| 23 | + */ |
| 24 | + public abstract function getIdentifierField(); |
| 25 | + |
| 26 | + /** |
| 27 | + * Returns the namespace in which objects of this type reside. |
| 28 | + * |
| 29 | + * @since 0.1 |
| 30 | + * |
| 31 | + * @return integer |
| 32 | + */ |
| 33 | + public abstract function getNamespace(); |
| 34 | + |
45 | 35 | public function hasIdentifier( $identifier ) { |
46 | 36 | return $this->has( array( $this->getIdentifierField() => $identifier ) ); |
47 | 37 | } |
48 | 38 | |
49 | 39 | public function get( $identifier, $fields = null ) { |
50 | | - return static::selectRow( $fields, array( $this->getIdentifierField() => $identifier ) ); |
| 40 | + return $this->selectRow( $fields, array( $this->getIdentifierField() => $identifier ) ); |
51 | 41 | } |
52 | 42 | |
53 | | - public function getListPage() { |
54 | | - return static::$info['list']; |
55 | | - } |
56 | | - |
57 | 43 | /** |
58 | 44 | * Delete all objects matching the provided condirions. |
59 | 45 | * |
— | — | @@ -92,40 +78,48 @@ |
93 | 79 | 'title' => $title, |
94 | 80 | ); |
95 | 81 | } |
96 | | - |
97 | | - public static function getTypeForNS( $ns ) { |
98 | | - foreach ( static::$info as $type => $info ) { |
99 | | - if ( $info['ns'] === $ns ) { |
100 | | - return $type; |
101 | | - } |
102 | | - } |
103 | | - |
104 | | - throw new MWException( 'Unknown EPPageObject ns' ); |
105 | | - } |
106 | | - |
107 | | - public static function getLatestRevForTitle( Title $title, $conditions = array() ) { |
108 | | - $conds = array( |
109 | | - 'type' => self::getTypeForNS( $title->getNamespace() ), |
110 | | - 'object_identifier' => $title->getText(), |
| 82 | + |
| 83 | + /** |
| 84 | + * Construct a new title for an object of this type with the provided identifier value. |
| 85 | + * |
| 86 | + * @since 0.1 |
| 87 | + * |
| 88 | + * @param string $identifierValue |
| 89 | + * |
| 90 | + * @return Title |
| 91 | + */ |
| 92 | + public function getTitleFor( $identifierValue ) { |
| 93 | + return Title::newFromText( |
| 94 | + $identifierValue, |
| 95 | + $this->getNamespace() |
111 | 96 | ); |
112 | | - |
113 | | - return EPRevision::getLastRevision( array_merge( $conds, $conditions ) ); |
114 | 97 | } |
115 | 98 | |
116 | | - public static function displayDeletionLog( IContextSource $context, $messageKey ) { |
117 | | - $out = $context->getOutput(); |
| 99 | + /** |
| 100 | + * Returns a link to the page representing the object of this type with the provided identifier value. |
| 101 | + * |
| 102 | + * @since 0.1 |
| 103 | + * |
| 104 | + * @param string $identifierValue |
| 105 | + * @param string $action |
| 106 | + * @param string $html |
| 107 | + * @param array $customAttribs |
| 108 | + * @param array $query |
| 109 | + * |
| 110 | + * @return string |
| 111 | + */ |
| 112 | + public function getLinkFor( $identifierValue, $action = 'view', $html = null, array $customAttribs = array(), array $query = array() ) { |
| 113 | + if ( $action !== 'view' ) { |
| 114 | + $query['action'] = $action; |
| 115 | + } |
118 | 116 | |
119 | | - LogEventsList::showLogExtract( |
120 | | - $out, |
121 | | - array( static::$info['log-type'] ), |
122 | | - $context->getTitle(), |
123 | | - '', |
124 | | - array( |
125 | | - 'lim' => 10, |
126 | | - 'conds' => array( 'log_action' => 'remove' ), |
127 | | - 'showIfEmpty' => false, |
128 | | - 'msgKey' => array( $messageKey ) |
129 | | - ) |
| 117 | + // Linker has no hook that allows us to figure out if the page actually exists :( |
| 118 | + // FIXME: now it does |
| 119 | + return Linker::linkKnown( |
| 120 | + $this->getTitleFor( $identifierValue, $action ), |
| 121 | + is_null( $html ) ? htmlspecialchars( $identifierValue ) : $html, |
| 122 | + $customAttribs, |
| 123 | + $query |
130 | 124 | ); |
131 | 125 | } |
132 | 126 | |
Index: trunk/extensions/EducationProgram/includes/EPPageObject.php |
— | — | @@ -13,13 +13,17 @@ |
14 | 14 | */ |
15 | 15 | abstract class EPPageObject extends EPRevisionedObject { |
16 | 16 | |
| 17 | + /** |
| 18 | + * (non-PHPdoc) |
| 19 | + * @see EPRevisionedObject::getIdentifier() |
| 20 | + */ |
17 | 21 | public function getIdentifier() { |
18 | 22 | return $this->getField( $this->table->getIdentifierField() ); |
19 | 23 | } |
20 | | - |
| 24 | + |
21 | 25 | /** |
| 26 | + * Returns the title of the page representing the object. |
22 | 27 | * |
23 | | - * |
24 | 28 | * @since 0.1 |
25 | 29 | * |
26 | 30 | * @return Title |
— | — | @@ -29,27 +33,39 @@ |
30 | 34 | } |
31 | 35 | |
32 | 36 | /** |
| 37 | + * Gets a link to the page representing the object. |
| 38 | + * |
| 39 | + * @since 0.1 |
| 40 | + * |
| 41 | + * @param string $action |
| 42 | + * @param string $html |
| 43 | + * @param array $customAttribs |
| 44 | + * @param array $query |
| 45 | + * |
| 46 | + * @return string |
| 47 | + */ |
| 48 | + public function getLink( $action = 'view', $html = null, array $customAttribs = array(), array $query = array() ) { |
| 49 | + return $this->table->getLinkFor( |
| 50 | + $this->getIdentifier(), |
| 51 | + $action, |
| 52 | + $html, |
| 53 | + $customAttribs, |
| 54 | + $query |
| 55 | + ); |
| 56 | + } |
| 57 | + |
| 58 | + /** |
33 | 59 | * (non-PHPdoc) |
34 | 60 | * @see DBDataObject::save() |
35 | 61 | */ |
36 | 62 | public function save() { |
37 | | - if ( $this->hasField( $this->table->getIdentifierField() ) && is_null( $this->getTitle() ) ) { |
| 63 | + if ( $this->hasField( $this->getIdentifierField() ) && is_null( $this->getTitle() ) ) { |
38 | 64 | throw new MWException( 'The title for a EPPageObject needs to be valid when saving.' ); |
39 | 65 | return false; |
40 | 66 | } |
41 | 67 | |
42 | 68 | return parent::save(); |
43 | 69 | } |
44 | | - |
45 | | - public function getLink( $action = 'view', $html = null, $customAttribs = array(), $query = array() ) { |
46 | | - return $this->table->getLinkFor( |
47 | | - $this->getIdentifier(), |
48 | | - $action, |
49 | | - $html, |
50 | | - $customAttribs, |
51 | | - $query |
52 | | - ); |
53 | | - } |
54 | 70 | |
55 | 71 | /** |
56 | 72 | * (non-PHPdoc) |
Index: trunk/extensions/EducationProgram/includes/EPRevisionPager.php |
— | — | @@ -107,7 +107,8 @@ |
108 | 108 | ); |
109 | 109 | } |
110 | 110 | |
111 | | - if ( $this->getUser()->isAllowed( $this->table->getEditRight() ) ) { |
| 111 | + // TODO: $this->getUser()->isAllowed( $this->table->getEditRight() ) |
| 112 | + if ( false ) { |
112 | 113 | $actionLinks = array(); |
113 | 114 | |
114 | 115 | if ( $this->mOffset !== '' || $this->rowNr < $this->mResult->numRows() - 1 ) { |
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | public function getFormattedValue( $name, $value ) { |
74 | 74 | switch ( $name ) { |
75 | 75 | case 'name': |
76 | | - $value = EPCourses::getLinkFor( $value ); |
| 76 | + $value = CoursePage::getLinkFor( $value ); |
77 | 77 | break; |
78 | 78 | case 'org_id': |
79 | 79 | $org = EPOrgs::singleton()->selectRow( 'name', array( 'id' => $value ) ); |
Index: trunk/extensions/EducationProgram/includes/EPCourses.php |
— | — | @@ -13,20 +13,6 @@ |
14 | 14 | */ |
15 | 15 | class EPCourses extends EPPageTable { |
16 | 16 | |
17 | | - protected static $info = array( |
18 | | - 'ns' => EP_NS_COURSE, |
19 | | - 'actions' => array( |
20 | | - 'view' => false, |
21 | | - 'edit' => 'ep-course', |
22 | | - 'history' => false, |
23 | | - 'enroll' => 'ep-enroll', |
24 | | - ), |
25 | | - 'edit-right' => 'ep-course', |
26 | | - 'identifier' => 'name', |
27 | | - 'list' => 'Courses', |
28 | | - 'log-type' => 'course', |
29 | | - ); |
30 | | - |
31 | 17 | /** |
32 | 18 | * (non-PHPdoc) |
33 | 19 | * @see DBTable::getDBTable() |
— | — | @@ -145,4 +131,20 @@ |
146 | 132 | ) ); |
147 | 133 | } |
148 | 134 | |
| 135 | + /** |
| 136 | + * (non-PHPdoc) |
| 137 | + * @see EPPageObject::getIdentifierField() |
| 138 | + */ |
| 139 | + public function getIdentifierField() { |
| 140 | + return 'name'; |
| 141 | + } |
| 142 | + |
| 143 | + /** |
| 144 | + * (non-PHPdoc) |
| 145 | + * @see EPPageObject::getNamespace() |
| 146 | + */ |
| 147 | + public function getNamespace() { |
| 148 | + return EP_NS_COURSE; |
| 149 | + } |
| 150 | + |
149 | 151 | } |
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php |
— | — | @@ -255,8 +255,7 @@ |
256 | 256 | $links['actions'] = array(); |
257 | 257 | |
258 | 258 | $user = $sktemplate->getUser(); |
259 | | - $class = $classes[$title->getNamespace()]; |
260 | | - $exists = $class::singleton()->hasIdentifier( $title->getText() ); |
| 259 | + $exists = $classes[$title->getNamespace()]::singleton()->hasIdentifier( $title->getText() ); |
261 | 260 | $type = $sktemplate->getRequest()->getText( 'action' ); |
262 | 261 | $isSpecial = $sktemplate->getTitle()->isSpecialPage(); |
263 | 262 | |
— | — | @@ -268,7 +267,7 @@ |
269 | 268 | ); |
270 | 269 | } |
271 | 270 | |
272 | | - if ( $user->isAllowed( $class::singleton()->getEditRight() ) ) { |
| 271 | + if ( $user->isAllowed( EPPage::factory( $title )->getEditRight() ) ) { |
273 | 272 | $links['views']['edit'] = array( |
274 | 273 | 'class' => $type === 'edit' ? 'selected' : false, |
275 | 274 | 'text' => wfMsg( $exists ? 'ep-tab-edit' : 'ep-tab-create' ), |
— | — | @@ -341,30 +340,4 @@ |
342 | 341 | return true; |
343 | 342 | } |
344 | 343 | |
345 | | - /** |
346 | | - * Used to add new query-string actions. |
347 | | - * @see https://www.mediawiki.org/wiki/Manual:Hooks/UnknownAction |
348 | | - * |
349 | | - * @since 0.1 |
350 | | - * |
351 | | - * @param string $action |
352 | | - * @param Page $page |
353 | | - * |
354 | | - * @return true |
355 | | - */ |
356 | | - public static function onUnknownAction( $action, Page $page ) { |
357 | | - // Action does not allow us to associate actions that are not known to core |
358 | | - // with a single page, hence the less ideal handling in this hook. |
359 | | - if ( method_exists( $page, 'getActions' ) ) { |
360 | | - $actions = $page->getActions(); |
361 | | - |
362 | | - if ( array_key_exists( $action, $actions ) ) { |
363 | | - $action = new $actions[$action]( $page, $page->getContext() ); |
364 | | - $action->show(); |
365 | | - } |
366 | | - } |
367 | | - |
368 | | - return true; |
369 | | - } |
370 | | - |
371 | 344 | } |