Passed
Push — master ( 0deb8f...f54565 )
by Goffy
04:13
created
class/Github/Storages/ISessionStorage.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -8,25 +8,25 @@
 block discarded – undo
8 8
  */
9 9
 interface ISessionStorage
10 10
 {
11
-	/**
12
-	 * @param  string
13
-	 * @param  mixed
14
-	 * @return self
15
-	 */
16
-	function set($name, $value);
17
-
18
-
19
-	/**
20
-	 * @param  string
21
-	 * @return mixed
22
-	 */
23
-	function get($name);
24
-
25
-
26
-	/**
27
-	 * @param  string
28
-	 * @return self
29
-	 */
30
-	function remove($name);
11
+    /**
12
+     * @param  string
13
+     * @param  mixed
14
+     * @return self
15
+     */
16
+    function set($name, $value);
17
+
18
+
19
+    /**
20
+     * @param  string
21
+     * @return mixed
22
+     */
23
+    function get($name);
24
+
25
+
26
+    /**
27
+     * @param  string
28
+     * @return self
29
+     */
30
+    function remove($name);
31 31
 
32 32
 }
Please login to merge, or discard this patch.
class/Github/Storages/SessionStorage.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -12,75 +12,75 @@
 block discarded – undo
12 12
  */
13 13
 class SessionStorage extends Github\Sanity implements ISessionStorage
14 14
 {
15
-	const SESSION_KEY = 'milo.github-api';
16
-
17
-	/** @var string */
18
-	private $sessionKey;
19
-
20
-
21
-	/**
22
-	 * @param  string
23
-	 */
24
-	public function __construct($sessionKey = self::SESSION_KEY)
25
-	{
26
-		$this->sessionKey = $sessionKey;
27
-	}
28
-
29
-
30
-	/**
31
-	 * @param  string
32
-	 * @param  mixed
33
-	 * @return self
34
-	 */
35
-	public function set($name, $value)
36
-	{
37
-		if ($value === NULL) {
38
-			return $this->remove($name);
39
-		}
40
-
41
-		$this->check(__METHOD__);
42
-		$_SESSION[$this->sessionKey][$name] = $value;
43
-
44
-		return $this;
45
-	}
46
-
47
-
48
-	/**
49
-	 * @param  string
50
-	 * @return mixed
51
-	 */
52
-	public function get($name)
53
-	{
54
-		$this->check(__METHOD__);
55
-
56
-		return isset($_SESSION[$this->sessionKey][$name])
57
-			? $_SESSION[$this->sessionKey][$name]
58
-			: NULL;
59
-	}
60
-
61
-
62
-	/**
63
-	 * @param  string
64
-	 * @return self
65
-	 */
66
-	public function remove($name)
67
-	{
68
-		$this->check(__METHOD__);
69
-
70
-		unset($_SESSION[$this->sessionKey][$name]);
71
-
72
-		return $this;
73
-	}
74
-
75
-
76
-	/**
77
-	 * @param  string
78
-	 */
79
-	private function check($method)
80
-	{
81
-		if (!isset($_SESSION)) {
82
-			trigger_error("Start session before using $method().", E_USER_WARNING);
83
-		}
84
-	}
15
+    const SESSION_KEY = 'milo.github-api';
16
+
17
+    /** @var string */
18
+    private $sessionKey;
19
+
20
+
21
+    /**
22
+     * @param  string
23
+     */
24
+    public function __construct($sessionKey = self::SESSION_KEY)
25
+    {
26
+        $this->sessionKey = $sessionKey;
27
+    }
28
+
29
+
30
+    /**
31
+     * @param  string
32
+     * @param  mixed
33
+     * @return self
34
+     */
35
+    public function set($name, $value)
36
+    {
37
+        if ($value === NULL) {
38
+            return $this->remove($name);
39
+        }
40
+
41
+        $this->check(__METHOD__);
42
+        $_SESSION[$this->sessionKey][$name] = $value;
43
+
44
+        return $this;
45
+    }
46
+
47
+
48
+    /**
49
+     * @param  string
50
+     * @return mixed
51
+     */
52
+    public function get($name)
53
+    {
54
+        $this->check(__METHOD__);
55
+
56
+        return isset($_SESSION[$this->sessionKey][$name])
57
+            ? $_SESSION[$this->sessionKey][$name]
58
+            : NULL;
59
+    }
60
+
61
+
62
+    /**
63
+     * @param  string
64
+     * @return self
65
+     */
66
+    public function remove($name)
67
+    {
68
+        $this->check(__METHOD__);
69
+
70
+        unset($_SESSION[$this->sessionKey][$name]);
71
+
72
+        return $this;
73
+    }
74
+
75
+
76
+    /**
77
+     * @param  string
78
+     */
79
+    private function check($method)
80
+    {
81
+        if (!isset($_SESSION)) {
82
+            trigger_error("Start session before using $method().", E_USER_WARNING);
83
+        }
84
+    }
85 85
 
86 86
 }
