Skip to content
Snippets Groups Projects
Commit eda0763a authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Implementing module basic features

parent 55343f38
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,7 @@ use SGalinski\SgJobs\Service\BackendService;
use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
/**
......@@ -43,6 +44,13 @@ class BackendController extends ActionController {
*/
protected $docHeaderComponent;
/**
* The uid of the current root page
*
* @var int
*/
private $rootPageUid = 0;
/**
* Show all job offers and options to manage them
*
......@@ -53,11 +61,26 @@ class BackendController extends ActionController {
// create doc header component
try {
$pageUid = (int) GeneralUtility::_GP('id');
if ($pageUid) {
$this->rootPageUid = BackendService::getRootUidByPageUid($pageUid);
}
// create docheader + buttons
$pageInfo = BackendUtility::readPageAccess($pageUid, $GLOBALS['BE_USER']->getPagePermsClause(1));
$this->docHeaderComponent = GeneralUtility::makeInstance(DocHeaderComponent::class);
$this->docHeaderComponent->setMetaInformation($pageInfo);
BackendService::makeButtons($this->docHeaderComponent, $this->request);
// if we are not on a root page, display the root pages to the user
if (!$this->rootPageUid) {
$this->view->assign('rootOptions', BackendService::getRootOptions());
}
$this->view->assign('pageUid', $pageUid);
$this->view->assign('rootPageUid', $this->rootPageUid);
$this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
$this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version));
$this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
} catch (\Exception $exception) {
// check for NULL value in view and render an error message
......
......@@ -47,7 +47,7 @@ class BackendService {
* @return array
* @throws \InvalidArgumentException
*/
public static function getPages() {
public static function getPages(): array {
$out = [];
/** @var $databaseConnection DatabaseConnection */
$databaseConnection = $GLOBALS['TYPO3_DB'];
......@@ -60,10 +60,10 @@ class BackendService {
foreach ($rows as $row) {
$pageInfo = BackendUtility::readPageAccess($row['uid'], $GLOBALS['BE_USER']->getPagePermsClause(1));
if ($pageInfo) {
$rootline = BackendUtility::BEgetRootLine($pageInfo['uid'], '', true);
$rootline = BackendUtility::BEgetRootLine($pageInfo['uid'], '', TRUE);
ksort($rootline);
$path = '/root';
foreach($rootline as $page) {
foreach ($rootline as $page) {
$path .= '/p' . dechex($page['uid']);
}
$pageInfo['path'] = $path;
......@@ -116,7 +116,7 @@ class BackendService {
* @param int $currentPid
* @return int
*/
public static function getSiteRoot($currentPid) {
public static function getSiteRoot($currentPid): int {
$rootLine = BackendUtility::BEgetRootLine((int) $currentPid);
$siteRoot = ['uid' => 0];
......@@ -129,4 +129,49 @@ class BackendService {
return $siteRoot['uid'];
}
/**
* Returns the root uid based on the given page uid
*
* @param int $pageUid
* @return int
*/
public static function getRootUidByPageUid($pageUid): int {
$out = 0;
$pageRootline = BackendUtility::BEgetRootLine($pageUid);
foreach ($pageRootline as $pageData) {
if ($pageData['is_siteroot']) {
$out = (int) $pageData['uid'];
break;
}
}
return $out;
}
/**
* Get the root pages
*
* @return array
*/
public static function getRootOptions(): array {
$rootOptionRows = (array) BackendUtility::getRecordsByField('pages', 'is_siteroot', 1, '', '', 'sorting');
$rootOptions = [];
foreach ($rootOptionRows as $row) {
$pageInfo = BackendUtility::readPageAccess($row['uid'], $GLOBALS['BE_USER']->getPagePermsClause(1));
if ($pageInfo) {
$rootline = BackendUtility::BEgetRootLine($pageInfo['uid'], '', TRUE);
ksort($rootline);
$path = '/root';
foreach ($rootline as $page) {
$path .= '/p' . dechex($page['uid']);
}
$pageInfo['path'] = $path;
$pageInfo['_thePathFull'] = substr($pageInfo['_thePathFull'], 1);
$pageInfo['_thePathFull'] = substr($pageInfo['_thePathFull'], 0, -1);
$rootOptions[] = $pageInfo;
}
}
return $rootOptions;
}
}
{namespace sg=SGalinski\SgJobs\ViewHelpers}
<p>
<f:translate key="backend.selectRootPage" />
</p>
<f:if condition="{pages}">
<div class="panel panel-default recordlist">
<div class="table-fit">
<table data-table="pages" class="table table-striped table-hover">
<tbody>
<f:for each="{pages}" as="page">
<tr data-uid="{page.uid}">
<td nowrap="nowrap" class="col-title">
<a href="#" onclick="sgRouteGoToPage({page.uid}, '{page.path}'); return false;">
  • OnClick ist kein sauberer Weg den EventHandler anzuhängen. Die Logik gehört ins JS. Gib dem Link einfach eine Klasse und häng den EventListener dann im JS dran. Das hat sonst eine Reihe von unschönen Folgeeffekten.

  • Please register or sign in to reply
<f:format.raw>
<sg:backend.icon table="pages" row="{page}" clickMenu="0" /> {page._thePathFull}
</f:format.raw>
</a>
</td>
</tr>
</f:for>
</tbody>
</table>
</div>
</div>
</f:if>
\ No newline at end of file
<f:layout name="Default" />
<f:section name="main">
<ul>
<f:for each="{someData}" as="item" key="itemUid">
<li>
<f:link.action action="detail" arguments="{itemUid : '{itemUid}'}">
<f:render partial="ListEntry" arguments="{item : item}" />
</f:link.action>
</li>
</f:for>
</ul>
<f:section name="iconButtons">
</f:section>
<f:section name="headline">
</f:section>
<f:section name="content">
<f:debug>{_all}</f:debug>
<f:if condition="{rootPageUid}">
<f:then>
<h1>test</h1>
</f:then>
<f:else>
<f:render partial="SelectRoot" arguments="{pages: rootOptions}" />
</f:else>
</f:if>
</f:section>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment