⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.1
Server IP:
185.238.29.86
Server:
Linux server2 6.8.12-6-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-6 (2024-12-19T19:05Z) x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.31
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
var
/
www
/
olasjoys
/
modules
/
classy_productextratab
/
View File Name :
classy_productextratab.php
<?php if ( ! defined( '_PS_VERSION_' ) ) { exit; } /** * Classy_Productextratab ClassyDevs Product Extra Tab. * Module Main Class. */ class Classy_Productextratab extends Module { /** * __construct * * @return void */ public function __construct() { $this->name = 'classy_productextratab'; $this->tab = 'front_office_features'; $this->version = '1.1.2'; $this->author = 'ClassyDevs'; $this->need_instance = 0; $this->ps_versions_compliancy = array( 'min' => '1.6', 'max' => _PS_VERSION_, ); $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l( 'Classy Product Extra Tab' ); $this->description = $this->l( 'Add extra product tab to your products' ); $this->confirmUninstall = $this->l( 'Are you sure you want to uninstall?' ); $this->define_constants(); } /** * Install function runs on installing the module. */ public function install() { $this->insertTables(); $this->tabs = $this->get_module_tab_arr(); $this->register_module_controller(); return parent::install() && $this->registerHook( 'displayProductExtraContent' ) && $this->registerHook( 'displayDashboardTop' ) && $this->registerHook( 'displayAdminProductsExtra' ) && $this->registerHook( 'backOfficeHeader' ); } /** * Uninstall function runs on uninstallation of the module. */ public function uninstall() { include_once dirname( __FILE__ ) . '/helpers/uninstall_sql.php'; $this->tabs = $this->get_module_tab_arr(); return ( parent::uninstall() && $this->unregister_module_controllers() ); } /** * Define_constants function defines constants. * * @return void */ private function define_constants() { if ( ! defined( 'CLASSSY_PEXTRATAB_URL' ) ) { define( 'CLASSSY_PEXTRATAB_URL', _PS_BASE_URL_SSL_ . __PS_BASE_URI__ . '/modules/' . 'classy_productextratab/' ); } if ( ! defined( 'CLASSSY_PEXTRATAB_CLASS_DIR' ) ) { define( 'CLASSSY_PEXTRATAB_CLASS_DIR', _PS_MODULE_DIR_ . 'classy_productextratab/classes/' ); } if ( ! defined( 'CLASSSY_PEXTRATAB_ASSETS_DIR' ) ) { define( 'CLASSSY_PEXTRATAB_ASSETS_DIR', _PS_MODULE_DIR_ . 'classy_productextratab/assets/' ); } if ( ! defined( 'CLASSSY_PEXTRATAB_IMAGES_URL' ) ) { define( 'CLASSSY_PEXTRATAB_IMAGES_URL', CLASSSY_PEXTRATAB_URL . 'assets/images/' ); } if ( ! defined( 'CLASSSY_PEXTRATAB_VERSION' ) ) { define( 'CLASSSY_PEXTRATAB_VERSION', $this->version ); } } public function hookDisplayAdminProductsExtra( $params ) { include_once CLASSSY_PEXTRATAB_CLASS_DIR . 'classyproductextratab.php'; $link = ''; $link_html = ''; $link_all_html = ''; $link_add_html = ''; $prd_id = $params['id_product']; if($prd_id){ $classyextraobg = new classyproductextratab(); $results = $classyextraobg->GetTabContentByProductId( $prd_id, 'title' ); if(!empty($results)){ foreach($results as $result){ if($result['product_page']){ $link = $this->context->link->getAdminLink('Adminclassytabcreator', true, [], [ 'updateclassyproductextratabs' => true, 'id_classyproductextratabs' => (int) $result['id_classyproductextratabs']] ); $link_all_html .= '<a href="'.$link.'" class="btn btn-primary ml-1">Edit : '.$result['title'].'</a>'; }else{ $link = $this->context->link->getAdminLink('Adminclassytabcreator', true, [], [ 'updateclassyproductextratabs' => true, 'id_classyproductextratabs' => (int) $result['id_classyproductextratabs']] ); $link_html .= '<a href="'.$link.'" class="btn btn-primary ml-1">Edit : '.$result['title'].'</a>'; } } } $link = $this->context->link->getAdminLink('Adminclassytabcreator', true, [], [ 'addclassyproductextratabs' => true, 'specific_prd_value' => $prd_id] ); $link_add_html .= '<a href="'.$link.'" class="btn btn-primary">Add New Tab</a>'; if($link_all_html != ''){ $link_all_html = '<div class"classy-tabs-parent"> <h3>Tabs for All Products</h3> '.$link_all_html.' </div>'; } if($link_html != ''){ $link_html = '<div class"classy-tabs-parent"> <h3>Tabs for This Product</h3> '.$link_html.' </div>'; } $return_html = '<div class="classy-tabs-wrapper"> '.$link_all_html.' <br> '.$link_html.' <br> <div class"classy-tabs-parent"> <h3>Add a New Tab for This Product</h3> '.$link_add_html.' </div> </div>'; return $return_html; } } /** * GetContent gets the configuration content. */ public function getContent() { $output = null; if ( Tools::isSubmit( 'submit' . $this->name ) ) { $purchase_code = strval( Tools::getValue( 'CLASSYPETAB_LICENSE' ) ); if ( ! $purchase_code || empty( $purchase_code ) ) { $output .= $this->displayError( $this->l( 'Please Enter a Purchase Code' ) ); } else { include_once CLASSSY_PEXTRATAB_CLASS_DIR . 'classypetab_updater.php'; $updater = new ClassypetabUpdater(); $status = $updater->classypetab_activate_license( $purchase_code ); if ( $status ) { Configuration::updateValue( 'CLASSYPETAB_LICENSE', $purchase_code ); $today = date( 'Y-m-d' ); Configuration::updateValue( 'CLASSYPETAB_DATE', $today ); $output .= $this->displayConfirmation( $this->l( 'Purchase Code Activated' ) ); } else { Configuration::updateValue( 'CLASSYPETAB_LICENSE', '' ); $output .= $this->displayError( $this->l( 'Invalid Purchase Code. Please try again!!!' ) ); } } } return $output . $this->displayForm(); } /** * DisplayForm gets the configuration form. */ public function displayForm() { $defaultLang = (int) Configuration::get( 'PS_LANG_DEFAULT' ); $fieldsForm[0]['form'] = array( 'legend' => array( 'title' => $this->l( 'Activate License to Get Updates' ), ), 'input' => array( array( 'type' => 'text', 'label' => $this->l( 'Purchase Code' ), 'name' => 'CLASSYPETAB_LICENSE', 'size' => 20, 'required' => true, ), ), 'submit' => array( 'title' => $this->l( 'Save' ), 'class' => 'btn btn-default pull-right', ), ); $helper = new HelperForm(); $helper->module = $this; $helper->name_controller = $this->name; $helper->token = Tools::getAdminTokenLite( 'AdminModules' ); $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name; $helper->default_form_language = $defaultLang; $helper->allow_employee_form_lang = $defaultLang; $helper->title = $this->displayName; $helper->show_toolbar = false; $helper->toolbar_scroll = false; $helper->submit_action = 'submit' . $this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l( 'Save' ), 'href' => AdminController::$currentIndex . '&configure=' . $this->name . '&save' . $this->name . '&token=' . Tools::getAdminTokenLite( 'AdminModules' ), ), 'back' => array( 'href' => AdminController::$currentIndex . '&token=' . Tools::getAdminTokenLite( 'AdminModules' ), 'desc' => $this->l( 'Back to list' ), ), ); $helper->fields_value['CLASSYPETAB_LICENSE'] = Tools::getValue( 'CLASSYPETAB_LICENSE', Configuration::get( 'CLASSYPETAB_LICENSE' ) ); return $helper->generateForm( $fieldsForm ); } /** * InsertTables in sertst tables for the module. */ private function insertTables() { $sql = array(); include_once dirname( __FILE__ ) . '/helpers/install_sql.php'; if ( is_array( $sql ) && ! empty( $sql ) ) { foreach ( $sql as $sq ) : if ( ! Db::getInstance()->Execute( $sq ) ) { return false; } endforeach; }; return true; } /** * Get_module_tab_arr return the tab array of the module. */ private function get_module_tab_arr() { return array( array( 'class_name' => 'Adminclassytabcreator', 'module' => 'classy_productextratab', 'name' => 'Classy Product Extra Tab', 'visible' => true, 'active' => 1, ), ); } /** * Register_module_controller registers tab creator controller for the module. * * @return void */ private function register_module_controller() { $this->langs = Language::getLanguages(); $extratab = new Tab(); $extratab->class_name = 'Adminclassyextratab'; $extratab->module = ''; $extratab->id_parent = 0; $extratab->active = 1; foreach ( $this->langs as $l ) { $extratab->name[ $l['id_lang'] ] = $this->l( 'Product Extra Tabs' ); } $extratab->save(); $parenttab_id = $extratab->id; foreach ( $this->tabs as $tab ) { $newtab = new Tab(); $newtab->class_name = $tab['class_name']; $newtab->id_parent = $parenttab_id; $newtab->active = $tab['active']; $newtab->module = $tab['module']; foreach ( $this->langs as $l ) { $newtab->name[ $l['id_lang'] ] = $this->l( $tab['name'] ); } $newtab->save(); } } /** * Unregister_module_controllers deletes tab from admin dashboard. */ private function unregister_module_controllers() { foreach ( $this->tabs as $tab ) { $tabid = Tab::getIdFromClassName( $tab['class_name'] ); if ( $tabid ) { $tab = new Tab( $tabid ); $tab->delete(); } } $tabmid = Tab::getIdFromClassName( 'Adminclassyextratab' ); if ( $tabmid ) { $tabm = new Tab( $tabmid ); $tabm->delete(); } return true; } /** * HookdisplayProductExtraContent hook callback for the hook "displayProductExtraContent" * * @param mixed $params pramaeters for the functions. */ public function hookdisplayProductExtraContent( $params ) { include_once CLASSSY_PEXTRATAB_CLASS_DIR . 'classyproductextratab.php'; $id_product = Tools::getValue( 'id_product' ); $classyextraobg = new classyproductextratab(); $results = $classyextraobg->GetTabContentByProductId( $id_product, 'title' ); $array = array(); foreach ( $results as $result ) { $content = $result['content']; if (Module::isInstalled('jscomposer') && Module::isEnabled('jscomposer')) { $jsinstance = Module::getInstanceByName('jscomposer'); $jsinstance->init(); $content = JsComposer::do_shortcode($content); } $array[] = ( new PrestaShop\PrestaShop\Core\Product\ProductExtraContent() ) ->setTitle( $result['title'] ) ->setContent( $content ); } return $array; } /** * HookDisplayDashboardTop hook callback for the hook "displayDashboardTop" * * @return void */ public function hookDisplayDashboardTop() { $controller_name = Tools::getValue( 'controller' ); if ( $controller_name == 'Adminclassytabcreator' ) { include_once CLASSSY_PEXTRATAB_CLASS_DIR . 'classypetab_updater.php'; ClassypetabUpdater::init(); ?> <div class="row"> <div class="col-lg-12"> <div class="panel dashboard-presents-product-area"> <div class="dashboard-presents-product-container"> <div class="dashboard-presents-product-top-content"> <div class="dashboard-presents-product-top-by-content"> <h4> Powered by</h4> <a href="#" target="_blank"> <img src="<?php echo CLASSSY_PEXTRATAB_IMAGES_URL . 'smart-logo.png'; ?>" alt="Logo"> </a> </div> </div> <div class="dashboard-presents-product-bottom-content"> <!-- single item --> <div class="dashboar-single-presents-item db-first-item"> <a href="https://classydevs.com/elementor-prestashop-page-builder/" target="_blank"> <img src="<?php echo CLASSSY_PEXTRATAB_IMAGES_URL . 'crazy-banner-main.png'; ?>" alt="Logo"> </a> </div> <!-- single item --> <div class="dashboar-single-presents-item db-second-item"> <a href="https://classydevs.com/slider-revolution-prestashop/" target="_blank"> <img src="<?php echo CLASSSY_PEXTRATAB_IMAGES_URL . 'slider-rev-banner-2.png'; ?>" alt="Logo"> </a> </div> </div> </div> </div> </div> </div> <?php } } /** * HookDisplayBackOfficeHeader * * @return void */ public function hookDisplayBackOfficeHeader() { $this->context->controller->addCSS( CLASSSY_PEXTRATAB_ASSETS_DIR . '/css/admin.css' ); } /** * HookBackOfficeHeader */ public function hookBackOfficeHeader() { return $this->hookDisplayBackOfficeHeader(); } }