[TASK] Make TYPO3 Core PSR-2 standard compliant

In our efforts to achieve a better interoperability
with other PHP projects, the PHP code base of the
TYPO3 Core switches to the PHP coding guideline
standard PSR-2.

See http://www.php-fig.org/psr/psr-2/ for more
information.

Resolves: #70515
Releases: master
Change-Id: I734c0d838af157003decfeb5fc0a11dddcb87bf5
Reviewed-on: http://review.typo3.org/43918
Reviewed-by: TYPO3 Release Team <typo3cms@typo3.org>
Tested-by: TYPO3 Release Team <typo3cms@typo3.org>
This commit is contained in:
TYPO3 Release Team 2015-10-09 00:08:57 +02:00
parent 12c9393fad
commit 851a5d8262
2 changed files with 295 additions and 290 deletions

View file

@ -28,302 +28,307 @@ use TYPO3\CMS\Frontend\View\AdminPanelView;
/** /**
* View class for the edit panels in frontend editing. * View class for the edit panels in frontend editing.
*/ */
class FrontendEditPanel { class FrontendEditPanel
{
/**
* The Content Object Renderer
*
* @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
*/
protected $cObj;
/** /**
* The Content Object Renderer * Property for accessing TypoScriptFrontendController centrally
* *
* @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer * @var TypoScriptFrontendController
*/ */
protected $cObj; protected $frontendController;
/** /**
* Property for accessing TypoScriptFrontendController centrally * Property for accessing DatabaseConnection centrally
* *
* @var TypoScriptFrontendController * @var DatabaseConnection
*/ */
protected $frontendController; protected $databaseConnection;
/** /**
* Property for accessing DatabaseConnection centrally * @var FrontendBackendUserAuthentication
* */
* @var DatabaseConnection protected $backendUser;
*/
protected $databaseConnection;
/** /**
* @var FrontendBackendUserAuthentication * @var \TYPO3\CMS\Core\Imaging\IconFactory
*/ */
protected $backendUser; protected $iconFactory;
/** /**
* @var \TYPO3\CMS\Core\Imaging\IconFactory * Constructor for the edit panel
*/ *
protected $iconFactory; * @param DatabaseConnection $databaseConnection
* @param TypoScriptFrontendController $frontendController
* @param FrontendBackendUserAuthentication $backendUser
*/
public function __construct(DatabaseConnection $databaseConnection = null, TypoScriptFrontendController $frontendController = null, FrontendBackendUserAuthentication $backendUser = null)
{
$this->databaseConnection = $databaseConnection ?: $GLOBALS['TYPO3_DB'];
$this->frontendController = $frontendController ?: $GLOBALS['TSFE'];
$this->backendUser = $backendUser ?: $GLOBALS['BE_USER'];
$this->cObj = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
$this->cObj->start(array());
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
}
/** /**
* Constructor for the edit panel * Generates the "edit panels" which can be shown for a page or records on a page when the Admin Panel is enabled for a backend users surfing the frontend.
* * With the "edit panel" the user will see buttons with links to editing, moving, hiding, deleting the element
* @param DatabaseConnection $databaseConnection * This function is used for the cObject EDITPANEL and the stdWrap property ".editPanel"
* @param TypoScriptFrontendController $frontendController *
* @param FrontendBackendUserAuthentication $backendUser * @param string $content A content string containing the content related to the edit panel. For cObject "EDITPANEL" this is empty but not so for the stdWrap property. The edit panel is appended to this string and returned.
*/ * @param array $conf TypoScript configuration properties for the editPanel
public function __construct(DatabaseConnection $databaseConnection = NULL, TypoScriptFrontendController $frontendController = NULL, FrontendBackendUserAuthentication $backendUser = NULL) { * @param string $currentRecord The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW
$this->databaseConnection = $databaseConnection ?: $GLOBALS['TYPO3_DB']; * @param array $dataArr Alternative data array to use. Default is $this->data
$this->frontendController = $frontendController ?: $GLOBALS['TSFE']; * @param string $table
$this->backendUser = $backendUser ?: $GLOBALS['BE_USER']; * @param array $allow
$this->cObj = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class); * @param int $newUID
$this->cObj->start(array()); * @param array $hiddenFields
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); * @return string The input content string with the editPanel appended. This function returns only an edit panel appended to the content string if a backend user is logged in (and has the correct permissions). Otherwise the content string is directly returned.
} */
public function editPanel($content, array $conf, $currentRecord = '', array $dataArr = array(), $table = '', array $allow = array(), $newUID = 0, array $hiddenFields = array())
{
$hiddenFieldString = $command = '';
/** // Special content is about to be shown, so the cache must be disabled.
* Generates the "edit panels" which can be shown for a page or records on a page when the Admin Panel is enabled for a backend users surfing the frontend. $this->frontendController->set_no_cache('Frontend edit panel is shown', true);
* With the "edit panel" the user will see buttons with links to editing, moving, hiding, deleting the element
* This function is used for the cObject EDITPANEL and the stdWrap property ".editPanel"
*
* @param string $content A content string containing the content related to the edit panel. For cObject "EDITPANEL" this is empty but not so for the stdWrap property. The edit panel is appended to this string and returned.
* @param array $conf TypoScript configuration properties for the editPanel
* @param string $currentRecord The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW
* @param array $dataArr Alternative data array to use. Default is $this->data
* @param string $table
* @param array $allow
* @param int $newUID
* @param array $hiddenFields
* @return string The input content string with the editPanel appended. This function returns only an edit panel appended to the content string if a backend user is logged in (and has the correct permissions). Otherwise the content string is directly returned.
*/
public function editPanel($content, array $conf, $currentRecord = '', array $dataArr = array(), $table = '', array $allow = array(), $newUID = 0, array $hiddenFields = array()) {
$hiddenFieldString = $command = '';
// Special content is about to be shown, so the cache must be disabled. $formName = 'TSFE_EDIT_FORM_' . substr($this->frontendController->uniqueHash(), 0, 4);
$this->frontendController->set_no_cache('Frontend edit panel is shown', TRUE); $formTag = '<form name="' . $formName . '" id ="' . $formName . '" action="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '" method="post" enctype="multipart/form-data" onsubmit="return TBE_EDITOR.checkSubmit(1);">';
$sortField = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
$labelField = $GLOBALS['TCA'][$table]['ctrl']['label'];
$hideField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
$formName = 'TSFE_EDIT_FORM_' . substr($this->frontendController->uniqueHash(), 0, 4); $panel = '';
$formTag = '<form name="' . $formName . '" id ="' . $formName . '" action="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '" method="post" enctype="multipart/form-data" onsubmit="return TBE_EDITOR.checkSubmit(1);">'; if (isset($allow['toolbar']) && $this->backendUser->adminPanel instanceof AdminPanelView) {
$sortField = $GLOBALS['TCA'][$table]['ctrl']['sortby']; $panel .= $this->backendUser->adminPanel->ext_makeToolBar();
$labelField = $GLOBALS['TCA'][$table]['ctrl']['label']; }
$hideField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']; if (isset($allow['edit'])) {
$icon = '<span title="' . htmlspecialchars($this->backendUser->extGetLL('p_editRecord')) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'edit', $dataArr['_LOCALIZED_UID'] ? $table . ':' . $dataArr['_LOCALIZED_UID'] : $currentRecord);
}
// Hiding in workspaces because implementation is incomplete
if (isset($allow['move']) && $sortField && $this->backendUser->workspace === 0) {
$icon = '<span title="' . htmlspecialchars($this->backendUser->extGetLL('p_moveUp')) . '">' . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'up');
$icon = '<span title="' . htmlspecialchars($this->backendUser->extGetLL('p_moveDown')) . '">' . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'down');
}
// Hiding in workspaces because implementation is incomplete
// Hiding for localizations because it is unknown what should be the function in that case
if (isset($allow['hide']) && $hideField && $this->backendUser->workspace === 0 && !$dataArr['_LOCALIZED_UID']) {
if ($dataArr[$hideField]) {
$icon = $this->iconFactory->getIcon('actions-edit-unhide')->render();
$panel .= $this->editPanelLinkWrap($icon, $formName, 'unhide');
} else {
$icon = $this->iconFactory->getIcon('actions-edit-hide')->render();
$panel .= $this->editPanelLinkWrap($icon, $formName, 'hide', '', $this->backendUser->extGetLL('p_hideConfirm'));
}
}
if (isset($allow['new'])) {
if ($table === 'pages') {
$icon = '<span title="' . htmlspecialchars($this->backendUser->extGetLL('p_newSubpage')) . '">'
. $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)->render()
. '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'new', $currentRecord, '');
} else {
$icon = '<span title="' . htmlspecialchars($this->backendUser->extGetLL('p_newRecordAfter')) . '">'
. $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render()
. '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'new', $currentRecord, '', $newUID);
}
}
// Hiding in workspaces because implementation is incomplete
// Hiding for localizations because it is unknown what should be the function in that case
if (isset($allow['delete']) && $this->backendUser->workspace === 0 && !$dataArr['_LOCALIZED_UID']) {
$icon = '<span title="' . htmlspecialchars($this->backendUser->extGetLL('p_delete')) . '">'
. $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render()
. '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'delete', '', $this->backendUser->extGetLL('p_deleteConfirm'));
}
// Final
$labelTxt = $this->cObj->stdWrap($conf['label'], $conf['label.']);
foreach ((array)$hiddenFields as $name => $value) {
$hiddenFieldString .= '<input type="hidden" name="TSFE_EDIT[' . htmlspecialchars($name) . ']" value="' . htmlspecialchars($value) . '"/>' . LF;
}
$panel = ''; $panel = '<!-- BE_USER Edit Panel: -->
if (isset($allow['toolbar']) && $this->backendUser->adminPanel instanceof AdminPanelView) {
$panel .= $this->backendUser->adminPanel->ext_makeToolBar();
}
if (isset($allow['edit'])) {
$icon = '<span title="' . htmlspecialchars($this->backendUser->extGetLL('p_editRecord')) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'edit', $dataArr['_LOCALIZED_UID'] ? $table . ':' . $dataArr['_LOCALIZED_UID'] : $currentRecord);
}
// Hiding in workspaces because implementation is incomplete
if (isset($allow['move']) && $sortField && $this->backendUser->workspace === 0) {
$icon = '<span title="' . htmlspecialchars($this->backendUser->extGetLL('p_moveUp')) . '">' . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'up');
$icon = '<span title="' . htmlspecialchars($this->backendUser->extGetLL('p_moveDown')) . '">' . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'down');
}
// Hiding in workspaces because implementation is incomplete
// Hiding for localizations because it is unknown what should be the function in that case
if (isset($allow['hide']) && $hideField && $this->backendUser->workspace === 0 && !$dataArr['_LOCALIZED_UID']) {
if ($dataArr[$hideField]) {
$icon = $this->iconFactory->getIcon('actions-edit-unhide')->render();
$panel .= $this->editPanelLinkWrap($icon, $formName, 'unhide');
} else {
$icon = $this->iconFactory->getIcon('actions-edit-hide')->render();
$panel .= $this->editPanelLinkWrap($icon, $formName, 'hide', '', $this->backendUser->extGetLL('p_hideConfirm'));
}
}
if (isset($allow['new'])) {
if ($table === 'pages') {
$icon = '<span title="' . htmlspecialchars($this->backendUser->extGetLL('p_newSubpage')) . '">'
. $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)->render()
. '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'new', $currentRecord, '');
} else {
$icon = '<span title="' . htmlspecialchars($this->backendUser->extGetLL('p_newRecordAfter')) . '">'
. $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render()
. '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'new', $currentRecord, '', $newUID);
}
}
// Hiding in workspaces because implementation is incomplete
// Hiding for localizations because it is unknown what should be the function in that case
if (isset($allow['delete']) && $this->backendUser->workspace === 0 && !$dataArr['_LOCALIZED_UID']) {
$icon = '<span title="' . htmlspecialchars($this->backendUser->extGetLL('p_delete')) . '">'
. $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render()
. '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'delete', '', $this->backendUser->extGetLL('p_deleteConfirm'));
}
// Final
$labelTxt = $this->cObj->stdWrap($conf['label'], $conf['label.']);
foreach ((array)$hiddenFields as $name => $value) {
$hiddenFieldString .= '<input type="hidden" name="TSFE_EDIT[' . htmlspecialchars($name) . ']" value="' . htmlspecialchars($value) . '"/>' . LF;
}
$panel = '<!-- BE_USER Edit Panel: -->
' . $formTag . $hiddenFieldString . ' ' . $formTag . $hiddenFieldString . '
<input type="hidden" name="TSFE_EDIT[cmd]" value="" /> <input type="hidden" name="TSFE_EDIT[cmd]" value="" />
<input type="hidden" name="TSFE_EDIT[record]" value="' . $currentRecord . '" /> <input type="hidden" name="TSFE_EDIT[record]" value="' . $currentRecord . '" />
<div class="typo3-editPanel">' <div class="typo3-editPanel">'
. $panel . . $panel .
($labelTxt ? '<div class="typo3-editPanel-label">' . sprintf($labelTxt, htmlspecialchars(GeneralUtility::fixed_lgd_cs($dataArr[$labelField], 50))) . '</div>' : '') . ' ($labelTxt ? '<div class="typo3-editPanel-label">' . sprintf($labelTxt, htmlspecialchars(GeneralUtility::fixed_lgd_cs($dataArr[$labelField], 50))) . '</div>' : '') . '
</div> </div>
</form>'; </form>';
// Wrap the panel // Wrap the panel
if ($conf['innerWrap']) { if ($conf['innerWrap']) {
$panel = $this->cObj->wrap($panel, $conf['innerWrap']); $panel = $this->cObj->wrap($panel, $conf['innerWrap']);
} }
if ($conf['innerWrap.']) { if ($conf['innerWrap.']) {
$panel = $this->cObj->stdWrap($panel, $conf['innerWrap.']); $panel = $this->cObj->stdWrap($panel, $conf['innerWrap.']);
} }
// Wrap the complete panel // Wrap the complete panel
if ($conf['outerWrap']) { if ($conf['outerWrap']) {
$panel = $this->cObj->wrap($panel, $conf['outerWrap']); $panel = $this->cObj->wrap($panel, $conf['outerWrap']);
} }
if ($conf['outerWrap.']) { if ($conf['outerWrap.']) {
$panel = $this->cObj->stdWrap($panel, $conf['outerWrap.']); $panel = $this->cObj->stdWrap($panel, $conf['outerWrap.']);
} }
if ($conf['printBeforeContent']) { if ($conf['printBeforeContent']) {
$finalOut = $panel . $content; $finalOut = $panel . $content;
} else { } else {
$finalOut = $content . $panel; $finalOut = $content . $panel;
} }
$hidden = $this->isDisabled($table, $dataArr) ? ' typo3-feedit-element-hidden' : ''; $hidden = $this->isDisabled($table, $dataArr) ? ' typo3-feedit-element-hidden' : '';
$outerWrapConfig = isset($conf['stdWrap.']) $outerWrapConfig = isset($conf['stdWrap.'])
? $conf['stdWrap.'] ? $conf['stdWrap.']
: array('wrap' => '<div class="typo3-feedit-element' . $hidden . '">|</div>'); : array('wrap' => '<div class="typo3-feedit-element' . $hidden . '">|</div>');
$finalOut = $this->cObj->stdWrap($finalOut, $outerWrapConfig); $finalOut = $this->cObj->stdWrap($finalOut, $outerWrapConfig);
return $finalOut; return $finalOut;
} }
/** /**
* Adds an edit icon to the content string. The edit icon links to EditDocumentController with proper parameters for editing the table/fields of the context. * Adds an edit icon to the content string. The edit icon links to EditDocumentController with proper parameters for editing the table/fields of the context.
* This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well). * This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well).
* *
* @param string $content The content to which the edit icons should be appended * @param string $content The content to which the edit icons should be appended
* @param string $params The parameters defining which table and fields to edit. Syntax is [tablename]:[fieldname],[fieldname],[fieldname],... OR [fieldname],[fieldname],[fieldname],... (basically "[tablename]:" is optional, default table is the one of the "current record" used in the function). The fieldlist is sent as "&columnsOnly=" parameter to EditDocumentController * @param string $params The parameters defining which table and fields to edit. Syntax is [tablename]:[fieldname],[fieldname],[fieldname],... OR [fieldname],[fieldname],[fieldname],... (basically "[tablename]:" is optional, default table is the one of the "current record" used in the function). The fieldlist is sent as "&columnsOnly=" parameter to EditDocumentController
* @param array $conf TypoScript properties for configuring the edit icons. * @param array $conf TypoScript properties for configuring the edit icons.
* @param string $currentRecord The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW * @param string $currentRecord The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW
* @param array $dataArr Alternative data array to use. Default is $this->data * @param array $dataArr Alternative data array to use. Default is $this->data
* @param string $addUrlParamStr Additional URL parameters for the link pointing to EditDocumentController * @param string $addUrlParamStr Additional URL parameters for the link pointing to EditDocumentController
* @param string $table * @param string $table
* @param int $editUid * @param int $editUid
* @param string $fieldList * @param string $fieldList
* @return string The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content. * @return string The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content.
*/ */
public function editIcons($content, $params, array $conf = array(), $currentRecord = '', array $dataArr = array(), $addUrlParamStr = '', $table, $editUid, $fieldList) { public function editIcons($content, $params, array $conf = array(), $currentRecord = '', array $dataArr = array(), $addUrlParamStr = '', $table, $editUid, $fieldList)
// Special content is about to be shown, so the cache must be disabled. {
$this->frontendController->set_no_cache('Display frontend edit icons', TRUE); // Special content is about to be shown, so the cache must be disabled.
$iconTitle = $this->cObj->stdWrap($conf['iconTitle'], $conf['iconTitle.']); $this->frontendController->set_no_cache('Display frontend edit icons', true);
$iconImg = '<span title="' . htmlspecialchars($iconTitle, ENT_COMPAT, 'UTF-8', FALSE) . '" class="frontEndEditIcons" style="' . ($conf['styleAttribute'] ? htmlspecialchars($conf['styleAttribute']) : '') . '">' $iconTitle = $this->cObj->stdWrap($conf['iconTitle'], $conf['iconTitle.']);
. $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() $iconImg = '<span title="' . htmlspecialchars($iconTitle, ENT_COMPAT, 'UTF-8', false) . '" class="frontEndEditIcons" style="' . ($conf['styleAttribute'] ? htmlspecialchars($conf['styleAttribute']) : '') . '">'
. '</span>'; . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render()
$nV = GeneralUtility::_GP('ADMCMD_view') ? 1 : 0; . '</span>';
$nV = GeneralUtility::_GP('ADMCMD_view') ? 1 : 0;
$url = BackendUtility::getModuleUrl( $url = BackendUtility::getModuleUrl(
'record_edit', 'record_edit',
array( array(
'edit[' . $table . '][' . $editUid . ']' => 'edit', 'edit[' . $table . '][' . $editUid . ']' => 'edit',
'columnsOnly' => $fieldList, 'columnsOnly' => $fieldList,
'noView' => $nV 'noView' => $nV
) )
) . $addUrlParamStr; ) . $addUrlParamStr;
$icon = $this->editPanelLinkWrap_doWrap($iconImg, $url); $icon = $this->editPanelLinkWrap_doWrap($iconImg, $url);
if ($conf['beforeLastTag'] < 0) { if ($conf['beforeLastTag'] < 0) {
$content = $icon . $content; $content = $icon . $content;
} elseif ($conf['beforeLastTag'] > 0) { } elseif ($conf['beforeLastTag'] > 0) {
$cBuf = rtrim($content); $cBuf = rtrim($content);
$secureCount = 30; $secureCount = 30;
while ($secureCount && substr($cBuf, -1) == '>' && substr($cBuf, -4) != '</a>') { while ($secureCount && substr($cBuf, -1) == '>' && substr($cBuf, -4) != '</a>') {
$cBuf = rtrim(preg_replace('/<[^<]*>$/', '', $cBuf)); $cBuf = rtrim(preg_replace('/<[^<]*>$/', '', $cBuf));
$secureCount--; $secureCount--;
} }
$content = strlen($cBuf) && $secureCount ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : ($content = $icon . $content); $content = strlen($cBuf) && $secureCount ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : ($content = $icon . $content);
} else { } else {
$content .= $icon; $content .= $icon;
} }
return $content; return $content;
} }
/** /**
* Helper function for editPanel() which wraps icons in the panel in a link with the action of the panel. * Helper function for editPanel() which wraps icons in the panel in a link with the action of the panel.
* The links are for some of them not simple hyperlinks but onclick-actions which submits a little form which the panel is wrapped in. * The links are for some of them not simple hyperlinks but onclick-actions which submits a little form which the panel is wrapped in.
* *
* @param string $string The string to wrap in a link, typ. and image used as button in the edit panel. * @param string $string The string to wrap in a link, typ. and image used as button in the edit panel.
* @param string $formName The name of the form wrapping the edit panel. * @param string $formName The name of the form wrapping the edit panel.
* @param string $cmd The command of the link. There is a predefined list available: edit, new, up, down etc. * @param string $cmd The command of the link. There is a predefined list available: edit, new, up, down etc.
* @param string $currentRecord The "table:uid" of the record being processed by the panel. * @param string $currentRecord The "table:uid" of the record being processed by the panel.
* @param string $confirm Text string with confirmation message; If set a confirm box will be displayed before carrying out the action (if Yes is pressed) * @param string $confirm Text string with confirmation message; If set a confirm box will be displayed before carrying out the action (if Yes is pressed)
* @param int|string $nPid "New pid" - for new records * @param int|string $nPid "New pid" - for new records
* @return string A <a> tag wrapped string. * @return string A <a> tag wrapped string.
*/ */
protected function editPanelLinkWrap($string, $formName, $cmd, $currentRecord = '', $confirm = '', $nPid = '') { protected function editPanelLinkWrap($string, $formName, $cmd, $currentRecord = '', $confirm = '', $nPid = '')
$nV = GeneralUtility::_GP('ADMCMD_view') ? 1 : 0; {
if ($cmd == 'edit') { $nV = GeneralUtility::_GP('ADMCMD_view') ? 1 : 0;
$rParts = explode(':', $currentRecord); if ($cmd == 'edit') {
$out = $this->editPanelLinkWrap_doWrap($string, BackendUtility::getModuleUrl('record_edit', array('edit[' . $rParts[0] . '][' . $rParts[1] . ']' => 'edit', 'noView=' . $nV)), $currentRecord); $rParts = explode(':', $currentRecord);
} elseif ($cmd == 'new') { $out = $this->editPanelLinkWrap_doWrap($string, BackendUtility::getModuleUrl('record_edit', array('edit[' . $rParts[0] . '][' . $rParts[1] . ']' => 'edit', 'noView=' . $nV)), $currentRecord);
$rParts = explode(':', $currentRecord); } elseif ($cmd == 'new') {
if ($rParts[0] == 'pages') { $rParts = explode(':', $currentRecord);
$out = $this->editPanelLinkWrap_doWrap($string, BackendUtility::getModuleUrl('db_new', ['id' => $rParts[1], 'pagesOnly' => 1]), $currentRecord); if ($rParts[0] == 'pages') {
} else { $out = $this->editPanelLinkWrap_doWrap($string, BackendUtility::getModuleUrl('db_new', ['id' => $rParts[1], 'pagesOnly' => 1]), $currentRecord);
if (!(int)$nPid) { } else {
$nPid = MathUtility::canBeInterpretedAsInteger($rParts[1]) ? -$rParts[1] : $this->frontendController->id; if (!(int)$nPid) {
} $nPid = MathUtility::canBeInterpretedAsInteger($rParts[1]) ? -$rParts[1] : $this->frontendController->id;
$out = $this->editPanelLinkWrap_doWrap($string, BackendUtility::getModuleUrl('record_edit', array('edit[' . $rParts[0] . '][' . $nPid . ']' => 'new', 'noView' => $nV)), $currentRecord); }
} $out = $this->editPanelLinkWrap_doWrap($string, BackendUtility::getModuleUrl('record_edit', array('edit[' . $rParts[0] . '][' . $nPid . ']' => 'new', 'noView' => $nV)), $currentRecord);
} else { }
if ($confirm && $this->backendUser->jsConfirmation(JsConfirmation::FE_EDIT)) { } else {
// Gets htmlspecialchared later if ($confirm && $this->backendUser->jsConfirmation(JsConfirmation::FE_EDIT)) {
$cf1 = 'if (confirm(' . GeneralUtility::quoteJSvalue($confirm, TRUE) . ')) {'; // Gets htmlspecialchared later
$cf2 = '}'; $cf1 = 'if (confirm(' . GeneralUtility::quoteJSvalue($confirm, true) . ')) {';
} else { $cf2 = '}';
$cf1 = ($cf2 = ''); } else {
} $cf1 = ($cf2 = '');
$out = '<a href="#" onclick="' . htmlspecialchars(($cf1 . 'document.' . $formName . '[\'TSFE_EDIT[cmd]\'].value=\'' . $cmd . '\'; document.' . $formName . '.submit();' . $cf2 . ' return false;')) . '">' . $string . '</a>'; }
} $out = '<a href="#" onclick="' . htmlspecialchars(($cf1 . 'document.' . $formName . '[\'TSFE_EDIT[cmd]\'].value=\'' . $cmd . '\'; document.' . $formName . '.submit();' . $cf2 . ' return false;')) . '">' . $string . '</a>';
return $out; }
} return $out;
}
/** /**
* Creates a link to a script (eg. EditDocumentController or NewRecordController) which either opens in the current frame OR in a pop-up window. * Creates a link to a script (eg. EditDocumentController or NewRecordController) which either opens in the current frame OR in a pop-up window.
* *
* @param string $string The string to wrap in a link, typ. and image used as button in the edit panel. * @param string $string The string to wrap in a link, typ. and image used as button in the edit panel.
* @param string $url The URL of the link. Should be absolute if supposed to work with <base> path set. * @param string $url The URL of the link. Should be absolute if supposed to work with <base> path set.
* @return string A <a> tag wrapped string. * @return string A <a> tag wrapped string.
* @see editPanelLinkWrap() * @see editPanelLinkWrap()
*/ */
protected function editPanelLinkWrap_doWrap($string, $url) { protected function editPanelLinkWrap_doWrap($string, $url)
$onclick = 'vHWin=window.open(' . GeneralUtility::quoteJSvalue($url . '&returnUrl=sysext/backend/Resources/Private/Templates/Close.html') . ',\'FEquickEditWindow\',\'width=690,height=500,status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;'; {
return '<a href="#" onclick="' . htmlspecialchars($onclick) . '" class="frontEndEditIconLinks">' . $string . '</a>'; $onclick = 'vHWin=window.open(' . GeneralUtility::quoteJSvalue($url . '&returnUrl=sysext/backend/Resources/Private/Templates/Close.html') . ',\'FEquickEditWindow\',\'width=690,height=500,status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;';
} return '<a href="#" onclick="' . htmlspecialchars($onclick) . '" class="frontEndEditIconLinks">' . $string . '</a>';
}
/** /**
* Returns TRUE if the input table/row would be hidden in the frontend, according to the current time and simulate user group * Returns TRUE if the input table/row would be hidden in the frontend, according to the current time and simulate user group
* *
* @param string $table The table name * @param string $table The table name
* @param array $row The data record * @param array $row The data record
* @return bool * @return bool
*/ */
protected function isDisabled($table, array $row) { protected function isDisabled($table, array $row)
$status = FALSE; {
if ( $status = false;
$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'] && if (
$row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']] || $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'] &&
$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['fe_group'] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']] ||
$this->frontendController->simUserGroup && $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['fe_group'] &&
$row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['fe_group']] == $this->frontendController->simUserGroup || $this->frontendController->simUserGroup &&
$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime'] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['fe_group']] == $this->frontendController->simUserGroup ||
$row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime']] > $GLOBALS['EXEC_TIME'] || $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime'] &&
$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime'] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime']] > $GLOBALS['EXEC_TIME'] ||
$row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] && $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime'] &&
$row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] < $GLOBALS['EXEC_TIME'] $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] &&
) { $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] < $GLOBALS['EXEC_TIME']
$status = TRUE; ) {
} $status = true;
}
return $status;
}
return $status;
}
} }

