diff --git a/fb_social.install b/fb_social.install index f833da8..29d2f39 100644 --- a/fb_social.install +++ b/fb_social.install @@ -26,7 +26,7 @@ function fb_social_uninstall() { foreach ($languages as $language) { variable_del('fb_social_language_' . $language->language); } - + } @@ -155,3 +155,10 @@ function fb_social_update_7200() { db_create_table('fb_social_preset', $fb_social_preset); } } + +/** + * Clear system registry. + */ +function fb_social_update_7201() { + cache_clear_all('*', 'cache_bootstrap', TRUE); +} diff --git a/fb_social.module b/fb_social.module index 0e5a8cc..fba8bc6 100644 --- a/fb_social.module +++ b/fb_social.module @@ -20,52 +20,64 @@ function fb_social_rdf_namespaces() { */ function fb_social_menu() { $items = array(); - + $items['fb_social/channel'] = array( - 'type' => MENU_CALLBACK, - 'description' => 'Facebook Custom Channel URL', - 'page callback' => 'fb_social_custom_channel_url', - 'access callback' => TRUE + 'type' => MENU_CALLBACK, + 'description' => 'Facebook Custom Channel URL', + 'page callback' => 'fb_social_custom_channel_url', + 'access callback' => TRUE ); - + $items['admin/structure/fbsocial'] = array( - 'title' => 'Facebook social', - 'description' => 'Settings for facebook social plugins.', - 'page callback' => 'drupal_get_form', + 'title' => 'Facebook social', + 'description' => 'Settings for facebook social plugins.', + 'page callback' => 'drupal_get_form', 'page arguments' => array( - 'fb_social_admin_settings_form' - ), - 'file' => 'fb_social.admin.inc', - 'access callback' => 'user_access', + 'fb_social_admin_settings_form' + ), + 'file' => 'fb_social.admin.inc', + 'access callback' => 'user_access', 'access arguments' => array( - 'administer site configuration' - ) + 'administer fb_social' + ) ); - + $items['admin/structure/fbsocial/settings'] = array( 'type' => MENU_DEFAULT_LOCAL_TASK, - 'title' => 'Settings', - 'description' => 'Settings for facebook social plugins.', - 'page callback' => 'drupal_get_form', + 'title' => 'Settings', + 'description' => 'Settings for facebook social plugins.', + 'page callback' => 'drupal_get_form', 'page arguments' => array( - 'fb_social_admin_settings_form' - ), - 'file' => 'fb_social.admin.inc', - 'access callback' => 'user_access', + 'fb_social_admin_settings_form' + ), + 'file' => 'fb_social.admin.inc', + 'access callback' => 'user_access', 'access arguments' => array( - 'administer site configuration' - ) + 'administer fb_social' + ) ); - + return $items; } /** + * Implements hook_permission(). + */ +function fb_social_permission() { + return array( + 'administer fb_social' => array( + 'title' => t('Administer FB Social'), + 'description' => t('Perform Facebook social plugins and settings.'), + ), + ); +} + +/** * Implements hook_block_info(). */ function fb_social_block_info() { $blocks = array(); - + // load all presets if ($presets = fb_social_get_presets()) { foreach ( $presets as $preset ) { @@ -98,13 +110,13 @@ function fb_social_theme($existing, $type, $theme, $path) { $path1 = drupal_get_path('module', 'fb_social'); return array( 'fb_social_plugin' => array( - 'template' => 'fb-social-plugin', - 'path' => "$path1/theme", + 'template' => 'fb-social-plugin', + 'path' => "$path1/theme", 'variables' => array( - 'plugin_type' => NULL, - 'options' => array() - ) - ) + 'plugin_type' => NULL, + 'options' => array() + ) + ) ); } @@ -114,27 +126,27 @@ function fb_social_theme($existing, $type, $theme, $path) { function fb_social_preprocess_fb_social_plugin(&$variables) { global $_fb_script_init; $_fb_script_init = TRUE; - + $plugin = fb_social_fb_plugin_load($variables['plugin_type']); - + // delegate to plugin's preprocess function $function = ctools_plugin_get_function($plugin, 'hook_preprocess_fb_social_plugin'); if ($function) { $function($variables); } - + // are we rendering html5 or xfbml $markup_type = variable_get('fb_social_markup_type', 'xfbml'); - + $variables['tag_name'] = ($markup_type == "xfbml") ? "fb:" . $plugin['html tag name'] : "div"; - + if ($markup_type == 'html5') { foreach ( $variables['options'] as $key => $value ) { $variables['options']["data-" . $key] = $value; unset($variables['options'][$key]); } $variables['options'] = array( - 'class' => "fb-" . $plugin['html tag name'] + 'class' => "fb-" . $plugin['html tag name'] ) + $variables['options']; } } @@ -145,16 +157,16 @@ function fb_social_preprocess_fb_social_plugin(&$variables) { function fb_social_node_view($node, $view_mode = 'full') { $links = fb_social_link('node', $node, $view_mode); $node->content['links']['fb_social'] = array( - '#theme' => 'links__node__fb_social', - '#links' => $links, + '#theme' => 'links__node__fb_social', + '#links' => $links, '#attributes' => array( 'class' => array( - 'links', - 'inline' - ) - ) + 'links', + 'inline' + ) + ) ); - + if ($presets = fb_social_get_presets()) { foreach ( $presets as $preset ) { $plugin = fb_social_fb_plugin_load($preset->plugin_type); @@ -173,7 +185,7 @@ function fb_social_node_view($node, $view_mode = 'full') { function fb_social_field_extra_fields() { $extras = array(); if ($presets = fb_social_get_presets()) { - + foreach ( $presets as $preset ) { $plugin = fb_social_fb_plugin_load($preset->plugin_type); $function = ctools_plugin_get_function($plugin, 'hook_field_extra_fields'); @@ -200,7 +212,7 @@ function fb_social_link($type, $object = NULL, $view_mode = 'full') { if ($function) { $links += $function($preset, $type, $object, $view_mode); } - + } } if (isset($links)) { @@ -210,22 +222,22 @@ function fb_social_link($type, $object = NULL, $view_mode = 'full') { // ctools hooks / api - + /** - * Implements hook_ctools_plugin_type() to inform the plugin system + * Implements hook_ctools_plugin_type() to inform the plugin system * owns 'fb_plugin' plugin types. * - * "process" tells ctools that by default each - * plugin has some default functions named consistently + * "process" tells ctools that by default each + * plugin has some default functions named consistently * after the plugin name * @see _fb_social_ctools_plugin_fb_plugin_process() */ function fb_social_ctools_plugin_type() { - + return array( 'fb_plugin' => array( - 'process' => '_fb_social_ctools_plugin_fb_plugin_process' - ) + 'process' => '_fb_social_ctools_plugin_fb_plugin_process' + ) ); } @@ -235,13 +247,13 @@ function fb_social_ctools_plugin_type() { function fb_social_ctools_plugin_api($module, $api) { if ($module == 'fb_social' && $api == 'plugins') { return array( - 'version' => 1 + 'version' => 1 ); } //boxes if ($module == 'boxes' && $api == 'plugins') { return array( - 'version' => 1 + 'version' => 1 ); } } @@ -250,13 +262,13 @@ function fb_social_ctools_plugin_api($module, $api) { * Implementation of hook_ctools_plugin_directory(). */ function fb_social_ctools_plugin_directory($module, $type) { - + return 'plugins/' . $type; } /** - * Helper function for ctools plugin 'process' + * Helper function for ctools plugin 'process' * @param $plugin * @param $info * @see fb_social_ctools_plugin_fb_plugin() @@ -281,23 +293,23 @@ function fb_social_fb_plugin_load($type = NULL) { if (isset($type)) { return $plugins[$type]; } - + return $plugins; } /** - * Return the default vaules of a certain plugin + * Return the default vaules of a certain plugin * type as defined by facebook * @param $type the plugin type/name (i.e. like). */ function fb_social_fb_plugin_defaults($type) { $plugin = fb_social_fb_plugin_load($type); - + $function = ctools_plugin_get_function($plugin, 'default values'); if ($function) { return $function(); } - + return array(); } @@ -308,26 +320,26 @@ function fb_social_fb_plugin_defaults($type) { function fb_social_fb_plugin_fb_settings_form($type, $options) { $form = array(); $plugin = fb_social_fb_plugin_load($type); - + $url = FB_REF_BASE_URL . $plugin['html tag name']; $l = l("facebook documentation page", $url, array( 'attributes' => array( - 'target' => '_blank' - ) + 'target' => '_blank' + ) )); $desc = t("For more information about this plugin and its attributes please check out the !facebookdoc", array( - '!facebookdoc' => $l + '!facebookdoc' => $l )); - + $form['help'] = array( - '#value' => "
" . $desc . "
" + '#value' => "
" . $desc . "
" ); - + $function = ctools_plugin_get_function($plugin, 'fb plugin form'); if ($function) { $form += $function($options); } - + return $form; } @@ -337,14 +349,14 @@ function fb_social_fb_plugin_fb_settings_form($type, $options) { */ function fb_social_fb_plugin_drupal_settings_form($type, $options) { $form = array(); - + $plugin = fb_social_fb_plugin_load($type); - + $function = ctools_plugin_get_function($plugin, 'drupal settings form'); if ($function) { $form = $function($options); } - + return $form; } @@ -364,46 +376,46 @@ function fb_social_preset_load($name = NULL, $reset = FALSE) { ctools_export_load_object_reset('fb_social_preset'); } $presets = ctools_export_load_object('fb_social_preset', 'all'); - + if (isset($name)) { return isset($presets[$name]) ? $presets[$name] : FALSE; } - + return $presets; } /** * Get all presets or a preset by name. By default * it returns only enabled presets. - * + * * @param $name * the preset name * @param $enabled - * + * * @param $reset */ function fb_social_get_presets($name = NULL, $enabled = TRUE, $reset = FALSE) { - + $presets = fb_social_preset_load($name, $reset); - + if (empty($presets)) { return FALSE; } - + if (is_object($presets)) { $presets = array( - $presets->name => $presets + $presets->name => $presets ); } - + if ($enabled) { $presets = array_filter($presets, '_fb_social_enabled_presets_filter'); } - + if (isset($name)) { return isset($presets[$name]) ? $presets[$name] : FALSE; } - + return $presets; } @@ -425,7 +437,7 @@ function fb_social_get_presets_by_type($type, $en = TRUE) { } } } - + return $result; } @@ -437,99 +449,99 @@ function fb_social_get_presets_by_type($type, $en = TRUE) { function fb_social_boxes_plugins() { $info = array(); $path = drupal_get_path('module', 'fb_social') . '/plugins/boxes'; - + $info['fb_social_default'] = array( 'handler' => array( - 'class' => 'fb_social_default', - 'file' => 'fb_social_default.inc', - 'path' => $path, - 'parent' => 'box' - ) + 'class' => 'fb_social_default', + 'file' => 'fb_social_default.inc', + 'path' => $path, + 'parent' => 'box' + ) ); - + $info['fb_social_like'] = array( - 'title' => 'facebook like', + 'title' => 'facebook like', 'handler' => array( - 'class' => 'fb_social_like', - 'file' => 'fb_social_like.inc', - 'path' => $path, - 'parent' => 'fb_social_default' - ) + 'class' => 'fb_social_like', + 'file' => 'fb_social_like.inc', + 'path' => $path, + 'parent' => 'fb_social_default' + ) ); - + $info['fb_social_likebox'] = array( - 'title' => 'facebook likebox', + 'title' => 'facebook likebox', 'handler' => array( - 'class' => 'fb_social_likebox', - 'file' => 'fb_social_likebox.inc', - 'path' => $path, - 'parent' => 'fb_social_default' - ) + 'class' => 'fb_social_likebox', + 'file' => 'fb_social_likebox.inc', + 'path' => $path, + 'parent' => 'fb_social_default' + ) ); - + $info['fb_social_send'] = array( - 'title' => 'facebook send', + 'title' => 'facebook send', 'handler' => array( - 'class' => 'fb_social_send', - 'file' => 'fb_social_send.inc', - 'path' => $path, - 'parent' => 'fb_social_default' - ) + 'class' => 'fb_social_send', + 'file' => 'fb_social_send.inc', + 'path' => $path, + 'parent' => 'fb_social_default' + ) ); - + $info['fb_social_facepile'] = array( - 'title' => 'facebook facepile', + 'title' => 'facebook facepile', 'handler' => array( - 'class' => 'fb_social_facepile', - 'file' => 'fb_social_facepile.inc', - 'path' => $path, - 'parent' => 'fb_social_default' - ) + 'class' => 'fb_social_facepile', + 'file' => 'fb_social_facepile.inc', + 'path' => $path, + 'parent' => 'fb_social_default' + ) ); - + $info['fb_social_livestream'] = array( - 'title' => 'facebook livestream', + 'title' => 'facebook livestream', 'handler' => array( - 'class' => 'fb_social_livestream', - 'file' => 'fb_social_livestream.inc', - 'path' => $path, - 'parent' => 'fb_social_default' - ) + 'class' => 'fb_social_livestream', + 'file' => 'fb_social_livestream.inc', + 'path' => $path, + 'parent' => 'fb_social_default' + ) ); - + $info['fb_social_comments'] = array( - 'title' => 'facebook comments', + 'title' => 'facebook comments', 'handler' => array( - 'class' => 'fb_social_comments', - 'file' => 'fb_social_comments.inc', - 'path' => $path, - 'parent' => 'fb_social_default' - ) + 'class' => 'fb_social_comments', + 'file' => 'fb_social_comments.inc', + 'path' => $path, + 'parent' => 'fb_social_default' + ) ); - + // Truncate the name of the plugin because the delta column in the blocks // table is limited to 32 characters. - + $info['fb_social_recommend'] = array( - 'title' => 'facebook recommendations', + 'title' => 'facebook recommendations', 'handler' => array( - 'class' => 'fb_social_recommendations', - 'file' => 'fb_social_recommendations.inc', - 'path' => $path, - 'parent' => 'fb_social_default' - ) + 'class' => 'fb_social_recommendations', + 'file' => 'fb_social_recommendations.inc', + 'path' => $path, + 'parent' => 'fb_social_default' + ) ); - + $info['fb_social_activityf'] = array( - 'title' => 'facebook activity feed', + 'title' => 'facebook activity feed', 'handler' => array( - 'class' => 'fb_social_activityfeed', - 'file' => 'fb_social_activityfeed.inc', - 'path' => $path, - 'parent' => 'fb_social_default' - ) + 'class' => 'fb_social_activityfeed', + 'file' => 'fb_social_activityfeed.inc', + 'path' => $path, + 'parent' => 'fb_social_default' + ) ); - + return $info; } @@ -537,12 +549,12 @@ function fb_social_boxes_plugins() { * returns the fbml content of the plugin */ function fb_social_preset_view($preset) { - + $plugin_type = $preset->plugin_type; $options = $preset->fb_attrs; - + $output = theme('fb_social_plugin', array('plugin_type' => $plugin_type, 'options' => $options)); - + // if this is a "comment" plugin, get comments from facebook and print them // behind the iframe if ($plugin_type == 'comments' && isset($preset->settings['plugin_comments_seo']) && $preset->settings['plugin_comments_seo']['seo']) { @@ -552,7 +564,7 @@ function fb_social_preset_view($preset) { module_load_include('inc', 'fb_social', 'plugins/fb_plugin/comments'); $output .= _fb_social_comments_seo($url, $nr_comments, $cache_length); } - + return $output; } @@ -560,12 +572,12 @@ function fb_social_preset_view($preset) { * returns the fbml content of the plugin */ function fb_social_box_view($box) { - + $plugin_type = $box->fb_plugin_name; $options = $box->options; - + $output = theme('fb_social_plugin', array('plugin_type' => $plugin_type, 'options' => $options)); - + if ($plugin_type == 'comments') { $cache_length = 720; $nr_comments = 100; @@ -573,7 +585,7 @@ function fb_social_box_view($box) { module_load_include('inc', 'fb_social', 'plugins/fb_plugin/comments'); $output .= _fb_social_comments_seo($url, $nr_comments, $cache_length); } - + return $output; } @@ -582,14 +594,14 @@ function fb_social_box_view($box) { */ function fb_social_page_alter(&$page) { global $language, $_fb_script_init, $base_url; - + // If their is no fb plugin enabled on this page, do not load fb script then if (! $_fb_script_init) { return; } - + $languages = _map_active_languages(); - + if (fb_social_auto_language()) { if (array_key_exists($language->language, $languages)) { $fb_locale = $languages[$language->language]; @@ -601,10 +613,10 @@ function fb_social_page_alter(&$page) { else { $fb_locale = variable_get('fb_social_locale', 'en_US'); } - + $appid = variable_get('fb_social_appid', ''); $channel_url = $base_url . "/fb_social/channel"; - + $output = '
'; $output .= "