@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | |
79 | 79 | //if the language exists in cookie use it |
80 | 80 | $cfgKey = get_config('language_cookie_name'); |
81 | - $this->logger->debug('Getting current language from cookie [' .$cfgKey. ']'); |
|
81 | + $this->logger->debug('Getting current language from cookie [' . $cfgKey . ']'); |
|
82 | 82 | $objCookie = & class_loader('Cookie'); |
83 | 83 | $cookieLang = $objCookie->get($cfgKey); |
84 | - if($cookieLang && $this->isValid($cookieLang)){ |
|
84 | + if ($cookieLang && $this->isValid($cookieLang)) { |
|
85 | 85 | $this->current = $cookieLang; |
86 | - $this->logger->info('Language from cookie [' .$cfgKey. '] is valid so we will set the language using the cookie value [' .$cookieLang. ']'); |
|
87 | - } else{ |
|
88 | - $this->logger->info('Language from cookie [' .$cfgKey. '] is not set, use the default value [' .$this->getDefault(). ']'); |
|
86 | + $this->logger->info('Language from cookie [' . $cfgKey . '] is valid so we will set the language using the cookie value [' . $cookieLang . ']'); |
|
87 | + } else { |
|
88 | + $this->logger->info('Language from cookie [' . $cfgKey . '] is not set, use the default value [' . $this->getDefault() . ']'); |
|
89 | 89 | $this->current = $this->getDefault(); |
90 | 90 | } |
91 | 91 | } |
@@ -166,13 +166,13 @@ discard block |
||
166 | 166 | * @param string $name the short language name like "en", "fr". |
167 | 167 | * @param string $description the human readable description of this language |
168 | 168 | */ |
169 | - public function addLang($name, $description){ |
|
170 | - if(isset($this->availables[$name])){ |
|
169 | + public function addLang($name, $description) { |
|
170 | + if (isset($this->availables[$name])) { |
|
171 | 171 | return; //already added cost in performance |
172 | 172 | } |
173 | - if($this->isValid($name)){ |
|
173 | + if ($this->isValid($name)) { |
|
174 | 174 | $this->availables[$name] = $description; |
175 | - } else{ |
|
175 | + } else { |
|
176 | 176 | show_error('The language [' . $name . '] is not valid or does not exists.'); |
177 | 177 | } |
178 | 178 | } |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | * @param string $item the config item name to be deleted |
93 | 93 | * @return boolean true if the item exists and is deleted successfully otherwise will return false. |
94 | 94 | */ |
95 | - public static function delete($item){ |
|
95 | + public static function delete($item) { |
|
96 | 96 | $logger = self::getLogger(); |
97 | - if(array_key_exists($item, self::$config)){ |
|
98 | - $logger->info('Delete config item ['.$item.']'); |
|
97 | + if (array_key_exists($item, self::$config)) { |
|
98 | + $logger->info('Delete config item [' . $item . ']'); |
|
99 | 99 | unset(self::$config[$item]); |
100 | 100 | return true; |
101 | - } else{ |
|
102 | - $logger->warning('Config item ['.$item.'] to be deleted does not exists'); |
|
101 | + } else { |
|
102 | + $logger->warning('Config item [' . $item . '] to be deleted does not exists'); |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | } |
@@ -147,12 +147,12 @@ discard block |
||
147 | 147 | 0, |
148 | 148 | strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])) |
149 | 149 | ); |
150 | - } else{ |
|
150 | + } else { |
|
151 | 151 | $logger->warning('Can not determine the application base URL automatically, use http://localhost as default'); |
152 | 152 | $baseUrl = 'http://localhost/'; |
153 | 153 | } |
154 | 154 | self::set('base_url', $baseUrl); |
155 | 155 | } |
156 | - self::$config['base_url'] = rtrim(self::$config['base_url'], '/') .'/'; |
|
156 | + self::$config['base_url'] = rtrim(self::$config['base_url'], '/') . '/'; |
|
157 | 157 | } |
158 | 158 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | 25 | */ |
26 | 26 | |
27 | - class BaseStaticClass{ |
|
27 | + class BaseStaticClass { |
|
28 | 28 | /** |
29 | 29 | * The logger instance |
30 | 30 | * @var object |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | * The signleton of the logger |
36 | 36 | * @return Object the Log instance |
37 | 37 | */ |
38 | - public static function getLogger(){ |
|
39 | - if(self::$logger == null){ |
|
38 | + public static function getLogger() { |
|
39 | + if (self::$logger == null) { |
|
40 | 40 | $logger = array(); |
41 | - $logger[0] =& class_loader('Log', 'classes'); |
|
41 | + $logger[0] = & class_loader('Log', 'classes'); |
|
42 | 42 | $logger[0]->setLogger('Class::' . get_called_class()); |
43 | 43 | self::$logger = $logger[0]; |
44 | 44 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param object $logger the log object |
51 | 51 | * @return object the log instance |
52 | 52 | */ |
53 | - public static function setLogger($logger){ |
|
53 | + public static function setLogger($logger) { |
|
54 | 54 | self::$logger = $logger; |
55 | 55 | return self::$logger; |
56 | 56 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | |
43 | 43 | |
44 | - if(! function_exists('get_ip')){ |
|
44 | + if (!function_exists('get_ip')) { |
|
45 | 45 | /** |
46 | 46 | * Retrieves the user's IP address |
47 | 47 | * |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return string the IP address. |
52 | 52 | */ |
53 | - function get_ip(){ |
|
53 | + function get_ip() { |
|
54 | 54 | $ip = '127.0.0.1'; |
55 | 55 | $ipServerVars = array( |
56 | 56 | 'REMOTE_ADDR', |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | 'HTTP_FORWARDED' |
62 | 62 | ); |
63 | 63 | foreach ($ipServerVars as $var) { |
64 | - if(isset($_SERVER[$var])){ |
|
64 | + if (isset($_SERVER[$var])) { |
|
65 | 65 | $ip = $_SERVER[$var]; |
66 | 66 | break; |
67 | 67 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @filesource |
40 | 40 | */ |
41 | 41 | |
42 | - if(! function_exists('get_random_string')){ |
|
42 | + if (!function_exists('get_random_string')) { |
|
43 | 43 | /** |
44 | 44 | * Generate a random string |
45 | 45 | * @param string $type the type of generation. It can take the values: "alpha" for alphabetic characters, |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | * @param boolean $lower if we return the generated string in lowercase (true). By default it's false. |
50 | 50 | * @return string the generated string. |
51 | 51 | */ |
52 | - function get_random_string($type = 'alnum', $length = 10, $lower = false){ |
|
52 | + function get_random_string($type = 'alnum', $length = 10, $lower = false) { |
|
53 | 53 | $chars = array( |
54 | 54 | 'alpha' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', |
55 | 55 | 'alnum' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', |
56 | 56 | 'num' => '1234567890' |
57 | 57 | ); |
58 | 58 | $str = null; |
59 | - if(isset($chars[$type])){ |
|
59 | + if (isset($chars[$type])) { |
|
60 | 60 | $str = $chars[$type]; |
61 | 61 | } |
62 | 62 | $random = null; |
63 | - for($i = 0; $i < $length; $i++){ |
|
63 | + for ($i = 0; $i < $length; $i++) { |
|
64 | 64 | $random .= $str[mt_rand() % strlen($str)]; |
65 | 65 | } |
66 | - if($lower){ |
|
66 | + if ($lower) { |
|
67 | 67 | $random = strtolower($random); |
68 | 68 | } |
69 | 69 | return $random; |
@@ -142,9 +142,9 @@ |
||
142 | 142 | public function setTos(array $emails) |
143 | 143 | { |
144 | 144 | foreach ($emails as $name => $email) { |
145 | - if(is_numeric($name)){ |
|
145 | + if (is_numeric($name)) { |
|
146 | 146 | $this->setTo($email); |
147 | - } else{ |
|
147 | + } else { |
|
148 | 148 | $this->setTo($email, $name); |
149 | 149 | } |
150 | 150 | } |
@@ -69,14 +69,14 @@ |
||
69 | 69 | * @param string $item the cookie item name to be cleared |
70 | 70 | * @return boolean true if the item exists and is deleted successfully otherwise will return false. |
71 | 71 | */ |
72 | - public static function delete($item){ |
|
72 | + public static function delete($item) { |
|
73 | 73 | $logger = self::getLogger(); |
74 | - if(array_key_exists($item, $_COOKIE)){ |
|
75 | - $logger->info('Delete cookie item ['.$item.']'); |
|
74 | + if (array_key_exists($item, $_COOKIE)) { |
|
75 | + $logger->info('Delete cookie item [' . $item . ']'); |
|
76 | 76 | unset($_COOKIE[$item]); |
77 | 77 | return true; |
78 | - } else{ |
|
79 | - $logger->warning('Cookie item ['.$item.'] to be deleted does not exists'); |
|
78 | + } else { |
|
79 | + $logger->warning('Cookie item [' . $item . '] to be deleted does not exists'); |
|
80 | 80 | return false; |
81 | 81 | } |
82 | 82 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @since 1.0.0 |
39 | 39 | * @filesource |
40 | 40 | */ |
41 | - class Assets extends BaseStaticClass{ |
|
41 | + class Assets extends BaseStaticClass { |
|
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | * @param string $asset the name of the assets file path with the extension. |
54 | 54 | * @return string|null the absolute path of the assets file, if it exists otherwise returns null if the file does not exist. |
55 | 55 | */ |
56 | - public static function path($asset){ |
|
56 | + public static function path($asset) { |
|
57 | 57 | $logger = self::getLogger(); |
58 | 58 | $path = ASSETS_PATH . $asset; |
59 | 59 | |
60 | 60 | $logger->debug('Including the Assets file [' . $path . ']'); |
61 | 61 | //Check if the file exists |
62 | - if(file_exists($path)){ |
|
62 | + if (file_exists($path)) { |
|
63 | 63 | $logger->info('Assets file [' . $path . '] included successfully'); |
64 | 64 | return Url::base_url($path); |
65 | 65 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param string $path the name of the css file without the extension. |
80 | 80 | * @return string|null the absolute path of the css file, if it exists otherwise returns null if the file does not exist. |
81 | 81 | */ |
82 | - public static function css($path){ |
|
82 | + public static function css($path) { |
|
83 | 83 | $logger = self::getLogger(); |
84 | 84 | /* |
85 | 85 | * if the file name contains the ".css" extension, replace it with |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | $logger->debug('Including the Assets file [' . $path . '] for CSS'); |
92 | 92 | //Check if the file exists |
93 | - if(file_exists($path)){ |
|
93 | + if (file_exists($path)) { |
|
94 | 94 | $logger->info('Assets file [' . $path . '] for CSS included successfully'); |
95 | 95 | return Url::base_url($path); |
96 | 96 | } |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | * @param string $path the name of the javascript file without the extension. |
111 | 111 | * @return string|null the absolute path of the javascript file, if it exists otherwise returns null if the file does not exist. |
112 | 112 | */ |
113 | - public static function js($path){ |
|
113 | + public static function js($path) { |
|
114 | 114 | $logger = self::getLogger(); |
115 | 115 | $path = str_ireplace('.js', '', $path); |
116 | 116 | $path = ASSETS_PATH . 'js/' . $path . '.js'; |
117 | 117 | $logger->debug('Including the Assets file [' . $path . '] for javascript'); |
118 | - if(file_exists($path)){ |
|
118 | + if (file_exists($path)) { |
|
119 | 119 | $logger->info('Assets file [' . $path . '] for Javascript included successfully'); |
120 | 120 | return Url::base_url($path); |
121 | 121 | } |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | * @param string $path the name of the image file with the extension. |
136 | 136 | * @return string|null the absolute path of the image file, if it exists otherwise returns null if the file does not exist. |
137 | 137 | */ |
138 | - public static function img($path){ |
|
138 | + public static function img($path) { |
|
139 | 139 | $logger = self::getLogger(); |
140 | 140 | $path = ASSETS_PATH . 'images/' . $path; |
141 | 141 | $logger->debug('Including the Assets file [' . $path . '] for image'); |
142 | - if(file_exists($path)){ |
|
142 | + if (file_exists($path)) { |
|
143 | 143 | $logger->info('Assets file [' . $path . '] for image included successfully'); |
144 | 144 | return Url::base_url($path); |
145 | 145 | } |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | * Create an instance of pagination |
43 | 43 | * @param array $overwriteConfig the list of configuration to overwrite the defined configuration in config_pagination.php |
44 | 44 | */ |
45 | - public function __construct(array $overwriteConfig = array()){ |
|
46 | - if (file_exists(CONFIG_PATH . 'config_pagination.php')){ |
|
45 | + public function __construct(array $overwriteConfig = array()) { |
|
46 | + if (file_exists(CONFIG_PATH . 'config_pagination.php')) { |
|
47 | 47 | $config = array(); |
48 | 48 | require_once CONFIG_PATH . 'config_pagination.php'; |
49 | - if (empty($config) || ! is_array($config)){ |
|
49 | + if (empty($config) || !is_array($config)) { |
|
50 | 50 | show_error('No configuration found in ' . CONFIG_PATH . 'config_pagination.php'); |
51 | 51 | } |
52 | - else{ |
|
52 | + else { |
|
53 | 53 | $config = array_merge($config, $overwriteConfig); |
54 | 54 | $this->config = $config; |
55 | 55 | //put it gobally |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param string $paginationQueryString the new value |
98 | 98 | * @return object |
99 | 99 | */ |
100 | - public function setPaginationQueryString($paginationQueryString){ |
|
100 | + public function setPaginationQueryString($paginationQueryString) { |
|
101 | 101 | $this->paginationQueryString = $paginationQueryString; |
102 | 102 | return $this; |
103 | 103 | } |
@@ -108,22 +108,22 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return object |
110 | 110 | */ |
111 | - public function determinePaginationQueryStringValue(){ |
|
111 | + public function determinePaginationQueryStringValue() { |
|
112 | 112 | $pageQueryName = $this->config['page_query_string_name']; |
113 | 113 | $queryString = Url::queryString(); |
114 | 114 | $currentUrl = Url::current(); |
115 | 115 | $query = ''; |
116 | - if ($queryString == ''){ |
|
116 | + if ($queryString == '') { |
|
117 | 117 | $query = '?' . $pageQueryName . '='; |
118 | - } else{ |
|
118 | + } else { |
|
119 | 119 | $tab = explode($pageQueryName . '=', $queryString); |
120 | 120 | $nb = count($tab); |
121 | - if ($nb == 1){ |
|
121 | + if ($nb == 1) { |
|
122 | 122 | $query = '?' . $queryString . '&' . $pageQueryName . '='; |
123 | - } else{ |
|
124 | - if ($tab[0] == ''){ |
|
123 | + } else { |
|
124 | + if ($tab[0] == '') { |
|
125 | 125 | $query = '?' . $pageQueryName . '='; |
126 | - } else{ |
|
126 | + } else { |
|
127 | 127 | $query = '?' . $tab[0] . '' . $pageQueryName . '='; |
128 | 128 | } |
129 | 129 | } |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return string the pagination link |
143 | 143 | */ |
144 | - public function getLink($totalRows, $currentPageNumber){ |
|
144 | + public function getLink($totalRows, $currentPageNumber) { |
|
145 | 145 | $numberOfLink = $this->config['nb_link']; |
146 | 146 | $numberOfRowPerPage = $this->config['pagination_per_page']; |
147 | - if (empty($this->paginationQueryString)){ |
|
147 | + if (empty($this->paginationQueryString)) { |
|
148 | 148 | //determine the pagination query string value |
149 | 149 | $this->determinePaginationQueryStringValue(); |
150 | 150 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $numberOfLink = (int) $numberOfLink; |
156 | 156 | $numberOfRowPerPage = (int) $numberOfRowPerPage; |
157 | 157 | |
158 | - if ($currentPageNumber <= 0){ |
|
158 | + if ($currentPageNumber <= 0) { |
|
159 | 159 | $currentPageNumber = 1; |
160 | 160 | } |
161 | 161 | if ($numberOfPage <= 1 || $numberOfLink <= 0 || $numberOfRowPerPage <= 0) { |
@@ -170,18 +170,18 @@ discard block |
||
170 | 170 | * @param int $numberOfPage the total number of page |
171 | 171 | * @return string |
172 | 172 | */ |
173 | - protected function buildPaginationNavbar($currentPageNumber, $numberOfPage){ |
|
173 | + protected function buildPaginationNavbar($currentPageNumber, $numberOfPage) { |
|
174 | 174 | $values = $this->getPaginationBeginAndEndNumber($currentPageNumber, $numberOfPage); |
175 | 175 | $begin = $values['begin']; |
176 | 176 | $end = $values['end']; |
177 | 177 | $navbar = null; |
178 | - if ($currentPageNumber == 1){ |
|
178 | + if ($currentPageNumber == 1) { |
|
179 | 179 | $navbar .= $this->buildPaginationLinkForFirstPage($begin, $end, $currentPageNumber); |
180 | 180 | } |
181 | - else if ($currentPageNumber > 1 && $currentPageNumber < $numberOfPage){ |
|
181 | + else if ($currentPageNumber > 1 && $currentPageNumber < $numberOfPage) { |
|
182 | 182 | $navbar .= $this->buildPaginationLinkForMiddlePage($begin, $end, $currentPageNumber); |
183 | 183 | } |
184 | - else if ($currentPageNumber == $numberOfPage){ |
|
184 | + else if ($currentPageNumber == $numberOfPage) { |
|
185 | 185 | $navbar .= $this->buildPaginationLinkForLastPage($begin, $end, $currentPageNumber); |
186 | 186 | } |
187 | 187 | $navbar = $this->config['pagination_open'] . $navbar . $this->config['pagination_close']; |