Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 57a9871

Browse files
author
Charles Marion
committed
ENH : removed image magick from core
1 parent eb9861b commit 57a9871

28 files changed

+1141
-120
lines changed

core/controllers/InstallController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ function indexAction()
4646
"simplexml" => array(false, ""),
4747
);
4848
$this->view->phpextension_missing = $this->Component->Utility->checkPhpExtensions($phpextensions);
49-
$this->view->writable = is_writable(BASE_PATH.'/core/configs');
50-
$this->view->convertfound = $this->Component->Utility->isImageMagickWorking();
49+
$this->view->writable = is_writable(BASE_PATH.'/core/configs');
5150
$this->view->basePath = BASE_PATH;
5251
if(!empty($_POST) && $this->view->writable)
5352
{

core/controllers/ItemController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function viewAction()
130130
}
131131

132132
$items = array();
133-
if(in_array($itemDao->getKey(), $this->userSession->uploaded))
133+
if(isset($this->userSession->uploaded) && in_array($itemDao->getKey(), $this->userSession->uploaded))
134134
{
135135
$items = $this->Item->load($this->userSession->uploaded);
136136
}
@@ -147,8 +147,12 @@ function viewAction()
147147
break;
148148
}
149149
}
150+
if(isset($currentFolder))
151+
{
152+
$items = $this->Folder->getItemsFiltered($currentFolder, $this->userSession->Dao, MIDAS_POLICY_READ);
153+
}
150154
}
151-
$items = $this->Folder->getItemsFiltered($currentFolder, $this->userSession->Dao, MIDAS_POLICY_READ);
155+
152156
}
153157

154158
foreach($items as $key => $item)

core/controllers/UserController.php

Lines changed: 109 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -429,67 +429,146 @@ public function settingsAction()
429429
//simulate file upload
430430
$path = BASE_PATH.'/tests/testfiles/search.png';
431431
$size = filesize($path);
432+
$mime = 'image/png';
432433
}
433434
else
434435
{
436+
$mime = $_FILES['file']['type'];
435437
$upload = new Zend_File_Transfer();
436438
$upload->receive();
437439
$path = $upload->getFileName();
438-
$size = $upload->getFileSize();
440+
$size = $upload->getFileSize();
439441
}
440442

