]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/util.php
reformat curry() to make my editor happy
[quix0rs-gnu-social.git] / lib / util.php
index 29eb6cbbcea1ef02b30d4f023f8137e5a6f434c9..79a219fd6d7abb7378ec75532f6a656cd36c6ec0 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -54,9 +54,9 @@ function common_init_language()
     $language = common_language();
     // So we don't have to make people install the gettext locales
     $locale_set = common_init_locale($language);
-    bindtextdomain("laconica", common_config('site','locale_path'));
-    bind_textdomain_codeset("laconica", "UTF-8");
-    textdomain("laconica");
+    bindtextdomain("statusnet", common_config('site','locale_path'));
+    bind_textdomain_codeset("statusnet", "UTF-8");
+    textdomain("statusnet");
     setlocale(LC_CTYPE, 'C');
     if(!$locale_set) {
         common_log(LOG_INFO,'Language requested:'.$language.' - locale could not be set:',__FILE__);
@@ -404,7 +404,7 @@ function common_render_text($text)
 
     $r = preg_replace('/[\x{0}-\x{8}\x{b}-\x{c}\x{e}-\x{19}]/', '', $r);
     $r = common_replace_urls_callback($r, 'common_linkify');
-    $r = preg_replace('/(^|\(|\[|\s+)#([\pL\pN_\-\.]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r);
+    $r = preg_replace('/(^|\&quot\;|\'|\(|\[|\{|\s+)#([\pL\pN_\-\.]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r);
     // XXX: machine tags
     return $r;
 }
@@ -413,7 +413,7 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) {
     // Start off with a regex
     $regex = '#'.
     '(?:^|[\s\(\)\[\]\{\}\\\'\\\";]+)(?![\@\!\#])'.
-    '(?P<url>'.
+    '('.
         '(?:'.
             '(?:'. //Known protocols
                 '(?:'.
@@ -454,10 +454,10 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) {
 }
 
 function callback_helper($matches, $callback, $notice_id) {
-    $url=$matches['url'];
+    $url=$matches[1];
     $left = strpos($matches[0],$url);
     $right = $left+strlen($url);
-    
+
     $groupSymbolSets=array(
         array(
             'left'=>'(',
@@ -491,9 +491,7 @@ function callback_helper($matches, $callback, $notice_id) {
             $url=substr($url,0,-1);
         }
     }while($original_url!=$url);
-    
-    
-    
+
     if(empty($notice_id)){
         $result = call_user_func_array($callback,$url);
     }else{
@@ -508,16 +506,13 @@ function curry($fn) {
     array_shift($args);
     $id = uniqid('_partial');
     $GLOBALS[$id] = array($fn, $args);
-    return create_function(
-        '',
-        '
-        $args = func_get_args();
-        return call_user_func_array(
-        $GLOBALS["'.$id.'"][0],
-        array_merge(
-            $args,
-            $GLOBALS["'.$id.'"][1]));
-    ');
+    return create_function('',
+                           '$args = func_get_args(); '.
+                           'return call_user_func_array('.
+                           '$GLOBALS["'.$id.'"][0],'.
+                           'array_merge('.
+                           '$args,'.
+                           '$GLOBALS["'.$id.'"][1]));');
 }
 
 function common_linkify($url) {
@@ -1319,7 +1314,7 @@ function common_cache_key($extra)
         $base_key = common_keyize(common_config('site', 'name'));
     }
 
-    return 'laconica:' . $base_key . ':' . $extra;
+    return 'statusnet:' . $base_key . ':' . $extra;
 }
 
 function common_keyize($str)
@@ -1382,7 +1377,7 @@ function common_shorten_url($long_url)
 
     $curlh = curl_init();
     curl_setopt($curlh, CURLOPT_CONNECTTIMEOUT, 20); // # seconds to wait
-    curl_setopt($curlh, CURLOPT_USERAGENT, 'Laconica');
+    curl_setopt($curlh, CURLOPT_USERAGENT, 'StatusNet');
     curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true);
 
     switch($svc) {