UPGRADE NOTE: Do not edit or add to this file if you wish to upgrade AbanteCart to newer versions in the future. If you wish to customize AbanteCart for your needs please refer to http://www.AbanteCart.com for more information. ------------------------------------------------------------------------------*/ if (!defined('DIR_CORE') || !IS_ADMIN) { header('Location: static_pages/'); } /** * Class ControllerResponsesListingGridExtension */ class ControllerResponsesListingGridExtension extends AController { public $data; public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('extension/extensions'); $page = $this->request->post['page']; // get the requested page if ((int)$page < 0) $page = 0; $limit = $this->request->post['rows']; // get how many rows we want to have into the grid $sidx = $this->request->post['sidx']; // get index row - i.e. user click to sort $sord = $this->request->post['sord']; // get the direction $search_str = ''; if (isset($this->request->post['_search']) && $this->request->post['_search'] == 'true') { $searchData = json_decode(htmlspecialchars_decode($this->request->post['filters']), true); $search_str = $searchData['rules'][0]['data']; } $store_id = (int)$this->config->get('config_store_id'); if ($this->request->get_or_post('store_id')) { $store_id = $this->request->get_or_post('store_id'); } //sort $allowedSort = array(1 => 'key', 'name', 'category', 'date_modified', 'status', 'store_name'); if (!in_array($sidx, $allowedSort)) $sidx = 'date_modified'; $allowedDirection = array(SORT_ASC => 'asc', SORT_DESC => 'desc'); if (!in_array($sord, $allowedDirection)) { $sord = 'asc'; } //extensions that has record in DB but missing files $missing_extensions = $this->extensions->getMissingExtensions(); $data = array( 'store_id' => $store_id, 'search' => $search_str, 'filter' => $this->session->data['extension_filter'], 'sort_order' => array($sidx, $sord) ); if ($this->config->get('config_store_id')) { $data['store_id'] = (int)$this->config->get('config_store_id'); } //extensions list $extensions = $this->extension_manager->getExtensionsList($data); $total = $extensions->total; if ($total > 0) { $total_pages = ceil($total / $limit); } else { $total_pages = 0; } $response = new stdClass(); $response->rows = array(); $response->page = $page; $response->total = $total_pages; $response->records = $total; $response->userdata = new stdClass(); $i = 0; $push = array(); // get extensions for install $ready_to_install = $this->session->data['ready_to_install']; $to_install = $to_inst_keys = array(); if(!has_value( $this->session->data['extension_filter']) || $this->session->data['extension_filter']=='extensions'){ if($ready_to_install && is_array($ready_to_install)){ foreach( $ready_to_install as $pack ){ $to_install[$pack['extension_name']] = array('remote_install' => true, 'key' => $pack['extension_name'], 'name' => $pack['download_name'], 'extension_version' => $pack['extension_version'], 'installation_key' => $pack['installation_key'], 'date_modified' => $pack['date_modified']); $to_inst_keys[] = $pack['extension_name']; } } } //filter already installed from remote list (ignores new versions too) foreach($extensions->rows as $row){ if(in_array($row['key'],$to_inst_keys)){ unset($to_install[$row['key']]); } } $rows = array_merge( $to_install, $extensions->rows); $upd = $this->cache->get('extensions.updates'); foreach ($rows as $row) { $extension = $row['key']; $response->rows[$i]['id'] = $extension . '_' . (int)$row['store_id']; $id = $response->rows[$i]['id']; $response->userdata->extension_id[$id] = $extension; $response->userdata->store_id[$id] = $row['store_id']; $name = !isset($row['name']) ? trim($this->extensions->getExtensionName($extension)) : $row['name']; //for new extensions if( $row['remote_install'] ){ $response->userdata->installation_key[$id] = $row['installation_key']; $icon = ''; $category = ''; $status = $this->language->get('text_ready_to_install'); $response->userdata->classes[$id] = 'success disable-edit disable-delete disable-uninstall disable-install'; }elseif (in_array($extension, $missing_extensions)) { $response->userdata->classes[$id] = 'warning disable-edit disable-install disable-uninstall disable-remote-install'; $icon = ''; $name = sprintf($this->language->get('text_missing_extension'),$extension); $category = $status = ''; $row['date_modified'] = date('Y-m-d H:i:s', time()); // change it for show it in list first by default sorting } elseif (!file_exists(DIR_EXT . $extension . '/main.php') || !file_exists(DIR_EXT . $extension . '/config.xml')) { $response->userdata->classes[$id] = 'warning disable-edit disable-install disable-uninstall disable-remote-install'; $icon = ''; $name = sprintf($this->language->get('text_broken_extension'), $extension); $category = $status = ''; $row['date_modified'] = date('Y-m-d H:i:s', time()); // change it for show it in list first by default sorting } else { if (!$this->config->has($extension . '_status')) { $response->userdata->classes[$id] = 'disable-edit disable-uninstall disable-remote-install'; $status = $this->language->get('text_not_installed'); } else { $response->userdata->classes[$id] = 'disable-delete disable-install disable-remote-install'; $status = $this->html->buildCheckbox(array( 'name' => $extension . '[' . $extension . '_status]', 'value' => $row['status'], 'style' => 'btn_switch', )); } $icon_ext_img_url = HTTP_CATALOG . 'extensions/' . $extension . '/image/icon.png'; $icon_ext_dir = DIR_EXT . $extension . '/image/icon.png'; $icon = (is_file($icon_ext_dir) ? $icon_ext_img_url : RDIR_TEMPLATE . 'image/default_extension.png'); if (!$this->config->has($extension . '_status')) { $icon = ''; } else { $icon = ''; } $category = $row['category']; // if update available if( is_array($upd) && in_array($extension,array_keys($upd)) ){ $name = '
' . $name . '
' . sprintf( $this->language->get('text_update_available'),
$upd[$extension]['version'],
$this->html->getSecureURL('tool/package_installer', '&extension_key=' . $upd[$extension]['installation_key'])) . '