443+
441444
if(!empty($path) && file_exists($path) && $size > 0)
442445
{
443-
//create thumbnail
444-
$thumbnailCreator = $this->Component->Filter->getFilter('ThumbnailCreator');
445-
$thumbnailCreator->inputFile = $path;
446-
$thumbnailCreator->inputName = basename($path);
447-
$hasThumbnail = $thumbnailCreator->process();
448-
$thumbnail_output_file = $thumbnailCreator->outputFile;
449-
if($hasThumbnail && file_exists($thumbnail_output_file))
446+
if(file_exists($path) && $mime == 'image/jpeg')
447+
{
448+
try
449+
{
450+
$src = imagecreatefromjpeg($path);
451+
}
452+
catch(Exception $exc)
453+
{
454+
echo JsonComponent::encode(array(false, 'Error, Unable to read jpg file'));
455+
return;
456+
}
457+
}
458+
else if(file_exists($path) && $mime == 'image/png')
459+
{
460+
try
461+
{
462+
$src = imagecreatefrompng($path);
463+
}
464+
catch(Exception $exc)
465+
{
466+
echo JsonComponent::encode(array(false, 'Error, Unable to read png file'));
467+
return;
468+
}
469+
}
470+
else if(file_exists($path) && $mime == 'image/gif')
471+
{
472+
try
473+
{
474+
$src = imagecreatefromgif($path);
475+
}
476+
catch(Exception $exc)
477+
{
478+
echo JsonComponent::encode(array(false, 'Error, Unable to read gif file'));
479+
return;
480+
}
481+
}
482+
else
483+
{
484+
echo JsonComponent::encode(array(false, 'Error, wrong format'));
485+
return;
486+
}
487+
488+
$tmpPath = BASE_PATH.'/data/thumbnail/'.rand(1, 1000);
489+
if(!file_exists(BASE_PATH.'/data/thumbnail/'))
490+
{
491+
throw new Zend_Exception("Problem thumbnail path: ".BASE_PATH.'/data/thumbnail/');
492+
}
493+
if(!file_exists($tmpPath))
494+
{
495+
mkdir($tmpPath);
496+
}
497+
$tmpPath .= '/'.rand(1, 1000);
498+
if(!file_exists($tmpPath))
499+
{
500+
mkdir($tmpPath);
501+
}
502+
$destionation = $tmpPath."/".rand(1, 1000).'.jpeg';
503+
while(file_exists($destionation))
504+
{
505+
$destionation = $tmpPath."/".rand(1, 1000).'.jpeg';
506+
}
507+
$pathThumbnail = $destionation;
508+
509+
list ($x, $y) = getimagesize($path); //--- get size of img ---
510+
$thumb = 32; //--- max. size of thumb ---
511+
if($x > $y)
512+
{
513+
$tx = $thumb; //--- landscape ---
514+
$ty = round($thumb / $x * $y);
515+
}
516+
else
517+
{
518+
$tx = round($thumb / $y * $x); //--- portrait ---
519+
$ty = $thumb;
520+
}
521+
522+
$thb = imagecreatetruecolor($tx, $ty); //--- create thumbnail ---
523+
imagecopyresampled($thb, $src, 0, 0, 0, 0, $tx, $ty, $x, $y);
524+
imagejpeg($thb, $pathThumbnail, 80);
525+
imagedestroy($thb);
526+
imagedestroy($src);
527+
if(file_exists($pathThumbnail))
450528
{
451529
$userDao = $this->User->load($userDao->getKey());
452530
$oldThumbnail = $userDao->getThumbnail();
453531
if(!empty($oldThumbnail) && file_exists(BASE_PATH.'/'.$oldThumbnail))
454532
{
455533
unlink(BASE_PATH.'/'.$oldThumbnail);
456534
}
457-
$userDao->setThumbnail(substr($thumbnail_output_file, strlen(BASE_PATH) + 1));
535+
$userDao->setThumbnail(substr($pathThumbnail, strlen(BASE_PATH) + 1));
458536
$this->User->save($userDao);
459537
if(!isset($userId))
460538
{
461539
$this->userSession->Dao = $userDao;
462540
}
463541
echo JsonComponent::encode(array(true, $this->t('Changes saved'), $this->view->webroot.'/'.$userDao->getThumbnail()));
464-
}
542+
}
465543
else
466544
{
467545
echo JsonComponent::encode(array(false, 'Error'));
546+
return;
468547
}
469548
}
470-
}
471-
if(isset($modifyPictureGravatar) && $this->logged)
472-
{
473-
$gravatarUrl = $this->User->getGravatarUrl($userDao->getEmail());
474-
if($gravatarUrl != false)
549+
if(isset($modifyPictureGravatar) && $this->logged)
475550
{
476-
$userDao = $this->User->load($userDao->getKey());
477-
$oldThumbnail = $userDao->getThumbnail();
478-
if(!empty($oldThumbnail) && file_exists(BASE_PATH.'/'.$oldThumbnail))
479-
{
480-
unlink(BASE_PATH.'/'.$oldThumbnail);
481-
}
482-
$userDao->setThumbnail($gravatarUrl);
483-
$this->User->save($userDao);
484-
if(!isset($userId))
551+
$gravatarUrl = $this->User->getGravatarUrl($userDao->getEmail());
552+
if($gravatarUrl != false)
485553
{
486-
$this->userSession->Dao = $userDao;
554+
$userDao = $this->User->load($userDao->getKey());
555+
$oldThumbnail = $userDao->getThumbnail();
556+
if(!empty($oldThumbnail) && file_exists(BASE_PATH.'/'.$oldThumbnail))
557+
{
558+
unlink(BASE_PATH.'/'.$oldThumbnail);
559+
}
560+
$userDao->setThumbnail($gravatarUrl);
561+
$this->User->save($userDao);
562+
if(!isset($userId))
563+
{
564+
$this->userSession->Dao = $userDao;
565+
}
566+
echo JsonComponent::encode(array(true, $this->t('Changes saved'), $userDao->getThumbnail()));
487567
}
488-
echo JsonComponent::encode(array(true, $this->t('Changes saved'), $userDao->getThumbnail()));
489-
}
490-
else
491-
{
492-
echo JsonComponent::encode(array(false, 'Error'));
568+
else
569+
{
570+
echo JsonComponent::encode(array(false, 'Error'));
571+
}
493572
}
494573
}
495574
}

