Example #1
0
 /**
  * Links to publishing etc of a version
  *
  * @param	string		Table name
  * @param	array		Online record
  * @param	array		Offline record (version)
  * @param	string		Swap type, "branch", "page" or "element"
  * @return	string		HTML content, mainly link tags and images.
  */
 function displayWorkspaceOverview_commandLinks($table, &$rec_on, &$rec_off, $vType)
 {
     if ($this->publishAccess && (!($GLOBALS['BE_USER']->workspaceRec['publish_access'] & 1) || (int) $rec_off['t3ver_stage'] === 10)) {
         $actionLinks = '<a href="' . htmlspecialchars($this->doc->issueCommand('&cmd[' . $table . '][' . $rec_on['uid'] . '][version][action]=swap' . '&cmd[' . $table . '][' . $rec_on['uid'] . '][version][swapWith]=' . $rec_off['uid'])) . '" title="' . $GLOBALS['LANG']->getLL('publish', TRUE) . '">' . t3lib_iconWorks::getSpriteIcon('actions-version-swap-versions') . '</a>';
         if ($GLOBALS['BE_USER']->workspaceSwapAccess()) {
             $actionLinks .= '<a href="' . htmlspecialchars($this->doc->issueCommand('&cmd[' . $table . '][' . $rec_on['uid'] . '][version][action]=swap' . '&cmd[' . $table . '][' . $rec_on['uid'] . '][version][swapWith]=' . $rec_off['uid'] . '&cmd[' . $table . '][' . $rec_on['uid'] . '][version][swapIntoWS]=1')) . '" title="' . $GLOBALS['LANG']->getLL('swap', TRUE) . '">' . t3lib_iconWorks::getSpriteIcon('actions-version-swap-workspace') . '</a>';
         }
     }
     if (!$GLOBALS['BE_USER']->workspaceCannotEditOfflineVersion($table, $rec_off)) {
         // Release
         $actionLinks .= '<a href="' . htmlspecialchars($this->doc->issueCommand('&cmd[' . $table . '][' . $rec_off['uid'] . '][version][action]=clearWSID')) . '" onclick="return confirm(\'' . $GLOBALS['LANG']->getLL('removeFromWorkspace', TRUE) . '?\');" title="' . $GLOBALS['LANG']->getLL('removeFromWorkspace', TRUE) . '">' . t3lib_iconWorks::getSpriteIcon('actions-version-document-remove') . '</a>';
         // Edit
         if ($table === 'pages' && $vType !== 'element') {
             $tempUid = $vType === 'branch' || $GLOBALS['BE_USER']->workspace === 0 ? $rec_off['uid'] : $rec_on['uid'];
             $actionLinks .= '<a href="#" onclick="top.loadEditId(' . $tempUid . ');top.goToModule(\'' . $this->pageModule . '\'); return false;" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_user_ws.xml:img_title_edit_page', TRUE) . '">' . t3lib_iconWorks::getSpriteIcon('actions-version-page-open') . '</a>';
         } else {
             $params = '&edit[' . $table . '][' . $rec_off['uid'] . ']=edit';
             $actionLinks .= '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->doc->backPath)) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_user_ws.xml:img_title_edit_element', TRUE) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>';
         }
     }
     // History/Log
     $actionLinks .= '<a href="' . htmlspecialchars($this->doc->backPath . 'show_rechis.php?element=' . rawurlencode($table . ':' . $rec_off['uid']) . '&returnUrl=' . rawurlencode($this->REQUEST_URI)) . '" title="' . $GLOBALS['LANG']->getLL('showLog', TRUE) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-history-open') . '</a>';
     // View
     if ($table === 'pages') {
         $tempUid = $vType === 'branch' || $GLOBALS['BE_USER']->workspace === 0 ? $rec_off['uid'] : $rec_on['uid'];
         $actionLinks .= '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($tempUid, $this->doc->backPath, t3lib_BEfunc::BEgetRootLine($tempUid))) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-view') . '</a>';
     }
     return $actionLinks;
 }
Example #2
0
    /**
     * 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 name
     * @param	integer		uid for which to create a new language
     * @param	integer		pid of the record
     * @return	string		<select> HTML element (if there were items for the box anyways...)
     */
    function languageSwitch($table, $uid, $pid = NULL)
    {
        global $TCA;
        $content = '';
        $languageField = $TCA[$table]['ctrl']['languageField'];
        $transOrigPointerField = $TCA[$table]['ctrl']['transOrigPointerField'];
        // table editable and activated for languages?
        if ($GLOBALS['BE_USER']->check('tables_modify', $table) && $languageField && $transOrigPointerField && !$TCA[$table]['ctrl']['transOrigPointerTable']) {
            if (is_null($pid)) {
                $row = t3lib_befunc::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 = t3lib_befunc::getLiveVersionOfRecord($table, $uid, $fetchFields);
                if (!is_array($rowCurrent)) {
                    $rowCurrent = t3lib_befunc::getRecord($table, $uid, $fetchFields);
                }
                $currentLanguage = $rowCurrent[$languageField];
                if ($currentLanguage > -1) {
                    // Disabled for records with [all] language!
                    // get record in default language if needed
                    if ($currentLanguage) {
                        $rowsByLang[0] = t3lib_befunc::getLiveVersionOfRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields);
                        if (!is_array($rowsByLang[0])) {
                            $rowsByLang[0] = t3lib_befunc::getRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields);
                        }
                    } else {
                        $rowsByLang[0] = $rowCurrent;
                    }
                    // get record in other languages to see what's already available
                    $translations = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fetchFields, $table, 'pid=' . intval($pid) . ' AND ' . $languageField . '>0' . ' AND ' . $transOrigPointerField . '=' . intval($rowsByLang[0]['uid']) . t3lib_BEfunc::deleteClause($table) . t3lib_BEfunc::versioningPlaceholderClause($table));
                    foreach ($translations as $row) {
                        $rowsByLang[$row[$languageField]] = $row;
                    }
                    $langSelItems = array();
                    foreach ($langRows as $lang) {
                        if ($GLOBALS['BE_USER']->checkLanguageAccess($lang['uid'])) {
                            $newTranslation = isset($rowsByLang[$lang['uid']]) ? '' : ' [' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.new', 1) . ']';
                            // create url for creating a localized record
                            if ($newTranslation) {
                                $href = $this->doc->issueCommand('&cmd[' . $table . '][' . $rowsByLang[0]['uid'] . '][localize]=' . $lang['uid'], $this->backPath . 'alt_doc.php?justLocalized=' . rawurlencode($table . ':' . $rowsByLang[0]['uid'] . ':' . $lang['uid']) . '&returnUrl=' . rawurlencode($this->retUrl) . t3lib_BEfunc::getUrlToken('editRecord'));
                                // create edit url
                            } else {
                                $href = $this->backPath . 'alt_doc.php?';
                                $href .= '&edit[' . $table . '][' . $rowsByLang[$lang['uid']]['uid'] . ']=edit';
                                $href .= '&returnUrl=' . rawurlencode($this->retUrl) . t3lib_BEfunc::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 = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.language', 1) . ' <select name="_langSelector" onchange="' . htmlspecialchars($onChange) . '">
								' . implode('', $langSelItems) . '
							</select>';
                    }
                }
            }
        }
        return $content;
    }