Please login to merge, or discard this patch.
class/Github/Helpers.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -13,89 +13,89 @@
 block discarded – undo
13 13
  */
14 14
 class Helpers
15 15
 {
16
-	private static $jsonMessages = [
17
-		JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded',
18
-		JSON_ERROR_STATE_MISMATCH => 'Syntax error, malformed JSON',
19
-		JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
20
-		JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON',
21
-		JSON_ERROR_UTF8 => 'Invalid UTF-8 sequence',
22
-	];
23
-
24
-
25
-	/** @var Http\IClient */
26
-	private static $client;
27
-
28
-
29
-	/**
30
-	 * @param  mixed
31
-	 * @return string
32
-	 *
33
-	 * @throws JsonException
34
-	 */
35
-	public static function jsonEncode($value)
36
-	{
37
-		if (PHP_VERSION_ID < 50500) {
38
-			set_error_handler(function($severity, $message) { // needed to receive 'recursion detected' error
39
-				restore_error_handler();
40
-				throw new JsonException($message);
41
-			});
42
-		}
43
-
44
-		$json = json_encode($value, JSON_UNESCAPED_UNICODE);
45
-
46
-		if (PHP_VERSION_ID < 50500) {
47
-			restore_error_handler();
48
-		}
49
-
50
-		if ($error = json_last_error()) {
51
-			$message = isset(static::$jsonMessages[$error])
52
-				? static::$jsonMessages[$error]
53
-				: (PHP_VERSION_ID >= 50500 ? json_last_error_msg() : 'Unknown error');
54
-
55
-			throw new JsonException($message, $error);
56
-		}
57
-
58
-		$json = str_replace(array("\xe2\x80\xa8", "\xe2\x80\xa9"), array('\u2028', '\u2029'), $json);
59
-		return $json;
60
-	}
61
-
62
-
63
-	/**
64
-	 * @param  mixed
65
-	 * @return string
66
-	 *
67
-	 * @throws JsonException
68
-	 */
69
-	public static function jsonDecode($json, $assoc = false)
70
-	{
71
-		$json = (string) $json;
72
-		if (!preg_match('##u', $json)) {
73
-			throw new JsonException('Invalid UTF-8 sequence', 5); // PECL JSON-C
74
-		}
75
-
76
-		$value = json_decode($json, $assoc, 512, (defined('JSON_C_VERSION') && PHP_INT_SIZE > 4) ? 0 : JSON_BIGINT_AS_STRING);
77
-
78
-		if ($value === NULL && $json !== '' && strcasecmp($json, 'null')) { // '' does not clear json_last_error()
79
-			$error = json_last_error();
80
-			throw new JsonException(isset(static::$jsonMessages[$error]) ? static::$jsonMessages[$error] : 'Unknown error', $error);
81
-		}
82
-		return $value;
83
-	}
84
-
85
-
86
-	/**
87
-	 * @param  bool
88
-	 * @return Http\IClient
89
-	 */
90
-	public static function createDefaultClient($newInstance = FALSE)
91
-	{
92
-		if (self::$client === NULL || $newInstance) {
93
-			self::$client = extension_loaded('curl')
94
-				? new Http\CurlClient
95
-				: new Http\StreamClient;
96
-		}
97
-
98
-		return self::$client;
99
-	}
16
+    private static $jsonMessages = [
17
+        JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded',
18
+        JSON_ERROR_STATE_MISMATCH => 'Syntax error, malformed JSON',
19
+        JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
20
+        JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON',
21
+        JSON_ERROR_UTF8 => 'Invalid UTF-8 sequence',
22
+    ];
23
+
24
+
25
+    /** @var Http\IClient */
26
+    private static $client;
27
+
28
+
29
+    /**
30
+     * @param  mixed
31
+     * @return string
32
+     *
33
+     * @throws JsonException
34
+     */
35
+    public static function jsonEncode($value)
36
+    {
37
+        if (PHP_VERSION_ID < 50500) {
38
+            set_error_handler(function($severity, $message) { // needed to receive 'recursion detected' error
39
+                restore_error_handler();
40
+                throw new JsonException($message);
41
+            });
42
+        }
43
+
44
+        $json = json_encode($value, JSON_UNESCAPED_UNICODE);
45
+
46
+        if (PHP_VERSION_ID < 50500) {
47
+            restore_error_handler();
48
+        }
49
+
50
+        if ($error = json_last_error()) {
51
+            $message = isset(static::$jsonMessages[$error])
52
+                ? static::$jsonMessages[$error]
53
+                : (PHP_VERSION_ID >= 50500 ? json_last_error_msg() : 'Unknown error');
54
+
55
+            throw new JsonException($message, $error);
56
+        }
57
+
58
+        $json = str_replace(array("\xe2\x80\xa8", "\xe2\x80\xa9"), array('\u2028', '\u2029'), $json);
59
+        return $json;
60
+    }
61
+
62
+
63
+    /**
64
+     * @param  mixed
65
+     * @return string
66
+     *
67
+     * @throws JsonException
68
+     */
69
+    public static function jsonDecode($json, $assoc = false)
70
+    {
71
+        $json = (string) $json;
72
+        if (!preg_match('##u', $json)) {
73
+            throw new JsonException('Invalid UTF-8 sequence', 5); // PECL JSON-C
74
+        }
75
+
76
+        $value = json_decode($json, $assoc, 512, (defined('JSON_C_VERSION') && PHP_INT_SIZE > 4) ? 0 : JSON_BIGINT_AS_STRING);
77
+
78
+        if ($value === NULL && $json !== '' && strcasecmp($json, 'null')) { // '' does not clear json_last_error()
79
+            $error = json_last_error();
80
+            throw new JsonException(isset(static::$jsonMessages[$error]) ? static::$jsonMessages[$error] : 'Unknown error', $error);
81
+        }
82
+        return $value;
83
+    }
84
+
85
+
86
+    /**
87
+     * @param  bool
88
+     * @return Http\IClient
89
+     */
90
+    public static function createDefaultClient($newInstance = FALSE)
91
+    {
92
+        if (self::$client === NULL || $newInstance) {
93
+            self::$client = extension_loaded('curl')
94
+                ? new Http\CurlClient
95
+                : new Http\StreamClient;
96
+        }
97
+
98
+        return self::$client;
99
+    }
100 100
 
101 101
 }