core/public/js/browse/browse.index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
$("img.tableLoading").hide();
66
$("table#browseTable").show();
77

8-
$('div.feedThumbnail img').fadeTo("slow",0.2);
8+
$('div.feedThumbnail img').fadeTo("slow",0.4);
99
$('div.feedThumbnail img').mouseover(function(){
1010
$(this).fadeTo("fast",1);
1111
});
1212

1313
$('div.feedThumbnail img').mouseout(function(){
14-
$(this).fadeTo("fast",0.2);
14+
$(this).fadeTo("fast",0.4);
1515
});
1616

1717
$('a.createCommunity').click(function()

core/public/js/item/item.view.js

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -44,75 +44,6 @@
4444
showDialog(json.browse.edit,false);
4545
});
4646

47-
var currentElement = json.item.item_id;
48-
49-
function highlightCurrentPreview()
50-
{
51-
$('#fullscreenVisualize a.linkedcontentLink').css('font-weight','normal');
52-
$('#fullscreenVisualize a.linkedcontentLink[element='+currentElement+']').css('font-weight','bold');
53-
}
54-
/** preview */
55-
$('a#itemPreviewLink').click(function(){
56-
57-
var height = $(window).height()-100;
58-
var width = 900;
59-
var url = json.global.webroot+"/visualize/?itemId="+json.item.item_id+'&height='+height+'&width='+width;
60-
var html = '<div id="fullscreenVisualize" >';
61-
html += '<div id="fullscreenPanel">';
62-
html += '<a class="closeVisuButton" ><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/close.png"/> </a>';
63-
html += '<br/>';
64-
html += '<a class="previousVisu">Prev</a> - <a class="nextVisu">Nxt</a>';
65-
html += '<br/>';
66-
html += $('div.viewSameLocation').html();
67-
html += '</div>';
68-
html += '<iframe name="fullscreenVisualizeIframe" height="'+height+'" width="'+width+'" id="fullscreenVisualizeIframe" src="'+url+'"></iframe>';
69-
html += '</div>';
70-
71-
$('.Wrapper').append(html);
72-
73-
$('#fullscreenVisualize a.linkedcontentLink[preview=false]').remove();
74-
$('#fullscreenVisualize a.linkedcontentLink[preview=true]').removeAttr('href');
75-
76-
highlightCurrentPreview();
77-
78-
$('#fullscreenVisualize a.linkedcontentLink').click(function(){
79-
var height = $(window).height()-100;
80-
var width = 900;
81-
var url = json.global.webroot+"/visualize/?height="+height+'&width='+width+'&itemId='+$(this).attr('element');
82-
$('iframe#fullscreenVisualizeIframe').attr('src', url);
83-
currentElement = $(this).attr('element');
84-
highlightCurrentPreview();
85-
});
86-
87-
$('a.previousVisu').click(function(){
88-
var obj = $('#fullscreenVisualize a.linkedcontentLink[element='+currentElement+']').parents('li').prev().find('a');
89-
var height = $(window).height()-100;
90-
var width = 900;
91-
var url = json.global.webroot+"/visualize/?height="+height+'&width='+width+'&itemId='+obj.attr('element');
92-
$('iframe#fullscreenVisualizeIframe').attr('src', url);
93-
currentElement = obj.attr('element');
94-
highlightCurrentPreview();
95-
});
96-
$('a.nextVisu').click(function(){
97-
var obj = $('#fullscreenVisualize a.linkedcontentLink[element='+currentElement+']').parents('li').next().find('a');
98-
var height = $(window).height()-100;
99-
var width = 900;
100-
var url = json.global.webroot+"/visualize/?height="+height+'&width='+width+'&itemId='+obj.attr('element');
101-
$('iframe#fullscreenVisualizeIframe').attr('src', url);
102-
currentElement = obj.attr('element');
103-
highlightCurrentPreview();
104-
});
105-
106-
$('.MainDialog').hide();
107-
$('.TopDynamicBar').hide();
108-
$('.Topbar').show();
109-
$('.Header').hide();
110-
$('.SubWrapper').hide();
111-
$('#fullscreenVisualize a.closeVisuButton').click(function(){
112-
$('#fullscreenVisualize').remove();
113-
$('.Header').show();
114-
$('.SubWrapper').show();
115-
});
116-
});
47+
11748
});
11849

