@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | //check for minimum XOOPS version |
41 | 41 | $currentVer = mb_substr(XOOPS_VERSION, 6); // get the numeric part of string |
42 | 42 | if (null === $requiredVer) { |
43 | - $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
43 | + $requiredVer = ''.$module->getInfo('min_xoops'); //making sure it's a string |
|
44 | 44 | } |
45 | 45 | $success = true; |
46 | 46 | |
47 | 47 | if (\version_compare($currentVer, $requiredVer, '<')) { |
48 | 48 | $success = false; |
49 | - $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); |
|
49 | + $module->setErrors(\sprintf(\constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | return $success; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | if (false !== $reqVer && '' !== $reqVer) { |
77 | 77 | if (\version_compare($verNum, $reqVer, '<')) { |
78 | - $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
78 | + $module->setErrors(\sprintf(\constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
79 | 79 | $success = false; |
80 | 80 | } |
81 | 81 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $moduleDirName = \basename(dirname(__DIR__, 2)); |
98 | 98 | $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
99 | 99 | $update = ''; |
100 | - $repository = 'XoopsModules25x/' . $moduleDirName; |
|
100 | + $repository = 'XoopsModules25x/'.$moduleDirName; |
|
101 | 101 | // $repository = 'XoopsModules25x/publisher'; //for testing only |
102 | 102 | $ret = ''; |
103 | 103 | $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | if (false === $curlReturn) { |
112 | 112 | \trigger_error(\curl_error($curlHandle)); |
113 | 113 | } elseif (mb_strpos($curlReturn, 'Not Found')) { |
114 | - \trigger_error('Repository Not Found: ' . $infoReleasesUrl); |
|
114 | + \trigger_error('Repository Not Found: '.$infoReleasesUrl); |
|
115 | 115 | } else { |
116 | 116 | $file = \json_decode($curlReturn, false); |
117 | 117 | $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? reset($file)->tag_name : $default); |
118 | 118 | $latestVersion = $file[0]->tag_name; |
119 | 119 | $prerelease = $file[0]->prerelease; |
120 | 120 | if ('master' !== $latestVersionLink) { |
121 | - $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; |
|
121 | + $update = \constant('CO_'.$moduleDirNameUpper.'_'.'NEW_VERSION').$latestVersion; |
|
122 | 122 | } |
123 | 123 | //"PHP-standardized" version |
124 | 124 | $latestVersion = \mb_strtolower($latestVersion); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion)); |
127 | 127 | $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion)); |
128 | 128 | } |
129 | - $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status')); |
|
129 | + $moduleVersion = ($helper->getModule()->getInfo('version').'_'.$helper->getModule()->getInfo('module_status')); |
|
130 | 130 | //"PHP-standardized" version |
131 | 131 | $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion)); |
132 | 132 | // $moduleVersion = '1.0'; //for testing only |
@@ -31,96 +31,96 @@ |
||
31 | 31 | */ |
32 | 32 | class RequestsHandler extends \XoopsPersistableObjectHandler |
33 | 33 | { |
34 | - /** |
|
35 | - * Constructor |
|
36 | - * |
|
37 | - * @param \XoopsDatabase $db |
|
38 | - */ |
|
39 | - public function __construct(\XoopsDatabase $db) |
|
40 | - { |
|
41 | - parent::__construct($db, 'wggithub_requests', Requests::class, 'req_id', 'req_request'); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * @param bool $isNew |
|
46 | - * |
|
47 | - * @return object |
|
48 | - */ |
|
49 | - public function create($isNew = true) |
|
50 | - { |
|
51 | - return parent::create($isNew); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * retrieve a field |
|
56 | - * |
|
57 | - * @param int $i field id |
|
58 | - * @param null fields |
|
59 | - * @return mixed reference to the {@link Get} object |
|
60 | - */ |
|
61 | - public function get($i = null, $fields = null) |
|
62 | - { |
|
63 | - return parent::get($i, $fields); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * get inserted id |
|
68 | - * |
|
69 | - * @param null |
|
70 | - * @return int reference to the {@link Get} object |
|
71 | - */ |
|
72 | - public function getInsertId() |
|
73 | - { |
|
74 | - return $this->db->getInsertId(); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Get Count Requests in the database |
|
79 | - * @param int $start |
|
80 | - * @param int $limit |
|
81 | - * @param string $sort |
|
82 | - * @param string $order |
|
83 | - * @return int |
|
84 | - */ |
|
85 | - public function getCountRequests($start = 0, $limit = 0, $sort = 'req_id ASC, req_request', $order = 'ASC') |
|
86 | - { |
|
87 | - $crCountRequests = new \CriteriaCompo(); |
|
88 | - $crCountRequests = $this->getRequestsCriteria($crCountRequests, $start, $limit, $sort, $order); |
|
89 | - return $this->getCount($crCountRequests); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Get All Requests in the database |
|
94 | - * @param int $start |
|
95 | - * @param int $limit |
|
96 | - * @param string $sort |
|
97 | - * @param string $order |
|
98 | - * @return array |
|
99 | - */ |
|
100 | - public function getAllRequests($start = 0, $limit = 0, $sort = 'req_id ASC, req_request', $order = 'ASC') |
|
101 | - { |
|
102 | - $crAllRequests = new \CriteriaCompo(); |
|
103 | - $crAllRequests = $this->getRequestsCriteria($crAllRequests, $start, $limit, $sort, $order); |
|
104 | - return $this->getAll($crAllRequests); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Get Criteria Requests |
|
109 | - * @param $crRequests |
|
110 | - * @param int $start |
|
111 | - * @param int $limit |
|
112 | - * @param string $sort |
|
113 | - * @param string $order |
|
114 | - * @return int |
|
115 | - */ |
|
116 | - private function getRequestsCriteria($crRequests, $start, $limit, $sort, $order) |
|
117 | - { |
|
118 | - $crRequests->setStart($start); |
|
119 | - $crRequests->setLimit($limit); |
|
120 | - $crRequests->setSort($sort); |
|
121 | - $crRequests->setOrder($order); |
|
122 | - return $crRequests; |
|
123 | - } |
|
34 | + /** |
|
35 | + * Constructor |
|
36 | + * |
|
37 | + * @param \XoopsDatabase $db |
|
38 | + */ |
|
39 | + public function __construct(\XoopsDatabase $db) |
|
40 | + { |
|
41 | + parent::__construct($db, 'wggithub_requests', Requests::class, 'req_id', 'req_request'); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * @param bool $isNew |
|
46 | + * |
|
47 | + * @return object |
|
48 | + */ |
|
49 | + public function create($isNew = true) |
|
50 | + { |
|
51 | + return parent::create($isNew); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * retrieve a field |
|
56 | + * |
|
57 | + * @param int $i field id |
|
58 | + * @param null fields |
|
59 | + * @return mixed reference to the {@link Get} object |
|
60 | + */ |
|
61 | + public function get($i = null, $fields = null) |
|
62 | + { |
|
63 | + return parent::get($i, $fields); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * get inserted id |
|
68 | + * |
|
69 | + * @param null |
|
70 | + * @return int reference to the {@link Get} object |
|
71 | + */ |
|
72 | + public function getInsertId() |
|
73 | + { |
|
74 | + return $this->db->getInsertId(); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Get Count Requests in the database |
|
79 | + * @param int $start |
|
80 | + * @param int $limit |
|
81 | + * @param string $sort |
|
82 | + * @param string $order |
|
83 | + * @return int |
|
84 | + */ |
|
85 | + public function getCountRequests($start = 0, $limit = 0, $sort = 'req_id ASC, req_request', $order = 'ASC') |
|
86 | + { |
|
87 | + $crCountRequests = new \CriteriaCompo(); |
|
88 | + $crCountRequests = $this->getRequestsCriteria($crCountRequests, $start, $limit, $sort, $order); |
|
89 | + return $this->getCount($crCountRequests); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Get All Requests in the database |
|
94 | + * @param int $start |
|
95 | + * @param int $limit |
|
96 | + * @param string $sort |
|
97 | + * @param string $order |
|
98 | + * @return array |
|
99 | + */ |
|
100 | + public function getAllRequests($start = 0, $limit = 0, $sort = 'req_id ASC, req_request', $order = 'ASC') |
|
101 | + { |
|
102 | + $crAllRequests = new \CriteriaCompo(); |
|
103 | + $crAllRequests = $this->getRequestsCriteria($crAllRequests, $start, $limit, $sort, $order); |
|
104 | + return $this->getAll($crAllRequests); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Get Criteria Requests |
|
109 | + * @param $crRequests |
|
110 | + * @param int $start |
|
111 | + * @param int $limit |
|
112 | + * @param string $sort |
|
113 | + * @param string $order |
|
114 | + * @return int |
|
115 | + */ |
|
116 | + private function getRequestsCriteria($crRequests, $start, $limit, $sort, $order) |
|
117 | + { |
|
118 | + $crRequests->setStart($start); |
|
119 | + $crRequests->setLimit($limit); |
|
120 | + $crRequests->setSort($sort); |
|
121 | + $crRequests->setOrder($order); |
|
122 | + return $crRequests; |
|
123 | + } |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * Update table requests |
@@ -140,7 +140,7 @@ |
||
140 | 140 | $requestsObj = $requestsHandler->create(); |
141 | 141 | $requestsObj->setVar('req_request', $request); |
142 | 142 | $requestsObj->setVar('req_result', $result); |
143 | - $requestsObj->setVar('req_datecreated',time()); |
|
143 | + $requestsObj->setVar('req_datecreated', time()); |
|
144 | 144 | $requestsObj->setVar('req_submitter', $submitter); |
145 | 145 | // Insert Data |
146 | 146 | if ($requestsHandler->insert($requestsObj)) { |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | $ch = \curl_init(); |
46 | 46 | //set the url, number of POST vars, POST data |
47 | 47 | \curl_setopt($ch, \CURLOPT_URL, $url); |
48 | - \curl_setopt($ch, \CURLOPT_HTTPAUTH, 'token ' . $this->tokenAuth); |
|
49 | - \curl_setopt($ch, \CURLOPT_USERPWD, $this->userAuth . ':' . $this->tokenAuth); |
|
48 | + \curl_setopt($ch, \CURLOPT_HTTPAUTH, 'token '.$this->tokenAuth); |
|
49 | + \curl_setopt($ch, \CURLOPT_USERPWD, $this->userAuth.':'.$this->tokenAuth); |
|
50 | 50 | \curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'GET'); |
51 | 51 | \curl_setopt($ch, \CURLOPT_RETURNTRANSFER, true); |
52 | 52 | \curl_setopt($ch, \CURLOPT_CONNECTTIMEOUT, 25); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | \curl_setopt($ch, \CURLOPT_POST, 1); |
61 | 61 | $result = \curl_exec($ch); |
62 | 62 | $info = \curl_getinfo($ch); |
63 | - if (($errMsg = \curl_error($ch)) || !\in_array((int)$info['http_code'], [200, 201], true)) { |
|
63 | + if (($errMsg = \curl_error($ch)) || !\in_array((int) $info['http_code'], [200, 201], true)) { |
|
64 | 64 | $error = $throwError; |
65 | 65 | } |
66 | 66 | \curl_close($ch); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | if ($requestsHandler->insert($requestsObj, true)) { |
79 | 79 | $reqId = $requestsObj->getNewInsertedIdRequests(); |
80 | 80 | } else { |
81 | - throw new \RuntimeException('"' . \_MA_WGGITHUB_READGH_ERROR_INSERTREQ . '"'); |
|
81 | + throw new \RuntimeException('"'.\_MA_WGGITHUB_READGH_ERROR_INSERTREQ.'"'); |
|
82 | 82 | } |
83 | 83 | unset($requestsObj); |
84 | 84 | |
@@ -90,19 +90,19 @@ discard block |
||
90 | 90 | $requestsObj = $requestsHandler->get($reqId); |
91 | 91 | $requestsObj->setVar('req_result', $result); |
92 | 92 | if (!$requestsHandler->insert($requestsObj, true)) { |
93 | - throw new \RuntimeException('"' . \_MA_WGGITHUB_READGH_ERROR_INSERTREQ . '"'); |
|
93 | + throw new \RuntimeException('"'.\_MA_WGGITHUB_READGH_ERROR_INSERTREQ.'"'); |
|
94 | 94 | } |
95 | 95 | unset($requestsObj); |
96 | 96 | |
97 | 97 | if ($this->debug) { |
98 | - echo '<br>Error:' . $result; |
|
98 | + echo '<br>Error:'.$result; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | //catch common errors |
102 | - switch ((int)$info['http_code']) { |
|
102 | + switch ((int) $info['http_code']) { |
|
103 | 103 | case 401: |
104 | 104 | $this->apiErrorMisc = true; |
105 | - throw new \RuntimeException('"' . \_MA_WGGITHUB_READGH_ERROR_API_401 . '"'); |
|
105 | + throw new \RuntimeException('"'.\_MA_WGGITHUB_READGH_ERROR_API_401.'"'); |
|
106 | 106 | break; |
107 | 107 | case 403: |
108 | 108 | if (\strpos($result, 'API rate limit exceeded') > 0) { |
@@ -111,21 +111,21 @@ discard block |
||
111 | 111 | return false; |
112 | 112 | } else { |
113 | 113 | $this->apiErrorMisc = true; |
114 | - throw new \RuntimeException('"' . \_MA_WGGITHUB_READGH_ERROR_API_403 . '"'); |
|
114 | + throw new \RuntimeException('"'.\_MA_WGGITHUB_READGH_ERROR_API_403.'"'); |
|
115 | 115 | } |
116 | 116 | break; |
117 | 117 | case 404: |
118 | 118 | $this->apiErrorMisc = true; |
119 | - throw new \RuntimeException('"' . \_MA_WGGITHUB_READGH_ERROR_API_404 . '"'); |
|
119 | + throw new \RuntimeException('"'.\_MA_WGGITHUB_READGH_ERROR_API_404.'"'); |
|
120 | 120 | break; |
121 | 121 | case 405: |
122 | 122 | $this->apiErrorMisc = true; |
123 | - throw new \RuntimeException('"' . \_MA_WGGITHUB_READGH_ERROR_API_405 . '"'); |
|
123 | + throw new \RuntimeException('"'.\_MA_WGGITHUB_READGH_ERROR_API_405.'"'); |
|
124 | 124 | break; |
125 | 125 | case 0: |
126 | 126 | default: |
127 | 127 | $this->apiErrorMisc = true; |
128 | - throw new \RuntimeException('"' . \_MA_WGGITHUB_READGH_ERROR_API . ': ' . $errMsg . '"'); |
|
128 | + throw new \RuntimeException('"'.\_MA_WGGITHUB_READGH_ERROR_API.': '.$errMsg.'"'); |
|
129 | 129 | break; |
130 | 130 | } |
131 | 131 | } else { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function getReleases($user, $repository) |
36 | 36 | { |
37 | - $url = static::BASE_URL . 'repos/' . $user . '/' . $repository . '/releases'; |
|
37 | + $url = static::BASE_URL.'repos/'.$user.'/'.$repository.'/releases'; |
|
38 | 38 | |
39 | 39 | return $this->_get($url); |
40 | 40 | } |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | public function getLatestRelease($user, $repository, $prerelease = false) |
51 | 51 | { |
52 | 52 | if ($prerelease) { |
53 | - $url = static::BASE_URL . 'repos/' . $user . '/' . $repository . '/releases'; |
|
53 | + $url = static::BASE_URL.'repos/'.$user.'/'.$repository.'/releases'; |
|
54 | 54 | } else { |
55 | - $url = static::BASE_URL . 'repos/' . $user . '/' . $repository . '/releases/latest'; |
|
55 | + $url = static::BASE_URL.'repos/'.$user.'/'.$repository.'/releases/latest'; |
|
56 | 56 | } |
57 | 57 | $result = $this->_get($url); |
58 | 58 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function getUserRepositories($username, $per_page = 100, $page = 1) |
38 | 38 | { |
39 | - $url = static::BASE_URL . 'users/' . \rawurlencode($username) . '/repos?per_page=' . $per_page . '&page=' . $page; |
|
39 | + $url = static::BASE_URL.'users/'.\rawurlencode($username).'/repos?per_page='.$per_page.'&page='.$page; |
|
40 | 40 | |
41 | 41 | return $this->_get($url); |
42 | 42 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function getOrgRepositories($org, $per_page = 100, $page = 1) |
53 | 53 | { |
54 | - $url = static::BASE_URL . 'orgs/' . \rawurlencode($org) . '/repos?per_page=' . $per_page . '&page=' . $page; |
|
54 | + $url = static::BASE_URL.'orgs/'.\rawurlencode($org).'/repos?per_page='.$per_page.'&page='.$page; |
|
55 | 55 | |
56 | 56 | return $this->_get($url); |
57 | 57 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function getReadme($username, $repository) |
70 | 70 | { |
71 | - $url = static::BASE_URL . 'repos/' . \rawurlencode($username) . '/' . \rawurlencode($repository) . '/readme'; |
|
71 | + $url = static::BASE_URL.'repos/'.\rawurlencode($username).'/'.\rawurlencode($repository).'/readme'; |
|
72 | 72 | |
73 | 73 | return $this->_get($url, false, false); |
74 | 74 | } |
@@ -70,7 +70,7 @@ |
||
70 | 70 | */ |
71 | 71 | public function getHandler($name) |
72 | 72 | { |
73 | - $class = __NAMESPACE__ . '\\' . \ucfirst($name) . 'Handler'; |
|
73 | + $class = __NAMESPACE__.'\\'.\ucfirst($name).'Handler'; |
|
74 | 74 | if (!\class_exists($class)) { |
75 | 75 | throw new \RuntimeException("Class '$class' not found"); |
76 | 76 | } |
@@ -32,110 +32,110 @@ |
||
32 | 32 | */ |
33 | 33 | class Requests extends \XoopsObject |
34 | 34 | { |
35 | - /** |
|
36 | - * Constructor |
|
37 | - * |
|
38 | - * @param null |
|
39 | - */ |
|
40 | - public function __construct() |
|
41 | - { |
|
42 | - $this->initVar('req_id', XOBJ_DTYPE_INT); |
|
43 | - $this->initVar('req_request', XOBJ_DTYPE_TXTBOX); |
|
44 | - $this->initVar('req_result', XOBJ_DTYPE_TXTAREA); |
|
45 | - $this->initVar('req_datecreated', XOBJ_DTYPE_INT); |
|
46 | - $this->initVar('req_submitter', XOBJ_DTYPE_INT); |
|
47 | - } |
|
35 | + /** |
|
36 | + * Constructor |
|
37 | + * |
|
38 | + * @param null |
|
39 | + */ |
|
40 | + public function __construct() |
|
41 | + { |
|
42 | + $this->initVar('req_id', XOBJ_DTYPE_INT); |
|
43 | + $this->initVar('req_request', XOBJ_DTYPE_TXTBOX); |
|
44 | + $this->initVar('req_result', XOBJ_DTYPE_TXTAREA); |
|
45 | + $this->initVar('req_datecreated', XOBJ_DTYPE_INT); |
|
46 | + $this->initVar('req_submitter', XOBJ_DTYPE_INT); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @static function &getInstance |
|
51 | - * |
|
52 | - * @param null |
|
53 | - */ |
|
54 | - public static function getInstance() |
|
55 | - { |
|
56 | - static $instance = false; |
|
57 | - if (!$instance) { |
|
58 | - $instance = new self(); |
|
59 | - } |
|
60 | - } |
|
49 | + /** |
|
50 | + * @static function &getInstance |
|
51 | + * |
|
52 | + * @param null |
|
53 | + */ |
|
54 | + public static function getInstance() |
|
55 | + { |
|
56 | + static $instance = false; |
|
57 | + if (!$instance) { |
|
58 | + $instance = new self(); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * The new inserted $Id |
|
64 | - * @return inserted id |
|
65 | - */ |
|
66 | - public function getNewInsertedIdRequests() |
|
67 | - { |
|
68 | - $newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
|
69 | - return $newInsertedId; |
|
70 | - } |
|
62 | + /** |
|
63 | + * The new inserted $Id |
|
64 | + * @return inserted id |
|
65 | + */ |
|
66 | + public function getNewInsertedIdRequests() |
|
67 | + { |
|
68 | + $newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
|
69 | + return $newInsertedId; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @public function getForm |
|
74 | - * @param bool $action |
|
75 | - * @return \XoopsThemeForm |
|
76 | - */ |
|
77 | - public function getFormRequests($action = false) |
|
78 | - { |
|
79 | - $helper = \XoopsModules\Wggithub\Helper::getInstance(); |
|
80 | - if (!$action) { |
|
81 | - $action = $_SERVER['REQUEST_URI']; |
|
82 | - } |
|
83 | - $isAdmin = $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid()); |
|
84 | - // Title |
|
85 | - $title = $this->isNew() ? \sprintf(_AM_WGGITHUB_REQUEST_ADD) : \sprintf(_AM_WGGITHUB_REQUEST_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 | - // Form Text reqRequest |
|
91 | - $form->addElement(new \XoopsFormText(_AM_WGGITHUB_REQUEST_REQUEST, 'req_request', 50, 255, $this->getVar('req_request')), true); |
|
92 | - // Form Text reqResult |
|
72 | + /** |
|
73 | + * @public function getForm |
|
74 | + * @param bool $action |
|
75 | + * @return \XoopsThemeForm |
|
76 | + */ |
|
77 | + public function getFormRequests($action = false) |
|
78 | + { |
|
79 | + $helper = \XoopsModules\Wggithub\Helper::getInstance(); |
|
80 | + if (!$action) { |
|
81 | + $action = $_SERVER['REQUEST_URI']; |
|
82 | + } |
|
83 | + $isAdmin = $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid()); |
|
84 | + // Title |
|
85 | + $title = $this->isNew() ? \sprintf(_AM_WGGITHUB_REQUEST_ADD) : \sprintf(_AM_WGGITHUB_REQUEST_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 | + // Form Text reqRequest |
|
91 | + $form->addElement(new \XoopsFormText(_AM_WGGITHUB_REQUEST_REQUEST, 'req_request', 50, 255, $this->getVar('req_request')), true); |
|
92 | + // Form Text reqResult |
|
93 | 93 | $form->addElement(new \XoopsFormTextArea(_AM_WGGITHUB_REQUEST_RESULT, 'req_result', $this->getVar('req_result', 'e'), 4, 47)); |
94 | - // Form Text Date Select reqDatecreated |
|
95 | - $reqDatecreated = $this->isNew() ?: $this->getVar('req_datecreated'); |
|
96 | - $form->addElement(new \XoopsFormTextDateSelect(_AM_WGGITHUB_REQUEST_DATECREATED, 'req_datecreated', '', $reqDatecreated)); |
|
97 | - // Form Select User reqSubmitter |
|
98 | - $form->addElement(new \XoopsFormSelectUser(_AM_WGGITHUB_REQUEST_SUBMITTER, 'req_submitter', false, $this->getVar('req_submitter'))); |
|
99 | - // To Save |
|
100 | - $form->addElement(new \XoopsFormHidden('op', 'save')); |
|
101 | - $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
|
102 | - return $form; |
|
103 | - } |
|
94 | + // Form Text Date Select reqDatecreated |
|
95 | + $reqDatecreated = $this->isNew() ?: $this->getVar('req_datecreated'); |
|
96 | + $form->addElement(new \XoopsFormTextDateSelect(_AM_WGGITHUB_REQUEST_DATECREATED, 'req_datecreated', '', $reqDatecreated)); |
|
97 | + // Form Select User reqSubmitter |
|
98 | + $form->addElement(new \XoopsFormSelectUser(_AM_WGGITHUB_REQUEST_SUBMITTER, 'req_submitter', false, $this->getVar('req_submitter'))); |
|
99 | + // To Save |
|
100 | + $form->addElement(new \XoopsFormHidden('op', 'save')); |
|
101 | + $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
|
102 | + return $form; |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * Get Values |
|
107 | - * @param null $keys |
|
108 | - * @param null $format |
|
109 | - * @param null $maxDepth |
|
110 | - * @return array |
|
111 | - */ |
|
112 | - public function getValuesRequests($keys = null, $format = null, $maxDepth = null) |
|
113 | - { |
|
105 | + /** |
|
106 | + * Get Values |
|
107 | + * @param null $keys |
|
108 | + * @param null $format |
|
109 | + * @param null $maxDepth |
|
110 | + * @return array |
|
111 | + */ |
|
112 | + public function getValuesRequests($keys = null, $format = null, $maxDepth = null) |
|
113 | + { |
|
114 | 114 | $helper = \XoopsModules\Wggithub\Helper::getInstance(); |
115 | 115 | $utility = new \XoopsModules\Wggithub\Utility(); |
116 | - $ret = $this->getValues($keys, $format, $maxDepth); |
|
117 | - $ret['id'] = $this->getVar('req_id'); |
|
118 | - $ret['request'] = $this->getVar('req_request'); |
|
116 | + $ret = $this->getValues($keys, $format, $maxDepth); |
|
117 | + $ret['id'] = $this->getVar('req_id'); |
|
118 | + $ret['request'] = $this->getVar('req_request'); |
|
119 | 119 | $ret['result'] = \strip_tags($this->getVar('req_result', 'e')); |
120 | 120 | $editorMaxchar = $helper->getConfig('editor_maxchar'); |
121 | 121 | $ret['result_short'] = $utility::truncateHtml($ret['result'], $editorMaxchar); |
122 | - $ret['datecreated'] = \formatTimestamp($this->getVar('req_datecreated'), 'm'); |
|
123 | - $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('req_submitter')); |
|
124 | - return $ret; |
|
125 | - } |
|
122 | + $ret['datecreated'] = \formatTimestamp($this->getVar('req_datecreated'), 'm'); |
|
123 | + $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('req_submitter')); |
|
124 | + return $ret; |
|
125 | + } |
|
126 | 126 | |
127 | - /** |
|
128 | - * Returns an array representation of the object |
|
129 | - * |
|
130 | - * @return array |
|
131 | - */ |
|
132 | - public function toArrayRequests() |
|
133 | - { |
|
134 | - $ret = []; |
|
135 | - $vars = $this->getVars(); |
|
136 | - foreach (\array_keys($vars) as $var) { |
|
137 | - $ret[$var] = $this->getVar('"{$var}"'); |
|
138 | - } |
|
139 | - return $ret; |
|
140 | - } |
|
127 | + /** |
|
128 | + * Returns an array representation of the object |
|
129 | + * |
|
130 | + * @return array |
|
131 | + */ |
|
132 | + public function toArrayRequests() |
|
133 | + { |
|
134 | + $ret = []; |
|
135 | + $vars = $this->getVars(); |
|
136 | + foreach (\array_keys($vars) as $var) { |
|
137 | + $ret[$var] = $this->getVar('"{$var}"'); |
|
138 | + } |
|
139 | + return $ret; |
|
140 | + } |
|
141 | 141 | } |
@@ -1991,8 +1991,8 @@ |
||
1991 | 1991 | 'q', 'rt', 'ins', 'font', 'strong', |
1992 | 1992 | 's', 'tt', 'kbd', 'mark', |
1993 | 1993 | 'u', 'xm', 'sub', 'nobr', |
1994 | - 'sup', 'ruby', |
|
1995 | - 'var', 'span', |
|
1996 | - 'wbr', 'time', |
|
1994 | + 'sup', 'ruby', |
|
1995 | + 'var', 'span', |
|
1996 | + 'wbr', 'time', |
|
1997 | 1997 | ); |
1998 | 1998 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | if (isset($CurrentBlock['continuable'])) |
211 | 211 | { |
212 | - $methodName = 'block' . $CurrentBlock['type'] . 'Continue'; |
|
212 | + $methodName = 'block'.$CurrentBlock['type'].'Continue'; |
|
213 | 213 | $Block = $this->$methodName($Line, $CurrentBlock); |
214 | 214 | |
215 | 215 | if (isset($Block)) |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | { |
223 | 223 | if ($this->isBlockCompletable($CurrentBlock['type'])) |
224 | 224 | { |
225 | - $methodName = 'block' . $CurrentBlock['type'] . 'Complete'; |
|
225 | + $methodName = 'block'.$CurrentBlock['type'].'Complete'; |
|
226 | 226 | $CurrentBlock = $this->$methodName($CurrentBlock); |
227 | 227 | } |
228 | 228 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | { |
241 | 241 | foreach ($this->BlockTypes[$marker] as $blockType) |
242 | 242 | { |
243 | - $blockTypes []= $blockType; |
|
243 | + $blockTypes [] = $blockType; |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | { |
256 | 256 | $Block['type'] = $blockType; |
257 | 257 | |
258 | - if ( ! isset($Block['identified'])) |
|
258 | + if (!isset($Block['identified'])) |
|
259 | 259 | { |
260 | 260 | if (isset($CurrentBlock)) |
261 | 261 | { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | |
305 | 305 | if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type'])) |
306 | 306 | { |
307 | - $methodName = 'block' . $CurrentBlock['type'] . 'Complete'; |
|
307 | + $methodName = 'block'.$CurrentBlock['type'].'Complete'; |
|
308 | 308 | $CurrentBlock = $this->$methodName($CurrentBlock); |
309 | 309 | } |
310 | 310 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | |
323 | 323 | protected function extractElement(array $Component) |
324 | 324 | { |
325 | - if ( ! isset($Component['element'])) |
|
325 | + if (!isset($Component['element'])) |
|
326 | 326 | { |
327 | 327 | if (isset($Component['markup'])) |
328 | 328 | { |
@@ -339,12 +339,12 @@ discard block |
||
339 | 339 | |
340 | 340 | protected function isBlockContinuable($Type) |
341 | 341 | { |
342 | - return method_exists($this, 'block' . $Type . 'Continue'); |
|
342 | + return method_exists($this, 'block'.$Type.'Continue'); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | protected function isBlockCompletable($Type) |
346 | 346 | { |
347 | - return method_exists($this, 'block' . $Type . 'Complete'); |
|
347 | + return method_exists($this, 'block'.$Type.'Complete'); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | # |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | |
353 | 353 | protected function blockCode($Line, $Block = null) |
354 | 354 | { |
355 | - if (isset($Block) and $Block['type'] === 'Paragraph' and ! isset($Block['interrupted'])) |
|
355 | + if (isset($Block) and $Block['type'] === 'Paragraph' and !isset($Block['interrupted'])) |
|
356 | 356 | { |
357 | 357 | return; |
358 | 358 | } |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | return; |
437 | 437 | } |
438 | 438 | |
439 | - $Block['element']['rawHtml'] .= "\n" . $Line['body']; |
|
439 | + $Block['element']['rawHtml'] .= "\n".$Line['body']; |
|
440 | 440 | |
441 | 441 | if (strpos($Line['text'], '-->') !== false) |
442 | 442 | { |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | return $Block; |
528 | 528 | } |
529 | 529 | |
530 | - $Block['element']['element']['text'] .= "\n" . $Line['body']; |
|
530 | + $Block['element']['element']['text'] .= "\n".$Line['body']; |
|
531 | 531 | |
532 | 532 | return $Block; |
533 | 533 | } |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | |
561 | 561 | $Block = array( |
562 | 562 | 'element' => array( |
563 | - 'name' => 'h' . $level, |
|
563 | + 'name' => 'h'.$level, |
|
564 | 564 | 'handler' => array( |
565 | 565 | 'function' => 'lineElements', |
566 | 566 | 'argument' => $text, |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | { |
588 | 588 | $contentIndent -= 1; |
589 | 589 | $matches[1] = substr($matches[1], 0, -$contentIndent); |
590 | - $matches[3] = str_repeat(' ', $contentIndent) . $matches[3]; |
|
590 | + $matches[3] = str_repeat(' ', $contentIndent).$matches[3]; |
|
591 | 591 | } |
592 | 592 | elseif ($contentIndent === 0) |
593 | 593 | { |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | if ( |
621 | 621 | isset($CurrentBlock) |
622 | 622 | and $CurrentBlock['type'] === 'Paragraph' |
623 | - and ! isset($CurrentBlock['interrupted']) |
|
623 | + and !isset($CurrentBlock['interrupted']) |
|
624 | 624 | ) { |
625 | 625 | return; |
626 | 626 | } |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | ) |
639 | 639 | ); |
640 | 640 | |
641 | - $Block['element']['elements'] []= & $Block['li']; |
|
641 | + $Block['element']['elements'] [] = & $Block['li']; |
|
642 | 642 | |
643 | 643 | return $Block; |
644 | 644 | } |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | ) { |
667 | 667 | if (isset($Block['interrupted'])) |
668 | 668 | { |
669 | - $Block['li']['handler']['argument'] []= ''; |
|
669 | + $Block['li']['handler']['argument'] [] = ''; |
|
670 | 670 | |
671 | 671 | $Block['loose'] = true; |
672 | 672 | |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | ) |
689 | 689 | ); |
690 | 690 | |
691 | - $Block['element']['elements'] []= & $Block['li']; |
|
691 | + $Block['element']['elements'] [] = & $Block['li']; |
|
692 | 692 | |
693 | 693 | return $Block; |
694 | 694 | } |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | { |
707 | 707 | if (isset($Block['interrupted'])) |
708 | 708 | { |
709 | - $Block['li']['handler']['argument'] []= ''; |
|
709 | + $Block['li']['handler']['argument'] [] = ''; |
|
710 | 710 | |
711 | 711 | $Block['loose'] = true; |
712 | 712 | |
@@ -715,16 +715,16 @@ discard block |
||
715 | 715 | |
716 | 716 | $text = substr($Line['body'], $requiredIndent); |
717 | 717 | |
718 | - $Block['li']['handler']['argument'] []= $text; |
|
718 | + $Block['li']['handler']['argument'] [] = $text; |
|
719 | 719 | |
720 | 720 | return $Block; |
721 | 721 | } |
722 | 722 | |
723 | - if ( ! isset($Block['interrupted'])) |
|
723 | + if (!isset($Block['interrupted'])) |
|
724 | 724 | { |
725 | 725 | $text = preg_replace('/^[ ]{0,'.$requiredIndent.'}+/', '', $Line['body']); |
726 | 726 | |
727 | - $Block['li']['handler']['argument'] []= $text; |
|
727 | + $Block['li']['handler']['argument'] [] = $text; |
|
728 | 728 | |
729 | 729 | return $Block; |
730 | 730 | } |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | { |
739 | 739 | if (end($li['handler']['argument']) !== '') |
740 | 740 | { |
741 | - $li['handler']['argument'] []= ''; |
|
741 | + $li['handler']['argument'] [] = ''; |
|
742 | 742 | } |
743 | 743 | } |
744 | 744 | } |
@@ -777,14 +777,14 @@ discard block |
||
777 | 777 | |
778 | 778 | if ($Line['text'][0] === '>' and preg_match('/^>[ ]?+(.*+)/', $Line['text'], $matches)) |
779 | 779 | { |
780 | - $Block['element']['handler']['argument'] []= $matches[1]; |
|
780 | + $Block['element']['handler']['argument'] [] = $matches[1]; |
|
781 | 781 | |
782 | 782 | return $Block; |
783 | 783 | } |
784 | 784 | |
785 | - if ( ! isset($Block['interrupted'])) |
|
785 | + if (!isset($Block['interrupted'])) |
|
786 | 786 | { |
787 | - $Block['element']['handler']['argument'] []= $Line['text']; |
|
787 | + $Block['element']['handler']['argument'] [] = $Line['text']; |
|
788 | 788 | |
789 | 789 | return $Block; |
790 | 790 | } |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | |
815 | 815 | protected function blockSetextHeader($Line, array $Block = null) |
816 | 816 | { |
817 | - if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted'])) |
|
817 | + if (!isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted'])) |
|
818 | 818 | { |
819 | 819 | return; |
820 | 820 | } |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | return; |
866 | 866 | } |
867 | 867 | |
868 | - $Block['element']['rawHtml'] .= "\n" . $Line['body']; |
|
868 | + $Block['element']['rawHtml'] .= "\n".$Line['body']; |
|
869 | 869 | |
870 | 870 | return $Block; |
871 | 871 | } |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | |
901 | 901 | protected function blockTable($Line, array $Block = null) |
902 | 902 | { |
903 | - if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted'])) |
|
903 | + if (!isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted'])) |
|
904 | 904 | { |
905 | 905 | return; |
906 | 906 | } |
@@ -949,7 +949,7 @@ discard block |
||
949 | 949 | $alignment = $alignment === 'left' ? 'center' : 'right'; |
950 | 950 | } |
951 | 951 | |
952 | - $alignments []= $alignment; |
|
952 | + $alignments [] = $alignment; |
|
953 | 953 | } |
954 | 954 | |
955 | 955 | # ~ |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | ); |
991 | 991 | } |
992 | 992 | |
993 | - $HeaderElements []= $HeaderElement; |
|
993 | + $HeaderElements [] = $HeaderElement; |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | # ~ |
@@ -1004,16 +1004,16 @@ discard block |
||
1004 | 1004 | ), |
1005 | 1005 | ); |
1006 | 1006 | |
1007 | - $Block['element']['elements'] []= array( |
|
1007 | + $Block['element']['elements'] [] = array( |
|
1008 | 1008 | 'name' => 'thead', |
1009 | 1009 | ); |
1010 | 1010 | |
1011 | - $Block['element']['elements'] []= array( |
|
1011 | + $Block['element']['elements'] [] = array( |
|
1012 | 1012 | 'name' => 'tbody', |
1013 | 1013 | 'elements' => array(), |
1014 | 1014 | ); |
1015 | 1015 | |
1016 | - $Block['element']['elements'][0]['elements'] []= array( |
|
1016 | + $Block['element']['elements'][0]['elements'] [] = array( |
|
1017 | 1017 | 'name' => 'tr', |
1018 | 1018 | 'elements' => $HeaderElements, |
1019 | 1019 | ); |
@@ -1057,11 +1057,11 @@ discard block |
||
1057 | 1057 | if (isset($Block['alignments'][$index])) |
1058 | 1058 | { |
1059 | 1059 | $Element['attributes'] = array( |
1060 | - 'style' => 'text-align: ' . $Block['alignments'][$index] . ';', |
|
1060 | + 'style' => 'text-align: '.$Block['alignments'][$index].';', |
|
1061 | 1061 | ); |
1062 | 1062 | } |
1063 | 1063 | |
1064 | - $Elements []= $Element; |
|
1064 | + $Elements [] = $Element; |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | $Element = array( |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | 'elements' => $Elements, |
1070 | 1070 | ); |
1071 | 1071 | |
1072 | - $Block['element']['elements'][1]['elements'] []= $Element; |
|
1072 | + $Block['element']['elements'][1]['elements'] [] = $Element; |
|
1073 | 1073 | |
1074 | 1074 | return $Block; |
1075 | 1075 | } |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | |
1170 | 1170 | $Inline = $this->{"inline$inlineType"}($Excerpt); |
1171 | 1171 | |
1172 | - if ( ! isset($Inline)) |
|
1172 | + if (!isset($Inline)) |
|
1173 | 1173 | { |
1174 | 1174 | continue; |
1175 | 1175 | } |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | |
1184 | 1184 | # sets a default inline position |
1185 | 1185 | |
1186 | - if ( ! isset($Inline['position'])) |
|
1186 | + if (!isset($Inline['position'])) |
|
1187 | 1187 | { |
1188 | 1188 | $Inline['position'] = $markerPosition; |
1189 | 1189 | } |
@@ -1227,7 +1227,7 @@ discard block |
||
1227 | 1227 | |
1228 | 1228 | foreach ($Elements as &$Element) |
1229 | 1229 | { |
1230 | - if ( ! isset($Element['autobreak'])) |
|
1230 | + if (!isset($Element['autobreak'])) |
|
1231 | 1231 | { |
1232 | 1232 | $Element['autobreak'] = false; |
1233 | 1233 | } |
@@ -1283,14 +1283,14 @@ discard block |
||
1283 | 1283 | $hostnameLabel = '[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?'; |
1284 | 1284 | |
1285 | 1285 | $commonMarkEmail = '[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]++@' |
1286 | - . $hostnameLabel . '(?:\.' . $hostnameLabel . ')*'; |
|
1286 | + . $hostnameLabel.'(?:\.'.$hostnameLabel.')*'; |
|
1287 | 1287 | |
1288 | 1288 | if (strpos($Excerpt['text'], '>') !== false |
1289 | 1289 | and preg_match("/^<((mailto:)?$commonMarkEmail)>/i", $Excerpt['text'], $matches) |
1290 | - ){ |
|
1290 | + ) { |
|
1291 | 1291 | $url = $matches[1]; |
1292 | 1292 | |
1293 | - if ( ! isset($matches[2])) |
|
1293 | + if (!isset($matches[2])) |
|
1294 | 1294 | { |
1295 | 1295 | $url = "mailto:$url"; |
1296 | 1296 | } |
@@ -1310,7 +1310,7 @@ discard block |
||
1310 | 1310 | |
1311 | 1311 | protected function inlineEmphasis($Excerpt) |
1312 | 1312 | { |
1313 | - if ( ! isset($Excerpt['text'][1])) |
|
1313 | + if (!isset($Excerpt['text'][1])) |
|
1314 | 1314 | { |
1315 | 1315 | return; |
1316 | 1316 | } |
@@ -1356,12 +1356,12 @@ discard block |
||
1356 | 1356 | |
1357 | 1357 | protected function inlineImage($Excerpt) |
1358 | 1358 | { |
1359 | - if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[') |
|
1359 | + if (!isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[') |
|
1360 | 1360 | { |
1361 | 1361 | return; |
1362 | 1362 | } |
1363 | 1363 | |
1364 | - $Excerpt['text']= substr($Excerpt['text'], 1); |
|
1364 | + $Excerpt['text'] = substr($Excerpt['text'], 1); |
|
1365 | 1365 | |
1366 | 1366 | $Link = $this->inlineLink($Excerpt); |
1367 | 1367 | |
@@ -1447,7 +1447,7 @@ discard block |
||
1447 | 1447 | $definition = strtolower($Element['handler']['argument']); |
1448 | 1448 | } |
1449 | 1449 | |
1450 | - if ( ! isset($this->DefinitionData['Reference'][$definition])) |
|
1450 | + if (!isset($this->DefinitionData['Reference'][$definition])) |
|
1451 | 1451 | { |
1452 | 1452 | return; |
1453 | 1453 | } |
@@ -1502,7 +1502,7 @@ discard block |
||
1502 | 1502 | and preg_match('/^&(#?+[0-9a-zA-Z]++);/', $Excerpt['text'], $matches) |
1503 | 1503 | ) { |
1504 | 1504 | return array( |
1505 | - 'element' => array('rawHtml' => '&' . $matches[1] . ';'), |
|
1505 | + 'element' => array('rawHtml' => '&'.$matches[1].';'), |
|
1506 | 1506 | 'extent' => strlen($matches[0]), |
1507 | 1507 | ); |
1508 | 1508 | } |
@@ -1512,7 +1512,7 @@ discard block |
||
1512 | 1512 | |
1513 | 1513 | protected function inlineStrikethrough($Excerpt) |
1514 | 1514 | { |
1515 | - if ( ! isset($Excerpt['text'][1])) |
|
1515 | + if (!isset($Excerpt['text'][1])) |
|
1516 | 1516 | { |
1517 | 1517 | return; |
1518 | 1518 | } |
@@ -1535,7 +1535,7 @@ discard block |
||
1535 | 1535 | |
1536 | 1536 | protected function inlineUrl($Excerpt) |
1537 | 1537 | { |
1538 | - if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/') |
|
1538 | + if ($this->urlsLinked !== true or !isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/') |
|
1539 | 1539 | { |
1540 | 1540 | return; |
1541 | 1541 | } |
@@ -1706,7 +1706,7 @@ discard block |
||
1706 | 1706 | |
1707 | 1707 | if ($hasName) |
1708 | 1708 | { |
1709 | - $markup .= '<' . $Element['name']; |
|
1709 | + $markup .= '<'.$Element['name']; |
|
1710 | 1710 | |
1711 | 1711 | if (isset($Element['attributes'])) |
1712 | 1712 | { |
@@ -1764,7 +1764,7 @@ discard block |
||
1764 | 1764 | } |
1765 | 1765 | } |
1766 | 1766 | |
1767 | - $markup .= $hasName ? '</' . $Element['name'] . '>' : ''; |
|
1767 | + $markup .= $hasName ? '</'.$Element['name'].'>' : ''; |
|
1768 | 1768 | } |
1769 | 1769 | elseif ($hasName) |
1770 | 1770 | { |
@@ -1793,7 +1793,7 @@ discard block |
||
1793 | 1793 | // (autobreak === false) covers both sides of an element |
1794 | 1794 | $autoBreak = !$autoBreak ? $autoBreak : $autoBreakNext; |
1795 | 1795 | |
1796 | - $markup .= ($autoBreak ? "\n" : '') . $this->element($Element); |
|
1796 | + $markup .= ($autoBreak ? "\n" : '').$this->element($Element); |
|
1797 | 1797 | $autoBreak = $autoBreakNext; |
1798 | 1798 | } |
1799 | 1799 | |
@@ -1808,7 +1808,7 @@ discard block |
||
1808 | 1808 | { |
1809 | 1809 | $Elements = $this->linesElements($lines); |
1810 | 1810 | |
1811 | - if ( ! in_array('', $lines) |
|
1811 | + if (!in_array('', $lines) |
|
1812 | 1812 | and isset($Elements[0]) and isset($Elements[0]['name']) |
1813 | 1813 | and $Elements[0]['name'] === 'p' |
1814 | 1814 | ) { |
@@ -1865,12 +1865,12 @@ discard block |
||
1865 | 1865 | protected function sanitiseElement(array $Element) |
1866 | 1866 | { |
1867 | 1867 | static $goodAttribute = '/^[a-zA-Z0-9][a-zA-Z0-9-_]*+$/'; |
1868 | - static $safeUrlNameToAtt = array( |
|
1868 | + static $safeUrlNameToAtt = array( |
|
1869 | 1869 | 'a' => 'href', |
1870 | 1870 | 'img' => 'src', |
1871 | 1871 | ); |
1872 | 1872 | |
1873 | - if ( ! isset($Element['name'])) |
|
1873 | + if (!isset($Element['name'])) |
|
1874 | 1874 | { |
1875 | 1875 | unset($Element['attributes']); |
1876 | 1876 | return $Element; |
@@ -1881,12 +1881,12 @@ discard block |
||
1881 | 1881 | $Element = $this->filterUnsafeUrlInAttribute($Element, $safeUrlNameToAtt[$Element['name']]); |
1882 | 1882 | } |
1883 | 1883 | |
1884 | - if ( ! empty($Element['attributes'])) |
|
1884 | + if (!empty($Element['attributes'])) |
|
1885 | 1885 | { |
1886 | 1886 | foreach ($Element['attributes'] as $att => $val) |
1887 | 1887 | { |
1888 | 1888 | # filter out badly parsed attribute |
1889 | - if ( ! preg_match($goodAttribute, $att)) |
|
1889 | + if (!preg_match($goodAttribute, $att)) |
|
1890 | 1890 | { |
1891 | 1891 | unset($Element['attributes'][$att]); |
1892 | 1892 | } |
@@ -1987,8 +1987,8 @@ discard block |
||
1987 | 1987 | protected $textLevelElements = array( |
1988 | 1988 | 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont', |
1989 | 1989 | 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing', |
1990 | - 'i', 'rp', 'del', 'code', 'strike', 'marquee', |
|
1991 | - 'q', 'rt', 'ins', 'font', 'strong', |
|
1990 | + 'i', 'rp', 'del', 'code', 'strike', 'marquee', |
|
1991 | + 'q', 'rt', 'ins', 'font', 'strong', |
|
1992 | 1992 | 's', 'tt', 'kbd', 'mark', |
1993 | 1993 | 'u', 'xm', 'sub', 'nobr', |
1994 | 1994 | 'sup', 'ruby', |
@@ -217,8 +217,7 @@ discard block |
||
217 | 217 | $CurrentBlock = $Block; |
218 | 218 | |
219 | 219 | continue; |
220 | - } |
|
221 | - else |
|
220 | + } else |
|
222 | 221 | { |
223 | 222 | if ($this->isBlockCompletable($CurrentBlock['type'])) |
224 | 223 | { |
@@ -286,8 +285,7 @@ discard block |
||
286 | 285 | if (isset($Block)) |
287 | 286 | { |
288 | 287 | $CurrentBlock = $Block; |
289 | - } |
|
290 | - else |
|
288 | + } else |
|
291 | 289 | { |
292 | 290 | if (isset($CurrentBlock)) |
293 | 291 | { |
@@ -327,8 +325,7 @@ discard block |
||
327 | 325 | if (isset($Component['markup'])) |
328 | 326 | { |
329 | 327 | $Component['element'] = array('rawHtml' => $Component['markup']); |
330 | - } |
|
331 | - elseif (isset($Component['hidden'])) |
|
328 | + } elseif (isset($Component['hidden'])) |
|
332 | 329 | { |
333 | 330 | $Component['element'] = array(); |
334 | 331 | } |
@@ -588,8 +585,7 @@ discard block |
||
588 | 585 | $contentIndent -= 1; |
589 | 586 | $matches[1] = substr($matches[1], 0, -$contentIndent); |
590 | 587 | $matches[3] = str_repeat(' ', $contentIndent) . $matches[3]; |
591 | - } |
|
592 | - elseif ($contentIndent === 0) |
|
588 | + } elseif ($contentIndent === 0) |
|
593 | 589 | { |
594 | 590 | $matches[1] .= ' '; |
595 | 591 | } |
@@ -691,8 +687,7 @@ discard block |
||
691 | 687 | $Block['element']['elements'] []= & $Block['li']; |
692 | 688 | |
693 | 689 | return $Block; |
694 | - } |
|
695 | - elseif ($Line['indent'] < $requiredIndent and $this->blockList($Line)) |
|
690 | + } elseif ($Line['indent'] < $requiredIndent and $this->blockList($Line)) |
|
696 | 691 | { |
697 | 692 | return null; |
698 | 693 | } |
@@ -1320,12 +1315,10 @@ discard block |
||
1320 | 1315 | if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches)) |
1321 | 1316 | { |
1322 | 1317 | $emphasis = 'strong'; |
1323 | - } |
|
1324 | - elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches)) |
|
1318 | + } elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches)) |
|
1325 | 1319 | { |
1326 | 1320 | $emphasis = 'em'; |
1327 | - } |
|
1328 | - else |
|
1321 | + } else |
|
1329 | 1322 | { |
1330 | 1323 | return; |
1331 | 1324 | } |
@@ -1416,8 +1409,7 @@ discard block |
||
1416 | 1409 | $extent += strlen($matches[0]); |
1417 | 1410 | |
1418 | 1411 | $remainder = substr($remainder, $extent); |
1419 | - } |
|
1420 | - else |
|
1412 | + } else |
|
1421 | 1413 | { |
1422 | 1414 | return; |
1423 | 1415 | } |
@@ -1432,8 +1424,7 @@ discard block |
||
1432 | 1424 | } |
1433 | 1425 | |
1434 | 1426 | $extent += strlen($matches[0]); |
1435 | - } |
|
1436 | - else |
|
1427 | + } else |
|
1437 | 1428 | { |
1438 | 1429 | if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches)) |
1439 | 1430 | { |
@@ -1441,8 +1432,7 @@ discard block |
||
1441 | 1432 | $definition = strtolower($definition); |
1442 | 1433 | |
1443 | 1434 | $extent += strlen($matches[0]); |
1444 | - } |
|
1445 | - else |
|
1435 | + } else |
|
1446 | 1436 | { |
1447 | 1437 | $definition = strtolower($Element['handler']['argument']); |
1448 | 1438 | } |
@@ -1607,8 +1597,7 @@ discard block |
||
1607 | 1597 | $argument = $Element['text']; |
1608 | 1598 | unset($Element['text']); |
1609 | 1599 | $destination = 'rawHtml'; |
1610 | - } |
|
1611 | - else |
|
1600 | + } else |
|
1612 | 1601 | { |
1613 | 1602 | $function = $Element['handler']['function']; |
1614 | 1603 | $argument = $Element['handler']['argument']; |
@@ -1645,8 +1634,7 @@ discard block |
||
1645 | 1634 | if (isset($Element['elements'])) |
1646 | 1635 | { |
1647 | 1636 | $Element['elements'] = $this->elementsApplyRecursive($closure, $Element['elements']); |
1648 | - } |
|
1649 | - elseif (isset($Element['element'])) |
|
1637 | + } elseif (isset($Element['element'])) |
|
1650 | 1638 | { |
1651 | 1639 | $Element['element'] = $this->elementApplyRecursive($closure, $Element['element']); |
1652 | 1640 | } |
@@ -1659,8 +1647,7 @@ discard block |
||
1659 | 1647 | if (isset($Element['elements'])) |
1660 | 1648 | { |
1661 | 1649 | $Element['elements'] = $this->elementsApplyRecursiveDepthFirst($closure, $Element['elements']); |
1662 | - } |
|
1663 | - elseif (isset($Element['element'])) |
|
1650 | + } elseif (isset($Element['element'])) |
|
1664 | 1651 | { |
1665 | 1652 | $Element['element'] = $this->elementsApplyRecursiveDepthFirst($closure, $Element['element']); |
1666 | 1653 | } |
@@ -1747,26 +1734,22 @@ discard block |
||
1747 | 1734 | if (isset($Element['elements'])) |
1748 | 1735 | { |
1749 | 1736 | $markup .= $this->elements($Element['elements']); |
1750 | - } |
|
1751 | - elseif (isset($Element['element'])) |
|
1737 | + } elseif (isset($Element['element'])) |
|
1752 | 1738 | { |
1753 | 1739 | $markup .= $this->element($Element['element']); |
1754 | - } |
|
1755 | - else |
|
1740 | + } else |
|
1756 | 1741 | { |
1757 | 1742 | if (!$permitRawHtml) |
1758 | 1743 | { |
1759 | 1744 | $markup .= self::escape($text, true); |
1760 | - } |
|
1761 | - else |
|
1745 | + } else |
|
1762 | 1746 | { |
1763 | 1747 | $markup .= $text; |
1764 | 1748 | } |
1765 | 1749 | } |
1766 | 1750 | |
1767 | 1751 | $markup .= $hasName ? '</' . $Element['name'] . '>' : ''; |
1768 | - } |
|
1769 | - elseif ($hasName) |
|
1752 | + } elseif ($hasName) |
|
1770 | 1753 | { |
1771 | 1754 | $markup .= ' />'; |
1772 | 1755 | } |
@@ -1932,8 +1915,7 @@ discard block |
||
1932 | 1915 | if ($len > strlen($string)) |
1933 | 1916 | { |
1934 | 1917 | return false; |
1935 | - } |
|
1936 | - else |
|
1918 | + } else |
|
1937 | 1919 | { |
1938 | 1920 | return strtolower(substr($string, 0, $len)) === strtolower($needle); |
1939 | 1921 | } |
@@ -32,114 +32,114 @@ |
||
32 | 32 | */ |
33 | 33 | class PermissionsHandler extends \XoopsPersistableObjectHandler |
34 | 34 | { |
35 | - /** |
|
36 | - * Constructor |
|
37 | - * |
|
38 | - * @param null |
|
39 | - */ |
|
40 | - public function __construct() |
|
41 | - { |
|
42 | - } |
|
35 | + /** |
|
36 | + * Constructor |
|
37 | + * |
|
38 | + * @param null |
|
39 | + */ |
|
40 | + public function __construct() |
|
41 | + { |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @public function permGlobalApprove |
|
46 | - * returns right for global approve |
|
47 | - * |
|
48 | - * @param null |
|
49 | - * @return bool |
|
50 | - */ |
|
51 | - public function getPermGlobalApprove() |
|
52 | - { |
|
53 | - global $xoopsUser, $xoopsModule; |
|
54 | - $currentuid = 0; |
|
55 | - if (isset($xoopsUser) && \is_object($xoopsUser)) { |
|
56 | - if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
57 | - return true; |
|
58 | - } |
|
59 | - $currentuid = $xoopsUser->uid(); |
|
60 | - } |
|
61 | - $grouppermHandler = \xoops_getHandler('groupperm'); |
|
62 | - $mid = $xoopsModule->mid(); |
|
63 | - $memberHandler = \xoops_getHandler('member'); |
|
64 | - if (0 == $currentuid) { |
|
65 | - $my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
66 | - } else { |
|
67 | - $my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
|
68 | - } |
|
69 | - if ($grouppermHandler->checkRight('wggithub_ac', 4, $my_group_ids, $mid)) { |
|
70 | - return true; |
|
71 | - } |
|
72 | - return false; |
|
73 | - } |
|
44 | + /** |
|
45 | + * @public function permGlobalApprove |
|
46 | + * returns right for global approve |
|
47 | + * |
|
48 | + * @param null |
|
49 | + * @return bool |
|
50 | + */ |
|
51 | + public function getPermGlobalApprove() |
|
52 | + { |
|
53 | + global $xoopsUser, $xoopsModule; |
|
54 | + $currentuid = 0; |
|
55 | + if (isset($xoopsUser) && \is_object($xoopsUser)) { |
|
56 | + if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
57 | + return true; |
|
58 | + } |
|
59 | + $currentuid = $xoopsUser->uid(); |
|
60 | + } |
|
61 | + $grouppermHandler = \xoops_getHandler('groupperm'); |
|
62 | + $mid = $xoopsModule->mid(); |
|
63 | + $memberHandler = \xoops_getHandler('member'); |
|
64 | + if (0 == $currentuid) { |
|
65 | + $my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
66 | + } else { |
|
67 | + $my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
|
68 | + } |
|
69 | + if ($grouppermHandler->checkRight('wggithub_ac', 4, $my_group_ids, $mid)) { |
|
70 | + return true; |
|
71 | + } |
|
72 | + return false; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @public function permGlobalSubmit |
|
77 | - * returns right for global submit |
|
78 | - * |
|
79 | - * @param null |
|
80 | - * @return bool |
|
81 | - */ |
|
82 | - public function getPermGlobalSubmit() |
|
83 | - { |
|
84 | - global $xoopsUser, $xoopsModule; |
|
85 | - $currentuid = 0; |
|
86 | - if (isset($xoopsUser) && \is_object($xoopsUser)) { |
|
87 | - if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
88 | - return true; |
|
89 | - } |
|
90 | - $currentuid = $xoopsUser->uid(); |
|
91 | - } |
|
92 | - $grouppermHandler = \xoops_getHandler('groupperm'); |
|
93 | - $mid = $xoopsModule->mid(); |
|
94 | - $memberHandler = \xoops_getHandler('member'); |
|
95 | - if (0 == $currentuid) { |
|
96 | - $my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
97 | - } else { |
|
98 | - $my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
|
99 | - } |
|
100 | - if ($this->getGlobalApprove()) { |
|
101 | - return true; |
|
102 | - } |
|
103 | - if ($grouppermHandler->checkRight('wggithub_ac', 8, $my_group_ids, $mid)) { |
|
104 | - return true; |
|
105 | - } |
|
106 | - return false; |
|
107 | - } |
|
75 | + /** |
|
76 | + * @public function permGlobalSubmit |
|
77 | + * returns right for global submit |
|
78 | + * |
|
79 | + * @param null |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | + public function getPermGlobalSubmit() |
|
83 | + { |
|
84 | + global $xoopsUser, $xoopsModule; |
|
85 | + $currentuid = 0; |
|
86 | + if (isset($xoopsUser) && \is_object($xoopsUser)) { |
|
87 | + if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
88 | + return true; |
|
89 | + } |
|
90 | + $currentuid = $xoopsUser->uid(); |
|
91 | + } |
|
92 | + $grouppermHandler = \xoops_getHandler('groupperm'); |
|
93 | + $mid = $xoopsModule->mid(); |
|
94 | + $memberHandler = \xoops_getHandler('member'); |
|
95 | + if (0 == $currentuid) { |
|
96 | + $my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
97 | + } else { |
|
98 | + $my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
|
99 | + } |
|
100 | + if ($this->getGlobalApprove()) { |
|
101 | + return true; |
|
102 | + } |
|
103 | + if ($grouppermHandler->checkRight('wggithub_ac', 8, $my_group_ids, $mid)) { |
|
104 | + return true; |
|
105 | + } |
|
106 | + return false; |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @public function permGlobalView |
|
111 | - * returns right for global view |
|
112 | - * |
|
113 | - * @param null |
|
114 | - * @return bool |
|
115 | - */ |
|
116 | - public function getPermGlobalView() |
|
117 | - { |
|
118 | - global $xoopsUser, $xoopsModule; |
|
119 | - $currentuid = 0; |
|
120 | - if (isset($xoopsUser) && \is_object($xoopsUser)) { |
|
121 | - if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
122 | - return true; |
|
123 | - } |
|
124 | - $currentuid = $xoopsUser->uid(); |
|
125 | - } |
|
126 | - $grouppermHandler = \xoops_getHandler('groupperm'); |
|
127 | - $mid = $xoopsModule->mid(); |
|
128 | - $memberHandler = \xoops_getHandler('member'); |
|
129 | - if (0 == $currentuid) { |
|
130 | - $my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
131 | - } else { |
|
132 | - $my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
|
133 | - } |
|
134 | - if ($this->getGlobalApprove()) { |
|
135 | - return true; |
|
136 | - } |
|
137 | - if ($this->getGlobalSubmit()) { |
|
138 | - return true; |
|
139 | - } |
|
140 | - if ($grouppermHandler->checkRight('wggithub_ac', 16, $my_group_ids, $mid)) { |
|
141 | - return true; |
|
142 | - } |
|
143 | - return false; |
|
144 | - } |
|
109 | + /** |
|
110 | + * @public function permGlobalView |
|
111 | + * returns right for global view |
|
112 | + * |
|
113 | + * @param null |
|
114 | + * @return bool |
|
115 | + */ |
|
116 | + public function getPermGlobalView() |
|
117 | + { |
|
118 | + global $xoopsUser, $xoopsModule; |
|
119 | + $currentuid = 0; |
|
120 | + if (isset($xoopsUser) && \is_object($xoopsUser)) { |
|
121 | + if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
122 | + return true; |
|
123 | + } |
|
124 | + $currentuid = $xoopsUser->uid(); |
|
125 | + } |
|
126 | + $grouppermHandler = \xoops_getHandler('groupperm'); |
|
127 | + $mid = $xoopsModule->mid(); |
|
128 | + $memberHandler = \xoops_getHandler('member'); |
|
129 | + if (0 == $currentuid) { |
|
130 | + $my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
131 | + } else { |
|
132 | + $my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
|
133 | + } |
|
134 | + if ($this->getGlobalApprove()) { |
|
135 | + return true; |
|
136 | + } |
|
137 | + if ($this->getGlobalSubmit()) { |
|
138 | + return true; |
|
139 | + } |
|
140 | + if ($grouppermHandler->checkRight('wggithub_ac', 16, $my_group_ids, $mid)) { |
|
141 | + return true; |
|
142 | + } |
|
143 | + return false; |
|
144 | + } |
|
145 | 145 | } |