View source
<?php
define('SHAREAHOLIC_DIR', drupal_get_path('module', 'shareaholic'));
define('SHAREAHOLIC_ASSET_DIR', $GLOBALS['base_url'] . '/' . SHAREAHOLIC_DIR . '/assets/');
define('SHAREAHOLIC_DEBUG', getenv('SHAREAHOLIC_DEBUG'));
if (!defined('SHARE_COUNTS_CHECK_CACHE_LENGTH')) {
define('SHARE_COUNTS_CHECK_CACHE_LENGTH', 180);
}
module_load_include('php', 'shareaholic', 'utilities');
module_load_include('php', 'shareaholic', 'admin');
module_load_include('php', 'shareaholic', 'public');
module_load_include('php', 'shareaholic', 'content_manager');
module_load_include('php', 'shareaholic', 'content_settings');
module_load_include('php', 'shareaholic', 'cache');
module_load_include('php', 'shareaholic', 'includes/node');
module_load_include('php', 'shareaholic', 'includes/shareaholic_tos_modal');
module_load_include('php', 'shareaholic', 'includes/shareaholic_failure_modal');
module_load_include('php', 'shareaholic', 'includes/shareaholic_advanced_settings_form');
module_load_include('php', 'shareaholic', 'includes/shareaholic_reset_plugin_form');
module_load_include('php', 'shareaholic', 'includes/shareaholic_apps_configuration_form');
function shareaholic_init() {
ShareaholicPublic::set_xua_compatible_header();
if (!ShareaholicUtilities::is_admin_page()) {
ShareaholicPublic::insert_dns_snippet();
ShareaholicPublic::insert_content_meta_tags();
ShareaholicPublic::insert_script_tag();
ShareaholicPublic::insert_og_tags();
}
else {
ShareaholicAdmin::post_install();
}
}
function shareaholic_menu() {
$menu['admin/config/shareaholic'] = array(
'title' => 'Shareaholic',
'description' => 'Shareaholic Module Settings',
'weight' => 1,
'page callback' => 'system_admin_menu_block_page',
'access arguments' => array(
'access administration pages',
),
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system'),
'position' => 'left',
);
$menu['admin/config/shareaholic/advanced'] = array(
'title' => 'Shareaholic Advanced Settings',
'description' => 'Advanced settings for the Shareaholic module',
'page callback' => 'shareaholic_admin_advanced',
'access arguments' => array(
'administer site configuration',
),
'type' => MENU_NORMAL_ITEM,
'weight' => 2,
);
$menu['admin/config/shareaholic/settings'] = array(
'title' => 'Shareaholic App Manager',
'description' => 'Manage various Social Tools like Share Buttons and Related Posts',
'page callback' => 'shareaholic_admin_settings',
'access arguments' => array(
'administer site configuration',
),
'type' => MENU_NORMAL_ITEM,
'weight' => 1,
);
$menu['shareaholic/api/share_counts/v1'] = array(
'page callback' => 'shareaholic_share_counts_api',
'type' => MENU_CALLBACK,
'access callback' => TRUE,
);
return $menu;
}
function shareaholic_admin_advanced() {
ShareaholicAdmin::update_check();
return theme('shareaholic_admin_advanced');
}
function shareaholic_admin_settings() {
ShareaholicAdmin::update_check();
ShareaholicUtilities::share_counts_api_connectivity_check();
return theme('shareaholic_admin_settings');
}
function shareaholic_theme() {
return array(
'shareaholic_admin_advanced' => array(
'path' => SHAREAHOLIC_DIR . '/templates',
'template' => 'shareaholic_admin_advanced',
),
'shareaholic_admin_settings' => array(
'path' => SHAREAHOLIC_DIR . '/templates',
'template' => 'shareaholic_admin_settings',
),
'shareaholic_tos_modal' => array(
'render element' => 'form',
'path' => SHAREAHOLIC_DIR . '/templates',
'template' => 'shareaholic_tos_modal',
),
'shareaholic_failure_modal' => array(
'render element' => 'form',
'path' => SHAREAHOLIC_DIR . '/templates',
'template' => 'shareaholic_failure_modal',
),
'shareaholic_apps_configuration' => array(
'render element' => 'form',
'path' => SHAREAHOLIC_DIR . '/templates',
'template' => 'shareaholic_apps_configuration',
),
'shareaholic_verify_api_key' => array(
'path' => SHAREAHOLIC_DIR . '/templates',
'template' => 'shareaholic_verify_api_key',
),
);
}
function shareaholic_process_html(&$vars) {
ShareaholicAdmin::show_terms_of_service_notice($vars);
ShareaholicAdmin::show_pending_update_notice($vars);
}
function _prepare_template_form_variables(&$variables, $form_id) {
$variables[$form_id] = array();
$hidden = array();
foreach (element_children($variables['form']) as $key) {
$type = $variables['form'][$key]['#type'];
if ($type == 'hidden' || $type == 'token') {
$hidden[] = drupal_render($variables['form'][$key]);
}
else {
$variables[$form_id][$key] = drupal_render($variables['form'][$key]);
}
}
$variables[$form_id]['hidden'] = implode($hidden);
}
function shareaholic_share_counts_api() {
ShareaholicPublic::share_counts_api();
}