core/views/install/index.phtml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ PURPOSE. See the above copyright notices for more information.
2828
This script will guide you during the installation of MIDAS.
2929
MIDAS will store the datasets and related information in these directories.
3030
Make sure they are fitting your installation or modify your config.php file.
31-
<br/><br/>For more information go to: <a href="http://www.kitware.com/midaswiki/index.php/Installation">http://www.kitware.com/midaswiki/index.php/Installation</a>
31+
<br/><br/>For more information go to: <a href="http://www.kitware.com/midaswiki/index.php/MIDAS3-Installation">http://www.kitware.com/midaswiki/index.php/MIDAS3-Installation</a>
3232

3333
<h3>System check</h3>
3434
<?php
@@ -40,23 +40,13 @@ PURPOSE. See the above copyright notices for more information.
4040
echo "<li><span style=\"color:#d48304\"> $missing </span> </li>";
4141
}
4242
}
43-
44-
if($this->convertfound[0]==false)
45-
{
46-
echo "<li><span style=\"color:#d48304\"> {$this->convertfound[1]}</span>";
47-
if(strstr(PHP_OS,"WIN"))
48-
{
49-
echo " <br/>If you have installed Image Magick and it still doesn't work. Copy the convert.exe file to im-convert.exe in the Image Magick Folder. There may be a conflict with the windows convert application.";
50-
}
51-
echo "</li>";
52-
}
5343

5444
if($this->writable==false)
5545
{
5646
echo "<li><span style=\"color:red\"> Unable to right in the application folder: {$this->basePath}. Please check you apache server permissions</span> </li>";
5747
}
5848

59-
if($this->writable&&$this->convertfound[0]&&empty($this->phpextension_missing))
49+
if($this->writable&&empty($this->phpextension_missing))
6050
{
6151
echo "<li><span style=\"color:green\"> Your system is OK</span> </li>";
6252
}

core/views/item/view.phtml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ PURPOSE. See the above copyright notices for more information.
1616

1717
<?php
1818
$this->headScript()->appendFile($this->coreWebroot . '/public/js/item/item.view.js');
19+
if($this->preview) // module visualize
20+
{
21+
$this->headScript()->appendFile($this->webroot . '/modules/visualize/public/js/main.js');
22+
}
1923
?>
2024
<div class="viewMain">
2125
<div class="genericThumbnail">
@@ -177,7 +181,7 @@ $this->headScript()->appendFile($this->coreWebroot . '/public/js/item/item.view.
177181
?>
178182
</ul>
179183
</div>
180-
<div class="sideElement<?php if(count($this->sameLocation) == 1) echo "Last"?> viewInfo">
184+
<div class="sideElement<?php if(count($this->sameLocation) > 1) echo "Last"?> viewInfo">
181185
<h1>Info</h1>
182186
<table>
183187
<tbody>
@@ -211,7 +215,7 @@ $this->headScript()->appendFile($this->coreWebroot . '/public/js/item/item.view.
211215
?>
212216
</div>
213217
<?php
214-
if(count($this->sameLocation) != 1)
218+
if(count($this->sameLocation) > 1)
215219
{?>
216220
<div class='sideElementLast viewSameLocation'>
217221
<h1><?php echo $this->t('In the same location')?></h1>

0 commit comments

Comments
 (0)