public static function callbackName($echo, $tr)
 {
     static $show = null;
     if ($show === null) {
         $show = (bool) Configuration::get('PP_TEMPLATE_NAME_IN_CATALOG');
     }
     if ($show) {
         $id_pp_template = PP::getProductTemplateId($tr);
         if ($id_pp_template > 0) {
             PP::getAdminProductsTemplates(PP::getProductTemplateId($tr));
             $name = PP::getTemplateName($id_pp_template, true);
             if ($name != '') {
                 static $template_title = null;
                 if ($template_title === null) {
                     $module = Module::getInstanceByName('pproperties');
                     $translations = $module->getTranslations('AdminProductsController');
                     $template_title = $translations['template_title'];
                 }
                 return $echo . '<br><span class="pp_list_template" title="' . $template_title . '"><i class="icon-template"></i>' . PP::safeOutputLenient($name) . '</span>';
             }
         }
     }
     return $echo;
 }
Пример #2
0
    public function hookDisplayBackOfficeHeader($params)
    {
        $tab = Tools::getValue('tab');
        $controller = Tools::getValue('controller');
        if (Tools::strtolower($tab) == 'adminselfupgrade' || Tools::strtolower($controller) == 'adminselfupgrade') {
            $warn = '<div class="alert alert-danger"><button data-dismiss="alert" class="close" type="button">×</button>' . sprintf($this->l('%s: Please uninstall this module before upgrading and obtain, if needed, version compatible with your new PrestaShop version.'), $this->displayName) . '<br>' . $this->compatibilityText() . '</div>';
            return '
			<script type="text/javascript">
				$(document).ready(function() {
					$("#content .bootstrap").prepend(\'' . $warn . '\');
					$("#upgradeNow").remove();
					$("#currentConfiguration table tbody").append(\'<tr><td>' . sprintf($this->l('%s module uninstalled'), $this->displayName) . '<br>' . $this->compatibilityText() . '</td><td><img alt="ok" src="../img/admin/disabled.gif"></td></tr>\');
				});
			</script>
			';
        } else {
            if ($this->context->controller instanceof Controller) {
                if (Tools::getValue('configure') != 'pproperties') {
                    if (!(int) Tools::getValue('ajax')) {
                        $last_integration_check = Configuration::get('PP_INTEGRATION_CHECK');
                        if (time() > $last_integration_check + ($this->integrated ? 3600 : 3)) {
                            $setup = $this->setupInstance();
                            $setup->checkIntegration();
                            $this->integrated = count($this->integration_test_result) == 0;
                        }
                    }
                    if (!$this->integrated) {
                        $warn = '<div class="alert alert-danger" style="clear:both;">' . '<button data-dismiss="alert" class="close" type="button">×</button>' . sprintf($this->l('%s: Integration warning. Your site will not work properly until you %s.'), $this->displayName, '<a style="text-decoration:underline;color:inherit;" href="index.php?controller=adminmodules&configure=pproperties&token=' . Tools::getAdminTokenLite('AdminModules') . '&tab_module=administration&module_name=pproperties">' . $this->l('resolve the integration problems') . '</a>') . '</div>';
                        return '
						<script type="text/javascript">
							$(document).ready(function() {
								$("#content.bootstrap").prepend(\'' . $warn . '\');
							});
						</script>
						';
                    }
                }
                $html = '';
                $add_extra = false;
                $this->context->controller->addJquery();
                $css_files = array();
                $js_files = array();
                if (in_array(Tools::strtolower($controller), array('adminproducts', 'adminorders', 'admincarts', 'adminstockmanagement', 'adminstockmvt', 'adminstockinstantstate', 'adminstockcover'))) {
                    $add_extra = true;
                } elseif (strcasecmp($controller, 'AdminModules') == 0) {
                    if (Tools::getValue('configure') == 'pproperties') {
                        $this->context->controller->addJqueryUI('ui.tabs', 'base');
                        $add_extra = true;
                    }
                }
                if ($add_extra) {
                    $css_files[] = 'views/css/pproperties_admin.css';
                    $js_files[] = 'views/js/pproperties.js';
                    $js_files[] = 'views/js/pproperties_admin.js';
                    if ($this->integrated) {
                        $html .= '<script type="text/javascript">pp.decimalSign=\'' . PP::getDecimalSign() . '\';</script>';
                    }
                }
                if ($this->integrated && strcasecmp($controller, 'AdminAttributeGenerator') == 0) {
                    $template_id = PP::getProductTemplateId(Tools::getValue('id_product'));
                    if ($template_id > 0) {
                        $properties = PP::getProductPropertiesByTemplateId($template_id);
                        if (!empty($properties['pp_bo_qty_text'])) {
                            $css_files[] = 'css/pproperties_admin.css';
                            $html .= '<script type="text/javascript">$(function() {$(\'#generator input[name="quantity"]\').after(\' ' . $properties['pp_bo_qty_text'] . '\');});</script>';
                        }
                    }
                }
                if ($css_files) {
                    foreach ($css_files as $file) {
                        $this->context->controller->addCSS($this->getPathUri() . $file);
                    }
                    PSM::amendCSS($this->context->controller->css_files, $css_files);
                }
                if ($js_files) {
                    foreach ($js_files as $file) {
                        $this->context->controller->addJS($this->getPathUri() . $file);
                    }
                    PSM::amendJS($this->context->controller->js_files, $js_files);
                }
                return $html;
            }
        }
    }