/**
  * Initialization of the class.
  *
  * @return void
  */
 public function init()
 {
     // Setting GPvars:
     $this->id = (int) GeneralUtility::_GP('id');
     if (!$this->id) {
         \CommerceTeam\Commerce\Utility\FolderUtility::initFolders();
         $this->id = current(array_unique(FolderRepository::initFolders('Products', 'Commerce', 0, 'Commerce')));
     }
     $this->edit = GeneralUtility::_GP('edit');
     $this->return_id = GeneralUtility::_GP('return_id');
     $this->lastEdited = GeneralUtility::_GP('lastEdited');
     // Setting GPvars:
     $controlParams = GeneralUtility::_GP('control');
     if ($controlParams) {
         $controlArray = current($controlParams);
         $this->categoryUid = (int) $controlArray['uid'];
     }
     // Module name;
     $this->MCONF = $GLOBALS['MCONF'];
     // Page select clause:
     $this->perms_clause = \CommerceTeam\Commerce\Utility\BackendUtility::getCategoryPermsClause(1);
     $this->initPage();
     // Set up menus:
     $this->menuConfig();
 }
 /**
  * Initializing the module.
  *
  * @return void
  */
 public function init()
 {
     $this->getLanguageService()->includeLLFile('EXT:lang/locallang_mod_web_list.xml');
     // Setting GPvars:
     $this->id = (int) GeneralUtility::_GP('id');
     if (!$this->id) {
         \CommerceTeam\Commerce\Utility\FolderUtility::initFolders();
         $this->id = current(array_unique(FolderRepository::initFolders('Products', 'Commerce', 0, 'Commerce')));
     }
     // Initialize the listing object, dblist, for rendering the list:
     $this->pointer = max(min(GeneralUtility::_GP('pointer'), 100000), 0);
     $this->imagemode = GeneralUtility::_GP('imagemode');
     $this->table = GeneralUtility::_GP('table');
     $this->search_field = GeneralUtility::_GP('search_field');
     $this->search_levels = GeneralUtility::_GP('search_levels');
     $this->showLimit = (int) GeneralUtility::_GP('showLimit');
     $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
     $this->clear_cache = (bool) GeneralUtility::_GP('clear_cache');
     $this->cmd = GeneralUtility::_GP('cmd');
     $this->cmd_table = GeneralUtility::_GP('cmd_table');
     // Setting GPvars:
     $controlParams = GeneralUtility::_GP('control');
     if ($controlParams) {
         $controlArray = current($controlParams);
         $this->categoryUid = (int) $controlArray['uid'];
     }
     // Module name;
     $this->MCONF = $GLOBALS['MCONF'];
     // Page select clause:
     $this->perms_clause = \CommerceTeam\Commerce\Utility\BackendUtility::getCategoryPermsClause(1);
     $this->initPage();
     $this->clearCache();
     // Set up menus:
     $this->menuConfig();
 }
