Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[TASK] Move autoconfiguration to namesaces
Browse files Browse the repository at this point in the history
  • Loading branch information
helhum committed Apr 10, 2014
1 parent 41fea0e commit f966e38
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace Tx\Realurl\Configuration;

/***************************************************************
* Copyright notice
*
Expand Down Expand Up @@ -32,19 +34,27 @@
* @package realurl
* @subpackage tx_realurl
*/
class tx_realurl_autoconfgen {
class ConfigurationGenerator {

const AUTOCONFIGURTION_FILE = 'typo3conf/realurl_autoconf.php';

/* @var $db t3lib_DB */
var $databaseConnection;
var $hasStaticInfoTables;
/**
* @var \TYPO3\CMS\Core\Database\DatabaseConnection
*/
protected $databaseConnection;

/**
* @var bool
*/
protected $hasStaticInfoTables;

/**
* Generates configuration. Locks configuration file for exclusive access to avoid collisions. Will not be stabe on Windows.
*
* @return void
*/
public function generateConfiguration() {
$fileName = PATH_site . TX_REALURL_AUTOCONF_FILE;
$fileName = PATH_site . self::AUTOCONFIGURTION_FILE;

$lockObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_lock', $fileName, $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']);
/** @var t3lib_lock $lockObject */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Tx\Realurl\Controller;
namespace Tx\Realurl\View;

/***************************************************************
* Copyright notice
Expand All @@ -26,11 +26,13 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

/**
* Class InfoModuleController
* Class AdministrationModuleFunction
*/
class InfoModuleController {
class AdministrationModuleFunction extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule {
/**
* @var int
*/
Expand Down Expand Up @@ -138,8 +140,7 @@ protected function createModuleContentForPage() {
protected function getFunctionMenu() {
return $GLOBALS['LANG']->getLL('function') . ' ' .
\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->pObj->id, 'SET[type]',
$this->pObj->MOD_SETTINGS['type'], $this->pObj->MOD_MENU['type'],
'index.php');
$this->pObj->MOD_SETTINGS['type'], $this->pObj->MOD_MENU['type']);
}

/**
Expand All @@ -165,7 +166,7 @@ protected function addModuleStyles() {
*/
protected function getDepthSelector() {
return $GLOBALS['LANG']->getLL('depth') .
\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->pObj->id,"SET[depth]",$this->pObj->MOD_SETTINGS["depth"],$this->pObj->MOD_MENU["depth"],"index.php");
\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->pObj->id,"SET[depth]",$this->pObj->MOD_SETTINGS["depth"],$this->pObj->MOD_MENU["depth"]);
}

/**
Expand All @@ -188,10 +189,10 @@ protected function initializeTree() {
// Creating top icon; the current page
$tree->tree[] = array(
'row' => $treeStartingRecord,
"HTML" => \TYPO3\CMS\Backend\Utility\IconUtility::getIconImage("pages", $treeStartingRecord, $GLOBALS["BACK_PATH"], "align="top"")
"HTML" => \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord("pages", $treeStartingRecord)
);

// Create the tree from starting point:
// Create the tree from starting point:
if ($this->pObj->MOD_SETTINGS['depth'] > 0) {
$tree->getTree($treeStartingPoint, $this->pObj->MOD_SETTINGS['depth'], '');
}
Expand Down Expand Up @@ -502,13 +503,19 @@ function getPathCache($pageId) {
}

/**
* Links to the module script and sets necessary parameters (only for pathcache display)
* Links to the module script and sets necessary parameters (only for path cache display)
*
* @param string Additional GET vars
* @return string script + query
* @param string $parameters Additional GET vars
* @return string script + query
*/
function linkSelf($addParams) {
return htmlspecialchars('index.php?id='.$this->pObj->id.'&showLanguage='.rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('showLanguage')).$addParams);
function linkSelf($parameters) {
return htmlspecialchars(BackendUtility::getModuleUrl(
'web_info',
array(
'id' => $this->pObj->id,
'showLanguage' => \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('showLanguage'),
)
) . $parameters);
}

