diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2011-10-06 22:41:35 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2011-10-06 22:41:35 -0300 |
commit | fe5d67700ceb54bdc951dbd1f5f98e9dcae89855 (patch) | |
tree | 9ec00b088f2cb2b65ea62950d87754094f0d7e73 | |
parent | fc44d53e2538655f2859cfe1b7566b6db44cdcfb (diff) | |
download | muamba-fe5d67700ceb54bdc951dbd1f5f98e9dcae89855.tar.gz muamba-fe5d67700ceb54bdc951dbd1f5f98e9dcae89855.tar.bz2 |
Widget updates
-rw-r--r-- | CREDITS.txt | 2 | ||||
-rw-r--r-- | images/cancel.orig.png | bin | 0 -> 44388 bytes | |||
-rw-r--r-- | images/cancel.png | bin | 0 -> 10838 bytes | |||
-rw-r--r-- | images/unavailable.orig.png | bin | 0 -> 69262 bytes | |||
-rw-r--r-- | images/unavailable.png | bin | 0 -> 12484 bytes | |||
-rw-r--r-- | muamba-widget.tpl.php | 42 | ||||
-rw-r--r-- | muamba.misc.inc | 2 | ||||
-rw-r--r-- | muamba.module | 7 | ||||
-rw-r--r-- | muamba.theme.inc | 24 |
9 files changed, 62 insertions, 15 deletions
diff --git a/CREDITS.txt b/CREDITS.txt index ee91239..85e71bd 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -17,3 +17,5 @@ http://www.openclipart.org/detail/57079/recover-symbol-by-doctormo http://www.openclipart.org/detail/147421/home-by-netalloy-147421 http://www.openclipart.org/detail/107473/folder-inbox-by-anonymous http://www.openclipart.org/detail/160369/eshop-by-lbear +http://www.openclipart.org/detail/110/red-square-error-warning-icon-by-molumen +http://www.openclipart.org/detail/57745/denied-by-chovynz diff --git a/images/cancel.orig.png b/images/cancel.orig.png Binary files differnew file mode 100644 index 0000000..c65dc65 --- /dev/null +++ b/images/cancel.orig.png diff --git a/images/cancel.png b/images/cancel.png Binary files differnew file mode 100644 index 0000000..e6ec59d --- /dev/null +++ b/images/cancel.png diff --git a/images/unavailable.orig.png b/images/unavailable.orig.png Binary files differnew file mode 100644 index 0000000..945bcfc --- /dev/null +++ b/images/unavailable.orig.png diff --git a/images/unavailable.png b/images/unavailable.png Binary files differnew file mode 100644 index 0000000..7b4f6d4 --- /dev/null +++ b/images/unavailable.png diff --git a/muamba-widget.tpl.php b/muamba-widget.tpl.php index 3caf614..6923de8 100644 --- a/muamba-widget.tpl.php +++ b/muamba-widget.tpl.php @@ -3,27 +3,41 @@ /** * @file * Template for displaying the muamba widget. - * - * @todo: use $transaction - * Show item status: can it be requested? - * Is this item already requested? */ -// Add javascript and CSS files +// User and path $path = drupal_get_path('module', 'muamba'); +global $user; + +// Add javascript and CSS files drupal_add_js($path .'/muamba.js'); drupal_add_css($path .'/muamba.css'); -$icon = theme('image', - array( - 'path' => $path .'/images/basket.png', - 'alt' => t('Request item'), - 'title' => t('Request item'), - ) -); - $output = '<div class="muamba-widget">'; -$output .= l($icon, 'muamba/request/'. $nid, array('html' => TRUE)); + +if (empty($transaction)) { + $output .= theme('muamba_widget_icon', array('status' => MUAMBA_REQUESTED, 'id' => $nid)); +} +elseif ($transaction['uid'] == $user->uid) { + foreach (muamba_actions_available('sent', $transaction['status']) as $action) { + $output .= theme('muamba_widget_icon', array('status' => $action, 'id' => $transaction['mid'])); + } +} +elseif ($transaction['owner'] == $user->uid) { + foreach (muamba_actions_available('received', $transcation['status']) as $action) { + $output .= theme('muamba_widget_icon', array('status' => $action, 'id' => $transaction['mid'])); + } +} +else { + $icon = theme('image', + array( + 'path' => $path .'/images/unavailable.png', + 'alt' => t('Item unavailable'), + 'title' => t('Item unavailable'), + ) + ); +} + $output .= '</div>'; print $output; diff --git a/muamba.misc.inc b/muamba.misc.inc index b5c1111..70aa598 100644 --- a/muamba.misc.inc +++ b/muamba.misc.inc @@ -76,7 +76,7 @@ function muamba_actions($code = NULL) { MUAMBA_LOST => 'lost', ); - if ($code == NULL) { + if ($code === NULL) { return $status; } diff --git a/muamba.module b/muamba.module index fcd6565..b530bb9 100644 --- a/muamba.module +++ b/muamba.module @@ -198,6 +198,13 @@ function muamba_theme($existing, $type, $theme, $path) { ), 'file' => 'muamba.theme.inc', ), + 'muamba_widget_icon' => array( + 'variables' => array( + 'status' => MUAMBA_REQUESTED, + 'id' => NULL, + ), + 'file' => 'muamba.theme.inc', + ), ); } diff --git a/muamba.theme.inc b/muamba.theme.inc index 4e201f7..a51f6f6 100644 --- a/muamba.theme.inc +++ b/muamba.theme.inc @@ -134,3 +134,27 @@ function theme_muamba_recovered_message($transaction = NULL) { function theme_muamba_lost_message($transaction = NULL) { return t('I declare that my item is lost'); } + +/** + * Theme callback. + */ +function theme_muamba_widget_icon($variables) { + $status = $variables['status']; + $id = $variables['id']; + $path = drupal_get_path('module', 'muamba'); + $action = muamba_actions($status); + $image = $path .'/images/'. $action .'.png'; + $title = ucfirst($action) .' item'; + + $icon = theme('image', + array( + 'path' => $image, + 'alt' => t($title), + 'title' => t($title), + ) + ); + + $output = l($icon, 'muamba/'. $action .'/'. $id, array('html' => TRUE)); + + return $output; +} |