/[drupal]/contributions/sandbox/jamesandres/facebook_apps_demo/facebook_apps_demo.module
ViewVC logotype

Contents of /contributions/sandbox/jamesandres/facebook_apps_demo/facebook_apps_demo.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Sun Sep 9 19:16:15 2007 UTC (2 years, 2 months ago) by jamesandres
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/x-php
*** empty log message ***
1 <?php
2 /**
3 * @file facebook_apps_demo.module
4 * This is a demonstration module of the basic uses of the facebook_apps framework
5 *
6 * @author James Andres
7 * @since August 16th, 2007
8 **/
9
10 /**
11 * Implementation of the hook_menu().
12 */
13 function facebook_apps_demo_menu($may_cache) {
14 if ($may_cache) {
15 // The Demo Application Canvas Page
16 $items[] = array(
17 'path' => 'fb-app/demo',
18 'title' => t('Facebook Apps Demo'),
19 'callback' => 'drupal_get_form',
20 'callback arguments' => array('facebook_apps_demo_form'),
21 'type' => MENU_CALLBACK,
22 'fb_conf' => array(
23 'callback_url' => url('fb-app', NULL, FALSE, TRUE),
24 'canvas_path' => variable_get('facebook_apps_demo_canvas_path', 'drupal_fb_test'),
25 ),
26 'access' => TRUE,
27 );
28
29 // Admin settings page
30 $items[] = array(
31 'path' => 'admin/settings/facebook_apps_demo',
32 'title' => t('Facebook Apps Demo'),
33 'callback' => 'drupal_get_form',
34 'callback arguments' => array('facebook_apps_demo_admin_form'),
35 'access' => user_access('access administration pages'),
36 );
37 }
38
39 return (array) $items;
40 }
41
42 function facebook_apps_demo_form() {
43 global $user;
44
45 // Load our CSS with media set to 'facebook'. The facebook apps module catches this and displays our CSS inline.
46 drupal_add_css('modules/facebook_apps_demo/facebook_apps_demo.css', 'module', 'facebook');
47
48 $form['image_url'] = array(
49 '#title' => t('Image URL'),
50 '#type' => 'textfield',
51 '#description' => t('Enter an image URL. eg: http://mail.google.com/mail/help/images/logo1.gif'),
52 );
53 if ($_POST['image_url']) {
54 $form['image'] = array(
55 '#value' => '<img src="' . $_POST['image_url'] . '" /><br />',
56 );
57 }
58 $form['submit'] = array('#type' => 'submit', '#value' => 'Add image to my profile');
59 $form['POST'] = array(
60 '#value' => '<pre style="padding: 10px; font-size: x-small; background-color: black; color: white;">' . var_export($_POST, 1) . '</pre><br />',
61 );
62
63 return $form;
64 }
65
66 function theme_facebook_apps_demo_form($form) {
67 $output .= '<div class="container" @fb_apps_blue_bg>';
68 $output .= drupal_render($form);
69 $output .= '</div>';
70
71 return $output;
72 }
73
74 /**
75 * Implementation of hook_facebook_inline_css()
76 *
77 * The hook facebook_inline_css is used to define rules that will rewrite the
78 * output of facebook pages. This is incredibly useful for doing large ammounts
79 * of inline CSS.
80 *
81 * Also, try using this function as a workaround for this problem:
82 * http://wiki.developers.facebook.com/index.php/Common_error_messages#CSS:_INTERNAL_ERROR:_incomplete_url_list
83 **/
84 function facebook_apps_demo_facebook_inline_css(&$content) {
85 return array(
86 '@fb_apps_blue_bg' => 'style="background-color: #deeefd;"',
87 );
88 }
89
90 function facebook_apps_demo_form_validate($form_id, $form_values) {
91 if (!$form_values['image_url']) {
92 form_set_error('image_url', t('Please enter an image URL.'));
93 }
94 }
95
96 /**
97 * This is the admin settings form.
98 **/
99 function facebook_apps_demo_admin_form() {
100 $form['facebook_apps_demo_canvas_path'] = array(
101 '#title' => t('Canvas Path URL For Demo App'),
102 '#type' => 'textfield',
103 '#default_value' => variable_get('facebook_apps_demo_canvas_path', ''),
104 '#required' => TRUE,
105 '#description' => t('Enter the canvas page path for your application. This should be the same as the value you entered when you were applying for your API key from Facebook\'s Developer application. It will be something like "test_app" part of http://apps.facebook.com/test_app.'),
106 );
107 $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
108
109 return $form;
110 }
111 function facebook_apps_demo_admin_form_submit($form_id, $form_values) {
112 variable_set('facebook_apps_demo_canvas_path', $form_values['facebook_apps_demo_canvas_path']);
113 drupal_set_message(t('Settings saved!'));
114 }

  ViewVC Help
Powered by ViewVC 1.1.2