You are here

class twitter_pull_box in Twitter Pull 6.2

Same name and namespace in other branches
  1. 7.2 plugins/twitter_pull_box.inc \twitter_pull_box
  2. 7 plugins/twitter_pull_box.inc \twitter_pull_box

Simple custom text box.

Hierarchy

Expanded class hierarchy of twitter_pull_box

1 string reference to 'twitter_pull_box'
twitter_pull_boxes_plugins in ./twitter_pull.module
Implements hook_boxes_plugins().

File

plugins/twitter_pull_box.inc, line 6

View source
class twitter_pull_box extends boxes_box {

  /**
   * Implementation of boxes_box::options_defaults().
   */
  public function options_defaults() {
    return array(
      'title' => '',
      'search' => '',
      'max_results' => 20,
      'additional_classes' => '',
      'rts' => TRUE,
      'exclude_replies' => FALSE,
    );
  }

  /**
   * Implementation of boxes_box::options_form().
   */
  public function options_form() {
    $form = array();
    $form['search'] = array(
      '#type' => 'textfield',
      '#title' => t('Twitter search'),
      '#required' => TRUE,
      '#default_value' => $this->options['search'],
      '#description' => t("The twitter user, hashtag, or search for the tweet to show in this box. Use a '@' for a user or a list, eg '@user', '@user/list'; a '#' for a hashtag, 'eg '#hashtag'; and no prefix for a search."),
    );
    $form['max_results'] = array(
      '#type' => 'textfield',
      '#title' => t('Max tweets'),
      '#default_value' => $this->options['max_results'],
      '#description' => t('How many tweets you want the box to display at any one time.'),
    );
    $form['rts'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable retweets'),
      '#default_value' => $this->options['rts'],
      '#description' => t('If selected, retweets are included in the twitter feed. See the Twitter API for more details.'),
    );
    $form['exclude_replies'] = array(
      '#type' => 'checkbox',
      '#title' => t('Exclude replies'),
      '#default_value' => $this->options['exclude_replies'],
      '#description' => t('If selected, replies are not included in the twitter feed. See the Twitter API for more details.'),
    );
    return $form;
  }

  /**
   * Implementation of boxes_box::render().
   */
  public function render() {
    $content = twitter_pull_render($this->options['search'], NULL, $this->options['max_results'], NULL, $this->options['rts'], $this->options['exclude_replies']);
    $title = isset($this->title) ? check_plain($this->title) : NULL;
    return array(
      'delta' => $this->delta,
      // Crucial.
      'title' => $title,
      'subject' => $title,
      'content' => $content,
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
boxes_box::$boxes static property
boxes_box::$delta public property
boxes_box::$description public property
boxes_box::$export_type public property
boxes_box::$new public property
boxes_box::$options public property
boxes_box::$plugin_key public property
boxes_box::$title public property
boxes_box::delete public function Delete a box.
boxes_box::factory public static function Instantiate, populate and return a box object.
boxes_box::load public static function Load existing box by its unique identifier $delta.
boxes_box::reset public static function Reset the boxes cache.
boxes_box::save public function Save a box.
boxes_box::__construct protected function Create a new box.
twitter_pull_box::options_defaults public function Implementation of boxes_box::options_defaults(). Overrides boxes_box::options_defaults
twitter_pull_box::options_form public function Implementation of boxes_box::options_form(). Overrides boxes_box::options_form
twitter_pull_box::render public function Implementation of boxes_box::render(). Overrides boxes_box::render