You are here

function shariff_sharing_buttons_content_type_edit_form in Shariff Social Media Buttons 7

Form constructor for the content type edit form.

See also

shariff_sharing_buttons_content_type_edit_form_validate()

shariff_sharing_buttons_content_type_edit_form_submit()

File

plugins/content_types/sharing_buttons.inc, line 89

Code

function shariff_sharing_buttons_content_type_edit_form($form, &$form_state) {
  $conf = $form_state['conf'];
  $form['default_settings'] = array(
    '#title' => t('Use Shariff default settings?'),
    '#description' => t('When set default Shariff settings are used. Uncheck to overwrite settings here.'),
    '#type' => 'checkbox',
    '#checked' => TRUE,
    '#default_value' => !isset($conf['default_settings']) ? TRUE : $conf['default_settings'],
  );
  $form['services'] = array(
    '#title' => t('Activated services'),
    '#description' => t('Please define for which services a sharing button should be included.'),
    '#type' => 'checkboxes',
    '#options' => array(
      'twitter' => t('Twitter'),
      'facebook' => t('Facebook'),
      'googleplus' => t('Google+'),
      'linkedin' => t('LinkedIn'),
      'pinterest' => t('Pinterest'),
      'xing' => t('Xing'),
      'whatsapp' => t('WhatsApp'),
      'addthis' => t('AddThis'),
      'tumblr' => t('Tumblr'),
      'flattr' => t('Flattr'),
      'diaspora' => t('Diaspora'),
      'reddit' => t('reddit'),
      'stumbleupon' => t('StumbleUpon'),
      'threema' => t('Threema'),
      'weibo' => t('Weibo'),
      'tencent-weibo' => t('Tencent-Weibo'),
      'qzone' => t('Qzone'),
      'mail' => t('E-Mail'),
      'info' => t('Info Button'),
    ),
    '#states' => array(
      'visible' => array(
        ':input[name="default_settings"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
    '#default_value' => !isset($conf['services']) ? array(
      'twitter',
      'facebook',
    ) : $conf['services'],
  );
  $form['theme'] = array(
    '#title' => t('Theme'),
    '#description' => t('Please choose a layout option.'),
    '#type' => 'radios',
    '#options' => array(
      'colored' => t('Colored'),
      'grey' => t('Grey'),
      'white' => t('White'),
    ),
    '#states' => array(
      'visible' => array(
        ':input[name="default_settings"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
    '#default_value' => !isset($conf['theme']) ? 'colored' : $conf['theme'],
  );
  $form['orientation'] = array(
    '#title' => t('Orientation'),
    '#description' => t('Vertical will stack the buttons vertically. Default is horizontally.'),
    '#type' => 'radios',
    '#options' => array(
      'vertical' => t('Vertical'),
      'horizontal' => t('Horizontal'),
    ),
    '#states' => array(
      'visible' => array(
        ':input[name="default_settings"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
    '#default_value' => !isset($conf['orientation']) ? 'horizontal' : $conf['orientation'],
  );
  $form['twitter_via'] = array(
    '#title' => t('Twitter Via User'),
    '#description' => t('Screen name of the Twitter user to attribute the Tweets to.'),
    '#type' => 'textfield',
    '#default_value' => !isset($conf['twitter_via']) ? '' : $conf['twitter_via'],
    '#states' => array(
      'visible' => array(
        ':input[name="default_settings"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['url'] = array(
    '#title' => t('Share URL'),
    '#description' => t('The canonical URL of the page to share. Leave blank to use the URL from the page where the button is displayed (or og:url).'),
    '#type' => 'textfield',
    '#default_value' => !isset($conf['url']) ? '' : $conf['url'],
    '#states' => array(
      'visible' => array(
        ':input[name="default_settings"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['mail_url'] = array(
    '#title' => t('Mail link'),
    '#description' => t('The url target used for the mail service button. Leave it as "mailto:" to let the user
 choose an email address.'),
    '#type' => 'textfield',
    '#default_value' => !isset($conf['mail_url']) ? 'mailto:' : $conf['mail_url'],
    '#states' => array(
      'visible' => array(
        ':input[name="default_settings"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['mail_subject'] = array(
    '#title' => t('Mail subject'),
    '#description' => t("If a mailto: link is provided in Mail link above, then this value is used as the mail subject.\n You can add context specific substitutions like %node:title if given. Left empty the page's current (canonical) URL or og:url is used."),
    '#type' => 'textfield',
    '#default_value' => !isset($conf['mail_subject']) ? '' : $conf['mail_subject'],
    '#states' => array(
      'visible' => array(
        ':input[name="default_settings"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['mail_body'] = array(
    '#title' => t('Mail body'),
    '#description' => t("If a mailto: link is provided in Mail link above, then this value is used as the mail body.\n You can add context specific substitutions like %node:title if given. Left empty the page title is used."),
    '#type' => 'textarea',
    '#default_value' => !isset($conf['mail_body']) ? '' : $conf['mail_body'],
    '#states' => array(
      'visible' => array(
        ':input[name="default_settings"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['referrer_track'] = array(
    '#title' => t('Referrer track code'),
    '#description' => t('A string that will be appended to the share url. Disabled when empty.'),
    '#type' => 'textfield',
    '#default_value' => !isset($conf['referrer_track']) ? '' : $conf['referrer_track'],
    '#states' => array(
      'visible' => array(
        ':input[name="default_settings"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['backend_url'] = array(
    '#title' => t('Backend URL'),
    '#description' => t('The path to your Shariff backend. Leaving the value blank disables the backend feature and no counts will occur.'),
    '#type' => 'textfield',
    '#states' => array(
      'visible' => array(
        ':input[name="default_settings"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
    '#default_value' => !isset($conf['backend_url']) ? '' : $conf['backend_url'],
  );
  $form['flattr_category'] = array(
    '#title' => t('Flattr category'),
    '#description' => t('Category to be used for Flattr.'),
    '#type' => 'textfield',
    '#states' => array(
      'visible' => array(
        ':input[name="default_settings"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
    '#default_value' => !isset($conf['flattr_category']) ? '' : $conf['flattr_category'],
  );
  $form['flattr_user'] = array(
    '#title' => t('Flattr user'),
    '#description' => t('User that receives Flattr donation.'),
    '#type' => 'textfield',
    '#states' => array(
      'visible' => array(
        ':input[name="default_settings"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
    '#default_value' => !isset($conf['flattr_user']) ? '' : $conf['flattr_user'],
  );
  $form['media_url'] = array(
    '#title' => t('Media url'),
    '#description' => t('Media url to be shared (Pinterest). You can add context specific substitutions.'),
    '#type' => 'textfield',
    '#states' => array(
      'visible' => array(
        ':input[name="default_settings"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
    '#default_value' => !isset($conf['media_url']) ? '' : $conf['media_url'],
  );
  return $form;
}