AAAAacademiac/www/administrator/components/com_chronoforms/form_actions/csv_export_gh/csv_export_gh.ctp000060400000036672151375006630031331 0ustar00home
CSV Export [GH]
Header(array('settings' => 'Settings', 'download' => 'Download', 'mysql' => 'MySQL', 'columns' => 'Columns', 'help' => 'Help'), 'csv_export_gh_config_{n}'); echo $PluginTabsHelper->tabStart('settings'); $database = JFactory::getDBO(); $tables = $database->getTableList(); $options = array(); foreach($tables as $table){ $options[$table] = $table; } echo $HtmlHelper->input('action_csv_export_gh_{n}_table_name_config', array( 'type' => 'select', 'label' => 'Table', 'options' => $options, 'empty' => " - ", 'class' => 'medium_input', 'smalldesc' => 'The table to be used for the export.' ) ); echo $HtmlHelper->input('action_csv_export_gh_{n}_data_path_config', array( 'type' => 'text', 'label' => "Data path", 'class' => 'medium_input', 'value' => '', 'smalldesc' => 'The path to the data list in the form->data array, use this if you already have the data in your form data array through a DBMRL action for example. e.g. MODEL_ID' )); echo $HtmlHelper->input('action_csv_export_gh_{n}_save_path_config', array( 'type' => 'text', 'label' => "Save path", 'class' => 'big_input', 'value' => '', 'smalldesc' => 'The path to the folder where the csv file will be saved e.g. '.JPATH_SITE.DS.'components'.DS.'com_chronocontact'.DS.'exports'.DS )); echo $HtmlHelper->input('action_csv_export_gh_{n}_file_name_config', array( 'type' => 'text', 'label' => "File name", 'class' => 'big_input', 'value' => '', 'smalldesc' => 'The name of the csv file. You may include valid input values as {input_name}' )); echo $HtmlHelper->input('action_csv_export_gh_{n}_post_file_name_config', array( 'type' => 'text', 'label' => "Post File name", 'class' => 'medium_input', 'value' => '', 'smalldesc' => 'The name of the post data/files arrays key under which the CSV file data will exist (in case the file is saved to the server)' )); echo $HtmlHelper->input('action_csv_export_gh_{n}_delimiter_config', array( 'type' => 'text', 'label' => "Delimiter", 'class' => 'small_input', 'value' => '', 'smalldesc' => 'The delimiter to be used for the CSV file, a single character only, defaults to comma ,. Use ##tab## for a tab character.' )); echo $HtmlHelper->input('action_csv_export_gh_{n}_enclosure_config', array( 'type' => 'text', 'label' => "Enclosure", 'class' => 'small_input', 'value' => '', 'smalldesc' => 'The enclosure to be used for the CSV file, a single character only, defaults to double quote "' )); echo $PluginTabsHelper->tabEnd(); echo $PluginTabsHelper->tabStart('download'); echo $HtmlHelper->input('action_csv_export_gh_{n}_download_export_config', array( 'type' => 'checkbox', 'label' => 'Immediate download', 'class' => 'checkbox', 'value' => '1', 'rule' => 'bool', 'smalldesc' => 'If you check this box then the file will be downloaded immediately and your form or thank you page will not be displayed.' ) ); echo $HtmlHelper->input('action_csv_export_gh_{n}_download_nosave_config', array( 'type' => 'checkbox', 'label' => 'Do not save the file on the server', 'class' => 'checkbox', 'value' => '1', 'rule' => "bool", 'smalldesc' => 'If you check this box then the file will be created in the server memory and downloaded immediately.' ) ); echo $HtmlHelper->input('action_csv_export_gh_{n}_download_mime_type_config', array( 'type' => 'checkbox', 'label' => 'Set mime type to \'octet\'', 'class' => 'checkbox', 'value' => '1', 'rule' => 'bool', 'smalldesc' => 'If you check this box then the file type will be set to \'application/octet-stream\' instead of \'text/csv\'.' ) ); echo $PluginTabsHelper->tabEnd(); echo $PluginTabsHelper->tabStart('mysql'); echo $HtmlHelper->input('action_csv_export_gh_{n}_where_config', array( 'type' => 'text', 'label' => "MySQL WHERE clause", 'class' => 'big_input', 'value' => '', 'smalldesc' => 'A valid MySQL WHERE clause to filter the results.' )); echo $HtmlHelper->input('action_csv_export_gh_{n}_order_by_config', array( 'type' => 'text', 'label' => "MySQL ORDER BY clause", 'class' => 'big_input', 'value' => '', 'smalldesc' => 'A valid MySQL ORDER BY clause to sort the results.' )); echo $PluginTabsHelper->tabEnd(); echo $PluginTabsHelper->tabStart('columns'); echo $HtmlHelper->input('action_csv_export_gh_{n}_include_config', array( 'type' => 'text', 'label' => "Include columns", 'class' => 'big_input', 'value' => '', 'smalldesc' => 'You can enter a comma separated list of column names to be exported' )); echo $HtmlHelper->input('action_csv_export_gh_{n}_exclude_config', array( 'type' => 'text', 'label' => "Exclude columns", 'class' => 'big_input', 'value' => '', 'smalldesc' => 'You can enter a comma separated list of column names *not* to be exported' )); echo $HtmlHelper->input('action_csv_export_gh_{n}_add_titles_config', array( 'type' => 'checkbox', 'label' => 'Add Titles', 'class' => 'checkbox', 'value' => '1', 'rule' => 'bool', 'smalldesc' => 'If you check this box then the titles will be added to the first row in the output file.' ) ); echo $HtmlHelper->input('action_csv_export_gh_{n}_content1_config', array( 'type' => 'textarea', 'label' => "Column details", 'rows' => 20, 'cols' => 70, 'smalldesc' => 'For each database column to be exported add a new row using Column Title=column_name e.g. ID=id or User Name=name or Visible From=created_date. If you make any entry here then only columns included here will be exported; any \included\' or \'excluded\' entries above will be ignored.' )); echo $PluginTabsHelper->tabEnd(); echo $PluginTabsHelper->tabStart('help'); $style = " div.tabs-panel { font-size: 100%; } div.tabs-panel tt{ font-size: 120%; } "; $doc = JFactory::getDocument(); $doc->addStyleDeclaration($style); ?>
This action helps you export some or all of the entries from a database table into a CSV file that can be downloaded and used for other purposes.

Settings

Downloads

MySQL

This tab allows you to specify the records to be exported and the order of the export. Both use standard MySQL syntax.
Paths and file names can include the special {table_name}, {datetime} and {rand} values. The value {datetime} inserts string in the form 'YmdHi' e.g. 201105101543; {rand} inserts a six digit random number e.g. 857943.

Columns

This tab offers two different ways to specify the columns to be exported. You may leave all the boxes empty in which case all the columns will be exported in the order they appear in the table and the column names will be shown in the first row of the exported file.

Results

The Action generates several outputs: a file saved to the server in the specified folder; and three new form data items {csv_link}, {csv_count} and {csv_size}. These give you a full URL for the new file and the number of records exported. You can use these in later actions like Emails or Thank You messages to allow access to the file.
You can use the success (or fail) events to do whatever you need after the response is processed.
tabEnd(); ?>