From 5d84485001ace75c49cdc295b4ed3540db83e988 Mon Sep 17 00:00:00 2001 From: Mike Cochrane Date: Sun, 20 Jul 2008 01:57:02 -0400 Subject: First cut at hastags support. darcs-hash:20080720055702-533db-193ed842b0d0a952bef71a3c5287213ada0ef15c.gz --- lib/common.php | 1 - lib/util.php | 23 +++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'lib') 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]+@', '\0', $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 '' . $tag . ''; +} + 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; -- cgit v1.2.3-54-g00ecf