Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
21bc8e0c
Commit
21bc8e0c
authored
Mar 22, 2015
by
Morris Jobke
Browse files
Merge pull request #15088 from oparoz/3d-support
Introducing 3D images support (media type)
parents
a79d9730
f3fe4668
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
lib/private/mimetypes.list.php
View file @
21bc8e0c
...
...
@@ -81,6 +81,7 @@ return array(
'impress'
=>
array
(
'text/impress'
,
null
),
'jpeg'
=>
array
(
'image/jpeg'
,
null
),
'jpg'
=>
array
(
'image/jpeg'
,
null
),
'jps'
=>
array
(
'image/jpeg'
,
null
),
'js'
=>
array
(
'application/javascript'
,
'text/plain'
),
'json'
=>
array
(
'application/json'
,
'text/plain'
),
'k25'
=>
array
(
'image/x-dcraw'
,
null
),
...
...
@@ -103,6 +104,7 @@ return array(
'mp4'
=>
array
(
'video/mp4'
,
null
),
'mpeg'
=>
array
(
'video/mpeg'
,
null
),
'mpg'
=>
array
(
'video/mpeg'
,
null
),
'mpo'
=>
array
(
'image/jpeg'
,
null
),
'msi'
=>
array
(
'application/x-msi'
,
null
),
'nef'
=>
array
(
'image/x-dcraw'
,
null
),
'numbers'
=>
array
(
'application/x-iwork-numbers-sffnumbers'
,
null
),
...
...
lib/repair/repairmimetypes.php
View file @
21bc8e0c
...
...
@@ -17,7 +17,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
public
function
getName
()
{
return
'Repair mime types'
;
}
private
static
function
existsStmt
()
{
return
\
OC_DB
::
prepare
(
'
SELECT count(`mimetype`)
...
...
@@ -51,14 +51,14 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
) WHERE `mimetype` = ?
'
);
}
private
static
function
deleteStmt
()
{
return
\
OC_DB
::
prepare
(
'
DELETE FROM `*PREFIX*mimetypes`
WHERE `id` = ?
'
);
}
}
private
static
function
updateByNameStmt
()
{
return
\
OC_DB
::
prepare
(
'
UPDATE `*PREFIX*filecache`
...
...
@@ -69,7 +69,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
) WHERE `name` ILIKE ?
'
);
}
private
function
repairMimetypes
(
$wrongMimetypes
)
{
foreach
(
$wrongMimetypes
as
$wrong
=>
$correct
)
{
// do we need to remove a wrong mimetype?
...
...
@@ -81,8 +81,8 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
$result
=
\
OC_DB
::
executeAudited
(
self
::
existsStmt
(),
array
(
$correct
));
$exists
=
$result
->
fetchOne
();
if
(
!
is_null
(
$correct
)
)
{
if
(
!
$exists
)
{
if
(
!
is_null
(
$correct
))
{
if
(
!
$exists
)
{
// insert mimetype
\
OC_DB
::
executeAudited
(
self
::
insertStmt
(),
array
(
$correct
));
}
...
...
@@ -90,27 +90,27 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
// change wrong mimetype to correct mimetype in filecache
\
OC_DB
::
executeAudited
(
self
::
updateWrongStmt
(),
array
(
$correct
,
$wrongId
));
}
// delete wrong mimetype
\
OC_DB
::
executeAudited
(
self
::
deleteStmt
(),
array
(
$wrongId
));
}
}
}
private
function
updateMimetypes
(
$updatedMimetypes
)
{
foreach
(
$updatedMimetypes
as
$extension
=>
$mimetype
)
{
foreach
(
$updatedMimetypes
as
$extension
=>
$mimetype
)
{
$result
=
\
OC_DB
::
executeAudited
(
self
::
existsStmt
(),
array
(
$mimetype
));
$exists
=
$result
->
fetchOne
();
if
(
!
$exists
)
{
if
(
!
$exists
)
{
// insert mimetype
\
OC_DB
::
executeAudited
(
self
::
insertStmt
(),
array
(
$mimetype
));
}
// change mimetype for files with x extension
\
OC_DB
::
executeAudited
(
self
::
updateByNameStmt
(),
array
(
$mimetype
,
'%.'
.
$extension
));
\
OC_DB
::
executeAudited
(
self
::
updateByNameStmt
(),
array
(
$mimetype
,
'%.'
.
$extension
));
}
}
...
...
@@ -132,9 +132,9 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
// separate doc from docx etc
self
::
updateMimetypes
(
$updatedMimetypes
);
}
private
function
fixApkMimeType
()
{
$updatedMimetypes
=
array
(
'apk'
=>
'application/vnd.android.package-archive'
,
...
...
@@ -142,7 +142,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
self
::
updateMimetypes
(
$updatedMimetypes
);
}
private
function
fixFontsMimeTypes
()
{
// update wrong mimetypes
$wrongMimetypes
=
array
(
...
...
@@ -152,7 +152,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
);
self
::
repairMimetypes
(
$wrongMimetypes
);
$updatedMimetypes
=
array
(
'ttf'
=>
'application/font-sfnt'
,
'otf'
=>
'application/font-sfnt'
,
...
...
@@ -161,7 +161,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
self
::
updateMimetypes
(
$updatedMimetypes
);
}
private
function
fixPostscriptMimeType
()
{
$updatedMimetypes
=
array
(
'eps'
=>
'application/postscript'
,
...
...
@@ -195,6 +195,15 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
self
::
updateMimetypes
(
$updatedMimetypes
);
}
private
function
introduce3dImagesMimeType
()
{
$updatedMimetypes
=
array
(
'jps'
=>
'image/jpeg'
,
'mpo'
=>
'image/jpeg'
,
);
self
::
updateMimetypes
(
$updatedMimetypes
);
}
/**
* Fix mime types
*/
...
...
@@ -202,15 +211,15 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
if
(
$this
->
fixOfficeMimeTypes
())
{
$this
->
emit
(
'\OC\Repair'
,
'info'
,
array
(
'Fixed office mime types'
));
}
if
(
$this
->
fixApkMimeType
())
{
$this
->
emit
(
'\OC\Repair'
,
'info'
,
array
(
'Fixed APK mime type'
));
}
if
(
$this
->
fixFontsMimeTypes
())
{
$this
->
emit
(
'\OC\Repair'
,
'info'
,
array
(
'Fixed fonts mime types'
));
}
if
(
$this
->
fixPostscriptMimeType
())
{
$this
->
emit
(
'\OC\Repair'
,
'info'
,
array
(
'Fixed Postscript mime types'
));
}
...
...
@@ -218,5 +227,9 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
if
(
$this
->
introduceRawMimeType
())
{
$this
->
emit
(
'\OC\Repair'
,
'info'
,
array
(
'Fixed Raw mime types'
));
}
if
(
$this
->
introduce3dImagesMimeType
())
{
$this
->
emit
(
'\OC\Repair'
,
'info'
,
array
(
'Fixed 3D images mime types'
));
}
}
}
tests/lib/repair/repairmimetypes.php
View file @
21bc8e0c
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment