public function help() { $extension = $this->request->get['extension']; $ext = new ExtensionUtils($extension); $help_file_path = DIR_EXT . $extension . '/' . str_replace('..', '', $ext->getConfig('help_file')); $content = array(); $content['title'] = $this->language->get('text_help'); if (file_exists($help_file_path) && is_file($help_file_path)) { $content['content'] = file_get_contents($help_file_path); } else { $content['content'] = $this->language->get('error_no_help_file'); } $content['content'] = $this->html->convertLinks($content['content']); $this->load->library('json'); $this->response->setOutput(AJson::encode($content)); }
public function help() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $extension = $this->request->get['extension']; $ext = new ExtensionUtils($extension); $help_file_path = DIR_EXT . $extension . '/' . str_replace('..', '', $ext->getConfig('help_file')); $this->data['content'] = array(); $this->data['title'] = $this->language->get('text_help'); if (file_exists($help_file_path) && is_file($help_file_path)) { $this->data['content'] = file_get_contents($help_file_path); } else { $this->data['content'] = $this->language->get('error_no_help_file'); } $this->data['content'] = $this->html->convertLinks($this->data['content']); $this->view->batchAssign($this->data); $this->response->setOutput($this->view->fetch('responses/extension/howto.tpl')); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function delete() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!$this->user->canModify('extension/extensions')) { $this->session->data['error'] = $this->language->get('error_permission'); $this->redirect($this->html->getSecureURL('extension/extensions/' . $this->session->data['extension_filter'])); } else { //extensions that has record in DB but missing files $missing_extensions = $this->extensions->getMissingExtensions(); if (!in_array($this->request->get['extension'], $missing_extensions) && $this->config->has($this->request->get['extension'] . '_status')) { $this->session->data['error'] = $this->language->get('error_uninstall'); $this->redirect($this->html->getSecureURL('extension/extensions/' . $this->session->data['extension_filter'])); } $ext = new ExtensionUtils($this->request->get['extension']); if (in_array($this->request->get['extension'], $missing_extensions)) { $this->extension_manager->uninstall($this->request->get['extension'], $ext->getConfig()); } $this->extension_manager->delete($this->request->get['extension']); $this->redirect($this->html->getSecureURL('extension/extensions/' . $this->session->data['extension_filter'])); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function __construct() { $this->extensions_dir = array(); $this->db_extensions = array(); $this->missing_extensions = array(); $extensions = glob(DIR_EXT . '*', GLOB_ONLYDIR); if ($extensions) { foreach ($extensions as $ext) { //skip other directory not containing extensions if (is_file($ext . '/config.xml')) { $this->extensions_dir[] = str_replace(DIR_EXT, '', $ext); } } } $registry = Registry::getInstance(); if ($registry->has('db')) { $this->db = $registry->get('db'); //get extensions from db $query = $this->getExtensionsList(); foreach ($query->rows as $result) { $this->db_extensions[] = $result['key']; } //check if we have extensions that has record in db, but missing files // if so, disable them $this->missing_extensions = array_diff($this->db_extensions, $this->extensions_dir); if (!empty($this->missing_extensions)) { foreach ($this->missing_extensions as $ext) { $warning = new AWarning($ext . ' directory is missing'); $warning->toMessages(); } } //check if we have extensions in dir that has no record in db $diff = array_diff($this->extensions_dir, $this->db_extensions); if (!empty($diff)) { foreach ($diff as $ext) { $data['key'] = $ext; $data['status'] = 0; $misext = new ExtensionUtils($ext); $data['type'] = $misext->getConfig('type'); $data['version'] = $misext->getConfig('version'); $data['priority'] = $misext->getConfig('priority'); $data['category'] = $misext->getConfig('category'); $data['license_key'] = $registry->get('session')->data['package_info']['extension_key']; if ($registry->has('extension_manager')) { $registry->get('extension_manager')->add($data); } } } } }