| Commit | Line | Data |
|---|---|---|
| 8dd84187 | 1 | <?php |
| 8dd84187 DC |
2 | /** |
| 3 | * @file | |
| 4 | * Implementation of theme functions. | |
| 5 | * | |
| 6 | * XFBML markup will only work on canvas pages and facebook connect pages. | |
| 7 | */ | |
| 8 | ||
| 3cf45120 DC |
9 | // @TODO theme function now take only one parameter, an associative array. |
| 10 | ||
| 11 | function theme_fb_login_button($params) { | |
| 12 | $text = isset($params['text']) ? $params['text'] : ''; | |
| 13 | $options = isset($params['options']) ? $params['options'] : array(); | |
| 8dd84187 | 14 | |
| 16128aef DC |
15 | // Facebook used to provide default text. No longer, apparently. |
| 16 | if (!$text) { | |
| 17 | $text = t('Connect'); | |
| 18 | } | |
| 3cf45120 | 19 | |
| 97ccdfe6 DC |
20 | // Merge in defaults |
| 21 | $options += array( | |
| 22 | 'attributes' => array(), | |
| 23 | ); | |
| 79bfec16 | 24 | if (!isset($options['attributes']['scope'])) { |
| 97ccdfe6 DC |
25 | // Which permissions to prompt for? |
| 26 | $perms = array(); | |
| 27 | drupal_alter('fb_required_perms', $perms); | |
| 28 | if (count($perms)) { | |
| 79bfec16 | 29 | $options['attributes']['scope'] = implode(',', $perms); |
| 97ccdfe6 DC |
30 | } |
| 31 | } | |
| 19092d2f | 32 | |
| 3cf45120 | 33 | |
| 97ccdfe6 | 34 | $button = '<fb:login-button ' . drupal_attributes($options['attributes']) . '>' . |
| 73a3b338 | 35 | ($text ? '<fb:intl>' . check_plain($text) . '</fb:intl>' : '') . '</fb:login-button>'; |
| 3cf45120 | 36 | |
| 8dd84187 DC |
37 | return $button; |
| 38 | } | |
| 39 | ||
| 40 | ||
| 3cf45120 DC |
41 | function theme_fb_username($params) { |
| 42 | $fbu = $params['fbu']; | |
| 43 | $object = $params['account']; | |
| 44 | $orig = $params['orig']; | |
| b20ba34e | 45 | if (!$fbu || arg(0) == 'admin') { |
| 8dd84187 DC |
46 | return $orig; |
| 47 | } | |
| 48 | ||
| 49 | $wrap_pre = "<span class=fb_hide>$orig</span><span class=fb_show style='display:none'>"; | |
| 50 | $wrap_post = "</span>\n"; | |
| 11665fdd | 51 | $ifcantsee = ''; |
| 8dd84187 DC |
52 | if ($object->uid && user_access('access user profiles')) { |
| 53 | // Provide link if local account. | |
| 54 | $wrap_pre = $wrap_pre . '<a href="' . url('user/' . $object->uid) . '">'; | |
| 55 | $wrap_post = '</a>' . $wrap_post; | |
| 56 | $ifcantsee = 'ifcantsee="' . addslashes(check_plain($object->name)) . '"'; | |
| 57 | } | |
| 19092d2f | 58 | |
| 8dd84187 DC |
59 | $fbml = "<fb:name linked=false useyou=false uid=\"$fbu\" $ifcantsee></fb:name>"; $output = $wrap_pre . $fbml . $wrap_post; |
| 60 | ||
| 61 | return $output; | |
| 62 | } | |
| 63 | ||
| 3cf45120 DC |
64 | function theme_fb_user_picture($params) { |
| 65 | if (!$params['fbu']) | |
| 66 | return $params['orig']; | |
| 8dd84187 | 67 | |
| 40491169 DC |
68 | $fbu = $params['fbu']; |
| 69 | $object = $params['account']; | |
| 70 | $orig = $params['orig']; | |
| 71 | ||
| 006ce70b | 72 | // http://developers.facebook.com/docs/reference/fbml/profile-pic |
| 8dd84187 DC |
73 | $fbml = "<fb:profile-pic linked=false uid=\"$fbu\"></fb:profile-pic>"; |
| 74 | $wrap_pre = '<span class=fb_hide>' . $orig . '</span><span class="fb_show" style="display:none;"><div class="picture">'; | |
| 75 | $wrap_post = '</div></span>'; | |
| 76 | if ($object->uid && user_access('access user profiles')) { | |
| 77 | // Provide link to local account. | |
| 78 | $wrap_pre = $wrap_pre . '<a href="' . url('user/' . $object->uid) . '">'; | |
| 79 | $wrap_post = '</a>' . $wrap_post; | |
| 80 | } | |
| 81 | return $wrap_pre . $fbml . $wrap_post; | |
| 82 | } | |
| 83 | ||
| 84 | ||
| 7d7e57b4 | 85 | function theme_fb_fbml_popup($elem) { |
| 8dd84187 | 86 | // Hide this markup until javascript shows it. |
| 7d7e57b4 | 87 | $t = '<div class="fb_fbml_popup_wrap" style="display:none;" ' . ">\n"; |
| 19092d2f DC |
88 | |
| 89 | $t .= '<a href="#" title="' . check_plain($elem['#title']) . '" ' . | |
| 8dd84187 | 90 | (isset($elem['#link_attributes']) ? drupal_attributes($elem['#link_attributes']) : '') . |
| 3cf45120 | 91 | '>' . check_plain($elem['#link_text']) . '</a>'; |
| 7d7e57b4 | 92 | $t .= '<div class="fb_fbml_popup" ' . drupal_attributes($elem['#attributes']) . '>'; |
| 8dd84187 DC |
93 | $t .= $elem['#children']; |
| 94 | $t .= "</div></div>\n"; | |
| 95 | return $t; | |
| 96 | } |