Skip to content

Commit fa08950

Browse files
committed
make it work with 5.7
1 parent ed0be07 commit fa08950

File tree

5 files changed

+35
-53
lines changed

5 files changed

+35
-53
lines changed

blocks/zoom_image/controller.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
<?php
22

3-
Loader::block('library_file');
3+
namespace Concrete\Package\ZoomImage\Block\ZoomImage;
4+
5+
use \Concrete\Core\Block\BlockType\BlockType,
6+
\Concrete\Core\Block\BlockController,
7+
\Concrete\Core\File\File,
8+
\Concrete\Core\View\View,
9+
Loader;
410

511
defined('C5_EXECUTE') or die(_("Access Denied."));
612

7-
class ZoomImageBlockController extends BlockController {
13+
class Controller extends BlockController {
814

915
protected $btInterfaceWidth = 450;
1016
protected $btInterfaceHeight = 500;
@@ -38,8 +44,8 @@ public function on_page_view() {
3844

3945
$uh = Loader::helper('concrete/urls');
4046

41-
$v->addHeaderItem('<script type="text/javascript" src="' . $uh->getBlockTypeAssetsURL($bt) . '/fancyzoom.min.js"></script>', 'CONTROLLER');
42-
$v->addHeaderItem('<script type="text/javascript">$(document).ready(function() { $("a.zoomImage").fancyZoom({scaleImg: true, closeOnClick: true, directory:"' . $uh->getBlockTypeAssetsURL($bt) . '/images"}); });</script>', 'CONTROLLER');
47+
$v->addFooterItem('<script type="text/javascript" src="' . $uh->getBlockTypeAssetsURL($bt) . '/fancyzoom.min.js"></script>');
48+
$v->addFooterItem('<script type="text/javascript">$(document).ready(function() { $("a.zoomImage").fancyZoom({scaleImg: true, closeOnClick: true, directory:"' . $uh->getBlockTypeAssetsURL($bt) . '/images"}); });</script>');
4349
}
4450

4551
function getFileID() {
@@ -65,6 +71,18 @@ public function save($args) {
6571
$args['limitMaxZoom'] = empty($args['limitMaxZoom']) ? 0 : 1;
6672
parent::save($args);
6773
}
74+
75+
public function view() {
76+
$ih = Loader::helper('image');
77+
78+
$fileObject = $this->getFileObject();
79+
80+
$fileName = $fileObject->getRelativePath();
81+
$thumbnail = $ih->getThumbnail($fileObject, intval($this->thumbnailWidth), intval($this->thumbnailHeight));
82+
83+
$this->set('fileName', $fileName);
84+
$this->set('thumbnail', $thumbnail);
85+
}
6886

6987
}
7088

blocks/zoom_image/fancyzoom.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ function show(e) {
102102
height: '1px'
103103
});
104104

105-
fixBackgroundsForIE();
106105
zoom_close.hide();
107106

108107
if (options.closeOnClick) {
@@ -131,7 +130,6 @@ function show(e) {
131130
if (options.scaleImg != true) {
132131
zoom_content.html(content_div.html());
133132
}
134-
unfixBackgroundsForIE();
135133
zoom_close.show();
136134
zooming = false;
137135
}
@@ -149,7 +147,6 @@ function hide() {
149147
}
150148
zooming = true;
151149
$('#zoom').unbind('click');
152-
fixBackgroundsForIE();
153150
if (zoom_close.attr('scaleImg') != 'true') {
154151
zoom_content.html('');
155152
}
@@ -168,7 +165,6 @@ function hide() {
168165
if (zoom_close.attr('scaleImg') == 'true') {
169166
zoom_content.html('');
170167
}
171-
unfixBackgroundsForIE();
172168
zooming = false;
173169
if(current_zoom.data('hide-original-on-zoom') === 'yes') {
174170
current_zoom.css('visibility', current_zoom.data('fancyzoom.initial-visibility'));
@@ -189,16 +185,4 @@ function switchBackgroundImagesTo(to) {
189185
close_img.attr('src', new_img);
190186
}
191187

192-
function fixBackgroundsForIE() {
193-
if ($.browser.msie && parseFloat($.browser.version) >= 7) {
194-
switchBackgroundImagesTo('gif');
195-
}
196-
}
197-
198-
function unfixBackgroundsForIE() {
199-
if ($.browser.msie && $.browser.version >= 7) {
200-
switchBackgroundImagesTo('png');
201-
}
202-
}
203-
204188
};

blocks/zoom_image/fancyzoom.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

blocks/zoom_image/view.php

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,17 @@
11
<?php
22
defined('C5_EXECUTE') or die('Access Denied.');
3-
4-
$version_arr = explode('.', APP_VERSION);
5-
6-
if ($version_arr[1] < 2)
7-
die("This block doesn't support concrete" . APP_VERSION);
8-
if ($version_arr[1] == 2) {
9-
$fo = $controller->getAssetFileObject();
10-
11-
$fileName = $fo->getFileRelativePath();
12-
$thumbnail = $fo->getThumbnail(intval($controller->thumbnailWidth), intval($controller->thumbnailHeight));
13-
} else {
14-
$ih = Loader::helper('image');
15-
$fo = $controller->getFileObject();
16-
17-
$fileName = $fo->getRelativePath();
18-
$thumbnail = $ih->getThumbnail($fo, intval($controller->thumbnailWidth), intval($controller->thumbnailHeight));
19-
}
203
?>
214

225
<a class="zoomImage" href="#zoomImage<?php echo $bID;?>"<?php echo empty($hideOriginalOnZoom) ? '' : ' data-hide-original-on-zoom="yes"'; ?><?php echo empty($limitMaxZoom) ? '' : ' data-limit-max-zoom="yes"'; ?>>
236
<img src="<?php echo $thumbnail->src;?>"
24-
alt="<?php echo $controller->altText;?>"
7+
alt="<?php echo $altText;?>"
258
width="<?php echo $thumbnail->width;?>"
26-
height="<?php echo $thumbnail->height;?>"/>
9+
height="<?php echo $thumbnail->height;?>"/>
2710
</a>
2811

2912
<div id="zoomImage<?php echo $bID;?>" style="display:none;">
30-
<img src="<?php echo $fileName;?>" alt="<?php echo $controller->altText;?>"/>
31-
<?php if ($controller->displayCaption):?>
32-
<p id="zoomImage<?php echo $bID;?>_caption"><?php echo $controller->altText;?></p>
13+
<img src="<?php echo $fileName;?>" alt="<?php echo $altText;?>"/>
14+
<?php if ($displayCaption):?>
15+
<p id="zoomImage<?php echo $bID;?>_caption"><?php echo $altText;?></p>
3316
<?php endif;?>
3417
</div>

controller.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<?php
22

3-
defined('C5_EXECUTE') or die(_("Access Denied."));
3+
namespace Concrete\Package\ZoomImage;
44

5-
class ZoomImagePackage extends Package {
5+
use Concrete\Core\Block\BlockType\BlockType;
6+
7+
defined('C5_EXECUTE') or die('Access Denied.');
8+
9+
class Controller extends \Concrete\Core\Package\Package {
610

711
protected $pkgHandle = 'zoom_image';
812
protected $appVersionRequired = '5.2.0';
9-
protected $pkgVersion = '1.0.7';
13+
protected $pkgVersion = '2.0.0';
1014

1115
public function getPackageDescription() {
1216
return t("Adds images and onstates from the library to pages.");
@@ -23,12 +27,5 @@ public function install() {
2327
BlockType::installBlockTypeFromPackage('zoom_image', $pkg);
2428
}
2529

26-
public function upgrade() {
27-
parent::upgrade();
28-
$bt = BlockType::getByHandle('zoom_image');
29-
if(is_object($bt)) {
30-
$bt->refresh();
31-
}
32-
}
3330

3431
}

0 commit comments

Comments
 (0)