Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
161 commits
Select commit Hold shift + click to select a range
cc7cfb8
Update files, add config_form
DBinaghi Jun 8, 2021
ca31595
Update file
DBinaghi Jun 8, 2021
e2edf19
Update file, commented out faulty rules
DBinaghi Jun 8, 2021
73e0897
Update file with improved functions
DBinaghi Jun 8, 2021
4e4e6b6
Update Readme.md
DBinaghi Jun 8, 2021
d4c8475
Fixed indentation
DBinaghi Jun 8, 2021
c301c59
Added config option to hide popularity count
DBinaghi Jun 8, 2021
917f3e3
Added config option to hide popularity count
DBinaghi Jun 8, 2021
d52c1bc
Added config option to hide popularity count
DBinaghi Jun 8, 2021
ed1c917
Added option to hide popularity count, added tags count and sorting b…
DBinaghi Jun 8, 2021
7e23883
Added localization support
DBinaghi Jun 8, 2021
87e44b0
Fixed translatable string
DBinaghi Jun 8, 2021
a700819
Removed useless array variable
DBinaghi Jun 8, 2021
91a5f4c
Initial commit
DBinaghi Jun 8, 2021
a5fbe2b
Add files via upload
DBinaghi Jun 8, 2021
5dd1109
Corrected typo
DBinaghi Jun 8, 2021
01e449e
Update Readme.md
DBinaghi Jun 8, 2021
d23614b
Create Readme.md
DBinaghi Jun 8, 2021
ee733fa
Fixed issue with search page
DBinaghi Jun 8, 2021
7d28b8c
Update FacetsPlugin.php
DBinaghi Jun 8, 2021
31ff695
Update Readme.md
DBinaghi Jun 8, 2021
0e9554d
Corrected variable name
DBinaghi Jun 9, 2021
b54e5ff
Changed parameter passed to builder functions
DBinaghi Jun 9, 2021
bb8bfa6
Changed parameter passed to builder functions
DBinaghi Jun 9, 2021
b36fc2d
Modified showFacets function
DBinaghi Jun 9, 2021
0ec4715
Added feature for Collections
DBinaghi Jun 9, 2021
1a7269a
Extended feature to Collections
DBinaghi Jun 9, 2021
607f344
Extended feature to Collections, improved Single Entries exclusion
DBinaghi Jun 9, 2021
e49aed0
Extended feature to Collections
DBinaghi Jun 9, 2021
2154e13
Update Readme.md
DBinaghi Jun 9, 2021
4f7ed84
Update plugin.ini
DBinaghi Jun 9, 2021
b8e5366
Files updated, addes esperanto language
DBinaghi Jun 9, 2021
8490d25
Added more control on individual elements
DBinaghi Jun 12, 2021
1930545
Added more control on individual elements
DBinaghi Jun 12, 2021
089723b
Added more control on individual elements
DBinaghi Jun 12, 2021
f77718a
Added more control on individual elements
DBinaghi Jun 12, 2021
7725345
Simplified code
DBinaghi Jun 12, 2021
fbe7bde
Added config options
DBinaghi Jun 12, 2021
da3a7e0
Added config options
DBinaghi Jun 12, 2021
35cf008
Added function, simplified code
DBinaghi Jun 12, 2021
7e893df
Update plugin.ini
DBinaghi Jun 12, 2021
d2c2648
Update Readme.md
DBinaghi Jun 12, 2021
508b84d
Update Readme.md
DBinaghi Jun 13, 2021
11ed71b
Update Readme.md
DBinaghi Jun 13, 2021
4e471e9
Update Readme.md
DBinaghi Jun 13, 2021
041654a
Update Readme.md
DBinaghi Jun 13, 2021
74283a5
Update Readme.md
DBinaghi Jun 13, 2021
3121cba
Update Readme.md
DBinaghi Jun 13, 2021
0a341c9
Update Readme.md
DBinaghi Jun 13, 2021
fdb5205
Update Readme.md
DBinaghi Jun 13, 2021
4fde0b1
Update plugin.ini
DBinaghi Jun 13, 2021
27fa215
Added layout options
DBinaghi Jun 13, 2021
83bde60
Added layout options
DBinaghi Jun 13, 2021
f759c5a
Added layout features
DBinaghi Jun 13, 2021
06ad8b9
Added layout features
DBinaghi Jun 13, 2021
faf642e
Update language files
DBinaghi Jun 13, 2021
6062864
Update plugin.ini
DBinaghi Jun 14, 2021
bb2441d
Update plugin.ini
DBinaghi Jun 15, 2021
1489255
Delete facets.jpg
DBinaghi Jun 15, 2021
e5347d4
Delete cross.svg
DBinaghi Jun 15, 2021
8b32750
Improved styling for vertical layout
DBinaghi Jun 15, 2021
2c38930
Fixed references, cleaned up code
DBinaghi Jun 15, 2021
46286f4
Added ability to collapse automatically if screen size is too small
DBinaghi Jun 15, 2021
66e67e8
Update Readme.md
DBinaghi Jun 15, 2021
57841d0
Corrected typo
DBinaghi Jun 15, 2021
fa74ece
Update template.pot
DBinaghi Jun 15, 2021
0e6c543
Update it.po
DBinaghi Jun 15, 2021
8d1ea80
Update eo.po
DBinaghi Jun 15, 2021
ce0924f
Added isset() controls to fix possible warnings issue
DBinaghi Jul 4, 2021
5b3e7fa
Added isset() controls to solve possible warnings issue
DBinaghi Jul 4, 2021
e1faef3
Added isset() check to avoid warnings issue
DBinaghi Jul 4, 2021
20ed45f
Added isset() checks to avoid warnings issues
DBinaghi Jul 4, 2021
d964977
Update FacetsFunctions.php
DBinaghi Jul 4, 2021
5695eaf
Closed brackets
DBinaghi Jul 4, 2021
7b6eed6
Update Readme.md
DBinaghi Jul 5, 2021
eebc7d8
Update plugin.ini
DBinaghi Jul 5, 2021
fb04250
Changed elements table, adding not-DC elements
DBinaghi Jul 5, 2021
6dcf436
Added not-DC elements
DBinaghi Jul 5, 2021
2bd82c6
Update template.pot
DBinaghi Jul 5, 2021
62c853d
Updated fi
DBinaghi Jul 5, 2021
7c39d19
Fixed typos, tidied up indentation
DBinaghi Jul 6, 2021
782a9f9
Changed header string
DBinaghi Jul 6, 2021
accbfb7
Changed string
DBinaghi Jul 6, 2021
0fc4143
Changed string
DBinaghi Jul 6, 2021
1d61b84
Changed string
DBinaghi Jul 6, 2021
d4206e7
Updated files
DBinaghi Jul 6, 2021
cf6e593
Corrected bug
DBinaghi Jul 7, 2021
69a131e
Update plugin.ini
DBinaghi Jul 7, 2021
60477e8
Update plugin.ini
DBinaghi Jul 8, 2021
df27bb9
Modified get_facet_select() function
DBinaghi Jul 9, 2021
24b5efd
Removes Dublin Core element set limit
DBinaghi Jul 9, 2021
be8e02f
Corrected name of variable
DBinaghi Jul 9, 2021
13f4b5c
Added extra check for Collection and ItemType id existence
DBinaghi Jul 10, 2021
cab0ad5
Removed dropdown arrows hiding
DBinaghi Jul 10, 2021
3d08bc5
Update Readme.md
DBinaghi Jul 10, 2021
60e899d
Update Readme.md
DBinaghi Jul 10, 2021
521c149
Corrected check in functions
DBinaghi Jul 11, 2021
c052abf
Update FacetsFunctions.php
DBinaghi Jul 16, 2021
7429568
Update Readme.md
DBinaghi Jul 16, 2021
0e26cdf
Added echo
DBinaghi Jul 16, 2021
35e495b
Added style and Minimum checkbox count options
DBinaghi Jul 17, 2021
dca686c
Added checkbox support
DBinaghi Jul 17, 2021
6b7bc25
Create facets.js
DBinaghi Jul 17, 2021
f88eceb
Added checkbox style
DBinaghi Jul 17, 2021
59f00d5
Added checkbox style options
DBinaghi Jul 17, 2021
8f5ca2d
Update facets.css
DBinaghi Jul 17, 2021
cc3f79a
Modified code for new style option
DBinaghi Jul 18, 2021
3100647
Sligtly modified appearance
DBinaghi Jul 18, 2021
ea16d1c
Tidied up indentation
DBinaghi Jul 18, 2021
9ff53f2
Added checkbox option to collections, tags and item types
DBinaghi Jul 18, 2021
1f2a3e1
Fixed typos
DBinaghi Jul 18, 2021
66e82b0
Corrected typo
DBinaghi Jul 18, 2021
9fb0e1e
Fixed function
DBinaghi Jul 18, 2021
f13195b
Chanced initial collapsed status
DBinaghi Jul 18, 2021
1d483bb
Added internationalization to js strings
DBinaghi Jul 18, 2021
ba6f890
Added checkbox style
DBinaghi Jul 18, 2021
6cee805
Update config_form.php
DBinaghi Jul 18, 2021
9f94c0f
Strings updated
DBinaghi Jul 18, 2021
6c50907
Update Readme.md
DBinaghi Jul 18, 2021
0a77a1b
Update Readme.md
DBinaghi Jul 18, 2021
0c58562
Strings updated
DBinaghi Jul 18, 2021
76882fb
Update browse.php
DBinaghi Jul 18, 2021
d7b9ddb
Update plugin.ini
DBinaghi Jul 18, 2021
88c184e
Rename Readme.md to README.md
DBinaghi Jul 19, 2021
e86634a
Added new options, compacted code
DBinaghi Jul 20, 2021
44780ff
Added upgrade hook, compacted code
DBinaghi Jul 20, 2021
00ed1f2
Added new options, compacted code
DBinaghi Jul 20, 2021
b8ab4a4
Added new options
DBinaghi Jul 20, 2021
167fc7e
Update plugin.ini
DBinaghi Jul 20, 2021
05c4b85
Updated strings
DBinaghi Jul 20, 2021
723a4d5
Changed way to build $params array
DBinaghi Jul 23, 2021
8d5dc55
Corrected typo
DBinaghi Sep 3, 2021
ca65367
Vertically centered table cells of first column
DBinaghi Sep 3, 2021
6183573
Corrected typos
DBinaghi Sep 3, 2021
f5170f2
Corrected typo
DBinaghi Sep 3, 2021
567990a
Corrected typos
DBinaghi Sep 3, 2021
a92d822
Added search parameter to items search
DBinaghi Sep 29, 2021
9360a0e
Fixed bug, fixed search parameters
DBinaghi Sep 29, 2021
4a92066
Updated version
DBinaghi Sep 29, 2021
e5c5945
Update README.md
DBinaghi Sep 29, 2021
4fd818b
Added additional control on array $elements
DBinaghi Oct 3, 2021
421300c
Added information about date fields
DBinaghi Oct 3, 2021
2c532e1
Update plugin.ini
DBinaghi Oct 3, 2021
3caafe8
Update browse.php
DBinaghi Oct 4, 2021
ed44f53
Corrected typo
DBinaghi Dec 11, 2021
0a1979a
Hardcoded record type for functions limited to Items
DBinaghi Dec 11, 2021
306237d
Added style for checkbox labels
DBinaghi Dec 11, 2021
7338fff
Fixed extras issue, improved logic for tags, removed useless function
DBinaghi Dec 11, 2021
813e911
Update README.md
DBinaghi Dec 11, 2021
4b1c438
Update plugin.ini
DBinaghi Dec 11, 2021
262c5b0
Corrected typo
DBinaghi Dec 11, 2021
952d5fd
Update plugin.ini
DBinaghi Dec 11, 2021
7efd3cb
Fixed layout glitch
DBinaghi Aug 4, 2022
a59e6ae
Modified some properties, moved constansts
DBinaghi Aug 4, 2022
488b133
Modified layout
DBinaghi Aug 4, 2022
2851450
Removed property, modified property
DBinaghi Aug 4, 2022
c660dc0
Removed property
DBinaghi Aug 4, 2022
d67656c
Remove property, modified strings
DBinaghi Aug 4, 2022
0aec6aa
Updated strings
DBinaghi Aug 4, 2022
1de13d0
Update plugin.ini
DBinaghi Aug 4, 2022
ce05d0c
Update README.md
DBinaghi Sep 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
489 changes: 364 additions & 125 deletions FacetsPlugin.php

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Facets

