Skip to content

Commit

Permalink
updates for php 7.2 (#324)
Browse files Browse the repository at this point in the history
* updates for php 7.2

* update travis yaml to match implementation

* forgot a thing

* add update hook

* update notice in core module

* language cleanup
  • Loading branch information
Daniel Aitken authored and jonathangreen committed Jul 18, 2019
1 parent a52d147 commit 4ba0d68
Show file tree
Hide file tree
Showing 337 changed files with 81 additions and 97,503 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ before_install:
- git clone -b 7.x git://github.com/Islandora/islandora_xacml_editor.git
- git clone -b 7.x git://github.com/Islandora/islandora_bookmark.git
- git clone -b 7.x git://github.com/Islandora/islandora_batch.git
- git clone git://github.com/tecnickcom/TCPDF.git
- git clone git://github.com/Islandora/citeproc-php.git
- export ISLANDORA_DIR=$HOME/islandora
- export JAVASCRIPT_DIR=$HOME/javascript
- $HOME/islandora/tests/scripts/travis_setup.sh
- cd $HOME/drupal-*
- ln -s $TRAVIS_BUILD_DIR sites/all/modules/islandora_scholar
- ln -s $HOME/citeproc-php sites/all/libraries/citeproc-php
- ln -s $HOME/TCPDF sites/all/libraries/TCPDF
- ln -s $HOME/islandora_solr_search sites/all/modules/islandora_solr_search
- ln -s $HOME/islandora_importer sites/all/modules/islandora_importer
- ln -s $HOME/islandora_xacml_editor sites/all/modules/islandora_xacml_editor
Expand All @@ -80,7 +82,6 @@ script:
- sites/all/modules/islandora_scholar/tests/scripts/line_endings.sh sites/all/modules/islandora_scholar
# XXX: Move the 3rd-party library stuff out of the way, so it doesn't
# throw warnings from coder.
- mv $TRAVIS_BUILD_DIR/modules/exporter/lib/tcpdf $HOME
- find $TRAVIS_BUILD_DIR/modules/pmid/xsl/exslt -iname "*.js" -type f -exec cp --parents -v {} $JAVASCRIPT_DIR \;
- find $TRAVIS_BUILD_DIR/modules/pmid/xsl/exslt -iname "*.js" -type f -exec rm {} \;
- drush coder-review --reviews=production,security,style,i18n,potx,sniffer --no-empty islandora_scholar
Expand All @@ -95,7 +96,6 @@ script:
- drush coder-review --reviews=production,security,style,i18n,potx,sniffer --no-empty citeproc
- drush coder-review --reviews=production,security,style,i18n,potx,sniffer --no-empty csl
# XXX: Move the 3rd-party library stuff back in, for tests.
- mv $HOME/tcpdf $TRAVIS_BUILD_DIR/modules/exporter/lib/
- cp -Rv $JAVASCRIPT_DIR/* $TRAVIS_BUILD_DIR
- phpcpd --names *.module,*.inc,*.test sites/all/modules/islandora_scholar
- vendor/bin/phpunit sites/all/modules/islandora_scholar/modules/citeproc/tests/CSL_Dateparser.test
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,21 @@ These XPaths are shared within most of the submodules. To see the MODS value aft
* Default Value: //mods:mods[1]//mods:role/mods:roleTerm
* XPath to use for the role_term.

## Upgrade notice
## Upgrade notices

### 7.x-1.3

As of Islandora 7.x-1.3, PDF datastreams of citationCModel objects are expected to have derivatives (PREVIEW, TN, optionally FULL_TEXT). Existing citations that are missing PDF-derived datastreams can be updated using the provided Drush script, which will generate the derivatives.

This can be done by running:
`drush -u 1 islandora-scholar-update-citations`

### 7.x-1.14

The TCPDF library was previously directly included inside the `citation_exporter` module; it has now been removed so that it can be managed properly via the Drupal Libraries module. If the `citation_exporter` submodule is installed when updating to Islandora 7.x-1.14, it is imperative that the TCPDF library is installed in the site libraries folder for citation exports to continue to properly function.

Check the `README.md` for the `citation_exporter` submodule for details on downloading and installing the TCPDF library.

## Documentation

Further documentation for this module is available at [our wiki](https://wiki.duraspace.org/display/ISLANDORA/Islandora+Scholar).
Expand Down
1 change: 1 addition & 0 deletions modules/bibliography/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This module requires the following modules/libraries:
* [Islandora Scholar](https://github.com/islandora/islandora_scholar)
* [CSL](https://github.com/Islandora/islandora_scholar/tree/7.x/modules/csl)
* [Citeproc](https://github.com/Islandora/islandora_scholar/tree/7.x/modules/citeproc)
* [Citation Exporter](https://github.com/islandora_scholar/tree/7.x/modules/exporter)

## Installation

Expand Down
1 change: 1 addition & 0 deletions modules/bibliography/islandora_bibliography.info
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ dependencies[] = islandora_bookmark
dependencies[] = islandora_scholar
dependencies[] = csl
dependencies[] = citeproc
dependencies[] = citation_exporter
version = 7.x-dev
core = 7.x
53 changes: 26 additions & 27 deletions modules/citeproc/includes/converter.inc
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,16 @@ function convert_mods_to_citeproc_json_genre($mods) {
function convert_mods_to_citeproc_json_title(SimpleXMLElement $mods) {
$output = '';
add_mods_namespace($mods);
$titles = $mods->xpath(variable_get('islandora_scholar_xpaths_title', '//mods:mods[1]/mods:titleInfo/mods:title'));

if (!empty($titles)) {
while (list($num, $node) = each($titles)) {
add_mods_namespace($node);
$title = (string) $node;
$subtitle = convert_mods_to_citeproc_json_query($node, variable_get('islandora_scholar_xpaths_title_subtitle', '../mods:subTitle'));
$non_sort = convert_mods_to_citeproc_json_query($node, variable_get('islandora_scholar_xpaths_title_nonsort', '../mods:nonSort'));
$title = !empty($subtitle) ? "$title: $subtitle" : $title;
$title = !empty($non_sort) ? "$non_sort $title" : $title;
// Choose the longest title.
$output = strlen($title) > strlen($output) ? $title : $output;
}

foreach ($mods->xpath(variable_get('islandora_scholar_xpaths_title', '//mods:mods[1]/mods:titleInfo/mods:title')) as $node) {
add_mods_namespace($node);
$title = (string) $node;
$subtitle = convert_mods_to_citeproc_json_query($node, variable_get('islandora_scholar_xpaths_title_subtitle', '../mods:subTitle'));
$non_sort = convert_mods_to_citeproc_json_query($node, variable_get('islandora_scholar_xpaths_title_nonsort', '../mods:nonSort'));
$title = !empty($subtitle) ? "$title: $subtitle" : $title;
$title = !empty($non_sort) ? "$non_sort $title" : $title;
// Choose the longest title.
$output = strlen($title) > strlen($output) ? $title : $output;
}
return !empty($output) ? $output : NULL;
}
Expand Down Expand Up @@ -282,12 +279,16 @@ function convert_mods_to_citeproc_json_event_place(SimpleXMLElement $mods) {
* The note property for the Citation.
*/
function convert_mods_to_citeproc_json_note(SimpleXMLElement $mods) {
$notes = $mods->xpath(variable_get('islandora_scholar_xpaths_note', '//mods:mods[1]/mods:note'));
$ouput = '';
while (list($num, $note) = each($notes)) {
$ouput .= $num + 1 . ". " . rtrim(strip_tags($note), '. ') . ". ";
}
return !empty($ouput) ? $ouput : NULL;
$output = '';
$as_string = function ($note, $idx) use (&$output) {
$output .= format_string('!idx. !note. ', array(
'!idx' => $idx + 1,
'!note' => rtrim(strip_tags((string) $note), '. '),
));
};
$elements = $mods->xpath(variable_get('islandora_scholar_xpaths_note', '//mods:mods[1]/mods:note'));
array_walk($elements, $as_string);
return empty($output) ? NULL : $output;
}

/**
Expand Down Expand Up @@ -468,15 +469,13 @@ function _get_related_marcgt_type(SimpleXMLElement $mods) {
* Get other types.
*/
function _get_other_types(SimpleXMLElement $mods) {
$output = '';

$types_local_auth = $mods->xpath(variable_get('islandora_scholar_xpaths_types_local_auth', '//mods:mods[1]/mods:genre[not(@authority="marcgt" or @authority="endnote")]'));
while (empty($output) && list($num, $type) = each($types_local_auth)) {
$interim_type = (string) $type;
$output = mods_genre_to_csl_type($interim_type);
foreach ($mods->xpath(variable_get('islandora_scholar_xpaths_types_local_auth', '//mods:mods[1]/mods:genre[not(@authority="marcgt" or @authority="endnote")]')) as $type) {
$as_string = mods_genre_to_csl_type((string) $type);
if ($as_string && !empty($as_string)) {
return $as_string;
}
}

return $output;
return '';
}

/**
Expand Down
3 changes: 3 additions & 0 deletions modules/exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ This module requires the following modules/libraries:
* [Islandora Scholar](https://github.com/islandora/islandora_scholar)
* [Citeproc](https://github.com/islandora/islandora_scholar/tree/7.x/modules/citeproc)
* [Bibutils](https://github.com/islandora/islandora_scholar/tree/7.x/modules/bibutils)
* [Libraries](https://www.drupal.org/project/libraries)

## Installation

Install as usual, see [this](https://drupal.org/documentation/install/modules-themes/modules-7) for further information.

Additionally, the [TCPDF](https://github.com/tecnickcom/TCPDF) library should be cloned into your site's libraries folder.

## Configuration

Enable the module via Administration » Modules (admin/modules)
Expand Down
1 change: 1 addition & 0 deletions modules/exporter/citation_exporter.info
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies[] = islandora
dependencies[] = islandora_scholar
dependencies[] = citeproc
dependencies[] = bibutils
dependencies[] = libraries
files[] = includes/citation.export.inc
version = 7.x-dev
core = 7.x
8 changes: 8 additions & 0 deletions modules/exporter/citation_exporter.install
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,11 @@ function citation_exporter_update_7100() {
db_create_table($table_name, $structure);
}
}

/**
* Inform of the moved TCPDF library.
*/
function citation_exporter_update_7101() {
$t = get_t();
return $t('The TCPDF library has been removed from the citation exporter module to allow it to be sourced as a proper Drupal library. It is imperative that the TCPDF library is installed in the site libraries folder in order for PDF citation exports to continue to properly function. Check the README.md under islandora_scholar/modules/exporter for more details on where to find the most up to date version of TCPDF, and how to install it.');
}
22 changes: 22 additions & 0 deletions modules/exporter/citation_exporter.module
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,25 @@ function citation_exporter_cron() {
module_load_include('inc', 'citation_exporter', 'includes/db');
array_map('citation_exporter_drop_set', $sets);
}

/**
* Implements hook_libraries_info().
*/
function citation_exporter_libraries_info() {
return array(
'TCPDF' => array(
'name' => t('TCPDF'),
'vendor url' => 'https://tcpdf.org',
'download url' => 'https://github.com/tecnickcom/TCPDF/releases',
'download file url' => 'https://github.com/tecnickcom/TCPDF/archive/master.zip',
'files' => array(
'php' => array('tcpdf.php'),
),
'version arguments' => array(
'file' => 'CHANGELOG.TXT',
'pattern' => '@([0-9.]+)@',
'lines' => 1,
),
),
);
}
8 changes: 7 additions & 1 deletion modules/exporter/includes/pdf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@
*
* @param string $output_filename
* The location to save the generated PDF.
*
* @throws Exception
* If the TCPDF library is not installed.
*/
function citation_exporter_create_pdf($html_input, $output_filename) {
module_load_include('php', 'citation_exporter', '/lib/tcpdf/tcpdf');
$tcpdf = libraries_load('TCPDF');
if (!$tcpdf['installed']) {
throw new Exception(t('Attempting to export a PDF, but the TCPDF library is not installed.'));
}

// Create new PDF document.
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, TRUE, 'UTF-8', FALSE, FALSE);
Expand Down
Loading

0 comments on commit 4ba0d68

Please sign in to comment.