diff options
author | Federico Marani <federico.marani@ymail.com> | 2009-03-16 22:43:51 +0000 |
---|---|---|
committer | Federico Marani <federico.marani@ymail.com> | 2009-03-16 22:43:51 +0000 |
commit | 420c3613049bec1360cdeb1f50283b239adf23d3 (patch) | |
tree | 0ab458b3c45c883232b3ed31addbc2aba1288f6a /lib/util.php | |
parent | bab3e1b8586f42bc1f0a5f96b6990d67c6b74446 (diff) | |
parent | b3a0eea3b66e95becb6c4595ed71c7fe71ed6437 (diff) |
Merge branch '0.8.x' of git://gitorious.org/laconica/dev into 0.8.x
Diffstat (limited to 'lib/util.php')
-rw-r--r-- | lib/util.php | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/lib/util.php b/lib/util.php index 91b15ccf5..4e09bffce 100644 --- a/lib/util.php +++ b/lib/util.php @@ -72,8 +72,7 @@ function common_timezone() } } - global $config; - return $config['site']['timezone']; + return common_config('site', 'timezone'); } function common_language() @@ -467,7 +466,7 @@ function common_replace_urls_callback($text, $callback) { $url = (mb_strpos($orig_url, htmlspecialchars($url)) === FALSE) ? $url:htmlspecialchars($url); // Call user specified func - $modified_url = $callback($url); + $modified_url = call_user_func($callback, $url); // Replace it! $start = mb_strpos($text, $url, $offset); @@ -481,18 +480,12 @@ function common_replace_urls_callback($text, $callback) { function common_linkify($url) { // It comes in special'd, so we unspecial it before passing to the stringifying // functions - $ext = pathinfo($url, PATHINFO_EXTENSION); $url = htmlspecialchars_decode($url); - $video_ext = array('mp4', 'flv', 'avi', 'mpg', 'mp3', 'ogg'); $display = $url; $url = (!preg_match('#^([a-z]+://|(mailto|aim|tel):)#i', $url)) ? 'http://'.$url : $url; $attrs = array('href' => $url, 'rel' => 'external'); - if (in_array($ext, $video_ext)) { - $attrs['class'] = 'media'; - } - if ($longurl = common_longurl($url)) { $attrs['title'] = $longurl; } @@ -688,7 +681,7 @@ function common_relative_profile($sender, $nickname, $dt=null) $recipient = new Profile(); // XXX: use a join instead of a subquery $recipient->whereAdd('EXISTS (SELECT subscribed from subscription where subscriber = '.$sender->id.' and subscribed = id)', 'AND'); - $recipient->whereAdd('nickname = "' . trim($nickname) . '"', 'AND'); + $recipient->whereAdd("nickname = '" . trim($nickname) . "'", 'AND'); if ($recipient->find(true)) { // XXX: should probably differentiate between profiles with // the same name by date of most recent update @@ -698,7 +691,7 @@ function common_relative_profile($sender, $nickname, $dt=null) $recipient = new Profile(); // XXX: use a join instead of a subquery $recipient->whereAdd('EXISTS (SELECT subscriber from subscription where subscribed = '.$sender->id.' and subscriber = id)', 'AND'); - $recipient->whereAdd('nickname = "' . trim($nickname) . '"', 'AND'); + $recipient->whereAdd("nickname = '" . trim($nickname) . "'", 'AND'); if ($recipient->find(true)) { // XXX: should probably differentiate between profiles with // the same name by date of most recent update @@ -722,21 +715,23 @@ function common_local_url($action, $args=null, $params=null, $fragment=null) { $r = Router::get(); $path = $r->build($action, $args, $params, $fragment); - if ($path) { - } + if (common_config('site','fancy')) { $url = common_path(mb_substr($path, 1)); } else { - $url = common_path('index.php'.$path); + if (mb_strpos($path, '/index.php') === 0) { + $url = common_path(mb_substr($path, 1)); + } else { + $url = common_path('index.php'.$path); + } } return $url; } function common_path($relative) { - global $config; - $pathpart = ($config['site']['path']) ? $config['site']['path']."/" : ''; - return "http://".$config['site']['server'].'/'.$pathpart.$relative; + $pathpart = (common_config('site', 'path')) ? common_config('site', 'path')."/" : ''; + return "http://".common_config('site', 'server').'/'.$pathpart.$relative; } function common_date_string($dt) @@ -1029,8 +1024,7 @@ function common_ensure_syslog() { static $initialized = false; if (!$initialized) { - global $config; - openlog($config['syslog']['appname'], 0, LOG_USER); + openlog(common_config('syslog', 'appname'), 0, LOG_USER); $initialized = true; } } |