diff --git a/module/VuFind/src/VuFind/Cover/Generator.php b/module/VuFind/src/VuFind/Cover/Generator.php index 262184861720893f02e3a963d38f996ca9686a3a..474d79255b9f2cb9d6130521ed7ceb2e3d795931 100644 --- a/module/VuFind/src/VuFind/Cover/Generator.php +++ b/module/VuFind/src/VuFind/Cover/Generator.php @@ -76,7 +76,7 @@ class Generator 'topPadding' => 19, 'wrapWidth' => 80, ); - foreach($settings as $i=>$setting) { + foreach ($settings as $i=>$setting) { $default[$i] = $setting; } $default['authorFont'] = $this->fontPath($default['authorFont']); @@ -155,20 +155,20 @@ class Generator } if (null !== $callnumber) { $cv = 0; - for($i=0;$i<strlen($callnumber);$i++) { - $cv += ord($callnumber[$i]); + for ($i=0;$i<strlen($callnumber);$i++) { + $cv += ord($callnumber[$i]); } return $cv; } else { // If no callnumber, random - return ceil(rand(pow(2,4), pow(2,32))); + return ceil(rand(pow(2, 4), pow(2, 32))); } } /** * Turn number into pattern * - * @param integer $title Title of the book + * @param integer $seed Seed used to generate the pattern * * @return string binary string describing a quarter of the pattern */ @@ -177,19 +177,19 @@ class Generator // Convert to binary $bc = decbin($seed); // If we have less that a half of a quarter - if(strlen($bc) < 8) { - // Rotate square of the first 4 into a 4x2 - // Simulate matrix rotation on string - $bc = substr($bc, 0, 3) - . substr($bc, 0, 1) - . substr($bc, 2, 2) - . substr($bc, 3, 1) - . substr($bc, 1, 1); + if (strlen($bc) < 8) { + // Rotate square of the first 4 into a 4x2 + // Simulate matrix rotation on string + $bc = substr($bc, 0, 3) + . substr($bc, 0, 1) + . substr($bc, 2, 2) + . substr($bc, 3, 1) + . substr($bc, 1, 1); } // If we have less than a quarter - if(strlen($bc) < 16) { - // Rotate the first 8 as a 4x2 into a 4x4 - $bc .= strrev($bc); + if (strlen($bc) < 16) { + // Rotate the first 8 as a 4x2 into a 4x4 + $bc .= strrev($bc); } return $bc; } @@ -267,8 +267,8 @@ class Generator /** * Render author at bottom in wrapped, white text with black border * - * @param GCImage $im Image object to render to - * @param string $author Author to write + * @param GCImage $im Image object to render to + * @param string $author Author to write * * @return void */ @@ -277,25 +277,31 @@ class Generator // Scale author to fit by incrementing fontsizes down $fontSize = $this->settings->fontSize; do { - $txtWidth=$this->textWidth($author, $this->settings->titleFont, $fontSize); + $txtWidth=$this->textWidth( + $author, + $this->settings->titleFont, + $fontSize + ); $fontSize--; } while ($txtWidth > $this->settings->wrapWidth); // white text, black outline + $fontSize = ++$fontSize < $this->settings->minFontSize + ? $this->settings->fontSize + : $fontSize; + // Too small to read? Align left + $alignment = $fontSize < $this->settings->minFontSize + ? 'left' + : null; $this->drawText( $im, $author, 3, $this->settings->size-3, $this->settings->authorFont, - ++$fontSize < $this->settings->minFontSize - ? $this->settings->fontSize - : $fontSize, + $fontSize, $this->white, $this->black, - // Too small to read? Align left - $fontSize < $this->settings->minFontSize - ? 'left' - : null + $alignment ); } @@ -344,8 +350,9 @@ class Generator * * @return void */ - protected function drawText($im, $text, $x, $y, $font, $fontSize, $mcolor, $scolor, $align = null) - { + protected function drawText($im, $text, $x, $y, + $font, $fontSize, $mcolor, $scolor, $align = null + ) { $txtWidth = $this->textWidth( $text, $this->settings->titleFont, @@ -393,17 +400,17 @@ class Generator protected function render($bc, $im, $color, $half, $box) { $bc = str_split($bc); - for($k=0;$k<4;$k++) { + for ($k=0;$k<4;$k++) { $x = $k%2 ? $half : $half-$box; $y = $k/2<1 ? $half : $half-$box; $u = $k%2 ? $box : -$box; $v = $k/2<1 ? $box : -$box; - for($i=0;$i<16;$i++) { - if($bc[$i] == "1") { + for ($i=0;$i<16;$i++) { + if ($bc[$i] == "1") { imagefilledrectangle($im, $x, $y, $x+$box-1, $y+$box-1, $color); } $x += $u; - if($x >= $this->settings->size || $x < 0) { + if ($x >= $this->settings->size || $x < 0) { $x = $k%2 ? $half : $half-$box; $y += $v; } @@ -425,7 +432,9 @@ class Generator protected function makeHSBColor($im, $h, $s, $v) { $s /= 256.0; - if ($s == 0.0) return imagecolorallocate($im, $v,$v,$v); + if ($s == 0.0) { + return imagecolorallocate($im, $v, $v, $v); + } $h /= (256.0 / 6.0); $i = floor($h); $f = $h - $i; @@ -433,12 +442,12 @@ class Generator $q = (integer)($v * (1.0 - $s * $f)); $t = (integer)($v * (1.0 - $s * (1.0 - $f))); switch($i) { - case 0: return imagecolorallocate($im, $v,$t,$p); - case 1: return imagecolorallocate($im, $q,$v,$p); - case 2: return imagecolorallocate($im, $p,$v,$t); - case 3: return imagecolorallocate($im, $p,$q,$v); - case 4: return imagecolorallocate($im, $t,$p,$v); - default: return imagecolorallocate($im, $v,$p,$q); + case 0: return imagecolorallocate($im, $v, $t, $p); + case 1: return imagecolorallocate($im, $q, $v, $p); + case 2: return imagecolorallocate($im, $p, $v, $t); + case 3: return imagecolorallocate($im, $p, $q, $v); + case 4: return imagecolorallocate($im, $t, $p, $v); + default: return imagecolorallocate($im, $v, $p, $q); } return imagecolorallocate($im, $R, $G, $B); } diff --git a/module/VuFind/src/VuFind/Cover/Loader.php b/module/VuFind/src/VuFind/Cover/Loader.php index e4f7d5640421954c6ad0d0bcab89049b2c578f54..6b7efb5adcfb191fcb4469f05a8d9e618cfbb5ff 100644 --- a/module/VuFind/src/VuFind/Cover/Loader.php +++ b/module/VuFind/src/VuFind/Cover/Loader.php @@ -211,9 +211,12 @@ class Loader implements \Zend\Log\LoggerAwareInterface /** * Load an image given an ISBN and/or content type. * - * @param string $isn ISBN - * @param string $size Requested size - * @param string $type Content type + * @param string $isn ISBN + * @param string $size Requested size + * @param string $type Content type + * @param string $title Title of book (for dynamic covers) + * @param string $author Author of the book (for dynamic covers) + * @param string $callnumber Callnumber (unique id for dynamic covers) * * @return void */ diff --git a/themes/blueprint/js/ill.js b/themes/blueprint/js/ill.js index fe02ebc41b4a0273120d7b46ce9779ca1e7e81b5..e299090be42c60bf290de463948bfc82e274778f 100644 --- a/themes/blueprint/js/ill.js +++ b/themes/blueprint/js/ill.js @@ -1,3 +1,4 @@ +/*global path */ function setUpILLRequestForm(recordId) { $("#ILLRequestForm #pickupLibrary").change(function() { $("#ILLRequestForm #pickupLibraryLocation option").remove(); diff --git a/themes/bootstrap/js/common.js b/themes/bootstrap/js/common.js index e35a3374b763109f2313cd7227ad932294a8b4bd..6a5e42e394cacef5e1337d85e0795f67d1723980 100644 --- a/themes/bootstrap/js/common.js +++ b/themes/bootstrap/js/common.js @@ -1,4 +1,4 @@ -/*global Lightbox, path, vufindString */ +/*global checkSaveStatuses, console, extractSource, hexEncode, Lightbox, path, rc4Encrypt, refreshCommentList, vufindString */ /* --- GLOBAL FUNCTIONS --- */ function htmlEncode(value){ @@ -248,26 +248,28 @@ function ajaxLogin(form) { /* --- BOOTSTRAP LIBRARY TWEAKS --- */ // Prevent typeahead highlighting $.fn.typeahead.Constructor.prototype.render = function(items) { - var that = this + var that = this; items = $(items).map(function (i, item) { - i = $(that.options.item).attr('data-value', item) - i.find('a').html(that.highlighter(item)) - return i[0] + i = $(that.options.item).attr('data-value', item); + i.find('a').html(that.highlighter(item)); + return i[0]; }) - this.$menu.html(items) - return this + this.$menu.html(items); + return this; }; // Enter without highlight does not delete the query $.fn.typeahead.Constructor.prototype.select = function () { - var val = this.$menu.find('.active') - if(val.length > 0) val = val.attr('data-value') - else val = this.$element.val() + var val = this.$menu.find('.active'); + if (val.length > 0) { + val = val.attr('data-value'); + } + else val = this.$element.val(); this.$element .val(this.updater(val)) - .change() - return this.hide() + .change(); + return this.hide(); } $(document).ready(function() { diff --git a/themes/bootstrap/js/ill.js b/themes/bootstrap/js/ill.js index 923707ddc3ddbaa5ebb629d3867efd232f527dcb..ef89332825268d4047096eb09abd206125ecb2fd 100644 --- a/themes/bootstrap/js/ill.js +++ b/themes/bootstrap/js/ill.js @@ -1,3 +1,4 @@ +/*global path */ function setUpILLRequestForm(recordId) { $("#ILLRequestForm #pickupLibrary").change(function() { $("#ILLRequestForm #pickupLibraryLocation option").remove(); diff --git a/themes/bootstrap/js/lightbox.js b/themes/bootstrap/js/lightbox.js index dcdfe5af99dff6e28156d141cc62fd1102c87b03..a7971d49d50bc6a3ea4a1c3521319c7309544973 100644 --- a/themes/bootstrap/js/lightbox.js +++ b/themes/bootstrap/js/lightbox.js @@ -1,4 +1,4 @@ -/*global checkSaveStatuses, console, deparam, extractSource, hexEncode, htmlEncode, path, rc4Encrypt, refreshCommentList, vufindString */ +/*global checkSaveStatuses, console, deparam, path, refreshCommentList, vufindString */ var Lightbox = { /** @@ -219,7 +219,7 @@ var Lightbox = { try { var data = JSON.parse(d.responseText); Lightbox.changeContent('<p class="alert alert-error">'+data.data+'</p>'); - } catch(e) { + } catch(error) { Lightbox.changeContent('<p class="alert alert-error">'+d.responseText+'</p>'); } } else {