summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/stream.php14
-rw-r--r--lib/util.php36
2 files changed, 48 insertions, 2 deletions
diff --git a/lib/stream.php b/lib/stream.php
index c50167841..62d1cd67c 100644
--- a/lib/stream.php
+++ b/lib/stream.php
@@ -60,6 +60,11 @@ class StreamAction extends Action {
_('Profile'),
($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname,
$action == 'showstream');
+ common_menu_item(common_local_url('showfavorites', array('nickname' =>
+ $nickname)),
+ _('Favorites'),
+ sprintf(_('%s\'s favorite notices'), ($user_profile) ? $user_profile->getBestName() : _('User')),
+ $action == 'showfavorites');
common_element_end('ul');
}
@@ -133,10 +138,17 @@ class StreamAction extends Action {
common_raw('×');
common_element_end('a');
}
+ if ($user) {
+ if ($user->hasFave($notice)) {
+ common_disfavor_form($notice);
+ } else {
+ common_favor_form($notice);
+ }
+ }
common_element_end('p');
common_element_end('li');
}
-
+
function source_link($source) {
$source_name = _($source);
switch ($source) {
diff --git a/lib/util.php b/lib/util.php
index eeb2d7f64..6be317701 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -174,7 +174,7 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL, $headercall=
# FIXME: correct language for interface
$language = common_language();
-
+
common_element_start('html', array('xmlns' => 'http://www.w3.org/1999/xhtml',
'xml:lang' => $language,
'lang' => $language));
@@ -913,6 +913,16 @@ function common_fancy_url($action, $args=NULL) {
return common_path($path . (($args) ? ('?' . http_build_query($args)) : ''));
case 'tags':
return common_path('tags' . (($args) ? ('?' . http_build_query($args)) : ''));
+ case 'favor':
+ return common_path('main/favor');
+ case 'disfavor':
+ return common_path('main/disfavor');
+ case 'showfavorites':
+ if ($args && isset($args['page'])) {
+ return common_path($args['nickname'].'/favorites?page=' . $args['page']);
+ } else {
+ return common_path($args['nickname'].'/favorites');
+ }
default:
return common_simple_url($action, $args);
}
@@ -1537,6 +1547,30 @@ function common_session_token() {
return $_SESSION['token'];
}
+function common_disfavor_form($notice) {
+ common_element_start('form', array('id' => 'disfavor-' . $notice->id,
+ 'method' => 'post',
+ 'action' => common_local_url('disfavor')));
+ common_hidden('token', common_session_token());
+ common_hidden('notice', $notice->id);
+ common_element('input', array('type' => 'button',
+ 'class' => 'disfavor'),
+ '♥');
+ common_element_end('form');
+}
+
+function common_favor_form($notice) {
+ common_element_start('form', array('id' => 'favor-' . $notice->id,
+ 'method' => 'post',
+ 'action' => common_local_url('disfavor')));
+ common_hidden('token', common_session_token());
+ common_hidden('notice', $notice->id);
+ common_element('input', array('type' => 'button',
+ 'class' => 'disfavor'),
+ '♡');
+ common_element_end('form');
+}
+
function common_cache_key($extra) {
return 'laconica:' . common_keyize(common_config('site', 'name')) . ':' . $extra;
}