first commit

This commit is contained in:
sujan
2024-08-06 18:06:00 +05:45
commit a2fa49071a
2745 changed files with 391199 additions and 0 deletions

View File

@ -0,0 +1,96 @@
<?php
namespace Opencart\Admin\Controller\Extension\OcThemeExample\Theme;
class ThemeExample extends \Opencart\System\Engine\Controller {
public function index(): void {
$this->load->language('extension/oc_theme_example/theme/theme_example');
$this->document->setTitle($this->language->get('heading_title'));
if (isset($this->request->get['store_id'])) {
$store_id = (int)$this->request->get['store_id'];
} else {
$store_id = 0;
}
$data['breadcrumbs'] = [];
$data['breadcrumbs'][] = [
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
];
$data['breadcrumbs'][] = [
'text' => $this->language->get('text_extension'),
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=theme')
];
$data['breadcrumbs'][] = [
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('extension/oc_theme_example/theme/theme_example', 'user_token=' . $this->session->data['user_token'] . '&store_id=' . $store_id)
];
$data['save'] = $this->url->link('extension/oc_theme_example/theme/theme_example.save', 'user_token=' . $this->session->data['user_token'] . '&store_id=' . $store_id);
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=theme');
$data['theme_theme_example_status'] = $this->config->get('theme_theme_example_status');
$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
$this->response->setOutput($this->load->view('extension/oc_theme_example/theme/theme_example', $data));
}
public function save(): void {
$this->load->language('extension/oc_theme_example/theme/theme_example');
if (isset($this->request->get['store_id'])) {
$store_id = (int)$this->request->get['store_id'];
} else {
$store_id = 0;
}
$json = [];
if (!$this->user->hasPermission('modify', 'extension/oc_theme_example/theme/theme_example')) {
$json['error'] = $this->language->get('error_permission');
}
if (!$json) {
$this->load->model('setting/setting');
$this->model_setting_setting->editSetting('theme_theme_example', $this->request->post, $store_id);
$json['success'] = $this->language->get('text_success');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
public function install(): void {
if ($this->user->hasPermission('modify', 'extension/theme')) {
// Add startup to catalog
$startup_data = [
'code' => 'theme_example',
'description' => 'Example theme extension',
'action' => 'catalog/extension/oc_theme_example/startup/theme_example',
'status' => 1,
'sort_order' => 2
];
// Add startup for admin
$this->load->model('setting/startup');
$this->model_setting_startup->addStartup($startup_data);
}
}
public function uninstall(): void {
if ($this->user->hasPermission('modify', 'extension/theme')) {
$this->load->model('setting/startup');
$this->model_setting_startup->deleteStartupByCode('theme_example');
}
}
}

View File

@ -0,0 +1,14 @@
<?php
// Heading
$_['heading_title'] = 'Example Theme';
// Text
$_['text_extension'] = 'Extensions';
$_['text_success'] = 'Success: You have modified example theme!';
$_['text_edit'] = 'Edit Example Theme';
// Entry
$_['entry_status'] = 'Status';
// Error
$_['error_permission'] = 'Warning: You do not have permission to modify example theme!';

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -0,0 +1,35 @@
{{ header }}{{ column_left }}
<div id="content">
<div class="page-header">
<div class="container-fluid">
<div class="float-end">
<button type="submit" form="form-theme" data-bs-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fas fa-save"></i></button>
<a href="{{ back }}" data-bs-toggle="tooltip" title="{{ button_back }}" class="btn btn-light"><i class="fas fa-reply"></i></a></div>
<h1>{{ heading_title }}</h1>
<ol class="breadcrumb">
{% for breadcrumb in breadcrumbs %}
<li class="breadcrumb-item"><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
{% endfor %}
</ol>
</div>
</div>
<div class="container-fluid">
<div class="card">
<div class="card-header"><i class="fas fa-pencil-alt"></i> {{ text_edit }}</div>
<div class="card-body">
<form id="form-theme" action="{{ save }}" method="post" data-oc-toggle="ajax">
<div class="row mb-3">
<label for="input-status" class="col-sm-2 col-form-label">{{ entry_status }}</label>
<div class="col-sm-10">
<div class="form-check form-switch form-switch-lg">
<input type="hidden" name="theme_theme_example_status" value="0"/>
<input type="checkbox" name="theme_theme_example_status" value="1" id="input-status" class="form-check-input"{% if theme_theme_example_status %} checked{% endif %}/>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{{ footer }}