diff --git plugins/twitter_pull_box.inc plugins/twitter_pull_box.inc new file mode 100755 index 0000000..8cf8d60 --- /dev/null +++ plugins/twitter_pull_box.inc @@ -0,0 +1,54 @@ +'', + 'search' => '', + 'max_results' => 20, + 'additional_classes' => '', + ); + } + + /** + * Implementation of boxes_box::options_form(). + */ + public function options_form(&$form_state) { + $form = array(); + + $form['search'] = array( + '#type' => 'textfield', + '#title' => t('Twitter Search'), + '#required' => TRUE, + '#default_value' => $this->options['search'], + '#description' => t('The twitter user or hashtag to build this box off of.'), + ); + $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.'), + ); + return $form; + } + + /** + * Implementation of boxes_box::render(). + */ + public function render() { + $content = twitter_pull_render($this->options['search'], NULL, $this->options['max_results']); + $title = isset($this->title) ? check_plain($this->title) : NULL; + return array( + 'delta' => $this->delta, // Crucial. + 'title' => $title, + 'subject' => $title, + 'content' => $content, + ); + } +} diff --git twitter_pull.info twitter_pull.info index 261e07e..28c18ca 100644 --- twitter_pull.info +++ twitter_pull.info @@ -4,4 +4,5 @@ package = Other core = 7.x files[] = twitter_pull.module files[] = twitter_pull.install +files[] = plugins/twitter_pull_box.inc files[] = twitter_pull.class.inc diff --git twitter_pull.module twitter_pull.module index 5e326f3..9023860 100644 --- twitter_pull.module +++ twitter_pull.module @@ -208,5 +208,33 @@ function twitter_pull_block_data() { return $data; } +/** + * Implements hook_ctools_plugin_api(). + */ +function twitter_pull_ctools_plugin_api($module, $api) { + if ($module == 'boxes' && $api == 'plugins') { + return array('version' => 1); + } +} + +/** + * Implements hook_boxes_plugins(). + */ +function twitter_pull_boxes_plugins() { + $info = array(); + $path = drupal_get_path('module', 'twitter_pull') . '/plugins'; + $info['twitter'] = array( + 'title' => 'Twitter Box', + 'handler' => array( + 'parent' => 'box', + 'class' => 'twitter_pull_box', + 'file' => 'twitter_pull_box.inc', + 'path' => $path, + ), + ); + return $info; +} + +