Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hy3n4 committed Nov 8, 2017
0 parents commit c2258b7
Show file tree
Hide file tree
Showing 6 changed files with 2,073 additions and 0 deletions.
37 changes: 37 additions & 0 deletions install.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Elevate Zoom Plugin</name>
<code>elevate-zoom-plugin</code>
<version>3.0.0</version>
<author>Hy3n4 ([email protected])</author>
<link>http://www.hwdesign.cz/</link>
<file path="catalog/view/theme/*/template/product/product.twig">
<operation>
<search>
<![CDATA[{{ footer }}]]>
</search>
<add position="before">
<![CDATA[
<script src='catalog/view/javascript/jquery.elevatezoom.js'></script>
<script type="text/javascript" src="{{ module_elevate_zoom }}"></script>
<script>$('#{{ model }}').elevateZoom({
zoomType: "inner",
cursor: "crosshair",
zoomWindowFadeIn: 500,
zoomWindowFadeOut: 750
});</script>
]]>
</add>
</operation>
<operation>
<search>
<![CDATA[<img src="{{ thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" />]]>
</search>
<add position="replace">
<![CDATA[
<img id="{{ model }}" src="{{ thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" data-zoom-image="{{ popup }}" />
]]>
</add>
</operation>
</file>
</modification>
103 changes: 103 additions & 0 deletions upload/admin/controller/extension/module/elevate_zoom.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php
/**
* Created by PhpStorm.
* User: patrikchadima
* Date: 07/11/2017
* Time: 14:19
*/
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
class ControllerExtensionModuleElevateZoom extends Controller
{
public $option_fadein_value = '500';
public $option_fadeout_value = '750';

private $error = array(); // This is used to set the errors, if any.

public function index() { // Default function

$this->load->language('extension/module/elevate_zoom');
$this->document->setTitle($this->language->get('heading_title'));

$this->load->model('setting/setting');

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_setting_setting->editSetting('module_elevate_zoom', $this->request->post);

$this->session->data['success'] = $this->language->get('text_success');

$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true));
}

if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}

if (isset($this->session->data['success'])) {
$data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$data['success'] = '';
}

$data['breadcrumbs'] = array();

$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
);

$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_extension'),
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true)
);

$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('extension/module/elevate_zoom', 'user_token=' . $this->session->data['user_token'], true)
);

$data['action'] = $this->url->link('extension/module/elevate_zoom', 'user_token=' . $this->session->data['user_token'], true);

$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true);

if (isset($this->request->post['module_elevate_zoom_fadein'])) {
$data['module_elevate_zoom_fadein'] = $this->request->post['module_elevate_zoom_fadein'];
} elseif ( null !== $this->config->get('module_elevate_zoom_fadein')) {
$data['module_elevate_zoom_fadein'] = $this->config->get('module_elevate_zoom_fadein');
} else {
$data['module_elevate_zoom_fadein'] = $this->option_fadein_value;
}

if (isset($this->request->post['module_elevate_zoom_fadeout'])) {
$data['module_elevate_zoom_fadeout'] = $this->request->post['module_elevate_zoom_fadeout'];
} elseif ( null !== $this->config->get('module_elevate_zoom_fadeout')) {
$data['module_elevate_zoom_fadeout'] = $this->config->get('module_elevate_zoom_fadeout');
} else {
$data['module_elevate_zoom_fadeout'] = $this->option_fadeout_value;
}

if (isset($this->request->post['module_elevate_zoom_status'])) {
$data['module_elevate_zoom_status'] = $this->request->post['module_elevate_zoom_status'];
} else {
$data['module_elevate_zoom_status'] = $this->config->get('module_elevate_zoom_status');
}

$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
$data['current_lang_id'] = $this->config->get('config_language_id');

$this->response->setOutput($this->load->view('extension/module/elevate_zoom', $data));
}
protected function validate() {
if (!$this->user->hasPermission('modify', 'extension/module/elevate_zoom')) {
$this->error['warning'] = $this->language->get('error_permission');
}

return !$this->error;
}
}
31 changes: 31 additions & 0 deletions upload/admin/language/en-gb/extension/module/elevate_zoom.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Created by PhpStorm.
* User: patrikchadima
* Date: 07/11/2017
* Time: 14:40
*/
// Heading
$_['heading_title'] = 'Elevate Zoom';

