You are here

function theme_web_widgets_embed_code in Web Widgets 7

Same name and namespace in other branches
  1. 6 web_widgets.module \theme_web_widgets_embed_code()

Shows the widget code to the user. Usually appears when the widget display is attached to a page display. In most cases you don't want to call this function directly, but use web_widgets_render_embed_code() to render embed code.

Parameters

$code: The code that can be copy/pasted from this site to another site.

$style: The embed style of the widget.

Return value

HTML that displays the widget embed code.

1 theme call to theme_web_widgets_embed_code()
web_widgets_render_embed_code in ./web_widgets.module
Renders the embed code for a given widget style.

File

./web_widgets.module, line 188
web_widgets module main. Contains the views api hook and theming functions.

Code

function theme_web_widgets_embed_code($variables) {
  $code = $variables['code'];
  $style = $variables['style'];
  $styles = web_widgets_get_styles();
  $style_name = $styles[$style];
  static $num = 0;
  $form = array(
    '#type' => 'textarea',
    '#title' => t('Embed code'),
    '#description' => t('Copy and paste this code to your website.'),
    '#id' => 'web_widgets_' . $num++,
    '#name' => 'web_widgets',
    '#value' => $code,
    '#parents' => array(
      'none',
    ),
    '#maxlength' => FALSE,
    '#attributes' => array(
      'onclick' => 'this.focus(); this.select();',
    ),
    '#cols' => 30,
    '#rows' => 5,
  );
  if ($style == 'uwa') {
    $form['#type'] = 'item';
    $form['#value'] = l($code, $code);
    $form['#title'] = t('@style widget', array(
      '@style' => $style_name,
    ));
    $form['#description'] = t('Embed your widget on NetVibes or iGoogle.');
  }
  else {
    if ($style == 'google_gadget') {
      $form['#title'] = t('@style widget', array(
        '@style' => $style_name,
      ));
      $form['#description'] = t('Copy and paste this code to your iGoogle page.');
    }
  }
  return drupal_render($form);
}