diff --git export/views_bonus_export.module export/views_bonus_export.module index 388ca54..38b8905 100644 --- export/views_bonus_export.module +++ export/views_bonus_export.module @@ -13,3 +13,45 @@ function views_bonus_export_views_api() { 'api' => 2, ); } + +/** + * Implementation of hook_theme(). + */ +function views_bonus_export_theme() { + return array( + 'views_bonus_export_feed_icon' => array( + 'pattern' => 'views_bonus_export_feed_icon__', + 'arguments' => array('image_path', 'url', 'query'), + ), + ); +} + +/** + * Theme a feed link. + * + * This theme function uses the theme pattern system to allow it to be + * overidden in a more specific manner. The options for overiding this include + * providing per display id; per type; per display id and per type. + * + * e.g. + * For the view "export_test" with the display "page_1" and the type "csv" you + * would have the following options. + * views_bonus_export_feed_icon__export_test__page_1__csv + * views_bonus_export_feed_icon__export_test__page_1 + * views_bonus_export_feed_icon__export_test__csv + * views_bonus_export_feed_icon__page_1__csv + * views_bonus_export_feed_icon__page_1 + * views_bonus_export_feed_icon__csv + * views_bonus_export_feed_icon + * + * @ingroup themeable + */ +function theme_views_bonus_export_feed_icon($image_path, $url, $query = '') { + $url_options = array('html' => true); + if ($query) { + $url_options['query'] = $query; + } + $image = theme('image', $image_path); + return l($image, $url, $url_options); +} + diff --git export/views_bonus_plugin_style_export.inc export/views_bonus_plugin_style_export.inc index ead053e..ef79d75 100644 --- export/views_bonus_plugin_style_export.inc +++ export/views_bonus_plugin_style_export.inc @@ -19,12 +19,22 @@ class views_bonus_plugin_style_export extends views_plugin_style { * feed image link. */ function attach_to($display_id, $path, $title) { - $url_options = array('html' => true); - $input = $this->view->get_exposed_input(); - if ($input) { - $url_options['query'] = $input; - } - $image = theme('image', $this->feed_image); - $this->view->feed_icon .= l($image, $this->view->get_url(NULL, $path), $url_options); + $types = array( + 'views_bonus_plugin_style_export_csv' => 'csv', + 'views_bonus_plugin_style_export_doc' => 'doc', + 'views_bonus_plugin_style_export_txt' => 'txt', + 'views_bonus_plugin_style_export_xml' => 'xml', + ); + $type = $types[get_class($this)]; + $theme_pattern = array( + 'views_bonus_export_feed_icon__' . $this->view->name . '__' . $display_id . '__' . $type, + 'views_bonus_export_feed_icon__' . $this->view->name . '__' . $display_id, + 'views_bonus_export_feed_icon__' . $this->view->name . '__' . $type, + 'views_bonus_export_feed_icon__' . $display_id . '__' . $type, + 'views_bonus_export_feed_icon__' . $display_id, + 'views_bonus_export_feed_icon__' . $type, + 'views_bonus_export_feed_icon', + ); + $this->view->feed_icon .= theme($theme_pattern, $this->feed_image, $this->view->get_url(NULL, $path), $this->view->get_exposed_input()); } }