/**
  * Administrative links for a table / record
  *
  * @param string $table Table name
  * @param array $row Record for which administrative links are generated.
  *
  * @return string HTML link tags.
  */
 public function adminLinks($table, array $row)
 {
     if ($table !== 'tx_commerce_products') {
         return parent::adminLinks($table, $row);
     } else {
         $language = $this->getLanguageService();
         // Edit link:
         $adminLink = '<a href="#" onclick="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick('&edit[' . $table . '][' . $row['uid'] . ']=edit', $this->doc->backPath)) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-open', array('title' => $language->sL('LLL:EXT:lang/locallang_core.xml:cm.edit', TRUE))) . '</a>';
         // Delete link:
         $adminLink .= '<a href="' . htmlspecialchars($this->doc->issueCommand('&cmd[' . $table . '][' . $row['uid'] . '][delete]=1')) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-delete', array('title' => $language->sL('LLL:EXT:lang/locallang_core.php:cm.delete', TRUE))) . '</a>';
         if ($row['pid'] == -1) {
             // get page TSconfig
             $pagesTyposcriptConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($GLOBALS['_POST']['popViewId']);
             if ($pagesTyposcriptConfig['tx_commerce.']['singlePid']) {
                 $previewPageId = $pagesTyposcriptConfig['tx_commerce.']['singlePid'];
             } else {
                 $previewPageId = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][COMMERCE_EXTKEY]['extConf']['previewPageID'];
             }
             $sysLanguageUid = (int) $row['sys_language_uid'];
             /**
              * Product
              *
              * @var $product Tx_Commerce_Domain_Model_Product
              */
             $product = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Domain_Model_Product', $row['t3ver_oid'], $sysLanguageUid);
             $product->loadData();
             $getVars = ($sysLanguageUid > 0 ? '&L=' . $sysLanguageUid : '') . '&ADMCMD_vPrev[' . rawurlencode($table . ':' . $row['t3ver_oid']) . ']=' . $row['uid'] . '&no_cache=1&tx_commerce_pi1[showUid]=' . $product->getUid() . '&tx_commerce_pi1[catUid]=' . current($product->getMasterparentCategory());
             $adminLink .= '<a href="#" onclick="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick($previewPageId, $this->doc->backPath, \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($row['_REAL_PID']), '', '', $getVars)) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-view') . '</a>';
         }
         return $adminLink;
     }
 }
 /**
  * Administrative links for a table / record
  *
  * @param string $table Table name
  * @param array $row Record for which administrative links are generated.
  * @return string HTML link tags.
  * @todo Define visibility
  */
 public function adminLinks($table, $row)
 {
     // Edit link:
     $adminLink = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick('&edit[' . $table . '][' . $row['uid'] . ']=edit', $this->doc->backPath)) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.edit', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
     // Delete link:
     $adminLink .= '<a href="' . htmlspecialchars($this->doc->issueCommand('&cmd[' . $table . '][' . $row['uid'] . '][delete]=1')) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.delete', TRUE) . '">' . IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
     if ($table === 'pages') {
         // If another page module was specified, replace the default Page module with the new one
         $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
         $pageModule = BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
         // Perform some acccess checks:
         $a_wl = $GLOBALS['BE_USER']->check('modules', 'web_list');
         $a_wp = $GLOBALS['BE_USER']->check('modules', $pageModule);
         $adminLink .= '<a href="#" onclick="top.loadEditId(' . $row['uid'] . ');top.goToModule(\'' . $pageModule . '\'); return false;">' . IconUtility::getSpriteIcon('actions-page-open') . '</a>';
         $adminLink .= '<a href="#" onclick="top.loadEditId(' . $row['uid'] . ');top.goToModule(\'web_list\'); return false;">' . IconUtility::getSpriteIcon('actions-system-list-open') . '</a>';
         // "View page" icon is added:
         $adminLink .= '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($row['uid'], $this->doc->backPath, BackendUtility::BEgetRootLine($row['uid']))) . '">' . IconUtility::getSpriteIcon('actions-document-view') . '</a>';
     } else {
         if ($row['pid'] == -1) {
             $getVars = '&ADMCMD_vPrev[' . rawurlencode($table . ':' . $row['t3ver_oid']) . ']=' . $row['uid'];
             // "View page" icon is added:
             $adminLink .= '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($row['_REAL_PID'], $this->doc->backPath, BackendUtility::BEgetRootLine($row['_REAL_PID']), '', '', $getVars)) . '">' . IconUtility::getSpriteIcon('actions-document-view') . '</a>';
         }
     }
     return $adminLink;
 }
 /**
  * Administrative links for a table / record
  *
  * @param string $table Table name
  * @param array $row Record for which administrative links are generated.
  * @return string HTML link tags.
  */
 public function adminLinks($table, $row)
 {
     // Edit link:
     $editUrl = BackendUtility::getModuleUrl('record_edit', ['edit' => [$table => [$row['uid'] => 'edit']], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]);
     $adminLink = '<a class="btn btn-default" href="' . htmlspecialchars($editUrl) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.edit', true) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
     // Delete link:
     $adminLink .= '<a class="btn btn-default" href="' . htmlspecialchars($this->doc->issueCommand('&cmd[' . $table . '][' . $row['uid'] . '][delete]=1')) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.delete', true) . '">' . $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render() . '</a>';
     if ($table === 'pages') {
         // If another page module was specified, replace the default Page module with the new one
         $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
         $pageModule = BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
         // Perform some access checks:
         $a_wl = $GLOBALS['BE_USER']->check('modules', 'web_list');
         $a_wp = $GLOBALS['BE_USER']->check('modules', $pageModule);
         $adminLink .= '<a class="btn btn-default" href="#" onclick="top.loadEditId(' . $row['uid'] . ');top.goToModule(\'' . $pageModule . '\'); return false;">' . $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render() . '</a>';
         $adminLink .= '<a class="btn btn-default" href="#" onclick="top.loadEditId(' . $row['uid'] . ');top.goToModule(\'web_list\'); return false;">' . $this->iconFactory->getIcon('actions-system-list-open', Icon::SIZE_SMALL)->render() . '</a>';
         // "View page" icon is added:
         $adminLink .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($row['uid'], '', BackendUtility::BEgetRootLine($row['uid']))) . '">' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '</a>';
     } else {
         if ($row['pid'] == -1) {
             $getVars = '&ADMCMD_vPrev[' . rawurlencode($table . ':' . $row['t3ver_oid']) . ']=' . $row['uid'];
             // "View page" icon is added:
             $adminLink .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($row['_REAL_PID'], '', BackendUtility::BEgetRootLine($row['_REAL_PID']), '', '', $getVars)) . '">' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '</a>';
         }
     }
     return '<div class="btn-group btn-group-sm" role="group">' . $adminLink . '</div>';
 }
 /**
  * Render supplier row.
  *
  * @param \mysqli_result $result Result
  * @param array $fields Fields
  *
  * @return string
  */
 protected function renderSupplierRows(\mysqli_result $result, array $fields)
 {
     $language = $this->getLanguageService();
     $output = '';
     $table = 'tx_commerce_supplier';
     while ($row = $this->getDatabaseConnection()->sql_fetch_assoc($result)) {
         $refCountMsg = BackendUtility::referenceCount($table, $row['uid'], ' ' . $language->sL('LLL:EXT:lang/locallang_core.xml:labels.referencesToRecord'), $this->getReferenceCount($table, $row['uid']));
         $editParams = '&edit[' . $table . '][' . (int) $row['uid'] . ']=edit';
         $deleteParams = '&cmd[' . $table . '][' . (int) $row['uid'] . '][delete]=1';
         $onClickAction = 'onclick="' . htmlspecialchars(BackendUtility::editOnClick($editParams, $this->getBackPath(), -1)) . '"';
         $output .= '<tr><td><a href="#" ' . $onClickAction . '>' . IconUtility::getSpriteIcon('actions-document-open', array('title' => $language->getLL('edit', true))) . '</a>';
         $output .= '<a href="#" onclick="' . htmlspecialchars('if (confirm(' . $language->JScharCode($language->getLL('deleteWarningSupplier') . ' "' . htmlspecialchars($row['title']) . '" ' . $refCountMsg) . ')) {jumpToUrl(\'' . $this->doc->issueCommand($deleteParams, -1) . '\');} return false;') . '">' . IconUtility::getSpriteIcon('actions-edit-delete', array('title' => $language->getLL('delete', true))) . '</a>';
         $output .= '</td>';
         foreach ($fields as $field) {
             $output .= '<td valign="top" class="bgColor4"><strong>' . htmlspecialchars($row[$field]) . '</strong>';
         }
         $output .= '</td></tr>';
     }
     return $output;
 }
    /**
     * Make selector box for creating new translation for a record or switching to edit the record in an existing language.
     * Displays only languages which are available for the current page.
     *
     * @param string $table Table name
     * @param int $uid Uid for which to create a new language
     * @param int $pid Pid of the record
     * @return string <select> HTML element (if there were items for the box anyways...)
     */
    public function languageSwitch($table, $uid, $pid = NULL)
    {
        $content = '';
        $languageField = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
        $transOrigPointerField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
        // Table editable and activated for languages?
        if ($this->getBackendUser()->check('tables_modify', $table) && $languageField && $transOrigPointerField && !$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable']) {
            if (is_null($pid)) {
                $row = BackendUtility::getRecord($table, $uid, 'pid');
                $pid = $row['pid'];
            }
            // Get all avalibale languages for the page
            $langRows = $this->getLanguages($pid);
            // Page available in other languages than default language?
            if (is_array($langRows) && count($langRows) > 1) {
                $rowsByLang = array();
                $fetchFields = 'uid,' . $languageField . ',' . $transOrigPointerField;
                // Get record in current language
                $rowCurrent = BackendUtility::getLiveVersionOfRecord($table, $uid, $fetchFields);
                if (!is_array($rowCurrent)) {
                    $rowCurrent = BackendUtility::getRecord($table, $uid, $fetchFields);
                }
                $currentLanguage = $rowCurrent[$languageField];
                // Disabled for records with [all] language!
                if ($currentLanguage > -1) {
                    // Get record in default language if needed
                    if ($currentLanguage && $rowCurrent[$transOrigPointerField]) {
                        $rowsByLang[0] = BackendUtility::getLiveVersionOfRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields);
                        if (!is_array($rowsByLang[0])) {
                            $rowsByLang[0] = BackendUtility::getRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields);
                        }
                    } else {
                        $rowsByLang[$rowCurrent[$languageField]] = $rowCurrent;
                    }
                    if ($rowCurrent[$transOrigPointerField] || $currentLanguage === '0') {
                        // Get record in other languages to see what's already available
                        $translations = $this->getDatabaseConnection()->exec_SELECTgetRows($fetchFields, $table, 'pid=' . (int) $pid . ' AND ' . $languageField . '>0' . ' AND ' . $transOrigPointerField . '=' . (int) $rowsByLang[0]['uid'] . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table));
                        foreach ($translations as $row) {
                            $rowsByLang[$row[$languageField]] = $row;
                        }
                    }
                    $langSelItems = array();
                    foreach ($langRows as $lang) {
                        if ($this->getBackendUser()->checkLanguageAccess($lang['uid'])) {
                            $newTranslation = isset($rowsByLang[$lang['uid']]) ? '' : ' [' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.new', TRUE) . ']';
                            // Create url for creating a localized record
                            if ($newTranslation) {
                                $redirectUrl = BackendUtility::getModuleUrl('record_edit', array('justLocalized' => $table . ':' . $rowsByLang[0]['uid'] . ':' . $lang['uid'], 'returnUrl' => $this->retUrl)) . BackendUtility::getUrlToken('editRecord');
                                $href = $this->doc->issueCommand('&cmd[' . $table . '][' . $rowsByLang[0]['uid'] . '][localize]=' . $lang['uid'], $redirectUrl);
                            } else {
                                $href = BackendUtility::getModuleUrl('record_edit', array('edit[' . $table . '][' . $rowsByLang[$lang['uid']]['uid'] . ']' => 'edit', 'returnUrl' => $this->retUrl)) . BackendUtility::getUrlToken('editRecord');
                            }
                            $langSelItems[$lang['uid']] = '
								<option value="' . htmlspecialchars($href) . '"' . ($currentLanguage == $lang['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($lang['title'] . $newTranslation) . '</option>';
                        }
                    }
                    // If any languages are left, make selector:
                    if (count($langSelItems) > 1) {
                        $onChange = 'if(this.options[this.selectedIndex].value){window.location.href=(this.options[this.selectedIndex].value);}';
                        $content = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_general.xlf:LGL.language', TRUE) . ' <select name="_langSelector" onchange="' . htmlspecialchars($onChange) . '">
							' . implode('', $langSelItems) . '
							</select>';
                    }
                }
            }
        }
        return $content;
    }