| Commit | Line | Data |
|---|---|---|
| 4a49bc9a | 1 | <?php |
| 456be90c DC |
2 | /** |
| 3 | * @file | |
| 4 | * Admin pages and forms for canvas apps. | |
| 19092d2f | 5 | * |
| 456be90c | 6 | */ |
| 4a49bc9a | 7 | |
| 67523320 | 8 | /** |
| 3cf45120 | 9 | * Implements hook_fb_admin(). |
| 67523320 DC |
10 | */ |
| 11 | function fb_canvas_fb_admin($op, $data, &$return) { | |
| 12 | $fb = isset($data['fb']) ? $data['fb'] : NULL; | |
| 13 | $fb_app = isset($data['fb_app']) ? $data['fb_app'] : NULL; | |
| 19092d2f | 14 | |
| 67523320 DC |
15 | if ($op == FB_ADMIN_OP_SET_PROPERTIES) { |
| 16 | // Compute properties which we can set automatically. | |
| f54b3a2b | 17 | if (function_exists('fb_url_inbound_alter')) { |
| b389f367 | 18 | $callback_url = url('', array('absolute' => TRUE)) . FB_SETTINGS_CB . '/' . $fb_app->id . '/'; |
| f54b3a2b DC |
19 | } |
| 20 | else { | |
| 21 | // Paving the way to make URL alters optional. | |
| 22 | $callback_url = url('', array('absolute' => TRUE)); | |
| 23 | } | |
| 67523320 DC |
24 | $return['callback_url'] = $callback_url; |
| 25 | } | |
| 456be90c | 26 | elseif ($op == FB_ADMIN_OP_LIST_PROPERTIES) { |
| 67523320 DC |
27 | $return[t('Callback URL')] = 'callback_url'; |
| 28 | } | |
| 29 | } | |
| 30 | ||
| 31 | ||
| 4a49bc9a DC |
32 | /** |
| 33 | * Form builder; Configure settings for this site. | |
| 34 | * | |
| 35 | * @ingroup forms | |
| 36 | * @see system_settings_form() | |
| 37 | */ | |
| 38 | function fb_canvas_admin_settings() { | |
| 39 | ||
| 40 | $form['process_settings'] = array( | |
| 41 | '#type' => 'fieldset', | |
| b389f367 DC |
42 | '#title' => t('Canvas page URL processing'), |
| 43 | '#description' => t('This option alters links, so that instead of changing the iframe\'s URL, they change the top frame, to something starting <em>apps.facebook.com/APP/...</em> This adds some overhead to each canvas page served. Still, most sites will want this enabled.'), | |
| 4a49bc9a | 44 | ); |
| 4a49bc9a DC |
45 | $form['process_settings'][FB_CANVAS_VAR_PROCESS_IFRAME] = array( |
| 46 | '#type' => 'checkbox', | |
| cd2b0fa0 | 47 | '#title' => t('Enable on iframe canvas pages.'), |
| 4a49bc9a | 48 | '#default_value' => variable_get(FB_CANVAS_VAR_PROCESS_IFRAME, TRUE), |
| b389f367 | 49 | '#description' => t('If unchecked, settings below have no effect.'), |
| 4a49bc9a | 50 | ); |
| 8b29158f DC |
51 | $form['process_settings'][FB_CANVAS_VAR_PROCESS_ABSOLUTE] = array( |
| 52 | '#type' => 'checkbox', | |
| b389f367 | 53 | '#title' => t('Replace absolute hrefs, not just relative, with canvas page URLs.'), |
| 8b29158f DC |
54 | '#default_value' => variable_get(FB_CANVAS_VAR_PROCESS_ABSOLUTE, TRUE), |
| 55 | ); | |
| 4a49bc9a DC |
56 | return system_settings_form($form); |
| 57 | } | |
| 58 | ||
| 3946309e DC |
59 | /** |
| 60 | * See fb_canvas_form_alter. | |
| 61 | */ | |
| 62 | function fb_canvas_admin_form_alter(&$form, &$form_state, $form_id) { | |
| 63 | // Add our settings to the fb_app edit form. | |
| 64 | if (isset($form['fb_app_data']) && is_array($form['fb_app_data'])) { | |
| 65 | $fb_app = $form['#fb_app']; | |
| 19092d2f DC |
66 | $fb_canvas_data = _fb_canvas_get_config($fb_app); |
| 67 | ||
| 3946309e DC |
68 | $form['fb_app_data']['fb_canvas'] = array( |
| 69 | '#type' => 'fieldset', | |
| 70 | '#collapsible' => TRUE, | |
| d8f85b06 | 71 | '#collapsed' => isset($fb_app->label), |
| 3946309e DC |
72 | '#title' => t('Facebook canvas pages'), |
| 73 | '#description' => t('Settings which apply to <a href=!url target=_blank>canvas pages</a>.', | |
| cd2b0fa0 | 74 | array('!url' => 'http://developers.facebook.com/docs/guides/canvas/')), |
| 3946309e | 75 | ); |
| cd2b0fa0 | 76 | |
| 3cf45120 DC |
77 | // Override themes. Start by fetching all enabled themes. |
| 78 | $themes = system_get_info('theme'); | |
| cd2b0fa0 DC |
79 | ksort($themes); |
| 80 | $theme_options[0] = t('System default'); | |
| 3cf45120 DC |
81 | foreach ($themes as $key => $theme) { |
| 82 | $theme_options[$key] = $theme['name']; | |
| cd2b0fa0 DC |
83 | } |
| 84 | $form['fb_app_data']['fb_canvas']['theme_iframe'] = array( | |
| 85 | '#type' => 'select', | |
| 86 | '#title' => t('Theme for canvas pages'), | |
| 87 | '#description' => t('Choose a theme designed for 760px width iframe canvas.'), | |
| 88 | '#options' => $theme_options, | |
| 89 | '#required' => TRUE, | |
| 90 | '#default_value' => $fb_canvas_data['theme_iframe'], | |
| 91 | ); | |
| 92 | ||
| 19092d2f | 93 | |
| cd2b0fa0 | 94 | if (FALSE) { // @TODO - no require_login in new libs??? |
| 3946309e DC |
95 | $form['fb_app_data']['fb_canvas']['require_login'] = array( |
| 96 | '#type' => 'radios', | |
| 97 | '#title' => t('Require authorization'), | |
| 98 | '#description' => t('Require authorization if you want Drupal for Facebook to call require_login() on <strong>every</strong> canvas page.'), | |
| 99 | '#options' => array( | |
| 100 | FB_CANVAS_OPTION_ALLOW_ANON => t('Allow anonymous visitors'), | |
| 101 | FB_CANVAS_OPTION_REQUIRE_LOGIN => t('Require all users to authorize the application'), | |
| 102 | ), | |
| 103 | '#default_value' => $fb_canvas_data['require_login'], | |
| 104 | '#required' => TRUE, | |
| 105 | ); | |
| cd2b0fa0 | 106 | } |
| 19092d2f | 107 | |
| 0b3a0b45 DC |
108 | $form['fb_app_data']['fb_canvas']['front_anonymous'] = array( |
| 109 | '#type' => 'textfield', | |
| 110 | '#title' => t('Front page when user has not authorized the application'), | |
| 111 | '#description' => t('This is the front page for users who are not logged into facebook, or have not authorized the application. Leave blank to use the site-wide front page.'), | |
| 112 | '#default_value' => $fb_canvas_data['front_anonymous'], | |
| 113 | ); | |
| 114 | $form['fb_app_data']['fb_canvas']['front_added'] = array( | |
| 115 | '#type' => 'textfield', | |
| 116 | '#title' => t('Front page for authorized users of this application'), | |
| 117 | '#description' => t('Leave blank to use the site-wide front page.'), | |
| 118 | '#default_value' => $fb_canvas_data['front_added'], | |
| 119 | ); | |
| 3946309e | 120 | } |
| 3946309e | 121 | } |