@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | // Generate the function for the template |
| 33 | 33 | $template = new doT (); |
| 34 | 34 | $dot = $template->template ($page, array ('bookdetail' => $bookdetail, |
| 35 | - 'header' => $header, |
|
| 36 | - 'footer' => $footer, |
|
| 37 | - 'main' => $main)); |
|
| 35 | + 'header' => $header, |
|
| 36 | + 'footer' => $footer, |
|
| 37 | + 'main' => $main)); |
|
| 38 | 38 | // If there is a syntax error in the function created |
| 39 | 39 | // $dot will be equal to FALSE |
| 40 | 40 | if (!$dot) { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | case LIBXML_ERR_WARNING: |
| 126 | 126 | $return .= 'Warning ' . $error->code . ': '; |
| 127 | 127 | break; |
| 128 | - case LIBXML_ERR_ERROR: |
|
| 128 | + case LIBXML_ERR_ERROR: |
|
| 129 | 129 | $return .= 'Error ' . $error->code . ': '; |
| 130 | 130 | break; |
| 131 | 131 | case LIBXML_ERR_FATAL: |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | $return .= trim($error->message) . |
| 137 | - "\n Line: " . $error->line . |
|
| 138 | - "\n Column: " . $error->column; |
|
| 137 | + "\n Line: " . $error->line . |
|
| 138 | + "\n Column: " . $error->column; |
|
| 139 | 139 | |
| 140 | 140 | if ($error->file) { |
| 141 | 141 | $return .= "\n File: " . $error->file; |
@@ -8,8 +8,8 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | require_once 'config.php'; |
| 10 | 10 | |
| 11 | -define ('VERSION', '1.0.0RC4'); |
|
| 12 | -define ('DB', 'db'); |
|
| 11 | +define('VERSION', '1.0.0RC4'); |
|
| 12 | +define('DB', 'db'); |
|
| 13 | 13 | date_default_timezone_set($config['default_timezone']); |
| 14 | 14 | |
| 15 | 15 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | function serverSideRender($data) |
| 23 | 23 | { |
| 24 | 24 | // Get the templates |
| 25 | - $theme = getCurrentTemplate (); |
|
| 25 | + $theme = getCurrentTemplate(); |
|
| 26 | 26 | $header = file_get_contents('templates/' . $theme . '/header.html'); |
| 27 | 27 | $footer = file_get_contents('templates/' . $theme . '/footer.html'); |
| 28 | 28 | $main = file_get_contents('templates/' . $theme . '/main.html'); |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | $page = file_get_contents('templates/' . $theme . '/page.html'); |
| 31 | 31 | |
| 32 | 32 | // Generate the function for the template |
| 33 | - $template = new doT (); |
|
| 34 | - $dot = $template->template ($page, array ('bookdetail' => $bookdetail, |
|
| 33 | + $template = new doT(); |
|
| 34 | + $dot = $template->template($page, array('bookdetail' => $bookdetail, |
|
| 35 | 35 | 'header' => $header, |
| 36 | 36 | 'footer' => $footer, |
| 37 | 37 | 'main' => $main)); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | // Execute the template |
| 44 | 44 | if (!empty ($data)) { |
| 45 | - return $dot ($data); |
|
| 45 | + return $dot($data); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | return NULL; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | function notFound() |
| 60 | 60 | { |
| 61 | - header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); |
|
| 61 | + header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); |
|
| 62 | 62 | header('Status: 404 Not Found'); |
| 63 | 63 | |
| 64 | 64 | $_SERVER['REDIRECT_STATUS'] = 404; |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | global $config; |
| 78 | 78 | if (isset($_COOKIE[$option])) { |
| 79 | - if (isset($config ['cops_' . $option]) && is_array ($config ['cops_' . $option])) { |
|
| 80 | - return explode (',', $_COOKIE[$option]); |
|
| 79 | + if (isset($config ['cops_' . $option]) && is_array($config ['cops_' . $option])) { |
|
| 80 | + return explode(',', $_COOKIE[$option]); |
|
| 81 | 81 | } else { |
| 82 | 82 | return $_COOKIE[$option]; |
| 83 | 83 | } |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | function getCurrentCss() |
| 93 | 93 | { |
| 94 | - return 'templates/' . getCurrentTemplate () . '/styles/style-' . getCurrentOption('style') . '.css'; |
|
| 94 | + return 'templates/' . getCurrentTemplate() . '/styles/style-' . getCurrentOption('style') . '.css'; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | function getCurrentTemplate() |
| 98 | 98 | { |
| 99 | - return getCurrentOption ('template'); |
|
| 99 | + return getCurrentOption('template'); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | function getUrlWithVersion($url) |
@@ -160,10 +160,10 @@ discard block |
||
| 160 | 160 | libxml_use_internal_errors(true); |
| 161 | 161 | |
| 162 | 162 | $doc->loadHTML('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>' . |
| 163 | - $html . '</body></html>'); // Load the HTML |
|
| 163 | + $html . '</body></html>'); // Load the HTML |
|
| 164 | 164 | $output = $doc->saveXML($doc->documentElement); // Transform to an Ansi xml stream |
| 165 | 165 | $output = xml2xhtml($output); |
| 166 | - if (preg_match ('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) { |
|
| 166 | + if (preg_match('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) { |
|
| 167 | 167 | $output = $matches [1]; // Remove <html><body> |
| 168 | 168 | } |
| 169 | 169 | /* |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | */ |
| 177 | 177 | |
| 178 | - if (!are_libxml_errors_ok ()) $output = 'HTML code not valid.'; |
|
| 178 | + if (!are_libxml_errors_ok()) $output = 'HTML code not valid.'; |
|
| 179 | 179 | |
| 180 | 180 | libxml_use_internal_errors(false); |
| 181 | 181 | return $output; |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | //echo var_dump($langs); |
| 265 | 265 | $lang_file = NULL; |
| 266 | 266 | foreach ($langs as $language => $val) { |
| 267 | - $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json'; |
|
| 267 | + $temp_file = dirname(__FILE__) . '/lang/Localization_' . $language . '.json'; |
|
| 268 | 268 | if (file_exists($temp_file)) { |
| 269 | 269 | $lang = $language; |
| 270 | 270 | $lang_file = $temp_file; |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | if (empty ($lang_file)) { |
| 275 | - $lang_file = dirname(__FILE__). '/lang/Localization_' . $lang . '.json'; |
|
| 275 | + $lang_file = dirname(__FILE__) . '/lang/Localization_' . $lang . '.json'; |
|
| 276 | 276 | } |
| 277 | 277 | return array($lang, $lang_file); |
| 278 | 278 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | * This method is based on this page |
| 282 | 282 | * http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/ |
| 283 | 283 | */ |
| 284 | -function localize($phrase, $count=-1, $reset=false) |
|
| 284 | +function localize($phrase, $count = -1, $reset = false) |
|
| 285 | 285 | { |
| 286 | 286 | global $config; |
| 287 | 287 | if ($count == 0) |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | $lang_file_en = NULL; |
| 302 | 302 | list ($lang, $lang_file) = getLangAndTranslationFile(); |
| 303 | 303 | if ($lang != 'en') { |
| 304 | - $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json'; |
|
| 304 | + $lang_file_en = dirname(__FILE__) . '/lang/' . 'Localization_en.json'; |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | $lang_file_content = file_get_contents($lang_file); |
@@ -309,8 +309,8 @@ discard block |
||
| 309 | 309 | $translations = json_decode($lang_file_content, true); |
| 310 | 310 | |
| 311 | 311 | /* Clean the array of all unfinished translations */ |
| 312 | - foreach (array_keys ($translations) as $key) { |
|
| 313 | - if (preg_match ('/^##TODO##/', $key)) { |
|
| 312 | + foreach (array_keys($translations) as $key) { |
|
| 313 | + if (preg_match('/^##TODO##/', $key)) { |
|
| 314 | 314 | unset ($translations [$key]); |
| 315 | 315 | } |
| 316 | 316 | } |
@@ -318,10 +318,10 @@ discard block |
||
| 318 | 318 | { |
| 319 | 319 | $lang_file_content = file_get_contents($lang_file_en); |
| 320 | 320 | $translations_en = json_decode($lang_file_content, true); |
| 321 | - $translations = array_merge ($translations_en, $translations); |
|
| 321 | + $translations = array_merge($translations_en, $translations); |
|
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | - if (array_key_exists ($phrase, $translations)) { |
|
| 324 | + if (array_key_exists($phrase, $translations)) { |
|
| 325 | 325 | return $translations[$phrase]; |
| 326 | 326 | } |
| 327 | 327 | return $phrase; |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | $urlParams = ''; |
| 334 | 334 | } |
| 335 | 335 | $start = ''; |
| 336 | - if (preg_match ('#^\?(.*)#', $urlParams, $matches)) { |
|
| 336 | + if (preg_match('#^\?(.*)#', $urlParams, $matches)) { |
|
| 337 | 337 | $start = '?'; |
| 338 | 338 | $urlParams = $matches[1]; |
| 339 | 339 | } |
@@ -149,7 +149,9 @@ discard block |
||
| 149 | 149 | $errors = libxml_get_errors(); |
| 150 | 150 | |
| 151 | 151 | foreach ($errors as $error) { |
| 152 | - if ($error->code == 801) return false; |
|
| 152 | + if ($error->code == 801) { |
|
| 153 | + return false; |
|
| 154 | + } |
|
| 153 | 155 | } |
| 154 | 156 | return true; |
| 155 | 157 | } |
@@ -175,7 +177,9 @@ discard block |
||
| 175 | 177 | } |
| 176 | 178 | */ |
| 177 | 179 | |
| 178 | - if (!are_libxml_errors_ok ()) $output = 'HTML code not valid.'; |
|
| 180 | + if (!are_libxml_errors_ok ()) { |
|
| 181 | + $output = 'HTML code not valid.'; |
|
| 182 | + } |
|
| 179 | 183 | |
| 180 | 184 | libxml_use_internal_errors(false); |
| 181 | 185 | return $output; |
@@ -235,7 +239,9 @@ discard block |
||
| 235 | 239 | |
| 236 | 240 | // set default to 1 for any without q factor |
| 237 | 241 | foreach ($langs as $lang => $val) { |
| 238 | - if ($val === '') $langs[$lang] = 1; |
|
| 242 | + if ($val === '') { |
|
| 243 | + $langs[$lang] = 1; |
|
| 244 | + } |
|
| 239 | 245 | } |
| 240 | 246 | |
| 241 | 247 | // sort list based on value |
@@ -257,8 +263,7 @@ discard block |
||
| 257 | 263 | $lang = 'en'; |
| 258 | 264 | if (!empty($config['cops_language'])) { |
| 259 | 265 | $lang = $config['cops_language']; |
| 260 | - } |
|
| 261 | - elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 266 | + } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 262 | 267 | $langs = getAcceptLanguages(); |
| 263 | 268 | } |
| 264 | 269 | //echo var_dump($langs); |
@@ -284,12 +289,15 @@ discard block |
||
| 284 | 289 | function localize($phrase, $count=-1, $reset=false) |
| 285 | 290 | { |
| 286 | 291 | global $config; |
| 287 | - if ($count == 0) |
|
| 288 | - $phrase .= '.none'; |
|
| 289 | - if ($count == 1) |
|
| 290 | - $phrase .= '.one'; |
|
| 291 | - if ($count > 1) |
|
| 292 | - $phrase .= '.many'; |
|
| 292 | + if ($count == 0) { |
|
| 293 | + $phrase .= '.none'; |
|
| 294 | + } |
|
| 295 | + if ($count == 1) { |
|
| 296 | + $phrase .= '.one'; |
|
| 297 | + } |
|
| 298 | + if ($count > 1) { |
|
| 299 | + $phrase .= '.many'; |
|
| 300 | + } |
|
| 293 | 301 | |
| 294 | 302 | /* Static keyword is used to ensure the file is loaded only once */ |
| 295 | 303 | static $translations = NULL; |
@@ -314,8 +322,7 @@ discard block |
||
| 314 | 322 | unset ($translations [$key]); |
| 315 | 323 | } |
| 316 | 324 | } |
| 317 | - if ($lang_file_en) |
|
| 318 | - { |
|
| 325 | + if ($lang_file_en) { |
|
| 319 | 326 | $lang_file_content = file_get_contents($lang_file_en); |
| 320 | 327 | $translations_en = json_decode($lang_file_content, true); |
| 321 | 328 | $translations = array_merge ($translations_en, $translations); |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | // If there is a syntax error in the function created |
| 39 | 39 | // $dot will be equal to FALSE |
| 40 | 40 | if (!$dot) { |
| 41 | - return FALSE; |
|
| 41 | + return false; |
|
| 42 | 42 | } |
| 43 | 43 | // Execute the template |
| 44 | 44 | if (!empty ($data)) { |
| 45 | 45 | return $dot ($data); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - return NULL; |
|
| 48 | + return null; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | function getQueryString() |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $_SERVER['REDIRECT_STATUS'] = 404; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | -function getURLParam($name, $default = NULL) |
|
| 67 | +function getURLParam($name, $default = null) |
|
| 68 | 68 | { |
| 69 | 69 | if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != '') { |
| 70 | 70 | return $_GET[$name]; |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | $langs = getAcceptLanguages(); |
| 263 | 263 | } |
| 264 | 264 | //echo var_dump($langs); |
| 265 | - $lang_file = NULL; |
|
| 265 | + $lang_file = null; |
|
| 266 | 266 | foreach ($langs as $language => $val) { |
| 267 | 267 | $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json'; |
| 268 | 268 | if (file_exists($temp_file)) { |
@@ -292,13 +292,13 @@ discard block |
||
| 292 | 292 | $phrase .= '.many'; |
| 293 | 293 | |
| 294 | 294 | /* Static keyword is used to ensure the file is loaded only once */ |
| 295 | - static $translations = NULL; |
|
| 295 | + static $translations = null; |
|
| 296 | 296 | if ($reset) { |
| 297 | - $translations = NULL; |
|
| 297 | + $translations = null; |
|
| 298 | 298 | } |
| 299 | 299 | /* If no instance of $translations has occured load the language file */ |
| 300 | 300 | if (is_null($translations)) { |
| 301 | - $lang_file_en = NULL; |
|
| 301 | + $lang_file_en = null; |
|
| 302 | 302 | list ($lang, $lang_file) = getLangAndTranslationFile(); |
| 303 | 303 | if ($lang != 'en') { |
| 304 | 304 | $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json'; |