Example #1
0
 /**
  * Initialize the form.
  */
 public function init()
 {
     parent::init();
     $this->_columnDelimiter = CsvImport_RowIterator::getDefaultColumnDelimiter();
     $this->_fileDelimiter = CsvImport_ColumnMap_File::getDefaultFileDelimiter();
     $this->_tagDelimiter = CsvImport_ColumnMap_Tag::getDefaultTagDelimiter();
     $this->_elementDelimiter = CsvImport_ColumnMap_Element::getDefaultElementDelimiter();
     $this->setAttrib('id', 'csvimport');
     $this->setMethod('post');
     $this->_addFileElement();
     $values = get_db()->getTable('ItemType')->findPairsForSelectForm();
     $values = array('' => __('Select Item Type')) + $values;
     $this->addElement('checkbox', 'omeka_csv_export', array('label' => __('Use an export from Omeka CSV Report'), 'description' => __('Selecting this will override the options below.')));
     $this->addElement('checkbox', 'automap_columns_names_to_elements', array('label' => __('Automap Column Names to Elements'), 'description' => __('Automatically maps columns to elements based on their column names. The column name must be in the form: <br/> {ElementSetName}:{ElementName}'), 'value' => true));
     $this->addElement('select', 'item_type_id', array('label' => __('Select Item Type'), 'multiOptions' => $values));
     $values = get_db()->getTable('Collection')->findPairsForSelectForm();
     $values = array('' => __('Select Collection')) + $values;
     $this->addElement('select', 'collection_id', array('label' => __('Select Collection'), 'multiOptions' => $values));
     $this->addElement('checkbox', 'items_are_public', array('label' => __('Make All Items Public?')));
     $this->addElement('checkbox', 'items_are_featured', array('label' => __('Feature All Items?')));
     $this->_addColumnDelimiterElement();
     $this->_addTagDelimiterElement();
     $this->_addFileDelimiterElement();
     $this->_addElementDelimiterElement();
     $this->applyOmekaStyles();
     $this->setAutoApplyOmekaStyles(false);
     $submit = $this->createElement('submit', 'submit', array('label' => __('Next'), 'class' => 'submit submit-medium'));
     $submit->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'csvimportnext'))));
     $this->addElement($submit);
 }
