diff options
author | Mike Cochrane <mikec@mikenz.geek.nz> | 2008-07-20 01:57:02 -0400 |
---|---|---|
committer | Mike Cochrane <mikec@mikenz.geek.nz> | 2008-07-20 01:57:02 -0400 |
commit | 5d84485001ace75c49cdc295b4ed3540db83e988 (patch) | |
tree | 4100b04f90ecfecf95082c5fc2472bd7707e28f3 /lib | |
parent | e4f1d6f50444cf2ca6e9aaf7116d40eaa17b0f1c (diff) |
First cut at hastags support.
darcs-hash:20080720055702-533db-193ed842b0d0a952bef71a3c5287213ada0ef15c.gz
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common.php | 1 | ||||
-rw-r--r-- | lib/util.php | 23 |
2 files changed, 19 insertions, 5 deletions
diff --git a/lib/common.php b/lib/common.php index 69714be1d..518171249 100644 --- a/lib/common.php +++ b/lib/common.php @@ -115,6 +115,5 @@ require_once(INSTALLDIR.'/classes/Confirm_address.php'); require_once(INSTALLDIR.'/classes/Remember_me.php'); require_once(INSTALLDIR.'/classes/Queue_item.php'); require_once(INSTALLDIR.'/classes/Reply.php'); -require_once(INSTALLDIR.'/classes/Sms_carrier.php'); require_once('markdown.php'); diff --git a/lib/util.php b/lib/util.php index cc7a725fb..a049ea600 100644 --- a/lib/util.php +++ b/lib/util.php @@ -275,6 +275,7 @@ function common_nav_menu() { } common_menu_item(common_local_url('public'), _('Public')); common_menu_item(common_local_url('peoplesearch'), _('Search')); + common_menu_item(common_local_url('tags'), _('Tags')); common_menu_item(common_local_url('doc', array('title' => 'help')), _('Help')); if ($user) { @@ -603,11 +604,15 @@ function common_render_content($text, $notice) { $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 + $r = preg_replace('/(^|\s+)#([a-z0-9]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r); # XXX: machine tags return $r; } +function common_tag_link($tag) { + return '<a href="' . htmlspecialchars(common_path('tag/' . $tag)) . '" class="hashlink">' . $tag . '</a>'; +} + function common_at_link($sender_id, $nickname) { $sender = Profile::staticGet($sender_id); $recipient = common_relative_profile($sender, $nickname); @@ -790,6 +795,16 @@ function common_fancy_url($action, $args=NULL) { return common_path('search/notice/rss' . (($args) ? ('?' . http_build_query($args)) : '')); case 'avatarbynickname': return common_path($args['nickname'].'/avatar/'.$args['size']); + case 'tag': + if (isset($args['tag']) && $args['tag']) { + $path = 'tag/' . $args['tag']; + unset($args['tag']); + } else { + $path = 'tags'; + } + return common_path($path . (($args) ? ('?' . http_build_query($args)) : '')); + case 'tags': + return common_path('tags' . (($args) ? ('?' . http_build_query($args)) : '')); default: return common_simple_url($action, $args); } @@ -859,12 +874,12 @@ function common_date_w3dtf($dt) { function common_date_rfc2822($dt) { $t = strtotime($dt); - return date("r", $t); + return date("r", $t); } function common_date_iso8601($dt) { $t = strtotime($dt); - return date("c", $t); + return date("c", $t); } function common_redirect($url, $code=307) { @@ -1314,7 +1329,7 @@ function common_profile_uri($profile) { if ($user) { return $user->uri; } - + $remote = Remote_profile::staticGet($profile->id); if ($remote) { return $remote->uri; |