/**
  * 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')));
 }