## Description

Plugin for Omeka Classic. Once installed and active, allows to insert a Faceted search refining block containing available metadata values extracted from browsing context. Works for both Items and Collections.

Settings allow to choose the hook to be used, which criteria to use for search refinement, whether to ignore single entries, sorting order for values, whether to show values popularity, whether to use an horizontal or vertical layout, whether to make the block collapsible, etc.

## Credits

Original development is part of the [Armarium](https://www.armarium-hautsdefrance.fr/) Project, managed by the french association [AR2L Hauts de France](http://www.ar2l-hdf.fr/).

Fixed and improved version by [DBinaghi](https://github.com/DBinaghi).

## Installation
Uncompress files and rename plugin folder "Facets".

Then install it like any other Omeka plugin.

## (optional) Theme customization

Facets will appear by default in the **Items browse** and **Collections browse** pages, where the `public_items_browse` and `public_collections_browse` hooks are set. It is possible to use instead a custom `public_facets` hook, that can be positioned wherever needed (`YOUR_THEME/items/browse.php` or `YOUR_THEME/common/header.php`, f.i.) according to the theme used; in such a case, the use of [get_specific_plugin_hook_output](http://omeka.readthedocs.io/en/latest/Reference/libraries/globals/get_specific_plugin_hook_output.html) function is suggested.

For **Thanks, Roy** theme, for example, best way is to change `common/header.php` code using the custom hook, while unchecking **Block collapsible** option and setting **Vertical** as **Block layout**:
```php
<div id="search-container" role="search">
<?php if (get_theme_option('use_advanced_search') === null || get_theme_option('use_advanced_search')): ?>
<?php echo search_form(array('show_advanced' => true)); ?>
<?php else: ?>
<?php echo search_form(); ?>
<?php endif; ?>
</div>
<?php echo get_specific_plugin_hook_output('Facets', 'public_facets', array('view' => $this)); ?>
```
For **Berlin** theme, instead, check **Block collapsible** option, set **Horizontal** as **Block layout** and then add the custom hook in `items/browse.php` and `collections/browse.php`:
```php
<?php echo item_search_filters(); ?>

<?php echo get_specific_plugin_hook_output('Facets', 'public_facets', array('view' => $this)); ?>

<?php echo pagination_links(); ?>
```

Background and foreground colors, as well as other parameters, can be customized in `facets.css` file (`views/public/css` folder).

## Plugin configuration

The elements used for search refinement can be selected in the configuration page; best practice suggestion is to activate only elements that are displayed in the browse page, and that are offering some kind of data aggregation (a unique id would not offer any really useful refinement).

Similarly, one can choose to also include **Item Types**, **Collections** and **Tags** to the facets block.

**Single values** can be exluded as not really significant, although they will be listed anyway if less than 5 values are available.

Facets block can be set up for **vertical** or **horizontal** layout, according to the theme layout; and it can be made **collapsible**, to use less vertical space (recommended for horizontal layout).

Style for facets can be either **dropdown selectbox**, or **checkbox**; this last one allows to choose more values, while with the first one one value excludes other. For checkbox style, a **minimum amount of values** can be set too.

Sorting order can be **alphabetical**, or **first by popularity and then alphabetical**. Popularity count can be shown, if needed.

**Date** element filter's behaviour is a bit different: dates are ordered decrescently, and only year is displayed; consequently, the matching will be with the beginning of the date (assuming the format is '_yyyy-mm-dd_'). By default, the following are considered date fields: '**Date**', '**Date Available**', '**Date Created**', '**Date Accepted**', '**Date Copyrighted**', '**Date Submitted**', '**Date Issued**', '**Date Modified**', '**Date Valid**' (the list can be changed in browse.php file).

## Licence
MIT Licence, please credit AR2L [AR2L Hauts de France](http://www.ar2l-hdf.fr/) and [Daniele Binaghi](https://github.com/DBinaghi).
35 changes: 0 additions & 35 deletions Readme.md

This file was deleted.

289 changes: 289 additions & 0 deletions config_form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
<?php
$view = get_view();
?>
<style type = "text/css">
.boxes, .boxes-left {
vertical-align: middle;
}
.boxes {
text-align: center;
}
.field select {
margin-bottom: 0;
}
</style>

<h2><?php echo __('Use'); ?></h2>

<div class="field">
<div class="two columns alpha">
<?php echo $view->formLabel('facets_public_hook', __('Public Hooks')); ?>
</div>
<div class="inputs five columns omega">
<p class="explanation">
<?php echo __('The hooks you want to use: Omeka\'s default <code>public_items_browse</code> and <code>public_collections_browse</code>, already coded into every page (so no changes are needed), normally showing up at the end of the page; or the plugin\'s own <code>public_facets</code>, that has to be coded into relevant theme pages but can be used wherever deemed right.'); ?>
</p>
<?php echo $view->formRadio('facets_public_hook',
get_option('facets_public_hook'),
null,
array(
'default' => 'public_items_browse & public_collections_browse',
'custom' => 'public_facets',
));
?>
</div>
</div>

<h2><?php echo __('Aspect'); ?></h2>

<div class="field">
<div class="two columns alpha">
<?php echo $view->formLabel('facets_description', __('Description')); ?>
</div>
<div class="inputs five columns omega">
<p class="explanation">
<?php echo __('If checked, a short description will be shown above all values.'); ?>
</p>
<?php echo $view->formCheckbox('facets_description', get_option('facets_description'), null, array('1', '0')); ?>
</div>
</div>

<div class="field">
<div class="two columns alpha">
<?php echo $view->formLabel('facets_count', __('Facet Count')); ?>
</div>
<div class="inputs five columns omega">
<p class="explanation">
<?php echo __('For all checkbox style fields, the maximum amount of values to be displayed (0 means all values will be displayed).'); ?>
</p>
<?php echo $view->formText('facets_count', get_option('facets_count')); ?>
</div>
</div>

<div class="field">
<div class="two columns alpha">
<?php echo $view->formLabel('facets_direction', __('Block Layout')); ?>
</div>
<div class="inputs five columns omega">
<p class="explanation">
<?php echo __('The layout direction of the facets block.'); ?>
</p>
<?php echo $view->formSelect(
'facets_direction',
get_option('facets_direction'),
array(),
array(
'horizontal' => __('Horizontal (useful for themes with top main navigation menu)'),
'vertical' => __('Vertical (useful for themes with side main navigation menu)')
));
?>
</div>
</div>

<div class="field">
<div class="two columns alpha">
<?php echo $view->formLabel('facets_collapsible', __('Collapsible Block')); ?>
</div>
<div class="inputs five columns omega">
<p class="explanation">
<?php echo __('If checked, facets block will be collapsible (tip: as it saves space, it\'s particularly useful with horizontal theme layouts).'); ?>
</p>
<?php echo $view->formCheckbox('facets_collapsible', get_option('facets_collapsible'), null, array('1', '0')); ?>
</div>
</div>

<h2><?php echo __('Elements'); ?></h2>

<div class="field">
<div class="inputs seven columns omega">
<p class="explanation">
<?php echo __('The elements that can be used for search refinement. Item and Collection columns to (de)activate, Style column to choose the facet style, Sort order column to choose sorting order, Popularity column to show counters near names.'); ?>
</p>
<table id="facets_elements-table">
<thead>
<tr>
<th class="boxes"><?php echo __('Element Name'); ?></th>
<th class="boxes"><?php echo __('Item'); ?></th>
<th class="boxes"><?php echo __('Collection'); ?></th>
<th class="boxes"><?php echo __('Style'); ?></th>
<th class="boxes"><?php echo __('Sort Order'); ?></th>
<th class="boxes"><?php echo __('Popularity'); ?></th>
</tr>
</thead>
<tbody>
<?php
$current_element_set = null;
foreach ($elements as $element):
if ($element->set_name != $current_element_set):
$current_element_set = $element->set_name;
?>
<tr>
<th colspan="6">
<strong><?php echo __($current_element_set); ?></strong>
</th>
</tr>
<?php endif; ?>
<tr>
<td class="boxes-left"><?php echo __($element->name); ?></td>
<td class="boxes">
<?php
echo $view->formCheckbox(
"elements[{$element->name}][item]",
'1',
array(
'disableHidden' => true,
'checked' => (isset($settings['elements'][$element->name]['item']) && $settings['elements'][$element->name]['item'] == 1)
)
);
?>
</td>
<td class="boxes">
<?php
if ($element->set_name == 'Dublin Core') {
echo $view->formCheckbox(
"elements[{$element->name}][collection]",
'1',
array(
'disableHidden' => true,
'checked' => (isset($settings['elements'][$element->name]['collection']) && $settings['elements'][$element->name]['collection'] == 1)
)
);
} else {
echo "&nbsp";
}
?>
</td>
<td class="boxes">
<?php
$style = (isset($settings['elements'][$element->name]['style']) ? $settings['elements'][$element->name]['style'] : '');
echo $view->formSelect(
"elements[{$element->name}][style]",
$style,
array(),
array(
'dropdown' => __('Dropdown'),
'checkbox' => __('Checkbox')
)
);
?>
</td>
<td class="boxes">
<?php
$sortOrder = (isset($settings['elements'][$element->name]['sort']) ? $settings['elements'][$element->name]['sort'] : '');
echo $view->formSelect(
"elements[{$element->name}][sort]",
$sortOrder,
array(),
array(
'alpha' => __('Alphabetical'),
'count_alpha' => __('Popularity first, then alphabetical')
)
);
?>
</td>
<td class="boxes">
<?php
echo $view->formCheckbox(
"elements[{$element->name}][popularity]",
'1',
array(
'disableHidden' => true,
'checked' => (isset($settings['elements'][$element->name]['popularity']) && $settings['elements'][$element->name]['popularity'] == 1)
)
);
?>
</td>
</tr>
<?php endforeach; ?>
<tr>
<th colspan="6">
<strong><?php echo __('Extra parameters'); ?></strong>
</th>
</tr>
<?php
$extraParameters = array(
'item_types' => array('label' => 'Item Type', 'collection' => 0),
'collections' => array('label' => 'Collection', 'collection' => 0),
'tags' => array('label' => 'Tags', 'collection' => 0),
'users' => array('label' => 'Owner', 'collection' => 1),
'public' => array('label' => 'Public', 'collection' => 1),
'featured' => array('label' => 'Featured', 'collection' => 1)
);
foreach ($extraParameters as $key => $value):
?>
<tr>
<td class="boxes-left"><?php echo __($value['label']); ?></td>
<td class="boxes">
<?php
echo $view->formCheckbox(
"{$key}[item]",
'1',
array(
'disableHidden' => true,
'checked' => (isset($settings[$key]['item']) && $settings[$key]['item'] == 1)
)
);
?>
</td>
<td class="boxes">
<?php
if ($value['collection']) {
echo $view->formCheckbox(
"{$key}[collection]",
'1',
array(
'disableHidden' => true,
'checked' => isset($settings[$key]['collection'])
)
);
} else {
echo "&nbsp;";
}
?>
</td>
<td class="boxes">
<?php
$style = (isset($settings[$key]['style']) ? $settings[$key]['style'] : '');
echo $view->formSelect(
"{$key}[style]",
$style,
array(),
array(
'dropdown' => __('Dropdown'),
'checkbox' => __('Checkbox')
)
);
?>
</td>
<td class="boxes">
<?php
$sort = (isset($settings[$key]['sort']) ? $settings[$key]['sort'] : '');
echo $view->formSelect(
"{$key}[sort]",
$sort,
array(),
array(
'alpha' => __('Alphabetical'),
'count_alpha' => __('Popularity first, then alphabetical')
)
);
?>
</td>
<td class="boxes">
<?php
echo $view->formCheckbox(
"{$key}[popularity]",
'1',
array(
'disableHidden' => true,
'checked' => (isset($settings[$key]['popularity']) && $settings[$key]['popularity'] == 1)
)
);
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
Binary file removed facets.jpg
Binary file not shown.
Loading