// Text
$_['text_extension'] = 'Extensions';
$_['text_module'] = 'Modules';
$_['text_success'] = 'Success: You have modified module Elevate Zoom!';
$_['text_fadein'] = 'Fade in';
$_['text_fadeout'] = 'Fade out';

// Entry
$_['entry_status'] = 'Status:';
$_['entry_fadein'] = 'Fade In:';
$_['entry_fadeout'] = 'Fade Out:';


// Help
$_['help_fadein'] = 'Fade in in ms';
$_['help_fadeout'] = 'Fade in in ms';

// Error
$_['error_permission'] = 'Warning: You do not have permission to modify module Hello World!';
$_['error_code'] = 'Code Required';
?>
75 changes: 75 additions & 0 deletions upload/admin/view/template/extension/module/elevate_zoom.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{{ header }}{{ column_left }}
<div id="content">
<div class="page-header">
<div class="container-fluid">
<div class="pull-right">
<button type="submit" form="form-module" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button>
<a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a>
</div>
<h1>{{ heading_title }}</h1>
<ul class="breadcrumb">
{% for breadcrumb in breadcrumbs %}
<li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
{% endfor %}
</ul>
</div>
</div>
<div class="container-fluid">
{% if error_warning %}
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}
<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
{% endif %}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-pencil"></i> {{ text_edit }} </h3>
</div>
<div class="panel-body">
<form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-module" class="form-horizontal">
<ul class="nav nav-tabs" id="tabs">
<li class="active"><a href="#tab-general" data-toggle="tab"><i class="fa fa-fw fa-wrench"></i> {{ tab_general }} </a></li>
<li><a href="#tab-css-style" data-toggle="tab"><i class="fa fa-fw fa-css3"></i> {{ tab_additional }} </a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab-general">
<div class="form-group">
<label class="col-sm-2 control-label" for="input-fadein"><span data-toggle="tooltip" title="{{ help_fadein }}">{{ entry_fadein }}</span></label>
<div class="col-sm-10">
<input type="text" name="module_elevate_zoom_fadein" value="{{ module_elevate_zoom_fadein }}" placeholder="{{ entry_fadein }}" id="input-fadein" class="form-control" />
{% if error_fadein %}
<div class="text-danger">{{ error_fadein }}</div>
{% endif %}
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="input-fadeout"><span data-toggle="tooltip" title="{{ help_fadeout }}">{{ entry_fadeout }}</span></label>
<div class="col-sm-10">
<input type="text" name="module_elevate_zoom_fadeout" value="{{ module_elevate_zoom_fadeout }}" placeholder="{{ entry_fadeout }}" id="input-fadeout" class="form-control" />
{% if error_fadeout %}
<div class="text-danger">{{ error_fadeout }}</div>
{% endif %}
</div>
</div>

<div class="form-group">
<label class="col-sm-2 control-label" for="input-status">{{ entry_status }}</label>
<div class="col-sm-10">
<select name="module_elevate_zoom_status" id="input-status" class="form-control">
{% if module_elevate_zoom_status %}
<option value="1" selected="selected">{{ text_enabled }}</option>
<option value="0">{{ text_disabled }}</option>
{% else %}
<option value="1">{{ text_enabled }}</option>
<option value="0" selected="selected">{{ text_disabled }}</option>
{% endif %}
</select>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{{ footer }}
37 changes: 37 additions & 0 deletions upload/catalog/controller/extension/module/elevate_zoom.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Created by PhpStorm.
* User: patrikchadima
* Date: 07/11/2017
* Time: 21:25
*/
class ControllerExtensionModuleElevateZoom extends Controller {
public function __construct($params) {
parent::__construct($params);

$this->options_fadein = $this->config->get('module_elevate_zoom_fadein');
$this->options_fadeout = $this->config->get('module_elevate_zoom_fadeout');
}

public function index() {
$this->load->model('catalog/product');
}
public function js() {
header('Content-Type: application/javascript');
/*$product_id = isset($this->request->get['product_id']) ? (int)$this->request->get['product_id'] : 0;
if ($product_id == 0 || !$this->status) {
exit;
}*/
$js = <<<HTML
$('#{{ model }}').elevateZoom({
zoomType: "inner",
cursor: "crosshair",
zoomWindowFadeIn: {{ module_elevate_zoom.module_elevate_zoom_fadein }},
zoomWindowFadeOut: {{ module_elevate_zoom.module_elevate_zoom_fadeout }}
HTML;

echo $js;
exit;
}
}
Loading

0 comments on commit c2258b7

Please sign in to comment.