Skip to content

Commit

Permalink
version 1.5.2
Browse files Browse the repository at this point in the history
tool Slug vs. RealURL added
  • Loading branch information
bihor committed Mar 16, 2020
1 parent 44935c8 commit d65d691
Show file tree
Hide file tree
Showing 10 changed files with 257 additions and 17 deletions.
88 changes: 88 additions & 0 deletions Classes/Controller/SessionController.php
Expand Up @@ -468,6 +468,94 @@ public function pagesearchAction()
$this->view->assign('settings', $this->settings);
}

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

if ($this->request->hasArgument('my_p')) {
$my_p = intval($this->request->getArgument('my_p'));
$default->setValue1($my_p);
} else $my_p = $default->getValue1();
if ($this->request->hasArgument('my_e')) {
$my_e = intval($this->request->getArgument('my_e'));
$default->setValue2($my_e);
} else $my_e = $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) {
$my_page = $this->settings['pagebrowser']['itemsPerPage'];
if (!$my_page) {
$my_page = $this->settings['pagebrowser']['itemsPerPage'] = 25;
}
} else {
$this->settings['pagebrowser']['itemsPerPage'] = $my_page;
}

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);
}

$pagesRealurl = $this->sessionRepository->getPagesRealurl();
$pagesSlug = $this->sessionRepository->getPagesSlug($my_p);
$pages = [];
$siteFinder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Site\SiteFinder::class);

foreach ($pagesSlug as $key => $value) {
$slug = $value['slug'];
$site = $siteFinder->getSiteByPageId($key);
if ($site) {
$base = $site->getConfiguration()['base'];
if (substr($base, 0, 4) == 'http') {
$parse_url = parse_url($base);
$base = $parse_url['path'];
}
$slug = substr($base, 0, -1) . $slug;
}
if ($slug != $pagesRealurl[$key]) {
if (($my_e == 0) || (($my_e == 1) && !$pagesRealurl[$key]) || (($my_e == 2) && $pagesRealurl[$key])) {
$pages[$key] = $value;
$pages[$key]['uid'] = $key;
$pages[$key]['slug'] = $slug;
//$pages[$key]['slug'] = $value['slug'];
$pages[$key]['realurl'] = $pagesRealurl[$key];
}
}
}

$this->view->assign('my_p', $my_p);
$this->view->assign('my_e', $my_e);
$this->view->assign('my_page', $my_page);
$this->view->assign('settings', $this->settings);
$this->view->assign('pages', $pages);
}

/**
* action redirects
*
Expand Down
54 changes: 54 additions & 0 deletions Classes/Domain/Repository/SessionRepository.php
Expand Up @@ -650,6 +650,60 @@ public function setAltOrTitle($uid, $alternative, $title) {
}
}

/**
* Get list of pages with RealUrl-path
*
* @return array
*/
public function getPagesRealurl() {
$pages = [];
$table = 'tx_realurl_pathdata';
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$statement = $queryBuilder
->select('*')
->from($table)
->orderBy('page_id', 'ASC')
->execute();
while ($row = $statement->fetch()) {
$pages[$row['page_id']] = '/' . $row['pagepath'];
}
return $pages;
}

/**
* Get list of pages with slug-path
* @param int $hidden hidden-flag
* @return array
*/
public function getPagesSlug($hidden) {
$pages = [];
$table = 'pages';
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$statement = $queryBuilder
->select('*')
->from($table)
->where($queryBuilder->expr()->eq('deleted', 0))
->andWhere($queryBuilder->expr()->gt('pid', 0))
->orderBy('uid', 'ASC')
->execute();
while ($row = $statement->fetch()) {
$p_hidden = $row['hidden'];
if (($hidden == 0) || (($hidden == 1) && $p_hidden) || (($hidden == 2) && !$p_hidden)) {
$pages[$row['uid']] = [];
$pages[$row['uid']]['hidden'] = $hidden;
$pages[$row['uid']]['sys_language_uid'] = $row['sys_language_uid'];
$pages[$row['uid']]['title'] = $row['title'];
$pages[$row['uid']]['slug'] = $row['slug'];
if ($row['slug_locked'] && ($row['slug_locked'] == 1)) {
$pages[$row['uid']]['slug_locked'] = 1;
} else {
$pages[$row['uid']]['slug_locked'] = 0;
}
}
}
return $pages;
}

