コード例 #1
0
/**
 * 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');
}
コード例 #2
0
<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 = '';
    }