Skip to content

Commit

Permalink
Replaced (integer) and (boolean) by (int) and (bool).
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-KM committed Oct 28, 2018
1 parent 77df501 commit 149b81c
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 49 deletions.
14 changes: 7 additions & 7 deletions UniversalViewerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function hookItemsBatchEditCustom($args)
$checkImageSize = $args['custom']['universalviewer']['checkImageSize'];

if ($orderByFilename) {
$this->_sortFiles($item, (boolean) $mixImages);
$this->_sortFiles($item, (bool) $mixImages);
}

if ($checkImageSize) {
Expand Down Expand Up @@ -514,7 +514,7 @@ protected function _displayUniversalViewer($args)
foreach ($recs as $record) {
$records[] = is_object($record)
? $record
: get_record_by_id($recordType, (integer) $record);
: get_record_by_id($recordType, (int) $record);
}
unset($args[$type]);
}
Expand All @@ -526,14 +526,14 @@ protected function _displayUniversalViewer($args)
$record = null;
if (!empty($args['id'])) {
// Currently only item.
$record = get_record_by_id('Item', (integer) $args['id']);
$record = get_record_by_id('Item', (int) $args['id']);
unset($args['id']);
} elseif (!empty($args['record'])) {
if (is_numeric($args['record'])) {
if (isset($args['type'])
&& in_array(ucfirst($args['type']), array('Item', 'Collection', 'File'))
) {
$record = get_record_by_id(ucfirst($args['type']), (integer) $args['record']);
$record = get_record_by_id(ucfirst($args['type']), (int) $args['record']);
}
unset($args['record']);
unset($args['type']);
Expand All @@ -543,21 +543,21 @@ protected function _displayUniversalViewer($args)
}
} elseif (!empty($args['item'])) {
if (is_numeric($args['item'])) {
$record = get_record_by_id('Item', (integer) $args['item']);
$record = get_record_by_id('Item', (int) $args['item']);
} else {
$record = $args['item'];
}
unset($args['record']);
} elseif (!empty($args['collection'])) {
if (is_numeric($args['collection'])) {
$record = get_record_by_id('Collection', (integer) $args['collection']);
$record = get_record_by_id('Collection', (int) $args['collection']);
} else {
$record = $args['collection'];
}
unset($args['collection']);
} elseif (!empty($args['file'])) {
if (is_numeric($args['file'])) {
$record = get_record_by_id('File', (integer) $args['file']);
$record = get_record_by_id('File', (int) $args['file']);
} else {
$record = $args['file'];
}
Expand Down
10 changes: 5 additions & 5 deletions controllers/ImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ protected function _cleanRequest($file)
// "!w,h": sizeByWh
elseif (strpos($size, '!') === 0) {
$pos = strpos($size, ',');
$destinationWidth = (integer) substr($size, 1, $pos);
$destinationHeight = (integer) substr($size, $pos + 1);
$destinationWidth = (int) substr($size, 1, $pos);
$destinationHeight = (int) substr($size, $pos + 1);
if (empty($destinationWidth) || empty($destinationHeight)) {
$this->view->message = __('The IIIF server cannot fulfill the request: the size "%s" is incorrect.', $size);
return;
Expand All @@ -402,8 +402,8 @@ protected function _cleanRequest($file)
// "w,h", "w," or ",h".
else {
$pos = strpos($size, ',');
$destinationWidth = (integer) substr($size, 0, $pos);
$destinationHeight = (integer) substr($size, $pos + 1);
$destinationWidth = (int) substr($size, 0, $pos);
$destinationHeight = (int) substr($size, $pos + 1);
if (empty($destinationWidth) && empty($destinationHeight)) {
$this->view->message = __('The IIIF server cannot fulfill the request: the size "%s" is incorrect.', $size);
return;
Expand Down Expand Up @@ -484,7 +484,7 @@ protected function _cleanRequest($file)
$rotation = trim($rotation, '0');
$rotationDotPos = strpos($rotation, '.');
if ($rotationDotPos === strlen($rotation)) {
$rotation = (integer) trim($rotation, '.');
$rotation = (int) trim($rotation, '.');
} elseif ($rotationDotPos === 0) {
$rotation = '0' . $rotation;
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/PresentationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ public function listAction()
$identifier = str_replace('-', '', $identifier);
if (is_numeric($identifier)) {
$recordType = 'Item';
$recordId = (integer) $identifier;
$recordId = (int) $identifier;
} else {
$recordType = substr($identifier, 0, 1);
if (!isset($map[$recordType])) {
continue;
}
$recordType = $map[$recordType];
$recordId = (integer) substr($identifier, 1);
$recordId = (int) substr($identifier, 1);
}
if ($recordId) {
$record = get_record_by_id($recordType, $recordId);
Expand Down
24 changes: 12 additions & 12 deletions libraries/UniversalViewer/Controller/Action/Helper/TileInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ protected function getTilingDataDeepzoomDzi($path)
$tilingData['media_path'] = '';
$tilingData['url_base'] = $this->tileBaseUrl;
$tilingData['path_base'] = $this->tileBaseDir;
$tilingData['size'] = (integer) $data['@attributes']['TileSize'];
$tilingData['overlap'] = (integer) $data['@attributes']['Overlap'];
$tilingData['size'] = (int) $data['@attributes']['TileSize'];
$tilingData['overlap'] = (int) $data['@attributes']['Overlap'];
$tilingData['total'] = null;
$tilingData['source']['width'] = (integer) $data['Size']['@attributes']['Width'];
$tilingData['source']['height'] = (integer) $data['Size']['@attributes']['Height'];
$tilingData['source']['width'] = (int) $data['Size']['@attributes']['Width'];
$tilingData['source']['height'] = (int) $data['Size']['@attributes']['Height'];
$tilingData['format'] = $data['@attributes']['Format'];
return $tilingData;
}
Expand All @@ -184,11 +184,11 @@ protected function getTilingDataDeepzoomJsonp($path)
$tilingData['media_path'] = '';
$tilingData['url_base'] = $this->tileBaseUrl;
$tilingData['path_base'] = $this->tileBaseDir;
$tilingData['size'] = (integer) $data['TileSize'];
$tilingData['overlap'] = (integer) $data['Overlap'];
$tilingData['size'] = (int) $data['TileSize'];
$tilingData['overlap'] = (int) $data['Overlap'];
$tilingData['total'] = null;
$tilingData['source']['width'] = (integer) $data['Size']['Width'];
$tilingData['source']['height'] = (integer) $data['Size']['Height'];
$tilingData['source']['width'] = (int) $data['Size']['Width'];
$tilingData['source']['height'] = (int) $data['Size']['Height'];
$tilingData['format'] = $data['Format'];
return $tilingData;
}
Expand All @@ -214,11 +214,11 @@ protected function getTilingDataZoomify($path)
$tilingData['media_path'] = '';
$tilingData['url_base'] = $this->tileBaseUrl;
$tilingData['path_base'] = $this->tileBaseDir;
$tilingData['size'] = (integer) $properties['TILESIZE'];
$tilingData['size'] = (int) $properties['TILESIZE'];
$tilingData['overlap'] = 0;
$tilingData['total'] = (integer) $properties['NUMTILES'];
$tilingData['source']['width'] = (integer) $properties['WIDTH'];
$tilingData['source']['height'] = (integer) $properties['HEIGHT'];
$tilingData['total'] = (int) $properties['NUMTILES'];
$tilingData['source']['width'] = (int) $properties['WIDTH'];
$tilingData['source']['height'] = (int) $properties['HEIGHT'];
$tilingData['format'] = isset($properties['FORMAT'])
? $properties['FORMAT']
: 'jpg';
Expand Down
28 changes: 14 additions & 14 deletions libraries/UniversalViewer/Controller/Action/Helper/TileServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@ protected function getLevelAndPosition($tileInfo, $source, $region, $size, $isOn
// Use row, because Deepzoom and Zoomify tiles are
// square by default.
// TODO Manage the case where tiles are not square.
$count = (integer) ceil(max($source['width'], $source['height']) / $region['height']);
$count = (int) ceil(max($source['width'], $source['height']) / $region['height']);
$cellX = $region['x'] / $region['height'];
$cellY = $region['y'] / $region['height'];
}
}
// Normal column and normal region.
else {
$count = (integer) ceil(max($source['width'], $source['height']) / $region['width']);
$count = (int) ceil(max($source['width'], $source['height']) / $region['width']);
$cellX = $region['x'] / $region['width'];
$cellY = $region['y'] / $region['width'];
}
Expand All @@ -244,14 +244,14 @@ protected function getLevelAndPosition($tileInfo, $source, $region, $size, $isOn
// Normal column. The last cell is an exception.
if (!$isLastCell) {
// Use column, because tiles are square.
$count = (integer) ceil(max($source['width'], $source['height']) / $region['width']);
$count = (int) ceil(max($source['width'], $source['height']) / $region['width']);
$cellX = $region['x'] / $region['width'];
$cellY = $region['y'] / $region['width'];
}
}
// Normal row and normal region.
else {
$count = (integer) ceil(max($source['width'], $source['height']) / $region['height']);
$count = (int) ceil(max($source['width'], $source['height']) / $region['height']);
$cellX = $region['x'] / $region['height'];
$cellY = $region['y'] / $region['height'];
}
Expand All @@ -264,14 +264,14 @@ protected function getLevelAndPosition($tileInfo, $source, $region, $size, $isOn
// Normal row. The last cell is an exception.
if (!$isLastCell) {
// Use row, because tiles are square.
$count = (integer) ceil(max($source['width'], $source['height']) / $region['height']);
$count = (int) ceil(max($source['width'], $source['height']) / $region['height']);
$cellX = $region['x'] / $region['width'];
$cellY = $region['y'] / $region['height'];
}
}
// Normal column and normal region.
else {
$count = (integer) ceil(max($source['width'], $source['height']) / $region['width']);
$count = (int) ceil(max($source['width'], $source['height']) / $region['width']);
$cellX = $region['x'] / $region['width'];
$cellY = $region['y'] / $region['height'];
}
Expand All @@ -282,7 +282,7 @@ protected function getLevelAndPosition($tileInfo, $source, $region, $size, $isOn
// Normalize the size, but they can be cropped.
$size['width'] = $region['width'];
$size['height'] = $region['height'];
$count = (integer) ceil(max($source['width'], $source['height']) / $region['width']);
$count = (int) ceil(max($source['width'], $source['height']) / $region['width']);
$cellX = $region['x'] / $region['width'];
$cellY = $region['y'] / $region['height'];
break;
Expand All @@ -295,10 +295,10 @@ protected function getLevelAndPosition($tileInfo, $source, $region, $size, $isOn
$maxDimension = max([$source['width'], $source['height']]);
$numLevels = $this->getNumLevels($maxDimension);
// In IIIF, levels start at the tile size.
$numLevels -= (integer) log($cellSize, 2);
$numLevels -= (int) log($cellSize, 2);
$squaleFactors = $this->getScaleFactors($numLevels);
$maxSize = max($source['width'], $source['height']);
$total = (integer) ceil($maxSize / $tileInfo['size']);
$total = (int) ceil($maxSize / $tileInfo['size']);
// If level is set, count is not set and useless.
$level = isset($level) ? $level : 0;
$count = isset($count) ? $count : 0;
Expand All @@ -319,8 +319,8 @@ protected function getLevelAndPosition($tileInfo, $source, $region, $size, $isOn
$isLevelFound = false;
foreach ($reversedSqualeFactors as $level => $reversedFactor) {
$tileFactor = $reversedFactor * $tileInfo['size'];
$countX = (integer) ceil($source['width'] / $tileFactor);
$countY = (integer) ceil($source['height'] / $tileFactor);
$countX = (int) ceil($source['width'] / $tileFactor);
$countY = (int) ceil($source['height'] / $tileFactor);
$lastRegionWidth = $source['width'] - (($countX - 1) * $tileFactor);
$lastRegionHeight = $source['height'] - (($countY - 1) * $tileFactor);
$lastRegionX = $source['width'] - $lastRegionWidth;
Expand All @@ -347,7 +347,7 @@ protected function getLevelAndPosition($tileInfo, $source, $region, $size, $isOn
// TODO Check if the cell size is the required one (always true for image tiled here).

if ($isOneBased) {
$level += (integer) log($cellSize, 2);
$level += (int) log($cellSize, 2);
}

return [
Expand All @@ -373,7 +373,7 @@ protected function getLevelAndPosition($tileInfo, $source, $region, $size, $isOn
*/
protected function getNumLevels($maxDimension)
{
$result = (integer) ceil(log($maxDimension, 2)) + 1;
$result = (int) ceil(log($maxDimension, 2)) + 1;
return $result;
}

Expand Down Expand Up @@ -459,7 +459,7 @@ protected function getTileGroup($image, $tile)
+ $tile['row'] * $tierSizeInTiles[$tile['level']][0]
+ $tileCountUpToTier[$tile['level']];
$tileGroup = ($tileIndex / $tile['size']) ?: 0;
return (integer) $tileGroup;
return (int) $tileGroup;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions views/admin/plugins/universal-viewer-config-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</div>
<div class="inputs five columns omega">
<?php echo $this->formCheckbox('universalviewer_manifest_description_default', true,
array('checked' => (boolean) get_option('universalviewer_manifest_description_default'))); ?>
array('checked' => (bool) get_option('universalviewer_manifest_description_default'))); ?>
<p class="explanation">
<?php echo __('If checked, and if there is no metadata for the element above, the Omeka citation will be added in all manifests and viewers as main description.'); ?>
</p>
Expand Down Expand Up @@ -138,7 +138,7 @@
</div>
<div class="inputs five columns omega">
<?php echo $this->formCheckbox('universalviewer_append_collections_show', true,
array('checked' => (boolean) get_option('universalviewer_append_collections_show'))); ?>
array('checked' => (bool) get_option('universalviewer_append_collections_show'))); ?>
</div>
</div>
<div class="field">
Expand All @@ -148,7 +148,7 @@
</div>
<div class="inputs five columns omega">
<?php echo $this->formCheckbox('universalviewer_append_items_show', true,
array('checked' => (boolean) get_option('universalviewer_append_items_show'))); ?>
array('checked' => (bool) get_option('universalviewer_append_items_show'))); ?>
</div>
</div>
<div class="field">
Expand All @@ -158,7 +158,7 @@
</div>
<div class="inputs five columns omega">
<?php echo $this->formCheckbox('universalviewer_append_collections_browse', true,
array('checked' => (boolean) get_option('universalviewer_append_collections_browse'))); ?>
array('checked' => (bool) get_option('universalviewer_append_collections_browse'))); ?>
</div>
</div>
<div class="field">
Expand All @@ -168,7 +168,7 @@
</div>
<div class="inputs five columns omega">
<?php echo $this->formCheckbox('universalviewer_append_items_browse', true,
array('checked' => (boolean) get_option('universalviewer_append_items_browse'))); ?>
array('checked' => (bool) get_option('universalviewer_append_items_browse'))); ?>
</div>
</div>
<p class="explanation">
Expand Down Expand Up @@ -250,7 +250,7 @@
</div>
<div class="inputs five columns omega">
<?php echo $this->formCheckbox('universalviewer_force_strict_json', true,
array('checked' => (boolean) get_option('universalviewer_force_strict_json'))); ?>
array('checked' => (bool) get_option('universalviewer_force_strict_json'))); ?>
<p class="explanation">
<?php echo __('With some servers, the json files (manifest and info) are badly formatted.'); ?>
<?php echo __('This option forces Omeka to follow strictly the json standard.'); ?>
Expand Down
4 changes: 2 additions & 2 deletions views/helpers/IiifInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function iiifInfo($record = null)
if (is_null($record)) {
$record = get_current_record('file', false);
} elseif (is_numeric($record)) {
$record = get_record_by_id('File', (integer) $record);
$record = get_record_by_id('File', (int) $record);
}

if (empty($record)) {
Expand Down Expand Up @@ -136,7 +136,7 @@ protected function _iiifTileInfo($tileInfo)
$squaleFactors = array();
$maxSize = max($tileInfo['source']['width'], $tileInfo['source']['height']);
$tileSize = $tileInfo['size'];
$total = (integer) ceil($maxSize / $tileSize);
$total = (int) ceil($maxSize / $tileSize);
$factor = 1;
while ($factor / 2 <= $total) {
$squaleFactors[] = $factor;
Expand Down
2 changes: 1 addition & 1 deletion views/helpers/IiifManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ protected function _iiifTileInfo($tileInfo)
$squaleFactors = array();
$maxSize = max($tileInfo['source']['width'], $tileInfo['source']['height']);
$tileSize = $tileInfo['size'];
$total = (integer) ceil($maxSize / $tileSize);
$total = (int) ceil($maxSize / $tileSize);
$factor = 1;
while ($factor / 2 <= $total) {
$squaleFactors[] = $factor;
Expand Down

0 comments on commit 149b81c

Please sign in to comment.