Example #2
0
 /**
  * Initialize the form.
  */
 public function init()
 {
     parent::init();
     $this->_columnDelimiter = CsvImport_RowIterator::getDefaultColumnDelimiter();
     $this->_enclosure = CsvImport_RowIterator::getDefaultEnclosure();
     $this->_elementDelimiter = CsvImport_ColumnMap_Element::getDefaultElementDelimiter();
     $this->_tagDelimiter = CsvImport_ColumnMap_Tag::getDefaultTagDelimiter();
     $this->_fileDelimiter = CsvImport_ColumnMap_File::getDefaultFileDelimiter();
     $this->setAttrib('id', 'csvimport');
     $this->setMethod('post');
     $this->_addFileElement();
     $this->addElement('radio', 'format', array('description' => __('Choose the type of record (the format of your file) you want to import.'), 'multiOptions' => array('Manage' => __('Manage records (import, update, remove)'), 'Report' => __('Omeka CSV Report'), 'Item' => __('Items'), 'File' => __('Files metadata (update)'), 'Mix' => __('Mixed records'), 'Update' => __('Update records')), 'required' => TRUE));
     $this->_addColumnDelimiterElement();
     $this->_addEnclosureElement();
     $this->_addElementDelimiterElement();
     $this->_addTagDelimiterElement();
     $this->_addFileDelimiterElement();
     $identifierField = get_option('csv_import_identifier_field');
     if (!empty($identifierField) && $identifierField != 'internal id') {
         $currentIdentifierField = $this->_getElementFromIdentifierField($identifierField);
         if ($currentIdentifierField) {
             $identifierField = $currentIdentifierField->id;
         }
     }
     $values = get_table_options('Element', null, array('record_types' => array('All'), 'sort' => 'alphaBySet'));
     $values = array('' => __('No default identifier field'), 'internal id' => __('Internal id')) + $values;
     $this->addElement('select', 'identifier_field', array('label' => __('Identifier field (required)'), 'description' => __('The default identifier should be available for all record types that are currently imported in the file.'), 'multiOptions' => $values, 'value' => $identifierField));
     $this->addElement('select', 'action', array('label' => __('Action'), 'multiOptions' => label_table_options(array(CsvImport_ColumnMap_Action::ACTION_UPDATE_ELSE_CREATE => __('Update the record if it exists, else create one'), CsvImport_ColumnMap_Action::ACTION_CREATE => __('Create a new record'), CsvImport_ColumnMap_Action::ACTION_UPDATE => __('Update values of specific fields'), CsvImport_ColumnMap_Action::ACTION_ADD => __('Add values to specific fields'), CsvImport_ColumnMap_Action::ACTION_REPLACE => __('Replace values of all fields'), CsvImport_ColumnMap_Action::ACTION_DELETE => __('Delete the record'), CsvImport_ColumnMap_Action::ACTION_SKIP => __('Skip process of the record')), __('No default action'))));
     $values = get_table_options('ItemType', __('No default item type'));
     $this->addElement('select', 'item_type_id', array('label' => __('Item type'), 'multiOptions' => $values));
     $values = get_table_options('Collection', __('No default collection'));
     $this->addElement('select', 'collection_id', array('label' => __('Collection'), 'multiOptions' => $values));
     $this->addElement('checkbox', 'records_are_public', array('label' => __('Make records public'), 'description' => __('Check to make records (items or collections) public by default.')));
     $this->addElement('checkbox', 'records_are_featured', array('label' => __('Feature records'), 'description' => __('Check to make records (items or collections) featured by default.')));
     $this->addElement('checkbox', 'elements_are_html', array('label' => __('Elements are html'), 'description' => __('Set default format of all imported elements as html, else raw text.'), 'value' => get_option('csv_import_html_elements')));
     $this->addElement('checkbox', 'create_collections', array('label' => __('Create collections'), 'description' => __("If the collection of an item doesn't exist, it will be created.") . '<br />' . __('Use "Update" to set metadata of a collection.'), 'value' => get_option('csv_import_create_collections')));
     $this->addElement('select', 'contains_extra_data', array('label' => __('Contains extra data'), 'description' => __('Other columns can be used as values for non standard data.'), 'multiOptions' => array('no' => __('No, so unrecognized column names will be noticed'), 'manual' => __('Perhaps, so the mapping should be done manually'), 'ignore' => __('Ignore unrecognized column names'), 'yes' => __("Yes, so column names won't be checked")), 'value' => get_option('csv_import_extra_data')));
     $this->addElement('checkbox', 'automap_columns', array('label' => __('Automap column names to elements'), 'description' => __('Automatically maps columns to elements based on their column names.') . ' ' . __('The column name must be in the form: {ElementSetName}:{ElementName}'), 'value' => get_option('csv_import_automap_columns')));
     $this->addDisplayGroup(array('csv_file', 'format'), 'file_type');
     $this->addDisplayGroup(array('column_delimiter_name', 'column_delimiter', 'enclosure_name', 'enclosure', 'element_delimiter_name', 'element_delimiter', 'tag_delimiter_name', 'tag_delimiter', 'file_delimiter_name', 'file_delimiter'), 'csv_format', array('legend' => __('CSV format'), 'description' => __('Set delimiters and enclosure used in the file.')));
     $this->addDisplayGroup(array('identifier_field', 'action', 'item_type_id', 'collection_id', 'records_are_public', 'records_are_featured', 'elements_are_html'), 'default_values', array('legend' => __('Default values'), 'description' => __("Set the default values to use when the column doesn't exist.")));
     $this->addDisplayGroup(array('create_collections', 'contains_extra_data', 'automap_columns'), 'import_features', array('legend' => __('Features to use'), 'description' => __('Set features used to process the file.')));
     $submit = $this->createElement('submit', 'submit', array('label' => __('Next'), 'class' => 'submit submit-medium'));
     $submit->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'csvimportnext'))));
     $this->addElement($submit);
     $this->applyOmekaStyles();
     $this->setAutoApplyOmekaStyles(false);
 }
