Skip to content

Commit

Permalink
started adding my own version of vqmod.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkerr committed Feb 15, 2013
1 parent 748faf4 commit 7a64c34
Show file tree
Hide file tree
Showing 8 changed files with 284 additions and 53 deletions.
136 changes: 132 additions & 4 deletions upload/admin/controller/extension/modification.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,82 @@ public function index() {
);

$this->data['heading_title'] = $this->language->get('heading_title');

$this->data['text_no_results'] = $this->language->get('text_no_results');
$this->data['text_confirm'] = $this->language->get('text_confirm');

$this->data['column_name'] = $this->language->get('column_name');
$this->data['column_status'] = $this->language->get('column_status');
$this->data['column_sort_order'] = $this->language->get('column_sort_order');
$this->data['column_action'] = $this->language->get('column_action');

$this->data['button_upload'] = $this->language->get('button_upload');

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

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

if (isset($this->session->data['error'])) {
$this->data['error'] = $this->session->data['error'];

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

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

$extensions = $this->model_setting_extension->getInstalled('modification');

foreach ($extensions as $key => $value) {
if (!file_exists(DIR_APPLICATION . 'controller/modification/' . $value . '.php')) {
$this->model_setting_extension->uninstall('modification', $value);

unset($extensions[$key]);
}
}

$this->data['extensions'] = array();

$files = glob(DIR_APPLICATION . 'controller/modification/*.php');

if ($files) {
foreach ($files as $file) {
$extension = basename($file, '.php');

$this->language->load('modification/' . $extension);

$action = array();

if (!in_array($extension, $extensions)) {
$action[] = array(
'text' => $this->language->get('text_install'),
'href' => $this->url->link('extension/modification/install', 'token=' . $this->session->data['token'] . '&extension=' . $extension, 'SSL')
);
} else {
$action[] = array(
'text' => $this->language->get('text_edit'),
'href' => $this->url->link('modification/' . $extension . '', 'token=' . $this->session->data['token'], 'SSL')
);

$action[] = array(
'text' => $this->language->get('text_uninstall'),
'href' => $this->url->link('extension/modification/uninstall', 'token=' . $this->session->data['token'] . '&extension=' . $extension, 'SSL')
);
}

$this->data['extensions'][] = array(
'name' => $this->language->get('heading_title'),
'status' => $this->config->get($extension . '_status') ? $this->language->get('text_enabled') : $this->language->get('text_disabled'),
'sort_order' => $this->config->get($extension . '_sort_order'),
'action' => $action
);
}
}

$this->template = 'extension/modification.tpl';
$this->children = array(
Expand All @@ -34,8 +106,65 @@ public function index() {
$this->response->setOutput($this->render());
}

public function install() {
$this->language->load('extension/payment');

if (!$this->user->hasPermission('modify', 'extension/payment')) {
$this->session->data['error'] = $this->language->get('error_permission');

$this->redirect($this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'));
} else {
$this->load->model('setting/extension');

$this->model_setting_extension->install('payment', $this->request->get['extension']);

$this->load->model('user/user_group');

$this->model_user_user_group->addPermission($this->user->getId(), 'access', 'payment/' . $this->request->get['extension']);
$this->model_user_user_group->addPermission($this->user->getId(), 'modify', 'payment/' . $this->request->get['extension']);

require_once(DIR_APPLICATION . 'controller/payment/' . $this->request->get['extension'] . '.php');

$class = 'ControllerPayment' . str_replace('_', '', $this->request->get['extension']);
$class = new $class($this->registry);

if (method_exists($class, 'install')) {
$class->install();
}

$this->redirect($this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'));
}
}

public function uninstall() {
$this->language->load('extension/payment');

if (!$this->user->hasPermission('modify', 'extension/payment')) {
$this->session->data['error'] = $this->language->get('error_permission');

$this->redirect($this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'));
} else {
$this->load->model('setting/extension');
$this->load->model('setting/setting');

$this->model_setting_extension->uninstall('payment', $this->request->get['extension']);

$this->model_setting_setting->deleteSetting($this->request->get['extension']);

require_once(DIR_APPLICATION . 'controller/payment/' . $this->request->get['extension'] . '.php');

$class = 'ControllerPayment' . str_replace('_', '', $this->request->get['extension']);
$class = new $class($this->registry);

if (method_exists($class, 'uninstall')) {
$class->uninstall();
}

$this->redirect($this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'));
}
}

public function upload() {
/*
$this->language->load('extension/manager');

$json = array();
Expand Down Expand Up @@ -119,7 +248,7 @@ public function upload() {

if (!in_array($destination, $list)) {
if (ftp_mkdir($connection, $destination)) {
echo 'made directory ' . $destination . '<br />';
echo 'Made directory ' . $destination . '<br />';
}
}
}
Expand Down Expand Up @@ -156,7 +285,6 @@ public function upload() {
}

$this->response->setOutput(json_encode($json));
*/
}
}
?>
10 changes: 8 additions & 2 deletions upload/admin/language/english/extension/modification.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?php
// Heading
$_['heading_title'] = 'Extension Modification';
$_['heading_title'] = 'Modifications';

// Text
$_['text_success'] = 'Success: You have installed your extension!';
$_['text_install'] = 'Install';
$_['text_uninstall'] = 'Uninstall';

// Column
$_['column_name'] = 'Modification Name';
$_['column_status'] = 'Status';
$_['column_action'] = 'Action';

// Error
$_['error_permission'] = 'Warning: You do not have permission to modify extension manager!';
Expand Down
42 changes: 30 additions & 12 deletions upload/admin/view/stylesheet/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ form {
label {
cursor: pointer;
}
#container {
height: 100%;
}
body > #container {
height: auto;
min-height: 100%;
}
#header .div1 {
height: 56px;
padding: 0px 30px;
Expand Down Expand Up @@ -135,18 +142,9 @@ label {
#menu > ul li li > a:hover {
background-color: #C15C2A;
}


#container {
height: 100%;
}
body > #container {
height: auto;
min-height: 100%;
}
#content {
background: #FFFFFF url('../image/background.png') 0px 1px repeat-x;
padding: 10px 30px 0px 30px;
padding: 15px 30px 0px 30px;
min-width: 900px;
padding-bottom: 128px;
}
Expand All @@ -165,10 +163,30 @@ body > #container {
color: #333;
text-decoration: underline;
}
.breadcrumb, .breadcrumb a {
.breadcrumb {
border: 1px solid #E5E5E5;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
-khtml-border-radius: 7px;
border-radius: 7px;
margin-bottom: 15px;
overflow: auto;
padding: 10px;

}

.breadcrumb a {
font-size: 12px;
color: #666;
margin-bottom: 15px;
border: 1px solid #E5E5E5;
border-radius: 5px 0 0 5px;
background: #FFFFFF;
box-shadow: 0 0 2px rgba(0,0,0,.2);
height: 50px;
width: 150px;
display: block;
float: left;

}
.success {
padding: 10px 10px 10px 33px;
Expand Down
98 changes: 70 additions & 28 deletions upload/admin/view/template/extension/modification.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,84 @@
<?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
<?php } ?>
</div>
<?php if ($success) { ?>
<div class="success"><?php echo $success; ?></div>
<?php } ?>
<?php if ($error) { ?>
<div class="warning"><?php echo $error; ?></div>
<?php } ?>
<div class="box">
<div class="heading">
<h1><img src="view/image/module.png" alt="" /> <?php echo $heading_title; ?></h1>
<div class="buttons"><a id="button-upload" class="button"><?php echo $button_upload; ?></a></div>
<div class="buttons"><a href="" class="button">Clear VQMOD Cache</a></div>
</div>
<div class="content">
<textarea wrap="off" style="width: 98%; height: 300px; padding: 5px; border: 1px solid #CCCCCC; background: #FFFFFF; overflow: scroll;"></textarea>
<div style="padding: 10px; border: 1px solid #CCCCCC; background: #EEEEEE; margin-bottom: 20px;">
<input type="button" value="<?php echo $button_upload; ?>" id="button-upload" class="button" onclick="$('input[name=\'file\']').click();" />
</div>
<table class="list">
<thead>
<tr>
<td class="left"><?php echo $column_name; ?></td>
<td class="right"><?php echo $column_action; ?></td>
</tr>
</thead>
<tbody>
<?php if ($extensions) { ?>
<?php foreach ($extensions as $extension) { ?>
<tr>
<td class="left"><?php echo $extension['name']; ?></td>
<td class="right"><?php foreach ($extension['action'] as $action) { ?>
[ <a href="<?php echo $action['href']; ?>"><?php echo $action['text']; ?></a> ]
<?php } ?></td>
</tr>
<?php } ?>
<?php } else { ?>
<tr>
<td class="center" colspan="8"><?php echo $text_no_results; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
<div style="display: none;">
<form enctype="multipart/form-data">
<input type="file" name="file" id="file" />
</form>
</div>
<script type="text/javascript"><!--
new AjaxUpload('#button-upload', {
action: 'index.php?route=extension/manage/upload&token=<?php echo $token; ?>',
name: 'file',
autoSubmit: true,
responseType: 'text',
onSubmit: function(file, extension) {
$('#button-upload').before('<img src="view/image/loading.gif" class="loading" style="padding-right: 5px;" />');
$('#button-upload').attr('disabled', true);
},
onComplete: function(file, json) {
$('.content').after(json);
/*
$('#button-upload').attr('disabled', false);
if (json['success']) {
alert(json['success']);
}
if (json['error']) {
alert(json['error']);
}
$('.loading').remove();
*/
}
$('#file').on('change', function() {
$.ajax({
url: 'index.php?route=extension/manage/upload&token=<?php echo $token; ?>',
type: 'post',
dataType: 'json',
data: new FormData($(this).parent()[0]),
beforeSend: function() {
$('#button-upload').after('<img src="view/image/loading.gif" class="loading" style="padding-left: 5px;" />');
$('#button-upload').attr('disabled', true);
},
complete: function() {
$('.loading').remove();
$('#button-upload').attr('disabled', false);
},
success: function(json) {
if (json['error']) {
alert(json['error']);
}
if (json['success']) {
alert(json['success']);
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
},
cache: false,
contentType: false,
processData: false
});
});
//--></script>
//--></script>
<?php echo $footer; ?>
4 changes: 2 additions & 2 deletions upload/catalog/controller/common/maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public function info() {

$this->data['heading_title'] = $this->language->get('heading_title');

$this->document->breadcrumbs = array();
$this->data['breadcrumbs'] = array();

$this->document->breadcrumbs[] = array(
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_maintenance'),
'href' => $this->url->link('common/maintenance'),
'separator' => false
Expand Down
5 changes: 3 additions & 2 deletions upload/catalog/controller/common/seo_url.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public function index() {
// Decode URL
if (isset($this->request->get['_route_'])) {
$parts = explode('/', $this->request->get['_route_']);
if (strlen(end($parts))==0) array_pop($parts); // rmove any empty arrays from trailing /

if (strlen(end($parts)) == 0) array_pop($parts); // remove any empty arrays from trailing /

foreach ($parts as $part) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE keyword = '" . $this->db->escape($part) . "'");
Expand Down Expand Up @@ -115,4 +116,4 @@ public function rewrite($link) {
}
}
}
?>
?>
Loading

0 comments on commit 7a64c34

Please sign in to comment.