Ejemplo n.º 1
0
 /**
  * @return void
  */
 public function execute()
 {
     $contexts = array('BE', 'FE');
     if ($this->getExtensionKey()) {
         $extensionList = array($this->getExtensionKey());
     } else {
         $extensionList = Tx_Smoothmigration_Utility_ExtensionUtility::getLoadedExtensionsFiltered();
     }
     foreach ($contexts as $context) {
         if (is_array($GLOBALS['TYPO3_CONF_VARS'][$context]['XCLASS']) && count($GLOBALS['TYPO3_CONF_VARS'][$context]['XCLASS']) > 0) {
             foreach ($GLOBALS['TYPO3_CONF_VARS'][$context]['XCLASS'] as $targetClass => $implementationClass) {
                 if (is_file($implementationClass)) {
                     $path = str_replace(PATH_typo3conf . 'ext/', '', $implementationClass);
                     $extKey = current(explode('/', $path));
                 } else {
                     $extKey = t3lib_extMgm::getExtensionKeyByPrefix(strtolower($implementationClass));
                 }
                 if (!in_array($extKey, $extensionList)) {
                     continue;
                 }
                 $this->issues[] = $this->createIssue($context, $targetClass, $implementationClass, $extKey);
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Execute the check
  *
  * @return void
  */
 public function execute()
 {
     $extensions = Tx_Smoothmigration_Utility_ExtensionUtility::getIncompatibleExtensions();
     foreach ($extensions as $extension => $versionRange) {
         $location = new Tx_Smoothmigration_Domain_Model_IssueLocation_Extension($extension, $versionRange[0], $versionRange[1]);
         $this->issues[] = new Tx_Smoothmigration_Domain_Model_Issue($this->parentCheck->getIdentifier(), $location);
     }
 }
Ejemplo n.º 3
0
 /**
  * Execute the check
  *
  * @return void
  */
 public function execute()
 {
     $extensions = Tx_Smoothmigration_Utility_ExtensionUtility::getObsoleteExtensions();
     foreach ($extensions as $extension) {
         $location = new Tx_Smoothmigration_Domain_Model_IssueLocation_Extension($extension);
         $this->issues[] = new Tx_Smoothmigration_Domain_Model_Issue($this->parentCheck->getIdentifier(), $location);
     }
 }
Ejemplo n.º 4
0
 /**
  * Execute the check
  *
  * @return void
  */
 public function execute()
 {
     $list = Tx_Smoothmigration_Utility_ExtensionUtility::getLoadedExtensionsFiltered(TRUE, FALSE, TRUE);
     foreach ($list as $extensionKey) {
         $locations = Tx_Smoothmigration_Utility_FileLocatorUtility::searchInExtension($extensionKey, '.*[^ext_tables]\\.(php|inc)$', '(addPlugin\\s*\\(\\s*(array\\s*\\([^\\)]*\\)[^\\,]*\\,|\\$[^\\,]*\\,)[^\\)\\,]*\\))');
         foreach ($locations as $location) {
             $this->issues[] = new Tx_Smoothmigration_Domain_Model_Issue($this->parentCheck->getIdentifier(), $location);
         }
     }
 }
 /**
  * @param string $fileNamePattern
  * @param string $searchPattern
  * @param array $excludedExtensions
  *
  * @return Tx_Smoothmigration_Domain_Interface_IssueLocation[]
  */
 public static function searchInExtensions($fileNamePattern, $searchPattern, $excludedExtensions = array())
 {
     $locations = array();
     $loadedExtensions = Tx_Smoothmigration_Utility_ExtensionUtility::getLoadedExtensionsFiltered();
     foreach ($loadedExtensions as $extensionKey) {
         if (in_array($extensionKey, $excludedExtensions)) {
             continue;
         }
         $locations = array_merge(self::searchInExtension($extensionKey, $fileNamePattern, $searchPattern), $locations);
     }
     return $locations;
 }
 /**
  * Get a filtered list of loaded / active extensions
  *
  * Compatible extensions can be filtered out.
  * Ignored extensions can be filtered out.
  * System extensions can be filtered out.
  * Smoothmigration is filtered out.
  *
  * @param bool $removeCompatible
  * @param bool $removeIgnored
  * @param bool $removeSystem
  *
  * @return array Array of installed
  */
 public static function getLoadedExtensionsFiltered($removeCompatible = TRUE, $removeIgnored = TRUE, $removeSystem = TRUE)
 {
     if (self::$loadedExtensionsFiltered !== NULL) {
         return self::$loadedExtensionsFiltered;
     }
     // get extension configuration
     $configuration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['smoothmigration']);
     if (isset($configuration['includeInactiveExtensions']) && intval($configuration['includeInactiveExtensions']) > 0) {
         $loadedExtensionsFiltered = self::getInstalledExtensions();
     } else {
         $loadedExtensionsFiltered = self::getLoadedExtensions();
     }
     $loadedExtensionsFiltered = array_flip($loadedExtensionsFiltered);
     unset($loadedExtensionsFiltered['smoothmigration']);
     if ($removeCompatible) {
         if (isset($configuration['excludeCompatibleExtensions']) && intval($configuration['excludeCompatibleExtensions']) > 0) {
             $targetVersion = NULL;
             if (isset($configuration['targetVersionOverride']) && trim($configuration['targetVersionOverride'])) {
                 $targetVersion = trim($configuration['targetVersionOverride']);
             }
             $compatibleExtensions = Tx_Smoothmigration_Utility_ExtensionUtility::getCompatibleExtensions($targetVersion);
             foreach ($compatibleExtensions as $key => $_) {
                 unset($loadedExtensionsFiltered[$key]);
             }
         }
     }
     if ($removeIgnored) {
         if (isset($configuration['excludedExtensions']) && trim($configuration['excludedExtensions']) !== '') {
             $ingoreExtensions = explode(',', str_replace(' ', '', $configuration['excludedExtensions']));
             foreach ($ingoreExtensions as $key) {
                 unset($loadedExtensionsFiltered[$key]);
             }
         }
     }
     if ($removeSystem) {
         foreach ($loadedExtensionsFiltered as $key => $_) {
             if ($GLOBALS['TYPO3_LOADED_EXT'][$key]['type'] === 'S') {
                 unset($loadedExtensionsFiltered[$key]);
             }
         }
     }
     $loadedExtensionsFiltered = array_flip($loadedExtensionsFiltered);
     self::$loadedExtensionsFiltered = $loadedExtensionsFiltered;
     return self::$loadedExtensionsFiltered;
 }
    /**
     * Extension action, displays extension report
     *
     * @return void
     */
    public function extensionAction()
    {
        $values = array();
        // FIXME: It's unclear to me how to get this value programmatically
        // There is a getArgumentPrefix method, but that only applies to widgets
        $values['argumentPrefix'] = 'tx_smoothmigration_tools_smoothmigrationsmoothmigration';
        // List of frontend extensions
        $loadedExtensions = Tx_Smoothmigration_Utility_ExtensionUtility::getFrontendExtensions(FALSE);
        $this->view->assign('loadedExtensions', $loadedExtensions);
        $selectedExtension = '';
        if ($this->request->hasArgument('extension')) {
            $selectedExtension = $this->request->getArgument('extension');
        }
        // List of sites
        $sites = Tx_Smoothmigration_Utility_DatabaseUtility::getSiteRoots();
        $selectSites = array();
        foreach ($sites as $siteUid => $siteData) {
            $selectSites[$siteUid] = $siteUid . ': ' . $siteData['title'];
        }
        $values['sites'] = $selectSites;
        $selectedSite = '';
        if ($this->request->hasArgument('site')) {
            $selectedSite = $this->request->getArgument('site');
            $values['selectedSite'] = $selectedSite;
        }
        if ($selectedSite && $selectedExtension != 1) {
            // Get TypoScript configuration for selected site
            if (count($sites) && $selectedSite) {
                $tmpl = t3lib_div::makeInstance('t3lib_tsparser_ext');
                $tmpl->tt_track = 0;
                $tmpl->init();
                $tmpl->runThroughTemplates(t3lib_BEfunc::BEgetRootLine((int) $selectedSite, 'AND 1=1'), 0);
                $tmpl->generateConfig();
            }
            // Fetch correct class names
            $correctClassNames = array();
            if ($selectedExtension) {
                $correctClassNames[$selectedExtension] = t3lib_extMgm::getCN($selectedExtension);
            } else {
                $extensionKeys = Tx_Smoothmigration_Utility_ExtensionUtility::getLoadedExtensions();
                foreach ($extensionKeys as $key) {
                    $correctClassNames[$key] = t3lib_extMgm::getCN($key);
                }
            }
            $listTypes = array();
            $values['plugins'] = array();
            // For all the root plugin objects in the plugin array
            foreach ($tmpl->setup['plugin.'] as $name => $_) {
                $name = rtrim($name, '.');
                // Store the matching extension key with the plugin name
                foreach ($correctClassNames as $key => $className) {
                    if (strstr($name, $className)) {
                        $values['plugins'][$name] = $key;
                        $suffix = str_replace($className, '', $name);
                        $listTypes[] = $key . $suffix;
                    }
                }
            }
            asort($values['plugins']);
            $pluginNames = array_keys($values['plugins']);
            // This catches Powermail which has it's own ctype which it calls powermail_pi1
            $values['cTypes'] = array();
            foreach ($pluginNames as $name) {
                array_push($values['cTypes'], str_replace('tx_', '', $name));
            }
            // Fetch list types, initialize with legacy tt_news list_type: 9
            $values['listTypes'] = array();
            if ($selectedExtension === 'tt_news') {
                $values['listTypes'] = array('9');
            }
            foreach ($tmpl->setup['tt_content.']['list.']['20.'] as $listType => $_) {
                if (preg_match('/^[^.]+$/', $listType)) {
                    foreach ($values['plugins'] as $correctedClassName) {
                        if (preg_match('/^' . $correctedClassName . '/', $listType)) {
                            $values['listTypes'][] = $listType;
                        }
                    }
                }
            }
            asort($values['listTypes']);
            $values['pages'] = array();
            if (count($values['listTypes']) || count($values['cTypes'])) {
                $values['pages'] = Tx_Smoothmigration_Utility_DatabaseUtility::getPagesWithContentElements($values['cTypes'], $values['listTypes']);
            }
            $pages = array();
            foreach ($values['pages'] as $page) {
                $this->setInPageArray($pages, t3lib_BEfunc::BEgetRootLine($page['pageUid'], 'AND 1=1'), $page);
            }
            $lines = array();
            $lines[] = '<tr class="t3-row-header">
				<td nowrap>Page title</td>
				<td nowrap>' . $GLOBALS['LANG']->getLL('isExt') . '</td>
				</tr>';
            $lines = array_merge($lines, $this->renderList($pages));
            $values['table'] = '<table border="0" cellpadding="0" cellspacing="1" id="ts-overview">' . implode('', $lines) . '</table>';
        }
        $this->view->assignMultiple($values);
        $this->view->assign('selectedExtension', $selectedExtension);
        $this->view->assign('moduleToken', $this->moduleToken);
    }
 /**
  * Display index of actions
  *
  * @param string $type
  *
  * @return void
  */
 protected function displayActionIndex($type = 'Check')
 {
     $this->messageBus->headerMessage('Avaliable ' . $type . 's:', 'info');
     $type = strtolower($type);
     if ($this->availableActions === array()) {
         $this->availableActions = $this->commandManager->getAvailableCommands();
     }
     $colorizedIdentifierLength = $this->getMaximumIdentifierLength($this->availableActions[$type], TRUE);
     $identifierLength = $this->getMaximumIdentifierLength($this->availableActions[$type]);
     $this->messageBus->message(vsprintf('    %-' . $identifierLength . 's %s', array('Identifier', 'Description')));
     $this->messageBus->horizontalLine();
     /** @var Tx_Smoothmigration_Checks_AbstractCheckDefinition $command */
     $counter = 1;
     foreach ($this->availableActions[$type] as $command) {
         $this->autoCompleteValues['actions'][] = $command->getIdentifier();
         $description = wordwrap($command->getShortDescription(), TERMINAL_WIDTH - $identifierLength - 7, PHP_EOL . str_repeat(' ', $identifierLength + 7), TRUE);
         $shortCommandIdentifier = $command->getIdentifier();
         $this->messageBus->message(vsprintf('%2s) %-' . $colorizedIdentifierLength . 's %s', array($counter, $this->messageBus->successString($shortCommandIdentifier), $description)));
         $counter++;
     }
     $this->messageBus->message();
     if ($this->isInInteractiveMode) {
         $this->messageBus->setCompletions(array('actions' => $this->autoCompleteValues['actions'], 'extensions' => Tx_Smoothmigration_Utility_ExtensionUtility::getLoadedExtensionsFiltered()));
         $actions = $this->autoCompleteValues['actions'][$type];
         $this->messageBus->usage();
         $response = $this->messageBus->prompt();
         $this->messageBus->message();
         list($code, $extension) = explode(' ', $response);
         if (array_key_exists($code, $actions)) {
             readline_add_history($response);
             $method = $type . 'Command';
             $this->{$method}($actions[$code], $extension);
         } elseif (in_array($code, $actions)) {
             readline_add_history($response);
             $method = $type . 'Command';
             $this->{$method}($code, $extension);
         } elseif ($code == -1) {
             $this->interactiveCommand();
         } else {
             $this->messageBus->errorMessage('Uknown comand: ' . $code);
             $this->interactiveCommand();
         }
     } else {
         $this->messageBus->message('Usage: ./cli_dispatch.phpsh extbase smoothmigration:' . $type . ' <Identifier> [extensionName]');
     }
     $this->messageBus->message();
 }
 /**
  * Loads all Extension-Versions from ext_emconf files
  *
  * @return void
  */
 protected function initializeTypo3ExtensionArray()
 {
     $extensionKeys = Tx_Smoothmigration_Utility_ExtensionUtility::getLoadedExtensions();
     foreach ($extensionKeys as $extensionKey) {
         $this->installedTypo3Extensions[$extensionKey] = t3lib_extMgm::getExtensionVersion($extensionKey);
     }
 }