From 6382c1c6692288759ef83a175aed6a023575d5ee Mon Sep 17 00:00:00 2001 From: JamesJohns Date: Tue, 20 Aug 2013 15:30:05 +0100 Subject: [PATCH 1/2] Add md5 and sha1 checksum to General. --- .../Describr/Plugins/BoxUK/GeneralPlugin.php | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/BoxUK/Describr/Plugins/BoxUK/GeneralPlugin.php b/lib/BoxUK/Describr/Plugins/BoxUK/GeneralPlugin.php index d139726..b9d64f1 100644 --- a/lib/BoxUK/Describr/Plugins/BoxUK/GeneralPlugin.php +++ b/lib/BoxUK/Describr/Plugins/BoxUK/GeneralPlugin.php @@ -37,7 +37,7 @@ public function getMatchingFileExtensions() } /** - * @return array with keys "extension", "type", "mimeType" + * @return array with keys "extension", "type", "mimeType", "fileSizeInBytes", "md5Checksum" and "sha1Checksum" */ public function setAttributes() { @@ -45,6 +45,8 @@ public function setAttributes() $this->attributes['type'] = $this->getFileType(); $this->attributes['mimeType'] = $this->mimeTypeOfCurrentFile; $this->attributes['fileSizeInBytes'] = $this->getFileSizeInBytes(); + $this->attributes['md5Checksum'] = $this->getFileMd5Checksum(); + $this->attributes['sha1Checksum'] = $this->getFileSha1Checksum(); $this->addAutoTagsByFileSize(); } @@ -187,4 +189,22 @@ protected function getSizeOfMovie($sizeInKb) } return $fileSizeDescription; } + + /** + * Get file md5 hash. + * @return string + */ + protected function getFileMd5Checksum() + { + return md5_file($this->fullPathToFileOnDisk); + } + + /** + * Get file sha1 hash. + * @return string + */ + protected function getFileSha1Checksum() + { + return sha1_file($this->fullPathToFileOnDisk); + } } From 8ddca3e9249684bdba3f0b8ea724a4db914b74b3 Mon Sep 17 00:00:00 2001 From: JamesJohns Date: Tue, 20 Aug 2013 15:39:34 +0100 Subject: [PATCH 2/2] CS updates to General. --- lib/BoxUK/Describr/Plugins/BoxUK/GeneralPlugin.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/BoxUK/Describr/Plugins/BoxUK/GeneralPlugin.php b/lib/BoxUK/Describr/Plugins/BoxUK/GeneralPlugin.php index b9d64f1..51429db 100644 --- a/lib/BoxUK/Describr/Plugins/BoxUK/GeneralPlugin.php +++ b/lib/BoxUK/Describr/Plugins/BoxUK/GeneralPlugin.php @@ -87,10 +87,10 @@ private function addAutoTagsByFileSize() return; } - $sizeInKb = filesize ($this->fullPathToFileOnDisk) / 1024; + $sizeInKb = filesize($this->fullPathToFileOnDisk) / 1024; $function = 'getSizeOf' . ucfirst($this->getFileType()); - if(!function_exists($function)) { + if (!function_exists($function)) { $function = 'getSizeOf'; } $fileSizeDescription = $this->$function($sizeInKb); @@ -110,7 +110,7 @@ protected function getSizeOf($sizeInKb) $fileSizeDescription = 'Extra Large'; if ($sizeInKb < 32) { $fileSizeDescription = 'Extra Small'; - }else if ($sizeInKb < 128) { + } elseif ($sizeInKb < 128) { $fileSizeDescription = 'Small'; } elseif ($sizeInKb < 512) { $fileSizeDescription = 'Medium'; @@ -130,7 +130,7 @@ protected function getSizeOfImage($sizeInKb) $fileSizeDescription = 'Extra Large'; if ($sizeInKb < 16) { $fileSizeDescription = 'Extra Small'; - }else if ($sizeInKb < 32) { + } elseif ($sizeInKb < 32) { $fileSizeDescription = 'Small'; } elseif ($sizeInKb < 64) { $fileSizeDescription = 'Medium'; @@ -160,7 +160,7 @@ protected function getSizeOfDocument($sizeInKb) $fileSizeDescription = 'Extra Large'; if ($sizeInKb < 32) { $fileSizeDescription = 'Extra Small'; - }else if ($sizeInKb < 256) { + } elseif ($sizeInKb < 256) { $fileSizeDescription = 'Small'; } elseif ($sizeInKb < 1024) { $fileSizeDescription = 'Medium'; @@ -180,7 +180,7 @@ protected function getSizeOfMovie($sizeInKb) $fileSizeDescription = 'Extra Large'; if ($sizeInKb < 128) { $fileSizeDescription = 'Extra Small'; - }else if ($sizeInKb < 512) { + } elseif ($sizeInKb < 512) { $fileSizeDescription = 'Small'; } elseif ($sizeInKb < 2048) { $fileSizeDescription = 'Medium';