View file

@ -1,21 +1,21 @@
<?php <?php
$EM_CONF[$_EXTKEY] = array( $EM_CONF[$_EXTKEY] = array(
'title' => 'Frontend Editing', 'title' => 'Frontend Editing',
'description' => '', 'description' => '',
'category' => 'fe', 'category' => 'fe',
'author' => 'Jeff Segars, David Slayback', 'author' => 'Jeff Segars, David Slayback',
'author_email' => 'jeff@webempoweredchurch.org, dave@webempoweredchurch.org', 'author_email' => 'jeff@webempoweredchurch.org, dave@webempoweredchurch.org',
'author_company' => 'Web-Empowered Church', 'author_company' => 'Web-Empowered Church',
'state' => 'stable', 'state' => 'stable',
'uploadfolder' => 0, 'uploadfolder' => 0,
'createDirs' => '', 'createDirs' => '',
'clearCacheOnLoad' => 0, 'clearCacheOnLoad' => 0,
'version' => '7.6.0', 'version' => '7.6.0',
'constraints' => array( 'constraints' => array(
'depends' => array( 'depends' => array(
'typo3' => '7.6.0-7.6.99', 'typo3' => '7.6.0-7.6.99',
), ),
'conflicts' => array(), 'conflicts' => array(),
'suggests' => array(), 'suggests' => array(),
), ),
); );