Skip to content

Commit

Permalink
Version 4.2.0: new tool: show pages with layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
bihor committed May 24, 2022
1 parent 2b898e1 commit cb8556b
Show file tree
Hide file tree
Showing 19 changed files with 348 additions and 215 deletions.
89 changes: 89 additions & 0 deletions Classes/Controller/SessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,95 @@ public function latestAction()
$this->view->assign('action', 'latest');
}

/**
* action backend layouts
*
* @return void
*/
public function layoutsAction()
{
$beuser_id = $GLOBALS['BE_USER']->user['uid'];
$result = $this->sessionRepository->findByAction('layouts', $beuser_id);
if ($result->count() == 0) {
$new = TRUE;
$default = GeneralUtility::makeInstance('Fixpunkt\\Backendtools\\Domain\\Model\\Session');
$default->setAction('layouts');
$default->setValue1(0);
$default->setValue2(0);
} else {
$new = FALSE;
$default = $result[0];
}

if ($this->request->hasArgument('currentPage')) {
$currentPage = intval($this->request->getArgument('currentPage'));
} else $currentPage = 1;
if ($this->request->hasArgument('my_value')) {
$my_value = $this->request->getArgument('my_value'); // date and time
$default->setValue1($my_value);
} else $my_value = $default->getValue1();
if ($this->request->hasArgument('my_p')) {
$my_p = intval($this->request->getArgument('my_p')); // pages visibility
$default->setValue2($my_p);
} else $my_p = $default->getValue2();
if ($this->request->hasArgument('my_page')) {
$my_page = intval($this->request->getArgument('my_page')); // elements per page
$default->setPageel($my_page);
} else $my_page = $default->getPageel();
if (!$my_page) {
if (isset($this->settings['pagebrowser']['itemsPerPage'])) {
$my_page = $this->settings['pagebrowser']['itemsPerPage'];
}
if (!$my_page) {
$my_page = $this->settings['pagebrowser']['itemsPerPage'] = 25;
}
} else {
$this->settings['pagebrowser']['itemsPerPage'] = $my_page;
}
if ($this->request->hasArgument('my_outp')) {
$my_outp = intval($this->request->getArgument('my_outp')); // output
} else $my_outp = 0;
if ($this->request->hasArgument('my_recursive')) {
$my_recursive = intval($this->request->getArgument('my_recursive')); // recursive pid search
$default->setPagestart($my_recursive);
} else $my_recursive = $default->getPagestart();

if ($new) {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$backendUserRepository = $objectManager->get(BackendUserRepository::class);
/** @var \TYPO3\CMS\Extbase\Domain\Model\BackendUser $user */
$user = $backendUserRepository->findByUid($beuser_id);
$default->setBeuser($user);
$this->sessionRepository->add($default);
$persistenceManager = GeneralUtility::makeInstance("TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager");
$persistenceManager->persistAll();
} else {
$this->sessionRepository->update($default);
}

$pages = $this->sessionRepository->getLayouts( $my_value, $my_p );
if ($my_recursive > 0) {
$pages = $this->sessionRepository->filterPagesRecursive($pages, $my_recursive);
}

$arrayPaginator = new ArrayPaginator($pages, $currentPage, $this->settings['pagebrowser']['itemsPerPage']);
$pagination = new SimplePagination($arrayPaginator);

// Assign
$this->view->assign('my_p', $my_p);
$this->view->assign('my_value', $my_value);
$this->view->assign('my_page', $my_page);
$this->view->assign('my_outp', $my_outp);
$this->view->assign('my_recursive', $my_recursive);
$this->view->assign('rows', count($pages));
$this->view->assign('pages', $pages);
$this->view->assign('paginator', $arrayPaginator);
$this->view->assign('pagination', $pagination);
$this->view->assign('no_pages', range(1, $pagination->getLastPageNumber()));
$this->view->assign('settings', $this->settings);
$this->view->assign('action', 'layouts');
}

