/**
  * Builds the html body for the tinymce popup
  *
  * @access private
  * @return string Popup body
  */
 function render_tinymce_popup_body()
 {
     require_once 'AuthorAvatarsForm.class.php';
     $form = new AuthorAvatarsForm();
     // BASIC TAB
     $basic_left = $form->renderFieldShortcodeType();
     $basic_left .= '<div class="fields_type_show_avatar">';
     $basic_left .= $form->renderFieldUsers();
     $basic_left .= $form->renderFieldEmail();
     $basic_left .= $form->renderFieldAlignment();
     $basic_left .= $form->renderFieldDisplayOptions();
     $basic_left .= $form->renderFieldUserLink('');
     $basic_left .= '</div>';
     $basic_left .= '<div class="fields_type_authoravatars">';
     $basic_left .= $form->renderFieldRoles(array('administrator', 'editor'));
     $basic_left .= $form->renderFieldDisplayOptions();
     $basic_left .= $form->renderFieldUserLink('authorpage');
     $basic_left .= '</div>';
     $basic_right = $form->renderFieldAvatarSize();
     $basic_right .= $form->renderFieldMaxBioLength();
     $basic_tab = $form->renderTabStart(__('Basic', 'author-avatars'));
     $basic_tab .= $form->renderColumns($basic_left, $basic_right);
     $basic_tab .= $form->renderTabEnd();
     // ADVANCED TAB
     $adv_left = $form->renderFieldOrder('display_name');
     $adv_left .= $form->renderFieldSortDirection('asc');
     $adv_left .= $form->renderFieldLimit();
     $adv_left .= $form->renderPageLimit();
     $adv_left .= $form->renderFieldMinPostCount();
     $adv_left .= $form->renderFieldHiddenUsers();
     $adv_right = '';
     if (AA_is_wpmu()) {
         global $blog_id;
         // default value: current blog
         $adv_right .= $form->renderFieldBlogs($blog_id);
     }
     $adv_right .= $form->renderFieldGroupBy();
     $advanced_tab = $form->renderTabStart(__('Advanced', 'author-avatars'));
     $advanced_tab .= $form->renderColumns($adv_left, $adv_right);
     $advanced_tab .= $form->renderTabEnd();
     $tabs = $basic_tab . $advanced_tab;
     $html = '<div class="aa-tabs">' . $form->renderTabList() . $tabs . '</div>';
     $html .= "\n\t" . '<div class="mceActionPanel"> ' . AA_donateButton();
     $html .= "\n\t" . '<div style="float: left">';
     $html .= "\n\t" . '<input type="button" id="cancel" name="cancel" value="' . __("Cancel") . '" onclick="tinyMCEPopup.close();" />';
     $html .= "\n\t" . '</div>';
     $html .= "\n\t" . '<div style="float: right">';
     $html .= "\n\t" . '<input type="submit" id="insert" name="insert" value="' . __("Insert") . '" onclick="insertAuthorAvatarsCode();" />';
     $html .= "\n\t" . '</div>';
     $html .= "\n\t" . '</div>';
     echo '<body class="tinymce_popup">' . $html . "\n" . '</body>';
 }
 /**
  * Builds the widget control form.
  *
  * @access protected
  *
  * @param $instance Array of widget options. If empty then we're creating a new widget.
  *
  * @return void
  */
 function form($instance)
 {
     $instance = array_merge($this->defaults, $instance);
     require_once 'AuthorAvatarsForm.class.php';
     $form = new AuthorAvatarsForm();
     $form->setFieldIdCallback(array($this, 'get_field_id'));
     $form->setFieldNameCallback(array($this, 'get_field_name'));
     // widget title
     $widget_title = '<p>' . FormHelper::input('text', $this->get_field_name('title'), $instance['title'], array('label' => '<strong>' . __('Title', 'author-avatars') . ':</strong> ', 'class' => 'widefat', 'id' => $this->get_field_id('title'))) . '</p>';
     // BASIC TAB
     $basic_left = $widget_title;
     $basic_left .= $form->renderFieldRoles($instance['roles']);
     $basic_left .= $form->renderFieldUserLink($instance['display']['user_link'], 'display][user_link');
     $basic_right = $form->renderFieldDisplayOptions($instance['display']);
     $basic_right .= $form->renderFieldAvatarSize($instance['display']['avatar_size'], 'display][avatar_size');
     $basic_right .= '<div class="avatar_donate">' . AA_donateButton('link') . '</div>';
     $basic = '<h5>' . __('Basic', 'author-avatars') . '</h5>';
     $basic .= $form->renderColumns($basic_left, $basic_right);
     // ADVANCED TAB
     $adv_left = $form->renderFieldOrder($instance['display']['order'], 'display][order');
     $adv_left .= $form->renderFieldSortDirection($instance['display']['sort_direction'], 'display][sort_direction');
     $adv_left .= $form->renderFieldLimit($instance['display']['limit'], 'display][limit');
     $adv_left .= $form->renderFieldMinPostCount($instance['display']['min_post_count'], 'display][min_post_count');
     $adv_left .= $form->renderFieldHiddenUsers($instance['hiddenusers']);
     $adv_right = "";
     // incase we don't have any blogs
     if (AA_is_wpmu() && !empty($instance['blogs'])) {
         $adv_right .= $form->renderFieldBlogs($instance['blogs']);
     }
     $adv_right .= $form->renderFieldGroupBy($instance['group_by']);
     $advanced = '<h5>' . __('Advanced', 'author-avatars') . '</h5>';
     $advanced .= $form->renderColumns($adv_left, $adv_right);
     echo '<div class="aa-widget-control-panel">' . $basic . $advanced . '</div>';
     // hidden "submit=1" field (do we still need this?, FIXME)
     echo FormHelper::input('hidden', $this->get_field_name('submit'), '1', array('id' => $this->get_field_id('submit')));
 }