/** * Processing of clickmenu items * * @param \TYPO3\CMS\Backend\ClickMenu\ClickMenu $backRef parent * @param array $menuItems Menu items array to modify * @param string $table Table name * @param int $uid Uid of the record * @return array Menu item array, returned after modification * @todo Skinning for icons... */ public function main(&$backRef, $menuItems, $table, $uid) { $localItems = []; // Show import/export on second level menu OR root level. if ($backRef->cmLevel && GeneralUtility::_GP('subname') == 'moreoptions' || $table === 'pages' && $uid == 0) { $LL = $this->includeLL(); $urlParameters = ['tx_impexp' => ['action' => 'export'], 'id' => $table == 'pages' ? $uid : $backRef->rec['pid']]; if ($table == 'pages') { $urlParameters['tx_impexp']['pagetree']['id'] = $uid; $urlParameters['tx_impexp']['pagetree']['levels'] = 0; $urlParameters['tx_impexp']['pagetree']['tables'][] = '_ALL'; } else { $urlParameters['tx_impexp']['record'][] = $table . ':' . $uid; $urlParameters['tx_impexp']['external_ref']['tables'][] = '_ALL'; } $url = BackendUtility::getModuleUrl('xMOD_tximpexp', $urlParameters); $localItems[] = $backRef->linkItem(htmlspecialchars($this->getLanguageService()->getLLL('export', $LL)), $this->iconFactory->getIcon('actions-document-export-t3d', Icon::SIZE_SMALL), $backRef->urlRefForCM($url), 1); if ($table === 'pages') { $backendUser = $this->getBackendUser(); $isEnabledForNonAdmin = $backendUser->getTSConfig('options.impexp.enableImportForNonAdminUser'); if ($backendUser->isAdmin() || !empty($isEnabledForNonAdmin['value'])) { $urlParameters = ['id' => $uid, 'table' => $table, 'tx_impexp' => ['action' => 'import']]; $url = BackendUtility::getModuleUrl('xMOD_tximpexp', $urlParameters); $localItems[] = $backRef->linkItem(htmlspecialchars($this->getLanguageService()->getLLL('import', $LL)), $this->iconFactory->getIcon('actions-document-import-t3d', Icon::SIZE_SMALL), $backRef->urlRefForCM($url), 1); } } } return array_merge($menuItems, $localItems); }
/** * Processing of clickmenu items * * @param \TYPO3\CMS\Backend\ClickMenu\ClickMenu $backRef parent * @param array $menuItems Menu items array to modify * @param string $table Table name * @param int $uid Uid of the record * @return array Menu item array, returned after modification * @todo Skinning for icons... */ public function main(&$backRef, $menuItems, $table, $uid) { $localItems = array(); // Show import/export on second level menu OR root level. if ($backRef->cmLevel && \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('subname') == 'moreoptions' || $table === 'pages' && $uid == 0) { $LL = $this->includeLL(); $urlParameters = array('tx_impexp' => array('action' => 'export'), 'id' => $table == 'pages' ? $uid : $backRef->rec['pid']); if ($table == 'pages') { $urlParameters['tx_impexp']['pagetree']['id'] = $uid; $urlParameters['tx_impexp']['pagetree']['levels'] = 0; $urlParameters['tx_impexp']['pagetree']['tables'][] = '_ALL'; } else { $urlParameters['tx_impexp']['record'][] = $table . ':' . $uid; $urlParameters['tx_impexp']['external_ref']['tables'][] = '_ALL'; } $url = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('xMOD_tximpexp', $urlParameters); $localItems[] = $backRef->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('export', $LL)), $backRef->excludeIcon(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-export-t3d')), $backRef->urlRefForCM($url), 1); if ($table == 'pages') { $urlParameters = array('id' => $uid, 'table' => $table, 'tx_impexp' => array('action' => 'import')); $url = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('xMOD_tximpexp', $urlParameters); $localItems[] = $backRef->linkItem($GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLLL('import', $LL)), $backRef->excludeIcon(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-import-t3d')), $backRef->urlRefForCM($url), 1); } } return array_merge($menuItems, $localItems); }
/** * Create click menu item * * @param string $title * @param string $shortTitle * @param string $icon * @param string $url * @param bool $addReturnUrl * @return string */ protected function createLink($title, $shortTitle, $icon, $url, $addReturnUrl = TRUE) { if (strpos($url, 'alert') !== 0) { $url = $this->parentObject->urlRefForCM($url, $addReturnUrl ? 'returnUrl' : ''); } return $this->parentObject->linkItem('<span title="' . htmlspecialchars($title) . '">' . $shortTitle . '</span>', $this->parentObject->excludeIcon($icon), $url); }
/** * Main function, adding the item to input menuItems array * * @param ClickMenu $backRef References to parent clickmenu objects. * @param array $menuItems Array of existing menu items accumulated. New element added to this. * @param string $table Table name of the element * @param int $uid Record UID of the element * @return array Modified menuItems array */ public function main(&$backRef, $menuItems, $table, $uid) { $localItems = array(); if (!$backRef->cmLevel && $uid > 0 && $GLOBALS['BE_USER']->check('modules', 'web_txversionM1')) { // Returns directly, because the clicked item was not from the pages table if (in_array('versioning', $backRef->disabledItems) || !$GLOBALS['TCA'][$table] || !$GLOBALS['TCA'][$table]['ctrl']['versioningWS']) { return $menuItems; } // Adds the regular item $LL = $this->includeLL(); // "Versioning" element added: $url = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_txversionM1', array('table' => $table, 'uid' => $uid)); $localItems[] = $backRef->linkItem($GLOBALS['LANG']->getLLL('title', $LL), $backRef->excludeIcon($this->iconFactory->getIcon('actions-version-open', Icon::SIZE_SMALL)->render()), $backRef->urlRefForCM($url), true); // Find position of "delete" element: $c = 0; foreach ($menuItems as $k => $value) { $c++; if ($k === 'delete') { break; } } // .. subtract two (delete item + divider line) $c -= 2; // ... and insert the items just before the delete element. array_splice($menuItems, $c, 0, $localItems); } return $menuItems; }
/** * Main function, adding the item to input menuItems array * * @param ClickMenu $backRef References to parent clickmenu objects. * @param array $menuItems Array of existing menu items accumulated. New element added to this. * @param string $table Table name of the element * @param int $uid Record UID of the element * @return array Modified menuItems array */ public function main(&$backRef, $menuItems, $table, $uid) { $localItems = array(); if (!$backRef->cmLevel && $uid > 0 && $GLOBALS['BE_USER']->check('modules', 'web_txversionM1')) { // Returns directly, because the clicked item was not from the pages table if (in_array('versioning', $backRef->disabledItems) || !$GLOBALS['TCA'][$table] || !$GLOBALS['TCA'][$table]['ctrl']['versioningWS']) { return $menuItems; } // Adds the regular item $LL = $this->includeLL(); // "Versioning" element added: $url = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_txversionM1', array('table' => $table, 'uid' => $uid)); $localItems[] = $backRef->linkItem($GLOBALS['LANG']->getLLL('title', $LL), $backRef->excludeIcon('<img src="' . $backRef->backPath . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('version') . 'Resources/Public/Icons/module-version.png" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url), TRUE); // Find position of "delete" element: $c = 0; foreach ($menuItems as $k => $value) { $c++; if ($k === 'delete') { break; } } // .. subtract two (delete item + divider line) $c -= 2; // ... and insert the items just before the delete element. array_splice($menuItems, $c, 0, $localItems); } return $menuItems; }
/** * Displays the 'Send to review/public' option * * @param string $table Table that is to be host of the sending * @param int $uid Uid of the item that is to be send * * @return string */ public function DB_review($table, $uid) { $language = $this->getLanguageService(); $url = ExtensionManagementUtility::extRelPath('version') . 'cm1/index.php?id=' . ($table == 'pages' ? $uid : $this->rec['pid']) . '&table=' . rawurlencode($table) . '&uid=' . $uid . '&sendToReview=1'; return $this->clickMenu->linkItem($language->sL('LLL:EXT:version/locallang.xml:title_review', 1), $this->excludeIcon('<img src="' . $this->backPath . ExtensionManagementUtility::extRelPath('version') . 'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $this->clickMenu->urlRefForCM($url), 1); }