/** * Initialization of the class * * @return void */ public function init() { // Setting GPvars: $this->id = (int) GeneralUtility::_GP('id'); if (!$this->id) { Tx_Commerce_Utility_FolderUtility::initFolders(); $this->id = current(array_unique(Tx_Commerce_Domain_Repository_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 = Tx_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) { Tx_Commerce_Utility_FolderUtility::initFolders(); $this->id = current(array_unique(Tx_Commerce_Domain_Repository_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 = Tx_Commerce_Utility_BackendUtility::getCategoryPermsClause(1); $this->initPage(); $this->clearCache(); // Set up menus: $this->menuConfig(); }
/** * Initializes the categorydata * Builds the Permission-Statement * * @return void */ public function init() { $this->whereClause = ' deleted = 0 AND ' . Tx_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 * * @return void */ protected function showCopyWizard($uidClip, $uidTarget, $command) { $language = $this->getLanguageService(); $str = ''; $this->pageinfo = Tx_Commerce_Utility_BackendUtility::readCategoryAccess($uidTarget, Tx_Commerce_Utility_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 objects (if any) // for hooks which extend this function: $hookObjectsArr = array(); if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/mod_cce/class.tx_commerce_cce_db.php']['copyWizardClass'])) { \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(' hook $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/mod_cce/class.tx_commerce_cce_db.php\'][\'copyWizardClass\'] is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0, please use instead $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/Classes/Utility/DataHandlerUtility.php\'][\'copyWizard\'] '); foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/mod_cce/class.tx_commerce_cce_db.php']['copyWizardClass'] as $classRef) { $hookObjectsArr[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef); } } if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Utility/DataHandlerUtility.php']['copyWizard'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Utility/DataHandlerUtility.php']['copyWizard'] as $classRef) { $hookObjectsArr[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef); } } switch ($command) { case 'overwrite': // pass through // pass through case 'pasteProduct': // chose local to copy from product /** * Product * * @var Tx_Commerce_Domain_Model_Product $product */ $product = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Domain_Model_Product', $uidClip); $product->loadData(); $prods = $product->getL18nProducts(); if (count($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->doc->backPath . '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 Tx_Commerce_Tree_Leaf_ProductData $treedb */ $treedb = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_ProductData'); $treedb->init(); $records = $treedb->getRecordsDbList($uidTarget); } $l = count($records['pid'][$uidTarget]); // Hook: beforeFormClose $userIgnoreClose = FALSE; foreach ($hookObjectsArr 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 && (0 != count($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' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/newrecord_marker_d.gif', 'width="281" height="8"') . ' alt="" title="Insert the category" />'; $prodIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getIconImage('tx_commerce_products', array('uid' => $uidTarget), $this->doc->backPath, '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 Tx_Commerce_Domain_Model_Category $category */ $category = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Domain_Model_Category', $uidClip); $category->loadData(); $cats = $category->getL18nCategories(); if (0 != count($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->doc->backPath . '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 Tx_Commerce_Tree_Leaf_CategoryData $treedb */ $treedb = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_CategoryData'); $treedb->init(); $records = $treedb->getRecordsDbList($uidTarget); $l = count($records['pid'][$uidTarget]); // Hook: beforeFormClose $userIgnoreClose = FALSE; foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'beforeFormClose')) { $str .= $hookObj->beforeFormClose($uidClip, $uidTarget, $command, $userIgnoreClose); } } if (0 == $l && (0 != count($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' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/newrecord_marker_d.gif', 'width="281" height="8"') . ' alt="" title="Insert the category" />'; $catIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getIconImage('tx_commerce_categories', array('uid' => $uidTarget), $this->doc->backPath, '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 ($hookObjectsArr 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(); }