'; $output .= $var['message']; $output .= ''; return $output; } /** * 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_data_export_feed_icon__export_test__page_1__csv * views_data_export_feed_icon__export_test__page_1 * views_data_export_feed_icon__export_test__csv * views_data_export_feed_icon__page_1__csv * views_data_export_feed_icon__page_1 * views_data_export_feed_icon__csv * views_data_export_feed_icon * * @ingroup themeable */ function theme_views_data_export_feed_icon($variables) { extract($variables, EXTR_SKIP); $url_options = array('html' => TRUE); if ($query) { $url_options['query'] = $query; } $image = theme('image', array('path' => $image_path, 'alt' => $text, 'title' => $text)); return l($image, $url, $url_options); } /** * Theme callback for the export complete page. * * @param $file * Link to output file */ function theme_views_data_export_complete_page($variables) { extract($variables, EXTR_SKIP); drupal_set_title(t('Data export successful')); drupal_add_html_head(array('#tag' => 'meta', '#attributes' => array('http-equiv' =>"Refresh", 'content' => '3;url='. $file)), 'views_data_export_download'); $output = ''; $output .= '
'; $output .= t('Your export has been created. View/download the file here (will automatically download in 3 seconds.)', array('@link' => $file)); $output .= '
'; if (!empty($return_url)) { $output .= ''; $output .= l(t('Return to previous page'), $return_url); $output .= '
'; } return $output; } function template_preprocess_views_data_export(&$vars) { $vars['header'] = $vars['rows']['header']; $vars['body'] = $vars['rows']['body']; $vars['footer'] = $vars['rows']['footer']; $view = $vars['view']; $fields = &$view->field; } function template_preprocess_views_data_export_csv_header(&$vars) { _views_data_export_header_shared_preprocess($vars); // Make sure we catch saved options that are misspelled. LEGACY if (isset($vars['options']['seperator'])) { $vars['options']['separator'] = $vars['options']['seperator']; } // Support old misspelled templates. LEGACY $vars['seperator'] = $vars['separator'] = $vars['options']['separator']; // Special handling when quoted values are involved. if ($vars['options']['quote']) { $wrap = '"'; $replace_value = '""'; } else { $wrap = ''; $replace_value = ''; } // Format header values. foreach ($vars['header'] as $key => $value) { $output = decode_entities($value); $output = (empty($vars['options']['keep_html'])) ? strip_tags($output) : $output; if (!empty($vars['options']['trim'])) { $output = trim($output); } if (!empty($vars['options']['encoding']) && function_exists('iconv')) { switch($vars['options']['encoding']) { case 'utf8_decode': $converted = utf8_decode($output); break; default: $converted = iconv("UTF-8", $vars['options']['encoding'], $output); break; } if ($converted !== FALSE) { $output = $converted; } } $vars['header'][$key] = $wrap . str_replace('"', $replace_value, $output) . $wrap; } } function template_preprocess_views_data_export_csv_body(&$vars) { _views_data_export_body_shared_preprocess($vars); // Make sure we catch saved options that are misspelled. LEGACY if (isset($vars['options']['seperator'])) { $vars['options']['separator'] = $vars['options']['seperator']; } // Support old misspelled templates. LEGACY $vars['seperator'] = $vars['separator'] = $vars['options']['separator']; // Special handling when quoted values are involved. if ($vars['options']['quote']) { $wrap = '"'; $replace_value = '""'; } else { $wrap = ''; $replace_value = ''; } // Format row values. foreach ($vars['themed_rows'] as $i => $values) { foreach ($values as $j => $value) { $output = decode_entities($value); $output = (empty($vars['options']['keep_html'])) ? strip_tags($output) : $output; if (!empty($vars['options']['trim'])) { $output = trim($output); } if (!empty($vars['options']['encoding']) && function_exists('iconv')) { switch($vars['options']['encoding']) { case 'utf8_decode': $converted = utf8_decode($output); break; default: $converted = iconv("UTF-8", $vars['options']['encoding'], $output); break; } if ($converted !== FALSE) { $output = $converted; } } if (!empty($vars['options']['replace_newlines'])) { if (!empty($vars['options']['newline_token'])) { $output = str_replace( array("\r\n", "\r", "\n"), $vars['options']['newline_replacement'], $output); } else { $output = str_replace("\n", $vars['options']['newline_replacement'], $output); } } $vars['themed_rows'][$i][$j] = $wrap . str_replace('"', $replace_value, $output) . $wrap; } } } /** * Preprocess csv output template. */ function template_preprocess_views_data_export_csv(&$vars) { // TODO Replace items with themed_rows. _views_data_export_shared_preprocess($vars); // Make sure we catch saved options that are misspelled. LEGACY if (isset($vars['options']['separator'])) { $vars['options']['separator'] = $vars['options']['seperator']; } // Support old misspelled templates. LEGACY $vars['seperator'] = $vars['separator'] = $vars['options']['separator']; // Special handling when quoted values are involved. if ($vars['options']['quote']) { $wrap = '"'; $replace_value = '""'; } else { $wrap = ''; $replace_value = ''; } // Format header values. foreach ($vars['header'] as $key => $value) { $output = decode_entities(strip_tags($value)); if ($vars['options']['trim']) { $output = trim($output); } if (!empty($vars['options']['encoding']) && function_exists('iconv')) { switch($vars['options']['encoding']) { case 'ASCII': $converted = iconv("UTF-8", "ASCII//TRANSLIT", $output); if ($converted !== FALSE) { $output = $converted; } break; } } $vars['header'][$key] = $wrap . str_replace('"', $replace_value, $output) . $wrap; } // Format row values. foreach ($vars['themed_rows'] as $i => $values) { foreach ($values as $j => $value) { $output = decode_entities(strip_tags($value)); if ($vars['options']['trim']) { $output = trim($output); } if (!empty($vars['options']['encoding']) && function_exists('iconv')) { switch($vars['options']['encoding']) { case 'ASCII': $converted = iconv("UTF-8", "ASCII//TRANSLIT", $output); if ($converted !== FALSE) { $output = $converted; } break; } } $vars['themed_rows'][$i][$j] = $wrap . str_replace('"', $replace_value, $output) . $wrap; } } } /** * Preprocess txt output template. */ function template_preprocess_views_data_export_txt_body(&$vars) { _views_data_export_header_shared_preprocess($vars); // We support not outputting fields when they are empty, so indicate so. $vars['hide_empty_support'] = TRUE; _views_data_export_body_shared_preprocess($vars); } function template_preprocess_views_data_export_doc_body(&$vars) { // Pass through the generic MS Office preprocess. template_preprocess_views_data_export_msoffice_body($vars); } function template_preprocess_views_data_export_xls_body(&$vars) { // Pass through the generic MS Office preprocess. template_preprocess_views_data_export_msoffice_body($vars); } function template_preprocess_views_data_export_msoffice_body(&$vars) { _views_data_export_header_shared_preprocess($vars); _views_data_export_body_shared_preprocess($vars); $output = ''; // Construct the tbody of a table, see theme_table(). $ts = tablesort_init($vars['header']); $flip = array( 'even' => 'odd', 'odd' => 'even', ); $class = 'even'; foreach ($vars['themed_rows'] as $number => $row) { $attributes = array(); // Check if we're dealing with a simple or complex row if (isset($row['data'])) { foreach ($row as $key => $value) { if ($key == 'data') { $cells = $value; } else { $attributes[$key] = $value; } } } else { $cells = $row; } if (count($cells)) { // Add odd/even class $class = $flip[$class]; if (isset($attributes['class'])) { $attributes['class'] .= ' ' . $class; } else { $attributes['class'] = $class; } // Build row $output .= '