From 20f79e5d5570e62aa525ef9e55a0ad1c895c80af Mon Sep 17 00:00:00 2001 From: Anurag Date: Wed, 14 Jan 2015 16:20:51 -0500 Subject: [PATCH 01/20] Extend SolrSearch to index all items, regardless of their public / private status, which gets added to the index as well. We then in turn modify the search query based on whether the user_role has sufficient privileges to view non-public items by utilizing Omeka's is_allowed('Items','showNotPublic')) --- .DS_Store | Bin 0 -> 6148 bytes SolrSearchPlugin.php | 29 ++++++++++---------------- controllers/ResultsController.php | 30 +++++++++++++++++++++++---- forms/SolrSearch_Form_Results.php | 11 +++++++++- helpers/SolrSearch_Helpers_Index.php | 7 ++++++- lib/.DS_Store | Bin 0 -> 6148 bytes lib/SolrSearch/.DS_Store | Bin 0 -> 6148 bytes lib/SolrSearch/Addon/Indexer.php | 4 ++++ solr-core/.DS_Store | Bin 0 -> 6148 bytes solr-core/omeka/.DS_Store | Bin 0 -> 6148 bytes 10 files changed, 57 insertions(+), 24 deletions(-) create mode 100644 .DS_Store create mode 100644 lib/.DS_Store create mode 100644 lib/SolrSearch/.DS_Store create mode 100644 solr-core/.DS_Store create mode 100644 solr-core/omeka/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..651986faa7a81ce2e080a695da41436df5844d0c GIT binary patch literal 6148 zcmeHKOHRW;41K1h6m`=j%eepxZV*-F1Y7{x6oC{7O6WdE@3TEY8ps+IWJfd4@n=3y z%1jJEHplu7SOZwHDT*o+qUK50MGjsN#m0C?U-$cF*S5{XK<8-EwJ-35noo;w>tA7S z#!qy_hR=aovBgU~)79avG+*I`u?;@T46=k7&9B&vJgMm#y^Y`D)@JN*7~SW{S*$4- z2nK?IVBl{vpjQuNxpIs?7zhS}fiDL1d`N7HRmQ>5jt+KK0ubjkn^4zULUU5aD&yct z4@Eqc=&6!R4Doc@Q;w@L4vwA<$;F4{naAQqY<7;HEF4lfMjs3W10@49e_iYSf6q^5 zvdAw};w=~m2L2fXGT%OIH{4XdTYqd%@7l!n$flxkgDMp2#ZLfV^c=Y{r~8xYjH@yZ Vjyj6kEu9!Y0!B!5!N4yta01ToGra%+ literal 0 HcmV?d00001 diff --git a/SolrSearchPlugin.php b/SolrSearchPlugin.php index 860f716f..a9515be4 100644 --- a/SolrSearchPlugin.php +++ b/SolrSearchPlugin.php @@ -54,11 +54,11 @@ public function hookUninstall() $this->_db->query(<<_db->prefix}solr_search_fields SQL -); + ); $this->_db->query(<<_db->prefix}solr_search_excludes SQL -); + ); try { $solr = SolrSearch_Helpers_Index::connect(); @@ -189,20 +189,11 @@ public function hookAfterSaveItem($args) $solr = SolrSearch_Helpers_Index::connect(); - // If the item is public, add/update the Solr document. - if ($item['public'] == true) { - $doc = SolrSearch_Helpers_Index::itemToDocument($item); - $solr->addDocuments(array($doc)); - $solr->commit(); - $solr->optimize(); - } - - // If the item's is being set private, remove it from Solr. - else { - $solr->deleteById('Item_' . $item['id']); - $solr->commit(); - $solr->optimize(); - } + // Both public and private items will be indexed + $doc = SolrSearch_Helpers_Index::itemToDocument($item); + $solr->addDocuments(array($doc)); + $solr->commit(); + $solr->optimize(); } @@ -323,7 +314,7 @@ protected function _createSolrTables() PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; SQL -); + ); $this->_db->query(<<_db->prefix}solr_search_excludes ( @@ -332,7 +323,7 @@ protected function _createSolrTables() PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; SQL -); + ); } @@ -395,6 +386,7 @@ protected function _setOptions() set_option('solr_search_hl', '1'); set_option('solr_search_hl_snippets', '1'); set_option('solr_search_hl_fragsize', '250'); + set_option('solr_search_display_private_items', '1'); } @@ -411,6 +403,7 @@ protected function _clearOptions() delete_option('solr_search_hl'); delete_option('solr_search_hl_snippets'); delete_option('solr_search_hl_fragsize'); + delete_option('solr_search_display_private_items'); } diff --git a/controllers/ResultsController.php b/controllers/ResultsController.php index cea50db7..7d9cafa9 100644 --- a/controllers/ResultsController.php +++ b/controllers/ResultsController.php @@ -44,8 +44,25 @@ public function indexAction() $page = $this->_request->page ? $this->_request->page : 1; $start = ($page-1) * $limit; + + // determine whether to display private items or not + // items will only be displayed if: + // solr_search_display_private_items has been enabled in the Solr Search admin panel + // user is logged in + // user_role has sufficient permissions + + $user = current_user(); + if(get_option('solr_search_display_private_items') + && $user + && is_allowed('Items','showNotPublic')) { + // limit to public items + $limitToPublicItems = false; + } else { + $limitToPublicItems = true; + } + // Execute the query. - $results = $this->_search($start, $limit); + $results = $this->_search($start, $limit, $limitToPublicItems); // Set the pagination. Zend_Registry::set('pagination', array( @@ -67,7 +84,7 @@ public function indexAction() * @param int $limit Limit per page * @return SolrResultDoc Solr results */ - protected function _search($offset, $limit) + protected function _search($offset, $limit, $limitToPublicItems = true) { // Connect to Solr. @@ -77,7 +94,7 @@ protected function _search($offset, $limit) $params = $this->_getParameters(); // Construct the query. - $query = $this->_getQuery(); + $query = $this->_getQuery($limitToPublicItems); // Execute the query. return $solr->search($query, $offset, $limit, $params); @@ -90,7 +107,7 @@ protected function _search($offset, $limit) * * @return string The Solr query. */ - protected function _getQuery() + protected function _getQuery($limitToPublicItems = true) { // Get the `q` GET parameter. @@ -106,6 +123,11 @@ protected function _getQuery() // Form the composite Solr query. if (!empty($facet)) $query .= " AND {$facet}"; + // Limit the query to public items if required + if($limitToPublicItems) { + $query .= ' AND public:"true"'; + } + return $query; } diff --git a/forms/SolrSearch_Form_Results.php b/forms/SolrSearch_Form_Results.php index 15d6a166..628b3b0e 100644 --- a/forms/SolrSearch_Form_Results.php +++ b/forms/SolrSearch_Form_Results.php @@ -89,6 +89,14 @@ public function init() ) )); + // Display Private Items: + $this->addElement('checkbox', 'solr_search_display_private_items', array( + 'label' => __('Display private items'), + 'description' => __('Display private items for all user roles with sufficient permission to view them.'), + 'value' => get_option('solr_search_display_private_items') + )); + + // Submit: $this->addElement('submit', 'submit', array( 'label' => __('Save Settings') @@ -99,7 +107,8 @@ public function init() 'solr_search_hl_snippets', 'solr_search_hl_fragsize', 'solr_search_facet_sort', - 'solr_search_facet_limit' + 'solr_search_facet_limit', + 'solr_search_display_private_items' ), 'fields'); $this->addDisplayGroup(array( diff --git a/helpers/SolrSearch_Helpers_Index.php b/helpers/SolrSearch_Helpers_Index.php index feeba7eb..64379c91 100644 --- a/helpers/SolrSearch_Helpers_Index.php +++ b/helpers/SolrSearch_Helpers_Index.php @@ -86,6 +86,9 @@ public static function itemToDocument($item) $doc->setField('model', 'Item'); $doc->setField('modelid', $item->id); + // extend $doc to to include and items public / private status + $doc->setField('public', $item->public); + // Title: $title = metadata($item, array('Dublin Core', 'Title')); $doc->setField('title', $title); @@ -222,7 +225,9 @@ public static function indexAll($options=array()) $table = $db->getTable('Item'); $select = $table->getSelect(); - $table->filterByPublic($select, true); + // Removed in order to index both public and private items + // $table->filterByPublic($select, true); + $table->applySorting($select, 'id', 'ASC'); $excTable = $db->getTable('SolrSearchExclude'); diff --git a/lib/.DS_Store b/lib/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..090f5e6fad7da450416e1147c6c62d7c416760c8 GIT binary patch literal 6148 zcmeHKJ5EC}5S)b+5ouCV`U>2@ijouL0zeXp;z>^e(Z7mwaWrN>1<`{pX`)$aJ@$IX zmZy087JzL&k59lFz>@BWFCXUS`|dNltB4WlJY$a&Uhs|s-e%c<2b}vr-iU#`U;N|8 zVR#+K!4qUsKnh3!DIf);z{M1((z;w->_i5R9^>xENd(qYwnSlw*Zp;+9`^IN3DdZI=tAO+49 zxX;I1aPyc^T(n<7HQ|7J$_#9JW&5|{@8dp{(&X$~z_{ndfNTL5T-v>WE$OF)w)pgFWuMFytPJ!l+N zZ$m8a$Dt|q<addField('model', $addon->table); $doc->addField('modelid', $record->id); + // extend $doc to include public / private records + // not sure if required + //$doc->addField('public', $record->public); + $titleField = $addon->getTitleField(); foreach ($addon->fields as $field) { $solrName = $this->makeSolrName($addon, $field->name); diff --git a/solr-core/.DS_Store b/solr-core/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..02208806101c34ca50a0c0aeff108d85d1de991a GIT binary patch literal 6148 zcmeH~O=`nH427lCg+Mo6W;vT2pf?yydV*Y_ZQNB|yeQev(ev~}z;4$egeQ>Rj7CcE zxA0gZqQiN773oD}3pbU$g_SAx&oax8e95aPw29|52p(r#G$ECDT+fY#I&iVRGn z6&kJTV~FLw9a^%krnb;%7tP^A^PknG7??)8Xu$@i)rElsNMJ?aDfYeH|8MaB=Koa- zw?+>D-EdxP0j;Sm6d4#l1RMhc I3EY&x1;OGIasU7T literal 0 HcmV?d00001 diff --git a/solr-core/omeka/.DS_Store b/solr-core/omeka/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..878677845a65fa897646859996ebdbbabb735c39 GIT binary patch literal 6148 zcmeH~JqiLr422WjLa^D=avBfd4F=H@cmYwd61NchIl3=D2(H#5@&d^>$xK-G6+0Ud z(e?eb66r-`1~ zw}U0m)np4syJ!v{nom}nVqhBWq6G;|tAl|GP=S#G)5v?f|F`f@^Z%%YDHWgsf2M$T zo84xOm&&{K?e(m_&#J8(9Q5M|FFyfD>?&Ts-LPM50oG&-q5|WOfXl!@1-`1l11psh AsQ>@~ literal 0 HcmV?d00001 From 8eaf6327895576361c8847ed5234e92eefe22bad Mon Sep 17 00:00:00 2001 From: Anurag Date: Wed, 14 Jan 2015 16:23:38 -0500 Subject: [PATCH 02/20] Ignore .DS_Store --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 1 + lib/.DS_Store | Bin 6148 -> 0 bytes lib/SolrSearch/.DS_Store | Bin 6148 -> 0 bytes solr-core/.DS_Store | Bin 6148 -> 0 bytes solr-core/omeka/.DS_Store | Bin 6148 -> 0 bytes 6 files changed, 1 insertion(+) delete mode 100644 .DS_Store delete mode 100644 lib/.DS_Store delete mode 100644 lib/SolrSearch/.DS_Store delete mode 100644 solr-core/.DS_Store delete mode 100644 solr-core/omeka/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 651986faa7a81ce2e080a695da41436df5844d0c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKOHRW;41K1h6m`=j%eepxZV*-F1Y7{x6oC{7O6WdE@3TEY8ps+IWJfd4@n=3y z%1jJEHplu7SOZwHDT*o+qUK50MGjsN#m0C?U-$cF*S5{XK<8-EwJ-35noo;w>tA7S z#!qy_hR=aovBgU~)79avG+*I`u?;@T46=k7&9B&vJgMm#y^Y`D)@JN*7~SW{S*$4- z2nK?IVBl{vpjQuNxpIs?7zhS}fiDL1d`N7HRmQ>5jt+KK0ubjkn^4zULUU5aD&yct z4@Eqc=&6!R4Doc@Q;w@L4vwA<$;F4{naAQqY<7;HEF4lfMjs3W10@49e_iYSf6q^5 zvdAw};w=~m2L2fXGT%OIH{4XdTYqd%@7l!n$flxkgDMp2#ZLfV^c=Y{r~8xYjH@yZ Vjyj6kEu9!Y0!B!5!N4yta01ToGra%+ diff --git a/.gitignore b/.gitignore index dbc004bf..c64faf24 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ Gemfile.lock node_modules/ vendor pkg +.DS_Store tests/phpunit/solr.ini solr-core/collection1/data diff --git a/lib/.DS_Store b/lib/.DS_Store deleted file mode 100644 index 090f5e6fad7da450416e1147c6c62d7c416760c8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKJ5EC}5S)b+5ouCV`U>2@ijouL0zeXp;z>^e(Z7mwaWrN>1<`{pX`)$aJ@$IX zmZy087JzL&k59lFz>@BWFCXUS`|dNltB4WlJY$a&Uhs|s-e%c<2b}vr-iU#`U;N|8 zVR#+K!4qUsKnh3!DIf);z{M1((z;w->_i5R9^>xENd(qYwnSlw*Zp;+9`^IN3DdZI=tAO+49 zxX;I1aPyc^T(n<7HQ|7J$_#9JW&5|{@8dp{(&X$~z_{ndfNTL5T-v>WE$OF)w)pgFWuMFytPJ!l+N zZ$m8a$Dt|q<Rj7CcE zxA0gZqQiN773oD}3pbU$g_SAx&oax8e95aPw29|52p(r#G$ECDT+fY#I&iVRGn z6&kJTV~FLw9a^%krnb;%7tP^A^PknG7??)8Xu$@i)rElsNMJ?aDfYeH|8MaB=Koa- zw?+>D-EdxP0j;Sm6d4#l1RMhc I3EY&x1;OGIasU7T diff --git a/solr-core/omeka/.DS_Store b/solr-core/omeka/.DS_Store deleted file mode 100644 index 878677845a65fa897646859996ebdbbabb735c39..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~JqiLr422WjLa^D=avBfd4F=H@cmYwd61NchIl3=D2(H#5@&d^>$xK-G6+0Ud z(e?eb66r-`1~ zw}U0m)np4syJ!v{nom}nVqhBWq6G;|tAl|GP=S#G)5v?f|F`f@^Z%%YDHWgsf2M$T zo84xOm&&{K?e(m_&#J8(9Q5M|FFyfD>?&Ts-LPM50oG&-q5|WOfXl!@1-`1l11psh AsQ>@~ From d7c77329b1b13d6a3a3712c10bebf4b23ba3b6a4 Mon Sep 17 00:00:00 2001 From: Anuragji Date: Fri, 23 Jan 2015 15:33:02 -0500 Subject: [PATCH 03/20] Fix unescaped characters in facet URL When a facet includes special characters, it is necessary to escape them properly. https://github.com/scholarslab/SolrSearch/issues/115 --- helpers/SolrSearch_Helpers_Facet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/SolrSearch_Helpers_Facet.php b/helpers/SolrSearch_Helpers_Facet.php index 453dfed0..d77c6d07 100644 --- a/helpers/SolrSearch_Helpers_Facet.php +++ b/helpers/SolrSearch_Helpers_Facet.php @@ -57,7 +57,7 @@ public static function makeUrl($facets) } // Implode on ` AND `. - $fParam = implode(' AND ', $fParam); + $fParam = urlencode(implode(' AND ', $fParam)); // Get the `q` parameter, reverting to ''. $qParam = array_key_exists('q', $_GET) ? $_GET['q'] : ''; From b2da895b335c9a92305af9867fd95ad882a2c0c6 Mon Sep 17 00:00:00 2001 From: Anuragji Date: Thu, 18 Jun 2015 17:07:12 -0400 Subject: [PATCH 04/20] Test if $facet is set before deleting Add testing to make sure we only attempt to delete a facet which is actually set. --- SolrSearchPlugin.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SolrSearchPlugin.php b/SolrSearchPlugin.php index a9515be4..2864ccb3 100644 --- a/SolrSearchPlugin.php +++ b/SolrSearchPlugin.php @@ -265,7 +265,10 @@ public function hookBeforeDeleteElement($args) { $table = $this->_db->getTable('SolrSearchField'); $facet = $table->findByElement($args['record']); - $facet->delete(); + + if(!empty($facet)) { + $facet->delete(); + } } From 4a3ca294e81e1a1fbdeb75615582208ac0c29d69 Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Tue, 23 Jun 2015 19:22:13 +0000 Subject: [PATCH 05/20] Stripped out whitespace. --- SolrSearchPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SolrSearchPlugin.php b/SolrSearchPlugin.php index 2864ccb3..0adde292 100644 --- a/SolrSearchPlugin.php +++ b/SolrSearchPlugin.php @@ -265,7 +265,7 @@ public function hookBeforeDeleteElement($args) { $table = $this->_db->getTable('SolrSearchField'); $facet = $table->findByElement($args['record']); - + if(!empty($facet)) { $facet->delete(); } From ebd7aef799e2a72a943bd427a216ad02bef828a6 Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Wed, 15 Jul 2015 18:12:39 +0000 Subject: [PATCH 06/20] Clean up invalid characters. Fixes #119. We'll probably need to keep adding to `$to_remove` as time goes on. --- controllers/ResultsController.php | 14 +++++++++++--- .../ResultsController/SearchItemsTest.php | 12 ++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/controllers/ResultsController.php b/controllers/ResultsController.php index 7d9cafa9..f1a61010 100644 --- a/controllers/ResultsController.php +++ b/controllers/ResultsController.php @@ -113,9 +113,17 @@ protected function _getQuery($limitToPublicItems = true) // Get the `q` GET parameter. $query = $this->_request->q; - // If defined, replace `:`; otherwise, revert to `*:*` - if (!empty($query)) $query = str_replace(':', ' ', $query); - else $query = '*:*'; + // If defined, replace `:`; otherwise, revert to `*:*`. + // Also, clean it up some. + if (!empty($query)) { + $query = str_replace(':', ' ', $query); + $to_remove = array('[', ']'); + foreach ($to_remove as $c) { + $query = str_replace($c, '', $query); + } + } else { + $query = '*:*'; + } // Get the `facet` GET parameter $facet = $this->_request->facet; diff --git a/tests/phpunit/tests/integration/ResultsController/SearchItemsTest.php b/tests/phpunit/tests/integration/ResultsController/SearchItemsTest.php index 4e3a9955..7440838e 100644 --- a/tests/phpunit/tests/integration/ResultsController/SearchItemsTest.php +++ b/tests/phpunit/tests/integration/ResultsController/SearchItemsTest.php @@ -85,5 +85,17 @@ public function testSearchIndexedElements() } + /** + * Special character handling (#119) + */ + public function testSpecialCharHandling() + { + $this->fieldTable->setElementIndexed('Dublin Core', 'Description'); + + $_GET['q'] = 'hop[e]'; + $this->dispatch('solr-search'); + + $this->assertTrue(TRUE); + } } From e32e236e412875411704cd1cf3d6ee1b9f27355e Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Mon, 20 Jul 2015 18:17:00 +0000 Subject: [PATCH 07/20] Move facet methods into the field table class. --- SolrSearchPlugin.php | 33 ++++------------------ models/SolrSearchFieldTable.php | 49 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 27 deletions(-) diff --git a/SolrSearchPlugin.php b/SolrSearchPlugin.php index 0adde292..5bd70518 100644 --- a/SolrSearchPlugin.php +++ b/SolrSearchPlugin.php @@ -335,27 +335,9 @@ protected function _createSolrTables() */ protected function _installFacetMappings() { - - $facets = $this->_db->getTable('SolrSearchField'); - $elements = $this->_db->getTable('Element'); - - // Generic facets: - $this->_installGenericFacet('tag', __('Tag')); - $this->_installGenericFacet('collection', __('Collection')); - $this->_installGenericFacet('itemtype', __('Item Type')); - $this->_installGenericFacet('resulttype', __('Result Type')); - $this->_installGenericFacet('featured', __('Featured')); - - // Element-backed facets: - foreach ($elements->findAll() as $element) { - $facet = new SolrSearchField($element); - $facet->save(); - } - - // By default, index DC Title/Description. - $facets->setElementIndexed('Dublin Core', 'Title'); - $facets->setElementIndexed('Dublin Core', 'Description'); - + $this->_db + ->getTable('SolrSearchField') + ->installFacetMappings(); } @@ -367,12 +349,9 @@ protected function _installFacetMappings() */ protected function _installGenericFacet($slug, $label) { - $facet = new SolrSearchField(); - $facet->slug = $slug; - $facet->label = $label; - $facet->is_indexed = 1; - $facet->is_facet = 1; - $facet->save(); + $this->_db + ->getTable('SolrSearchField') + ->installGenericFacet($slub, $label); } diff --git a/models/SolrSearchFieldTable.php b/models/SolrSearchFieldTable.php index f90a0842..3e2276ef 100644 --- a/models/SolrSearchFieldTable.php +++ b/models/SolrSearchFieldTable.php @@ -162,4 +162,53 @@ public function groupByElementSet() } + /** + * Installs the current set of elements as facets. + */ + public function installFacetMappings() + { + $elements = $this->_db->getTable('Element'); + + // Generic facets: + $this->installGenericFacet('tag', __('Tag')); + $this->installGenericFacet('collection', __('Collection')); + $this->installGenericFacet('itemtype', __('Item Type')); + $this->installGenericFacet('resulttype', __('Result Type')); + $this->installGenericFacet('featured', __('Featured')); + + // Element-backed facets: + foreach ($elements->findAll() as $element) { + $facet = new SolrSearchField($element); + $facet->save(); + } + + // By default, index DC Title/Description. + $this->setElementIndexed('Dublin Core', 'Title'); + $this->setElementIndexed('Dublin Core', 'Description'); + } + + /** + * Install a default facet mapping. + * + * @param string $slug The facet `slug`. + * @param string $label The facet `label`. + */ + public function installGenericFacet($slug, $label) + { + $facet = new SolrSearchField(); + $facet->slug = $slug; + $facet->label = $label; + $facet->is_indexed = 1; + $facet->is_facet = 1; + $facet->save(); + } + + /** + * Updates the facets with elements that have been added since + * `installFacets` was called. + */ + public function updateFacets() + { + } + } From f31894f7d2d56f793eef76e5c815758999072fba Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Tue, 21 Jul 2015 16:51:30 +0000 Subject: [PATCH 08/20] updateFacetMappings method. --- models/SolrSearchFieldTable.php | 14 +++- .../UpdateFacetMappingsTest.php | 71 +++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/tests/unit/SolrSearchFieldTable/UpdateFacetMappingsTest.php diff --git a/models/SolrSearchFieldTable.php b/models/SolrSearchFieldTable.php index 3e2276ef..b133c36e 100644 --- a/models/SolrSearchFieldTable.php +++ b/models/SolrSearchFieldTable.php @@ -207,8 +207,20 @@ public function installGenericFacet($slug, $label) * Updates the facets with elements that have been added since * `installFacets` was called. */ - public function updateFacets() + public function updateFacetMappings() { + $facetSet = array(); + foreach ($this->findAll() as $facet) { + $facetSet[$facet->element_id] = TRUE; + } + + $elementTable = $this->_db->getTable('Element'); + foreach ($elementTable->findAll() as $element) { + if (! array_key_exists($element->id, $facetSet)) { + $facet = new SolrSearchField($element); + $facet->save(); + } + } } } diff --git a/tests/phpunit/tests/unit/SolrSearchFieldTable/UpdateFacetMappingsTest.php b/tests/phpunit/tests/unit/SolrSearchFieldTable/UpdateFacetMappingsTest.php new file mode 100644 index 00000000..69368eed --- /dev/null +++ b/tests/phpunit/tests/unit/SolrSearchFieldTable/UpdateFacetMappingsTest.php @@ -0,0 +1,71 @@ +elSet = new ElementSet(); + $this->elSet->record_type = "item"; + $this->elSet->name = "FacetMappingsMissing"; + $this->elSet->save(); + + $elementSet = $this->db->getTable('ElementSet')->findByName('Dublin Core'); + $sql = " + INSERT INTO `{$this->db->Element}` (`element_set_id`, `name`, `description`) + VALUES (?, ?, ?)"; + $this->db->query($sql, array($this->elSet->id, 'element one', 'description one')); + + $elementTable = $this->db->getTable('Element'); + $this->el = $elementTable->findByElementSetNameAndElementName( + $this->elSet->name, 'element one' + ); + } + + public function tearDown() + { + parent::tearDown(); + + if (! is_null($this->el)) { + $this->el->delete(); + } + if (! is_null($this->elSet)) { + $this->elSet->delete(); + } + } + + /** + * Newly added elements are not automatically added to the facet set. + */ + public function testUpdateFacetMappingsMissing() + { + $this->assertNull( + $this->fieldTable->findByElementName( + "FacetMappingsMissing", "element one" + )); + } + + /** + * Updating the facet set adds newly created elements. + */ + public function testUpdateFacetMappings() + { + $this->fieldTable->updateFacetMappings(); + $this->assertNotNull( + $this->fieldTable->findByElementName( + "FacetMappingsMissing", "element one" + )); + } + +} From d895659b84498cc48a95a6d74fef01fb56748a67 Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Tue, 21 Jul 2015 16:52:15 +0000 Subject: [PATCH 09/20] Touched up testing system. --- tests/phpunit/bootstrap.php | 3 +++ tests/phpunit/cases/SolrSearch_Case_Default.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php index 1db00dd7..cf46ea12 100644 --- a/tests/phpunit/bootstrap.php +++ b/tests/phpunit/bootstrap.php @@ -17,3 +17,6 @@ // Base test case. require_once 'cases/SolrSearch_Case_Default.php'; + +// Load other files. +require_once SOLR_DIR . '/helpers/SolrSearch_Helpers_Index.php'; diff --git a/tests/phpunit/cases/SolrSearch_Case_Default.php b/tests/phpunit/cases/SolrSearch_Case_Default.php index 3cd7ad99..4017f629 100644 --- a/tests/phpunit/cases/SolrSearch_Case_Default.php +++ b/tests/phpunit/cases/SolrSearch_Case_Default.php @@ -103,7 +103,7 @@ protected function _installPluginOrSkip($pluginName) protected function _clearFieldMappings() { $this->db->query(<<db->prefix}solr_search_fields WHERE 1=1 + DELETE FROM {$this->db->prefix}solr_search_fields; SQL ); } @@ -297,7 +297,7 @@ protected function _element( $element = new Element(); $element->element_set_id = $elementSet->id; - $element->name = 'New Element'; + $element->name = $name; $element->save(); return $element; From cd4b67d1787d707c9c895007afb6296f078e74b3 Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Tue, 21 Jul 2015 18:01:39 +0000 Subject: [PATCH 10/20] Wired up the 'Load New Elements' button. --- controllers/AdminController.php | 12 ++++++++++++ views/admin/admin/fields.php | 3 +++ 2 files changed, 15 insertions(+) diff --git a/controllers/AdminController.php b/controllers/AdminController.php index 448011c2..47059272 100644 --- a/controllers/AdminController.php +++ b/controllers/AdminController.php @@ -122,6 +122,18 @@ protected function _collectionsForm() return $form; } + /** + * Update the set of fields in the facet set. + * + * @author Eric Rochester + */ + public function updatefacetAction() + { + $fieldTable = $this->_helper->db->getTable('SolrSearchField'); + $fieldTable->updateFacetMappings(); + $this->redirect('solr-search/fields'); + } + /** * Display the "Field Configuration" form. */ diff --git a/views/admin/admin/fields.php b/views/admin/admin/fields.php index 7ba02d4f..8e81caab 100644 --- a/views/admin/admin/fields.php +++ b/views/admin/admin/fields.php @@ -59,6 +59,9 @@ + + Load New Elements + formSubmit('submit', __('Update Search Fields')); ?> From 3e383b7af340fb7c3bab3b08a4e22c1e9111037c Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Tue, 21 Jul 2015 18:04:15 +0000 Subject: [PATCH 11/20] Documentation is good. Fixes #120. --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a5ef3c63..dd43ad75 100644 --- a/README.md +++ b/README.md @@ -80,8 +80,13 @@ can select collections to *exclude* from indexing. This form makes it possible to configure (a) which metadata elements and Omeka categories ("fields") are stored as searchable content in Solr and (b) which fields should be used as "facets", groupings of records that can be used to -iteratively narrow down the set of results. For each element, there are three -options: +iteratively narrow down the set of results. + +> If you've installed any new metadata elements and they're missing from this +> form, click the "Load New Elements" button at the bottom of the page. The +> page will reload, and hopefully the new elements will be listed. + +For each element, there are three options: - **Facet Label**: The label used as the heading for the facet corresponding to the field. In most cases, it probably just makes sense to use the From 17454a3a9201f00301ea1b80104888f40e4975bf Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Tue, 21 Jul 2015 18:48:15 +0000 Subject: [PATCH 12/20] Clean out facets based on elements that have been removed. --- models/SolrSearchFieldTable.php | 13 ++++++++-- .../UpdateFacetMappingsTest.php | 24 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/models/SolrSearchFieldTable.php b/models/SolrSearchFieldTable.php index b133c36e..fbe2a47e 100644 --- a/models/SolrSearchFieldTable.php +++ b/models/SolrSearchFieldTable.php @@ -60,7 +60,7 @@ public function findByElementName($set, $element) ); // Find the element's field. - return $this->findByElement($element); + return is_null($element) ? null : $this->findByElement($element); } @@ -211,14 +211,23 @@ public function updateFacetMappings() { $facetSet = array(); foreach ($this->findAll() as $facet) { - $facetSet[$facet->element_id] = TRUE; + $facetSet[$facet->element_id] = $facet; } $elementTable = $this->_db->getTable('Element'); + $elementSet = array(); foreach ($elementTable->findAll() as $element) { if (! array_key_exists($element->id, $facetSet)) { $facet = new SolrSearchField($element); $facet->save(); + } else { + $elementSet[$element->id] = TRUE; + } + } + + foreach ($facetSet as $facetId => $facet) { + if (! array_key_exists($facetId, $elementSet)) { + $facet->delete(); } } } diff --git a/tests/phpunit/tests/unit/SolrSearchFieldTable/UpdateFacetMappingsTest.php b/tests/phpunit/tests/unit/SolrSearchFieldTable/UpdateFacetMappingsTest.php index 69368eed..80d70d05 100644 --- a/tests/phpunit/tests/unit/SolrSearchFieldTable/UpdateFacetMappingsTest.php +++ b/tests/phpunit/tests/unit/SolrSearchFieldTable/UpdateFacetMappingsTest.php @@ -68,4 +68,28 @@ public function testUpdateFacetMappings() )); } + /** + * Updating the facet set also removes orphaned facets. + */ + public function testRemoveRemovedFacets() + { + $this->fieldTable->updateFacetMappings(); + $facet = $this->fieldTable->findByElementName( + "FacetMappingsMissing", "element one" + ); + $this->assertNotNull($facet); + + if (! is_null($this->el)) { + $sql = "DELETE FROM `{$this->db->Element}` WHERE id=?;"; + $this->db->query($sql, array($this->el->id)); + $this->el = null; + } + + $this->fieldTable->updateFacetMappings(); + $facet2 = $this->fieldTable->findBySql( + 'label=?', array($facet->label), true + ); + $this->assertNull($facet2); + } + } From aa732e1f282220d51f885d9a1b0ddb2f3346d8d1 Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Mon, 27 Jul 2015 15:41:14 +0000 Subject: [PATCH 13/20] Update/fix grunt tasks. --- Gruntfile.js | 6 ++++-- package.json | 18 +++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index a1a2b0b2..9675d3c6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -44,7 +44,9 @@ module.exports = function(grunt) { dist: { options: { sassDir: 'views/shared/css/sass', - cssDir: 'views/shared/css' + cssDir: 'views/shared/css', + outputStyle: 'compressed', + sourcemap: true } } @@ -54,7 +56,7 @@ module.exports = function(grunt) { payload: { files: 'views/shared/css/sass/*.scss', - tasks: 'compile:min' + tasks: 'build' } }, diff --git a/package.json b/package.json index 35db1a98..74ce8d7f 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "name": "SolrSearch", "version": "2.2.1", - "devDependencies" : { - "grunt": ">= 0.4.0" - , "grunt-contrib-concat": ">= 0.1.3" - , "grunt-contrib-uglify": ">= 0.1.1" - , "grunt-contrib-compass": ">= 0.7.1" - , "grunt-contrib-compress": ">= 0.4.0" - , "grunt-contrib-clean": ">= 0.4.0" - , "grunt-contrib-watch": ">= 0.2.0" - , "grunt-phpunit": ">= 0.3.1" + "devDependencies": { + "grunt": ">= 0.4.0", + "grunt-contrib-clean": ">= 0.4.0", + "grunt-contrib-compass": ">= 0.7.1", + "grunt-contrib-compress": ">= 0.4.0", + "grunt-contrib-concat": ">= 0.1.3", + "grunt-contrib-uglify": ">= 0.1.1", + "grunt-contrib-watch": ">= 0.2.0", + "grunt-phpunit": ">= 0.3.1" } } From 5c3601f0dd9d358b68c1f5a5f0df04973845d5b6 Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Mon, 27 Jul 2015 15:41:45 +0000 Subject: [PATCH 14/20] Get rid of extra whitespace. --- views/shared/results/index.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/views/shared/results/index.php b/views/shared/results/index.php index 987c503e..9a4a9939 100644 --- a/views/shared/results/index.php +++ b/views/shared/results/index.php @@ -116,15 +116,13 @@ - - " class="result-title">title) ? $doc->title[0] : $doc->title; if (empty($title)) { $title = '' . __('Untitled') . ''; } echo $title; - ?> - + ?> (resulttype; ?>) From e6a59cf8462e3f0e3c7cd0d2ec88343557b773ff Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Mon, 27 Jul 2015 16:20:58 +0000 Subject: [PATCH 15/20] Include the image thumbnails for all files attached to search result items. Fixes #116. --- views/shared/css/fields.css | 10 +- views/shared/css/results.css | 493 +---------------------------- views/shared/css/sass/results.scss | 6 + views/shared/results/index.php | 10 + 4 files changed, 23 insertions(+), 496 deletions(-) diff --git a/views/shared/css/fields.css b/views/shared/css/fields.css index 170da3ab..a3fa9e44 100644 --- a/views/shared/css/fields.css +++ b/views/shared/css/fields.css @@ -236,7 +236,7 @@ /* line 146, sass/_buttons.scss */ .btn-primary { - background-color: #0073cc; + background-color: #0074cc; background-image: -moz-linear-gradient(top, #08c, #0055cc); background-image: -ms-linear-gradient(top, #08c, #0055cc); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#08c), to(#0055cc)); @@ -263,7 +263,7 @@ /* line 150, sass/_buttons.scss */ .btn-warning { - background-color: #f9a732; + background-color: #faa732; background-image: -moz-linear-gradient(top, #fbb450, #f89406); background-image: -ms-linear-gradient(top, #fbb450, #f89406); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406)); @@ -290,7 +290,7 @@ /* line 154, sass/_buttons.scss */ .btn-danger { - background-color: #da4e49; + background-color: #da4f49; background-image: -moz-linear-gradient(top, #ee5f5b, #bd362f); background-image: -ms-linear-gradient(top, #ee5f5b, #bd362f); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#bd362f)); @@ -317,7 +317,7 @@ /* line 158, sass/_buttons.scss */ .btn-success { - background-color: #5bb65b; + background-color: #5bb75b; background-image: -moz-linear-gradient(top, #62c462, #51a351); background-image: -ms-linear-gradient(top, #62c462, #51a351); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#51a351)); @@ -371,7 +371,7 @@ /* line 166, sass/_buttons.scss */ .btn-inverse { - background-color: #404040; + background-color: #414141; background-image: -moz-linear-gradient(top, #555, #222); background-image: -ms-linear-gradient(top, #555, #222); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#555), to(#222)); diff --git a/views/shared/css/results.css b/views/shared/css/results.css index 7e85f13c..b4e13dfa 100644 --- a/views/shared/css/results.css +++ b/views/shared/css/results.css @@ -1,491 +1,2 @@ -@charset "UTF-8"; -/* line 109, sass/_mixins.scss */ -.clearfix { - *zoom: 1; -} -/* line 99, sass/_mixins.scss */ -.clearfix:before, .clearfix:after { - display: table; - content: ""; -} -/* line 104, sass/_mixins.scss */ -.clearfix:after { - clear: both; -} - -/* line 201, sass/_mixins.scss */ -.hide-text { - font: 0/0 a; - color: transparent; - text-shadow: none; - background-color: transparent; - border: 0; -} - -/* line 382, sass/_mixins.scss */ -.input-block-level { - display: block; - width: 100%; - min-height: 28px; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - box-sizing: border-box; -} - -/* line 740, sass/_mixins.scss */ -.clearfix { - *zoom: 1; -} -/* line 730, sass/_mixins.scss */ -.clearfix:before, .clearfix:after { - display: table; - content: ""; -} -/* line 735, sass/_mixins.scss */ -.clearfix:after { - clear: both; -} - -/* line 835, sass/_mixins.scss */ -.hide-text { - font: 0/0 a; - color: transparent; - text-shadow: none; - background-color: transparent; - border: 0; -} - -/* line 1016, sass/_mixins.scss */ -.input-block-level { - display: block; - width: 100%; - min-height: 28px; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - box-sizing: border-box; -} - -/* line 14, sass/_buttons.scss */ -.btn { - display: inline-block; - *display: inline; - *zoom: 1; - padding: 4px 10px 4px; - margin-bottom: 0; - font-size: 13px; - line-height: 18px; - *line-height: 20px; - color: #333; - text-align: center; - text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); - vertical-align: middle; - cursor: pointer; - background-color: whitesmoke; - background-image: -moz-linear-gradient(top, #fff, #e6e6e6); - background-image: -ms-linear-gradient(top, #fff, #e6e6e6); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fff), to(#e6e6e6)); - background-image: -webkit-linear-gradient(top, #fff, #e6e6e6); - background-image: -o-linear-gradient(top, #fff, #e6e6e6); - background-image: linear-gradient(top, #fff, #e6e6e6); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fcfcfc', endColorstr='#e3e3e3', GradientType=0); - border-color: #e6e6e6 #e6e6e6 #bfbfbf; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - *background-color: #e6e6e6; - /* Darken IE7 buttons by default so they stand out more given they won't have borders */ - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); - border: 1px solid #ccc; - *border: 0; - border-bottom-color: #b3b3b3; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - *margin-left: .3em; - -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); - -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); -} -/* line 1182, sass/_mixins.scss */ -.btn:hover, .btn:active, .btn.active, .btn.disabled, .btn[disabled] { - background-color: #e6e6e6; - *background-color: #d9d9d9; -} -/* line 1188, sass/_mixins.scss */ -.btn:active, .btn.active { - background-color: #cccccc \9; -} -/* line 778, sass/_mixins.scss */ -.btn:first-child { - *margin-left: 0; -} - -/* line 38, sass/_buttons.scss */ -.btn:hover { - color: #333; - text-decoration: none; - background-color: #e6e6e6; - *background-color: #d9d9d9; - /* Buttons in IE7 don't get borders, so darken on hover */ - background-position: 0 -15px; - -webkit-transition: background-position 0.1s linear; - -moz-transition: background-position 0.1s linear; - -ms-transition: background-position 0.1s linear; - -o-transition: background-position 0.1s linear; - transition: background-position 0.1s linear; -} - -/* line 51, sass/_buttons.scss */ -.btn:focus { - outline: thin dotted #333; - outline: 5px auto -webkit-focus-ring-color; - outline-offset: -2px; -} - -/* line 56, sass/_buttons.scss */ -.btn.active, -.btn:active { - background-color: #e6e6e6; - background-color: #d9d9d9 \9; - background-image: none; - outline: 0; - -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); - -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); - box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); -} - -/* line 67, sass/_buttons.scss */ -.btn.disabled, -.btn[disabled] { - cursor: default; - background-color: #e6e6e6; - background-image: none; - opacity: 0.65; - filter: alpha(opacity=65); - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; -} - -/* line 81, sass/_buttons.scss */ -.btn-large { - padding: 9px 14px; - font-size: 15px; - line-height: normal; - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - border-radius: 5px; -} - -/* line 87, sass/_buttons.scss */ -.btn-large [class^="icon-"] { - margin-top: 1px; -} - -/* line 92, sass/_buttons.scss */ -.btn-small { - padding: 5px 9px; - font-size: 11px; - line-height: 16px; -} - -/* line 97, sass/_buttons.scss */ -.btn-small [class^="icon-"] { - margin-top: -1px; -} - -/* line 102, sass/_buttons.scss */ -.btn-mini { - padding: 2px 6px; - font-size: 11px; - line-height: 14px; -} - -/* line 114, sass/_buttons.scss */ -.btn-primary, -.btn-primary:hover, -.btn-warning, -.btn-warning:hover, -.btn-danger, -.btn-danger:hover, -.btn-success, -.btn-success:hover, -.btn-info, -.btn-info:hover, -.btn-inverse, -.btn-inverse:hover { - color: #fff; - text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); -} - -/* line 130, sass/_buttons.scss */ -.btn-primary.active, -.btn-warning.active, -.btn-danger.active, -.btn-success.active, -.btn-info.active, -.btn-inverse.active { - color: rgba(255, 255, 255, 0.75); -} - -/* line 141, sass/_buttons.scss */ -.btn { - border-color: #ccc; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); -} - -/* line 146, sass/_buttons.scss */ -.btn-primary { - background-color: #0073cc; - background-image: -moz-linear-gradient(top, #08c, #0055cc); - background-image: -ms-linear-gradient(top, #08c, #0055cc); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#08c), to(#0055cc)); - background-image: -webkit-linear-gradient(top, #08c, #0055cc); - background-image: -o-linear-gradient(top, #08c, #0055cc); - background-image: linear-gradient(top, #08c, #0055cc); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0085c7', endColorstr='#0053c7', GradientType=0); - border-color: #0055cc #0055cc #003580; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - *background-color: #0055cc; - /* Darken IE7 buttons by default so they stand out more given they won't have borders */ - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); -} -/* line 1182, sass/_mixins.scss */ -.btn-primary:hover, .btn-primary:active, .btn-primary.active, .btn-primary.disabled, .btn-primary[disabled] { - background-color: #0055cc; - *background-color: #004ab3; -} -/* line 1188, sass/_mixins.scss */ -.btn-primary:active, .btn-primary.active { - background-color: #004099 \9; -} - -/* line 150, sass/_buttons.scss */ -.btn-warning { - background-color: #f9a732; - background-image: -moz-linear-gradient(top, #fbb450, #f89406); - background-image: -ms-linear-gradient(top, #fbb450, #f89406); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406)); - background-image: -webkit-linear-gradient(top, #fbb450, #f89406); - background-image: -o-linear-gradient(top, #fbb450, #f89406); - background-image: linear-gradient(top, #fbb450, #f89406); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fbb24b', endColorstr='#f39106', GradientType=0); - border-color: #f89406 #f89406 #ad6704; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - *background-color: #f89406; - /* Darken IE7 buttons by default so they stand out more given they won't have borders */ - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); -} -/* line 1182, sass/_mixins.scss */ -.btn-warning:hover, .btn-warning:active, .btn-warning.active, .btn-warning.disabled, .btn-warning[disabled] { - background-color: #f89406; - *background-color: #df8505; -} -/* line 1188, sass/_mixins.scss */ -.btn-warning:active, .btn-warning.active { - background-color: #c67605 \9; -} - -/* line 154, sass/_buttons.scss */ -.btn-danger { - background-color: #da4e49; - background-image: -moz-linear-gradient(top, #ee5f5b, #bd362f); - background-image: -ms-linear-gradient(top, #ee5f5b, #bd362f); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#bd362f)); - background-image: -webkit-linear-gradient(top, #ee5f5b, #bd362f); - background-image: -o-linear-gradient(top, #ee5f5b, #bd362f); - background-image: linear-gradient(top, #ee5f5b, #bd362f); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ee5a56', endColorstr='#b9352e', GradientType=0); - border-color: #bd362f #bd362f #802420; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - *background-color: #bd362f; - /* Darken IE7 buttons by default so they stand out more given they won't have borders */ - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); -} -/* line 1182, sass/_mixins.scss */ -.btn-danger:hover, .btn-danger:active, .btn-danger.active, .btn-danger.disabled, .btn-danger[disabled] { - background-color: #bd362f; - *background-color: #a9302a; -} -/* line 1188, sass/_mixins.scss */ -.btn-danger:active, .btn-danger.active { - background-color: #942a25 \9; -} - -/* line 158, sass/_buttons.scss */ -.btn-success { - background-color: #5bb65b; - background-image: -moz-linear-gradient(top, #62c462, #51a351); - background-image: -ms-linear-gradient(top, #62c462, #51a351); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#51a351)); - background-image: -webkit-linear-gradient(top, #62c462, #51a351); - background-image: -o-linear-gradient(top, #62c462, #51a351); - background-image: linear-gradient(top, #62c462, #51a351); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#5ec35e', endColorstr='#4fa04f', GradientType=0); - border-color: #51a351 #51a351 #387038; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - *background-color: #51a351; - /* Darken IE7 buttons by default so they stand out more given they won't have borders */ - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); -} -/* line 1182, sass/_mixins.scss */ -.btn-success:hover, .btn-success:active, .btn-success.active, .btn-success.disabled, .btn-success[disabled] { - background-color: #51a351; - *background-color: #499249; -} -/* line 1188, sass/_mixins.scss */ -.btn-success:active, .btn-success.active { - background-color: #408140 \9; -} - -/* line 162, sass/_buttons.scss */ -.btn-info { - background-color: #49afcd; - background-image: -moz-linear-gradient(top, #5bc0de, #2f96b4); - background-image: -ms-linear-gradient(top, #5bc0de, #2f96b4); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#2f96b4)); - background-image: -webkit-linear-gradient(top, #5bc0de, #2f96b4); - background-image: -o-linear-gradient(top, #5bc0de, #2f96b4); - background-image: linear-gradient(top, #5bc0de, #2f96b4); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#57bedd', endColorstr='#2e93b0', GradientType=0); - border-color: #2f96b4 #2f96b4 #1f6377; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - *background-color: #2f96b4; - /* Darken IE7 buttons by default so they stand out more given they won't have borders */ - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); -} -/* line 1182, sass/_mixins.scss */ -.btn-info:hover, .btn-info:active, .btn-info.active, .btn-info.disabled, .btn-info[disabled] { - background-color: #2f96b4; - *background-color: #2a85a0; -} -/* line 1188, sass/_mixins.scss */ -.btn-info:active, .btn-info.active { - background-color: #24748c \9; -} - -/* line 166, sass/_buttons.scss */ -.btn-inverse { - background-color: #404040; - background-image: -moz-linear-gradient(top, #555, #222); - background-image: -ms-linear-gradient(top, #555, #222); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#555), to(#222)); - background-image: -webkit-linear-gradient(top, #555, #222); - background-image: -o-linear-gradient(top, #555, #222); - background-image: linear-gradient(top, #555, #222); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#525252', endColorstr='#1f1f1f', GradientType=0); - border-color: #222 #222 black; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - *background-color: #222; - /* Darken IE7 buttons by default so they stand out more given they won't have borders */ - filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); -} -/* line 1182, sass/_mixins.scss */ -.btn-inverse:hover, .btn-inverse:active, .btn-inverse.active, .btn-inverse.disabled, .btn-inverse[disabled] { - background-color: #222; - *background-color: #151515; -} -/* line 1188, sass/_mixins.scss */ -.btn-inverse:active, .btn-inverse.active { - background-color: #090909 \9; -} - -/* line 174, sass/_buttons.scss */ -button.btn, -input[type="submit"].btn { - *padding-top: 2px; - *padding-bottom: 2px; -} -/* line 178, sass/_buttons.scss */ -button.btn::-moz-focus-inner, -input[type="submit"].btn::-moz-focus-inner { - padding: 0; - border: 0; -} -/* line 186, sass/_buttons.scss */ -button.btn.btn-large, -input[type="submit"].btn.btn-large { - *padding-top: 7px; - *padding-bottom: 7px; -} -/* line 190, sass/_buttons.scss */ -button.btn.btn-small, -input[type="submit"].btn.btn-small { - *padding-top: 3px; - *padding-bottom: 3px; -} -/* line 194, sass/_buttons.scss */ -button.btn.btn-mini, -input[type="submit"].btn.btn-mini { - *padding-top: 1px; - *padding-bottom: 1px; -} - -/* line 5, sass/results.scss */ -ul { - margin-left: 1em; -} - -/* line 9, sass/results.scss */ -#solr-search-form { - overflow: hidden; - box-sizing: border-box; -} -/* line 13, sass/results.scss */ -#solr-search-form span.float-wrap { - display: block; - padding-right: 10px; - overflow: hidden; -} -/* line 18, sass/results.scss */ -#solr-search-form span.float-wrap input[type="text"] { - width: 100%; -} -/* line 24, sass/results.scss */ -#solr-search-form input[type="submit"] { - float: right; -} - -/* line 32, sass/results.scss */ -#solr-applied-facets ul { - margin: 0; - padding: 0; -} -/* line 36, sass/results.scss */ -#solr-applied-facets ul li { - display: inline; -} -/* line 39, sass/results.scss */ -#solr-applied-facets ul li + li:before { - content: "· "; -} - -/* line 49, sass/results.scss */ -#solr-facets { - width: 20%; - float: left; -} - -/* line 54, sass/results.scss */ -#solr-results { - margin-left: 22%; -} -/* line 57, sass/results.scss */ -#solr-results div.result { - margin: 1em 0; -} -/* line 60, sass/results.scss */ -#solr-results div.result a.result-title { - font-weight: bold; -} -/* line 65, sass/results.scss */ -#solr-results div.result ul.hl em { - font-weight: bold; -} +.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 10px 4px;margin-bottom:0;font-size:13px;line-height:18px;*line-height:20px;color:#333;text-align:center;text-shadow:0 1px 1px rgba(255,255,255,0.75);vertical-align:middle;cursor:pointer;background-color:#f5f5f5;background-image:-moz-linear-gradient(top, #fff, #e6e6e6);background-image:-ms-linear-gradient(top, #fff, #e6e6e6);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#fff), to(#e6e6e6));background-image:-webkit-linear-gradient(top, #fff, #e6e6e6);background-image:-o-linear-gradient(top, #fff, #e6e6e6);background-image:linear-gradient(top, #fff, #e6e6e6);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fcfcfc', endColorstr='#e3e3e3', GradientType=0);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn:hover,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{background-color:#e6e6e6;*background-color:#d9d9d9}.btn:active,.btn.active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:hover{color:#333;text-decoration:none;background-color:#e6e6e6;*background-color:#d9d9d9;background-position:0 -15px;-webkit-transition:background-position 0.1s linear;-moz-transition:background-position 0.1s linear;-ms-transition:background-position 0.1s linear;-o-transition:background-position 0.1s linear;transition:background-position 0.1s linear}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{background-color:#e6e6e6;background-color:#d9d9d9 \9;background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.btn.disabled,.btn[disabled]{cursor:default;background-color:#e6e6e6;background-image:none;opacity:0.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:9px 14px;font-size:15px;line-height:normal;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.btn-large [class^="icon-"]{margin-top:1px}.btn-small{padding:5px 9px;font-size:11px;line-height:16px}.btn-small [class^="icon-"]{margin-top:-1px}.btn-mini{padding:2px 6px;font-size:11px;line-height:14px}.btn-primary,.btn-primary:hover,.btn-warning,.btn-warning:hover,.btn-danger,.btn-danger:hover,.btn-success,.btn-success:hover,.btn-info,.btn-info:hover,.btn-inverse,.btn-inverse:hover{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.btn-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn{border-color:#ccc;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25)}.btn-primary{background-color:#0074cc;background-image:-moz-linear-gradient(top, #08c, #05c);background-image:-ms-linear-gradient(top, #08c, #05c);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#08c), to(#05c));background-image:-webkit-linear-gradient(top, #08c, #05c);background-image:-o-linear-gradient(top, #08c, #05c);background-image:linear-gradient(top, #08c, #05c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#0085c7', endColorstr='#0053c7', GradientType=0);border-color:#05c #05c #003580;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#05c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary:hover,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.btn-primary[disabled]{background-color:#05c;*background-color:#004ab3}.btn-primary:active,.btn-primary.active{background-color:#004099 \9}.btn-warning{background-color:#faa732;background-image:-moz-linear-gradient(top, #fbb450, #f89406);background-image:-ms-linear-gradient(top, #fbb450, #f89406);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));background-image:-webkit-linear-gradient(top, #fbb450, #f89406);background-image:-o-linear-gradient(top, #fbb450, #f89406);background-image:linear-gradient(top, #fbb450, #f89406);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fbb24b', endColorstr='#f39106', GradientType=0);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning:hover,.btn-warning:active,.btn-warning.active,.btn-warning.disabled,.btn-warning[disabled]{background-color:#f89406;*background-color:#df8505}.btn-warning:active,.btn-warning.active{background-color:#c67605 \9}.btn-danger{background-color:#da4f49;background-image:-moz-linear-gradient(top, #ee5f5b, #bd362f);background-image:-ms-linear-gradient(top, #ee5f5b, #bd362f);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#bd362f));background-image:-webkit-linear-gradient(top, #ee5f5b, #bd362f);background-image:-o-linear-gradient(top, #ee5f5b, #bd362f);background-image:linear-gradient(top, #ee5f5b, #bd362f);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ee5a56', endColorstr='#b9352e', GradientType=0);border-color:#bd362f #bd362f #802420;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#bd362f;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-danger:hover,.btn-danger:active,.btn-danger.active,.btn-danger.disabled,.btn-danger[disabled]{background-color:#bd362f;*background-color:#a9302a}.btn-danger:active,.btn-danger.active{background-color:#942a25 \9}.btn-success{background-color:#5bb75b;background-image:-moz-linear-gradient(top, #62c462, #51a351);background-image:-ms-linear-gradient(top, #62c462, #51a351);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#51a351));background-image:-webkit-linear-gradient(top, #62c462, #51a351);background-image:-o-linear-gradient(top, #62c462, #51a351);background-image:linear-gradient(top, #62c462, #51a351);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#5ec35e', endColorstr='#4fa04f', GradientType=0);border-color:#51a351 #51a351 #387038;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#51a351;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-success:hover,.btn-success:active,.btn-success.active,.btn-success.disabled,.btn-success[disabled]{background-color:#51a351;*background-color:#499249}.btn-success:active,.btn-success.active{background-color:#408140 \9}.btn-info{background-color:#49afcd;background-image:-moz-linear-gradient(top, #5bc0de, #2f96b4);background-image:-ms-linear-gradient(top, #5bc0de, #2f96b4);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#2f96b4));background-image:-webkit-linear-gradient(top, #5bc0de, #2f96b4);background-image:-o-linear-gradient(top, #5bc0de, #2f96b4);background-image:linear-gradient(top, #5bc0de, #2f96b4);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#57bedd', endColorstr='#2e93b0', GradientType=0);border-color:#2f96b4 #2f96b4 #1f6377;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#2f96b4;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-info:hover,.btn-info:active,.btn-info.active,.btn-info.disabled,.btn-info[disabled]{background-color:#2f96b4;*background-color:#2a85a0}.btn-info:active,.btn-info.active{background-color:#24748c \9}.btn-inverse{background-color:#414141;background-image:-moz-linear-gradient(top, #555, #222);background-image:-ms-linear-gradient(top, #555, #222);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#555), to(#222));background-image:-webkit-linear-gradient(top, #555, #222);background-image:-o-linear-gradient(top, #555, #222);background-image:linear-gradient(top, #555, #222);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#525252', endColorstr='#1f1f1f', GradientType=0);border-color:#222 #222 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#222;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-inverse:hover,.btn-inverse:active,.btn-inverse.active,.btn-inverse.disabled,.btn-inverse[disabled]{background-color:#222;*background-color:#151515}.btn-inverse:active,.btn-inverse.active{background-color:#090909 \9}button.btn,input[type="submit"].btn{*padding-top:2px;*padding-bottom:2px}button.btn::-moz-focus-inner,input[type="submit"].btn::-moz-focus-inner{padding:0;border:0}button.btn.btn-large,input[type="submit"].btn.btn-large{*padding-top:7px;*padding-bottom:7px}button.btn.btn-small,input[type="submit"].btn.btn-small{*padding-top:3px;*padding-bottom:3px}button.btn.btn-mini,input[type="submit"].btn.btn-mini{*padding-top:1px;*padding-bottom:1px}ul{margin-left:1em}#solr-search-form{overflow:hidden;box-sizing:border-box}#solr-search-form span.float-wrap{display:block;padding-right:10px;overflow:hidden}#solr-search-form span.float-wrap input[type="text"]{width:100%}#solr-search-form input[type="submit"]{float:right}#solr-applied-facets ul{margin:0;padding:0}#solr-applied-facets ul li{display:inline}#solr-applied-facets ul li+li:before{content:"· "}#solr-facets{width:20%;float:left}#solr-results{margin-left:22%}#solr-results div.result{margin:1em 0}#solr-results div.result a.result-title{font-weight:bold}#solr-results div.result ul.hl em{font-weight:bold} +/*# sourceMappingURL=results.css.map */ diff --git a/views/shared/css/sass/results.scss b/views/shared/css/sass/results.scss index e87bd0dd..bb0f60ea 100644 --- a/views/shared/css/sass/results.scss +++ b/views/shared/css/sass/results.scss @@ -67,6 +67,12 @@ ul { } } + /* + * .gallery img { + * height: 50px; + * } + */ + } } diff --git a/views/shared/results/index.php b/views/shared/results/index.php index 9a4a9939..5c9a53d9 100644 --- a/views/shared/results/index.php +++ b/views/shared/results/index.php @@ -140,6 +140,16 @@ + getTable($doc->model)->find($doc->modelid); + echo item_image_gallery( + array('wrapper' => array('class' => 'gallery')), + 'square_thumbnail', + false, + $item + ); + ?> + From 28a5abe649494ab03ffa7529ce3674c4fe4f1b25 Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Tue, 28 Jul 2015 18:08:08 +0000 Subject: [PATCH 16/20] Added option for hl.maxAnalyzedChars. * Added option `solr_search_hl_max_analyzed_chars`; * Added configuration form; and * Passed this option on to Solr. Fixes #114. --- SolrSearchPlugin.php | 8 +++++++- controllers/ResultsController.php | 19 ++++++++++--------- forms/SolrSearch_Form_Results.php | 20 ++++++++++++++++++++ plugin.ini | 2 +- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/SolrSearchPlugin.php b/SolrSearchPlugin.php index 0adde292..7598492a 100644 --- a/SolrSearchPlugin.php +++ b/SolrSearchPlugin.php @@ -90,6 +90,10 @@ public function hookUpgrade($args) if (is_null($featured) || empty($featured)) { $this->_installGenericFacet('featured', __('Featured')); } + + if (version_compare($args['old_version'], '2.2.1', '<=')) { + set_option('solr_search_hl_max_analyzed_chars', '51200'); + } } @@ -389,7 +393,8 @@ protected function _setOptions() set_option('solr_search_hl', '1'); set_option('solr_search_hl_snippets', '1'); set_option('solr_search_hl_fragsize', '250'); - set_option('solr_search_display_private_items', '1'); + set_option('solr_search_hl_max_analyzed_chars', '51200'); + set_option('solr_search_display_private_items', '1'); } @@ -406,6 +411,7 @@ protected function _clearOptions() delete_option('solr_search_hl'); delete_option('solr_search_hl_snippets'); delete_option('solr_search_hl_fragsize'); + delete_option('solr_search_hl_max_analyzed_chars'); delete_option('solr_search_display_private_items'); } diff --git a/controllers/ResultsController.php b/controllers/ResultsController.php index 7d9cafa9..0a4ea35a 100644 --- a/controllers/ResultsController.php +++ b/controllers/ResultsController.php @@ -146,15 +146,16 @@ protected function _getParameters() return array( - 'facet' => 'true', - 'facet.field' => $facets, - 'facet.mincount' => 1, - 'facet.limit' => get_option('solr_search_facet_limit'), - 'facet.sort' => get_option('solr_search_facet_sort'), - 'hl' => get_option('solr_search_hl')?'true':'false', - 'hl.snippets' => get_option('solr_search_hl_snippets'), - 'hl.fragsize' => get_option('solr_search_hl_fragsize'), - 'hl.fl' => '*_t' + 'facet' => 'true', + 'facet.field' => $facets, + 'facet.mincount' => 1, + 'facet.limit' => get_option('solr_search_facet_limit'), + 'facet.sort' => get_option('solr_search_facet_sort'), + 'hl' => get_option('solr_search_hl')?'true':'false', + 'hl.snippets' => get_option('solr_search_hl_snippets'), + 'hl.fragsize' => get_option('solr_search_hl_fragsize'), + 'hl.maxAnalyzedChars' => get_option('solr_search_hl_max_analyzed_chars'), + 'hl.fl' => '*_t' ); diff --git a/forms/SolrSearch_Form_Results.php b/forms/SolrSearch_Form_Results.php index 628b3b0e..34906a64 100644 --- a/forms/SolrSearch_Form_Results.php +++ b/forms/SolrSearch_Form_Results.php @@ -63,6 +63,26 @@ public function init() ) )); + // Max Analyzed Chars + $this->addElement('text', 'solr_search_hl_max_analyzed_chars', array( + 'label' => __('Extent of Document Highlightable'), + 'description' => __('How much of the document can be highlighted, in characters. Occurrences past this point will not be returned in the results highlighting.'), + 'value' => get_option('solr_search_hl_max_analyzed_chars'), + 'required' => true, + 'size' => 10, + 'validators' => array( + array( + 'validator' => 'Int', + 'breakChainOnFailure' => true, + 'options' => array( + 'messages' => array( + Zend_Validate_Int::NOT_INT => __('Must be an integer.') + ) + ) + ) + ) + )); + // Facet Ordering: $this->addElement('select', 'solr_search_facet_sort', array( 'label' => __('Facet Ordering'), diff --git a/plugin.ini b/plugin.ini index 171a5fe3..969b5319 100644 --- a/plugin.ini +++ b/plugin.ini @@ -7,6 +7,6 @@ support_link="https://github.com/scholarslab/SolrSearch/issues" omeka_minimum_version="2.0" omeka_tested_up_to="2.1" omeka_target_version="2.1" -version="2.2.1" +version="2.2.2-dev" tags="solr, search" license="Apache 2.0" From 3a182f2db31b3e7295bfeb2d1de871b08c6b542d Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Tue, 28 Jul 2015 18:15:15 +0000 Subject: [PATCH 17/20] Document `solr_search_hl_max_analyzed_chars`. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index a5ef3c63..f3ea3b5c 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,11 @@ honing in on specific categories. - **Enable Highlighting**: Set whether highlighting snippets should be displayed. + - **Extent of Document Highlightable**: Set the amount of the document to + scan when highlighting. By default, to save time, this is limited to 51200 + characters. If you have documents in the results that don't have snippets, + you can make this larger. + - **Number of Snippets**: The maximum number of snippets to display for a result. From 3e219e840578354f3637c01bd6997ab81ed501bd Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Thu, 6 Aug 2015 14:27:39 +0000 Subject: [PATCH 18/20] Allow exclusion on private collections. This is only enabled when 'Display Private Items' is selected. Fixes #122. --- controllers/AdminController.php | 8 +- .../AdminController/CollectionsTest.php | 96 +++++++++++++++++++ 2 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/tests/integration/AdminController/CollectionsTest.php diff --git a/controllers/AdminController.php b/controllers/AdminController.php index 47059272..b7630c96 100644 --- a/controllers/AdminController.php +++ b/controllers/AdminController.php @@ -98,7 +98,13 @@ protected function _updateCollections($post) protected function _collectionsForm() { $ctable = $this->_helper->db->getTable('Collection'); - $collections = $ctable->findBy(array('public' => 1)); + $private = (int)get_option('solr_search_display_private_items'); + + if ($private) { + $collections = $ctable->findAll(); + } else { + $collections = $ctable->findBy(array('public' => 1)); + } $form = new Zend_Form(); $form->setAction(url('solr-search/collections'))->setMethod('post'); diff --git a/tests/phpunit/tests/integration/AdminController/CollectionsTest.php b/tests/phpunit/tests/integration/AdminController/CollectionsTest.php new file mode 100644 index 00000000..9e5a9341 --- /dev/null +++ b/tests/phpunit/tests/integration/AdminController/CollectionsTest.php @@ -0,0 +1,96 @@ + $public), + array( + 'Dublin Core' => array( + 'Title' => array( + array('text' => $title, 'html' => false) + ) + ) + ) + ); + } + + + public function setUp() + { + parent::setUp(); + + $this->pubColl = $this->_collection('public collection', TRUE ); + $this->privColl = $this->_collection('private collection', FALSE); + + $this->opt = get_option('solr_search_display_private_items'); + } + + public function tearDown() + { + set_option('solr_search_display_private_items', $this->opt); + + $this->pubColl ->delete(); + $this->privColl->delete(); + + parent:: tearDown(); + } + + /** + * If 'Display private items' is checked, also display private collections + * for exclusion. + */ + public function testDisplayPrivateCollectionsChecked() + { + set_option('solr_search_display_private_items', '1'); + + $this->dispatch('solr-search/collections'); + + // echo $this->getResponse()->getBody(); + + $this->assertXpathContentContains( + "//dd[@id='solrexclude-element']/label", + "public collection" + ); + $this->assertXpathContentContains( + "//dd[@id='solrexclude-element']/label", + "private collection" + ); + } + + /** + * If 'Display private items' is not checked, do not display private + * collections for exclusion. + */ + public function testDisplayPrivateCollectionsNotChecked() + { + set_option('solr_search_display_private_items', '0'); + + $this->dispatch('solr-search/collections'); + + $this->assertXpathContentContains( + "//dd[@id='solrexclude-element']/label", + "public collection" + ); + $this->assertNotXpathContentContains( + "//dd[@id='solrexclude-element']/label", + "private collection" + ); + } + +} From 25f113809abb2190dedbc69d40f288d39f067ca2 Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Thu, 6 Aug 2015 17:44:40 +0000 Subject: [PATCH 19/20] Fixed test by adding value for solr_search_hl_max_analyzed_chars to form. --- .../AdminController/ResultsTest.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/tests/integration/AdminController/ResultsTest.php b/tests/phpunit/tests/integration/AdminController/ResultsTest.php index 8409b7a1..28ae5a2a 100644 --- a/tests/phpunit/tests/integration/AdminController/ResultsTest.php +++ b/tests/phpunit/tests/integration/AdminController/ResultsTest.php @@ -217,11 +217,14 @@ public function testSuccess() set_option('solr_search_facet_limit', '25'); $this->request->setMethod('POST')->setPost(array( - 'solr_search_hl' => '0', - 'solr_search_hl_snippets' => '2', - 'solr_search_hl_fragsize' => '300', - 'solr_search_facet_sort' => 'index', - 'solr_search_facet_limit' => '30' + 'solr_search_hl_max_analyzed_chars' => '102400', + 'solr_search_hl' => '0', + 'solr_search_hl_snippets' => '2', + 'solr_search_hl_fragsize' => '300', + 'solr_search_facet_sort' => 'index', + 'solr_search_facet_limit' => '30', + 'solr_search_display_private_items' => '0', + 'submit' => 'Save+Settings' )); $this->dispatch('solr-search/results'); @@ -232,6 +235,12 @@ public function testSuccess() $sort = get_option('solr_search_facet_sort'); $limit = get_option('solr_search_facet_limit'); + $this->assertXpath("//li[@class='success']"); + $this->assertXpathContentContains( + "//li[@class='success']", + "Highlighting options successfully saved!" + ); + // Should update options. $this->assertEquals('0', $hl); $this->assertEquals('2', $snippets); From 1a04a07ba696c44fb5dc0dbae91a4d6158f9c3f8 Mon Sep 17 00:00:00 2001 From: Eric Rochester Date: Wed, 19 Aug 2015 17:50:16 +0000 Subject: [PATCH 20/20] Updated version numbers. --- package.json | 2 +- plugin.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 74ce8d7f..17967f4a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "SolrSearch", - "version": "2.2.1", + "version": "2.3.0", "devDependencies": { "grunt": ">= 0.4.0", "grunt-contrib-clean": ">= 0.4.0", diff --git a/plugin.ini b/plugin.ini index 969b5319..c0dd52e7 100644 --- a/plugin.ini +++ b/plugin.ini @@ -7,6 +7,6 @@ support_link="https://github.com/scholarslab/SolrSearch/issues" omeka_minimum_version="2.0" omeka_tested_up_to="2.1" omeka_target_version="2.1" -version="2.2.2-dev" +version="2.3.0" tags="solr, search" license="Apache 2.0"