Please login to merge, or discard this patch.
class/Github/GithubClient.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public function getUserRepositories($username, $per_page = 100, $page = 1)
112 112
     {
113
-        $url = static::BASE_URL . 'users/' . \rawurlencode($username) . '/repos?per_page=' . $per_page . '&page=' . $page;
113
+        $url = static::BASE_URL.'users/'.\rawurlencode($username).'/repos?per_page='.$per_page.'&page='.$page;
114 114
 
115 115
         return $this->_get($url);
116 116
     }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function getOrgRepositories($org, $per_page = 100, $page = 1)
127 127
     {
128
-        $url = static::BASE_URL . 'orgs/' . \rawurlencode($org) . '/repos?per_page=' . $per_page . '&page=' . $page;
128
+        $url = static::BASE_URL.'orgs/'.\rawurlencode($org).'/repos?per_page='.$per_page.'&page='.$page;
129 129
 
130 130
         return $this->_get($url);
131 131
     }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      */
143 143
     public function getReadme($username, $repository)
144 144
     {
145
-        $url = static::BASE_URL . 'repos/' . \rawurlencode($username) . '/' . \rawurlencode($repository) . '/readme';
145
+        $url = static::BASE_URL.'repos/'.\rawurlencode($username).'/'.\rawurlencode($repository).'/readme';
146 146
 
147 147
         return $this->_get($url, false, false);
148 148
     }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      */
157 157
     public function getReleases($user, $repository)
158 158
     {
159
-        $url = static::BASE_URL . 'repos/' . $user . '/' . $repository . '/releases';
159
+        $url = static::BASE_URL.'repos/'.$user.'/'.$repository.'/releases';
160 160
 
161 161
         return $this->_get($url);
162 162
     }
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
     public function getLatestRelease($user, $repository, $prerelease = false)
