public function index()
{
$this->document->setTitle('Journal Control Panel');
$this->document->addStyle('//fonts.googleapis.com/css?family=Oswald');
if (!Front::$IS_OC2) {
$this->document->addStyle('view/journal2/lib/bootstrap/css/bootstrap.css');
$this->document->addScript('view/journal2/lib/bootstrap/js/bootstrap.min.js');
}
$this->document->addScript('view/journal2/lib/css_browser_selector.js');
$this->document->addScript('//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js');
$this->document->addScript('view/journal2/lib/ckeditor/ckeditor.js');
$this->document->addStyle('view/journal2/lib/css-toggle-switch/toggle-switch.css');
$this->document->addStyle('view/journal2/lib/select2/select2.css');
$this->document->addStyle('view/journal2/lib/angular-table/ng-table.min.css');
$this->document->addStyle('view/journal2/lib/simple-slider/css/simple-slider.css');
$this->document->addStyle('view/journal2/css/hint.min.css');
$this->document->addStyle('view/journal2/css/main.css');
$this->document->addScript('view/journal2/lib/spectrum/spectrum.js');
$this->document->addStyle('view/journal2/lib/spectrum/spectrum.css');
$this->document->addScript('view/journal2/js/colors.js');
$this->document->addStyle('../catalog/view/theme/journal2/css/icons/style.css');
if (Front::$IS_OC2) {
$this->data['header'] = $this->load->controller('common/header');
$this->data['column_left'] = $this->load->controller('common/column_left');
$this->data['footer'] = $this->load->controller('common/footer');
} else {
$this->children = array('common/header', 'common/footer');
}
/* check browser */
$browser = new Browser();
if ($browser->isBrowser('Internet Explorer') && version_compare($browser->getVersion(), '8.0', '<=')) {
$this->template = '../journal2/tpl/error' . (Front::$IS_OC2 ? '_oc2' : '') . '.tpl';
$this->data['journal_error_title'] = 'Browser Error';
$this->data['journal_error_message'] = 'It seems you are using an outdated browser. <br />We recommend you update your browser to the latest version.';
$this->response->setOutput($this->render());
return;
}
/* tables does not exist*/
if (!$this->db->query(str_replace('_', '\\_', 'show tables like "' . DB_PREFIX . 'journal2_config"'))->num_rows) {
$this->template = '../journal2/tpl/error' . (Front::$IS_OC2 ? '_oc2' : '') . '.tpl';
$this->data['journal_error_title'] = 'Database Error';
$this->data['journal_error_message'] = 'Uninstalling and reinstalling this module may solve this issue.';
$this->response->setOutput($this->render());
return;
}
/* check if files are replaced correctly */
if (!defined('JOURNAL_VERSION')) {
$this->template = '../journal2/tpl/error' . (Front::$IS_OC2 ? '_oc2' : '') . '.tpl';
$this->data['journal_error_title'] = 'Journal Installation Error';
$this->data['journal_error_message'] = 'Make sure you have uploaded all Journal files to your server and successfully replaced <b>system/engine/front.php</b> file.<br /> You can find more information <a href="http://docs.digital-atelier.com/opencart/journal/#/settings/install" target="_blank">here</a>.';
$this->response->setOutput($this->render());
return;
}
if (!Front::$IS_OC2) {
$this->load->model('setting/extension');
if (!method_exists($this->model_setting_extension, 'uninstallJ2Extension')) {
$this->template = '../journal2/tpl/error' . (Front::$IS_OC2 ? '_oc2' : '') . '.tpl';
$this->data['journal_error_title'] = 'Journal Installation Error';
$this->data['journal_error_message'] = 'Make sure you have uploaded all Journal files to your server and successfully replaced <b>admin/model/setting/extension.php</b> file.<br /> You can find more information <a href="http://docs.digital-atelier.com/opencart/journal/#/settings/install" target="_blank">here</a>.';
$this->response->setOutput($this->render());
return;
}
}
/* check if vqmod is installed */
if (!Front::$IS_OC2 && !class_exists('VQMod')) {
$this->template = '../journal2/tpl/error' . (Front::$IS_OC2 ? '_oc2' : '') . '.tpl';
$this->data['journal_error_title'] = 'VQMod Error';
$this->data['journal_error_message'] = 'It seems you do not have the latest VQMod version installed. Click <a href="https://github.com/vqmod/vqmod/releases" target="_blank">here</a> to download it.';
$this->response->setOutput($this->render());
return;
}
/* check if blog is installed */
$this->load->model('journal2/blog');
if (!$this->model_journal2_blog->isInstalled()) {
$this->model_journal2_blog->install();
}
/* get success message */
if (isset($this->session->data['success'])) {
$this->data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$this->data['success'] = '';
}
/* get warning message */
if (isset($this->session->data['warning'])) {
$this->data['warning'] = $this->session->data['warning'];
unset($this->session->data['warning']);
} else {
$this->data['warning'] = '';
}
/* get stores */
$this->load->model('setting/store');
$stores = $this->model_setting_store->getStores();
array_unshift($stores, array('store_id' => "0", 'name' => $this->config->get('config_name')));
$this->data['journal2_config']['stores'] = $stores;
/* get active skin */
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "journal2_config WHERE store_id = '0' AND `key` = 'active_skin'");
$this->data['journal2_config']['active_skin'] = $query->num_rows ? $query->row['value'] : 1;
/* get languages */
$this->load->model('localisation/language');
$languages = $this->model_localisation_language->getLanguages();
$default_language = null;
foreach ($languages as $language) {
if ($language['language_id'] == $this->config->get('config_language_id')) {
$default_language = $language['language_id'];
break;
}
}
$this->data['journal2_config']['languages'] = array('languages' => $languages, 'default' => $default_language);
/* get layouts */
$this->load->model('design/layout');
$this->data['journal2_config']['layouts'] = $this->model_design_layout->getLayouts();
/* img folder */
$this->data['journal2_config']['img_folder'] = isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1') ? HTTPS_CATALOG . 'image/' : HTTP_CATALOG . 'image/';
/* render template */
$this->template = '../journal2/tpl/cp_index.tpl';
$this->response->setOutput($this->render());
}