]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/util.php
lcase tname
[quix0rs-gnu-social.git] / lib / util.php
index c1fc8c78105f76dad2f2f4098db495a9158b3216..acc907480685ff1cc2dcd9f2f71a98f32669468a 100644 (file)
@@ -234,11 +234,7 @@ function common_show_footer() {
        } else {
                $instr = _('**%%site.name%%** is a microblogging service. ');
        }
-       $instr .= sprintf(_('It runs the [Laconica](http://laconi.ca/) ' .
-                        'microblogging software, version %s, ' .
-                        'available under the ' .
-                        '[GNU Affero General Public License]' .
-                        '(http://www.fsf.org/licensing/licenses/agpl-3.0.html).'), LACONICA_VERSION);
+       $instr .= sprintf(_('It runs the [Laconica](http://laconi.ca/) microblogging software, version %s, available under the [GNU Affero General Public License](http://www.fsf.org/licensing/licenses/agpl-3.0.html).'), LACONICA_VERSION);
     $output = common_markup_to_html($instr);
     common_raw($output);
        common_element_end('div');
@@ -597,8 +593,9 @@ define('URL_REGEX', '^|[ \t\r\n])((ftp|http|https|gopher|mailto|news|nntp|telnet
 function common_render_content($text, $notice) {
        $r = htmlspecialchars($text);
        $id = $notice->profile_id;
-       $r = preg_replace('@https?://\S+@', '<a href="\0" class="extlink">\0</a>', $r);
+       $r = preg_replace('@https?://[^)\]>\s]+@', '<a href="\0" class="extlink">\0</a>', $r);
        $r = preg_replace('/(^|\s+)@([a-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r);
+       $r = preg_replace('/^T ([A-Z0-9]{1,64}) /e', "'T '.common_at_link($id, '\\1').' '", $r);
        # XXX: # tags
        # XXX: machine tags
        return $r;
@@ -728,6 +725,8 @@ function common_fancy_url($action, $args=NULL) {
                return common_path('settings/'.$action);
         case 'profilesettings':
                return common_path('settings/profile');
+        case 'emailsettings':
+               return common_path('settings/email');
         case 'openidsettings':
                return common_path('settings/openid');
         case 'newnotice':
@@ -866,16 +865,22 @@ function common_redirect($url, $code=307) {
 }
 
 function common_save_replies($notice) {
+       # Alternative reply format
+       if (preg_match('/^T ([A-Z0-9]{1,64}) /', $notice->content, $match)) {
+               $tname = $match[1];
+       }
        # extract all @messages
        $cnt = preg_match_all('/(?:^|\s)@([a-z0-9]{1,64})/', $notice->content, $match);
-       if (!$cnt) {
+       if (!$cnt && !$tname) {
                return true;
        }
+       # XXX: is there another way to make an array copy?
+       $names = ($tname) ? array_unique(array_merge($match[1], array(strtolower($tname)))) : $match[1];
        $sender = Profile::staticGet($notice->profile_id);
        # store replied only for first @ (what user/notice what the reply directed,
        # we assume first @ is it)
-       for ($i=0; $i<count($match[1]); $i++) {
-               $nickname = $match[1][$i];
+       for ($i=0; $i<count($names); $i++) {
+               $nickname = $names[$i];
                $recipient = common_relative_profile($sender, $nickname, $notice->created);
                if (!$recipient) {
                        continue;
@@ -1062,7 +1067,7 @@ function common_log($priority, $msg, $filename=NULL) {
        if ($logfile) {
                $log = fopen($logfile, "a");
                if ($log) {
-                       static $syslog_priorities = array('LOG_EMERG', 'LOG_ALERT', 'LOG_CRIT', 'LOG_ERR', 
+                       static $syslog_priorities = array('LOG_EMERG', 'LOG_ALERT', 'LOG_CRIT', 'LOG_ERR',
                                                                                          'LOG_WARNING', 'LOG_NOTICE', 'LOG_INFO', 'LOG_DEBUG');
                        $output = date('Y-m-d H:i:s') . ' ' . $syslog_priorities[$priority] . ': ' . $msg . "\n";
                        fwrite($log, $output);
@@ -1273,3 +1278,13 @@ function common_markup_to_html($c) {
        $c = preg_replace('/%%(\w+).(\w+)%%/e', 'common_config(\'\\1\', \'\\2\')', $c);
        return Markdown($c);
 }
+
+function common_profile_avatar_url($profile, $size=AVATAR_PROFILE_SIZE) {
+       $avatar = $profile->getAvatar($size);
+       if ($avatar) {
+               return common_avatar_display_url($avatar);
+       } else {
+               return common_default_avatar($size);
+       }
+}
+       
\ No newline at end of file