public function init() { parent::init(); $mappings = $this->_getFiltered('archive_folder_mappings'); $allowLocalPaths = Zend_Registry::get('archive_folder')->local_folders->allow == '1'; $this->setAttrib('id', 'archive-folder'); $this->setMethod('post'); $this->addElement('text', 'uri', array('label' => __('Base URI'), 'description' => __('The base url or path of the folder to expose.') . ' ' . __('If url, the server should allow directory listing.') . ($allowLocalPaths ? '' : ' ' . __('Local paths are forbidden by the administrator.')), 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', array('Callback', true, array('callback' => array('ArchiveFolder_Form_Validator', 'validateUri')), 'messages' => array(Zend_Validate_Callback::INVALID_VALUE => __('A url or a path is required to add a folder.')))))); $this->addElement('radio', 'unreferenced_files', array('label' => __('Unreferenced Files'), 'description' => __('This option indicates what to do with files, maybe all of them, that are not referenced inside metadata files ("%s").', implode('", "', array_keys($mappings))), 'value' => get_option('archive_folder_unreferenced_files') ?: 'by_file', 'multiOptions' => array('by_file' => __('One item by file'), 'by_directory' => __('One item by directory'), 'skip' => __("Skip")))); /* $this->addElement('checkbox', 'records_for_files', array( 'label' => __('Files Metadata'), 'description' => __('Create metadata for files, not only for items.') . ' ' . __('Metadata for files may be useless if there is only one file by item.') . ' ' . __('This parameter may be bypassed when a metadata file is directly included in the folder.'), 'value' => true, )); */ $this->addElement('hidden', 'records_for_files', array('value' => true)); $this->addElement('text', 'exclude_extensions', array('label' => __('File extensions to exclude'), 'description' => __('A black-list of extensions (normal or double) to exclude from the source, separated by a space or a comma and without the initial dot.') . ' ' . __('The white-list is the Omeka one, defined in the security page.'))); $this->addElement('checkbox', 'allow_no_extension', array('label' => __('Allow file without extension'), 'description' => __('This option allows to import some specific files and urls.') . ' ' . __('The option "Disable File Upload Validation" in Settings > Security should be set too.'), 'value' => false)); $values = array('' => __('No default item type'), 'default' => __('Default type according to first file of each item')) + get_table_options('ItemType'); $this->addElement('select', 'item_type_id', array('label' => __('Default Item Type'), 'description' => __('Set the item type during import as Omeka Item Type and Dublin Core Type.') . ' ' . __('For the second option (type of the first file), it can be:') . ' ' . __('"Still image" for an item with a single Image, "Text" for an item with multiple image or a pdf, ' . '"Sound" for an audio file, "Moving Image" for a video file and none in all other cases.'), 'multiOptions' => $values, 'value' => '')); $this->addElement('checkbox', 'add_relations', array('label' => __('Add unique identifiers'), 'description' => __('To add unique identifiers allows to link items and files easily and independantly from Omeka.') . ' ' . __('Added identifiers are absolute urls.') . ' ' . __("This option is only usefull when there aren't such identifiers."), 'value' => false)); $this->addElement('text', 'element_delimiter', array('label' => __('Table/Spreadsheet element separator'), 'description' => __('If metadata are available in a table (as Open Document Spreadsheet ods), multiple elements can be set within one cell for the same field.') . ' ' . __('This character or this string, for example the pipe "|", can be used to delimite them.') . ' ' . __('If the delimiter is empty, then the whole text will be used.') . ' ' . __('Anyway, multiple columns can be mapped to the same element and multiple rows can manage multiple values for the same field of the same record.'), 'value' => ArchiveFolder_Mapping_Table::DEFAULT_ELEMENT_DELIMITER)); $this->addElement('text', 'empty_value', array('label' => __('Table/Spreadsheet empty value'), 'description' => __('If metadata are available in a table (as Open Document Spreadsheet ods), an empty cell can be an empty value or no value.') . ' ' . __('To distinct these two cases, an empty value can be replaced by this string (case sensitive).'), 'value' => ArchiveFolder_Mapping_Table::DEFAULT_EMPTY_VALUE)); $this->addElement('textarea', 'extra_parameters', array('label' => __('Add specific parameters'), 'description' => __('Some formats require specific parameters, for example to be used in the xsl sheets.') . ' ' . __('You can specify them here, one by line.'), 'value' => '', 'required' => false, 'rows' => 5, 'placeholder' => __('parameter_1_name = parameter 1 value'), 'filters' => array('StringTrim'), 'validators' => array(array('callback', false, array('callback' => array('ArchiveFolder_Form_Validator', 'validateExtraParameters')), 'messages' => array(Zend_Validate_Callback::INVALID_VALUE => __('Each extra parameter, one by line, should have a name separated from the value with a "=".')))))); $identifierField = get_option('archive_folder_identifier_field'); if (!empty($identifierField) && $identifierField != ArchiveFolder_Importer::IDFIELD_INTERNAL_ID) { $currentIdentifierField = $this->_getElementFromIdentifierField($identifierField); if ($currentIdentifierField) { $identifierField = $currentIdentifierField->id; } } $values = get_table_options('Element', null, array('record_types' => array('All'), 'sort' => 'alphaBySet')); unset($values['']); $values = array(ArchiveFolder_Importer::IDFIELD_NONE => __('No default identifier field'), ArchiveFolder_Importer::IDFIELD_INTERNAL_ID => __('Internal id')) + $values; $this->addElement('select', 'identifier_field', array('label' => __('Identifier field (required)'), 'description' => __('The identifier field is used to simplify the update of records.') . ' ' . __('This is the link between the files in the folder and the records in the Omeka base.') . ' ' . __('The identifier should be set and unique in all records (collections, items, files).') . ' ' . __('This is generally the Dublin Core : Identifier or a specific element.'), 'multiOptions' => $values, 'value' => $identifierField)); $this->addElement('select', 'action', array('label' => __('Action'), 'multiOptions' => label_table_options(array(ArchiveFolder_Importer::ACTION_UPDATE_ELSE_CREATE => __('Update the record if it exists, else create one'), ArchiveFolder_Importer::ACTION_CREATE => __('Create a new record'), ArchiveFolder_Importer::ACTION_UPDATE => __('Update values of specific fields'), ArchiveFolder_Importer::ACTION_ADD => __('Add values to specific fields'), ArchiveFolder_Importer::ACTION_REPLACE => __('Replace values of all fields'), ArchiveFolder_Importer::ACTION_DELETE => __('Delete the record'), ArchiveFolder_Importer::ACTION_SKIP => __('Skip process of the record')), __('No default action')), 'description' => __('The action defines how records and metadara are processed.') . ' ' . __('The record can be created, updated, deleted or skipped.') . ' ' . __('The metadata of an existing record can be updated, appended or replaced.'))); // Parameters for the folder of original files. $this->addDisplayGroup(array('uri'), 'archive_folder_folder', array('legend' => __('Archive Folder URI'))); $this->addDisplayGroup(array('unreferenced_files', 'records_for_files', 'exclude_extensions', 'allow_no_extension', 'item_type_id', 'add_relations'), 'archive_folder_records', array('legend' => __('Archive Folder Records and files'), 'description' => __('Set parameters to create each record from files.') . ' ' . __('Note:') . ' ' . __('An item can have multiple files, and items and files can have different metadata.') . ' ' . __('For example, a record of a book can have each digitalized page attached to it.') . ' ' . __('An object can have multiple pictures under different views or taken by different photographers.') . ' ' . __('In that case, it is recommended to separate the metadata, for example to add data about each page or the different authors of the view.') . ' ' . __("Conversely, an image of a paint, a photography, or a book digitalized as a pdf and e-book files doesn't need to have separate records."))); // Parameters to create each record. $this->addDisplayGroup(array('element_delimiter', 'empty_value'), 'archive_folder_table', array('legend' => __('Tables'), 'description' => __('Set specific parameters for table or spreadsheets.'))); apply_filters('archive_folder_add_parameters', $this); $this->addDisplayGroup(array('extra_parameters'), 'archive_folder_extra_parameters', array('legend' => __('Extra Parameters'))); // Parameters for the folder of original files. $this->addDisplayGroup(array('identifier_field', 'action'), 'archive_folder_process', array('legend' => __('Process'))); $this->applyOmekaStyles(); $this->setAutoApplyOmekaStyles(false); $this->addElement('sessionCsrfToken', 'csrf_token'); $this->addElement('submit', 'submit', array('label' => __('Add folder'), 'class' => 'submit submit-medium', 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'field'))))); }
/** * 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); }
/** * Get the options array for a given table. * * @package Omeka\Function\View\Form * @uses Omeka_Db_Table::findPairsForSelectForm() * @param string $tableClass * @param string $labelOption * @param array $searchParams search parameters on table. */ function get_table_options($tableClass, $labelOption = null, $searchParams = array()) { $options = get_db()->getTable($tableClass)->findPairsForSelectForm($searchParams); $options = apply_filters(Inflector::tableize($tableClass) . '_select_options', $options); return label_table_options($options, $labelOption); }
<?php echo $this->formSelect('public', @$_REQUEST['public'], array(), label_table_options(array('1' => __('Only Public Items'), '0' => __('Only Non-Public Items')))); ?> </div> </div> <?php } ?> <div class="field"> <?php echo $this->formLabel('featured', __('Featured/Non-Featured')); ?> <div class="inputs"> <?php echo $this->formSelect('featured', @$_REQUEST['featured'], array(), label_table_options(array('1' => __('Only Featured Items'), '0' => __('Only Non-Featured Items')))); ?> </div> </div> <?php fire_plugin_hook('public_items_search', array('view' => $this)); ?> </div> <div> </div> </form> </div>
/** * 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); }
/** * Appends a narrow by Zotero Item Type select menu to the admin advanced * search. */ public function hookAdminItemsSearch() { $formSelect = get_view()->formSelect('zotero_item_type', null, null, label_table_options(self::getZoteroItemTypes())); echo ' <div class="field"> <div class="two columns alpha"> <label for="zotero_item_type">Zotero Item Type</label> </div> <div class="five columns omega inputs">'; echo $formSelect; echo ' </div> </div>'; }
/** * Initialize the form. */ public function init() { parent::init(); $this->setAttrib('id', 'csvimport-mapping'); $this->setMethod('post'); // Prepare elements for each format. switch ($this->_format) { case 'Manage': $elementsByElementSetName = $this->_getElementPairs(true); $special = label_table_options(array('Tags' => 'Tags', 'Collection' => 'Collection (for item)', 'Item' => 'Item (for file)', 'File' => 'Files', 'Action' => 'Action', 'RecordType' => 'Record type', 'itemType' => 'Item type', 'IdentifierField' => 'Identifier field', 'Identifier' => 'Identifier')); break; case 'Report': return false; case 'Item': $elementsByElementSetName = $this->_getElementPairs($this->_itemTypeId); break; case 'File': $elementsByElementSetName = $this->_getElementPairsForFiles(); break; // Deprecated. // Deprecated. case 'Mix': $elementsByElementSetName = $this->_getElementPairs(true); $special = label_table_options(array('Tags' => 'Tags', 'Collection' => 'Collection', 'fileUrl' => 'Zero or one file', 'File' => 'Files', 'RecordType' => 'Record type', 'ItemType' => 'Item type', 'Public' => 'Public', 'Featured' => 'Featured', 'sourceItemId' => 'Source Item Id')); break; case 'Update': $elementsByElementSetName = $this->_getElementPairs(true); $special = label_table_options(array('Tags' => 'Tags', 'Collection' => 'Collection', 'fileUrl' => 'Zero or one file', 'File' => 'Files', 'RecordType' => 'Record type', 'ItemType' => 'Item type', 'Public' => 'Public', 'Featured' => 'Featured', 'updateMode' => 'Update mode', 'updateIdentifier' => 'Update identifier', 'recordIdentifier' => 'Record identifier')); break; default: return false; } $elementsByElementSetName = label_table_options($elementsByElementSetName); foreach ($this->_columnNames as $index => $colName) { $rowSubForm = new Zend_Form_SubForm(); $selectElement = $rowSubForm->createElement('select', 'element', array('class' => 'map-element', 'multiOptions' => $elementsByElementSetName, 'multiple' => false)); $selectElement->setIsArray(true); if ($this->_automapColumns) { $selectElement->setValue($this->_getElementIdFromColumnName($colName)); } $rowSubForm->addElement($selectElement); $rowSubForm->addElement('checkbox', 'html', array('value' => $this->_elementsAreHtml)); // If import type is File, add checkbox for file url only because // files can't get tags and we just need the url. switch ($this->_format) { case 'Item': $rowSubForm->addElement('checkbox', 'tags'); $rowSubForm->addElement('checkbox', 'file'); break; case 'File': $rowSubForm->addElement('checkbox', 'file_url'); break; case 'Manage': // Deprecated. // Deprecated. case 'Mix': case 'Update': $specialElement = $rowSubForm->createElement('select', 'special', array('class' => 'map-element', 'multiOptions' => $special, 'multiple' => false)); // $specialElement->setIsArray(true); if ($this->_automapColumns) { $specialElement->setValue($this->_getSpecialValue($colName, $special)); } $rowSubForm->addElement($specialElement); $rowSubForm->addElement('checkbox', 'extra_data', array('label' => __('Extra data'))); break; } $this->_setSubFormDecorators($rowSubForm); $this->addSubForm($rowSubForm, "row{$index}"); } $this->addElement('submit', 'submit', array('label' => __('Import CSV file'), 'class' => 'submit submit-medium')); }