/**
* action filedeletion
*
Expand Down
97 changes: 97 additions & 0 deletions Classes/Domain/Repository/SessionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,103 @@ public function getLatestContentElements($my_c, $my_p, $tstamp) {
return $pages;
}

/**
* Get list of pages with (backend)-layouts
*
* @param int $my_value layouts or backend-layouts
* @param int $my_p pages visibility
* @return array
*/
public function getLayouts($my_value, $my_p) {
$pages = [];
$this->siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
// Query aufbauen
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages')->createQueryBuilder();
$res = $queryBuilder ->select(...[
'uid',
'l10n_parent',
'sys_language_uid',
'deleted AS pdeleted',
'hidden AS phidden',
'tstamp AS ptstamp',
'title',
'slug',
'layout',
'backend_layout',
'backend_layout_next_level'
]) -> from ('pages');
if ($my_value == 0) {
$res->where(
$queryBuilder->expr()->neq(
'layout',
$queryBuilder->createNamedParameter('')
)
);
} else {
$res->where(
$queryBuilder->expr()->neq(
'backend_layout',
$queryBuilder->createNamedParameter('')
)
)
->orWhere(
$queryBuilder->expr()->neq(
'backend_layout_next_level',
$queryBuilder->createNamedParameter('')
)
);
}
// Restricions
$queryBuilder
->getRestrictions()
->removeAll();
if ($my_p==1) {
$res -> andWhere(...[
$queryBuilder->expr()->orX(
$queryBuilder->expr()->eq('pages.deleted', $queryBuilder->createNamedParameter(1)),
$queryBuilder->expr()->eq('pages.hidden', $queryBuilder->createNamedParameter(1)),
$queryBuilder->expr()->gt('pages.starttime', $queryBuilder->createNamedParameter(time())),
$queryBuilder->expr()->andX(
$queryBuilder->expr()->gt('pages.endtime', $queryBuilder->createNamedParameter(0)),
$queryBuilder->expr()->lte('pages.endtime', $queryBuilder->createNamedParameter(time()))
)
)
]);
} else if ($my_p==2) {
$res -> andWhere(...[
$queryBuilder->expr()->eq('pages.deleted', $queryBuilder->createNamedParameter(0)),
$queryBuilder->expr()->eq('pages.hidden', $queryBuilder->createNamedParameter(0)),
$queryBuilder->expr()->lte('pages.starttime', $queryBuilder->createNamedParameter(time())),
$queryBuilder->expr()->orX(
$queryBuilder->expr()->eq('pages.endtime', $queryBuilder->createNamedParameter(0)),
$queryBuilder->expr()->gt('pages.endtime', $queryBuilder->createNamedParameter(time()))
)
]);
}
$res -> orderBy('uid', 'ASC');
$result = $res-> execute();

foreach($result as $row) {
if ($row['sys_language_uid'] > 0) {
$row['pl10n'] = $row['uid'];
$row['uid'] = $row['l10n_parent'];
} else {
$row['pl10n'] = $row['uid'];
}
$row['pid'] = $row['uid'];
$row['uid'] = 0;
if ( $row["pdeleted"] ) {
$row['domain'] = '';
} else {
$row['domain'] = $this->getDomain($row['pid'], $row['sys_language_uid']);
}
$row['csvheader'] = '';
$row['csvtitle'] = str_replace('"', '\'', $row['title']);
$pages[] = $row;
}
return $pages;
}

/**
* Get list of pages modified since a given date
*
Expand Down
62 changes: 0 additions & 62 deletions Classes/Widgets/BackendLayoutWidget.php

This file was deleted.

80 changes: 0 additions & 80 deletions Classes/Widgets/Provider/BeLayoutsDataProvider.php

This file was deleted.

16 changes: 0 additions & 16 deletions Configuration/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,5 @@
]
);

$services->set('dashboard.widget.fixpunktBeLayouts')
->class(\Fixpunkt\Backendtools\Widgets\BackendLayoutWidget::class)
->arg('$view', new Reference('dashboard.views.widget'))
->arg('$dataProvider', new Reference(\Fixpunkt\Backendtools\Widgets\Provider\BeLayoutsDataProvider::class))
->tag(
'dashboard.widget',
[
'identifier' => 'fixpunktBeLayouts',
'groupNames' => 'fixpunkt',
'title' => 'Infos about used backend layouts',
'description' => 'Shows where backend layouts are in use.',
'iconIdentifier' => 'content-widget-list',
'height' => 'medium',
'width' => 'medium'
]
);
}
};
8 changes: 1 addition & 7 deletions Configuration/TypoScript/setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,4 @@ module.tx_backendtools {
insertBelow = 1
maximumNumberOfLinks = 25
}
}

module.tx_dashboard.view {
templateRootPaths {
44 = EXT:backendtools/Resources/Private/Templates/
}
}
}
3 changes: 2 additions & 1 deletion Documentation/Changelog/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
Changelog
=========
Version 4.2.0:
5 dashboard widgets added.
New tool: shows you where (backend) layouts are in use.
4 dashboard widgets added.
Bugfix for PHP 8.

Version 4.1.0:
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Backend tools
en

:Description:
7 admin tools for TYPO3 extension listing, recent pages, redirects, unused files, images with no alt- or title-tag and links.
8 admin tools for TYPO3 extension listing, recent pages, pages with layouts, redirects, unused files, images with no alt- or title-tag and links.

:Keywords:
backend,tools,extensions
Expand Down
Loading

0 comments on commit cb8556b

Please sign in to comment.