Commit 65bb0148 authored by speedprogs_de's avatar speedprogs_de

added titles to extension provider configuration and task

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@51569 735d13b6-9817-0410-8766-e36946ffe9aa
parent c16abd93
......@@ -71,6 +71,9 @@
}
$provider = $this->objectManager->get($configuration['class']);
if (!($provider instanceof Tx_TerFe2_ExtensionProvider_ProviderInterface)) {
throw new Exception('Provider "' . $name . '" does not implement the interface "Tx_TerFe2_ExtensionProvider_ProviderInterface"');
}
if (!empty($configuration['configuration']) && method_exists($provider, 'setConfiguration')) {
$provider->setConfiguration($configuration['configuration']);
}
......
......@@ -71,7 +71,7 @@
// Load configuration manager and set extension setup
// required to be loaded in object manager for persistence mapping
$configurationManager = $this->objectManager->get('Tx_Extbase_Configuration_ConfigurationManager');
$configurationManager->setConfiguration(Tx_TerFe2_Utility_TypoScript::getSetup());
$configurationManager->setConfiguration(Tx_TerFe2_Utility_TypoScript::getSetup('plugin.tx_terfe2'));
// Load provider manager
$this->providerManager = $this->objectManager->get('Tx_TerFe2_ExtensionProvider_ProviderManager');
......@@ -146,7 +146,12 @@
* @return string
*/
public function getAdditionalInformation() {
return ' ' . $this->providerName . ' ';
$title = ucfirst($this->providerName);
if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ter_fe2']['extensionProviders'][$this->providerName]['title'])) {
$title = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ter_fe2']['extensionProviders'][$this->providerName]['title'];
$title = Tx_Extbase_Utility_Localization::translate($title);
}
return ' ' . $title . ' ';
}
}
......
......@@ -81,7 +81,9 @@
// Add html structure for provider name field
$options = array();
if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ter_fe2']['extensionProviders'])) {
$options = array_keys($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ter_fe2']['extensionProviders']);
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ter_fe2']['extensionProviders'] as $key => $configuration) {
$options[$key] = (!empty($configuration['title']) ? $configuration['title'] : $key);
}
}
$additionalFields[$this->fields['providerName']] = array(
'code' => $this->getSelect($this->fields['providerName'], $options, $taskInfo[$this->fields['providerName']]),
......@@ -124,15 +126,18 @@
*
* @param string $fieldName Field name
* @param array $options Select options
* @param string $selectedOption Selected option
* @param string $selectedKey Selected option key
* @return string
*/
protected function getSelect($fieldName, array $options, $selectedOption = '') {
protected function getSelect($fieldName, array $options, $selectedKey = '') {
$html = array('<option></option>');
foreach ($options as $option) {
$selected = ($option === $selectedOption ? ' selected="selected"' : '');
$html[] = '<option' . $selected . '>' . $option . '</option>';
foreach ($options as $key => $option) {
$selected = ($key === $selectedKey ? ' selected="selected"' : '');
if ($key !== $option) {
$option = Tx_Extbase_Utility_Localization::translate($option);
}
$html[] = '<option value="' . $key . '"' . $selected . '>' . $option . '</option>';
}
return '<select name="tx_scheduler[' . $fieldName . ']">' . implode(PHP_EOL, $html) . '</select>';
......
......@@ -28,6 +28,11 @@
*/
class Tx_TerFe2_Utility_TypoScript {
/**
* @var object
*/
protected static $frontend;
/**
* @var tslib_cObj
*/
......@@ -50,14 +55,8 @@
self::$configurationManager = $objectManager->get('Tx_Extbase_Configuration_ConfigurationManager');
// Simulate Frontend
if (TYPO3_MODE == 'BE') {
Tx_Extbase_Utility_FrontendSimulator::simulateFrontendEnvironment();
if (empty($GLOBALS['TSFE']->sys_page)) {
$GLOBALS['TSFE']->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
}
if (empty($GLOBALS['TT'])) {
$GLOBALS['TT'] = t3lib_div::makeInstance('t3lib_TimeTrackNull');
}
if (TYPO3_MODE != 'FE') {
self::simulateFrontend();
self::$configurationManager->setContentObject($GLOBALS['TSFE']->cObj);
}
......@@ -66,10 +65,54 @@
if (empty(self::$contentObject)) {
self::$contentObject = t3lib_div::makeInstance('tslib_cObj');
}
}
/**
* Simulate a frontend environment
*
* @param tslib_cObj $cObj Instance of an content object
* @return void
*/
public static function simulateFrontend(tslib_cObj $cObj = NULL) {
// Make backup of current frontend
self::$frontend = (!empty($GLOBALS['TSFE']) ? $GLOBALS['TSFE'] : NULL);
// Create new frontend instance
$GLOBALS['TSFE'] = new stdClass();
$GLOBALS['TSFE']->cObjectDepthCounter = 100;
$GLOBALS['TSFE']->cObj = (!empty($cObj) ? $cObj: t3lib_div::makeInstance('tslib_cObj'));
if (empty($GLOBALS['TSFE']->sys_page)) {
$GLOBALS['TSFE']->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
}
// Reset Frontend if modified
if (TYPO3_MODE == 'BE') {
Tx_Extbase_Utility_FrontendSimulator::resetFrontendEnvironment();
if (empty($GLOBALS['TSFE']->tmpl)) {
$GLOBALS['TSFE']->tmpl = t3lib_div::makeInstance('t3lib_TStemplate');
$GLOBALS['TSFE']->tmpl->getFileName_backPath = PATH_site;
$GLOBALS['TSFE']->tmpl->init();
}
if (empty($GLOBALS['TT'])) {
$GLOBALS['TT'] = t3lib_div::makeInstance('t3lib_TimeTrackNull');
}
if (empty($GLOBALS['TSFE']->config)) {
$GLOBALS['TSFE']->config = t3lib_div::removeDotsFromTS(self::getSetup());
}
}
/**
* Reset an existing frontend environment
*
* @param object $frontend Instance of a frontend environemnt
* @return void
*/
public static function resetFrontend($frontend = NULL) {
$frontend = (!empty($frontend) ? $frontend : self::$frontend);
if (!empty($frontend)) {
$GLOBALS['TSFE'] = $frontend;
}
}
......@@ -77,9 +120,10 @@
/**
* Returns unparsed TypoScript setup
*
* @param string $typoScriptPath TypoScript path
* @return array TypoScript setup
*/
public static function getSetup() {
public static function getSetup($typoScriptPath = '') {
if (empty(self::$configurationManager)) {
self::initialize();
}
......@@ -87,12 +131,19 @@
$setup = self::$configurationManager->getConfiguration(
Tx_Extbase_Configuration_ConfigurationManager::CONFIGURATION_TYPE_FULL_TYPOSCRIPT
);
if (empty($typoScriptPath)) {
return $setup;
}
if (empty($setup['plugin.']['tx_terfe2.'])) {
return array();
$path = explode('.', $typoScriptPath);
foreach ($path as $segment) {
if (empty($setup[$segment . '.'])) {
return array();
}
$setup = $setup[$segment . '.'];
}
return $setup['plugin.']['tx_terfe2.'];
return $setup;
}
......@@ -114,33 +165,33 @@
}
// Parse configuration
$configuration = self::parseTypoScriptArray($configuration);
$configuration = t3lib_div::removeDotsFromTS($configuration);
return $configuration;
return self::parseTypoScriptArray($configuration);
}
/**
* Parse TypoScript configuration
* Parse TypoScript array
*
* @param array $configuration TypoScript configuration
* @param array $configuration TypoScript configuration array
* @return array Parsed configuration
* @api
*/
protected static function parseTypoScriptArray(array $configuration) {
public static function parseTypoScriptArray(array $configuration) {
$typoScriptArray = array();
foreach ($configuration as $key => $value) {
$ident = rtrim($key, '.');
if (is_array($value)) {
if (!empty($configuration[$ident])) {
$typoScriptArray[$ident] = self::$contentObject->cObjGetSingle($configuration[$ident], $value);
if (is_array($configuration)) {
foreach ($configuration as $key => $value) {
$ident = rtrim($key, '.');
if (is_array($value)) {
if (!empty($configuration[$ident])) {
$typoScriptArray[$ident] = self::$contentObject->cObjGetSingle($configuration[$ident], $value);
} else {
$typoScriptArray[$ident] = self::parseTypoScriptArray($value);
}
unset($configuration[$key]);
} else {
$typoScriptArray[$key] = self::parseTypoScriptArray($value);
} else if (is_string($value) && $key === $ident) {
$typoScriptArray[$key] = $value;
}
} else if (is_string($value) && $key == $ident) {
$typoScriptArray[$key] = $value;
}
}
......
......@@ -60,7 +60,10 @@
<label index="tx_terfe2_task_updateextensionlisttask.name">Get new extensions</label>
<label index="tx_terfe2_task_updateextensionlisttask.description">Get new extensions in ter directory</label>
<label index="tx_terfe2_task_updateextensionlisttask.extensionsPerRun">Count of extensions to process at once</label>
<label index="tx_terfe2_task_updateextensionlisttask.providerName">Fetch extensions from this provider</label>
<label index="tx_terfe2_task_updateextensionlisttask.providerName">Fetch extensions from this source</label>
<label index="tx_terfe2_extensionprovider_extensionmanagerprovider.name">Local Extension Manager</label>
<label index="tx_terfe2_extensionprovider_fileprovider.name">Local Filesystem</label>
<label index="tx_terfe2_extensionprovider_soapprovider.name">SOAP Server</label>
<label index="msg.extension_created">Extension created</label>
<label index="msg.extension_updated">Extension updated</label>
......
......@@ -27,12 +27,14 @@
}
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$_EXTKEY]['extensionProviders']['extensionmanager'] = array(
'class' => 'Tx_TerFe2_ExtensionProvider_ExtensionManagerProvider',
'title' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang.xml:tx_terfe2_extensionprovider_extensionmanagerprovider.name',
'configuration' => array(
'repositoryId' => 1,
),
);
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$_EXTKEY]['extensionProviders']['file'] = array(
'class' => 'Tx_TerFe2_ExtensionProvider_FileProvider',
'title' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang.xml:tx_terfe2_extensionprovider_fileprovider.name',
'configuration' => array(
'extensionRootPath' => 'fileadmin/ter/',
'extensionListFile' => 'typo3temp/extensions.xml.gz',
......@@ -40,6 +42,7 @@
);
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$_EXTKEY]['extensionProviders']['soap'] = array(
'class' => 'Tx_TerFe2_ExtensionProvider_SoapProvider',
'title' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang.xml:tx_terfe2_extensionprovider_soapprovider.name',
'configuration' => array(
'wsdlUrl' => '',
'username' => '',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment