r62683 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62682‎ | r62683 | r62684 >
Date:00:39, 19 February 2010
Author:reedy
Status:ok
Tags:
Comment:
Reorganise code file to match "more normal" api layout
Modified paths:
  • /trunk/extensions/LiquidThreads/api/ApiThreadAction.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/api/ApiThreadAction.php
@@ -1,114 +1,7 @@
22 <?php
33
44 class ApiThreadAction extends ApiBase {
5 - public function getDescription() {
6 - return 'Allows actions to be taken on threads and posts in threaded discussions.';
7 - }
85
9 - public function getActions() {
10 - return array(
11 - 'markread' => 'actionMarkRead',
12 - 'markunread' => 'actionMarkUnread',
13 - 'split' => 'actionSplit',
14 - 'merge' => 'actionMerge',
15 - 'reply' => 'actionReply',
16 - 'newthread' => 'actionNewThread',
17 - 'setsubject' => 'actionSetSubject',
18 - 'setsortkey' => 'actionSetSortkey',
19 - 'edit' => 'actionEdit',
20 - );
21 - }
22 -
23 - public function getParamDescription() {
24 - return array(
25 - 'thread' => 'A list (pipe-separated) of thread IDs or titles to act on',
26 - 'threadaction' => 'The action to take',
27 - 'token' => 'An edit token (from ?action=query&prop=info&intoken=edit)',
28 - 'talkpage' => 'The talkpage to act on (if applicable)',
29 - 'subject' => 'The subject to set for the new or split thread',
30 - 'reason' => 'If applicable, the reason/summary for the action',
31 - 'newparent' => 'If merging a thread, the ID or title for its new parent',
32 - 'text' => 'The text of the post to create',
33 - 'render' => 'If set, on post/reply methods, the top-level thread ' .
34 - 'after the change will be rendered and returned in the result.',
35 - 'bump' => 'If set, overrides default behaviour as to whether or not to ',
36 - "increase the thread's sort key. If true, sets it to current " .
37 - "timestamp. If false, does not set it. Default depends on " .
38 - "the action being taken. Presently only works for newthread " .
39 - "and reply actions.",
40 - 'sortkey' => "Specifies the timestamp to which to set a thread's " .
41 - "sort key. Must be in the form YYYYMMddhhmmss, " .
42 - "a unix timestamp or 'now'.",
43 - 'signature' => 'Specifies the signature to use for that post. Can be ' .
44 - 'NULL to specify the default signature',
45 - );
46 - }
47 -
48 - public function getPossibleErrors() {
49 - return array_merge( parent::getPossibleErrors(), array(
50 - array( 'missingparam', 'action' ),
51 - array( 'missingparam', 'talkpage' ),
52 - array( 'missingparam', 'subject' ),
53 - array( 'code' => 'too-many-threads', 'info' => 'You may only split one thread at a time' ),
54 - array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to split' ),
55 - array( 'code' => 'already-top-level', 'info' => 'This thread is already a top-level thread.' ),
56 - array( 'code' => 'no-valid-subject', 'info' => 'No subject, or an invalid subject, was specified' ),
57 - array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to merge' ),
58 - array( 'code' => 'no-parent-thread', 'info' => 'You must specify a new parent thread to merge beneath' ),
59 - array( 'code' => 'invalid-parent-thread', 'info' => 'The parent thread you specified was neither the title of a thread, nor a thread ID.' ),
60 - array( 'code' => 'invalid-talkpage', 'info' => 'The talkpage you specified is invalid, or does not have discussion threading enabled.' ),
61 - array( 'code' => 'talkpage-protected', 'info' => 'You cannot post to the specified talkpage, because it is protected from new posts' ),
62 - array( 'code' => 'invalid-subject', 'info' => 'The subject you specified is not valid' ),
63 - array( 'code' => 'no-text', 'info' => 'You must include text in your post' ),
64 - array( 'code' => 'too-many-threads', 'info' => 'You may only edit one thread at a time' ),
65 - array( 'code' => 'invalid-subject', 'info' => 'You must specify a thread to edit' ),
66 - array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to reply to' ),
67 - array( 'code' => 'perm_result-protected', 'info' => 'You cannot reply to this thread, because the perm_result is protected from replies.' ),
68 - array( 'code' => 'too-many-threads', 'info' => 'You may only change the subject of one thread at a time' ),
69 - array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to change the subject of' ),
70 - array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to set the sortkey of' ),
71 - array( 'code' => 'invalid-sortkey', 'info' => 'You must specify a valid timestamp for the sortkey parameter. It should be in the form YYYYMMddhhmmss, a unix timestamp or "now".' ),
72 - ) );
73 - }
74 -
75 - public function getExamples() {
76 - return array(
77 - );
78 - }
79 -
80 - public function getTokenSalt() {
81 - return '';
82 - }
83 -
84 - public function getAllowedParams() {
85 - return array(
86 - 'thread' => array(
87 - ApiBase::PARAM_ISMULTI => true,
88 - ),
89 - 'talkpage' => null,
90 - 'threadaction' => array(
91 - ApiBase::PARAM_TYPE => array_keys( $this->getActions() ),
92 - ),
93 - 'token' => null,
94 - 'subject' => null,
95 - 'reason' => null,
96 - 'newparent' => null,
97 - 'text' => null,
98 - 'render' => null,
99 - 'bump' => null,
100 - 'sortkey' => null,
101 - 'signature' => null,
102 - );
103 - }
104 -
105 - public function mustBePosted() {
106 - return true;
107 - }
108 -
109 - public function isWriteMode() {
110 - return true;
111 - }
112 -
1136 public function execute() {
1147 $params = $this->extractRequestParams();
1158
@@ -775,7 +668,115 @@
776669
777670 $this->getResult()->addValue( null, $this->getModuleName(), $result );
778671 }
 672+
 673+ public function getDescription() {
 674+ return 'Allows actions to be taken on threads and posts in threaded discussions.';
 675+ }
779676
 677+ public function getActions() {
 678+ return array(
 679+ 'markread' => 'actionMarkRead',
 680+ 'markunread' => 'actionMarkUnread',
 681+ 'split' => 'actionSplit',
 682+ 'merge' => 'actionMerge',
 683+ 'reply' => 'actionReply',
 684+ 'newthread' => 'actionNewThread',
 685+ 'setsubject' => 'actionSetSubject',
 686+ 'setsortkey' => 'actionSetSortkey',
 687+ 'edit' => 'actionEdit',
 688+ );
 689+ }
 690+
 691+ public function getParamDescription() {
 692+ return array(
 693+ 'thread' => 'A list (pipe-separated) of thread IDs or titles to act on',
 694+ 'threadaction' => 'The action to take',
 695+ 'token' => 'An edit token (from ?action=query&prop=info&intoken=edit)',
 696+ 'talkpage' => 'The talkpage to act on (if applicable)',
 697+ 'subject' => 'The subject to set for the new or split thread',
 698+ 'reason' => 'If applicable, the reason/summary for the action',
 699+ 'newparent' => 'If merging a thread, the ID or title for its new parent',
 700+ 'text' => 'The text of the post to create',
 701+ 'render' => 'If set, on post/reply methods, the top-level thread ' .
 702+ 'after the change will be rendered and returned in the result.',
 703+ 'bump' => 'If set, overrides default behaviour as to whether or not to ',
 704+ "increase the thread's sort key. If true, sets it to current " .
 705+ "timestamp. If false, does not set it. Default depends on " .
 706+ "the action being taken. Presently only works for newthread " .
 707+ "and reply actions.",
 708+ 'sortkey' => "Specifies the timestamp to which to set a thread's " .
 709+ "sort key. Must be in the form YYYYMMddhhmmss, " .
 710+ "a unix timestamp or 'now'.",
 711+ 'signature' => 'Specifies the signature to use for that post. Can be ' .
 712+ 'NULL to specify the default signature',
 713+ );
 714+ }
 715+
 716+ public function getPossibleErrors() {
 717+ return array_merge( parent::getPossibleErrors(), array(
 718+ array( 'missingparam', 'action' ),
 719+ array( 'missingparam', 'talkpage' ),
 720+ array( 'missingparam', 'subject' ),
 721+ array( 'code' => 'too-many-threads', 'info' => 'You may only split one thread at a time' ),
 722+ array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to split' ),
 723+ array( 'code' => 'already-top-level', 'info' => 'This thread is already a top-level thread.' ),
 724+ array( 'code' => 'no-valid-subject', 'info' => 'No subject, or an invalid subject, was specified' ),
 725+ array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to merge' ),
 726+ array( 'code' => 'no-parent-thread', 'info' => 'You must specify a new parent thread to merge beneath' ),
 727+ array( 'code' => 'invalid-parent-thread', 'info' => 'The parent thread you specified was neither the title of a thread, nor a thread ID.' ),
 728+ array( 'code' => 'invalid-talkpage', 'info' => 'The talkpage you specified is invalid, or does not have discussion threading enabled.' ),
 729+ array( 'code' => 'talkpage-protected', 'info' => 'You cannot post to the specified talkpage, because it is protected from new posts' ),
 730+ array( 'code' => 'invalid-subject', 'info' => 'The subject you specified is not valid' ),
 731+ array( 'code' => 'no-text', 'info' => 'You must include text in your post' ),
 732+ array( 'code' => 'too-many-threads', 'info' => 'You may only edit one thread at a time' ),
 733+ array( 'code' => 'invalid-subject', 'info' => 'You must specify a thread to edit' ),
 734+ array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to reply to' ),
 735+ array( 'code' => 'perm_result-protected', 'info' => 'You cannot reply to this thread, because the perm_result is protected from replies.' ),
 736+ array( 'code' => 'too-many-threads', 'info' => 'You may only change the subject of one thread at a time' ),
 737+ array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to change the subject of' ),
 738+ array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to set the sortkey of' ),
 739+ array( 'code' => 'invalid-sortkey', 'info' => 'You must specify a valid timestamp for the sortkey parameter. It should be in the form YYYYMMddhhmmss, a unix timestamp or "now".' ),
 740+ ) );
 741+ }
 742+
 743+ public function getExamples() {
 744+ return array(
 745+ );
 746+ }
 747+
 748+ public function getTokenSalt() {
 749+ return '';
 750+ }
 751+
 752+ public function getAllowedParams() {
 753+ return array(
 754+ 'thread' => array(
 755+ ApiBase::PARAM_ISMULTI => true,
 756+ ),
 757+ 'talkpage' => null,
 758+ 'threadaction' => array(
 759+ ApiBase::PARAM_TYPE => array_keys( $this->getActions() ),
 760+ ),
 761+ 'token' => null,
 762+ 'subject' => null,
 763+ 'reason' => null,
 764+ 'newparent' => null,
 765+ 'text' => null,
 766+ 'render' => null,
 767+ 'bump' => null,
 768+ 'sortkey' => null,
 769+ 'signature' => null,
 770+ );
 771+ }
 772+
 773+ public function mustBePosted() {
 774+ return true;
 775+ }
 776+
 777+ public function isWriteMode() {
 778+ return true;
 779+ }
 780+
780781 public function getVersion() {
781782 return __CLASS__ . ': $Id$';
782783 }

Status & tagging log