aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/LinkDB.php3
-rw-r--r--application/Utils.php25
2 files changed, 28 insertions, 0 deletions
diff --git a/application/LinkDB.php b/application/LinkDB.php
index 9f4d3e3c..9488ac45 100644
--- a/application/LinkDB.php
+++ b/application/LinkDB.php
@@ -32,6 +32,9 @@ class LinkDB implements Iterator, Countable, ArrayAccess
32 // Links are stored as a PHP serialized string 32 // Links are stored as a PHP serialized string
33 private $_datastore; 33 private $_datastore;
34 34
35 // Link date storage format
36 const LINK_DATE_FORMAT = 'Ymd_His';
37
35 // Datastore PHP prefix 38 // Datastore PHP prefix
36 protected static $phpPrefix = '<?php /* '; 39 protected static $phpPrefix = '<?php /* ';
37 40
diff --git a/application/Utils.php b/application/Utils.php
index 868946df..3d819716 100644
--- a/application/Utils.php
+++ b/application/Utils.php
@@ -229,3 +229,28 @@ function space2nbsp($text)
229function format_description($description, $redirector) { 229function format_description($description, $redirector) {
230 return nl2br(space2nbsp(text2clickable($description, $redirector))); 230 return nl2br(space2nbsp(text2clickable($description, $redirector)));
231} 231}
232
233/**
234 * Sniff browser language to set the locale automatically.
235 * Note that is may not work on your server if the corresponding locale is not installed.
236 *
237 * @param string $headerLocale Locale send in HTTP headers (e.g. "fr,fr-fr;q=0.8,en;q=0.5,en-us;q=0.3").
238 **/
239function autoLocale($headerLocale)
240{
241 // Default if browser does not send HTTP_ACCEPT_LANGUAGE
242 $attempts = array('en_US');
243 if (isset($headerLocale)) {
244 // (It's a bit crude, but it works very well. Preferred language is always presented first.)
245 if (preg_match('/([a-z]{2})-?([a-z]{2})?/i', $headerLocale, $matches)) {
246 $loc = $matches[1] . (!empty($matches[2]) ? '_' . strtoupper($matches[2]) : '');
247 $attempts = array(
248 $loc.'.UTF-8', $loc, str_replace('_', '-', $loc).'.UTF-8', str_replace('_', '-', $loc),
249 $loc . '_' . strtoupper($loc).'.UTF-8', $loc . '_' . strtoupper($loc),
250 $loc . '_' . $loc.'.UTF-8', $loc . '_' . $loc, $loc . '-' . strtoupper($loc).'.UTF-8',
251 $loc . '-' . strtoupper($loc), $loc . '-' . $loc.'.UTF-8', $loc . '-' . $loc
252 );
253 }
254 }
255 setlocale(LC_ALL, $attempts);
256} \ No newline at end of file