Example #3
0
 /**
  * Initialize the form.
  */
 public function init()
 {
     parent::init();
     $this->_columnDelimiter = CsvImport_RowIterator::getDefaultColumnDelimiter();
     $this->_enclosure = XmlImportPlugin::isFullCsvImport() ? CsvImport_RowIterator::getDefaultEnclosure() : '"';
     $this->_elementDelimiter = CsvImport_ColumnMap_Element::getDefaultElementDelimiter();
     $this->_tagDelimiter = CsvImport_ColumnMap_Tag::getDefaultTagDelimiter();
     $this->_fileDelimiter = CsvImport_ColumnMap_File::getDefaultFileDelimiter();
     $this->setName('xmlimport');
     $this->setAttrib('id', 'xmlimport');
     $this->setMethod('post');
     // Radio button for selecting record type.
     $this->addElement('radio', 'file_import', array('label' => __('How many files do you want to import?'), 'multiOptions' => array('file' => __('One xml file'), 'folder' => __('All xml files in a folder'), 'recursive' => __('All xml files in a folder (recursive)')), 'description' => __('The xsl sheet will create one csv file from this or these xml files and send it to CsvImport.'), 'required' => true, 'value' => 'file'));
     // One xml file upload.
     $this->_addFileElement();
     // Multiple files.
     $this->addElement('text', 'xml_folder', array('description' => __('The server should be able to access to this uri.')));
     // Helper to manage multiple files.
     $this->addElement('text', 'format_filename', array('description' => __('The format of the filenames to search (format: "suffix.extension", for example "refnum.xml"; default: ".xml").') . ' ' . __('This is useful especially when folders contains multiple xml files.'), 'value' => get_option('xml_import_format_filename')));
     // Radio button for selecting record type.
     if (XmlImportPlugin::isFullCsvImport()) {
         $values = array('Manage' => __('Manage records (import, update, remove)'), 'Report' => __('Omeka CSV Report'), 'Item' => __('Items'), 'File' => __('Files metadata (update)'), 'Mix' => __('Mixed records'), 'Update' => __('Update records'));
         $description = '';
     } else {
         $values = array('Manage' => __('Manage records (import, update, remove) (only if CsvImport full is enabled)'), 'Report' => __('Omeka CSV Report'), 'Item' => __('Items'), 'File' => __('Files metadata (only if CsvImport full is enabled)'), 'Mix' => __('Mixed records (only if CsvImport full is enabled)'), 'Update' => __('Update records (only if CsvImport full is enabled)'));
         $description = __('Metadata of files cannot be imported and nothing can be updated, because you are using standard Csv Import.');
     }
     $this->addElement('radio', 'format', array('label' => __('Choose the type of record you want to import (according to the xsl sheet below):'), 'description' => $description, 'multiOptions' => $values, 'value' => get_option('xml_import_format'), 'required' => TRUE));
     $this->_addColumnDelimiterElement();
     if (XmlImportPlugin::isFullCsvImport()) {
         $this->_addEnclosureElement();
     } else {
         $enclosureElement = new Zend_Form_Element_Hidden('enclosure');
         $enclosureElement->setValue($this->_enclosure);
         $this->addElement($enclosureElement);
     }
     $this->_addElementDelimiterElement();
     $this->_addTagDelimiterElement();
     $this->_addFileDelimiterElement();
     $identifierField = get_option('csv_import_identifier_field');
     if (!empty($identifierField) && $identifierField != 'internal id') {
         $currentIdentifierField = $this->_getElementFromIdentifierField($identifierField);
         if ($currentIdentifierField) {
             $identifierField = $currentIdentifierField->id;
         }
     }
     $values = get_table_options('Element', null, array('record_types' => array('All'), 'sort' => 'alphaBySet'));
     $values = array('' => __('No default identifier field'), 'internal id' => __('Internal id')) + $values;
     $this->addElement('select', 'identifier_field', array('label' => __('Identifier field (required)'), 'description' => __('The default identifier should be available for all record types that are currently imported in the file.'), 'multiOptions' => $values, 'value' => $identifierField));
     if (XmlImportPlugin::isFullCsvImport()) {
         $this->addElement('select', 'action', array('label' => __('Action'), 'multiOptions' => label_table_options(array(CsvImport_ColumnMap_Action::ACTION_UPDATE_ELSE_CREATE => __('Update the record if it exists, else create one'), CsvImport_ColumnMap_Action::ACTION_CREATE => __('Create a new record'), CsvImport_ColumnMap_Action::ACTION_UPDATE => __('Update values of specific fields'), CsvImport_ColumnMap_Action::ACTION_ADD => __('Add values to specific fields'), CsvImport_ColumnMap_Action::ACTION_REPLACE => __('Replace values of all fields'), CsvImport_ColumnMap_Action::ACTION_DELETE => __('Delete the record'), CsvImport_ColumnMap_Action::ACTION_SKIP => __('Skip process of the record')), __('No default action'))));
     } else {
         $actionElement = new Zend_Form_Element_Hidden('action');
         $actionElement->setValue(false);
         $this->addElement($actionElement);
     }
     $values = get_table_options('ItemType', __('No default item type'));
     $this->addElement('select', 'item_type_id', array('label' => __('Item type'), 'multiOptions' => $values));
     $values = get_table_options('Collection', __('No default collection'));
     $this->addElement('select', 'collection_id', array('label' => __('Collection'), 'multiOptions' => $values));
     $this->addElement('checkbox', 'records_are_public', array('label' => __('Make records public'), 'description' => __('Check to make records (items or collections) public by default.')));
     $this->addElement('checkbox', 'records_are_featured', array('label' => __('Feature records'), 'description' => __('Check to make records (items or collections) featured by default.')));
     $this->addElement('checkbox', 'elements_are_html', array('label' => __('Elements are html'), 'description' => __('Set default format of all imported elements as html, else raw text.'), 'value' => get_option('csv_import_html_elements')));
     if (XmlImportPlugin::isFullCsvImport()) {
         $this->addElement('checkbox', 'create_collections', array('label' => __('Create collections'), 'description' => __("If the collection of an item doesn't exist, it will be created.") . '<br />' . __('Use "Update" to set metadata of a collection.'), 'value' => get_option('csv_import_create_collections')));
         $this->addElement('select', 'contains_extra_data', array('label' => __('Contains extra data'), 'description' => __('Other columns can be used as values for non standard data.'), 'multiOptions' => array('no' => __('No, so unrecognized column names will be noticed'), 'manual' => __('Perhaps, so the mapping should be done manually'), 'ignore' => __('Ignore unrecognized column names'), 'yes' => __("Yes, so column names won't be checked")), 'value' => get_option('csv_import_extra_data')));
     } else {
         $createCollectionsElement = new Zend_Form_Element_Hidden('create_collections');
         $createCollectionsElement->setValue(false);
         $this->addElement($createCollectionsElement);
         $extraDataElement = new Zend_Form_Element_Hidden('contains_extra_data');
         $extraDataElement->setValue('no');
         $this->addElement($extraDataElement);
     }
     // XSLT Stylesheet.
     $values = $this->_listDirectory(get_option('xml_import_xsl_directory'), 'xsl');
     // Don't return an error if the folder is unavailable, but simply set an
     // empty list.
     if ($values === false) {
         $values = array();
     }
     $this->addElement('select', 'stylesheet', array('label' => __('Xsl sheet'), 'description' => __('The generic xsl sheet is "xml_import_generic_item.xsl". It transforms a flat xml file with multiple records into a csv file with multiple rows to import via "Item" format.'), 'multiOptions' => $values, 'required' => true, 'value' => get_option('xml_import_stylesheet')));
     $this->addElement('text', 'stylesheet_parameters', array('label' => __('Add specific parameters to use with this xsl sheet'), 'description' => __('Format: "< parameter_1_name = parameter 1 value >< parameter_2_name = parameter 2 value >"...') . ' ' . __('For generic imports, one important parameter is the name of the node that represents a record.') . ' ' . __('It automatically uses the first level node, but it may be a sub level one.') . ' ' . __('In that case, set it like that: "< node = record_name >".'), 'value' => get_option('xml_import_stylesheet_parameters')));
     $this->addDisplayGroup(array('file_import', 'xml_file', 'xml_folder', 'format_filename', 'format'), 'file_type');
     $this->addDisplayGroup(array('column_delimiter_name', 'column_delimiter', 'enclosure_name', 'enclosure', 'element_delimiter_name', 'element_delimiter', 'tag_delimiter_name', 'tag_delimiter', 'file_delimiter_name', 'file_delimiter'), 'csv_format', array('legend' => __('CSV format'), 'description' => __('Set delimiters and enclosure used in the file.')));
     $this->addDisplayGroup(array('identifier_field', 'action', 'item_type_id', 'collection_id', 'records_are_public', 'records_are_featured', 'elements_are_html'), 'default_values', array('legend' => __('Default values'), 'description' => __("Set the default values to use when the column doesn't exist.")));
     $this->addDisplayGroup(array('create_collections', 'contains_extra_data'), 'import_features', array('legend' => __('Features to use'), 'description' => __('Set features used to process the file.')));
     $this->addDisplayGroup(array('stylesheet', 'stylesheet_parameters'), 'xsl_params', array('legend' => __('XSL transformation'), 'description' => __('Set xslt sheet and optional parameters used to process the file.')));
     // Submit button.
     $submit = $this->createElement('submit', 'submit', array('label' => __('Upload'), 'class' => 'submit submit-medium'));
     $submit->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'xmlimportupload'))));
     $this->addElement($submit);
     $this->applyOmekaStyles();
     $this->setAutoApplyOmekaStyles(false);
 }