public function index()

in 3.0.x-and-above/upload/admin/controller/extension/module/facebook_business.php [20:127]


    public function index() {
        $data = $this->load->language('extension/module/facebook_business');

        $this->document->setTitle(strip_tags($this->language->get('heading_title')));

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

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

            $this->clearProductFeed();

            $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));
        }

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

        // For LWI integration
        $data['business_name'] = $this->config->get('config_name');
        $data['external_business_id'] = HTTPS_CATALOG;
        $data['timezone'] = date_default_timezone_get();
        $data['currency'] = strtoupper(addslashes($this->config->get('config_currency')));

        $plugin_version = $this->model_extension_module_facebook_business->getPluginVersion();

        $data['opencart_iframe_url'] = $this->opencart_server_base_url . '/facebook?'
        . 'external_business_id=' . urlencode(HTTPS_CATALOG)
        . '&business_name=' . addslashes($this->config->get('config_name'))
        . '&feed_url=' . urlencode(HTTPS_CATALOG . 'index.php?route=extension/module/facebook_business/genFeed')
        . '&feed_ping_url=' . urlencode(HTTPS_CATALOG . 'index.php?route=extension/module/facebook_business/genFeedPing')
        . '&timezone=' . date_default_timezone_get()
        . '&currency=' . strtoupper(addslashes($this->config->get('config_currency')))
        . '&version=' . $plugin_version;

        if ($this->config->get('config_maintenance')) {
            $data['error_maintenance_mode'] = $this->language->get('error_maintenance_mode');
        } else {
            $data['error_maintenance_mode'] = '';
        }

        if (!empty($this->config->get('facebook_dia_setting_id'))) {
            $data['opencart_iframe_url'] .= '&merchant_settings_id=' . $this->config->get('facebook_dia_setting_id');
        }

        if (!empty($this->config->get('facebook_fbe_v2_installed'))) {
            $data['opencart_iframe_url'] .= '&fbe_v2_installed=' . $this->config->get('facebook_fbe_v2_installed');
        }

        if (!empty($this->config->get('facebook_use_s2s'))) {
            $data['opencart_iframe_url'] .= '&s2s_configured=' . $this->config->get('facebook_use_s2s');
        }

        $data['access_token'] = $this->config->get('facebook_system_user_access_token');
        $data['opencart_server_base_url'] = $this->opencart_server_base_url;
        $data['facebook_app_id'] = $this->facebook_app_id;
        $data['user_token'] = $this->session->data['user_token'];
        $data['redirect_uri'] = $this->url->link('extension/module/facebook_business', 'user_token=' . $this->session->data['user_token'], true);

        $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/facebook_business', 'user_token=' . $this->session->data['user_token'], true)
        );

        $data['action'] = $this->url->link('extension/module/facebook_business', '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->error['warning'])) {
            $data['error_warning'] = $this->error['warning'];
        } else {
            $data['error_warning'] = '';
        }

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

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

        $data['text_plugin_version'] = sprintf($this->language->get('text_plugin_version'), $plugin_version);

        $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/module/facebook_business', $data));
    }