Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_news
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_news
Commits
d0cd79a7
Commit
d0cd79a7
authored
8 years ago
by
Fabian Galinski
Browse files
Options
Downloads
Patches
Plain Diff
[FEATURE] Implements a language feature, which should be respected in extbase
parent
a69bff8e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Xclass/Typo3DbBackend.php
+157
-0
157 additions, 0 deletions
Classes/Xclass/Typo3DbBackend.php
ext_localconf.php
+2
-0
2 additions, 0 deletions
ext_localconf.php
with
159 additions
and
0 deletions
Classes/Xclass/Typo3DbBackend.php
0 → 100755
+
157
−
0
View file @
d0cd79a7
<?php
namespace
SGalinski\SgNews\Xclass
;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use
TYPO3\CMS\Backend\Utility\BackendUtility
;
use
TYPO3\CMS\Extbase\Persistence\Generic\Qom
;
/**
* Xclass for the TYPO3 db backend, which handles, that the l18n_cfg parameters are used for pages in Extbase.
*/
class
Typo3DbBackend
extends
\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend
{
/**
* Performs workspace and language overlay on the given row array. The language and workspace id is automatically
* detected (depending on FE or BE context). You can also explicitly set the language/workspace id.
*
* @param Qom\SourceInterface $source The source (selector od join)
* @param array $rows
* @param \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings The TYPO3 CMS specific query settings
* @param null|int $workspaceUid
* @return array
*/
protected
function
doLanguageAndWorkspaceOverlay
(
Qom
\SourceInterface
$source
,
array
$rows
,
\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface
$querySettings
,
$workspaceUid
=
null
)
{
if
(
$source
instanceof
Qom\SelectorInterface
)
{
$tableName
=
$source
->
getSelectorName
();
}
elseif
(
$source
instanceof
Qom\JoinInterface
)
{
$tableName
=
$source
->
getRight
()
->
getSelectorName
();
}
else
{
// No proper source, so we do not have a table name here
// we cannot do an overlay and return the original rows instead.
return
$rows
;
}
$pageRepository
=
$this
->
getPageRepository
();
if
(
is_object
(
$GLOBALS
[
'TSFE'
]))
{
if
(
$workspaceUid
!==
null
)
{
$pageRepository
->
versioningWorkspaceId
=
$workspaceUid
;
}
}
else
{
if
(
$workspaceUid
===
null
)
{
$workspaceUid
=
$GLOBALS
[
'BE_USER'
]
->
workspace
;
}
$pageRepository
->
versioningWorkspaceId
=
$workspaceUid
;
}
// Fetches the move-placeholder in case it is supported
// by the table and if there's only one row in the result set
// (applying this to all rows does not work, since the sorting
// order would be destroyed and possible limits not met anymore)
if
(
!
empty
(
$pageRepository
->
versioningWorkspaceId
)
&&
BackendUtility
::
isTableWorkspaceEnabled
(
$tableName
)
&&
count
(
$rows
)
===
1
)
{
$movePlaceholder
=
$this
->
databaseHandle
->
exec_SELECTgetSingleRow
(
$tableName
.
'.*'
,
$tableName
,
't3ver_state=3 AND t3ver_wsid='
.
$pageRepository
->
versioningWorkspaceId
.
' AND t3ver_move_id='
.
$rows
[
0
][
'uid'
]
);
if
(
!
empty
(
$movePlaceholder
))
{
$rows
=
array
(
$movePlaceholder
);
}
}
$overlaidRows
=
array
();
foreach
(
$rows
as
$row
)
{
// If current row is a translation select its parent
if
(
isset
(
$tableName
)
&&
isset
(
$GLOBALS
[
'TCA'
][
$tableName
])
&&
isset
(
$GLOBALS
[
'TCA'
][
$tableName
][
'ctrl'
][
'languageField'
])
&&
isset
(
$GLOBALS
[
'TCA'
][
$tableName
][
'ctrl'
][
'transOrigPointerField'
])
&&
!
isset
(
$GLOBALS
[
'TCA'
][
$tableName
][
'ctrl'
][
'transOrigPointerTable'
])
)
{
if
(
isset
(
$row
[
$GLOBALS
[
'TCA'
][
$tableName
][
'ctrl'
][
'transOrigPointerField'
]])
&&
$row
[
$GLOBALS
[
'TCA'
][
$tableName
][
'ctrl'
][
'transOrigPointerField'
]]
>
0
)
{
$row
=
$this
->
databaseHandle
->
exec_SELECTgetSingleRow
(
$tableName
.
'.*'
,
$tableName
,
$tableName
.
'.uid='
.
(
int
)
$row
[
$GLOBALS
[
'TCA'
][
$tableName
][
'ctrl'
][
'transOrigPointerField'
]]
.
' AND '
.
$tableName
.
'.'
.
$GLOBALS
[
'TCA'
][
$tableName
][
'ctrl'
][
'languageField'
]
.
'=0'
);
}
}
$pageRepository
->
versionOL
(
$tableName
,
$row
,
true
);
if
(
$tableName
==
'pages'
)
{
$row
=
$pageRepository
->
getPageOverlay
(
$row
,
$querySettings
->
getLanguageUid
());
if
(
$row
===
null
||
!
is_array
(
$row
))
{
continue
;
}
$l18nConfiguration
=
$row
[
'l18n_cfg'
];
if
(
$l18nConfiguration
>
0
)
{
if
(
is_object
(
$GLOBALS
[
'TSFE'
]))
{
$sysLanguageUid
=
$GLOBALS
[
'TSFE'
]
->
sys_language_uid
;
if
(
$sysLanguageUid
>
0
)
{
// Request the overlay record for the sys_language_uid:
$pageOverlay
=
$pageRepository
->
getPageOverlay
(
$row
[
'uid'
],
$sysLanguageUid
);
if
(
empty
(
$pageOverlay
)
&&
\TYPO3\CMS\Core\Utility\GeneralUtility
::
hideIfNotTranslated
(
$l18nConfiguration
)
)
{
// Page is not available in default language.
continue
;
}
}
if
(
!
$sysLanguageUid
&&
\TYPO3\CMS\Core\Utility\GeneralUtility
::
hideIfDefaultLanguage
(
$l18nConfiguration
)
)
{
// Page is not available in default language.
continue
;
}
}
}
}
elseif
(
isset
(
$GLOBALS
[
'TCA'
][
$tableName
][
'ctrl'
][
'languageField'
])
&&
$GLOBALS
[
'TCA'
][
$tableName
][
'ctrl'
][
'languageField'
]
!==
''
&&
!
isset
(
$GLOBALS
[
'TCA'
][
$tableName
][
'ctrl'
][
'transOrigPointerTable'
])
)
{
if
(
in_array
(
$row
[
$GLOBALS
[
'TCA'
][
$tableName
][
'ctrl'
][
'languageField'
]],
array
(
-
1
,
0
)))
{
$overlayMode
=
$querySettings
->
getLanguageOverlayMode
();
if
(
$overlayMode
!==
'hideNonTranslated'
||
preg_match
(
'/sys_file_.*/is'
,
$tableName
))
{
$overlayMode
=
$querySettings
->
getLanguageMode
()
===
'strict'
?
'hideNonTranslated'
:
''
;
}
$row
=
$pageRepository
->
getRecordOverlay
(
$tableName
,
$row
,
$querySettings
->
getLanguageUid
(),
$overlayMode
);
}
}
if
(
$row
!==
null
&&
is_array
(
$row
))
{
$overlaidRows
[]
=
$row
;
}
}
return
$overlaidRows
;
}
}
?>
This diff is collapsed.
Click to expand it.
ext_localconf.php
+
2
−
0
View file @
d0cd79a7
...
...
@@ -70,6 +70,8 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['proc
// Xclasses
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'SYS'
][
'Objects'
][
'TYPO3\CMS\Core\Page\PageRenderer'
]
=
[
'className'
=>
'SGalinski\SgNews\Xclass\PageRenderer'
];
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'SYS'
][
'Objects'
][
'TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend'
]
=
[
'className'
=>
'SGalinski\SgNews\Xclass\Typo3DbBackend'
];
// add realurl configuration
if
(
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::
isLoaded
(
'realurl'
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment