+ formText('simple_vocab_plus_fields_highlight', $simple_vocab_plus_fields_highlight, array('title'=>__('pound sign (#) followed by six hex values'),'pattern'=>'^#[0-9a-fA-F]{6}$')); ?>
+
diff --git a/controllers/EndpointController.php b/controllers/EndpointController.php
index 0ae7307..9ccb209 100644
--- a/controllers/EndpointController.php
+++ b/controllers/EndpointController.php
@@ -1,55 +1,77 @@
-_helper->viewRenderer->setNoRender();
- $elementId = $this->getRequest()->getParam('element_id');
- $svAssign = $this->_helper->db->getTable('SvpAssign')->findByElementId($elementId);
- $vocab = $this->_helper->db->getTable('SvpAssign')->find($svAssign->vocab_id);
- echo $vocab ? $vocab->url : null;
- }
-
- /**
- * Proxy for the Sv Suggest suggest endpoints, used by the
- * autosuggest feature.
- */
- public function suggestProxyAction()
- {
- //get the term
- $term = $this->getRequest()->getParam('term');
-
- // Get the suggest record.
- $elementId = $this->getRequest()->getParam('element-id');
- $svAssigns = $this->_helper->db->getTable('SvpAssign')->findByElementId($elementId);
- $return = array();
- $termTable = $this->_helper->db->getTable('SvpTerm');
- foreach($svAssigns as $svAssign) {
- $results = $termTable->findBySql('vocab_id = ? and term like ?',array($svAssign->vocab_id,$term.'%'));
- foreach($results as $result) {
- $return[] = $result->term;
- }
- }
- $this->_helper->json($return);
- }
-
-
-
-}
\ No newline at end of file
+_helper->viewRenderer->setNoRender();
+ $elementId = $this->getRequest()->getParam('element_id');
+ $svpAssign = $this->_helper->db->getTable('SvpAssign')->findByElementId($elementId);
+ $vocab = $this->_helper->db->getTable('SvpAssign')->find($svpAssign->vocab_id);
+ echo $vocab ? $vocab->url : null;
+ }
+
+ /**
+ * Proxy for the SvpSuggest suggest endpoints, used by the
+ * autosuggest feature.
+ */
+ public function suggestProxyAction()
+ {
+ // Get the term
+ $term = $this->getRequest()->getParam('term');
+
+ // Get the suggest record
+ $elementId = $this->getRequest()->getParam('element-id');
+ $svpAssigns = $this->_helper->db->getTable('SvpAssign')->findByElementId($elementId);
+ $return = array();
+ $termTable = $this->_helper->db->getTable('SvpTerm');
+ $elementTextTable = $this->_helper->db->getTable('ElementText');
+ foreach ($svpAssigns as $svpAssign) {
+ if ($svpAssign['type'] == 'self') {
+ // case of values retrieved from repository's data
+ $select = $elementTextTable->getSelect();
+ $select->from(array(),'text')
+ ->where('record_type = ?', 'Item')
+ ->where('element_id = ?', $elementId)
+ ->where('text LIKE ?', $term . '%')
+ ->group('text')
+ ->order('text ASC');
+ $return = $elementTextTable->fetchCol($select);
+ } elseif ($svpAssign['type'] == 'multi') {
+ // case of values retrieved from multiple elements in repository's data
+ $select = $elementTextTable->getSelect();
+ $select->from(array(),'text')
+ ->where('record_type = ?', 'Item')
+ ->where('element_id IN (' . $svpAssign->sources_id . ')')
+ ->where('text LIKE ?', $term . '%')
+ ->group('text')
+ ->order('text ASC');
+ $return = $elementTextTable->fetchCol($select);
+ } else {
+ // case of values retrieved from vocabulary (local or remote)
+ $results = $termTable->findBySql('vocab_id = ? and term like ?', array($svpAssign->vocab_id, $term . '%'));
+ foreach($results as $result) {
+ $return[] = $result->term;
+ }
+ }
+ }
+ $this->_helper->json($return);
+ }
+}
diff --git a/controllers/IndexController.php b/controllers/IndexController.php
index 7947880..5b4d324 100644
--- a/controllers/IndexController.php
+++ b/controllers/IndexController.php
@@ -1,123 +1,244 @@
-view->form_element_options = $this->_getFormElementOptions();
- $this->view->form_vocab_options = $this->_getFormSuggestOptions();
- $this->view->assignments = $this->_getAssignments();
-
- $csrf = new Omeka_Form_SessionCsrf;
- $this->view->csrf = $csrf;
-
- foreach(get_db()->getTable('SvpVocab')->findAll() as $vocab) {
- $vocab->updateNow();
- }
- }
-
- /**
- * Get an array to be used in formSelect() containing all elements.
- *
- * @return array
- */
- private function _getFormElementOptions()
- {
- $db = $this->_helper->db->getDb();
- $sql = "
- SELECT es.name AS element_set_name,
- e.id AS element_id,
- e.name AS element_name,
- it.name AS item_type_name,
- gv.id AS gv_suggest_id
- FROM {$db->ElementSet} es
- JOIN {$db->Element} e ON es.id = e.element_set_id
- LEFT JOIN {$db->ItemTypesElements} ite ON e.id = ite.element_id
- LEFT JOIN {$db->ItemType} it ON ite.item_type_id = it.id
- LEFT JOIN {$db->SvpAssign} gv ON e.id = gv.element_id
- WHERE es.record_type IS NULL OR es.record_type = 'Item'
- ORDER BY es.name, it.name, e.name";
- $elements = $db->fetchAll($sql);
- $options = array('' => __('Select Below'));
- foreach ($elements as $element) {
- $optGroup = $element['item_type_name']
- ? __('Item Type') . ': ' . __($element['item_type_name'])
- : __($element['element_set_name']);
- $value = __($element['element_name']);
- if ($element['gv_suggest_id']) {
- $value .= ' *';
- }
- $options[$optGroup][$element['element_id']] = $value;
- }
- return $options;
- }
-
- /**
- * Get an array to be used in formSelect() containing all sugggest endpoints.
- *
- * @return array
- */
- private function _getFormSuggestOptions()
- {
- $vocabs = $this->_helper->db->getTable('SvpVocab')->findAll();
-
- $options = array('' => __('Select Below'));
-
- foreach ($vocabs as $vocab) {
- $options[$vocab['id']] = $vocab['name'];
- }
-
- return $options;
- }
-
- /**
- * Get all the authority/vocabulary assignments.
- *
- * @return array
- */
- private function _getAssignments()
- {
- $svSuggestTable = $this->_helper->db->getTable('SvpAssign');
- $svpVocabTable = $this->_helper->db->getTable('SvpVocab');
- $elementTable = $this->_helper->db->getTable('Element');
- $elementSetTable = $this->_helper->db->getTable('ElementSet');
- $itemTypeTable = $this->_helper->db->getTable('ItemType');
- $itemTypesElementsTable = $this->_helper->db->getTable('ItemTypesElements');
-
- $assignments = array();
- foreach ($svSuggestTable->findAll() as $svSuggest) {
- $element = $elementTable->find($svSuggest->element_id);
- $elementSet = $elementSetTable->find($element->element_set_id);
- $elementSetName = $elementSet->name;
- if( $itemTypesElements = $itemTypesElementsTable->findByElement($element->id)) {
- $itemTypesElement = $itemTypesElements[0];
- $itemType = $itemTypeTable->find($itemTypesElement->item_type_id);
- $elementSetName.=': '.$itemType->name;
- }
- $authorityVocabulary = $svpVocabTable->find($svSuggest->vocab_id);
- $authorityVocabularyName = $authorityVocabulary['name'];
-
- $assignments[] = array(
- 'suggest_id' => $svSuggest->id,
- 'element_set_name' => $elementSetName,
- 'element_set_id' => $elementSet->id,
- 'element_name' => $element->name,
- 'element_id' => $svSuggest->element_id,
- 'authority_vocabulary' => __($authorityVocabularyName),
- 'authority_vocabulary_id' => $authorityVocabulary->id,
- );
- }
- return $assignments;
- }
-}
+_helper->getHelper('AjaxContext')
+ ->addActionContexts(array('element-texts' => 'html'))
+ ->initContext();
+ }
+
+ public function indexAction()
+ {
+ $this->view->form_element_options_marked = $this->_getFormElementOptions(true);
+ $this->view->form_element_options = $this->_getFormElementOptions(false);
+ $this->view->form_vocab_options = $this->_getFormSuggestOptions();
+ $this->view->assignments = $this->_getAssignments();
+
+ $csrf = new Omeka_Form_SessionCsrf;
+ $this->view->csrf = $csrf;
+
+ foreach (get_db()->getTable('SvpVocab')->findAll() as $vocab) {
+ $vocab->updateNow();
+ }
+ }
+
+ /**
+ * Get an array to be used in formSelect() containing all elements,
+ * with the ones already assigned marked.
+ *
+ * @return array
+ */
+ private function _getFormElementOptions($marked=true)
+ {
+ $db = $this->_helper->db->getDb();
+ $sql = "
+ SELECT es.name AS element_set_name,
+ e.id AS element_id,
+ e.name AS element_name,
+ it.name AS item_type_name,
+ gv.id AS gv_suggest_id
+ FROM {$db->ElementSet} es
+ JOIN {$db->Element} e ON es.id = e.element_set_id
+ LEFT JOIN {$db->ItemTypesElements} ite ON e.id = ite.element_id
+ LEFT JOIN {$db->ItemType} it ON ite.item_type_id = it.id
+ LEFT JOIN {$db->SvpAssign} gv ON e.id = gv.element_id
+ WHERE es.record_type IS NULL OR es.record_type = 'Item'
+ ORDER BY es.name, it.name, e.name";
+ $elements = $db->fetchAll($sql);
+ $options = array('' => __('Select Below'));
+ foreach ($elements as $element) {
+ $optGroup = $element['item_type_name']
+ ? __('Item Type') . ': ' . __($element['item_type_name'])
+ : __($element['element_set_name']);
+ $value = __($element['element_name']);
+ if ($marked && $element['gv_suggest_id']) {
+ $value .= ' *';
+ }
+ $options[$optGroup][$element['element_id']] = $value;
+ }
+ return $options;
+ }
+
+ /**
+ * Get an array to be used in formSelect() containing all suggest endpoints.
+ *
+ * @return array
+ */
+ private function _getFormSuggestOptions()
+ {
+ $vocabs = $this->_helper->db->getTable('SvpVocab')->findAll();
+
+ foreach ($vocabs as $vocab) {
+ $options[$vocab['id']] = $vocab['name'];
+ }
+
+ if (!empty($options)) arsort($options);
+
+ $options[''] = __('Select Below');
+
+ return array_reverse($options, true);
+ }
+
+ /**
+ * Get all the authority/vocabulary assignments.
+ *
+ * @return array
+ */
+ private function _getAssignments()
+ {
+ $svpSuggestTable = $this->_helper->db->getTable('SvpAssign');
+ $svpVocabTable = $this->_helper->db->getTable('SvpVocab');
+ $elementTable = $this->_helper->db->getTable('Element');
+ $elementSetTable = $this->_helper->db->getTable('ElementSet');
+ $itemTypeTable = $this->_helper->db->getTable('ItemType');
+ $itemTypesElementsTable = $this->_helper->db->getTable('ItemTypesElements');
+
+ $assignments = array();
+ foreach ($svpSuggestTable->findAll() as $svpSuggest) {
+ $element = $elementTable->find($svpSuggest->element_id);
+ $elementSet = $elementSetTable->find($element->element_set_id);
+ $elementSetName = __($elementSet->name);
+ if ($itemTypesElements = $itemTypesElementsTable->findByElement($element->id)) {
+ $itemTypesElement = $itemTypesElements[0];
+ $itemType = $itemTypeTable->find($itemTypesElement->item_type_id);
+ $elementSetName .= ': ' . $itemType->name;
+ }
+ $authorityVocabulary = $svpVocabTable->find($svpSuggest->vocab_id);
+ $authorityVocabularyName = (isset($authorityVocabulary['name']) ? $authorityVocabulary['name'] : '');
+ if ($svpSuggest->sources_id != '') {
+ $sources_id = explode(',', $svpSuggest->sources_id);
+ $sources_name = array();
+ foreach ($sources_id as $source_id) {
+ $sources_name[] = __($elementTable->find($source_id)->name);
+ }
+ $sources_names = implode(', ', $sources_name);
+ } else {
+ $sources_names = '';
+ }
+
+ $assignments[] = array(
+ 'suggest_id' => $svpSuggest->id,
+ 'element_set_name' => $elementSetName,
+ 'element_set_id' => $elementSet->id,
+ 'element_name' => $element->name,
+ 'element_id' => $svpSuggest->element_id,
+ 'authority_vocabulary' => __($authorityVocabularyName),
+ 'authority_vocabulary_id' => (isset($authorityVocabulary->id) ? $authorityVocabulary->id : ''),
+ 'type' => __($svpSuggest->type),
+ 'enforced' => __($svpSuggest->enforced),
+ 'sources_id' => $svpSuggest->sources_id,
+ 'sources_names' => $sources_names
+ );
+ }
+ return $assignments;
+ }
+
+ /**
+ * Render the element texts.
+ *
+ * Available only via an AJAX request.
+ */
+ public function elementTextsAction()
+ {
+ $elementId = $this->getRequest()->getParam('element_id');
+ $warningMessages = array(
+ 'shortText' => __('Short text'),
+ 'longText' => __('Long text'),
+ 'containsNewlines' => __('Contains newlines'),
+ 'containsHTML' => __('Contains HTML code')
+ );
+
+ // Get the local vocabulary's terms, if any
+ $elementVocabTerms = $this->findElementTerms($elementId);
+
+ // Get the element's element texts, if any
+ $elementTexts = array();
+ $comparisonEnabled = get_option('simple_vocab_plus_values_compare');
+ foreach ($this->findElementTexts($elementId) as $elementText) {
+ $text = htmlspecialchars($elementText->text, ENT_QUOTES);
+ $warnings = array();
+ if (strlen($text) < 3) {
+ $warnings[] = $warningMessages['shortText'];
+ }
+ if (strlen($text) > 100) {
+ $warnings[] = $warningMessages['longText'];
+ }
+ if (strstr($elementText->text, "\n")) {
+ $warnings[] = $warningMessages['containsNewlines'];
+ }
+ if ($this->contains_html($elementText->text)) {
+ $warnings[] = $warningMessages['containsHTML'];
+ }
+ $elementTexts[] = array('element_id' => $elementId,
+ 'count' => $elementText->count,
+ 'warnings' => $warnings,
+ 'text' => ($comparisonEnabled ? (in_array($elementText->text, $elementVocabTerms) ? $text : '***' . $text . '***') : $text));
+ }
+
+ $this->view->element_texts = $elementTexts;
+ }
+
+ /**
+ * Checks whether string contains any HTML tag.
+ *
+ * @param str $string
+ * @return boolean
+ */
+ public function contains_html($string)
+ {
+ return preg_match("/<[^<]+>/", $string, $m) != 0;
+ }
+
+ /**
+ * Find distinct element texts for a specific element.
+ *
+ * @param int $elementId
+ * @return array
+ */
+ public function findElementTexts($elementId)
+ {
+ $db = get_db();
+ $select = $db->select()
+ ->from($db->ElementText, array('text', 'COUNT(*) AS count'))
+ ->group('text')
+ ->where('element_id = ?', $elementId)
+ ->where('record_type = ?', 'Item')
+ ->order(array('count DESC', 'text ASC'));
+ return $db->getTable('ElementText')->fetchObjects($select);
+ }
+
+ /**
+ * Find distinct local vocabulary's terms for a specific element.
+ *
+ * @return array
+ */
+ public function findElementTerms($elementId)
+ {
+ $db = $this->_helper->db->getDb();
+ $sql = "SELECT st.term
+ FROM {$db->SvpTerm} st
+ JOIN {$db->SvpAssign} sa ON st.vocab_id = sa.vocab_id
+ WHERE sa.element_id = ?
+ AND sa.type = 'local'
+ ORDER BY term ASC";
+ return $db->fetchCol($sql, $elementId);
+ }
+}
diff --git a/controllers/SuggestController.php b/controllers/SuggestController.php
index f1e352c..cc59c8f 100644
--- a/controllers/SuggestController.php
+++ b/controllers/SuggestController.php
@@ -1,94 +1,117 @@
-getRequest()->getParam('suggest_id');
- $svAssign = $this->_helper->db->getTable('SvpAssign')->find($suggestId);
- $svAssign->delete();
- $this->_helper->flashMessenger(__('Successfully disabled the element\'s suggest feature.'), 'success');
- $this->_helper->redirector('index','index');
- }
-
- public function editAction()
- {
- $suggestId = $this->getRequest()->getParam('suggest_id');
- $elementId = $this->getRequest()->getParam('element_id');
- $vocabId = $this->getRequest()->getParam('vocab_id');
- // Don't process empty select options.
- if ('' == $elementId) {
- $this->_helper->redirector('index','index');
- }
-
- // Don't process an invalid suggest endpoint.
- if (!$this->_vocabExists($vocabId)) {
- $this->_helper->flashMessenger(__('Invalid suggest endpoint. No changes have been made.'), 'error');
- $this->_helper->redirector('index','index');
- }
-
- $svAssign = $this->_helper->db->getTable('SvpAssign')->find($suggestId);
-
- $svAssign->element_id = $elementId;
- $svAssign->vocab_id = $vocabId;
- $svAssign->save();
- $this->_helper->flashMessenger(__('Successfully edited the element\'s suggest feature.'), 'success');
- $this->_helper->redirector('index','index');
- }
-
- /**
- * Adds a connection between an element and a vocabulary
- *
- * Overwrites existing connection for that element, if one exists
- *
- * @return void
- */
- public function addAction() {
-
- $elementId = $this->getRequest()->getParam('element_id');
- $vocabId = $this->getRequest()->getParam('vocab_id');
-
- // Don't process empty select options.
- if ('' == $elementId) {
- $this->_helper->flashMessenger(__('Please select an element to assign'), 'success');
- $this->_helper->redirector('index','index');
- }
-
- // Don't process an invalid suggest endpoint.
- if (!$this->_vocabExists($vocabId)) {
- $this->_helper->flashMessenger(__('Invalid suggest endpoint. No changes have been made.'), 'error');
- $this->_helper->redirector('index','index');
- }
-
- $svAssign = new SvpAssign;
- $svAssign->element_id = $elementId;
- $svAssign->vocab_id = $vocabId;
- $svAssign->save();
- $this->_helper->flashMessenger(__('Successfully enabled the element\'s suggest feature.'), 'success');
- $this->_helper->redirector('index','index');
- }
-
- /**
- * Check if the specified vocabulary exists.
- *
- * @param integer $vocabId
- * @return bool
- */
- private function _vocabExists($vocabId)
- {
- $vocab = $this->_helper->db->getTable('SvpVocab')->find($vocabId);
- return !empty($vocab);
- }
-}
+findById()
+ $this->_helper->db->setDefaultModelName('SvpAssign');
+ }
+
+ public function deleteAction()
+ {
+ $id = $this->getRequest()->getParam('id');
+ $svpAssign = $this->_helper->db->getTable('SvpAssign')->find($id);
+ $svpAssign->delete();
+ $this->_helper->flashMessenger(__('The element\'s suggest feature was successfully deleted.'), 'success');
+ $this->_helper->redirector('index','index');
+ }
+
+ protected function _getDeleteConfirmMessage($record)
+ {
+ return __('This will delete this Assignment, but not the assigned Vocabulary.');
+ }
+
+ /**
+ * Adds a connection between an element and a vocabulary
+ *
+ * Overwrites existing connection for that element, if one exists
+ *
+ * @return void
+ */
+ public function addAction() {
+
+ $element_id = $this->getRequest()->getParam('av_element-id');
+ $enforced = $this->getRequest()->getParam('av_enforced');
+ $sources_id = ($this->getRequest()->getParam('av_multi-id') !== null ? implode(',', $this->getRequest()->getParam('av_multi-id')) : '');
+ // Do not process too many sources.
+ if (strlen($sources_id) > 100) {
+ $this->_helper->flashMessenger(__('Please select less source elements.'), 'error');
+ $this->_helper->redirector('index','index');
+ }
+
+ switch ($this->getRequest()->getParam('av_source')) {
+ case "self":
+ $vocab_id = 0;
+ $type = __('self');
+ break;
+ case "multi":
+ $vocab_id = 0;
+ $type = __('multi');
+ break;
+ default:
+ $vocab_id = $this->getRequest()->getParam('av_vocab-id');
+ $type = ($this->_vocabIsLocal($vocab_id) ? __('local') : __('remote'));
+ }
+
+ // Do not process empty select options.
+ if ($element_id == '') {
+ $this->_helper->flashMessenger(__('Please select an element to assign.'), 'error');
+ $this->_helper->redirector('index','index');
+ }
+
+ // Do not process an invalid suggest endpoint.
+ if ($type != 'self' && (($type == 'multi' && !$sources_id) || ($type == 'vocab' && !$this->_vocabExists($vocab_id)))) {
+ $this->_helper->flashMessenger(__('Invalid suggest endpoint. No changes have been made.'), 'error');
+ $this->_helper->redirector('index','index');
+ }
+
+ $svpAssign = new SvpAssign;
+ $svpAssign->element_id = $element_id;
+ $svpAssign->type = $type;
+ $svpAssign->enforced = $enforced;
+ $svpAssign->vocab_id = $vocab_id;
+ $svpAssign->sources_id = $sources_id;
+ $svpAssign->save();
+ $this->_helper->flashMessenger(__('The element\'s suggest feature was successfully added.'), 'success');
+ $this->_helper->redirector('index','index');
+ }
+
+ /**
+ * Check if the specified vocabulary exists.
+ *
+ * @param integer $vocab_id
+ * @return bool
+ */
+ private function _vocabExists($vocab_id)
+ {
+ $vocab = $this->_helper->db->getTable('SvpVocab')->find($vocab_id);
+ return !empty($vocab);
+ }
+
+ /**
+ * Check if the specified vocabulary is local or remote.
+ *
+ * @param integer $vocab_id
+ * @return bool
+ */
+ private function _vocabIsLocal($vocab_id)
+ {
+ $vocab = $this->_helper->db->getTable('SvpVocab')->find($vocab_id);
+ return ($vocab['url'] == 'local');
+ }
+}
diff --git a/controllers/VocabularyController.php b/controllers/VocabularyController.php
index acdcb8a..2dd22c5 100644
--- a/controllers/VocabularyController.php
+++ b/controllers/VocabularyController.php
@@ -1,146 +1,147 @@
-_validatePost();
-
- $name = $_REQUEST['nv-name'];
- // Local.
- if ($_REQUEST['nv-local'] == 'local') {
- $text = $_REQUEST['nv-definetext'];
- $vocab = $this->_helper->db->getTable('SvpVocab')->createVocab($name, 'local');
- $success = $this->_helper->db->getTable('SvpTerm')->addFromText($vocab->id, $text);
- }
- // Remote..
- elseif ($_REQUEST['nv-local'] == 'remote') {
- $url = $_REQUEST['nv-url'];
- $vocab = $this->_helper->db->getTable('SvpVocab')->createVocab($name,$url);
- $vocab->updateNow();
- }
- $flash = $this->_helper->FlashMessenger;
- $flash->addMessage(__('Your vocabulary has been created successfully. You may now assign it to metadata elements.'), 'success');
- $this->_helper->redirector('index', 'index');
- }
-
- public function editAction()
- {
- $this->_validatePost();
-
- if (isset($_REQUEST['vocab']) && $_REQUEST['vocab'] != '') {
- $vocab_id = $_REQUEST['vocab'];
- }
- else {
- //throw new Exception('no vocab chosen');
- $this->_helper->flashMessenger(__('There was a problem editing your vocabulary.'), 'error');
- $this->_helper->redirector('index', 'index');
- }
-
- if (isset($_REQUEST['ev-url']) && $_REQUEST['ev-url'] !=' local') {
- $url = $_REQUEST['ev-url'];
- $vocab = $this->_helper->db->getTable('SvpVocab')->find($vocab_id);
- $vocab->url = $url;
- $vocab->save();
- }
- // Edit text.
- elseif (isset($_REQUEST['ev-edittext'])) {
- $text = $_REQUEST['ev-edittext'];
- $possibleUpdates = $this->_helper->db->getTable('SvpTerm')->updateFromText($vocab_id, $text);
- if ($possibleUpdates) {
- //prompt about updates
- $updates = $this->_promptUpdates($possibleUpdates);
- //if there are updates
- //update terms for all assigned records
- $this->_updateRecords($vocab_id, $updates);
- }
- }
- $this->_helper->flashMessenger(__('Vocabulary edited successfully'), 'success');
- $this->_helper->redirector('index', 'index');
- }
-
- public function getAction()
- {
- $db = $this->_helper->db;
- $vocabId = $this->getParam('vocab');
- $vocab = $db->getTable('SvpVocab')->find($vocabId);
- $terms = $db->getTable('SvpTerm')->findBy(array('vocab_id' => $vocabId));
- $return = array('url' => $vocab->url, 'terms' => array());
- foreach ($terms as $term) {
- $return['terms'][] = $term->term;
- }
- $this->_helper->viewRenderer->setNoRender();
- echo json_encode($return);
- }
-
- private function _promptUpdates($possibleUpdates)
- {
- // this is only a test function.
- // it'll work ok as long as there
- // are the same number of deleted and added
- // terms and they're all intended as
- // updates. This code will have to be
- // reorganized, since we will probably need an interactive
- // dialog here
-
- $length = count($possibleUpdates['add']) > count($possibleUpdates['delete'])
- ? count($possibleUpdates['delete'])
- : count($possibleUpdates['add']);
-
- for ($i=0; $i < $length; $i++) {
- $updates[$possibleUpdates['delete'][$i]] = $possibleUpdates['add'][$i];
- }
- return $updates;
- }
-
- private function _updateRecords($vocab_id, $updates)
- {
- // find all assignments for this vocab
- // run a sql query to update the element texts table
- // for these elements when the old term is matched
- // should be able to get it in a single query.
- $db = $this->_helper->db;
- foreach ($updates as $old => $new) {
- $sql = "UPDATE `{$db->ElementText}` AS et
- LEFT JOIN `{$db->SvpAssign}` AS sa
- ON et.element_id = sa.element_id
- SET et.text = REPLACE(et.text, ?, ?)
- WHERE sa.vocab_id = ?
- ";
- $bind = array($old, $new, (integer) $vocab_id);
- $db->query($sql, $bind);
- }
- }
-
- /**
- * Check if the specified vocabulary exists.
- *
- * @param string $vocab
- * @return bool
- */
- private function _vocabExists($vocab)
- {
- $vocab = $this->_helper->db->getTable('SvpVocab')->find($vocab);
- return !empty($vocab);
- }
-
- private function _validatePost()
- {
- $csrf = new Omeka_Form_SessionCsrf;
- if (!$csrf->isValid($_POST)) {
- $flash->addMessage(__('There was an error processing your request.'), 'error');
- $this->_helper->redirector('index', 'index');
- }
- }
-}
+findById()
+ $this->_helper->db->setDefaultModelName('SvpVocab');
+ }
+
+ public function addAction()
+ {
+ $this->_validatePost();
+
+ $name = trim($_REQUEST['nv_name']);
+ // Checks that an unambiguous name has been provided for the vocabulary
+ if ($name == '') {
+ $this->_helper->flashMessenger(__('You did not provide a name for your new vocabulary.'), 'error');
+ $this->_helper->redirector('index', 'index');
+ } elseif ($this->_vocabExists($name)) {
+ $this->_helper->flashMessenger(__('The name you provided for your new vocabulary is already in use.'), 'error');
+ $this->_helper->redirector('index', 'index');
+ }
+
+ $db = $this->_helper->db;
+ if ($_REQUEST['nv_local'] == 'local') {
+ // Local vocabulary
+ $text = $_REQUEST['nv_definetext'];
+ $vocab = $db->getTable('SvpVocab')->createVocab($name, 'local');
+ $success = $db->getTable('SvpTerm')->addFromText($vocab->id, $text);
+ } elseif ($_REQUEST['nv_local'] == 'remote') {
+ // Remote vocabulary
+ $url = $_REQUEST['nv_url'];
+ $vocab = $db->getTable('SvpVocab')->createVocab($name, $url);
+ $vocab->updateNow();
+ }
+ $flash = $this->_helper->FlashMessenger;
+ $flash->addMessage(__('Your new vocabulary has been created successfully. You may now assign it to metadata elements.'), 'success');
+ $this->_helper->redirector('index', 'index');
+ }
+
+ public function editAction()
+ {
+ $this->_validatePost();
+
+ if (isset($_REQUEST['ev_name'])) {
+ $vocab_id = $_REQUEST['ev_name'];
+ if ($vocab_id == '') {
+ $this->_helper->flashMessenger(__('No vocabulary was chosen for editing.'), 'error');
+ $this->_helper->redirector('index', 'index');
+ }
+ } else {
+ $this->_helper->flashMessenger(__('There was a problem editing your vocabulary.'), 'error');
+ $this->_helper->redirector('index', 'index');
+ }
+
+ $vocab_url = trim('' . $_REQUEST['ev_url']);
+ $vocab_text = trim('' . $_REQUEST['ev_edittext']);
+ $db = $this->_helper->db;
+
+ if ($vocab_url != '' && $vocab_url != 'local') {
+ // edit remote vocabulary
+ $vocab = $db->getTable('SvpVocab')->find($vocab_id);
+ $vocab->url = $vocab_url;
+ $vocab->save();
+ $this->_helper->flashMessenger(__('Remote vocabulary edited successfully.'), 'success');
+ $this->_helper->redirector('index', 'index');
+ } else {
+ // edit local vocabulary
+ $updates = $db->getTable('SvpTerm')->updateFromText($vocab_id, $vocab_text);
+ if (empty($updates['add']) && empty($updates['delete'])) {
+ $this->_helper->flashMessenger(__('No changes were made to the vocabulary.'), 'alert');
+ } else {
+ $this->_helper->flashMessenger(__('Local vocabulary edited successfully.'), 'success');
+ }
+ $this->_helper->redirector('index', 'index');
+ }
+ }
+
+ public function deleteAction()
+ {
+ $id = $this->getRequest()->getParam('id');
+ // delete vocabulary
+ if (!empty($this->_helper->db->getTable('SvpAssign')->findBy(array('vocab_id' => $id)))) {
+ $this->_helper->flashMessenger(__('At least one element is still assigned to this vocabulary. Delete the assignments before trying to delete the vocabulary.'), 'error');
+ $this->_helper->redirector('index', 'index');
+ } else {
+ $this->_helper->db->getTable('SvpVocab')->deleteVocab($id);
+ $this->_helper->flashMessenger(__('Vocabulary deleted successfully.'), 'success');
+ $this->_helper->redirector('index', 'index');
+ }
+ }
+
+ protected function _getDeleteConfirmMessage($record)
+ {
+ return __('This will delete the Vocabulary "%s", but not the values already stored in the repository.', $record['name']);
+ }
+
+ public function getAction()
+ {
+ $db = $this->_helper->db;
+ $vocabId = $this->getParam('vocab');
+ $vocab = $db->getTable('SvpVocab')->find($vocabId);
+ $terms = $db->getTable('SvpTerm')->findBy(array('vocab_id' => $vocabId, 'sort_field' => 'id', 'sort_dir' => 'a'));
+ $return = array('url' => $vocab->url, 'terms' => array());
+ foreach ($terms as $term) {
+ $return['terms'][] = $term->term;
+ }
+ $this->_helper->viewRenderer->setNoRender();
+ echo json_encode($return);
+ }
+
+ /**
+ * Check if the specified vocabulary exists.
+ *
+ * @param string $vocab_name
+ * @return bool
+ */
+ private function _vocabExists($vocab_name)
+ {
+ $vocab = $this->_helper->db->getTable('SvpVocab')->findBy(array('name'=>$vocab_name));
+ return !empty($vocab);
+ }
+
+ private function _validatePost()
+ {
+ $csrf = new Omeka_Form_SessionCsrf;
+ if (!$csrf->isValid($_POST)) {
+ $flash->addMessage(__('There was an error processing your request.'), 'error');
+ $this->_helper->redirector('index', 'index');
+ }
+ }
+}
diff --git a/languages/it.mo b/languages/it.mo
new file mode 100644
index 0000000..8e690b1
Binary files /dev/null and b/languages/it.mo differ
diff --git a/languages/it.po b/languages/it.po
new file mode 100644
index 0000000..93d055b
--- /dev/null
+++ b/languages/it.po
@@ -0,0 +1,547 @@
+# Translation for the Simple Vocab Plus plugin for Omeka.
+# Copyright (C) 2020 Daniele Binaghi
+# This file is distributed under the same license as the Omeka package.
+# Daniele Binaghi , 2020
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Simple Vocab Plus\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2020-02-01 11:54+0200\n"
+"PO-Revision-Date: 2020-02-01 12:06+0200\n"
+"PO-Revision-Date: 2021-04-07 10:50+0200\n"
+"PO-Revision-Date: 2021-04-10 08:53+0200\n"
+"Last-Translator: Daniele Binaghi \n"
+"Language-Team: Italian\n"
+"Language: it\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#: SimpleVocabPlusPlugin.php:200
+msgid "Simple Vocab Plus"
+msgstr "Simple Vocab Plus"
+
+#: SimpleVocabPlusPlugin.php:216
+msgid "
+"(Please note: this element has autosuggest activated using the Simple "
+"Vocab Plus plugin)"
+msgstr ""
+"(Attenzione: questo elemento ha la funzione di suggerimento attivata "
+"usando il plugin Simple Vocab Plus)"
+
+#: config_form.php:8
+msgid "Application scope"
+msgstr "Intervallo di applicazione"
+
+#: config_form.php:15
+msgid "Apply to Collections"
+msgstr "Applica alle collezioni"
+
+#: config_form.php:19
+msgid ""
+"If checked, the plugin will apply to Collections metadata too "
+"(by default, this plugin only applies to Items metadata)."
+msgstr ""
+"Se selezionata, il plugin sarà applicato anche ai metadati delle "
+"collezioni (per default, viene applicato solo ai metadati dei documenti)."
+
+#: config_form.php:27
+msgid "Apply to Files"
+msgstr "Applica ai file"
+
+#: config_form.php:31
+msgid ""
+"If checked, the plugin will apply to Files metadata too "
+"(by default, this plugin only applies to Items metadata)."
+msgstr ""
+"Se selezionata, il plugin sarà applicato anche ai metadati dei "
+"file (per default, viene applicato solo ai metadati dei documenti)."
+
+#: config_form.php:39
+msgid "Apply to Exhibit"
+msgstr "Applica alle esposizioni"
+
+#: config_form.php:44
+msgid ""
+"If checked, the plugin will apply to Exhibits metadata too "
+"(by default, this plugin only applies to Items metadata)."
+msgstr ""
+"Se selezionata, il plugin sarà applicato anche ai metadati delle "
+"esposizioni (per default, viene applicato solo ai metadati dei documenti)."
+
+#: config_form.php:49
+msgid ""
+"The %s plugin is not installed or active. Install "
+"and activate the plugin in order to be able to configure notifications "
+"for new Exhibits."
+msgstr ""
+"Il plugin %s non è installato o attivo. Installare ed attivare "
+"il plugin per poter configurare le notifiche per nuove esposizioni."
+
+#: config_form.php:55
+msgid "Alerts"
+msgstr "Notifiche"
+
+#: config_form.php:59
+msgid "Highlight autosuggest fields"
+msgstr "Evidenzia campi autosuggerimento"
+
+#: config_form.php:63
+msgid "
+"Color hex code (e.g.: #ff0000) to highlight the fields that have autosuggest feature "
+"applied (blank means no highlight)."
+msgstr ""
+"Codice esadecimale (p.e.: #ff0000) del colore da usarsi per evidenziare i campi che "
+"hanno la funzionalità di autosuggerimento applicata (vuoto significa nessuna evidenziazione)."
+
+#: config_form.php:71
+msgid "Add autosuggest reminder"
+msgstr "Aggiungi nota autosuggerimento"
+
+#: config_form.php:75
+msgid ""
+"Adds a notice to the description of fields that have autosuggest feature "
+"applied."
+msgstr ""
+"Aggiunge una notifica alla descrizione dei campi che hanno la funzionalità "
+"di autosuggerimento applicata."
+
+#: config_form.php:81
+msgid "Checks"
+msgstr "Controlli"
+
+#: config_form.php:85
+msgid "Compare element values"
+msgstr "Compara valori elementi"
+
+#: config_form.php:89
+msgid "When examining an element, compare the recorded values with the vocabulary's terms."
+msgstr "Durante l'esame di un elemento, comparare i valori registrati con i termini del vocabolario."
+
+#: index.php:83
+#: index.php:156
+msgid "Assign Vocabulary"
+msgstr "Assegna vocabolario"
+
+#: index.php:84
+#: index.php:265
+msgid "Create Vocabulary"
+msgstr "Crea vocabolario"
+
+#: index.php:85
+msgid "Edit Vocabulary"
+msgstr "Modifica vocabolario"
+
+#: index.php:86
+msgid "Examine Element"
+msgstr "Esamina elemento"
+
+#: index.php:92
+msgid "Assign Vocabulary to Metadata Element"
+msgstr "Assegna vocabolario ad un elemento dei metadati"
+
+#: index.php:95
+#: index.php:169
+#: index.php:333
+msgid "Element"
+msgstr "Elemento"
+
+#: index.php:99
+msgid ""
+"Select an element to assign it a vocabulary. Elements already assigned a vocabulary "
+"are marked with an asterisk (*)."
+msgstr ""
+"Selezionare un elemento al quale assegnare un vocabolario. Gli elementi "
+"ai quali è già assegnato un vocabolario sono indicati con un asterisco (*)."
+
+#: index.php:106
+msgid "Source"
+msgstr "Origine"
+
+#: index.php:110
+msgid ""
+"Choose the source of terms (note: if uncertain of values' consistency, you might want to "
+"examine them first)."
+msgstr ""
+"Scegliere la sorgente dei termini (nota: se si hanno delle riserve sulla consistenza dei "
+"valori, è meglio sesaminarli prima)."
+
+#: index.php:113
+msgid "Self assign: values are retrieved from the element's recorded ones"
+msgstr "Autoassegna: i valori sono recuperati da quelli già presenti in archivio"
+
+#: index.php:116
+msgid "Multiple assign: values are retrieved from multiple elements of the repository"
+msgstr "Assegnazione multipla: i valori sono recuperati da più elementi dell'archivio"
+
+#: index.php:119
+msgid "Vocabulary: values are retrieved from a local/remote custom vocabulary"
+msgstr "Vocabolario: i valori sono recuperati da un vocabolario personalizzato locale/remoto"
+
+#: index.php:124
+#: index.php:172
+msgid "Source element(s)"
+msgstr "Elemento/i sorgente"
+
+#: index.php:128
+msgid "Select one or more elements to use as source."
+msgstr "Selezionare uno o più elementi da usare come sorgenti."
+
+#: index.php:135
+msgid "Source vocabulary"
+msgstr "Vocabolario sorgente"
+
+#: index.php:139
+msgid "Select a vocabulary to enable the autosuggest feature for the above element."
+msgstr "Seleziona un vocabolario per abilitare la funzionalità di autosuggerimento per l'elemento indicato sopra."
+
+#: index.php:146
+msgid "Enforce values"
+msgstr "Forza valori"
+
+#: index.php:150
+msgid ""
+"If selected, user will see a dropdown box and will have to choose one of the suggested values. Works "
+"only with local/remote vocabularies. Deselect the option to disable the feature."
+msgstr ""
+"Se selezionata, l'utente vedrà una casella di riepilogo a discesa e dovrà scegliere uno dei valori "
+"suggeriti. Funziona solo con vocabolari locali/remoti. Deselezionare l'opzione per disabilitare la funzione."
+
+#: index.php:162
+msgid "Current Assignments"
+msgstr "Assegnazioni correnti"
+
+#: index.php:168
+msgid "Element Set"
+msgstr "Insieme di elementi"
+
+#: index.php:170
+msgid "Type"
+msgstr "Tipologia"
+
+#: index.php:171
+msgid "Vocabulary"
+msgstr "Vocabolario"
+
+#: index.php:173
+msgid "Enforced"
+msgstr "Forzato"
+
+#: index.php:196
+msgid "yes"
+msgstr "sì"
+
+#: index.php:196
+msgid "no"
+msgstr "no"
+
+#: index.php:206
+msgid "There are no suggest assignments."
+msgstr "Non esistono assegnazioni di suggerimenti."
+
+#: index.php:216
+msgid "Create new Vocabulary"
+msgstr "Crea un nuovo vocabolario"
+
+#: index.php:229
+#: index.php:278
+msgid "Name"
+msgstr "Nome"
+
+#: index.php:223
+msgid "Provide a name for your new vocabulary."
+msgstr "Fornisci un nome per il tuo nuovo vocabolario."
+
+#: index.php:229
+msgid "Location"
+msgstr "Collocazione"
+
+#: index.php:233
+msgid ""
+"Choose whether you would like the repository to store your new vocabulary's terms, "
+"or rather to store the vocabulary in the cloud (using Google Drive or GitPages or "
+"other similar services)."
+msgstr ""
+"Scegli se vuoi che l'archivio conservi i termini del tuo nuovo vocabolario, oppure "
+"se vuoi conservare il vocabolario nel cloud (usando Google Drive o GitPages o altri "
+"servizi similari)."
+
+#: index.php:236
+msgid "Define vocabulary and manually edit it here"
+msgstr "Definisci il vocabolario e modificalo manualmente qui"
+
+#: index.php:239
+msgid "Import vocabulary from the cloud"
+msgstr "Importa il vocabolario dal cloud"
+
+#: index.php:244
+#: index.php:287
+msgid "URL"
+msgstr "URL"
+
+#: index.php:248
+msgid ""
+"If the vocabulary is stored in the cloud, this field shows the file URL for the "
+"vocabulary; any web server or cloud service can host this file. A plain text file "
+"is expected with one term per line; a line consisting of a sequence of 3 hyphens "
+"will be displayed as an empty line and can be used as separator for subgroups of "
+"terms; a line starting with 3 asterisks will be displayed as an unselectable, "
+"bolded subgroup title."
+msgstr ""
+"Se il vocabolario è conservato nel cloud, questo campo mostra l'URL del file "
+"vocabolario; qualsiasi server web o servizio cloud può ospitare questo file. È "
+"atteso un file di testo semplice, con un termine per riga; una riga formata da una "
+"sequenza di 3 trattini sarà mostrata come una riga vuota e può essere usata "
+"come separatore per sottogruppi di termini; una riga che comincia con 3 asterischi "
+"verrà mostrata come titolo di un sottogruppo, in grassetto e non selezionabile.
+
+#: index.php:255
+#: index.php:298
+msgid "Terms list"
+msgstr "Lista termini"
+
+#: index.php:259
+msgid ""
+"Input all terms below, one term per line; a line consisting of a sequence of 3 "
+"hyphens will be displayed as an empty line and can be used as separator for "
+"subgroups of terms; a line starting with 3 asterisks will be displayed as an "
+"unselectable, bolded subgroup title. You can also drag and drop a text file here, "
+"to automatically paste its content."
+msgstr ""
+"Inserisci tutti i termini qui sotto, un termine per riga; una riga formata da una "
+"sequenza di 3 trattini sarà mostrata come una riga vuota e può essere usata "
+"come separatore per sottogruppi di termini; una riga che comincia con 3 asterischi "
+"verrà mostrata come titolo di un sottogruppo, in grassetto e non selezionabile. Puoi "
+"anche trascinare e rilasciare qui un file di testo, incollandone automaticamente il "
+"contenuto."
+
+#: index.php:261
+msgid "Input all terms or drop a text file..."
+msgstr "Inserisci tutti i termini o rilascia un file di testo..."
+
+#: index.php:274
+msgid "Edit existing Vocabulary"
+msgstr "Modifica vocabolario esistente"
+
+#: index.php:281
+msgid "Select a Vocabulary to edit."
+msgstr "Seleziona un vocabolario da modificare."
+
+#: index.php:291
+msgid ""
+"If the vocabulary is stored in the cloud, this field shows the file URL for the "
+"vocabulary. Any web server or cloud service can host this file (we recommend GitPages)."
+msgstr ""
+"Se il vocabolario è conservato nel cloud, questo campo mostra l'URL del file "
+"vocabolario. Ogni server web o servizio cloud può ospitare questo file (noi "
+"raccomandiamo GitPages)."
+
+#: index.php:302
+msgid ""
+"The vocabulary's terms are displayed here, one term per line; a line consisting of a "
+"sequence of 3 hyphens will be displayed as an empty line and can be used as separator "
+"for subgroups of terms; a line starting with 3 asterisks will be displayed as an "
+"unselectable, bolded subgroup title."
+msgstr ""
+"I termini del vocabolario vengono mostrati qui, un termine per riga; una riga formata "
+"da una sequenza di 3 trattini sarà mostrata come una riga vuota e può essere usata "
+"come separatore per sottogruppi di termini; una riga che comincia con 3 asterischi "
+"verrà mostrata come titolo di un sottogruppo, in grassetto e non selezionabile."
+
+#: index.php:308
+msgid "Save Changes"
+msgstr "Salva le modifiche"
+
+#: index.php:309
+msgid "Delete Vocabulary"
+msgstr "Elimina vocabolario"
+
+#: index.php:318
+msgid "Examine Element's values"
+msgstr "Esamina i valori di un elemento"
+
+#: index.php:322
+msgid ""
+"Before creating a vocabulary with values retrieved from the ones stored in the "
+"repository for a particular element, you might want to examine their consistency. "
+"Consider in fact the following caveats:"
+msgstr ""
+"Prima di creare un vocabolario con valori ottenuti da quelli presenti nell'archivio "
+"per un dato elemento, potresti voler esaminare la loro consistenza. Considera infatti "
+"le seguenti indicazioni:"
+
+#: index.php:325
+msgid "Vocabulary terms must not contain newlines (line breaks)."
+msgstr "Un vocabolario non deve contenere rimandi a capo (interruzioni di riga)."
+
+#: index.php:326
+msgid ""
+"Vocabulary terms are typically short and concise. If your existing texts are "
+"otherwise, avoid using a controlled vocabulary for this element."
+msgstr ""
+"I termini del vocabolario sono solitamente corti e concisi. Se i testi preesistenti "
+"non lo sono, si suggerisce di non utilizzare un vocabolario controllato per questo elemento."
+
+#: index.php:327
+msgid ""
+"Existing texts that are not in the vocabulary will be preserved - however, they cannot "
+"be selected in the item edit page, and will be deleted once you save the item."
+msgstr ""
+"I testi preesistenti che non sono nel vocabolario verranno preservati - non potranno "
+"però essere selezionati nella pagina di modifica, e saranno cancellati una volta che "
+"il documento verrà salvato."
+
+#: index.php:337
+msgid "Select an element to examine."
+msgstr "Seleziona un elemento da esaminare."
+
+# IndexController.php:94
+msgid "Select Below"
+msgstr "Seleziona sotto"
+
+# IndexController.php:150
+msgid "Short text"
+msgstr "Testo corto"
+
+# IndexController.php:151
+msgid "Long text"
+msgstr "Testo lungo"
+
+# IndexController.php:152
+msgid "Contains newlines"
+msgstr "Contiene rimandi a capo"
+
+# IndexController.php:153
+msgid "Contains HTML code"
+msgstr "Contiene codice HTML"
+
+# SuggestController.php:29
+msgid "The element's suggest feature was successfully deleted."
+msgstr "La funzionalità di suggerimento per l'elemento è stata eliminata correttamente."
+
+# SuggestController.php:35
+msgid "This will delete this Assignment, but not the assigned Vocabulary."
+msgstr "Questo cancellerà questa assegnazione, ma non il vocabolario associato"
+
+# SuggestController.php:52
+msgid "Please select less source elements."
+msgstr "Si prega di selezionare meno elementi sorgente."
+
+# SuggestController.php:67
+msgid "local"
+msgstr "locale"
+
+# SuggestController.php:67
+msgid "remote"
+msgstr "remoto"
+
+# SuggestController.php:72
+msgid "Please select an element to assign."
+msgstr "Si prega di selezionare un elemento da assegnare."
+
+# SuggestController.php:78
+msgid "Invalid suggest endpoint. No changes have been made."
+msgstr "Parametro di suggerimento invalido. Nessuna modifica è stata effettuata."
+
+# SuggestController.php:89
+msgid "The element's suggest feature was successfully added."
+msgstr "La funzionalità di suggerimento per l'elemento è stata aggiunta correttamente."
+
+# VocabularyController.php:31
+msgid "You did not provide a name for your new vocabulary."
+msgstr "Non hai fornito un nome per il tuo nuovo vocabolario."
+
+# VocabularyController.php:34
+msgid "The name you provided for your new vocabulary is already in use."
+msgstr "Il nome fornito per il tuo nuovo vocabolario è già in uso."
+
+# VocabularyController.php:51
+msgid ""
+"Your new vocabulary has been created successfully. You may now assign "
+"it to metadata elements."
+msgstr ""
+"Il tuo nuovo vocabolario è stato creato correttamente. Puoi ora assegnarlo "
+"agli elementi metadati."
+
+# VocabularyController.php:62
+msgid "No vocabulary was chosen for editing."
+msgstr "Non è stato scelto alcun vocabolario per la modifica."
+
+# VocabularyController.php:66
+msgid "There was a problem editing your vocabulary."
+msgstr "Si è verificato un problema durante la modifica del tuo vocabolario."
+
+# VocabularyController.php:79
+msgid "Remote vocabulary edited successfully."
+msgstr "Vocabolario remoto modificato correttamente."
+
+# VocabularyController.php:85
+msgid "No changes were made to the vocabulary."
+msgstr "Nessuna modifica è stata apportata al vocabolario."
+
+# VocabularyController.php:87
+msgid "Local vocabulary edited successfully."
+msgstr "Vocabolario locale modificato correttamente."
+
+# VocabularyController.php:98
+msgid ""
+"At least one element is still assigned to this vocabulary. Delete the "
+"assignments before trying to delete the vocabulary."
+msgstr ""
+"Almeno un elemento è ancora assegnato a questo vocabolario. Cancella la "
+"assegnazione prima di provare a cancellare il vocabolario."
+
+# VocabularyController.php:102
+msgid "Vocabulary deleted successfully."
+msgstr "Vocabolario cancellato correttamente."
+
+# VocabularyController.php:109
+msgid "This will delete the Vocabulary \"%s\", but not the values already stored in the repository."
+msgstr "Questo cancellerà il vocabolario \"%s\", ma non i valori già registrati nell'archivio."
+
+# VocabularyController.php:142
+msgid "There was an error processing your request."
+msgstr "Si è verificato un errore nella lavorazione della tua richiesta."
+
+# element-texts.ajax:2
+msgid "No value for the selected element was found in the repository."
+msgstr "Non è stato trovato nell'archivio alcun valore per l'elemento selezionato."
+
+# element-texts.ajax:4
+msgid ""
+"These are the values stored in the repository for the selected element; clicking on "
+"any of them results in a search for all Items including that particular value. "
+"Values not found in a local vocabulary assigned to the element will be marked in red "
+"(feature has to be enabled in plugin configuration)."
+msgstr ""
+"Questi sono i valori registrati nell'archivio per l'elemento selezionato; cliccando su "
+"uno qualsiasi di essi si realizzare una ricerca di tutti i Documenti che includono quel "
+"particolare valore. I valori non rinvenuti nel vocabolario locale assegnato all'elemento "
+"verranno marcati in rosso (la funzionalità dev'essere attivata nella configurazione del "
+"plugin)."
+
+# element-texts.ajax:7
+msgid "Count"
+msgstr "Conteggio"
+
+# element-texts.ajax:8
+msgid "Value"
+msgstr "Valore"
+
+# element-texts.ajax:9
+msgid "Warnings"
+msgstr "Avvertimenti"
+
+# element-texts.ajax:26
+msgid "click to search for"
+msgstr "clicca per cercare"
+
+# element-texts.ajax:26
+msgid "this page"
+msgstr "questa pagina"
+
+# element-texts.ajax:26
+msgid "these pages"
+msgstr "queste pagine"
diff --git a/languages/template.base.pot b/languages/template.base.pot
new file mode 100644
index 0000000..2975561
--- /dev/null
+++ b/languages/template.base.pot
@@ -0,0 +1,17 @@
+# Translation for the Simple Vocab Plus plugin for Omeka.
+# This file is distributed under the same license as the Omeka plugin.
+# FIRST AUTHOR , YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: Reference\n"
+"Report-Msgid-Bugs-To: https://github.com/UCSCLibrary/SimpleVocabPlus/issues\n"
+"POT-Creation-Date: 2021-04-09 00:00-0000\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME \n"
+"Language-Team: LANGUAGE \n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
\ No newline at end of file
diff --git a/languages/template.pot b/languages/template.pot
new file mode 100644
index 0000000..0cf27c4
--- /dev/null
+++ b/languages/template.pot
@@ -0,0 +1,488 @@
+# Translation for the Simple Vocab Plus plugin for Omeka.
+# This file is distributed under the same license as the Omeka plugin.
+# FIRST AUTHOR , YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: Reference\n"
+"Report-Msgid-Bugs-To: https://github.com/UCSCLibrary/SimpleVocabPlus/issues\n"
+"POT-Creation-Date: 2021-04-09 00:00-0000\n"
+"PO-Revision-Date: 2021-04-10 08:53+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME \n"
+"Language-Team: LANGUAGE \n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: SimpleVocabPlusPlugin.php:200
+msgid "Simple Vocab Plus"
+msgstr ""
+
+#: SimpleVocabPlusPlugin.php:216
+msgid "
+"(Please note: this element has autosuggest activated using the Simple "
+"Vocab Plus plugin)"
+msgstr ""
+
+#: config_form.php:8
+msgid "Application scope"
+msgstr ""
+
+#: config_form.php:15
+msgid "Apply to Collections"
+msgstr ""
+
+#: config_form.php:19
+msgid ""
+"If checked, the plugin will apply to Collections metadata too "
+"(by default, this plugin only applies to Items metadata)."
+msgstr ""
+
+#: config_form.php:27
+msgid "Apply to Files"
+msgstr ""
+
+#: config_form.php:31
+msgid ""
+"If checked, the plugin will apply to Files metadata too "
+"(by default, this plugin only applies to Items metadata)."
+msgstr ""
+
+#: config_form.php:39
+msgid "Apply to Exhibit"
+msgstr ""
+
+#: config_form.php:44
+msgid ""
+"If checked, the plugin will apply to Exhibits metadata too "
+"(by default, this plugin only applies to Items metadata)."
+msgstr ""
+
+#: config_form.php:49
+msgid ""
+"The %s plugin is not installed or active. Install "
+"and activate the plugin in order to be able to configure notifications "
+"for new Exhibits."
+msgstr ""
+
+#: config_form.php:55
+msgid "Alerts"
+msgstr ""
+
+#: config_form.php:59
+msgid "Highlight autosuggest fields"
+msgstr ""
+
+#: config_form.php:63
+msgid "
+"Color hex code (e.g.: #ff0000) to highlight the fields that have autosuggest feature "
+"applied (blank means no highlight)."
+msgstr ""
+
+#: config_form.php:71
+msgid "Add autosuggest reminder"
+msgstr ""
+
+#: config_form.php:75
+msgid ""
+"Adds a notice to the description of fields that have autosuggest feature "
+"applied."
+msgstr ""
+
+#: config_form.php:81
+msgid "Checks"
+msgstr ""
+
+#: config_form.php:85
+msgid "Compare element values"
+msgstr ""
+
+#: config_form.php:89
+msgid "When examining an element, compare the recorded values with the vocabulary's terms."
+msgstr ""
+
+#: index.php:83
+#: index.php:156
+msgid "Assign Vocabulary"
+msgstr ""
+
+#: index.php:84
+#: index.php:265
+msgid "Create Vocabulary"
+msgstr ""
+
+#: index.php:85
+msgid "Edit Vocabulary"
+msgstr ""
+
+#: index.php:86
+msgid "Examine Element"
+msgstr ""
+
+#: index.php:92
+msgid "Assign Vocabulary to Metadata Element"
+msgstr ""
+
+#: index.php:95
+#: index.php:169
+#: index.php:333
+msgid "Element"
+msgstr ""
+
+#: index.php:99
+msgid ""
+"Select an element to assign it a vocabulary. Elements already assigned a vocabulary "
+"are marked with an asterisk (*)."
+msgstr ""
+
+#: index.php:106
+msgid "Source"
+msgstr ""
+
+#: index.php:110
+msgid ""
+"Choose the source of terms (note: if uncertain of values' consistency, you might want to "
+"examine them first)."
+msgstr ""
+
+#: index.php:113
+msgid "Self assign: values are retrieved from the element's recorded ones"
+msgstr ""
+
+#: index.php:116
+msgid "Multiple assign: values are retrieved from multiple elements of the repository"
+msgstr ""
+
+#: index.php:119
+msgid "Vocabulary: values are retrieved from a local/remote custom vocabulary"
+msgstr ""
+
+#: index.php:124
+#: index.php:172
+msgid "Source element(s)"
+msgstr ""
+
+#: index.php:128
+msgid "Select one or more elements to use as source."
+msgstr ""
+
+#: index.php:135
+msgid "Source vocabulary"
+msgstr ""
+
+#: index.php:139
+msgid "Select a vocabulary to enable the autosuggest feature for the above element."
+msgstr ""
+
+#: index.php:146
+msgid "Enforce values"
+msgstr ""
+
+#: index.php:150
+msgid ""
+"If selected, user will see a dropdown box and will have to choose one of the suggested values. Works "
+"only with local/remote vocabularies. Deselect the option to disable the feature."
+msgstr ""
+
+#: index.php:162
+msgid "Current Assignments"
+msgstr ""
+
+#: index.php:168
+msgid "Element Set"
+msgstr ""
+
+#: index.php:170
+msgid "Type"
+msgstr ""
+
+#: index.php:171
+msgid "Vocabulary"
+msgstr ""
+
+#: index.php:173
+msgid "Enforced"
+msgstr ""
+
+#: index.php:196
+msgid "yes"
+msgstr ""
+
+#: index.php:196
+msgid "no"
+msgstr ""
+
+#: index.php:206
+msgid "There are no suggest assignments."
+msgstr ""
+
+#: index.php:216
+msgid "Create new Vocabulary"
+msgstr ""
+
+#: index.php:229
+#: index.php:278
+msgid "Name"
+msgstr ""
+
+#: index.php:223
+msgid "Provide a name for your new vocabulary."
+msgstr ""
+
+#: index.php:229
+msgid "Location"
+msgstr ""
+
+#: index.php:233
+msgid ""
+"Choose whether you would like the repository to store your new vocabulary's terms, "
+"or rather to store the vocabulary in the cloud (using Google Drive or GitPages or "
+"other similar services)."
+msgstr ""
+
+#: index.php:236
+msgid "Define vocabulary and manually edit it here"
+msgstr ""
+
+#: index.php:239
+msgid "Import vocabulary from the cloud"
+msgstr ""
+
+#: index.php:244
+#: index.php:287
+msgid "URL"
+msgstr ""
+
+#: index.php:248
+msgid ""
+"If the vocabulary is stored in the cloud, this field shows the file URL for the "
+"vocabulary; any web server or cloud service can host this file. A plain text file "
+"is expected with one term per line; a line consisting of a sequence of 3 hyphens "
+"will be displayed as an empty line and can be used as separator for subgroups of "
+"terms; a line starting with 3 asterisks will be displayed as an unselectable, "
+"bolded subgroup title."
+msgstr ""
+"verrà mostrata come titolo di un sottogruppo, in grassetto e non selezionabile.
+
+#: index.php:255
+#: index.php:298
+msgid "Terms list"
+msgstr ""
+
+#: index.php:259
+msgid ""
+"Input all terms below, one term per line; a line consisting of a sequence of 3 "
+"hyphens will be displayed as an empty line and can be used as separator for "
+"subgroups of terms; a line starting with 3 asterisks will be displayed as an "
+"unselectable, bolded subgroup title. You can also drag and drop a text file here, "
+"to automatically paste its content."
+msgstr ""
+
+#: index.php:261
+msgid "Input all terms or drop a text file..."
+msgstr ""
+
+#: index.php:274
+msgid "Edit existing Vocabulary"
+msgstr ""
+
+#: index.php:281
+msgid "Select a Vocabulary to edit."
+msgstr ""
+
+#: index.php:291
+msgid ""
+"If the vocabulary is stored in the cloud, this field shows the file URL for the "
+"vocabulary. Any web server or cloud service can host this file (we recommend GitPages)."
+msgstr ""
+
+#: index.php:302
+msgid ""
+"The vocabulary's terms are displayed here, one term per line; a line consisting of a "
+"sequence of 3 hyphens will be displayed as an empty line and can be used as separator "
+"for subgroups of terms; a line starting with 3 asterisks will be displayed as an "
+"unselectable, bolded subgroup title."
+msgstr ""
+
+#: index.php:308
+msgid "Save Changes"
+msgstr ""
+
+#: index.php:309
+msgid "Delete Vocabulary"
+msgstr ""
+
+#: index.php:318
+msgid "Examine Element's values"
+msgstr ""
+
+#: index.php:322
+msgid ""
+"Before creating a vocabulary with values retrieved from the ones stored in the "
+"repository for a particular element, you might want to examine their consistency. "
+"Consider in fact the following caveats:"
+msgstr ""
+"le seguenti indicazioni:"
+
+#: index.php:325
+msgid "Vocabulary terms must not contain newlines (line breaks)."
+msgstr ""
+
+#: index.php:326
+msgid ""
+"Vocabulary terms are typically short and concise. If your existing texts are "
+"otherwise, avoid using a controlled vocabulary for this element."
+msgstr ""
+
+#: index.php:327
+msgid ""
+"Existing texts that are not in the vocabulary will be preserved - however, they cannot "
+"be selected in the item edit page, and will be deleted once you save the item."
+msgstr ""
+
+#: index.php:337
+msgid "Select an element to examine."
+msgstr ""
+
+# IndexController.php:94
+msgid "Select Below"
+msgstr ""
+
+# IndexController.php:150
+msgid "Short text"
+msgstr ""
+
+# IndexController.php:151
+msgid "Long text"
+msgstr ""
+
+# IndexController.php:152
+msgid "Contains newlines"
+msgstr ""
+
+# IndexController.php:153
+msgid "Contains HTML code"
+msgstr ""
+
+# SuggestController.php:29
+msgid "The element's suggest feature was successfully deleted."
+msgstr ""
+
+# SuggestController.php:35
+msgid "This will delete this Assignment, but not the assigned Vocabulary."
+msgstr ""
+
+# SuggestController.php:52
+msgid "Please select less source elements."
+msgstr ""
+
+# SuggestController.php:67
+msgid "local"
+msgstr ""
+
+# SuggestController.php:67
+msgid "remote"
+msgstr ""
+
+# SuggestController.php:72
+msgid "Please select an element to assign."
+msgstr ""
+
+# SuggestController.php:78
+msgid "Invalid suggest endpoint. No changes have been made."
+msgstr ""
+
+# SuggestController.php:89
+msgid "The element's suggest feature was successfully added."
+msgstr ""
+
+# VocabularyController.php:31
+msgid "You did not provide a name for your new vocabulary."
+msgstr ""
+
+# VocabularyController.php:34
+msgid "The name you provided for your new vocabulary is already in use."
+msgstr ""
+
+# VocabularyController.php:51
+msgid ""
+"Your new vocabulary has been created successfully. You may now assign "
+"it to metadata elements."
+msgstr ""
+
+# VocabularyController.php:62
+msgid "No vocabulary was chosen for editing."
+msgstr ""
+
+# VocabularyController.php:66
+msgid "There was a problem editing your vocabulary."
+msgstr ""
+
+# VocabularyController.php:79
+msgid "Remote vocabulary edited successfully."
+msgstr ""
+
+# VocabularyController.php:85
+msgid "No changes were made to the vocabulary."
+msgstr ""
+
+# VocabularyController.php:87
+msgid "Local vocabulary edited successfully."
+msgstr ""
+
+# VocabularyController.php:98
+msgid ""
+"At least one element is still assigned to this vocabulary. Delete the "
+"assignments before trying to delete the vocabulary."
+msgstr ""
+
+# VocabularyController.php:102
+msgid "Vocabulary deleted successfully."
+msgstr ""
+
+# VocabularyController.php:109
+msgid "This will delete the Vocabulary \"%s\", but not the values already stored in the repository."
+msgstr ""
+
+# VocabularyController.php:142
+msgid "There was an error processing your request."
+msgstr ""
+
+# element-texts.ajax:2
+msgid "No value for the selected element was found in the repository."
+msgstr ""
+
+# element-texts.ajax:4
+msgid ""
+"These are the values stored in the repository for the selected element; clicking on "
+"any of them results in a search for all Items including that particular value. "
+"Values not found in a local vocabulary assigned to the element will be marked in red "
+"(feature has to be enabled in plugin configuration)."
+msgstr ""
+
+# element-texts.ajax:7
+msgid "Count"
+msgstr ""
+
+# element-texts.ajax:8
+msgid "Value"
+msgstr ""
+
+# element-texts.ajax:9
+msgid "Warnings"
+msgstr ""
+
+# element-texts.ajax:26
+msgid "click to search for"
+msgstr ""
+
+# element-texts.ajax:26
+msgid "this page"
+msgstr ""
+
+# element-texts.ajax:26
+msgid "these pages"
+msgstr ""
diff --git a/libraries/SimpleVocabPlus/Controller/Plugin/Autosuggest.php b/libraries/SimpleVocabPlus/Controller/Plugin/Autosuggest.php
index a12af05..f001d22 100644
--- a/libraries/SimpleVocabPlus/Controller/Plugin/Autosuggest.php
+++ b/libraries/SimpleVocabPlus/Controller/Plugin/Autosuggest.php
@@ -1,80 +1,250 @@
-getModuleName();
- if (is_null($module)) {
- $module = 'default';
- }
- $controller = $request->getControllerName();
- $action = $request->getActionName();
-
- // Include all routes (route + controller + actions) that render an
- // element form, including actions requested via AJAX.
- $routes = array(
- array(
- 'module' => 'default',
- 'controller' => 'items',
- 'actions' => array('add', 'edit', 'element-form', 'change-type'),
- ),
- );
-
- // Allow plugins to add routes that contain form inputs rendered by
- // Omeka_View_Helper_ElementForm::_displayFormInput().
- $routes = apply_filters('sv_suggest_routes', $routes);
-
- // Iterate the defined routes.
- foreach ($routes as $route) {
- // Set the autosuggest if the current action matches a defined route.
- if ($route['module'] === $module
- && $route['controller'] === $controller
- && in_array($action, $route['actions'])
- ) {
- // Iterate the elements that are assigned to a suggest endpoint.
- $svSuggests = $db->getTable('SvpAssign')->findAll();
- foreach ($svSuggests as $svSuggest) {
- $element = $db->getTable('Element')->find($svSuggest->element_id);
- $elementSet = $db->getTable('ElementSet')->find($element->element_set_id);
-
- // Add the autosuggest JavaScript to the JS queue.
- $view = Zend_Registry::get('view');
- $view->headScript()->captureStart();
-?>
-// Add autosuggest to name . ':' . $element->name; ?>. Used by the Simple Vocab Plus plugin.
-jQuery(document).bind('omeka:elementformload', function(event) {
- jQuery('#element-id; ?> textarea').autocomplete({
- minLength: 2,
- source: url('simple-vocab-plus/endpoint/suggest-proxy/element-id/' . $element->id)); ?>
- });
-});
-headScript()->captureEnd();
- }
-
- // Once the JavaScript is applied there is no need to continue
- // looping the defined routes.
- break;
- }
- }
- }
-}
+ 'default',
+ 'controller' => 'items',
+ 'actions' => array('add', 'edit', 'change-type')
+ ),
+ array(
+ 'module' => 'default',
+ 'controller' => 'elements',
+ 'actions' => array('element-form')
+ )
+ );
+
+ /**
+ * Cached vocab terms.
+ */
+ protected $_svpSuggestedTerms;
+ protected $_elementText;
+
+ public function __construct()
+ {
+ $this->backgroundColor = get_option('simple_vocab_plus_fields_highlight');
+ $this->backgroundColorString = (preg_match('/#([a-f0-9]{3}){1,2}\b/i', $this->backgroundColor) ? 'background-color: ' . $this->backgroundColor : '');
+ }
+
+ /**
+ * Add autosuggest only during defined routes.
+ */
+ public function preDispatch(Zend_Controller_Request_Abstract $request)
+ {
+ $db = get_db();
+
+ // Set NULL modules to default. Some routes do not have a default
+ // module, which resolves to NULL.
+ $module = $request->getModuleName();
+ if (is_null($module)) {
+ $module = 'default';
+ }
+ $controller = $request->getControllerName();
+ $action = $request->getActionName();
+
+ $filterFiles = get_option('simple_vocab_plus_files');
+ if ($filterFiles) {
+ // Add the file add/edit route if configured to.
+ $this->_defaultRoutes[] = array(
+ 'module' => 'default',
+ 'controller' => 'files',
+ 'actions' => array('add', 'edit')
+ );
+ }
+
+ $filterCollections = get_option('simple_vocab_plus_collections');
+ if ($filterCollections) {
+ // Add the collections add/edit route if configured to.
+ $this->_defaultRoutes[] = array(
+ 'module' => 'default',
+ 'controller' => 'collections',
+ 'actions' => array('add', 'edit')
+ );
+ }
+
+ $filterExhibits = (get_option('simple_vocab_plus_exhibits') && plugin_is_active('ExhibitBuilder'));
+ if ($filterExhibits) {
+ // Add the exhibit add/edit route if configured to.
+ $this->_defaultRoutes[] = array(
+ 'module' => 'default',
+ 'controller' => 'exhibits',
+ 'actions' => array('add', 'edit')
+ );
+ }
+
+ // Allow plugins to add routes that contain form inputs rendered by
+ // Omeka_View_Helper_ElementForm::_displayFormInput().
+ $routes = apply_filters('svp_suggest_routes', $this->_defaultRoutes);
+
+ // Iterate the defined routes.
+ foreach ($routes as $route) {
+ // Set the autosuggest if the current action matches a defined route.
+ if ($route['module'] === $module
+ && $route['controller'] === $controller
+ && in_array($action, $route['actions'])
+ ) {
+ // Iterate the elements that are assigned to a suggest endpoint.
+ $svpAssigns = $db->getTable('SvpAssign')->findAll();
+ foreach ($svpAssigns as $svpAssign) {
+ $element = $db->getTable('Element')->find($svpAssign->element_id);
+ $elementSet = $db->getTable('ElementSet')->find($element->element_set_id);
+ $elementTextTable = $db->getTable('ElementText');
+ $svpTermTable = $db->getTable('SvpTerm');
+
+ if (!$svpAssign->enforced) {
+ // Add the autosuggest JavaScript to the JS queue.
+ $view = Zend_Registry::get('view');
+ $view->headScript()->captureStart();
+?>
+// Add autosuggest to name . ':' . $element->name; ?>. Used by the Simple Vocab Plus plugin.
+jQuery(document).bind('omeka:elementformload', function(event) {
+ jQuery('#element-id; ?> textarea').autocomplete({
+ minLength: 2,
+ source: url('simple-vocab-plus/endpoint/suggest-proxy/element-id/' . $element->id)); ?>
+ });
+});
+headScript()->captureEnd();
+ } else {
+ // Retrieve values to populate select box.
+ switch ($svpAssign->type) {
+ case 'self':
+ $select = $elementTextTable->getSelect();
+ $selectfrom(array(),'text')
+ ->where('record_type = ?', 'Item')
+ ->where('element_id = ?', $element->id)
+ ->group('text')
+ ->order('text ASC');
+ $this->_svpSuggestedTerms[$element->id] = $elementTextTable->fetchObjects($select);
+ break;
+ case 'multi':
+ $select = $elementTextTable->getSelect();
+ $select(array(),'text')
+ ->where('record_type = ?', 'Item')
+ ->where('element_id IN (' . $svpAssign->sources_id . ')')
+ ->group('text')
+ ->order('text ASC');
+ $this->_svpSuggestedTerms[$element->id] = $elementTextTable->fetchObjects($select);
+ break;
+ default:
+ $select = $svpTermTable->getSelect();
+ $select->from(array(), array('text' => 'term'))
+ ->where('vocab_id = ?', $svpAssign->vocab_id)
+ ->order('id ASC');
+ $this->_svpSuggestedTerms[$element->id] = $svpTermTable->fetchObjects($select);
+ }
+ }
+
+ add_filter(
+ array('ElementInput', 'Item', $elementSet->name, $element->name),
+ array($this, 'filterElementInput')
+ );
+ // Add the file filter if configured to.
+ if ($filterFiles) {
+ add_filter(
+ array('ElementInput', 'File', $elementSet->name, $element->name),
+ array($this, 'filterElementInput')
+ );
+ }
+ // Add the collection filter if configured to.
+ if ($filterCollections) {
+ add_filter(
+ array('ElementInput', 'Collection', $elementSet->name, $element->name),
+ array($this, 'filterElementInput')
+ );
+ }
+ // Add the exhibit filter if configured to.
+ if ($filterExhibits) {
+ add_filter(
+ array('ElementInput', 'Exhibit', $elementSet->name, $element->name),
+ array($this, 'filterElementInput')
+ );
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Filter the element input.
+ *
+ * @param array $components
+ * @param array $args
+ * @return array
+ */
+ public function filterElementInput($components, $args)
+ {
+ // Use the cached vocab terms
+ if (empty($this->_svpSuggestedTerms[$args['element']->id])) {
+ // case autosuggest, values not enforced
+ $components['input'] = get_view()->formTextarea(
+ $args['input_name_stem'] . '[text]',
+ $args['value'],
+ array('cols' => 50, 'rows' => 3, 'style' => $this->backgroundColorString)
+ );
+ } else {
+ // case autosuggest, values enforced
+ $components['input'] = get_view()->formSelect(
+ $args['input_name_stem'] . '[text]',
+ $args['value'],
+ array('style' => $this->backgroundColorString),
+ $this->getTermsList($this->_svpSuggestedTerms[$args['element']->id])
+ );
+ $components['html_checkbox'] = false;
+ }
+
+ return $components;
+ }
+
+ private function getTermsList($terms)
+ {
+ $selectTerms = array('' => __('Select Below'));
+ $blanks_count = 1;
+ $terms_count = count($terms);
+
+ for ($i = 0; $i < $terms_count; $i++) {
+ $term_text = $terms[$i]['text'];
+ if ($term_text == '---') {
+ $selectTerms[str_repeat(' ', $blanks_count)] = array();
+ $blanks_count++;
+ } elseif (substr($term_text, 0, 3) == '***') {
+ $stem = substr($term_text, 3);
+ $subterms = array();
+ $i++;
+ while ($i < $terms_count) {
+ $term_text = $terms[$i]['text'];
+ if ($term_text != '---' && substr($term_text, 0, 3) != '***') {
+ $subterms[$term_text] = $term_text;
+ $i++;
+ } else {
+ $i = $i - 1;
+ break;
+ }
+ }
+ $selectTerms[$stem] = $subterms;
+ } else {
+ $selectTerms[$term_text] = $term_text;
+ }
+ }
+
+ return $selectTerms;
+ }
+}
diff --git a/models/SvpAssign.php b/models/SvpAssign.php
index 5342ebf..81a653f 100644
--- a/models/SvpAssign.php
+++ b/models/SvpAssign.php
@@ -1,19 +1,23 @@
-id;
- $url = $this->url;
- if ($url == "local") {
- return;
- }
- //$newText = $this->_streamFetch($url);
- $newText = $this->_curlFetch($url);
- //die($newText);
- $newTerms = get_db()->getTable('SvpTerm')->updateFromText($id,$newText);
- }
-
- private function _streamFetch($Url)
- {
- ob_start();
- $context_options = array(
- 'http' => array(
- 'method '=> 'GET',
- 'header' => 'Accept-language: en\r\n'
- )
- );
- $context = stream_context_create($context_options);
- $contents = file_get_contents($Url, NULL, $context);
- ob_end_clean();
- //$contents = file_get_contents($Url);
- return $contents;
- }
-
- private function _curlFetch($url)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $output = curl_exec($ch);
- curl_close($ch);
- return($output);
- }
-}
+id;
+ $url = $this->url;
+ if ($url == "local") {
+ return;
+ }
+ //$newText = $this->_streamFetch($url);
+ $newText = $this->_curlFetch($url);
+ // removes html tags
+ $newText = strip_tags($newText);
+ //die($newText);
+ $newTerms = get_db()->getTable('SvpTerm')->updateFromText($id,$newText);
+ }
+
+ private function _streamFetch($url)
+ {
+ ob_start();
+ $context_options = array(
+ 'http' => array(
+ 'method '=> 'GET',
+ 'header' => 'Accept-language: en\r\n'
+ )
+ );
+ $context = stream_context_create($context_options);
+ $contents = file_get_contents($url, NULL, $context);
+ ob_end_clean();
+ //$contents = file_get_contents($url);
+ return $contents;
+ }
+
+ private function _curlFetch($url)
+ {
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ $output = curl_exec($ch);
+ curl_close($ch);
+ return($output);
+ }
+}
\ No newline at end of file
diff --git a/models/Table/SvpAssign.php b/models/Table/SvpAssign.php
index 910c0c6..ad3fd5e 100644
--- a/models/Table/SvpAssign.php
+++ b/models/Table/SvpAssign.php
@@ -1,43 +1,43 @@
-getSelect()->where('element_id = ?', $elementId);
- return $this->fetchObjects($select);
- }
-}
+getSelect()->where('element_id = ?', $elementId);
+ return $this->fetchObjects($select);
+ }
+}
\ No newline at end of file
diff --git a/models/Table/SvpTerm.php b/models/Table/SvpTerm.php
index 5735a0f..3c0988a 100644
--- a/models/Table/SvpTerm.php
+++ b/models/Table/SvpTerm.php
@@ -1,70 +1,73 @@
-_parseText($text);
- foreach($terms as $term) {
- $term = trim($term);
- $svpTerm = new SvpTerm();
- $svpTerm->vocab_id = $vocab_id;
- $svpTerm->term = $term;
- $svpTerm->save();
- }
- return true;
- }
-
- public function updateFromText($vocab_id, $text)
- {
- // set this to all rows
- $deleted = array();
- $added = array();
- $termObjs = $this->findBy(array('vocab_id' => $vocab_id));
- $terms = $this->_parseText($text);
- foreach ($termObjs as $termObj) {
- $deleted[] = trim($termObj->term);
- }
-
- foreach ($terms as $term) {
- $i = array_search(trim($term), $deleted);
- if ($i !== false) {
- unset($deleted[$i]);
- } else {
- $added[] = $term;
- }
- }
-
- $db = $this->_db;
- foreach ($deleted as $delete) {
- $sql = "DELETE FROM `{$db->SvpTerm}` WHERE vocab_id = ? AND term = ?";
- $bind = array($vocab_id, trim($delete));
- get_db()->query($sql, $bind);
- }
-
- foreach ($added as $add) {
- $term = trim($term);
- $svpTerm = new SvpTerm();
- $svpTerm->vocab_id = $vocab_id;
- $svpTerm->term = $add;
- $svpTerm->save();
- }
-
- if (!empty($added) && !empty($deleted)) {
- return array(
- 'add' => array_values($added),
- 'delete' => array_values($deleted),
- );
- }
-
- return false;
- }
-
- private function _parseText($text)
- {
- $text = str_replace("\n\r", "\n", $text);
- $text = str_replace("\r", '', $text);
- $terms = explode("\n", $text);
- $terms = array_map('trim', $terms);
- return $terms;
- }
-}
+_parseText($text);
+ foreach($terms as $term) {
+ $term = trim($term);
+ if ($term != '') {
+ $svpTerm = new SvpTerm();
+ $svpTerm->vocab_id = $vocab_id;
+ $svpTerm->term = $term;
+ $svpTerm->save();
+ }
+ }
+ return true;
+ }
+
+ public function updateFromText($vocab_id, $text)
+ {
+ $added = array();
+ $deleted = array();
+ $termObjs = $this->findBy(array('vocab_id' => $vocab_id));
+ $terms = $this->_parseText($text);
+
+ foreach ($termObjs as $termObj) {
+ $deleted[] = trim($termObj->term);
+ }
+
+ foreach ($terms as $term) {
+ $term = trim($term);
+ if ($term != '') {
+ $i = array_search(trim($term), $deleted);
+ if ($i !== false) {
+ unset($deleted[$i]);
+ } else {
+ $added[] = $term;
+ }
+ }
+ }
+
+ $db = $this->_db;
+ foreach ($deleted as $delete) {
+ $sql = "DELETE FROM `{$db->SvpTerm}` WHERE vocab_id = ? AND term = ?";
+ $bind = array($vocab_id, trim($delete));
+ get_db()->query($sql, $bind);
+ }
+
+ foreach ($added as $add) {
+ $term = trim($term);
+ $svpTerm = new SvpTerm();
+ $svpTerm->vocab_id = $vocab_id;
+ $svpTerm->term = $add;
+ $svpTerm->save();
+ }
+
+ return array(
+ 'add' => array_values($added),
+ 'delete' => array_values($deleted),
+ );
+
+ return false;
+ }
+
+ private function _parseText($text)
+ {
+ $text = str_replace("\n\r", "\n", $text);
+ $text = str_replace("\r", '', $text);
+ $terms = explode("\n", $text);
+ $terms = array_map('trim', $terms);
+ return $terms;
+ }
+}
diff --git a/models/Table/SvpVocab.php b/models/Table/SvpVocab.php
index f30f398..3cb96db 100644
--- a/models/Table/SvpVocab.php
+++ b/models/Table/SvpVocab.php
@@ -1,18 +1,28 @@
-name = $name;
- $vocab->url = $url;
- $save = $vocab->save();
- return $vocab;
- }
-
- public function updateAll()
- {
- foreach($this->findAll() as $vocab) {
- $vocab->update();
- }
- }
-}
+name = $name;
+ $vocab->url = $url;
+ $save = $vocab->save();
+ return $vocab;
+ }
+
+ public function deleteVocab($vocab_id)
+ {
+ $db = $this->_db;
+ $sql1 = "DELETE FROM `{$db->SvpTerm}` WHERE vocab_id = $vocab_id";
+ $db->query($sql1);
+ $sql2 = "DELETE FROM `{$db->SvpVocab}` WHERE id = $vocab_id";
+ $db->query($sql2);
+ }
+
+ public function updateAll()
+ {
+ foreach($this->findAll() as $vocab) {
+ $vocab->update();
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin.ini b/plugin.ini
index c663a5f..a104480 100644
--- a/plugin.ini
+++ b/plugin.ini
@@ -1,10 +1,10 @@
[info]
name="Simple Vocab Plus"
-author="UC Santa Cruz University Library"
-description="Allows for cloud based vocabulary definition and autosuggest features for Omeka elements"
+author="UC Santa Cruz University Library & Daniel Berthereau & Daniele Binaghi"
+description="Allows administrators to create, edit and update controlled vocabularies, either defined in the repository or in the cloud"
license="GPLv3"
link="https://github.com/UCSCLibrary/SimpleVocabPlus"
support_link="https://github.com/UCSCLibrary/SimpleVocabPlus/issues"
omeka_minimum_version="2.1"
omeka_target_version="2.4.1"
-version="2.4"
+version="3.1.2"
diff --git a/views/admin/css/SimpleVocabPlus.css b/views/admin/css/SimpleVocabPlus.css
new file mode 100644
index 0000000..3a523ef
--- /dev/null
+++ b/views/admin/css/SimpleVocabPlus.css
@@ -0,0 +1,11 @@
+table.centered td {
+ vertical-align: middle;
+}
+
+table.boldheaders thead th {
+ font-weight: bold;
+}
+
+table.striped tr:nth-child(even) {
+ background-color: #f2f2f2;
+}
diff --git a/views/admin/index/element-texts.ajax.php b/views/admin/index/element-texts.ajax.php
new file mode 100644
index 0000000..6fb8df4
--- /dev/null
+++ b/views/admin/index/element-texts.ajax.php
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+