/**
 * Submit handler for the shareaholic_apps_configuration form
 * When submitted, update the location settings
 *
 */
function shareaholic_apps_configuration_form_submit($form, &$form_state)
{
    $settings = ShareaholicUtilities::get_settings();
    if (empty($settings['recommendations']) || empty($settings['share_buttons'])) {
        return;
    }
    $form_input = $form_state['input'];
    $page_types = ShareaholicUtilities::page_types();
    foreach ($page_types as $key => $page_type) {
        foreach (array('share_buttons', 'recommendations') as $app) {
            foreach (array('above', 'below') as $location) {
                $location_name = "{$page_type->type}_{$location}_content";
                if ($location === 'above' && $app === 'recommendations') {
                    continue;
                }
                if (!isset($form_input[$app][$location_name]) || !isset($form_input[$app]["{$location_name}_location_id"]) || $form_input[$app][$location_name] !== 'on') {
                    $settings[$app][$location_name] = 'off';
                } else {
                    $settings[$app][$location_name] = 'on';
                    $settings['location_name_ids'][$app][$location_name] = $form_input[$app]["{$location_name}_location_id"];
                }
            }
        }
    }
    ShareaholicUtilities::set_settings($settings);
    ShareaholicUtilities::log_event('UpdatedSettings');
    drupal_set_message(t('Shareaholic Settings Saved'), 'status');
}
Esempio n. 2
0
 function get_shr_like_buttonset($position)
 {
     $trace = debug_backtrace();
     $deprecation = new ShareaholicDeprecation('get_shr_like_buttonset');
     $deprecation->push($trace[0]['file'], $trace[0]['line']);
     $settings = ShareaholicUtilities::get_settings();
     $page_type = ShareaholicUtilities::page_type();
     switch ($position) {
         case 'Top':
             $id = isset($settings['location_name_ids']["{$page_type}_above_content"]) ? $settings['location_name_ids']["{$page_type}_above_content"] : NULL;
             break;
         case 'Bottom':
             $id = isset($settings['location_name_ids']["{$page_type}_below_content"]) ? $settings['location_name_ids']["{$page_type}_below_content"] : NULL;
             break;
     }
     echo ShareaholicPublic::canvas($id, 'share_buttons');
 }
Esempio n. 3
0
 /**
  * This static function inserts the shareaholic canvas at the end of the post
  *
  * @param  string $content the wordpress content
  * @return string          the content
  */
 public static function draw_canvases($content)
 {
     global $post;
     $settings = ShareaholicUtilities::get_settings();
     $page_type = ShareaholicUtilities::page_type();
     foreach (array('share_buttons', 'recommendations') as $app) {
         if (!get_post_meta($post->ID, "shareaholic_disable_{$app}", true)) {
             if (isset($settings[$app]["{$page_type}_above_content"]) && $settings[$app]["{$page_type}_above_content"] == 'on') {
                 // share_buttons_post_above_content
                 $id = $settings['location_name_ids'][$app]["{$page_type}_above_content"];
                 $content = self::canvas($id, $app) . $content;
             }
             if (isset($settings[$app]["{$page_type}_below_content"]) && $settings[$app]["{$page_type}_below_content"] == 'on') {
                 // share_buttons_post_below_content
                 $id = $settings['location_name_ids'][$app]["{$page_type}_below_content"];
                 $content .= self::canvas($id, $app);
             }
         }
     }
     // something that uses the_content hook must return the $content
     return $content;
 }
Esempio n. 4
0
 /**
  * This static function inserts the shareaholic canvas in a node
  *
  * @param  string $node The node object to insert the canvas into
  */
 public static function draw_canvases(&$node, $view_mode)
 {
     $settings = ShareaholicUtilities::get_settings();
     $page_type = $node->type;
     $sb_above_weight = -1000;
     $rec_above_weight = -999;
     $sb_below_weight = 1000;
     $rec_below_weight = 1001;
     if ($view_mode === 'teaser') {
         $page_type = 'teaser';
     }
     foreach (array('share_buttons', 'recommendations') as $app) {
         if (isset($node->shareaholic_options["shareaholic_hide_{$app}"]) && $node->shareaholic_options["shareaholic_hide_{$app}"]) {
             continue;
         }
         $title = $node->title;
         $summary = isset($node->teaser) ? $node->teaser : '';
         $link = url('node/' . $node->nid, array('absolute' => TRUE));
         if (isset($settings[$app]["{$page_type}_above_content"]) && $settings[$app]["{$page_type}_above_content"] == 'on') {
             $id = $settings['location_name_ids'][$app]["{$page_type}_above_content"];
             $node->content["shareaholic_{$app}_{$page_type}_above_content"] = array('#markup' => self::canvas($id, $app, $title, $link), '#weight' => $app === 'share_buttons' ? $sb_above_weight : $rec_above_weight);
         }
         if (isset($settings[$app]["{$page_type}_below_content"]) && $settings[$app]["{$page_type}_below_content"] == 'on') {
             $id = $settings['location_name_ids'][$app]["{$page_type}_below_content"];
             $node->content["shareaholic_{$app}_{$page_type}_below_content"] = array('#markup' => self::canvas($id, $app, $title, $link), '#weight' => $app === 'share_buttons' ? $sb_below_weight : $rec_below_weight);
         }
     }
 }
Esempio n. 5
0
 /**
  * Answers whether we should ping CM
  *
  * @return bool
  */
 public static function should_notify_cm()
 {
     $settings = ShareaholicUtilities::get_settings();
     $recommendations_settings = isset($settings['recommendations']) ? $settings["recommendations"] : null;
     if (is_array($recommendations_settings)) {
         if (in_array("on", $recommendations_settings)) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Esempio n. 6
0
 /**
  * This function is in charge the logic for
  * showing whatever it is we want to show a user
  * about whether they have verified their api
  * key or not.
  */
 private static function draw_verify_api_key()
 {
     if (!ShareaholicUtilities::api_key_verified()) {
         $settings = ShareaholicUtilities::get_settings();
         $api_key = $settings['api_key'];
         $verification_key = $settings['verification_key'];
         ShareaholicUtilities::load_template('verify_api_key_js', array('verification_key' => $verification_key));
     }
 }
 /**
  *
  */
 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));
 }
<div id='app_settings'>
  <?php 
$page_types = ShareaholicUtilities::page_types();
?>
  <?php 
$settings = ShareaholicUtilities::get_settings();
?>

  <fieldset class="app">
    <legend><h2><i class="icon icon-recommendations"></i><?php 
print t('Related & Promoted Content');
?>
</h2></legend>

    <span class="helper"><i class="icon-star"></i> <?php 
print t('Pick where you want Related Content to be displayed. Click "Customize" to customize look & feel, themes, block lists, etc.');
?>
</span>
    <?php 
foreach ($page_types as $key => $page_type) {
    ?>
      <?php 
    if (isset($settings['location_name_ids']['recommendations']["{$page_type->type}_below_content"])) {
        ?>
        <?php 
        $location_id = $settings['location_name_ids']['recommendations']["{$page_type->type}_below_content"];
        ?>
      <?php 
    } else {
        $location_id = '';
    }