Revert "OC\Preview - outsource static methods"
This reverts commit 14a35267c1
.
This commit is contained in:
parent
65affdc9b3
commit
e01bc7de98
|
@ -42,13 +42,12 @@ $this->create('js_config', '/core/js/config.js')
|
|||
// Routing
|
||||
$this->create('core_ajax_routes', '/core/routes.json')
|
||||
->action('OC_Router', 'JSRoutes');
|
||||
OC::$CLASSPATH['OC\PreviewManager'] = 'lib/preview.php';
|
||||
$this->create('core_ajax_preview', '/core/preview.png')
|
||||
->action('OC\PreviewManager', 'previewRouter');
|
||||
->action('OC\Preview', 'previewRouter');
|
||||
$this->create('core_ajax_trashbin_preview', '/core/trashbinpreview.png')
|
||||
->action('OC\PreviewManager', 'trashbinPreviewRouter');
|
||||
->action('OC\Preview', 'trashbinPreviewRouter');
|
||||
$this->create('core_ajax_public_preview', '/core/publicpreview.png')
|
||||
->action('OC\PreviewManager', 'publicPreviewRouter');
|
||||
->action('OC\Preview', 'publicPreviewRouter');
|
||||
OC::$CLASSPATH['OC_Core_LostPassword_Controller'] = 'core/lostpassword/controller.php';
|
||||
$this->create('core_lostpassword_index', '/lostpassword/')
|
||||
->get()
|
||||
|
|
|
@ -44,6 +44,10 @@ class Preview {
|
|||
//preview images object
|
||||
private $preview;
|
||||
|
||||
//preview providers
|
||||
static private $providers = array();
|
||||
static private $registeredProviders = array();
|
||||
|
||||
/**
|
||||
* @brief check if thumbnail or bigger version of thumbnail of file is cached
|
||||
* @param string $user userid - if no user is given, OC_User::getUser will be used
|
||||
|
@ -78,13 +82,11 @@ class Preview {
|
|||
$this->preview = null;
|
||||
|
||||
//check if there are preview backends
|
||||
$providers = PreviewManager::getProviders();
|
||||
if(empty($providers)) {
|
||||
PreviewManager::initProviders();
|
||||
if(empty(self::$providers)) {
|
||||
self::initProviders();
|
||||
}
|
||||
|
||||
$providers = PreviewManager::getProviders();
|
||||
if(empty($providers)) {
|
||||
if(empty(self::$providers)) {
|
||||
\OC_Log::write('core', 'No preview providers exist', \OC_Log::ERROR);
|
||||
throw new \Exception('No preview providers');
|
||||
}
|
||||
|
@ -384,8 +386,7 @@ class Preview {
|
|||
$mimetype = $this->fileview->getMimeType($file);
|
||||
$preview = null;
|
||||
|
||||
$providers = PreviewManager::getProviders();
|
||||
foreach($providers as $supportedmimetype => $provider) {
|
||||
foreach(self::$providers as $supportedmimetype => $provider) {
|
||||
if(!preg_match($supportedmimetype, $mimetype)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -549,16 +550,6 @@ class Preview {
|
|||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PreviewManager {
|
||||
//preview providers
|
||||
static private $providers = array();
|
||||
static private $registeredProviders = array();
|
||||
|
||||
public static function getProviders() {
|
||||
return self::$providers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief register a new preview provider to be used
|
||||
|
@ -574,7 +565,7 @@ class PreviewManager {
|
|||
* @brief create instances of all the registered preview providers
|
||||
* @return void
|
||||
*/
|
||||
public static function initProviders() {
|
||||
private static function initProviders() {
|
||||
if(count(self::$providers)>0) {
|
||||
return;
|
||||
}
|
||||
|
@ -600,8 +591,8 @@ class PreviewManager {
|
|||
\OC_Util::checkLoggedIn();
|
||||
|
||||
$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';
|
||||
$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 === '') {
|
||||
|
@ -644,8 +635,8 @@ class PreviewManager {
|
|||
}
|
||||
|
||||
$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';
|
||||
$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'] : '';
|
||||
|
||||
|
@ -781,7 +772,7 @@ class PreviewManager {
|
|||
$preview->deleteAllPreviews();
|
||||
}
|
||||
|
||||
public static function showErrorPreview() {
|
||||
private static function showErrorPreview() {
|
||||
$path = \OC::$SERVERROOT . '/core/img/actions/delete.png';
|
||||
$preview = new \OC_Image($path);
|
||||
$preview->preciseResize(36, 36);
|
||||
|
|
|
@ -30,4 +30,4 @@ class Image extends Provider {
|
|||
}
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\Image');
|
||||
\OC\Preview::registerProvider('OC\Preview\Image');
|
|
@ -80,7 +80,7 @@ class MSOfficeDoc extends Office {
|
|||
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\MSOfficeDoc');
|
||||
\OC\Preview::registerProvider('OC\Preview\MSOfficeDoc');
|
||||
|
||||
//.docm, .dotm, .xls(m), .xlt(m), .xla(m), .ppt(m), .pot(m), .pps(m), .ppa(m)
|
||||
class MSOffice2003 extends Office {
|
||||
|
@ -91,7 +91,7 @@ class MSOffice2003 extends Office {
|
|||
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\MSOffice2003');
|
||||
\OC\Preview::registerProvider('OC\Preview\MSOffice2003');
|
||||
|
||||
//.docx, .dotx, .xlsx, .xltx, .pptx, .potx, .ppsx
|
||||
class MSOffice2007 extends Office {
|
||||
|
@ -102,7 +102,7 @@ class MSOffice2007 extends Office {
|
|||
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\MSOffice2007');
|
||||
\OC\Preview::registerProvider('OC\Preview\MSOffice2007');
|
||||
|
||||
//.odt, .ott, .oth, .odm, .odg, .otg, .odp, .otp, .ods, .ots, .odc, .odf, .odb, .odi, .oxt
|
||||
class OpenDocument extends Office {
|
||||
|
@ -113,7 +113,7 @@ class OpenDocument extends Office {
|
|||
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\OpenDocument');
|
||||
\OC\Preview::registerProvider('OC\Preview\OpenDocument');
|
||||
|
||||
//.sxw, .stw, .sxc, .stc, .sxd, .std, .sxi, .sti, .sxg, .sxm
|
||||
class StarOffice extends Office {
|
||||
|
@ -124,4 +124,4 @@ class StarOffice extends Office {
|
|||
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\StarOffice');
|
||||
\OC\Preview::registerProvider('OC\Preview\StarOffice');
|
|
@ -39,5 +39,5 @@ if(!is_null(shell_exec('ffmpeg -version'))) {
|
|||
}
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\Movie');
|
||||
\OC\Preview::registerProvider('OC\Preview\Movie');
|
||||
}
|
|
@ -43,4 +43,4 @@ class MP3 extends Provider {
|
|||
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\MP3');
|
||||
\OC\Preview::registerProvider('OC\Preview\MP3');
|
|
@ -20,7 +20,7 @@ class DOC extends Provider {
|
|||
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\DOC');
|
||||
\OC\Preview::registerProvider('OC\Preview\DOC');
|
||||
*/
|
||||
|
||||
class DOCX extends Provider {
|
||||
|
@ -50,7 +50,7 @@ class DOCX extends Provider {
|
|||
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\DOCX');
|
||||
\OC\Preview::registerProvider('OC\Preview\DOCX');
|
||||
|
||||
class MSOfficeExcel extends Provider {
|
||||
|
||||
|
@ -95,7 +95,7 @@ class XLS extends MSOfficeExcel {
|
|||
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\XLS');
|
||||
\OC\Preview::registerProvider('OC\Preview\XLS');
|
||||
|
||||
class XLSX extends MSOfficeExcel {
|
||||
|
||||
|
@ -105,7 +105,7 @@ class XLSX extends MSOfficeExcel {
|
|||
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\XLSX');
|
||||
\OC\Preview::registerProvider('OC\Preview\XLSX');
|
||||
|
||||
/* //There is no (good) php-only solution for converting powerpoint documents to pdfs / pngs ...
|
||||
class MSOfficePowerPoint extends Provider {
|
||||
|
@ -128,7 +128,7 @@ class PPT extends MSOfficePowerPoint {
|
|||
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\PPT');
|
||||
\OC\Preview::registerProvider('OC\Preview\PPT');
|
||||
|
||||
class PPTX extends MSOfficePowerPoint {
|
||||
|
||||
|
@ -138,5 +138,5 @@ class PPTX extends MSOfficePowerPoint {
|
|||
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\PPTX');
|
||||
\OC\Preview::registerProvider('OC\Preview\PPTX');
|
||||
*/
|
|
@ -36,5 +36,5 @@ if (extension_loaded('imagick')) {
|
|||
}
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\PDF');
|
||||
\OC\Preview::registerProvider('OC\Preview\PDF');
|
||||
}
|
||||
|
|
|
@ -39,6 +39,6 @@ if (extension_loaded('imagick')) {
|
|||
}
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\SVG');
|
||||
\OC\Preview::registerProvider('OC\Preview\SVG');
|
||||
|
||||
}
|
|
@ -46,7 +46,7 @@ class TXT extends Provider {
|
|||
}
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\TXT');
|
||||
\OC\Preview::registerProvider('OC\Preview\TXT');
|
||||
|
||||
class PHP extends TXT {
|
||||
|
||||
|
@ -56,7 +56,7 @@ class PHP extends TXT {
|
|||
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\PHP');
|
||||
\OC\Preview::registerProvider('OC\Preview\PHP');
|
||||
|
||||
class JavaScript extends TXT {
|
||||
|
||||
|
@ -66,4 +66,4 @@ class JavaScript extends TXT {
|
|||
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\JavaScript');
|
||||
\OC\Preview::registerProvider('OC\Preview\JavaScript');
|
|
@ -40,4 +40,4 @@ class Unknown extends Provider {
|
|||
}
|
||||
}
|
||||
|
||||
\OC\PreviewManager::registerProvider('OC\Preview\Unknown');
|
||||
\OC\Preview::registerProvider('OC\Preview\Unknown');
|
Loading…
Reference in New Issue