コード例 #1
0
 public function initPageHeaderToolbar()
 {
     if (empty($this->display)) {
         $this->page_header_toolbar_btn['new_product'] = array('href' => self::$currentIndex . '&addproduct&token=' . $this->token, 'desc' => $this->l('Add new product', null, null, false), 'icon' => 'process-icon-new');
     }
     if ($this->display == 'edit') {
         if (($product = $this->loadObject(true)) && $product->isAssociatedToShop()) {
             if ($url_preview = $this->getPreviewUrl($product)) {
                 $this->page_header_toolbar_btn['preview'] = array('short' => $this->l('Preview', null, null, false), 'href' => $url_preview, 'desc' => $this->l('Preview', null, null, false), 'target' => true, 'class' => 'previewUrl');
             }
             $js = (bool) Image::getImages($this->context->language->id, (int) $product->id) ? 'confirm_link(\'\', \'' . $this->l('This will copy the images too. If you wish to proceed, click "Yes". If not, click "No".', null, true, false) . '\', \'' . $this->l('Yes', null, true, false) . '\', \'' . $this->l('No', null, true, false) . '\', \'' . $this->context->link->getAdminLink('AdminProducts', true) . '&id_product=' . (int) $product->id . '&duplicateproduct' . '\', \'' . $this->context->link->getAdminLink('AdminProducts', true) . '&id_product=' . (int) $product->id . '&duplicateproduct&noimage=1' . '\')' : 'document.location = \'' . $this->context->link->getAdminLink('AdminProducts', true) . '&id_product=' . (int) $product->id . '&duplicateproduct&noimage=1' . '\'';
             if ($this->tabAccess['add']) {
                 $this->page_header_toolbar_btn['duplicate'] = array('short' => $this->l('Duplicate', null, null, false), 'desc' => $this->l('Duplicate', null, null, false), 'confirm' => 1, 'js' => $js);
             }
             if (file_exists(_PS_MODULE_DIR_ . 'statsproduct/statsproduct.php')) {
                 $this->page_header_toolbar_btn['stats'] = array('short' => $this->l('Statistics', null, null, false), 'href' => $this->context->link->getAdminLink('AdminStats') . '&module=statsproduct&id_product=' . (int) $product->id, 'desc' => $this->l('Product sales', null, null, false));
             }
             if ($this->tabAccess['delete']) {
                 $this->page_header_toolbar_btn['delete'] = array('short' => $this->l('Delete', null, null, false), 'href' => $this->context->link->getAdminLink('AdminProducts') . '&id_product=' . (int) $product->id . '&deleteproduct', 'desc' => $this->l('Delete this product', null, null, false), 'confirm' => 1, 'js' => 'if (confirm(\'' . $this->l('Delete product?', null, true, false) . '\')){return true;}else{event.preventDefault();}');
             }
         }
     }
     parent::initPageHeaderToolbar();
 }