173 173
     {
174 174
         if ($prerelease) {
175
-            $url = static::BASE_URL . 'repos/' . $user . '/' . $repository . '/releases';
175
+            $url = static::BASE_URL.'repos/'.$user.'/'.$repository.'/releases';
176 176
         } else {
177
-            $url = static::BASE_URL . 'repos/' . $user . '/' . $repository . '/releases/latest';
177
+            $url = static::BASE_URL.'repos/'.$user.'/'.$repository.'/releases/latest';
178 178
         }
179 179
         $result = $this->_get($url);
180 180
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         $api->setToken($token);
200 200
         $request = $api->createRequest('GET', $url, [], [], '');
201 201
         $response = $api->request($request);
202
-        $data = (array)$api->decode($response);
202
+        $data = (array) $api->decode($response);
203 203
 
204 204
         return $data;
205 205
     }
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         $setting = $settingsHandler->getPrimarySetting();
217 217
 
218 218
         if (0 == \count($setting)) {
219
-            \redirect_header(\XOOPS_URL . '/index.php', 3, \_AM_WGGITHUB_THEREARENT_SETTINGS);
219
+            \redirect_header(\XOOPS_URL.'/index.php', 3, \_AM_WGGITHUB_THEREARENT_SETTINGS);
220 220
         }
221 221
         $this->userAuth = $setting['user'];
222 222
         $this->tokenAuth = $setting['token'];
Please login to merge, or discard this patch.
class/RepositoriesHandler.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -31,96 +31,96 @@
 block discarded – undo
31 31
  */
