Skip to content

Commit

Permalink
Add docs for new 2.7 filters
Browse files Browse the repository at this point in the history
  • Loading branch information
zerocrates committed Jun 4, 2019
1 parent b5d40c6 commit b5dcc4d
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 13 deletions.
6 changes: 5 additions & 1 deletion source/Reference/filters/file_markup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ Arguments
``string`` wrapper_attributes
Attributes to apply to the wrapping ``<div>`` element


********
See Also
********

:php:func:`file_markup`, the function
30 changes: 30 additions & 0 deletions source/Reference/filters/file_markup_files.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#################
file_markup_files
#################

.. versionadded:: 2.7

*****
Usage
*****

Filter the set of files to be displayed by :php:func:`file_markup`

Omeka uses functions like :php:func:`files_for_item` to render all
the files attached to an item; this filter allows a developer
to alter that list, for example to exclude some files from being
displayed.

*****
Value
*****

``array`` $files
Array of :php:class:`File` objects to be displayed

*********
Arguments
*********

``array`` options
Options passed to ``file_markup``
54 changes: 54 additions & 0 deletions source/Reference/filters/file_markup_options.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
###################
file_markup_options
###################

.. versionadded:: 2.7

*****
Usage
*****

Modify the options passed to :php:func:`file_markup`

Unlike the :doc:`file_markup` filter, this filter allows you to change
options that Omeka uses when rendering HTML for a file, meaning you can
alter the output without having to write completely new markup yourself.

*****
Value
*****

``array`` $options
Array of options for ``file_markup``

*********
Arguments
*********

:php:class:`File` file
The file object

********
Examples
********

Add ``target="_blank"`` to all links to original files:

.. code-block:: php
class MyPlugin extends :php:class:`Omeka_Plugin_AbstractPlugin`
{
protected $_filters = array('file_markup_options');
public filterHtmlPurifierConfigSetup($options, $args)
{
$options['linkAttributes']['target'] = '_blank';
return $options;
}
}
********
See Also
********

:php:func:`file_markup` documentation for a list of possible options
43 changes: 43 additions & 0 deletions source/Reference/filters/files_for_item.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
##############
files_for_item
##############

.. versionadded:: 2.7

*****
Usage
*****

Filter the HTML for displaying all files for an item.

The :doc:`file_markup` filter is used to modify the HTML markup for
displaying a single file, but this filter can be used to modify the
markup for all the files being displayed as a whole (for example, to
add markup that comes before or after, or wraps around, all the
displayed files).

*****
Value
*****

``string`` $html
The HTML for displaying the files

*********
Arguments
*********

:php:class:`Item` item
The item object

``array`` options
Options to pass to the callback

``string`` wrapperAttributes
Attributes to apply to the wrapping ``<div>`` element

********
See Also
********

:php:func:`files_for_item`
60 changes: 60 additions & 0 deletions source/Reference/filters/html_purifier_config_setup.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
##########################
html_purifier_config_setup
##########################

.. versionadded:: 2.7

*****
Usage
*****

Alters the configuration settings for the HTMLPurifier library.

*****
Value
*****

``HTMLPurifier_Config`` $purifierConfig
The config object for HTMLPurifier

*********
Arguments
*********

``array`` defaults
The default configuration keys (these have already been set to the passed config object)
``array`` allowedHtmlElements
List of user-configured enabled elements
``array`` allowedHtmlAttributes
List of user-configured enabled attributes

********
Examples
********

Force a prefix on all user-provided ``id`` attributes (for other options see the HTMLPurifier
documentation pages linked below:

.. code-block:: php
class MyPlugin extends :php:class:`Omeka_Plugin_AbstractPlugin`
{
protected $_filters = array('html_purifier_config_setup');
public filterHtmlPurifierConfigSetup($purifierConfig, $args)
{
$purifierConfig->set('Attr.IDPrefix', 'foo_');
return $purifierConfig;
}
}
********
See Also
********

- `HTMLPurifier customization documentation <http://htmlpurifier.org/docs/enduser-customize.html>`_

- `HTMLPurifier list of configuration options <http://htmlpurifier.org/live/configdoc/plain.html>`_


39 changes: 39 additions & 0 deletions source/Reference/filters/image_tag_attributes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
####################
image_tag_attributes
####################

.. versionadded:: 2.7

*****
Usage
*****

Filter the HTML attributes used for an record's image.

This filter affects ``<img>`` tags created by :php:func:`file_markup`, :php:func:`files_for_item`,
:php:func:`record_image`, :php:func:`item_image`, and :php:func:`file_image` (essentially meaning
it covers anywhere derivative images are used for a record).

*****
Value
*****

``array`` $attrs
Array of HTML attributes for the ``<img>`` tag.

*********
Arguments
*********

:php:class:`Omeka_Record` record
The record being displayed (could be an Item or Collection in the case of a thumbnail)

:php:class:`File` file
The file being displayed. This is always the File that directly corresponds with the
image, while ``record`` can be another record like an Item, Collection or Exhibit
that simply uses the File as its representative image.

``string`` format
Type of derivative image being displayed (e.g., ``'thumbnail'``, ``'fullsize'``, ``'square_thumbnail'``)


30 changes: 18 additions & 12 deletions source/Reference/filters/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,20 @@ Database
:maxdepth: 1

file_ingest_validators


**********************
File and Image Display
**********************

.. toctree::
:maxdepth: 1

file_markup
file_markup_files
file_markup_options
files_for_item
image_tag_attributes

*******
Records
Expand All @@ -40,7 +53,10 @@ Records
:glob:
:maxdepth: 1

<model>_*
<model>s_browse_default_sort
<model>s_browse_params
<model>s_browse_per_page
<model>s_select_options


Record Metadata
Expand All @@ -51,8 +67,6 @@ Record Metadata
:maxdepth: 1

Element_*
record_metadata_elements



******
Expand Down Expand Up @@ -83,14 +97,6 @@ Text
Views
*****

.. toctree::
:glob:
:maxdepth: 1

define*



Admin Views
===========

Expand All @@ -100,7 +106,6 @@ Admin Views

admin*



Forms
=====
Expand All @@ -119,5 +124,6 @@ Public Views
:maxdepth: 1

body_tag_attributes
public*


0 comments on commit b5dcc4d

Please sign in to comment.