fixing typos/spellings
This commit is contained in:
parent
c7324f7e44
commit
f029312e5b
2 changed files with 27 additions and 20 deletions
|
@ -13,6 +13,8 @@
|
||||||
*/
|
*/
|
||||||
namespace OC;
|
namespace OC;
|
||||||
|
|
||||||
|
use OC\Preview\Provider;
|
||||||
|
|
||||||
require_once 'preview/image.php';
|
require_once 'preview/image.php';
|
||||||
require_once 'preview/movies.php';
|
require_once 'preview/movies.php';
|
||||||
require_once 'preview/mp3.php';
|
require_once 'preview/mp3.php';
|
||||||
|
@ -46,8 +48,9 @@ class Preview {
|
||||||
// index is path, value is fileinfo
|
// index is path, value is fileinfo
|
||||||
static public $deleteFileMapper = array();
|
static public $deleteFileMapper = array();
|
||||||
|
|
||||||
//preview images object
|
|
||||||
/**
|
/**
|
||||||
|
* preview images object
|
||||||
|
*
|
||||||
* @var \OC_Image
|
* @var \OC_Image
|
||||||
*/
|
*/
|
||||||
private $preview;
|
private $preview;
|
||||||
|
@ -198,7 +201,7 @@ class Preview {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief set mimetype explicitely
|
* @brief set mimetype explicitly
|
||||||
* @param string $mimetype
|
* @param string $mimetype
|
||||||
*/
|
*/
|
||||||
public function setMimetype($mimetype) {
|
public function setMimetype($mimetype) {
|
||||||
|
@ -361,6 +364,7 @@ class Preview {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get possible bigger thumbnails of the given image
|
* @brief get possible bigger thumbnails of the given image
|
||||||
* @param int $fileId fileId of the original image
|
* @param int $fileId fileId of the original image
|
||||||
|
@ -396,6 +400,7 @@ class Preview {
|
||||||
|
|
||||||
return $possibleThumbnails;
|
return $possibleThumbnails;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDimensionsFromFilename($name) {
|
private function getDimensionsFromFilename($name) {
|
||||||
$size = explode('-', $name);
|
$size = explode('-', $name);
|
||||||
$x = (int) $size[0];
|
$x = (int) $size[0];
|
||||||
|
@ -403,6 +408,7 @@ class Preview {
|
||||||
$aspectRatio = (float) ($x / $y);
|
$aspectRatio = (float) ($x / $y);
|
||||||
return array('x' => $x,'y' => $y,'aspectRatio' => $aspectRatio);
|
return array('x' => $x,'y' => $y,'aspectRatio' => $aspectRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function unscalable($x, $y) {
|
private function unscalable($x, $y) {
|
||||||
|
|
||||||
$maxX = $this->getMaxX();
|
$maxX = $this->getMaxX();
|
||||||
|
@ -422,6 +428,7 @@ class Preview {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief return a preview of a file
|
* @brief return a preview of a file
|
||||||
* @return \OC_Image
|
* @return \OC_Image
|
||||||
|
@ -464,6 +471,7 @@ class Preview {
|
||||||
|
|
||||||
\OC_Log::write('core', 'Generating preview for "' . $file . '" with "' . get_class($provider) . '"', \OC_Log::DEBUG);
|
\OC_Log::write('core', 'Generating preview for "' . $file . '" with "' . get_class($provider) . '"', \OC_Log::DEBUG);
|
||||||
|
|
||||||
|
/** @var $provider Provider */
|
||||||
$preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingUp, $this->fileView);
|
$preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingUp, $this->fileView);
|
||||||
|
|
||||||
if (!($preview instanceof \OC_Image)) {
|
if (!($preview instanceof \OC_Image)) {
|
||||||
|
@ -507,7 +515,6 @@ class Preview {
|
||||||
$this->getPreview();
|
$this->getPreview();
|
||||||
}
|
}
|
||||||
$this->preview->show('image/png');
|
$this->preview->show('image/png');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -516,7 +523,6 @@ class Preview {
|
||||||
*/
|
*/
|
||||||
public function show() {
|
public function show() {
|
||||||
$this->showPreview();
|
$this->showPreview();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -653,6 +659,7 @@ class Preview {
|
||||||
$class = $provider['class'];
|
$class = $provider['class'];
|
||||||
$options = $provider['options'];
|
$options = $provider['options'];
|
||||||
|
|
||||||
|
/** @var $object Provider */
|
||||||
$object = new $class($options);
|
$object = new $class($options);
|
||||||
|
|
||||||
self::$providers[$object->getMimeType()] = $object;
|
self::$providers[$object->getMimeType()] = $object;
|
||||||
|
|
|
@ -17,9 +17,9 @@ class Preview extends \PHPUnit_Framework_TestCase {
|
||||||
$rootView->mkdir('/'.$user);
|
$rootView->mkdir('/'.$user);
|
||||||
$rootView->mkdir('/'.$user.'/files');
|
$rootView->mkdir('/'.$user.'/files');
|
||||||
|
|
||||||
$samplefile = '/'.$user.'/files/test.txt';
|
$sampleFile = '/'.$user.'/files/test.txt';
|
||||||
|
|
||||||
$rootView->file_put_contents($samplefile, 'dummy file data');
|
$rootView->file_put_contents($sampleFile, 'dummy file data');
|
||||||
|
|
||||||
$x = 50;
|
$x = 50;
|
||||||
$y = 50;
|
$y = 50;
|
||||||
|
@ -27,16 +27,16 @@ class Preview extends \PHPUnit_Framework_TestCase {
|
||||||
$preview = new \OC\Preview($user, 'files/', 'test.txt', $x, $y);
|
$preview = new \OC\Preview($user, 'files/', 'test.txt', $x, $y);
|
||||||
$preview->getPreview();
|
$preview->getPreview();
|
||||||
|
|
||||||
$fileinfo = $rootView->getFileInfo($samplefile);
|
$fileInfo = $rootView->getFileInfo($sampleFile);
|
||||||
$fileid = $fileinfo['fileid'];
|
$fileId = $fileInfo['fileid'];
|
||||||
|
|
||||||
$thumbcachefile = '/' . $user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileid . '/' . $x . '-' . $y . '.png';
|
$thumbCacheFile = '/' . $user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/' . $x . '-' . $y . '.png';
|
||||||
|
|
||||||
$this->assertEquals($rootView->file_exists($thumbcachefile), true);
|
$this->assertEquals($rootView->file_exists($thumbCacheFile), true);
|
||||||
|
|
||||||
$preview->deletePreview();
|
$preview->deletePreview();
|
||||||
|
|
||||||
$this->assertEquals($rootView->file_exists($thumbcachefile), false);
|
$this->assertEquals($rootView->file_exists($thumbCacheFile), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAreAllPreviewsDeleted() {
|
public function testAreAllPreviewsDeleted() {
|
||||||
|
@ -46,9 +46,9 @@ class Preview extends \PHPUnit_Framework_TestCase {
|
||||||
$rootView->mkdir('/'.$user);
|
$rootView->mkdir('/'.$user);
|
||||||
$rootView->mkdir('/'.$user.'/files');
|
$rootView->mkdir('/'.$user.'/files');
|
||||||
|
|
||||||
$samplefile = '/'.$user.'/files/test.txt';
|
$sampleFile = '/'.$user.'/files/test.txt';
|
||||||
|
|
||||||
$rootView->file_put_contents($samplefile, 'dummy file data');
|
$rootView->file_put_contents($sampleFile, 'dummy file data');
|
||||||
|
|
||||||
$x = 50;
|
$x = 50;
|
||||||
$y = 50;
|
$y = 50;
|
||||||
|
@ -56,16 +56,16 @@ class Preview extends \PHPUnit_Framework_TestCase {
|
||||||
$preview = new \OC\Preview($user, 'files/', 'test.txt', $x, $y);
|
$preview = new \OC\Preview($user, 'files/', 'test.txt', $x, $y);
|
||||||
$preview->getPreview();
|
$preview->getPreview();
|
||||||
|
|
||||||
$fileinfo = $rootView->getFileInfo($samplefile);
|
$fileInfo = $rootView->getFileInfo($sampleFile);
|
||||||
$fileid = $fileinfo['fileid'];
|
$fileId = $fileInfo['fileid'];
|
||||||
|
|
||||||
$thumbcachefolder = '/' . $user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileid . '/';
|
$thumbCacheFolder = '/' . $user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/';
|
||||||
|
|
||||||
$this->assertEquals($rootView->is_dir($thumbcachefolder), true);
|
$this->assertEquals($rootView->is_dir($thumbCacheFolder), true);
|
||||||
|
|
||||||
$preview->deleteAllPreviews();
|
$preview->deleteAllPreviews();
|
||||||
|
|
||||||
$this->assertEquals($rootView->is_dir($thumbcachefolder), false);
|
$this->assertEquals($rootView->is_dir($thumbCacheFolder), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsMaxSizeWorking() {
|
public function testIsMaxSizeWorking() {
|
||||||
|
@ -81,9 +81,9 @@ class Preview extends \PHPUnit_Framework_TestCase {
|
||||||
$rootView->mkdir('/'.$user);
|
$rootView->mkdir('/'.$user);
|
||||||
$rootView->mkdir('/'.$user.'/files');
|
$rootView->mkdir('/'.$user.'/files');
|
||||||
|
|
||||||
$samplefile = '/'.$user.'/files/test.txt';
|
$sampleFile = '/'.$user.'/files/test.txt';
|
||||||
|
|
||||||
$rootView->file_put_contents($samplefile, 'dummy file data');
|
$rootView->file_put_contents($sampleFile, 'dummy file data');
|
||||||
|
|
||||||
$preview = new \OC\Preview($user, 'files/', 'test.txt', 1000, 1000);
|
$preview = new \OC\Preview($user, 'files/', 'test.txt', 1000, 1000);
|
||||||
$image = $preview->getPreview();
|
$image = $preview->getPreview();
|
||||||
|
|
Loading…
Reference in a new issue