style fixes
This commit is contained in:
parent
7425efade7
commit
ac6a3133ec
|
@ -825,7 +825,7 @@ function getMimeIcon(mime, ready){
|
|||
getMimeIcon.cache={};
|
||||
|
||||
function getPreviewIcon(path, ready){
|
||||
ready(OC.Router.generate('core_ajax_preview', {file: encodeURIComponent(path), x:44, y:44}));
|
||||
ready(OC.Router.generate('core_ajax_preview', {file: encodeURIComponent(path), x:36, y:36}));
|
||||
}
|
||||
|
||||
function getUniqueName(name){
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
$totaldirs = 0;
|
||||
$totalsize = 0; ?>
|
||||
<?php foreach($_['files'] as $file):
|
||||
$relativePath = substr($file['path'], 6);
|
||||
$relativePath = substr($file['path'], 6); //strlen('files/') => 6
|
||||
$totalsize += $file['size'];
|
||||
if ($file['type'] === 'dir') {
|
||||
$totaldirs++;
|
||||
|
|
|
@ -196,7 +196,7 @@ if (isset($path)) {
|
|||
OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=');
|
||||
$list->assign('isPublic', true);
|
||||
$list->assign('sharingtoken', $token);
|
||||
$list->assign('sharingroot', ($path));
|
||||
$list->assign('sharingroot', $basePath);
|
||||
$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
|
||||
$breadcrumbNav->assign('breadcrumb', $breadcrumb);
|
||||
$breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path=');
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
\OC_Util::checkLoggedIn();
|
||||
|
||||
$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
|
||||
$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36';
|
||||
$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36';
|
||||
$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
|
||||
|
||||
if($file === '') {
|
||||
\OC_Response::setStatus(400); //400 Bad Request
|
||||
\OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG);
|
||||
\OC\Preview::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
if($maxX === 0 || $maxY === 0) {
|
||||
\OC_Response::setStatus(400); //400 Bad Request
|
||||
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
|
||||
\OC\Preview::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
try{
|
||||
$preview = new \OC\Preview(\OC_User::getUser(), 'files');
|
||||
$preview->setFile($file);
|
||||
$preview->setMaxX($maxX);
|
||||
$preview->setMaxY($maxY);
|
||||
$preview->setScalingUp($scalingUp);
|
||||
|
||||
$preview->show();
|
||||
}catch(\Exception $e) {
|
||||
\OC_Response::setStatus(500);
|
||||
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
|
||||
\OC\Preview::showErrorPreview();
|
||||
exit;
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
if(!\OC_App::isEnabled('files_sharing')){
|
||||
exit;
|
||||
}
|
||||
|
||||
$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
|
||||
$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36';
|
||||
$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36';
|
||||
$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
|
||||
$token = array_key_exists('t', $_GET) ? (string) $_GET['t'] : '';
|
||||
|
||||
if($token === ''){
|
||||
\OC_Response::setStatus(400); //400 Bad Request
|
||||
\OC_Log::write('core-preview', 'No token parameter was passed', \OC_Log::DEBUG);
|
||||
\OC\Preview::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
$linkedItem = \OCP\Share::getShareByToken($token);
|
||||
if($linkedItem === false || ($linkedItem['item_type'] !== 'file' && $linkedItem['item_type'] !== 'folder')) {
|
||||
\OC_Response::setStatus(404);
|
||||
\OC_Log::write('core-preview', 'Passed token parameter is not valid', \OC_Log::DEBUG);
|
||||
\OC\Preview::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!isset($linkedItem['uid_owner']) || !isset($linkedItem['file_source'])) {
|
||||
\OC_Response::setStatus(500);
|
||||
\OC_Log::write('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OC_Log::WARN);
|
||||
\OC\Preview::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
$userId = $linkedItem['uid_owner'];
|
||||
\OC_Util::setupFS($userId);
|
||||
|
||||
$pathId = $linkedItem['file_source'];
|
||||
$path = \OC\Files\Filesystem::getPath($pathId);
|
||||
$pathInfo = \OC\Files\Filesystem::getFileInfo($path);
|
||||
$sharedFile = null;
|
||||
|
||||
if($linkedItem['item_type'] === 'folder') {
|
||||
$isvalid = \OC\Files\Filesystem::isValidPath($file);
|
||||
if(!$isvalid) {
|
||||
\OC_Response::setStatus(400); //400 Bad Request
|
||||
\OC_Log::write('core-preview', 'Passed filename is not valid, might be malicious (file:"' . $file . '";ip:"' . $_SERVER['REMOTE_ADDR'] . '")', \OC_Log::WARN);
|
||||
\OC\Preview::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
$sharedFile = \OC\Files\Filesystem::normalizePath($file);
|
||||
}
|
||||
|
||||
if($linkedItem['item_type'] === 'file') {
|
||||
$parent = $pathInfo['parent'];
|
||||
$path = \OC\Files\Filesystem::getPath($parent);
|
||||
$sharedFile = $pathInfo['name'];
|
||||
}
|
||||
|
||||
$path = \OC\Files\Filesystem::normalizePath($path, false);
|
||||
if(substr($path, 0, 1) === '/') {
|
||||
$path = substr($path, 1);
|
||||
}
|
||||
|
||||
if($maxX === 0 || $maxY === 0) {
|
||||
\OC_Response::setStatus(400); //400 Bad Request
|
||||
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
|
||||
\OC\Preview::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
$root = 'files/' . $path;
|
||||
|
||||
try{
|
||||
$preview = new \OC\Preview($userId, $root);
|
||||
$preview->setFile($sharedFile);
|
||||
$preview->setMaxX($maxX);
|
||||
$preview->setMaxY($maxY);
|
||||
$preview->setScalingUp($scalingUp);
|
||||
|
||||
$preview->show();
|
||||
}catch(\Exception $e) {
|
||||
\OC_Response::setStatus(500);
|
||||
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
|
||||
\OC\Preview::showErrorPreview();
|
||||
exit;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
\OC_Util::checkLoggedIn();
|
||||
|
||||
if(!\OC_App::isEnabled('files_trashbin')){
|
||||
exit;
|
||||
}
|
||||
|
||||
$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
|
||||
$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '44';
|
||||
$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '44';
|
||||
$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
|
||||
|
||||
if($file === '') {
|
||||
\OC_Response::setStatus(400); //400 Bad Request
|
||||
\OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG);
|
||||
\OC\Preview::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
if($maxX === 0 || $maxY === 0) {
|
||||
\OC_Response::setStatus(400); //400 Bad Request
|
||||
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
|
||||
\OC\Preview::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
try{
|
||||
$preview = new \OC\Preview(\OC_User::getUser(), 'files_trashbin/files');
|
||||
$preview->setFile($file);
|
||||
$preview->setMaxX($maxX);
|
||||
$preview->setMaxY($maxY);
|
||||
$preview->setScalingUp($scalingUp);
|
||||
|
||||
$preview->showPreview();
|
||||
}catch(\Exception $e) {
|
||||
\OC_Response::setStatus(500);
|
||||
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
|
||||
\OC\Preview::showErrorPreview();
|
||||
exit;
|
||||
}
|
|
@ -43,11 +43,11 @@ $this->create('js_config', '/core/js/config.js')
|
|||
$this->create('core_ajax_routes', '/core/routes.json')
|
||||
->action('OC_Router', 'JSRoutes');
|
||||
$this->create('core_ajax_preview', '/core/preview.png')
|
||||
->action('OC\Preview', 'previewRouter');
|
||||
->actionInclude('core/ajax/preview.php');
|
||||
$this->create('core_ajax_trashbin_preview', '/core/trashbinpreview.png')
|
||||
->action('OC\Preview', 'trashbinPreviewRouter');
|
||||
->actionInclude('core/ajax/trashbinpreview.php');
|
||||
$this->create('core_ajax_public_preview', '/core/publicpreview.png')
|
||||
->action('OC\Preview', 'publicPreviewRouter');
|
||||
->actionInclude('core/ajax/publicpreview.php');
|
||||
OC::$CLASSPATH['OC_Core_LostPassword_Controller'] = 'core/lostpassword/controller.php';
|
||||
$this->create('core_lostpassword_index', '/lostpassword/')
|
||||
->get()
|
||||
|
|
|
@ -233,7 +233,7 @@ class OC_Helper {
|
|||
return self::linkToRoute( 'core_ajax_preview', array('x' => 36, 'y' => 36, 'file' => urlencode($path) ));
|
||||
}
|
||||
|
||||
public static function publicPreview_icon( $path, $token ) {
|
||||
public static function publicPreviewIcon( $path, $token ) {
|
||||
return self::linkToRoute( 'core_ajax_public_preview', array('x' => 36, 'y' => 36, 'file' => urlencode($path), 't' => $token));
|
||||
}
|
||||
|
||||
|
|
308
lib/preview.php
308
lib/preview.php
|
@ -55,12 +55,12 @@ class Preview {
|
|||
* @param string $file The path to the file where you want a thumbnail from
|
||||
* @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
|
||||
* @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
|
||||
* @param bool $scalingup Disable/Enable upscaling of previews
|
||||
* @param bool $scalingUp Disable/Enable upscaling of previews
|
||||
* @return mixed (bool / string)
|
||||
* false if thumbnail does not exist
|
||||
* path to thumbnail if thumbnail exists
|
||||
*/
|
||||
public function __construct($user='', $root='/', $file='', $maxX=1, $maxY=1, $scalingup=true) {
|
||||
public function __construct($user='', $root='/', $file='', $maxX=1, $maxY=1, $scalingUp=true) {
|
||||
//set config
|
||||
$this->configMaxX = \OC_Config::getValue('preview_max_x', null);
|
||||
$this->configMaxY = \OC_Config::getValue('preview_max_y', null);
|
||||
|
@ -70,11 +70,11 @@ class Preview {
|
|||
$this->setFile($file);
|
||||
$this->setMaxX($maxX);
|
||||
$this->setMaxY($maxY);
|
||||
$this->setScalingUp($scalingup);
|
||||
$this->setScalingUp($scalingUp);
|
||||
|
||||
//init fileviews
|
||||
if($user === ''){
|
||||
$user = OC_User::getUser();
|
||||
$user = \OC_User::getUser();
|
||||
}
|
||||
$this->fileview = new \OC\Files\View('/' . $user . '/' . $root);
|
||||
$this->userview = new \OC\Files\View('/' . $user);
|
||||
|
@ -120,7 +120,7 @@ class Preview {
|
|||
* @brief returns whether or not scalingup is enabled
|
||||
* @return bool
|
||||
*/
|
||||
public function getScalingup() {
|
||||
public function getScalingUp() {
|
||||
return $this->scalingup;
|
||||
}
|
||||
|
||||
|
@ -172,8 +172,8 @@ class Preview {
|
|||
* @return $this
|
||||
*/
|
||||
public function setMaxX($maxX=1) {
|
||||
if($maxX === 0) {
|
||||
throw new \Exception('Cannot set width of 0!');
|
||||
if($maxX <= 0) {
|
||||
throw new \Exception('Cannot set width of 0 or smaller!');
|
||||
}
|
||||
$configMaxX = $this->getConfigMaxX();
|
||||
if(!is_null($configMaxX)) {
|
||||
|
@ -192,8 +192,8 @@ class Preview {
|
|||
* @return $this
|
||||
*/
|
||||
public function setMaxY($maxY=1) {
|
||||
if($maxY === 0) {
|
||||
throw new \Exception('Cannot set height of 0!');
|
||||
if($maxY <= 0) {
|
||||
throw new \Exception('Cannot set height of 0 or smaller!');
|
||||
}
|
||||
$configMaxY = $this->getConfigMaxY();
|
||||
if(!is_null($configMaxY)) {
|
||||
|
@ -208,14 +208,14 @@ class Preview {
|
|||
|
||||
/**
|
||||
* @brief set whether or not scalingup is enabled
|
||||
* @param bool $scalingup
|
||||
* @param bool $scalingUp
|
||||
* @return $this
|
||||
*/
|
||||
public function setScalingup($scalingup) {
|
||||
public function setScalingup($scalingUp) {
|
||||
if($this->getMaxScaleFactor() === 1) {
|
||||
$scalingup = false;
|
||||
$scalingUp = false;
|
||||
}
|
||||
$this->scalingup = $scalingup;
|
||||
$this->scalingup = $scalingUp;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -245,12 +245,12 @@ class Preview {
|
|||
public function deletePreview() {
|
||||
$file = $this->getFile();
|
||||
|
||||
$fileinfo = $this->fileview->getFileInfo($file);
|
||||
$fileid = $fileinfo['fileid'];
|
||||
$fileInfo = $this->fileview->getFileInfo($file);
|
||||
$fileId = $fileInfo['fileid'];
|
||||
|
||||
$previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/' . $this->getMaxX() . '-' . $this->getMaxY() . '.png';
|
||||
$this->userview->unlink($previewpath);
|
||||
return !$this->userview->file_exists($previewpath);
|
||||
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/' . $this->getMaxX() . '-' . $this->getMaxY() . '.png';
|
||||
$this->userview->unlink($previewPath);
|
||||
return !$this->userview->file_exists($previewPath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -260,13 +260,13 @@ class Preview {
|
|||
public function deleteAllPreviews() {
|
||||
$file = $this->getFile();
|
||||
|
||||
$fileinfo = $this->fileview->getFileInfo($file);
|
||||
$fileid = $fileinfo['fileid'];
|
||||
$fileInfo = $this->fileview->getFileInfo($file);
|
||||
$fileId = $fileInfo['fileid'];
|
||||
|
||||
$previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/';
|
||||
$this->userview->deleteAll($previewpath);
|
||||
$this->userview->rmdir($previewpath);
|
||||
return !$this->userview->is_dir($previewpath);
|
||||
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
|
||||
$this->userview->deleteAll($previewPath);
|
||||
$this->userview->rmdir($previewPath);
|
||||
return !$this->userview->is_dir($previewPath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -279,45 +279,45 @@ class Preview {
|
|||
$file = $this->getFile();
|
||||
$maxX = $this->getMaxX();
|
||||
$maxY = $this->getMaxY();
|
||||
$scalingup = $this->getScalingup();
|
||||
$scalingUp = $this->getScalingUp();
|
||||
$maxscalefactor = $this->getMaxScaleFactor();
|
||||
|
||||
$fileinfo = $this->fileview->getFileInfo($file);
|
||||
$fileid = $fileinfo['fileid'];
|
||||
$fileInfo = $this->fileview->getFileInfo($file);
|
||||
$fileId = $fileInfo['fileid'];
|
||||
|
||||
if(is_null($fileid)) {
|
||||
if(is_null($fileId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/';
|
||||
if(!$this->userview->is_dir($previewpath)) {
|
||||
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
|
||||
if(!$this->userview->is_dir($previewPath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//does a preview with the wanted height and width already exist?
|
||||
if($this->userview->file_exists($previewpath . $maxX . '-' . $maxY . '.png')) {
|
||||
return $previewpath . $maxX . '-' . $maxY . '.png';
|
||||
if($this->userview->file_exists($previewPath . $maxX . '-' . $maxY . '.png')) {
|
||||
return $previewPath . $maxX . '-' . $maxY . '.png';
|
||||
}
|
||||
|
||||
$wantedaspectratio = (float) ($maxX / $maxY);
|
||||
$wantedAspectRatio = (float) ($maxX / $maxY);
|
||||
|
||||
//array for usable cached thumbnails
|
||||
$possiblethumbnails = array();
|
||||
$possibleThumbnails = array();
|
||||
|
||||
$allthumbnails = $this->userview->getDirectoryContent($previewpath);
|
||||
foreach($allthumbnails as $thumbnail) {
|
||||
$allThumbnails = $this->userview->getDirectoryContent($previewPath);
|
||||
foreach($allThumbnails as $thumbnail) {
|
||||
$name = rtrim($thumbnail['name'], '.png');
|
||||
$size = explode('-', $name);
|
||||
$x = (int) $size[0];
|
||||
$y = (int) $size[1];
|
||||
|
||||
$aspectratio = (float) ($x / $y);
|
||||
if($aspectratio !== $wantedaspectratio) {
|
||||
$aspectRatio = (float) ($x / $y);
|
||||
if($aspectRatio !== $wantedAspectRatio) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($x < $maxX || $y < $maxY) {
|
||||
if($scalingup) {
|
||||
if($scalingUp) {
|
||||
$scalefactor = $maxX / $x;
|
||||
if($scalefactor > $maxscalefactor) {
|
||||
continue;
|
||||
|
@ -326,28 +326,28 @@ class Preview {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
$possiblethumbnails[$x] = $thumbnail['path'];
|
||||
$possibleThumbnails[$x] = $thumbnail['path'];
|
||||
}
|
||||
|
||||
if(count($possiblethumbnails) === 0) {
|
||||
if(count($possibleThumbnails) === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(count($possiblethumbnails) === 1) {
|
||||
return current($possiblethumbnails);
|
||||
if(count($possibleThumbnails) === 1) {
|
||||
return current($possibleThumbnails);
|
||||
}
|
||||
|
||||
ksort($possiblethumbnails);
|
||||
ksort($possibleThumbnails);
|
||||
|
||||
if(key(reset($possiblethumbnails)) > $maxX) {
|
||||
return current(reset($possiblethumbnails));
|
||||
if(key(reset($possibleThumbnails)) > $maxX) {
|
||||
return current(reset($possibleThumbnails));
|
||||
}
|
||||
|
||||
if(key(end($possiblethumbnails)) < $maxX) {
|
||||
return current(end($possiblethumbnails));
|
||||
if(key(end($possibleThumbnails)) < $maxX) {
|
||||
return current(end($possibleThumbnails));
|
||||
}
|
||||
|
||||
foreach($possiblethumbnails as $width => $path) {
|
||||
foreach($possibleThumbnails as $width => $path) {
|
||||
if($width < $maxX) {
|
||||
continue;
|
||||
}else{
|
||||
|
@ -358,7 +358,7 @@ class Preview {
|
|||
|
||||
/**
|
||||
* @brief return a preview of a file
|
||||
* @return image
|
||||
* @return \OC_Image
|
||||
*/
|
||||
public function getPreview() {
|
||||
if(!is_null($this->preview) && $this->preview->valid()){
|
||||
|
@ -369,10 +369,10 @@ class Preview {
|
|||
$file = $this->getFile();
|
||||
$maxX = $this->getMaxX();
|
||||
$maxY = $this->getMaxY();
|
||||
$scalingup = $this->getScalingup();
|
||||
$scalingUp = $this->getScalingUp();
|
||||
|
||||
$fileinfo = $this->fileview->getFileInfo($file);
|
||||
$fileid = $fileinfo['fileid'];
|
||||
$fileInfo = $this->fileview->getFileInfo($file);
|
||||
$fileId = $fileInfo['fileid'];
|
||||
|
||||
$cached = $this->isCached();
|
||||
|
||||
|
@ -386,12 +386,12 @@ class Preview {
|
|||
$mimetype = $this->fileview->getMimeType($file);
|
||||
$preview = null;
|
||||
|
||||
foreach(self::$providers as $supportedmimetype => $provider) {
|
||||
if(!preg_match($supportedmimetype, $mimetype)) {
|
||||
foreach(self::$providers as $supportedMimetype => $provider) {
|
||||
if(!preg_match($supportedMimetype, $mimetype)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingup, $this->fileview);
|
||||
$preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingUp, $this->fileview);
|
||||
|
||||
if(!($preview instanceof \OC_Image)) {
|
||||
continue;
|
||||
|
@ -400,18 +400,18 @@ class Preview {
|
|||
$this->preview = $preview;
|
||||
$this->resizeAndCrop();
|
||||
|
||||
$previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/';
|
||||
$cachepath = $previewpath . $maxX . '-' . $maxY . '.png';
|
||||
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
|
||||
$cachePath = $previewPath . $maxX . '-' . $maxY . '.png';
|
||||
|
||||
if($this->userview->is_dir($this->getThumbnailsFolder() . '/') === false) {
|
||||
$this->userview->mkdir($this->getThumbnailsFolder() . '/');
|
||||
}
|
||||
|
||||
if($this->userview->is_dir($previewpath) === false) {
|
||||
$this->userview->mkdir($previewpath);
|
||||
if($this->userview->is_dir($previewPath) === false) {
|
||||
$this->userview->mkdir($previewPath);
|
||||
}
|
||||
|
||||
$this->userview->file_put_contents($cachepath, $preview->data());
|
||||
$this->userview->file_put_contents($cachePath, $preview->data());
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -447,13 +447,13 @@ class Preview {
|
|||
|
||||
/**
|
||||
* @brief resize, crop and fix orientation
|
||||
* @return image
|
||||
* @return void
|
||||
*/
|
||||
private function resizeAndCrop() {
|
||||
$image = $this->preview;
|
||||
$x = $this->getMaxX();
|
||||
$y = $this->getMaxY();
|
||||
$scalingup = $this->getScalingup();
|
||||
$scalingUp = $this->getScalingUp();
|
||||
$maxscalefactor = $this->getMaxScaleFactor();
|
||||
|
||||
if(!($image instanceof \OC_Image)) {
|
||||
|
@ -480,7 +480,7 @@ class Preview {
|
|||
$factor = $factorY;
|
||||
}
|
||||
|
||||
if($scalingup === false) {
|
||||
if($scalingUp === false) {
|
||||
if($factor > 1) {
|
||||
$factor = 1;
|
||||
}
|
||||
|
@ -583,182 +583,6 @@ class Preview {
|
|||
array_multisort($keys, SORT_DESC, self::$providers);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief method that handles preview requests from users that are logged in
|
||||
* @return void
|
||||
*/
|
||||
public static function previewRouter() {
|
||||
\OC_Util::checkLoggedIn();
|
||||
|
||||
$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
|
||||
$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36';
|
||||
$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36';
|
||||
$scalingup = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
|
||||
|
||||
if($file === '') {
|
||||
\OC_Response::setStatus(400); //400 Bad Request
|
||||
\OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG);
|
||||
self::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
if($maxX === 0 || $maxY === 0) {
|
||||
\OC_Response::setStatus(400); //400 Bad Request
|
||||
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
|
||||
self::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
try{
|
||||
$preview = new Preview(\OC_User::getUser(), 'files');
|
||||
$preview->setFile($file);
|
||||
$preview->setMaxX($maxX);
|
||||
$preview->setMaxY($maxY);
|
||||
$preview->setScalingUp($scalingup);
|
||||
|
||||
$preview->show();
|
||||
}catch(\Exception $e) {
|
||||
\OC_Response::setStatus(500);
|
||||
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
|
||||
self::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief method that handles preview requests from users that are not logged in / view shared folders that are public
|
||||
* @return void
|
||||
*/
|
||||
public static function publicPreviewRouter() {
|
||||
if(!\OC_App::isEnabled('files_sharing')){
|
||||
exit;
|
||||
}
|
||||
|
||||
$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
|
||||
$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36';
|
||||
$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36';
|
||||
$scalingup = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
|
||||
$token = array_key_exists('t', $_GET) ? (string) $_GET['t'] : '';
|
||||
|
||||
if($token === ''){
|
||||
\OC_Response::setStatus(400); //400 Bad Request
|
||||
\OC_Log::write('core-preview', 'No token parameter was passed', \OC_Log::DEBUG);
|
||||
self::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
$linkedItem = \OCP\Share::getShareByToken($token);
|
||||
if($linkedItem === false || ($linkedItem['item_type'] !== 'file' && $linkedItem['item_type'] !== 'folder')) {
|
||||
\OC_Response::setStatus(404);
|
||||
\OC_Log::write('core-preview', 'Passed token parameter is not valid', \OC_Log::DEBUG);
|
||||
self::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!isset($linkedItem['uid_owner']) || !isset($linkedItem['file_source'])) {
|
||||
\OC_Response::setStatus(500);
|
||||
\OC_Log::write('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")');
|
||||
self::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
$userid = $linkedItem['uid_owner'];
|
||||
\OC_Util::setupFS($userid);
|
||||
|
||||
$pathid = $linkedItem['file_source'];
|
||||
$path = \OC\Files\Filesystem::getPath($pathid);
|
||||
$pathinfo = \OC\Files\Filesystem::getFileInfo($path);
|
||||
$sharedfile = null;
|
||||
|
||||
if($linkedItem['item_type'] === 'folder') {
|
||||
$isvalid = \OC\Files\Filesystem::isValidPath($file);
|
||||
if(!$isvalid) {
|
||||
\OC_Response::setStatus(400); //400 Bad Request
|
||||
\OC_Log::write('core-preview', 'Passed filename is not valid, might be malicious (file:"' . $file . '";ip:"' . $_SERVER['REMOTE_ADDR'] . '")', \OC_Log::WARN);
|
||||
self::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
$sharedfile = \OC\Files\Filesystem::normalizePath($file);
|
||||
}
|
||||
|
||||
if($linkedItem['item_type'] === 'file') {
|
||||
$parent = $pathinfo['parent'];
|
||||
$path = \OC\Files\Filesystem::getPath($parent);
|
||||
$sharedfile = $pathinfo['name'];
|
||||
}
|
||||
|
||||
$path = \OC\Files\Filesystem::normalizePath($path, false);
|
||||
if(substr($path, 0, 1) === '/') {
|
||||
$path = substr($path, 1);
|
||||
}
|
||||
|
||||
if($maxX === 0 || $maxY === 0) {
|
||||
\OC_Response::setStatus(400); //400 Bad Request
|
||||
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
|
||||
self::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
$root = 'files/' . $path;
|
||||
|
||||
try{
|
||||
$preview = new Preview($userid, $root);
|
||||
$preview->setFile($file);
|
||||
$preview->setMaxX($maxX);
|
||||
$preview->setMaxY($maxY);
|
||||
$preview->setScalingUp($scalingup);
|
||||
|
||||
$preview->show();
|
||||
}catch(\Exception $e) {
|
||||
\OC_Response::setStatus(500);
|
||||
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
|
||||
self::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public static function trashbinPreviewRouter() {
|
||||
\OC_Util::checkLoggedIn();
|
||||
|
||||
if(!\OC_App::isEnabled('files_trashbin')){
|
||||
exit;
|
||||
}
|
||||
|
||||
$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
|
||||
$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '44';
|
||||
$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '44';
|
||||
$scalingup = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
|
||||
|
||||
if($file === '') {
|
||||
\OC_Response::setStatus(400); //400 Bad Request
|
||||
\OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG);
|
||||
self::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
if($maxX === 0 || $maxY === 0) {
|
||||
\OC_Response::setStatus(400); //400 Bad Request
|
||||
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
|
||||
self::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
|
||||
try{
|
||||
$preview = new Preview(\OC_User::getUser(), 'files_trashbin/files');
|
||||
$preview->setFile($file);
|
||||
$preview->setMaxX($maxX);
|
||||
$preview->setMaxY($maxY);
|
||||
$preview->setScalingUp($scalingup);
|
||||
|
||||
$preview->showPreview();
|
||||
}catch(\Exception $e) {
|
||||
\OC_Response::setStatus(500);
|
||||
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
|
||||
self::showErrorPreview();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public static function post_write($args) {
|
||||
self::post_delete($args);
|
||||
}
|
||||
|
@ -780,8 +604,8 @@ class Preview {
|
|||
|
||||
//remove last element because it has the mimetype *
|
||||
$providers = array_slice(self::$providers, 0, -1);
|
||||
foreach($providers as $supportedmimetype => $provider) {
|
||||
if(preg_match($supportedmimetype, $mimetype)) {
|
||||
foreach($providers as $supportedMimetype => $provider) {
|
||||
if(preg_match($supportedMimetype, $mimetype)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,13 @@ class Image extends Provider {
|
|||
|
||||
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
|
||||
//get fileinfo
|
||||
$fileinfo = $fileview->getFileInfo($path);
|
||||
$fileInfo = $fileview->getFileInfo($path);
|
||||
if(!$fileInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//check if file is encrypted
|
||||
if($fileinfo['encrypted'] === true) {
|
||||
if($fileInfo['encrypted'] === true) {
|
||||
$image = new \OC_Image(stream_get_contents($fileview->fopen($path, 'r')));
|
||||
}else{
|
||||
$image = new \OC_Image();
|
||||
|
|
|
@ -22,28 +22,30 @@ class Office extends Provider {
|
|||
return false;
|
||||
}
|
||||
|
||||
$abspath = $fileview->toTmpFile($path);
|
||||
$absPath = $fileview->toTmpFile($path);
|
||||
|
||||
$tmpdir = get_temp_dir();
|
||||
$tmpDir = get_temp_dir();
|
||||
|
||||
$exec = $this->cmd . ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir ' . escapeshellarg($tmpdir) . ' ' . escapeshellarg($abspath);
|
||||
$export = 'export HOME=/' . $tmpdir;
|
||||
$exec = $this->cmd . ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir ' . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath);
|
||||
$export = 'export HOME=/' . $tmpDir;
|
||||
|
||||
shell_exec($export . "\n" . $exec);
|
||||
|
||||
//create imagick object from pdf
|
||||
try{
|
||||
$pdf = new \imagick($abspath . '.pdf' . '[0]');
|
||||
$pdf = new \imagick($absPath . '.pdf' . '[0]');
|
||||
$pdf->setImageFormat('jpg');
|
||||
}catch(\Exception $e){
|
||||
}catch (\Exception $e) {
|
||||
unlink($absPath);
|
||||
unlink($absPath . '.pdf');
|
||||
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
$image = new \OC_Image($pdf);
|
||||
|
||||
unlink($abspath);
|
||||
unlink($abspath . '.pdf');
|
||||
unlink($absPath);
|
||||
unlink($absPath . '.pdf');
|
||||
|
||||
return $image->valid() ? $image : false;
|
||||
}
|
||||
|
@ -55,11 +57,13 @@ class Office extends Provider {
|
|||
$cmd = \OC_Config::getValue('preview_libreoffice_path', null);
|
||||
}
|
||||
|
||||
if($cmd === '' && shell_exec('libreoffice --headless --version')) {
|
||||
$whichLibreOffice = shell_exec('which libreoffice');
|
||||
if($cmd === '' && !empty($whichLibreOffice)) {
|
||||
$cmd = 'libreoffice';
|
||||
}
|
||||
|
||||
if($cmd === '' && shell_exec('openoffice --headless --version')) {
|
||||
$whichOpenOffice = shell_exec('which openoffice');
|
||||
if($cmd === '' && !empty($whichOpenOffice)) {
|
||||
$cmd = 'openoffice';
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,11 @@
|
|||
*/
|
||||
namespace OC\Preview;
|
||||
|
||||
if(!is_null(shell_exec('ffmpeg -version'))) {
|
||||
$isShellExecEnabled = !in_array('shell_exec', explode(', ', ini_get('disable_functions')));
|
||||
$whichFFMPEG = shell_exec('which ffmpeg');
|
||||
$isFFMPEGAvailable = !empty($whichFFMPEG);
|
||||
|
||||
if($isShellExecEnabled && $isFFMPEGAvailable) {
|
||||
|
||||
class Movie extends Provider {
|
||||
|
||||
|
@ -17,23 +21,23 @@ if(!is_null(shell_exec('ffmpeg -version'))) {
|
|||
}
|
||||
|
||||
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
|
||||
$abspath = \OC_Helper::tmpFile();
|
||||
$tmppath = \OC_Helper::tmpFile();
|
||||
$absPath = \OC_Helper::tmpFile();
|
||||
$tmpPath = \OC_Helper::tmpFile();
|
||||
|
||||
$handle = $fileview->fopen($path, 'rb');
|
||||
|
||||
$firstmb = stream_get_contents($handle, 1048576); //1024 * 1024 = 1048576
|
||||
file_put_contents($abspath, $firstmb);
|
||||
file_put_contents($absPath, $firstmb);
|
||||
|
||||
//$cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmppath;
|
||||
$cmd = 'ffmpeg -an -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 ' . escapeshellarg($tmppath);
|
||||
//$cmd = 'ffmpeg -y -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmpPath;
|
||||
$cmd = 'ffmpeg -an -y -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 -ss 1 ' . escapeshellarg($tmpPath);
|
||||
|
||||
shell_exec($cmd);
|
||||
|
||||
$image = new \OC_Image($tmppath);
|
||||
$image = new \OC_Image($tmpPath);
|
||||
|
||||
unlink($abspath);
|
||||
unlink($tmppath);
|
||||
unlink($absPath);
|
||||
unlink($tmpPath);
|
||||
|
||||
return $image->valid() ? $image : false;
|
||||
}
|
||||
|
|
|
@ -18,19 +18,21 @@ class MP3 extends Provider {
|
|||
|
||||
$getID3 = new \getID3();
|
||||
|
||||
$tmppath = $fileview->toTmpFile($path);
|
||||
$tmpPath = $fileview->toTmpFile($path);
|
||||
|
||||
$tags = $getID3->analyze($tmppath);
|
||||
\getid3_lib::CopyTagsToComments($tags);
|
||||
$picture = @$tags['id3v2']['APIC'][0]['data'];
|
||||
$tags = $getID3->analyze($tmpPath);
|
||||
\getid3_lib::CopyTagsToComments($tags);
|
||||
if(isset($tags['id3v2']['APIC'][0]['data'])) {
|
||||
$picture = @$tags['id3v2']['APIC'][0]['data'];
|
||||
unlink($tmpPath);
|
||||
$image = new \OC_Image($picture);
|
||||
return $image->valid() ? $image : $this->getNoCoverThumbnail();
|
||||
}
|
||||
|
||||
unlink($tmppath);
|
||||
|
||||
$image = new \OC_Image($picture);
|
||||
return $image->valid() ? $image : $this->getNoCoverThumbnail($maxX, $maxY);
|
||||
return $this->getNoCoverThumbnail();
|
||||
}
|
||||
|
||||
public function getNoCoverThumbnail($maxX, $maxY) {
|
||||
private function getNoCoverThumbnail() {
|
||||
$icon = \OC::$SERVERROOT . '/core/img/filetypes/audio.png';
|
||||
|
||||
if(!file_exists($icon)) {
|
||||
|
|
|
@ -32,16 +32,16 @@ class DOCX extends Provider {
|
|||
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
|
||||
require_once('phpdocx/classes/TransformDoc.inc');
|
||||
|
||||
$tmpdoc = $fileview->toTmpFile($path);
|
||||
$tmpDoc = $fileview->toTmpFile($path);
|
||||
|
||||
$transformdoc = new \TransformDoc();
|
||||
$transformdoc->setStrFile($tmpdoc);
|
||||
$transformdoc->generatePDF($tmpdoc);
|
||||
$transformdoc->setStrFile($tmpDoc);
|
||||
$transformdoc->generatePDF($tmpDoc);
|
||||
|
||||
$pdf = new \imagick($tmpdoc . '[0]');
|
||||
$pdf = new \imagick($tmpDoc . '[0]');
|
||||
$pdf->setImageFormat('jpg');
|
||||
|
||||
unlink($tmpdoc);
|
||||
unlink($tmpDoc);
|
||||
|
||||
$image = new \OC_Image($pdf);
|
||||
|
||||
|
@ -62,23 +62,23 @@ class MSOfficeExcel extends Provider {
|
|||
require_once('PHPExcel/Classes/PHPExcel.php');
|
||||
require_once('PHPExcel/Classes/PHPExcel/IOFactory.php');
|
||||
|
||||
$abspath = $fileview->toTmpFile($path);
|
||||
$tmppath = \OC_Helper::tmpFile();
|
||||
$absPath = $fileview->toTmpFile($path);
|
||||
$tmpPath = \OC_Helper::tmpFile();
|
||||
|
||||
$rendererName = \PHPExcel_Settings::PDF_RENDERER_DOMPDF;
|
||||
$rendererLibraryPath = \OC::$THIRDPARTYROOT . '/3rdparty/dompdf';
|
||||
|
||||
\PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath);
|
||||
|
||||
$phpexcel = new \PHPExcel($abspath);
|
||||
$phpexcel = new \PHPExcel($absPath);
|
||||
$excel = \PHPExcel_IOFactory::createWriter($phpexcel, 'PDF');
|
||||
$excel->save($tmppath);
|
||||
$excel->save($tmpPath);
|
||||
|
||||
$pdf = new \imagick($tmppath . '[0]');
|
||||
$pdf = new \imagick($tmpPath . '[0]');
|
||||
$pdf->setImageFormat('jpg');
|
||||
|
||||
unlink($abspath);
|
||||
unlink($tmppath);
|
||||
unlink($absPath);
|
||||
unlink($tmpPath);
|
||||
|
||||
$image = new \OC_Image($pdf);
|
||||
|
||||
|
|
|
@ -7,8 +7,13 @@
|
|||
*/
|
||||
//both, libreoffice backend and php fallback, need imagick
|
||||
if (extension_loaded('imagick')) {
|
||||
$isShellExecEnabled = !in_array('shell_exec', explode(', ', ini_get('disable_functions')));
|
||||
$whichLibreOffice = shell_exec('which libreoffice');
|
||||
$isLibreOfficeAvailable = !empty($whichLibreOffice);
|
||||
$whichOpenOffice = shell_exec('which libreoffice');
|
||||
$isOpenOfficeAvailable = !empty($whichOpenOffice);
|
||||
//let's see if there is libreoffice or openoffice on this machine
|
||||
if(shell_exec('libreoffice --headless --version') || shell_exec('openoffice --headless --version') || is_string(\OC_Config::getValue('preview_libreoffice_path', null))) {
|
||||
if($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) {
|
||||
require_once('libreoffice-cl.php');
|
||||
}else{
|
||||
//in case there isn't, use our fallback
|
||||
|
|
|
@ -16,18 +16,18 @@ if (extension_loaded('imagick')) {
|
|||
}
|
||||
|
||||
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
|
||||
$tmppath = $fileview->toTmpFile($path);
|
||||
$tmpPath = $fileview->toTmpFile($path);
|
||||
|
||||
//create imagick object from pdf
|
||||
try{
|
||||
$pdf = new \imagick($tmppath . '[0]');
|
||||
$pdf = new \imagick($tmpPath . '[0]');
|
||||
$pdf->setImageFormat('jpg');
|
||||
}catch(\Exception $e){
|
||||
}catch (\Exception $e) {
|
||||
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
unlink($tmppath);
|
||||
unlink($tmpPath);
|
||||
|
||||
//new image object
|
||||
$image = new \OC_Image($pdf);
|
||||
|
|
|
@ -18,24 +18,23 @@ class TXT extends Provider {
|
|||
$content = stream_get_contents($content);
|
||||
|
||||
$lines = preg_split("/\r\n|\n|\r/", $content);
|
||||
$numoflines = count($lines);
|
||||
|
||||
$fontsize = 5; //5px
|
||||
$linesize = ceil($fontsize * 1.25);
|
||||
$fontSize = 5; //5px
|
||||
$lineSize = ceil($fontSize * 1.25);
|
||||
|
||||
$image = imagecreate($maxX, $maxY);
|
||||
$imagecolor = imagecolorallocate($image, 255, 255, 255);
|
||||
$textcolor = imagecolorallocate($image, 0, 0, 0);
|
||||
imagecolorallocate($image, 255, 255, 255);
|
||||
$textColor = imagecolorallocate($image, 0, 0, 0);
|
||||
|
||||
foreach($lines as $index => $line) {
|
||||
$index = $index + 1;
|
||||
|
||||
$x = (int) 1;
|
||||
$y = (int) ($index * $linesize) - $fontsize;
|
||||
$y = (int) ($index * $lineSize) - $fontSize;
|
||||
|
||||
imagestring($image, 1, $x, $y, $line, $textcolor);
|
||||
imagestring($image, 1, $x, $y, $line, $textColor);
|
||||
|
||||
if(($index * $linesize) >= $maxY) {
|
||||
if(($index * $lineSize) >= $maxY) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class Unknown extends Provider {
|
|||
list($type, $subtype) = explode('/', $mimetype);
|
||||
}
|
||||
|
||||
$iconsroot = \OC::$SERVERROOT . '/core/img/filetypes/';
|
||||
$iconsRoot = \OC::$SERVERROOT . '/core/img/filetypes/';
|
||||
|
||||
if(isset($type)){
|
||||
$icons = array($mimetype, $type, 'text');
|
||||
|
@ -30,10 +30,10 @@ class Unknown extends Provider {
|
|||
foreach($icons as $icon) {
|
||||
$icon = str_replace('/', '-', $icon);
|
||||
|
||||
$iconpath = $iconsroot . $icon . '.png';
|
||||
$iconPath = $iconsRoot . $icon . '.png';
|
||||
|
||||
if(file_exists($iconpath)) {
|
||||
return new \OC_Image($iconpath);
|
||||
if(file_exists($iconPath)) {
|
||||
return new \OC_Image($iconPath);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
|
||||
require_once __DIR__.'/template/functions.php';
|
||||
|
||||
/**
|
||||
* This class provides the templates for ownCloud.
|
||||
*/
|
||||
class OC_Template extends \OC\Template\Base {
|
||||
private $renderas; // Create a full page?
|
||||
private $path; // The path to the template
|
||||
|
|
|
@ -47,6 +47,22 @@ function image_path( $app, $image ) {
|
|||
return OC_Helper::imagePath( $app, $image );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief make preview_icon available as a simple function
|
||||
* Returns the path to the preview of the image.
|
||||
* @param $path path of file
|
||||
* @returns link to the preview
|
||||
*
|
||||
* For further information have a look at OC_Helper::previewIcon
|
||||
*/
|
||||
function preview_icon( $path ) {
|
||||
return OC_Helper::previewIcon( $path );
|
||||
}
|
||||
|
||||
function publicPreview_icon ( $path, $token ) {
|
||||
return OC_Helper::publicPreviewIcon( $path, $token );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief make OC_Helper::mimetypeIcon available as a simple function
|
||||
* @param string $mimetype mimetype
|
||||
|
|
Loading…
Reference in New Issue