32 32
 class RepositoriesHandler 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_repositories', Repositories::class, 'repo_id', 'repo_name');
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 Repositories 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 getCountRepositories($start = 0, $limit = 0, $sort = 'repo_id ASC, repo_name', $order = 'ASC')
86
-	{
87
-		$crCountRepositories = new \CriteriaCompo();
88
-		$crCountRepositories = $this->getRepositoriesCriteria($crCountRepositories, $start, $limit, $sort, $order);
89
-		return $this->getCount($crCountRepositories);
90
-	}
91
-
92
-	/**
93
-	 * Get All Repositories 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 getAllRepositories($start = 0, $limit = 0, $sort = 'repo_id ASC, repo_name', $order = 'ASC')
101
-	{
102
-		$crAllRepositories = new \CriteriaCompo();
103
-		$crAllRepositories = $this->getRepositoriesCriteria($crAllRepositories, $start, $limit, $sort, $order);
104
-		return $this->getAll($crAllRepositories);
105
-	}
106
-
107
-	/**
108
-	 * Get Criteria Repositories
109
-	 * @param        $crRepositories
110
-	 * @param int    $start
111
-	 * @param int    $limit
112
-	 * @param string $sort
113
-	 * @param string $order
114
-	 * @return int
115
-	 */
116
-	private function getRepositoriesCriteria($crRepositories, $start, $limit, $sort, $order)
117
-	{
118
-		$crRepositories->setStart($start);
119
-		$crRepositories->setLimit($limit);
120
-		$crRepositories->setSort($sort);
121
-		$crRepositories->setOrder($order);
122
-		return $crRepositories;
123
-	}
34
+    /**
35
+     * Constructor
36
+     *
37
+     * @param \XoopsDatabase $db
38
+     */
39
+    public function __construct(\XoopsDatabase $db)
40
+    {
41
+        parent::__construct($db, 'wggithub_repositories', Repositories::class, 'repo_id', 'repo_name');
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 Repositories 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 getCountRepositories($start = 0, $limit = 0, $sort = 'repo_id ASC, repo_name', $order = 'ASC')
86
+    {
87
+        $crCountRepositories = new \CriteriaCompo();
88
+        $crCountRepositories = $this->getRepositoriesCriteria($crCountRepositories, $start, $limit, $sort, $order);
89
+        return $this->getCount($crCountRepositories);
90
+    }
91
+
92
+    /**
93
+     * Get All Repositories 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 getAllRepositories($start = 0, $limit = 0, $sort = 'repo_id ASC, repo_name', $order = 'ASC')
101
+    {
102
+        $crAllRepositories = new \CriteriaCompo();
103
+        $crAllRepositories = $this->getRepositoriesCriteria($crAllRepositories, $start, $limit, $sort, $order);
104
+        return $this->getAll($crAllRepositories);
105
+    }
106
+
107
+    /**
108
+     * Get Criteria Repositories
109
+     * @param        $crRepositories
110
+     * @param int    $start
111
+     * @param int    $limit
112
+     * @param string $sort
113
+     * @param string $order
114
+     * @return int
115
+     */
116
+    private function getRepositoriesCriteria($crRepositories, $start, $limit, $sort, $order)
117
+    {
118
+        $crRepositories->setStart($start);
119
+        $crRepositories->setLimit($limit);
120
+        $crRepositories->setSort($sort);
121
+        $crRepositories->setOrder($order);
122
+        return $crRepositories;
123
+    }
124 124
 
125 125
     /**
126 126
      * Update table repositories
Please login to merge, or discard this patch.
class/Logs.php 2 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -32,96 +32,96 @@  discard block
 block discarded – undo
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);
93 93
         $logTypeSelect->addOption(Constants::LOG_TYPE_UPDATE_START, _AM_WGGITHUB_LOG_TYPE_UPDATE_START);
94 94
         $logTypeSelect->addOption(Constants::LOG_TYPE_UPDATE_END, _AM_WGGITHUB_LOG_TYPE_UPDATE_END);
95 95
         $form->addElement($logTypeSelect);
96
-		// Form Text logDetails
97
-		$form->addElement(new \XoopsFormText(_AM_WGGITHUB_LOG_DETAILS, 'log_details', 50, 255, $this->getVar('log_details')), true);
98
-		// Form Text logResult
96
+        // Form Text logDetails
97
+        $form->addElement(new \XoopsFormText(_AM_WGGITHUB_LOG_DETAILS, 'log_details', 50, 255, $this->getVar('log_details')), true);
98
+        // Form Text logResult
99 99
         $form->addElement(new \XoopsFormTextArea(_AM_WGGITHUB_LOG_RESULT, 'log_result', $this->getVar('log_result', 'e'), 4, 47));
100
-		// Form Text Date Select logDatecreated
101
-		$logDatecreated = $this->isNew() ?: $this->getVar('log_datecreated');
102
-		$form->addElement(new \XoopsFormTextDateSelect(_AM_WGGITHUB_LOG_DATECREATED, 'log_datecreated', '', $logDatecreated));
103
-		// Form Select User reqSubmitter
104
-		$form->addElement(new \XoopsFormSelectUser(_AM_WGGITHUB_LOG_SUBMITTER, 'log_submitter', false, $this->getVar('log_submitter')));
105
-		// To Save
106
-		$form->addElement(new \XoopsFormHidden('op', 'save'));
107
-		$form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false));
108
-		return $form;
109
-	}
100
+        // Form Text Date Select logDatecreated
101
+        $logDatecreated = $this->isNew() ?: $this->getVar('log_datecreated');
102
+        $form->addElement(new \XoopsFormTextDateSelect(_AM_WGGITHUB_LOG_DATECREATED, 'log_datecreated', '', $logDatecreated));
103
+        // Form Select User reqSubmitter
104
+        $form->addElement(new \XoopsFormSelectUser(_AM_WGGITHUB_LOG_SUBMITTER, 'log_submitter', false, $this->getVar('log_submitter')));
105
+        // To Save
106
+        $form->addElement(new \XoopsFormHidden('op', 'save'));
107
+        $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false));
108
+        return $form;
109
+    }
110 110
 
111
-	/**
112
-	 * Get Values
113
-	 * @param null $keys
114
-	 * @param null $format
115
-	 * @param null $maxDepth
116
-	 * @return array
117
-	 */
118
-	public function getValuesLogs($keys = null, $format = null, $maxDepth = null)
119
-	{
111
+    /**
112
+     * Get Values
113
+     * @param null $keys
114
+     * @param null $format
115
+     * @param null $maxDepth
116
+     * @return array
117
+     */
118
+    public function getValuesLogs($keys = null, $format = null, $maxDepth = null)
119
+    {
120 120
         $helper  = \XoopsModules\Wggithub\Helper::getInstance();
121 121
         $utility = new \XoopsModules\Wggithub\Utility();
122 122
         $editorMaxchar = $helper->getConfig('editor_maxchar');
123
-	    $ret = $this->getValues($keys, $format, $maxDepth);
124
-		$ret['id']           = $this->getVar('log_id');
123
+        $ret = $this->getValues($keys, $format, $maxDepth);
124
+        $ret['id']           = $this->getVar('log_id');
125 125
         $ret['type']         = $this->getVar('log_type');
126 126
         switch ($ret['type']) {
127 127
             case Constants::LOG_TYPE_NONE:
@@ -139,26 +139,26 @@  discard block
 block discarded – undo
139 139
                 break;
140 140
         }
141 141
         $ret['type_text']    = $type_text;
142
-		$ret['details']      = $this->getVar('log_details');
142
+        $ret['details']      = $this->getVar('log_details');
143 143
         $ret['result']       = \strip_tags($this->getVar('log_result', 'e'));
144 144
         $ret['result_short'] = $utility::truncateHtml($ret['result'], $editorMaxchar);
145
-		$ret['datecreated']  = \formatTimestamp($this->getVar('log_datecreated'), 'm');
146
-		$ret['submitter']    = \XoopsUser::getUnameFromId($this->getVar('log_submitter'));
147
-		return $ret;
148
-	}
145
+        $ret['datecreated']  = \formatTimestamp($this->getVar('log_datecreated'), 'm');
146
+        $ret['submitter']    = \XoopsUser::getUnameFromId($this->getVar('log_submitter'));
147
+        return $ret;
148
+    }
149 149
 
150
-	/**
151
-	 * Returns an array representation of the object
152
-	 *
153
-	 * @return array
154
-	 */
155
-	public function toArrayRequests()
156
-	{
157
-		$ret = [];
158
-		$vars = $this->getVars();
159
-		foreach (\array_keys($vars) as $var) {
160
-			$ret[$var] = $this->getVar('"{$var}"');
161
-		}
162
-		return $ret;
163
-	}
150
+    /**
151
+     * Returns an array representation of the object
152
+     *
153
+     * @return array
154
+     */
155
+    public function toArrayRequests()
156
+    {
157
+        $ret = [];
158
+        $vars = $this->getVars();
159
+        foreach (\array_keys($vars) as $var) {
160
+            $ret[$var] = $this->getVar('"{$var}"');
161
+        }
162
+        return $ret;
163
+    }
164 164
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@
 block discarded – undo
122 122
         $editorMaxchar = $helper->getConfig('editor_maxchar');
123 123
 	    $ret = $this->getValues($keys, $format, $maxDepth);
124 124
 		$ret['id']           = $this->getVar('log_id');
125
-        $ret['type']         = $this->getVar('log_type');
125
+        $ret['type'] = $this->getVar('log_type');
126 126
         switch ($ret['type']) {
127 127
             case Constants::LOG_TYPE_NONE:
128 128
             default:
Please login to merge, or discard this patch.
class/Constants.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  */
29 29
 interface Constants
30 30
 {
31
-	// Constants for tables
31
+    // Constants for tables
32 32
     public const TABLE_SETTINGS = 0;
33 33
     public const TABLE_REPOSITORIES = 1;
34 34
     public const TABLE_DIRECTORIES = 2;
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
     public const DIRECTORY_TYPE_USER = 1;
40 40
     public const DIRECTORY_TYPE_ORG  = 2;
41 41
 
42
-	// Constants for status
43
-	public const STATUS_NONE     = 0;
42
+    // Constants for status
43
+    public const STATUS_NONE     = 0;
44 44
     public const STATUS_NEW      = 1;
45 45
     public const STATUS_UPDATED  = 2;
46
-	public const STATUS_UPTODATE = 3;
46
+    public const STATUS_UPTODATE = 3;
47 47
 
48
-	// Constants for permissions
49
-	public const PERM_GLOBAL_NONE   = 0;
50
-	public const PERM_GLOBAL_VIEW   = 1;
51
-	public const PERM_GLOBAL_READ   = 2;
52
-	public const PERM_README_UPDATE = 3;
48
+    // Constants for permissions
49
+    public const PERM_GLOBAL_NONE   = 0;
50
+    public const PERM_GLOBAL_VIEW   = 1;
51
+    public const PERM_GLOBAL_READ   = 2;
52
+    public const PERM_README_UPDATE = 3;
53 53
 
54 54
     // Constants for log type
55 55
     public const LOG_TYPE_NONE  = 0;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
 	public const PERM_README_UPDATE = 3;
53 53
 
54 54
     // Constants for log type
55
-    public const LOG_TYPE_NONE  = 0;
55
+    public const LOG_TYPE_NONE = 0;
56 56
     public const LOG_TYPE_UPDATE_START = 1;
57 57
     public const LOG_TYPE_UPDATE_END   = 2;
58 58
     public const LOG_TYPE_REQUEST      = 3;
Please login to merge, or discard this patch.
class/LogsHandler.php 2 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -31,96 +31,96 @@
 block discarded – undo
31 31
  */
32 32
 class LogsHandler 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_logs', Logs::class, 'log_id', 'log_detail');
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 Logs 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 getCountLogs($start = 0, $limit = 0, $sort = 'log_id', $order = 'ASC')
86
-	{
87
-		$crCountLogs = new \CriteriaCompo();
88
-		$crCountLogs = $this->getLogsCriteria($crCountLogs, $start, $limit, $sort, $order);
89
-		return $this->getCount($crCountLogs);
90
-	}
91
-
92
-	/**
93
-	 * Get All Logs 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 getAllLogs($start = 0, $limit = 0, $sort = 'log_id', $order = 'ASC')
101
-	{
102
-		$crAllLogs = new \CriteriaCompo();
103
-		$crAllLogs = $this->getLogsCriteria($crAllLogs, $start, $limit, $sort, $order);
104
-		return $this->getAll($crAllLogs);
105
-	}
106
-
107
-	/**
108
-	 * Get Criteria Logs
109
-	 * @param        $crLogs
110
-	 * @param int    $start
111
-	 * @param int    $limit
112
-	 * @param string $sort
113
-	 * @param string $order
114
-	 * @return int
115
-	 */
116
-	private function getLogsCriteria($crLogs, $start, $limit, $sort, $order)
117
-	{
118
-		$crLogs->setStart($start);
119
-		$crLogs->setLimit($limit);
120
-		$crLogs->setSort($sort);
121
-		$crLogs->setOrder($order);
122
-		return $crLogs;
123
-	}
34
+    /**
35
+     * Constructor
36
+     *
37
+     * @param \XoopsDatabase $db
38
+     */
39
+    public function __construct(\XoopsDatabase $db)
40
+    {
41
+        parent::__construct($db, 'wggithub_logs', Logs::class, 'log_id', 'log_detail');
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 Logs 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 getCountLogs($start = 0, $limit = 0, $sort = 'log_id', $order = 'ASC')
86
+    {
87
+        $crCountLogs = new \CriteriaCompo();
88
+        $crCountLogs = $this->getLogsCriteria($crCountLogs, $start, $limit, $sort, $order);
89
+        return $this->getCount($crCountLogs);
90
+    }
91
+
92
+    /**
93
+     * Get All Logs 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 getAllLogs($start = 0, $limit = 0, $sort = 'log_id', $order = 'ASC')
101
+    {
102
+        $crAllLogs = new \CriteriaCompo();
103
+        $crAllLogs = $this->getLogsCriteria($crAllLogs, $start, $limit, $sort, $order);
104
+        return $this->getAll($crAllLogs);
105
+    }
106
+
107
+    /**
108
+     * Get Criteria Logs
109
+     * @param        $crLogs
110
+     * @param int    $start
111
+     * @param int    $limit
112
+     * @param string $sort
113
+     * @param string $order
114
+     * @return int
115
+     */
116
+    private function getLogsCriteria($crLogs, $start, $limit, $sort, $order)
117
+    {
118
+        $crLogs->setStart($start);
119
+        $crLogs->setLimit($limit);
120
+        $crLogs->setSort($sort);
121
+        $crLogs->setOrder($order);
122
+        return $crLogs;
123
+    }
124 124
 
125 125
     /**
126 126
      * Update table requests
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@
 block discarded – undo
142 142
         $logsObj->setVar('log_type', $type);
143 143
         $logsObj->setVar('log_details', $detail);
144 144
         $logsObj->setVar('log_result', $result);
145
-        $logsObj->setVar('log_datecreated',time());
145
+        $logsObj->setVar('log_datecreated', time());
146 146
         $logsObj->setVar('log_submitter', $submitter);
147 147
         // Insert Data
148 148
         if ($logsHandler->insert($logsObj)) {
Please login to merge, or discard this patch.