/**
* Get list of domains
*
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Index.rst
Expand Up @@ -23,7 +23,7 @@ Backend tools
en

:Description:
6 admin tools for TYPO3 extension listing, redirects, unzip, unused files, images with no alt- or title-tag and links.
7 admin tools for TYPO3 extension listing, slugs vs. RealURL-path, redirects, unzip, unused files, images with no alt- or title-tag and links.

:Keywords:
backend,tools,extensions
Expand Down
14 changes: 8 additions & 6 deletions Documentation/Introduction/Index.rst
Expand Up @@ -17,19 +17,21 @@ Introduction
What does it do?
----------------

This extension provides some usefull tools in the “Admin tools” section of the backend of TYPO3. Currently it contains 5 tools for extensions, files, images and links.
This extension provides some usefull tools in the “Admin tools” section of the backend of TYPO3. Currently it contains 7 tools for extensions, slugs, redirects, files, images and links.

Tool 1: shows you all pages where you use extensions. You can see where you use which extension. You can search for non-extensions too, e.g. if you set Ctype='mailform'.

Tool 2: you can extract an uploaded zip-file in the fileadmin-folder. Useful if you have no SSH connection.
Tool 2: shows differences between RealURL-pagepath (in tx_realurl_pathdata) and Slug (in pages). Note: the old RealURL-tables must be present!

Tool 3: helps you to delete unused files. Go to “Admin tools” → DB check” → “Database Relations” to find files which you can delete. This tool helps you to delete these files.
Tool 3: you can extract an uploaded zip-file in the fileadmin-folder. Useful if you have no SSH connection.

Tool 4: helps you to find pages that link to another page. You can find any content element with a link to a specific page.
Tool 4: helps you to delete unused files. Go to “Admin tools” → DB check” → “Database Relations” to find files which you can delete. This tool helps you to delete these files.

Tool 5: helps you to find images with no title- oder alternative-text. This tool can set that values for you too.
Tool 5: helps you to find pages that link to another page. You can find any content element with a link to a specific page.

Tool 6: you can import simple redirect rules form your .htaccess to the table sys_redirect.
Tool 6: helps you to find images with no title- oder alternative-text. This tool can set that values for you too.

Tool 7: you can import simple redirect rules form your .htaccess to the table sys_redirect.

.. _screenshots:

Expand Down
2 changes: 1 addition & 1 deletion Documentation/User/Index.rst
Expand Up @@ -11,6 +11,6 @@
Users Manual
============

Just install the extension. Click on the left side at “Extension & file tools”. Select one of the 6 modes (see top left).
Just install the extension. Click on the left side at “Extension & file tools”. Select one of the 7 modes (see top left).

Note: you need admin rights! The link appears under the “Admin tools”.
8 changes: 4 additions & 4 deletions README.md
@@ -1,11 +1,11 @@
# backendtools

version 1.5.1
version 1.5.2

6 admin tools for extensions, redirects, files, images and links:
extensionlist, import redirects, delete unused files, images with no title, unzip and linklist.
7 admin tools for extensions, slug, redirects, files, images and links:
extensionlist, Slug vs. RealURL, import redirects, delete unused files, images with no title, unzip and linklist.

You find the documentation for this extension at typo3.org:
https://docs.typo3.org/p/fixpunkt/backendtools/master/en-us/

Last feature: link the title with the slug.
Last feature: tool Slug vs. RealURL added.
1 change: 1 addition & 0 deletions Resources/Private/Layouts/Default.html
Expand Up @@ -11,6 +11,7 @@
<f:be.menus.actionMenuItem label="Show pages that use (specific) extensions" controller="" action="list" />
<f:be.menus.actionMenuItem label="Show pages that links to a specific page" controller="" action="pagesearch" />
<f:be.menus.actionMenuItem label="Show images without title- or alt-text" controller="" action="images" />
<f:be.menus.actionMenuItem label="Compare Slug with RealURL-path" controller="" action="realurl" />
<f:be.menus.actionMenuItem label="Unzip a file in the fileadmin-folder" controller="" action="unzip" />
<f:be.menus.actionMenuItem label="Delete unused files in the uploads-folder" controller="" action="filedeletion" />
<f:be.menus.actionMenuItem label="Import redirect-rules to sys_redirect" controller="" action="redirects" />
Expand Down
95 changes: 95 additions & 0 deletions Resources/Private/Templates/Session/Realurl.html
@@ -0,0 +1,95 @@
{namespace ex=Fixpunkt\Backendtools\ViewHelpers}
<f:layout name="Default" />
<f:section name="content">
<style>
.f3-widget-paginator { padding-left:0; }
.f3-widget-paginator li { display:inline-block; }
</style>
<h1>RealURL vs. Slug</h1>
<f:flashMessages />
<f:form action="realurl" class="form-inline">
<p>Differences between RealURL-pagepath (in tx_realurl_pathdata) and Slug (in pages):</p>
<div class="row"><div class="col-md-6">

<div style="margin: 10px 0;">Show only entries with
<label class="checkbox-inline">
<f:form.radio name="my_e" value="1" checked="{my_e} == 1" /> empty &nbsp; or
</label>
<label class="checkbox-inline">
<f:form.radio name="my_e" value="2" checked="{my_e} == 2" /> available &nbsp; or
</label>
<label class="checkbox-inline">
<f:form.radio name="my_e" value="0" checked="{my_e} == 0" /> whatever ... RealURL-pagepath.
</label>
</div>
<!-- div style="margin: 10px 0;">Show only
<label class="checkbox-inline">
<f:form.radio name="my_p" value="1" checked="{my_p} == 1" /> not visible &nbsp; or
</label>
<label class="checkbox-inline">
<f:form.radio name="my_p" value="2" checked="{my_p} == 2" /> visible &nbsp; or
</label>
<label class="checkbox-inline">
<f:form.radio name="my_p" value="0" checked="{my_p} == 0" /> all ... pages.
</label>
</div -->

</div><div class="col-md-6">
<div style="margin: 10px 0;">Entries per page:
<f:form.textfield name="my_page" value="{my_page}" size="5" /> &nbsp;
</div>
</div></div>

<f:form.submit value="search" name="search" class="btn btn-default" />
</f:form>

<f:if condition="{pages -> f:count()} > 0">
<f:then>
<f:widget.paginate objects="{pages}" as="paginatedpages" configuration="{settings.pagebrowser}">
<table class="table">
<thead>
<tr>
<th colspan="4" style="text-align:center;background-color:#cfc;">Page</th>
<th colspan="1" style="text-align:center;background-color:#fcc;">RealURL</th>
<th colspan="2" style="text-align:center;background-color:#ccf;">Slug</th>
</tr>
<tr>
<th>uid</th>
<th>lang.</th>
<th>hidden</th>
<th>title</th>
<th>Path</th>
<th>Slug</th>
<th>Locked</th>
</tr>
</thead>
<tbody>
<f:for each="{paginatedpages}" as="page" iteration="iterator">
<tr{f:if(condition:iterator.isOdd, then: ' style="background-color:#fff;"')}>
<td>
<ex:editLink action="edit" table="pages" uid="{page.uid}" returnUrl="mod.php?M=tools_BackendtoolsMod1&tx_backendtools_tools_backendtoolsmod1[action]=realurl">
<img src="/typo3/sysext/core/Resources/Public/Icons/T3Icons/actions/actions-document-open.svg" width="16" height="16">
</ex:editLink>
<a href="/index.php?id={page.uid}&L={page.sys_language_uid}&no_cache=1" target="extern">
<img src="/typo3/sysext/core/Resources/Public/Icons/T3Icons/actions/actions-document-view.svg" width="16" height="16">
</a>
{page.uid}
</td>
<td>{page.sys_language_uid}</td>
<td><f:if condition="{page.hidden} == 1"><f:then><span style="color:#bb0000;font-weight:bold;">yes</span></f:then><f:else>no</f:else></f:if></td>
<td>{page.title}</td>
<td>{page.realurl}</td>
<td>{page.slug}</td>
<td><f:if condition="{page.slug_locked} == 1"><f:then><span style="color:#bb0000;font-weight:bold;">yes</span></f:then><f:else>no</f:else></f:if></td>
</tr>
</f:for>
</tbody>
</table>
</f:widget.paginate>
<p>{pages -> f:count()} pages found.</p>
</f:then>
<f:else>
<p>0 pages found!</p>
</f:else>
</f:if>
</f:section>
8 changes: 4 additions & 4 deletions ext_emconf.php
Expand Up @@ -12,16 +12,16 @@

$EM_CONF[$_EXTKEY] = array (
'title' => 'Backend tools',
'description' => '6 admin tools for extensions, redirects, files, images and links: extensionlist, redirects import, filedeletion, images with no alt or title, unzip and linklist.',
'description' => '7 admin tools: extensionlist, slug vs. RealURL, redirects import, filedeletion, images with no alt or title, unzip and linklist.',
'category' => 'module',
'author' => 'Kurt Gusbeth',
'author_company' => 'fixpunkt werbeagentur gmbh',
'author' => 'Kurt Gusbeth',
'author_company' => 'fixpunkt werbeagentur gmbh',
'author_email' => 'info@quizpalme.de',
'state' => 'stable',
'uploadfolder' => false,
'createDirs' => '',
'clearCacheOnLoad' => false,
'version' => '1.5.1',
'version' => '1.5.2',
'constraints' =>
array (
'depends' => array (
Expand Down
2 changes: 1 addition & 1 deletion ext_tables.php
Expand Up @@ -13,7 +13,7 @@ function()
'mod1', // Submodule key
'', // Position
[
'Session' => 'list, filedeletion, unzip, images, pagesearch, redirects',
'Session' => 'list, filedeletion, unzip, images, pagesearch, redirects, realurl',
],
[
'access' => 'user,group',
Expand Down

0 comments on commit d65d691

Please sign in to comment.