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
730704ad
Commit
730704ad
authored
7 years ago
by
Torsten Oppermann
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Adding service function to read all categories for a siteroot id
parent
3149f056
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Feature be module
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Controller/BackendController.php
+4
-1
4 additions, 1 deletion
Classes/Controller/BackendController.php
Classes/Service/Backend/Utility.php
+49
-0
49 additions, 0 deletions
Classes/Service/Backend/Utility.php
with
53 additions
and
1 deletion
Classes/Controller/BackendController.php
+
4
−
1
View file @
730704ad
...
...
@@ -70,10 +70,13 @@ class BackendController extends ActionController {
$backendUser
=
$GLOBALS
[
'BE_USER'
];
$pageInfo
=
BackendUtility
::
readPageAccess
(
$pageUid
,
$backendUser
->
getPagePermsClause
(
1
));
$this
->
docHeaderComponent
=
GeneralUtility
::
makeInstance
(
DocHeaderComponent
::
class
);
$this
->
docHeaderComponent
->
setMetaInformation
(
$pageInfo
);
Utility
::
makeButtons
(
$this
->
docHeaderComponent
,
$this
->
request
);
// retrieve next site root id
$siteRootId
=
Utility
::
getSiteRoot
((
int
)
GeneralUtility
::
_GP
(
'id'
));
Utility
::
getCategoriesForSiteRoot
(
$siteRootId
);
$this
->
view
->
assign
(
'docHeader'
,
$this
->
docHeaderComponent
->
docHeaderContent
());
$this
->
view
->
assign
(
'pageUid'
,
$pageUid
);
}
...
...
This diff is collapsed.
Click to expand it.
Classes/Service/Backend/Utility.php
+
49
−
0
View file @
730704ad
...
...
@@ -28,6 +28,9 @@ namespace SGalinski\SgNews\Service\Backend;
use
TYPO3\CMS\Backend\Template\Components\ButtonBar
;
use
TYPO3\CMS\Backend\Template\Components\DocHeaderComponent
;
use
TYPO3\CMS\Backend\Utility\BackendUtility
;
use
TYPO3\CMS\Core\Database\DatabaseConnection
;
use
TYPO3\CMS\Core\Database\QueryGenerator
;
use
TYPO3\CMS\Core\Imaging\Icon
;
use
TYPO3\CMS\Core\Imaging\IconFactory
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
...
...
@@ -38,6 +41,7 @@ use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
* Class Utility
*/
class
Utility
{
const
CATEGORY_DOKTYPE
=
117
;
/**
* create buttons for the backend module header
...
...
@@ -75,4 +79,49 @@ class Utility {
$buttonBar
->
addButton
(
$shortcutButton
,
ButtonBar
::
BUTTON_POSITION_RIGHT
);
$docHeaderComponent
->
getButtonBar
();
}
/**
* Retrieves the next site root in the page hierarchy from the current page
*
* @param int $currentPid
* @return int
*/
public
static
function
getSiteRoot
(
$currentPid
)
{
$rootLine
=
BackendUtility
::
BEgetRootLine
((
int
)
$currentPid
);
$siteRoot
=
[
'uid'
=>
0
];
foreach
(
$rootLine
as
$page
)
{
if
(
$page
[
'is_siteroot'
]
===
'1'
)
{
$siteRoot
=
$page
;
break
;
}
}
return
$siteRoot
[
'uid'
];
}
/**
* Get an array of all category titles below the given site root id
*
* @param $siteRootPid
* @throws \InvalidArgumentException
* @return array
*/
public
static
function
getCategoriesForSiteRoot
(
$siteRootPid
)
{
// get all pageids below the given siteroot
$queryGenerator
=
GeneralUtility
::
makeInstance
(
QueryGenerator
::
class
);
$childPids
=
$queryGenerator
->
getTreeList
(
$siteRootPid
,
PHP_INT_MAX
,
0
,
1
);
// if doktype = 117 (category) then get the category name (page title)
/** @var DatabaseConnection $databaseConnection */
$databaseConnection
=
$GLOBALS
[
'TYPO3_DB'
];
$where
=
'doktype = '
.
self
::
CATEGORY_DOKTYPE
.
' AND uid in ('
.
$childPids
.
')'
;
$result
=
$databaseConnection
->
exec_SELECTquery
(
'title'
,
'pages'
,
$where
)
->
fetch_all
();
$categories
=
[];
foreach
(
$result
as
$item
)
{
$categories
[]
=
$item
[
0
];
}
return
$categories
;
}
}
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