/**
Expand Down Expand Up @@ -1704,7 +1711,7 @@ protected function deleteRedirectEntry() {
/**
* Creates a code for 'Add new entries' button
*
* @return void
* @return string
*/
protected function getNewButton() {
$content = '<div style="margin:0 0 0.5em 3px"><a href="'.$this->linkSelf('&cmd=new').'">'.
Expand Down
4 changes: 2 additions & 2 deletions class.tx_realurl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2173,7 +2173,7 @@ protected function setConfig() {
$realUrlConf = (array)@unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['realurl']);
// Autoconfiguration
if ($realUrlConf['enableAutoConf']) {
$autoConfPath = PATH_site . TX_REALURL_AUTOCONF_FILE;
$autoConfPath = PATH_site . \Tx\Realurl\Configuration\ConfigurationGenerator::AUTOCONFIGURTION_FILE;
$testConf = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'];
if (is_array($testConf)) {
unset($testConf['getHost']);
Expand All @@ -2184,7 +2184,7 @@ protected function setConfig() {

/** @noinspection PhpIncludeInspection */
if (count($testConf) == 0 && !@include_once($autoConfPath)) {
$autoConfGenerator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance("tx_realurl_autoconfgen");
$autoConfGenerator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance("Tx\\Realurl\\Configuration\\ConfigurationGenerator");
$autoConfGenerator->generateConfiguration();
unset($autoConfGenerator);
/** @noinspection PhpIncludeInspection */
Expand Down
6 changes: 1 addition & 5 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@
unset($_realurl_conf_file);
}

define('TX_REALURL_AUTOCONF_FILE', 'typo3conf/realurl_autoconf.php');
if (!isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'])) {
include_once(PATH_site . TX_REALURL_AUTOCONF_FILE);
include_once(PATH_site . \Tx\Realurl\Configuration\ConfigurationGenerator::AUTOCONFIGURTION_FILE);
}
unset($_realurl_conf);

define('TX_REALURL_SEGTITLEFIELDLIST_DEFAULT', 'tx_realurl_pathsegment,alias,nav_title,title,uid');
define('TX_REALURL_SEGTITLEFIELDLIST_PLO', 'tx_realurl_pathsegment,nav_title,title,uid');

// TYPO3 clean up handler
//$GLOBALS ['TYPO3_CONF_VARS']['EXTCONF']['lowlevel']['cleanerModules'][$_EXTKEY] = array('EXT:' . $_EXTKEY . '/class.tx_realurl_cleanuphandler.php:tx_realurl_cleanuphandler');

?>
38 changes: 11 additions & 27 deletions ext_tables.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
<?php
if (!defined ('TYPO3_MODE')) die ('Access denied.');

if (TYPO3_MODE=='BE') {
// \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule('tools','txrealurlM1','',\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY).'mod1/');
defined('TYPO3_MODE') or die ('Access denied.');

if (TYPO3_MODE == 'BE') {
// Add Web>Info module:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
'web_info',
"Tx\\Realurl\\Controller\\InfoModuleController",
"Tx\\Realurl\\View\\AdministrationModuleFunction",
'',
'LLL:EXT:realurl/Resources/Private/Language/locallang_db.xml:moduleFunction.tx_realurl_modfunc1',
'function',
'online'
);
}

if (version_compare(TYPO3_branch, '6.1', '<')) {
\TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('pages');
}
$TCA['pages']['columns'] += array(
$GLOBALS['TCA']['pages']['columns'] += array(
'tx_realurl_pathsegment' => array(
'label' => 'LLL:EXT:realurl/Resources/Private/Language/locallang_db.xml:pages.tx_realurl_pathsegment',
'displayCond' => 'FIELD:tx_realurl_exclude:!=:1',
Expand Down Expand Up @@ -61,29 +56,20 @@
)
);

$TCA["pages"]["ctrl"]["requestUpdate"] .= ",tx_realurl_exclude";
$GLOBALS["TCA"]["pages"]["ctrl"]["requestUpdate"] .= ",tx_realurl_exclude";

$TCA["pages"]["palettes"]["137"] = array(
$GLOBALS["TCA"]["pages"]["palettes"]["137"] = array(
'showitem' => 'tx_realurl_pathoverride'
);

if (\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('4.3')) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette('pages', '3', 'tx_realurl_nocache', 'after:cache_timeout');
}
if (\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('4.2')) {
// For 4.2 or new add fields to advanced page only
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', 'tx_realurl_pathsegment;;137;;,tx_realurl_exclude', '1', 'after:nav_title');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', 'tx_realurl_pathsegment;;137;;,tx_realurl_exclude', '4,199,254', 'after:title');
}
else {
// Put it for standard page
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', 'tx_realurl_pathsegment;;137;;,tx_realurl_exclude', '2', 'after:nav_title');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', 'tx_realurl_pathsegment;;137;;,tx_realurl_exclude', '1,5,4,199,254', 'after:title');
}

// Put it for standard page
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', 'tx_realurl_pathsegment;;137;;,tx_realurl_exclude', '2', 'after:nav_title');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', 'tx_realurl_pathsegment;;137;;,tx_realurl_exclude', '1,5,4,199,254', 'after:title');

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('pages','EXT:realurl/Resources/Private/Language/locallang_csh.xml');

$TCA["pages_language_overlay"]["columns"] += array(
$GLOBALS["TCA"]["pages_language_overlay"]["columns"] += array(
'tx_realurl_pathsegment' => array(
'label' => 'LLL:EXT:realurl/Resources/Private/Language/locallang_db.xml:pages.tx_realurl_pathsegment',
'exclude' => 1,
Expand All @@ -96,5 +82,3 @@
);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages_language_overlay', 'tx_realurl_pathsegment', '', 'after:nav_title');

?>

0 comments on commit f966e38

Please sign in to comment.