View source
<?php
class ShareaholicAdmin {
public static function draw_modal_popup() {
if (!ShareaholicUtilities::has_accepted_terms_of_service()) {
self::draw_tos_popup();
}
else {
if (!ShareaholicUtilities::get_option('api_key')) {
self::draw_failure_popup();
}
}
}
public static function draw_tos_popup() {
$form = drupal_get_form('shareaholic_tos_modal_form');
print drupal_render($form);
}
public static function draw_failure_popup() {
$form = drupal_get_form('shareaholic_failure_modal_form');
print drupal_render($form);
}
public static function show_terms_of_service_notice(&$vars) {
if (ShareaholicUtilities::is_admin_page() && !ShareaholicUtilities::is_shareaholic_settings_page() && !ShareaholicUtilities::has_accepted_terms_of_service() && user_access('administer modules')) {
$link = l('Get started now >>', 'admin/config/shareaholic/settings', array(
'attributes' => array(
'style' => 'background: #f3f3f3; border-color: #bbb; color: #333; display: inline-block; text-decoration: none; cursor: pointer; border-radius: 3px; padding: 0 10px; 1px; font-size: 12px; height: 20px;',
),
));
$message = sprintf(t('Action required: You\'ve installed Shareaholic for Drupal. We\'re ready when you are. %s'), $link);
$vars['page'] = self::header_message_html($message) . $vars['page'];
}
}
public static function show_pending_update_notice(&$vars) {
if (ShareaholicUtilities::is_admin_page() && ShareaholicUtilities::has_accepted_terms_of_service() && !db_table_exists('shareaholic_content_settings') && user_access('administer modules')) {
$message = sprintf(t('Action required: You have pending updates required by Shareaholic. Please go to update.php for more information.'));
$vars['page'] = self::header_message_html($message) . $vars['page'];
}
}
private static function header_message_html($message) {
$img_check = SHAREAHOLIC_ASSET_DIR . '/img/check.png';
$html = <<<DOC
<div id="shareaholic-wrap-container" style="padding: 0 20px 0px 15px; background-color: #45a147; margin: 25px 0px 20px -18px;">
<img src="{<span class="php-variable">$img_check</span>}" style="vertical-align:middle;" />
<span id="shareaholic-text-container" style="color: #fff; text-shadow: 0px 1px 1px rgba(0,0,0,0.4); font-size: 14px; vertical-align:middle;">
<strong>{<span class="php-variable">$message</span>}</strong>
</span>
</div>
<div style="clear:both;"></div>
DOC;
return $html;
}
public static function include_css_js_assets() {
$module_path = drupal_get_path('module', 'shareaholic');
drupal_add_css('//fonts.googleapis.com/css?family=Open+Sans:400,300,700', array(
'type' => 'external',
'group' => CSS_DEFAULT,
));
drupal_add_css($module_path . '/assets/css/bootstrap.css', array(
'group' => CSS_DEFAULT,
));
drupal_add_css($module_path . '/assets/css/bootstrap-responsive.css', array(
'group' => CSS_DEFAULT,
));
drupal_add_css($module_path . '/assets/css/reveal.css', array(
'group' => CSS_DEFAULT,
));
drupal_add_css($module_path . '/assets/css/main.css', array(
'group' => CSS_DEFAULT,
));
drupal_add_js(ShareaholicUtilities::asset_url('assets/pub/utilities.js'), array(
'type' => 'external',
'group' => JS_DEFAULT,
));
drupal_add_js(ShareaholicUtilities::asset_url('assets/pub/shareaholic_sdk.js'), array(
'type' => 'external',
'group' => JS_DEFAULT,
));
drupal_add_js($module_path . '/assets/js/jquery_custom.js', array(
'group' => JS_DEFAULT,
));
drupal_add_js($module_path . '/assets/js/jquery_ui_custom.js', array(
'group' => JS_DEFAULT,
));
drupal_add_js($module_path . '/assets/js/jquery.reveal.modified.js', array(
'group' => JS_DEFAULT,
));
drupal_add_js($module_path . '/assets/js/bootstrap.js', array(
'group' => JS_DEFAULT,
));
drupal_add_js($module_path . '/assets/js/main.js', array(
'group' => JS_DEFAULT,
));
}
public static function draw_verify_api_key() {
if (!ShareaholicUtilities::api_key_verified()) {
print theme('shareaholic_verify_api_key');
}
}
public static function update_check() {
$version = ShareaholicUtilities::get_option('version');
if (ShareaholicUtilities::get_option('api_key') && $version != ShareaholicUtilities::get_version()) {
ShareaholicUtilities::set_version(ShareaholicUtilities::get_version());
ShareaholicUtilities::log_event('Upgrade', array(
'previous_plugin_version' => $version,
));
}
}
public static function include_snapengage() {
ShareaholicUtilities::load_template('script_chat');
}
public static function post_install() {
if (variable_get('Installed_Module_Shareaholic', '') == 'shareaholic') {
variable_del('Installed_Module_Shareaholic');
ShareaholicUtilities::share_counts_api_connectivity_check();
}
}
public static function show_footer() {
ShareaholicUtilities::load_template('footer');
}
public static function show_header() {
$settings = ShareaholicUtilities::get_settings();
$settings['base_link'] = ShareaholicUtilities::URL . '/publisher_tools/' . $settings['api_key'] . '/';
$settings['website_settings_link'] = $settings['base_link'] . 'websites/edit?verification_key=' . $settings['verification_key'];
ShareaholicUtilities::load_template('header', array(
'settings' => $settings,
));
}
}