TYPO3 CMS  TYPO3_7-6
PageShortcutParentUpdate.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
25 {
29  protected $title = 'Update page shortcuts with shortcut type "Parent of selected or current page"';
30 
37  public function checkForUpdate(&$description)
38  {
39  if ($this->isWizardDone()) {
40  return false;
41  }
42 
43  $pagesNeedingUpdate = $this->getUpdatablePages();
44  if (empty($pagesNeedingUpdate)) {
45  return false;
46  }
47 
48  $description = 'There are some shortcut pages that need to updated in order to preserve their current behaviour.';
49 
50  return true;
51  }
52 
58  protected function getUpdatablePages()
59  {
60  return $this->getDatabaseConnection()->exec_SELECTgetRows('uid', 'pages', 'shortcut <> 0 AND shortcut_mode = ' . PageRepository::SHORTCUT_MODE_PARENT_PAGE);
61  }
62 
70  public function performUpdate(array &$databaseQueries, &$customMessages)
71  {
72  $pagesNeedingUpdate = $this->getUpdatablePages();
73  if (!empty($pagesNeedingUpdate)) {
74  $uids = array_column($pagesNeedingUpdate, 'uid');
75  $this->getDatabaseConnection()->exec_UPDATEquery(
76  'pages',
77  'uid IN (' . implode(',', $uids) . ')',
78  [ 'shortcut' => 0 ]
79  );
80  $databaseQueries[] = $this->getDatabaseConnection()->debug_lastBuiltQuery;
81  }
82 
83  $this->markWizardAsDone();
84  return true;
85  }
86 }
performUpdate(array &$databaseQueries, &$customMessages)