| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * (c) Kitodo. Key to digital objects e.V. <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * This file is part of the Kitodo and TYPO3 projects. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @license GNU General Public License version 3 or later. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * For the full copyright and license information, please read the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * LICENSE.txt file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | namespace Kitodo\Dlf\Controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Kitodo\Dlf\Common\Helper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use TYPO3\CMS\Core\Database\Connection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use TYPO3\CMS\Core\Database\ConnectionPool; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use TYPO3\CMS\Core\Utility\GeneralUtility; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use TYPO3\CMS\Extbase\Utility\LocalizationUtility; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * Controller for the plugin 'Statistics' for the 'dlf' extension | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * @author Sebastian Meyer <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * @package TYPO3 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * @subpackage dlf | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * @access public | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 27 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  | class StatisticsController extends AbstractController | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |      * The main method of the plugin | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |      * @return void | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     public function mainAction() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         // Quit without doing anything if required configuration variables are not set. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         if (empty($this->settings['pages'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             $this->logger->warning('Incomplete plugin configuration'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         // Check for selected collections. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         if ($this->settings['collections']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             // Include only selected collections. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |                 ->getQueryBuilderForTable('tx_dlf_documents'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             $countTitles = $queryBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |                 ->count('tx_dlf_documents.uid') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |                 ->from('tx_dlf_documents') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |                 ->innerJoin( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |                     'tx_dlf_documents', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |                     'tx_dlf_relations', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |                     'tx_dlf_relations_joins', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |                     $queryBuilder->expr()->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |                         'tx_dlf_relations_joins.uid_local', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |                         'tx_dlf_documents.uid' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |                 ->innerJoin( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |                     'tx_dlf_relations_joins', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |                     'tx_dlf_collections', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |                     'tx_dlf_collections_join', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |                     $queryBuilder->expr()->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |                         'tx_dlf_relations_joins.uid_foreign', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |                         'tx_dlf_collections_join.uid' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |                 ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |                     $queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages'])), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                     $queryBuilder->expr()->eq('tx_dlf_collections_join.pid', intval($this->settings['pages'])), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |                     $queryBuilder->expr()->eq('tx_dlf_documents.partof', 0), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                     $queryBuilder->expr()->in('tx_dlf_collections_join.uid', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                         $queryBuilder->createNamedParameter(GeneralUtility::intExplode(',', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                             $this->settings['collections']), Connection::PARAM_INT_ARRAY)), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |                     $queryBuilder->expr()->eq('tx_dlf_relations_joins.ident', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |                         $queryBuilder->createNamedParameter('docs_colls')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |                 ->execute() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |                 ->fetchColumn(0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |                 ->getQueryBuilderForTable('tx_dlf_documents'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |             $subQueryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |                 ->getQueryBuilderForTable('tx_dlf_documents'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |             $subQuery = $subQueryBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |                 ->select('tx_dlf_documents.partof') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |                 ->from('tx_dlf_documents') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |                 ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |                     $subQueryBuilder->expr()->neq('tx_dlf_documents.partof', 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |                 ->groupBy('tx_dlf_documents.partof') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |                 ->getSQL(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             $countVolumes = $queryBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |                 ->count('tx_dlf_documents.uid') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |                 ->from('tx_dlf_documents') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |                 ->innerJoin( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |                     'tx_dlf_documents', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |                     'tx_dlf_relations', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |                     'tx_dlf_relations_joins', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |                     $queryBuilder->expr()->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |                         'tx_dlf_relations_joins.uid_local', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |                         'tx_dlf_documents.uid' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |                 ->innerJoin( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |                     'tx_dlf_relations_joins', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |                     'tx_dlf_collections', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |                     'tx_dlf_collections_join', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |                     $queryBuilder->expr()->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |                         'tx_dlf_relations_joins.uid_foreign', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |                         'tx_dlf_collections_join.uid' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |                 ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |                     $queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages'])), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |                     $queryBuilder->expr()->eq('tx_dlf_collections_join.pid', intval($this->settings['pages'])), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |                     $queryBuilder->expr()->notIn('tx_dlf_documents.uid', $subQuery), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |                     $queryBuilder->expr()->in('tx_dlf_collections_join.uid', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |                         $queryBuilder->createNamedParameter(GeneralUtility::intExplode(',', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |                             $this->settings['collections']), Connection::PARAM_INT_ARRAY)), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |                     $queryBuilder->expr()->eq('tx_dlf_relations_joins.ident', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |                         $queryBuilder->createNamedParameter('docs_colls')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |                 ->execute() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |                 ->fetchColumn(0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |                 ->getQueryBuilderForTable('tx_dlf_documents'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |             // Include all collections. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             $countTitles = $queryBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |                 ->count('tx_dlf_documents.uid') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |                 ->from('tx_dlf_documents') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |                 ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |                     $queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages'])), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |                     $queryBuilder->expr()->eq('tx_dlf_documents.partof', 0), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |                     Helper::whereExpression('tx_dlf_documents') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |                 ->execute() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |                 ->fetchColumn(0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |                 ->getQueryBuilderForTable('tx_dlf_documents'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |             $subQueryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |                 ->getQueryBuilderForTable('tx_dlf_documents'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |             $subQuery = $subQueryBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |                 ->select('tx_dlf_documents.partof') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |                 ->from('tx_dlf_documents') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |                 ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |                     $subQueryBuilder->expr()->neq('tx_dlf_documents.partof', 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |                 ->groupBy('tx_dlf_documents.partof') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |                 ->getSQL(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |             $countVolumes = $queryBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |                 ->count('tx_dlf_documents.uid') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |                 ->from('tx_dlf_documents') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |                 ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |                     $queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages'])), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |                     $queryBuilder->expr()->notIn('tx_dlf_documents.uid', $subQuery) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |                 ->execute() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |                 ->fetchColumn(0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |         // Set replacements. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         $args['###TITLES###'] = $countTitles . ' ' . htmlspecialchars( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |             LocalizationUtility::translate( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |                 ($countTitles > 1 ? 'titles' : 'title'), 'dlf' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         $args['###VOLUMES###'] = $countVolumes . ' ' . htmlspecialchars( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |             LocalizationUtility::translate( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |                 ($countTitles > 1 ? 'volumes' : 'volume'), 'dlf' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         // Apply replacements. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |         $content = $this->settings['description']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         foreach ($args as $key => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |             $content = str_replace($key, $value, $content); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 190 |  |  |         $this->view->assign('content', $content); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 192 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 193 |  |  |  | 
            
                        
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.