/** * Renders the display framework of a single sheet. Calls itself recursively * * @param array $contentTreeArr: DataStructure info array (the whole tree) * @param string $languageKey: Language key for the display * @param string $sheet: The sheet key of the sheet which should be rendered * @param array $parentPointer: Flexform pointer to parent element * @param array $parentDsMeta: Meta array from parent DS (passing information about parent containers localization mode) * @return string HTML * @access protected * @see render_framework_singleSheet() */ function render_framework_singleSheet($contentTreeArr, $languageKey, $sheet, $parentPointer = array(), $parentDsMeta = array()) { global $LANG, $TYPO3_CONF_VARS; $elementBelongsToCurrentPage = FALSE; $pid = $contentTreeArr['el']['table'] == 'pages' ? $contentTreeArr['el']['uid'] : $contentTreeArr['el']['pid']; if ($contentTreeArr['el']['table'] == 'pages' || $contentTreeArr['el']['pid'] == $this->rootElementUid_pidForContent) { $elementBelongsToCurrentPage = TRUE; } else { if ($contentTreeArr['el']['_ORIG_uid']) { $record = t3lib_BEfunc::getMovePlaceholder('tt_content', $contentTreeArr['el']['uid']); if (is_array($record) && $record['t3ver_move_id'] == $contentTreeArr['el']['uid']) { $elementBelongsToCurrentPage = $this->rootElementUid_pidForContent == $record['pid']; $pid = $record['pid']; } } } $calcPerms = $this->getCalcPerms($pid); $canEditElement = $GLOBALS['BE_USER']->isPSet($calcPerms, 'pages', 'editcontent'); $canEditContent = $GLOBALS['BE_USER']->isPSet($this->calcPerms, 'pages', 'editcontent'); $elementClass = 'tpm-container-element'; $elementClass .= ' tpm-container-element-depth-' . $contentTreeArr['depth']; $elementClass .= ' tpm-container-element-depth-' . ($contentTreeArr['depth'] % 2 ? 'odd' : 'even'); // Prepare the record icon including a content sensitive menu link wrapped around it: if (isset($contentTreeArr['el']['iconTag'])) { $recordIcon = $contentTreeArr['el']['iconTag']; } else { $recordIcon = '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, $contentTreeArr['el']['icon'], '') . ' border="0" title="' . htmlspecialchars('[' . $contentTreeArr['el']['table'] . ':' . $contentTreeArr['el']['uid'] . ']') . '" alt="" />'; } $menuCommands = array(); if ($GLOBALS['BE_USER']->isPSet($calcPerms, 'pages', 'new')) { $menuCommands[] = 'new'; } if ($canEditContent) { $menuCommands[] = 'copy,cut,pasteinto,pasteafter,delete'; } else { $menuCommands[] = 'copy'; } $titleBarLeftButtons = $this->translatorMode ? $recordIcon : (count($menuCommands) == 0 ? $recordIcon : $this->doc->wrapClickMenuOnIcon($recordIcon, $contentTreeArr['el']['table'], $contentTreeArr['el']['uid'], 1, '&callingScriptId=' . rawurlencode($this->doc->scriptID), implode(',', $menuCommands))); $titleBarLeftButtons .= $this->getRecordStatHookValue($contentTreeArr['el']['table'], $contentTreeArr['el']['uid']); unset($menuCommands); // Prepare table specific settings: switch ($contentTreeArr['el']['table']) { case 'pages': $elementTitlebarClass = 'tpm-titlebar-page'; $elementClass .= ' pagecontainer'; $titleBarRightButtons = ''; break; case 'tt_content': $elementTitlebarClass = $elementBelongsToCurrentPage ? 'tpm-titlebar' : 'tpm-titlebar-fromOtherPage'; $elementClass .= ' tpm-content-element tpm-ctype-' . $contentTreeArr['el']['CType']; if ($contentTreeArr['el']['isHidden']) { $elementClass .= ' tpm-hidden t3-page-ce-hidden'; } if ($contentTreeArr['el']['CType'] == 'templavoila_pi1') { //fce $elementClass .= ' tpm-fce tpm-fce_' . intval($contentTreeArr['el']['TO']); } $languageUid = $contentTreeArr['el']['sys_language_uid']; $elementPointer = 'tt_content:' . $contentTreeArr['el']['uid']; $linkCopy = $this->clipboardObj->element_getSelectButtons($parentPointer, 'copy,ref'); if (!$this->translatorMode) { if ($canEditContent) { $iconMakeLocal = t3lib_iconWorks::getSpriteIcon('extensions-templavoila-makelocalcopy', array('title' => $LANG->getLL('makeLocal'))); $linkMakeLocal = !$elementBelongsToCurrentPage && !in_array('makeLocal', $this->blindIcons) ? $this->link_makeLocal($iconMakeLocal, $parentPointer) : ''; $linkCut = $this->clipboardObj->element_getSelectButtons($parentPointer, 'cut'); if ($this->modTSconfig['properties']['enableDeleteIconForLocalElements'] < 2 || !$elementBelongsToCurrentPage || $this->global_tt_content_elementRegister[$contentTreeArr['el']['uid']] > 1) { $iconUnlink = t3lib_iconWorks::getSpriteIcon('extensions-templavoila-unlink', array('title' => $LANG->getLL('unlinkRecord'))); $linkUnlink = !in_array('unlink', $this->blindIcons) ? $this->link_unlink($iconUnlink, $parentPointer, FALSE, FALSE, $elementPointer) : ''; } else { $linkUnlink = ''; } } else { $linkMakeLocal = $linkCut = $linkUnlink = ''; } if ($canEditElement && $GLOBALS['BE_USER']->recordEditAccessInternals('tt_content', $contentTreeArr['previewData']['fullRow'])) { if (($elementBelongsToCurrentPage || $this->modTSconfig['properties']['enableEditIconForRefElements']) && !in_array('edit', $this->blindIcons)) { $iconEdit = t3lib_iconWorks::getSpriteIcon('actions-document-open', array('title' => $LANG->getLL('editrecord'))); $linkEdit = $this->link_edit($iconEdit, $contentTreeArr['el']['table'], $contentTreeArr['el']['uid'], false, $contentTreeArr['el']['pid']); } else { $linkEdit = ''; } $linkHide = !in_array('hide', $this->blindIcons) ? $this->icon_hide($contentTreeArr['el']) : ''; if ($canEditContent && $this->modTSconfig['properties']['enableDeleteIconForLocalElements'] && $elementBelongsToCurrentPage) { $hasForeignReferences = tx_templavoila_div::hasElementForeignReferences($contentTreeArr['el'], $contentTreeArr['el']['pid']); $iconDelete = t3lib_iconWorks::getSpriteIcon('actions-edit-delete', array('title' => $LANG->getLL('deleteRecord'))); $linkDelete = !in_array('delete', $this->blindIcons) ? $this->link_unlink($iconDelete, $parentPointer, TRUE, $hasForeignReferences, $elementPointer) : ''; } else { $linkDelete = ''; } } else { $linkDelete = $linkEdit = $linkHide = ''; } $titleBarRightButtons = $linkEdit . $linkHide . $linkCopy . $linkCut . $linkMakeLocal . $linkUnlink . $linkDelete; } else { $titleBarRightButtons = $linkCopy; } break; } // Prepare the language icon: $languageLabel = htmlspecialchars($this->allAvailableLanguages[$contentTreeArr['el']['sys_language_uid']]['title']); if ($this->allAvailableLanguages[$languageUid]['flagIcon']) { $languageIcon = tx_templavoila_icons::getFlagIconForLanguage($this->allAvailableLanguages[$languageUid]['flagIcon'], array('title' => $languageLabel, 'alt' => $languageLabel)); } else { $languageIcon = $languageLabel && $languageUid ? '[' . $languageLabel . ']' : ''; } // If there was a language icon and the language was not default or [all] and if that langauge is accessible for the user, then wrap the flag with an edit link (to support the "Click the flag!" principle for translators) if ($languageIcon && $languageUid > 0 && $GLOBALS['BE_USER']->checkLanguageAccess($languageUid) && $contentTreeArr['el']['table'] === 'tt_content') { $languageIcon = $this->link_edit($languageIcon, 'tt_content', $contentTreeArr['el']['uid'], TRUE, $contentTreeArr['el']['pid'], 'tpm-langIcon'); } elseif ($languageIcon) { $languageIcon = '<span class="tpm-langIcon">' . $languageIcon . '</span>'; } // Create warning messages if neccessary: $warnings = ''; if (!$this->modTSconfig['properties']['disableReferencedElementNotification'] && !$elementBelongsToCurrentPage) { $warnings .= $this->doc->icons(1) . ' <em>' . htmlspecialchars(sprintf($LANG->getLL('info_elementfromotherpage'), $contentTreeArr['el']['uid'], $contentTreeArr['el']['pid'])) . '</em><br />'; } if (!$this->modTSconfig['properties']['disableElementMoreThanOnceWarning'] && $this->global_tt_content_elementRegister[$contentTreeArr['el']['uid']] > 1 && $this->rootElementLangParadigm != 'free') { $warnings .= $this->doc->icons(2) . ' <em>' . htmlspecialchars(sprintf($LANG->getLL('warning_elementusedmorethanonce', ''), $this->global_tt_content_elementRegister[$contentTreeArr['el']['uid']], $contentTreeArr['el']['uid'])) . '</em><br />'; } // Displaying warning for container content (in default sheet - a limitation) elements if localization is enabled: $isContainerEl = count($contentTreeArr['sub']['sDEF']); if (!$this->modTSconfig['properties']['disableContainerElementLocalizationWarning'] && $this->rootElementLangParadigm != 'free' && $isContainerEl && $contentTreeArr['el']['table'] === 'tt_content' && $contentTreeArr['el']['CType'] === 'templavoila_pi1' && !$contentTreeArr['ds_meta']['langDisable']) { if ($contentTreeArr['ds_meta']['langChildren']) { if (!$this->modTSconfig['properties']['disableContainerElementLocalizationWarning_warningOnly']) { $warnings .= $this->doc->icons(2) . ' <em>' . $LANG->getLL('warning_containerInheritance') . '</em><br />'; } } else { $warnings .= $this->doc->icons(3) . ' <em>' . $LANG->getLL('warning_containerSeparate') . '</em><br />'; } } // Preview made: $previewContent = $contentTreeArr['ds_meta']['disableDataPreview'] ? ' ' : $this->render_previewData($contentTreeArr['previewData'], $contentTreeArr['el'], $contentTreeArr['ds_meta'], $languageKey, $sheet); // Wrap workspace notification colors: if ($contentTreeArr['el']['_ORIG_uid']) { $previewContent = '<div class="ver-element">' . ($previewContent ? $previewContent : '<em>[New version]</em>') . '</div>'; } $title = t3lib_div::fixed_lgd_cs($contentTreeArr['el']['fullTitle'], $this->previewTitleMaxLen); // Finally assemble the table: $finalContent = ' <div class="' . $elementClass . '"> <div class="tpm-titlebar t3-page-ce-header ' . $elementTitlebarClass . '"> <div class="t3-row-header"> <div class="tpm-element-control"> ' . $titleBarRightButtons . ' </div> <div class="tpm-element-title">' . $languageIcon . $titleBarLeftButtons . '<div class="nobr sortable_handle">' . ($elementBelongsToCurrentPage ? '' : '<em>') . htmlspecialchars($title) . ($elementBelongsToCurrentPage ? '' : '</em>') . '</div> </div> </div> </div> <div class="tpm-sub-elements">' . ($warnings ? '<div class="tpm-warnings">' . $warnings . '</div>' : '') . $this->render_framework_subElements($contentTreeArr, $languageKey, $sheet, $calcPerms) . '<div class="tpm-preview">' . $previewContent . '</div>' . $this->render_localizationInfoTable($contentTreeArr, $parentPointer, $parentDsMeta) . '</div> </div> '; return $finalContent; }
/** * Performs the neccessary steps to creates a new page * * @param array $pageArray: array containing the fields for the new page * @param integer $positionPid: location within the page tree (parent id) * @return integer uid of the new page record */ function createPage($pageArray,$positionPid) { $positionPageMoveToRow = t3lib_BEfunc::getMovePlaceholder('pages', abs($positionPid)); if (is_array($positionPageMoveToRow)) { $positionPid = ($positionPid > 0 ) ? $positionPageMoveToRow['uid'] : '-' . $positionPageMoveToRow['uid']; } $dataArr = array(); $dataArr['pages']['NEW'] = $pageArray; $dataArr['pages']['NEW']['pid'] = $positionPid; if (is_null($dataArr['pages']['NEW']['hidden'])) { $dataArr['pages']['NEW']['hidden'] = 0; } unset($dataArr['pages']['NEW']['uid']); // If no data structure is set, try to find one by using the template object if ($dataArr['pages']['NEW']['tx_templavoila_to'] && !$dataArr['pages']['NEW']['tx_templavoila_ds']) { $templateObjectRow = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj',$dataArr['pages']['NEW']['tx_templavoila_to'],'uid,pid,datastructure'); $dataArr['pages']['NEW']['tx_templavoila_ds'] = $templateObjectRow['datastructure']; } $tce = t3lib_div::makeInstance('t3lib_TCEmain'); if (is_array($this->TCAdefaultOverride)) { $tce->setDefaultsFromUserTS($this->TCAdefaultOverride); } $tce->stripslashes_values=0; $tce->start($dataArr,array()); $tce->process_datamap(); return $tce->substNEWwithIDs['NEW']; }
/** * Creates a move placeholder for workspaces. * USE ONLY INTERNALLY * Moving placeholder: Can be done because the system sees it as a placeholder for NEW elements like t3ver_state=1 * Moving original: Will either create the placeholder if it doesn't exist or move existing placeholder in workspace. * * @param string $table Table name to move * @param integer $uid Record uid to move (online record) * @param integer $destPid Position to move to: $destPid: >=0 then it points to a page-id on which to insert the record (as the first element). <0 then it points to a uid from its own table after which to insert it (works if * @param integer $wsUid UID of offline version of online record * @param t3lib_TCEmain $tcemainObj TCEmain object * @return void * @see moveRecord() */ protected function moveRecord_wsPlaceholders($table, $uid, $destPid, $wsUid, t3lib_TCEmain $tcemainObj) { global $TCA; if ($plh = t3lib_BEfunc::getMovePlaceholder($table, $uid, 'uid')) { // If already a placeholder exists, move it: $tcemainObj->moveRecord_raw($table, $plh['uid'], $destPid); } else { // First, we create a placeholder record in the Live workspace that // represents the position to where the record is eventually moved to. $newVersion_placeholderFieldArray = array(); if ($TCA[$table]['ctrl']['crdate']) { $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['crdate']] = $GLOBALS['EXEC_TIME']; } if ($TCA[$table]['ctrl']['cruser_id']) { $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['cruser_id']] = $tcemainObj->userid; } if ($TCA[$table]['ctrl']['tstamp']) { $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME']; } if ($table == 'pages') { // Copy page access settings from original page to placeholder $perms_clause = $tcemainObj->BE_USER->getPagePermsClause(1); $access = t3lib_BEfunc::readPageAccess($uid, $perms_clause); $newVersion_placeholderFieldArray['perms_userid'] = $access['perms_userid']; $newVersion_placeholderFieldArray['perms_groupid'] = $access['perms_groupid']; $newVersion_placeholderFieldArray['perms_user'] = $access['perms_user']; $newVersion_placeholderFieldArray['perms_group'] = $access['perms_group']; $newVersion_placeholderFieldArray['perms_everybody'] = $access['perms_everybody']; } $newVersion_placeholderFieldArray['t3ver_label'] = 'MOVE-TO PLACEHOLDER for #' . $uid; $newVersion_placeholderFieldArray['t3ver_move_id'] = $uid; // Setting placeholder state value for temporary record $newVersion_placeholderFieldArray['t3ver_state'] = 3; // Setting workspace - only so display of place holders can filter out those from other workspaces. $newVersion_placeholderFieldArray['t3ver_wsid'] = $tcemainObj->BE_USER->workspace; $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['label']] = '[MOVE-TO PLACEHOLDER for #' . $uid . ', WS#' . $tcemainObj->BE_USER->workspace . ']'; // moving localized records requires to keep localization-settings for the placeholder too if (array_key_exists('languageField', $GLOBALS['TCA'][$table]['ctrl']) && array_key_exists('transOrigPointerField', $GLOBALS['TCA'][$table]['ctrl'])) { $l10nParentRec = t3lib_BEfunc::getRecord($table, $uid); $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['languageField']] = $l10nParentRec[$GLOBALS['TCA'][$table]['ctrl']['languageField']]; $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] = $l10nParentRec[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']]; unset($l10nParentRec); } // Initially, create at root level. $newVersion_placeholderFieldArray['pid'] = 0; $id = 'NEW_MOVE_PLH'; // Saving placeholder as 'original' $tcemainObj->insertDB($table, $id, $newVersion_placeholderFieldArray, FALSE); // Move the new placeholder from temporary root-level to location: $tcemainObj->moveRecord_raw($table, $tcemainObj->substNEWwithIDs[$id], $destPid); // Move the workspace-version of the original to be the version of the move-to-placeholder: // Setting placeholder state value for version (so it can know it is currently a new version...) $updateFields = array('t3ver_state' => 4); $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($wsUid), $updateFields); } // Check for the localizations of that element and move them as well $tcemainObj->moveL10nOverlayRecords($table, $uid, $destPid); }
/** * Release version from this workspace (and into "Live" workspace but as an offline version). * * @param string Table name * @param integer Record UID * @param boolean If set, will completely delete element * @return void */ function version_clearWSID($table, $id, $flush = FALSE) { global $TCA; if ($errorCode = $this->BE_USER->workspaceCannotEditOfflineVersion($table, $id)) { $this->newlog('Attempt to reset workspace for record failed: ' . $errorCode, 1); } elseif ($this->checkRecordUpdateAccess($table, $id)) { if ($liveRec = t3lib_BEfunc::getLiveVersionOfRecord($table, $id, 'uid,t3ver_state')) { // Clear workspace ID: $sArray = array(); $sArray['t3ver_wsid'] = 0; $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($id), $sArray); // Clear workspace ID for live version AND DELETE IT as well because it is a new record! if ((int) $liveRec['t3ver_state'] == 1 || (int) $liveRec['t3ver_state'] == 2) { $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($liveRec['uid']), $sArray); $this->deleteEl($table, $liveRec['uid'], TRUE); // THIS assumes that the record was placeholder ONLY for ONE record (namely $id) } // If "deleted" flag is set for the version that got released it doesn't make sense to keep that "placeholder" anymore and we delete it completly. $wsRec = t3lib_BEfunc::getRecord($table, $id); if ($flush || ((int) $wsRec['t3ver_state'] == 1 || (int) $wsRec['t3ver_state'] == 2)) { $this->deleteEl($table, $id, TRUE, TRUE); } // Remove the move-placeholder if found for live record. if ((int) $TCA[$table]['ctrl']['versioningWS'] >= 2) { if ($plhRec = t3lib_BEfunc::getMovePlaceholder($table, $liveRec['uid'], 'uid')) { $this->deleteEl($table, $plhRec['uid'], TRUE, TRUE); } } } } else { $this->newlog('Attempt to reset workspace for record failed because you do not have edit access', 1); } }