Esempio n. 3
0
 /**
  * Initializes the categorydata
  * Builds the Permission-Statement.
  *
  * @return void
  */
 public function init()
 {
     $this->whereClause = ' deleted = 0 AND ' . \CommerceTeam\Commerce\Utility\BackendUtility::getCategoryPermsClause($this->permsMask);
     $this->order = 'tx_commerce_categories.sorting ASC';
 }
    /**
     * Shows the copy wizard.
     *
     * @param int    $uidClip   Uid of the clipped item
     * @param int    $uidTarget Uid of target
     * @param string $command   Command
     */
    protected function showCopyWizard($uidClip, $uidTarget, $command)
    {
        $language = $this->getLanguageService();
        $str = '';
        $this->pageinfo = BackendUtility::readCategoryAccess($uidTarget, BackendUtility::getCategoryPermsClause(1));
        $str .= $this->doc->header($language->getLL('Copy'));
        $str .= $this->doc->spacer(5);
        // flag if neither sorting nor localizations
        // are existing and we can immediately copy
        $noActionReq = false;
        // First prepare user defined hooks
        $hooks = \CommerceTeam\Commerce\Factory\HookFactory::getHooks('Utility/DataHandlerUtility', 'showCopyWizard');
        switch ($command) {
            case 'overwrite':
                // pass through
            // pass through
            case 'pasteProduct':
                // chose local to copy from product
                /**
                 * Product.
                 *
                 * @var \CommerceTeam\Commerce\Domain\Model\Product $product
                 */
                $product = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Product', $uidClip);
                $product->loadData();
                $prods = $product->getL18nProducts();
                if (!empty($prods)) {
                    $str .= '<h1>' . $language->getLL('copy.head.l18n') . '</h1>
                        <h2>' . $language->getLL('copy.product') . ': ' . $product->getTitle() . '</h2>
                        <ul>';
                    // walk the l18n and get the selector box
                    $l = count($prods);
                    for ($i = 0; $i < $l; ++$i) {
                        $tmpProd = $prods[$i];
                        $flag = $tmpProd['flag'] != '' ? '<img src="' . $this->getBackPath() . 'gfx/flags/' . $tmpProd['flag'] . '" alt="Flag" />' : '';
                        $str .= '<li><input type="checkbox" name="locale[]" id="loc_' . $tmpProd['uid'] . '" value="' . $tmpProd['sys_language'] . '" /><label for="loc_' . $tmpProd['uid'] . '">' . $flag . $tmpProd['title'] . '</label></li>';
                    }
                    $str .= '</ul>';
                }
                $records = array();
                // chose sorting position
                if ($command != 'overwrite') {
                    // Initialize tree object:
                    /**
                     * Product data.
                     *
                     * @var \CommerceTeam\Commerce\Tree\Leaf\ProductData $productData
                     */
                    $productData = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\Leaf\\ProductData');
                    $productData->init();
                    $records = $productData->getRecordsDbList($uidTarget);
                }
                $l = count($records['pid'][$uidTarget]);
                // Hook: beforeFormClose
                $userIgnoreClose = false;
                foreach ($hooks as $hookObj) {
                    if (method_exists($hookObj, 'beforeFormClose')) {
                        // set $user_ignoreClose to true if you want to
                        // force the script to print out the execute button
                        $str .= $hookObj->beforeFormClose($uidClip, $uidTarget, $command, $userIgnoreClose);
                    }
                }
                if (0 >= $l && (!empty($prods) || $userIgnoreClose)) {
                    // no child object - sorting position is irrelevant - just print a submit button
                    // and notify users that there are not products in the category yet
                    $str .= '<input type="submit" value="' . $language->getLL('copy.submit') . '" />';
                } elseif (0 < $l) {
                    // at least 1 item - offer choice
                    $icon = '<img' . IconUtility::skinImg($this->getBackPath(), 'gfx/newrecord_marker_d.gif', 'width="281" height="8"') . ' alt="" title="Insert the category" />';
                    $prodIcon = '<img' . IconUtility::skinImg($this->getBackPath(), IconUtility::getIcon('tx_commerce_products', array('uid' => $uidTarget)), 'width="18" height="16"') . 'align="top" class="c-recIcon"/>';
                    $str .= '<h1>' . $language->getLL('copy.position') . '</h1>';
                    $onClickAction = 'onclick="submitForm(' . $records['pid'][$uidTarget][0]['uid'] . ')"';
                    $str .= '<span class="nobr"><a href="javascript:void(0)" ' . $onClickAction . '>' . $icon . '</a></span><br />';
                    for ($i = 0; $i < $l; ++$i) {
                        $record = $records['pid'][$uidTarget][$i];
                        $onClickAction = 'onclick="submitForm(-' . $record['uid'] . ')"';
                        $str .= '<span class="nobr">' . $prodIcon . $record['title'] . '</span><br />';
                        $str .= '<span class="nobr"><a href="javascript:void(0)" ' . $onClickAction . '>' . $icon . '</a></span><br />';
                    }
                } else {
                    $noActionReq = true;
                }
                break;
            case 'pasteCategory':
                // chose locale to copy from category
                /**
                 * Category.
                 *
                 * @var \CommerceTeam\Commerce\Domain\Model\Category $category
                 */
                $category = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Category', $uidClip);
                $category->loadData();
                $cats = $category->getL18nCategories();
                if (!empty($cats)) {
                    $str .= '<h1>' . $language->getLL('copy.head.l18n') . '</h1>
						<h2>' . $language->getLL('copy.category') . ': ' . $category->getTitle() . '</h2>
						<ul>';
                    // walk the l18n and get the selector box
                    $l = count($cats);
                    for ($i = 0; $i < $l; ++$i) {
                        $tmpCat = $cats[$i];
                        $flag = $tmpCat['flag'] != '' ? '<img src="' . $this->getBackPath() . 'gfx/flags/' . $tmpCat['flag'] . '" alt="Flag" />' : '';
                        $str .= '<li><input type="checkbox" name="locale[]" id="loc_' . $tmpCat['uid'] . '" value="' . $tmpCat['sys_language'] . '" /><label for="loc_' . $tmpCat['uid'] . '">' . $flag . $tmpCat['title'] . '</label></li>';
                    }
                    $str .= '</ul>';
                }
                // chose sorting position
                // Initialize tree object:
                /**
                 * Category data.
                 *
                 * @var \CommerceTeam\Commerce\Tree\Leaf\CategoryData $categoryData
                 */
                $categoryData = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\Leaf\\CategoryData');
                $categoryData->init();
                $records = $categoryData->getRecordsDbList($uidTarget);
                $l = count($records['pid'][$uidTarget]);
                // Hook: beforeFormClose
                $userIgnoreClose = false;
                foreach ($hooks as $hookObj) {
                    if (method_exists($hookObj, 'beforeFormClose')) {
                        $str .= $hookObj->beforeFormClose($uidClip, $uidTarget, $command, $userIgnoreClose);
                    }
                }
                if ($l == 0 && (!empty($cats) || $userIgnoreClose)) {
                    // no child object - sorting position is irrelevant - just print a submit button
                    $str .= '<input type="submit" value="' . $language->getLL('copy.submit') . '" />';
                } elseif (0 < $l) {
                    // at least 1 item - offer choice
                    $icon = '<img' . IconUtility::skinImg($this->getBackPath(), 'gfx/newrecord_marker_d.gif', 'width="281" height="8"') . ' alt="" title="Insert the category" />';
                    $catIcon = '<img' . IconUtility::skinImg($this->getBackPath(), IconUtility::getIcon('tx_commerce_categories', array('uid' => $uidTarget)), 'width="18" height="16"') . 'align="top" class="c-recIcon"/>';
                    $str .= '<h1>' . $language->getLL('copy.position') . '</h1>';
                    $onClickAction = 'onclick="submitForm(' . $records['pid'][$uidTarget][0]['uid'] . ')"';
                    $str .= '<span class="nobr"><a href="javascript:void(0)" ' . $onClickAction . '>' . $icon . '</a></span><br />';
                    for ($i = 0; $i < $l; ++$i) {
                        $record = $records['pid'][$uidTarget][$i];
                        $onClickAction = 'onclick="submitForm(-' . $record['uid'] . ')"';
                        $str .= '<span class="nobr">' . $catIcon . $record['title'] . '</span><br />
							<span class="nobr"><a href="javascript:void(0)" ' . $onClickAction . '>' . $icon . '</a></span><br />';
                    }
                } else {
                    $noActionReq = true;
                }
                break;
            default:
                die('unknown command');
        }
        // skip transforming and execute the command
        // if there are no locales and no positions
        if ($noActionReq) {
            $this->commitCommand($uidClip, $uidTarget, $command);
            return;
        }
        // Hook: beforeTransform
        foreach ($hooks as $hookObj) {
            if (method_exists($hookObj, 'beforeTransform')) {
                $str .= $hookObj->beforeTransform($uidClip, $uidTarget, $command);
            }
        }
        $this->content .= $str;
        $markers = array('CSH' => '', 'CONTENT' => $this->content, 'CATINFO' => '', 'CATPATH' => '');
        $markers['FUNC_MENU'] = $this->doc->funcMenu('', \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[mode]', $this->MOD_SETTINGS['mode'], $this->MOD_MENU['mode']));
        $this->content = $this->doc->startPage($language->getLL('Copy'));
        $this->content .= $this->doc->moduleBody($this->pageinfo, array(), $markers);
        $this->content .= $this->doc->endPage();
    }