@@ -8,169 +8,169 @@ |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | namespace XoopsModules\Wggithub\Github { |
11 | - /** |
|
12 | - * Marker interface. |
|
13 | - */ |
|
14 | - interface IException |
|
15 | - {} |
|
11 | + /** |
|
12 | + * Marker interface. |
|
13 | + */ |
|
14 | + interface IException |
|
15 | + {} |
|
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * Wrong algorithm. API is used in wrong way. Application code should be changed. |
|
20 | - */ |
|
21 | - class LogicException extends \LogicException implements IException |
|
22 | - {} |
|
18 | + /** |
|
19 | + * Wrong algorithm. API is used in wrong way. Application code should be changed. |
|
20 | + */ |
|
21 | + class LogicException extends \LogicException implements IException |
|
22 | + {} |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Substitution is used in URL path but corresponding parameter is missing. |
|
27 | - */ |
|
28 | - class MissingParameterException extends LogicException |
|
29 | - {} |
|
25 | + /** |
|
26 | + * Substitution is used in URL path but corresponding parameter is missing. |
|
27 | + */ |
|
28 | + class MissingParameterException extends LogicException |
|
29 | + {} |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * Unpredictable situation occurred. |
|
34 | - */ |
|
35 | - abstract class RuntimeException extends \RuntimeException implements IException |
|
36 | - {} |
|
32 | + /** |
|
33 | + * Unpredictable situation occurred. |
|
34 | + */ |
|
35 | + abstract class RuntimeException extends \RuntimeException implements IException |
|
36 | + {} |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Github API returned a non-success HTTP code or data are somehow wrong. See all following descendants. |
|
41 | - * |
|
42 | - * @see Api::decode() |
|
43 | - * @see https://developer.github.com/v3/#client-errors |
|
44 | - */ |
|
45 | - abstract class ApiException extends RuntimeException |
|
46 | - { |
|
47 | - /** @var Http\Response|NULL */ |
|
48 | - private $response; |
|
39 | + /** |
|
40 | + * Github API returned a non-success HTTP code or data are somehow wrong. See all following descendants. |
|
41 | + * |
|
42 | + * @see Api::decode() |
|
43 | + * @see https://developer.github.com/v3/#client-errors |
|
44 | + */ |
|
45 | + abstract class ApiException extends RuntimeException |
|
46 | + { |
|
47 | + /** @var Http\Response|NULL */ |
|
48 | + private $response; |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @param string |
|
53 | - * @param int |
|
54 | - */ |
|
55 | - public function __construct($message = '', $code = 0, \Exception $previous = NULL, Http\Response $response = NULL) |
|
56 | - { |
|
57 | - parent::__construct($message, $code, $previous); |
|
58 | - $this->response = clone $response; |
|
59 | - } |
|
51 | + /** |
|
52 | + * @param string |
|
53 | + * @param int |
|
54 | + */ |
|
55 | + public function __construct($message = '', $code = 0, \Exception $previous = NULL, Http\Response $response = NULL) |
|
56 | + { |
|
57 | + parent::__construct($message, $code, $previous); |
|
58 | + $this->response = clone $response; |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * @return Http\Response|NULL |
|
64 | - */ |
|
65 | - final public function getResponse() |
|
66 | - { |
|
67 | - return $this->response; |
|
68 | - } |
|
62 | + /** |
|
63 | + * @return Http\Response|NULL |
|
64 | + */ |
|
65 | + final public function getResponse() |
|
66 | + { |
|
67 | + return $this->response; |
|
68 | + } |
|
69 | 69 | |
70 | - } |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * Invalid credentials (e.g. revoked token). |
|
75 | - */ |
|
76 | - class UnauthorizedException extends ApiException |
|
77 | - {} |
|
73 | + /** |
|
74 | + * Invalid credentials (e.g. revoked token). |
|
75 | + */ |
|
76 | + class UnauthorizedException extends ApiException |
|
77 | + {} |
|
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * Invalid JSON sent to Github API. |
|
82 | - */ |
|
83 | - class BadRequestException extends ApiException |
|
84 | - {} |
|
80 | + /** |
|
81 | + * Invalid JSON sent to Github API. |
|
82 | + */ |
|
83 | + class BadRequestException extends ApiException |
|
84 | + {} |
|
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * Invalid structure sent to Github API (e.g. some required fields are missing). |
|
89 | - */ |
|
90 | - class UnprocessableEntityException extends ApiException |
|
91 | - {} |
|
87 | + /** |
|
88 | + * Invalid structure sent to Github API (e.g. some required fields are missing). |
|
89 | + */ |
|
90 | + class UnprocessableEntityException extends ApiException |
|
91 | + {} |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * Access denied. |
|
96 | - * @see https://developer.github.com/v3/#authentication |
|
97 | - */ |
|
98 | - class ForbiddenException extends ApiException |
|
99 | - {} |
|
94 | + /** |
|
95 | + * Access denied. |
|
96 | + * @see https://developer.github.com/v3/#authentication |
|
97 | + */ |
|
98 | + class ForbiddenException extends ApiException |
|
99 | + {} |
|
100 | 100 | |
101 | 101 | |
102 | - /** |
|
103 | - * Rate limit exceed. |
|
104 | - * @see https://developer.github.com/v3/#rate-limiting |
|
105 | - */ |
|
106 | - class RateLimitExceedException extends ForbiddenException |
|
107 | - {} |
|
102 | + /** |
|
103 | + * Rate limit exceed. |
|
104 | + * @see https://developer.github.com/v3/#rate-limiting |
|
105 | + */ |
|
106 | + class RateLimitExceedException extends ForbiddenException |
|
107 | + {} |
|
108 | 108 | |
109 | 109 | |
110 | - /** |
|
111 | - * Resource not found. |
|
112 | - * @see https://developer.github.com/v3/#authentication |
|
113 | - */ |
|
114 | - class NotFoundException extends ApiException |
|
115 | - {} |
|
110 | + /** |
|
111 | + * Resource not found. |
|
112 | + * @see https://developer.github.com/v3/#authentication |
|
113 | + */ |
|
114 | + class NotFoundException extends ApiException |
|
115 | + {} |
|
116 | 116 | |
117 | 117 | |
118 | - /** |
|
119 | - * Response cannot be classified. |
|
120 | - */ |
|
121 | - class UnexpectedResponseException extends ApiException |
|
122 | - {} |
|
118 | + /** |
|
119 | + * Response cannot be classified. |
|
120 | + */ |
|
121 | + class UnexpectedResponseException extends ApiException |
|
122 | + {} |
|
123 | 123 | |
124 | 124 | |
125 | - /** |
|
126 | - * Response from Github is somehow wrong (e.g. invalid JSON decoding). |
|
127 | - */ |
|
128 | - class InvalidResponseException extends ApiException |
|
129 | - {} |
|
125 | + /** |
|
126 | + * Response from Github is somehow wrong (e.g. invalid JSON decoding). |
|
127 | + */ |
|
128 | + class InvalidResponseException extends ApiException |
|
129 | + {} |
|
130 | 130 | |
131 | 131 | |
132 | - /** |
|
133 | - * JSON cannot be decoded, or value cannot be encoded to JSON. |
|
134 | - */ |
|
135 | - class JsonException extends RuntimeException |
|
136 | - { |
|
137 | - } |
|
132 | + /** |
|
133 | + * JSON cannot be decoded, or value cannot be encoded to JSON. |
|
134 | + */ |
|
135 | + class JsonException extends RuntimeException |
|
136 | + { |
|
137 | + } |
|
138 | 138 | |
139 | 139 | } |
140 | 140 | |
141 | 141 | |
142 | 142 | namespace Milo\Github\Http { |
143 | - use Milo\Github; |
|
143 | + use Milo\Github; |
|
144 | 144 | |
145 | 145 | |
146 | - /** |
|
147 | - * HTTP response is somehow wrong and cannot be processed. |
|
148 | - */ |
|
149 | - class BadResponseException extends Github\RuntimeException |
|
150 | - {} |
|
146 | + /** |
|
147 | + * HTTP response is somehow wrong and cannot be processed. |
|
148 | + */ |
|
149 | + class BadResponseException extends Github\RuntimeException |
|
150 | + {} |
|
151 | 151 | |
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | 155 | namespace Milo\Github\OAuth { |
156 | - use Milo\Github; |
|
156 | + use Milo\Github; |
|
157 | 157 | |
158 | - /** |
|
159 | - * Something fails during the token obtaining. |
|
160 | - */ |
|
161 | - class LoginException extends Github\RuntimeException |
|
162 | - {} |
|
158 | + /** |
|
159 | + * Something fails during the token obtaining. |
|
160 | + */ |
|
161 | + class LoginException extends Github\RuntimeException |
|
162 | + {} |
|
163 | 163 | |
164 | 164 | } |
165 | 165 | |
166 | 166 | |
167 | 167 | namespace Milo\Github\Storages { |
168 | - use Milo\Github; |
|
168 | + use Milo\Github; |
|
169 | 169 | |
170 | - /** |
|
171 | - * Directory is missing and/or cannot be created. |
|
172 | - */ |
|
173 | - class MissingDirectoryException extends Github\RuntimeException |
|
174 | - {} |
|
170 | + /** |
|
171 | + * Directory is missing and/or cannot be created. |
|
172 | + */ |
|
173 | + class MissingDirectoryException extends Github\RuntimeException |
|
174 | + {} |
|
175 | 175 | |
176 | 176 | } |
@@ -32,61 +32,61 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class Logs extends \XoopsObject |
34 | 34 | { |
35 | - /** |
|
36 | - * Constructor |
|
37 | - * |
|
38 | - * @param null |
|
39 | - */ |
|
40 | - public function __construct() |
|
41 | - { |
|
42 | - $this->initVar('log_id', XOBJ_DTYPE_INT); |
|
35 | + /** |
|
36 | + * Constructor |
|
37 | + * |
|
38 | + * @param null |
|
39 | + */ |
|
40 | + public function __construct() |
|
41 | + { |
|
42 | + $this->initVar('log_id', XOBJ_DTYPE_INT); |
|
43 | 43 | $this->initVar('log_type', XOBJ_DTYPE_INT); |
44 | - $this->initVar('log_details', XOBJ_DTYPE_TXTBOX); |
|
45 | - $this->initVar('log_result', XOBJ_DTYPE_TXTAREA); |
|
46 | - $this->initVar('log_datecreated', XOBJ_DTYPE_INT); |
|
47 | - $this->initVar('log_submitter', XOBJ_DTYPE_INT); |
|
48 | - } |
|
44 | + $this->initVar('log_details', XOBJ_DTYPE_TXTBOX); |
|
45 | + $this->initVar('log_result', XOBJ_DTYPE_TXTAREA); |
|
46 | + $this->initVar('log_datecreated', XOBJ_DTYPE_INT); |
|
47 | + $this->initVar('log_submitter', XOBJ_DTYPE_INT); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @static function &getInstance |
|
52 | - * |
|
53 | - * @param null |
|
54 | - */ |
|
55 | - public static function getInstance() |
|
56 | - { |
|
57 | - static $instance = false; |
|
58 | - if (!$instance) { |
|
59 | - $instance = new self(); |
|
60 | - } |
|
61 | - } |
|
50 | + /** |
|
51 | + * @static function &getInstance |
|
52 | + * |
|
53 | + * @param null |
|
54 | + */ |
|
55 | + public static function getInstance() |
|
56 | + { |
|
57 | + static $instance = false; |
|
58 | + if (!$instance) { |
|
59 | + $instance = new self(); |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * The new inserted $Id |
|
65 | - * @return inserted id |
|
66 | - */ |
|
67 | - public function getNewInsertedIdLogs() |
|
68 | - { |
|
69 | - $newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
|
70 | - return $newInsertedId; |
|
71 | - } |
|
63 | + /** |
|
64 | + * The new inserted $Id |
|
65 | + * @return inserted id |
|
66 | + */ |
|
67 | + public function getNewInsertedIdLogs() |
|
68 | + { |
|
69 | + $newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
|
70 | + return $newInsertedId; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @public function getForm |
|
75 | - * @param bool $action |
|
76 | - * @return \XoopsThemeForm |
|
77 | - */ |
|
78 | - public function getFormLogs($action = false) |
|
79 | - { |
|
80 | - $helper = \XoopsModules\Wggithub\Helper::getInstance(); |
|
81 | - if (!$action) { |
|
82 | - $action = $_SERVER['REQUEST_URI']; |
|
83 | - } |
|
84 | - // Title |
|
85 | - $title = $this->isNew() ? \sprintf(_AM_WGGITHUB_LOG_ADD) : \sprintf(_AM_WGGITHUB_LOG_EDIT); |
|
86 | - // Get Theme Form |
|
87 | - \xoops_load('XoopsFormLoader'); |
|
88 | - $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
|
89 | - $form->setExtra('enctype="multipart/form-data"'); |
|
73 | + /** |
|
74 | + * @public function getForm |
|
75 | + * @param bool $action |
|
76 | + * @return \XoopsThemeForm |
|
77 | + */ |
|
78 | + public function getFormLogs($action = false) |
|
79 | + { |
|
80 | + $helper = \XoopsModules\Wggithub\Helper::getInstance(); |
|
81 | + if (!$action) { |
|
82 | + $action = $_SERVER['REQUEST_URI']; |
|
83 | + } |
|
84 | + // Title |
|
85 | + $title = $this->isNew() ? \sprintf(_AM_WGGITHUB_LOG_ADD) : \sprintf(_AM_WGGITHUB_LOG_EDIT); |
|
86 | + // Get Theme Form |
|
87 | + \xoops_load('XoopsFormLoader'); |
|
88 | + $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
|
89 | + $form->setExtra('enctype="multipart/form-data"'); |
|
90 | 90 | |
91 | 91 | $logTypeSelect = new \XoopsFormSelect(_AM_WGGITHUB_LOG_TYPE, 'log_type', $this->getVar('log_type')); |
92 | 92 | $logTypeSelect->addOption(Constants::LOG_TYPE_NONE, _AM_WGGITHUB_LOG_TYPE_NONE); |
@@ -95,35 +95,35 @@ discard block |
||
95 | 95 | $logTypeSelect->addOption(Constants::LOG_TYPE_REQUEST, _AM_WGGITHUB_LOG_TYPE_REQUEST); |
96 | 96 | $logTypeSelect->addOption(Constants::LOG_TYPE_ERROR, _AM_WGGITHUB_LOG_TYPE_ERROR); |
97 | 97 | $form->addElement($logTypeSelect); |
98 | - // Form Text logDetails |
|
99 | - $form->addElement(new \XoopsFormText(_AM_WGGITHUB_LOG_DETAILS, 'log_details', 50, 255, $this->getVar('log_details')), true); |
|
100 | - // Form Text logResult |
|
98 | + // Form Text logDetails |
|
99 | + $form->addElement(new \XoopsFormText(_AM_WGGITHUB_LOG_DETAILS, 'log_details', 50, 255, $this->getVar('log_details')), true); |
|
100 | + // Form Text logResult |
|
101 | 101 | $form->addElement(new \XoopsFormTextArea(_AM_WGGITHUB_LOG_RESULT, 'log_result', $this->getVar('log_result', 'e'), 4, 47)); |
102 | - // Form Text Date Select logDatecreated |
|
103 | - $logDatecreated = $this->isNew() ?: $this->getVar('log_datecreated'); |
|
104 | - $form->addElement(new \XoopsFormTextDateSelect(_AM_WGGITHUB_LOG_DATECREATED, 'log_datecreated', '', $logDatecreated)); |
|
105 | - // Form Select User reqSubmitter |
|
106 | - $form->addElement(new \XoopsFormSelectUser(_AM_WGGITHUB_LOG_SUBMITTER, 'log_submitter', false, $this->getVar('log_submitter'))); |
|
107 | - // To Save |
|
108 | - $form->addElement(new \XoopsFormHidden('op', 'save')); |
|
109 | - $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
|
110 | - return $form; |
|
111 | - } |
|
102 | + // Form Text Date Select logDatecreated |
|
103 | + $logDatecreated = $this->isNew() ?: $this->getVar('log_datecreated'); |
|
104 | + $form->addElement(new \XoopsFormTextDateSelect(_AM_WGGITHUB_LOG_DATECREATED, 'log_datecreated', '', $logDatecreated)); |
|
105 | + // Form Select User reqSubmitter |
|
106 | + $form->addElement(new \XoopsFormSelectUser(_AM_WGGITHUB_LOG_SUBMITTER, 'log_submitter', false, $this->getVar('log_submitter'))); |
|
107 | + // To Save |
|
108 | + $form->addElement(new \XoopsFormHidden('op', 'save')); |
|
109 | + $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
|
110 | + return $form; |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * Get Values |
|
115 | - * @param null $keys |
|
116 | - * @param null $format |
|
117 | - * @param null $maxDepth |
|
118 | - * @return array |
|
119 | - */ |
|
120 | - public function getValuesLogs($keys = null, $format = null, $maxDepth = null) |
|
121 | - { |
|
113 | + /** |
|
114 | + * Get Values |
|
115 | + * @param null $keys |
|
116 | + * @param null $format |
|
117 | + * @param null $maxDepth |
|
118 | + * @return array |
|
119 | + */ |
|
120 | + public function getValuesLogs($keys = null, $format = null, $maxDepth = null) |
|
121 | + { |
|
122 | 122 | $helper = \XoopsModules\Wggithub\Helper::getInstance(); |
123 | 123 | $utility = new \XoopsModules\Wggithub\Utility(); |
124 | 124 | $editorMaxchar = $helper->getConfig('editor_maxchar'); |
125 | - $ret = $this->getValues($keys, $format, $maxDepth); |
|
126 | - $ret['id'] = $this->getVar('log_id'); |
|
125 | + $ret = $this->getValues($keys, $format, $maxDepth); |
|
126 | + $ret['id'] = $this->getVar('log_id'); |
|
127 | 127 | $ret['type'] = $this->getVar('log_type'); |
128 | 128 | switch ($ret['type']) { |
129 | 129 | case Constants::LOG_TYPE_NONE: |
@@ -144,26 +144,26 @@ discard block |
||
144 | 144 | break; |
145 | 145 | } |
146 | 146 | $ret['type_text'] = $type_text; |
147 | - $ret['details'] = $this->getVar('log_details'); |
|
147 | + $ret['details'] = $this->getVar('log_details'); |
|
148 | 148 | $ret['result'] = \strip_tags($this->getVar('log_result', 'e')); |
149 | 149 | $ret['result_short'] = $utility::truncateHtml($ret['result'], $editorMaxchar); |
150 | - $ret['datecreated'] = \formatTimestamp($this->getVar('log_datecreated'), 'm'); |
|
151 | - $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('log_submitter')); |
|
152 | - return $ret; |
|
153 | - } |
|
150 | + $ret['datecreated'] = \formatTimestamp($this->getVar('log_datecreated'), 'm'); |
|
151 | + $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('log_submitter')); |
|
152 | + return $ret; |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * Returns an array representation of the object |
|
157 | - * |
|
158 | - * @return array |
|
159 | - */ |
|
160 | - public function toArrayRequests() |
|
161 | - { |
|
162 | - $ret = []; |
|
163 | - $vars = $this->getVars(); |
|
164 | - foreach (\array_keys($vars) as $var) { |
|
165 | - $ret[$var] = $this->getVar('"{$var}"'); |
|
166 | - } |
|
167 | - return $ret; |
|
168 | - } |
|
155 | + /** |
|
156 | + * Returns an array representation of the object |
|
157 | + * |
|
158 | + * @return array |
|
159 | + */ |
|
160 | + public function toArrayRequests() |
|
161 | + { |
|
162 | + $ret = []; |
|
163 | + $vars = $this->getVars(); |
|
164 | + foreach (\array_keys($vars) as $var) { |
|
165 | + $ret[$var] = $this->getVar('"{$var}"'); |
|
166 | + } |
|
167 | + return $ret; |
|
168 | + } |
|
169 | 169 | } |