Project

General

Profile

Bug #15663 » em_1638.diff

Administrator Admin, 2006-07-15 14:18

View differences:

class.em_index.php 2006-07-14 20:22:53.193817600 +0200
define('EM_INSTALL_VERSION_MAX', 2);
define('EM_INSTALL_VERSION_STRICT', 3);
if (!defined ('PATH_tslib')) {
define('PATH_tslib', '../../../sysext/cms/tslib/');
}
require_once(PATH_tslib.'class.tslib_content.php');
require_once(PATH_tslib.'class.tslib_pibase.php');
require_once('class.em_tslib_pibase.php');
/**
* Module: Extension manager
*
......
var $lookUpStr; // Search string when listing local extensions
var $defaultStatesString = 'alpha,beta,stable,experimental,test,obsolete';
var $defaultCatString = ',be,module,fe,plugin,misc,services,templates,example,doc';
var $order = array ('DESC' => 'ASC', 'ASC' => 'DESC');
function memory_get_usage() {
//If its Windows
//Tested on Win XP Pro SP2. Should work on Win 2003 Server too
//Doesn't work for 2000
//If you need it to work for 2000 look at http://us2.php.net/manual/en/function.memory-get-usage.php#54642
if ( substr(PHP_OS,0,3) == 'WIN') {
$output = array();
exec( 'tasklist /FI "PID eq ' . getmypid() . '" /FO LIST', $output );
return preg_replace( '/[\D]/', '', $output[5] ) * 1024;
} else {
//We now assume the OS is UNIX
//Tested on Mac OS X 10.4.6 and Linux Red Hat Enterprise 4
//This should work on most UNIX systems
$pid = getmypid();
exec("ps -eo%mem,rss,pid | grep $pid", $output);
$output = explode(" ", $output[0]);
//rss is given in 1024 byte units
return $output[1] * 1024;
}
}
/*********************************
*
......
}
}
/**
* Configuration of which mod-menu items can be used
*
* @return void
*/
function menuConfig() {
global $BE_USER, $TYPO3_CONF_VARS;
// MENU-ITEMS:
$this->MOD_MENU = array(
'function' => array(
0 => 'Loaded extensions',
1 => 'Install extensions',
2 => 'Import extensions',
4 => 'Translation handling',
3 => 'Settings',
),
'listOrder' => array(
'cat' => 'Category',
'author_company' => 'Author',
'state' => 'State',
'type' => 'Type'
),
'display_details' => array(
1 => 'Details',
0 => 'Description',
2 => 'More details',
3 => 'Technical (takes time!)',
4 => 'Validating (takes time!)',
5 => 'Changed? (takes time!)',
/**
* Configuration of which mod-menu items can be used
*
* @return void
*/
function menuConfig() {
global $BE_USER, $TYPO3_CONF_VARS;
// MENU-ITEMS:
$this->MOD_MENU = array(
'function' => array(
0 => 'Loaded extensions',
1 => 'Install extensions',
2 => 'Import extensions',
4 => 'Translation handling',
3 => 'Settings',
),
'display_shy' => '',
'display_own' => '',
'display_unchecked' => '',
'display_obsolete' => '',
'singleDetails' => array(
'info' => 'Information',
'edit' => 'Edit files',
'backup' => 'Backup/Delete',
'dump' => 'Dump DB',
'upload' => 'Upload to TER',
'updateModule' => 'UPDATE!',
'cat' => array (
'all' => 'All',
'be' => 'Backend',
'module' => 'Backend Modules',
'fe' => 'Frontend',
'plugin' => 'Frontend Plugins',
'misc' => 'Miscellaneous',
'services' => 'Services',
'templates' => 'Templates',
'example' => 'Examples',
'doc' => 'Documentation',
'' => 'Noname'
),
'fe_u' => '',
'fe_p' => '',
'mirrorListURL' => '',
'rep_url' => '',
'extMirrors' => '',
'selectedMirror' => '',
'selectedLanguages' => ''
);
$this->MOD_MENU['singleDetails'] = $this->mergeExternalItems($this->MCONF['name'],'singleDetails',$this->MOD_MENU['singleDetails']);
// page/be_user TSconfig settings and blinding of menu-items
if (!$BE_USER->getTSConfigVal('mod.'.$this->MCONF['name'].'.allowTVlisting')) {
unset($this->MOD_MENU['display_details'][3]);
unset($this->MOD_MENU['display_details'][4]);
unset($this->MOD_MENU['display_details'][5]);
}
// CLEANSE SETTINGS
$this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
if ($this->MOD_SETTINGS['function']==2) {
// If listing from online repository, certain items are removed though:
unset($this->MOD_MENU['listOrder']['type']);
unset($this->MOD_MENU['display_details'][2]);
unset($this->MOD_MENU['display_details'][3]);
unset($this->MOD_MENU['display_details'][4]);
unset($this->MOD_MENU['display_details'][5]);
$this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
}
parent::menuConfig();
}
/**
* Main function for Extension Manager module.
*
* @return void
*/
function main() {
'state' => Array (
'all' => 'All',
'alpha' => 'Alpha',
'beta' => 'Beta',
'stable' => 'Stable',
'experimental' => 'Experimental',
'test' => 'Test',
'obsolete' => 'Obsolete',
),
'listOrder' => array(
'cat' => 'Category',
'author_company' => 'Author',
'state' => 'State',
),
'display_details' => array(
1 => 'Details',
0 => 'Description',
2 => 'More details',
3 => 'Technical (takes time!)',
4 => 'Validating (takes time!)',
5 => 'Changed? (takes time!)',
),
'display_shy' => '',
'display_own' => '',
'display_unsupported' => '',
'display_obsolete' => '',
'singleDetails' => array(
'info' => 'Information',
'edit' => 'Edit files',
'backup' => 'Backup/Delete',
'dump' => 'Dump DB',
'upload' => 'Upload to TER',
'updateModule' => 'UPDATE!',
),
'fe_u' => '',
'fe_p' => '',
'mirrorListURL' => '',
'rep_url' => '',
'extMirrors' => '',
'selectedMirror' => '',
'selectedLanguages' => ''
);
$this->MOD_MENU['singleDetails'] = $this->mergeExternalItems($this->MCONF['name'],'singleDetails',$this->MOD_MENU['singleDetails']);
// page/be_user TSconfig settings and blinding of menu-items
if (!$BE_USER->getTSConfigVal('mod.'.$this->MCONF['name'].'.allowTVlisting')) {
unset($this->MOD_MENU['display_details'][3]);
unset($this->MOD_MENU['display_details'][4]);
unset($this->MOD_MENU['display_details'][5]);
}
// CLEANSE SETTINGS
$this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
if ($this->MOD_SETTINGS['function']==2) {
// If listing from online repository, certain items are removed though:
unset($this->MOD_MENU['listOrder']['type']);
unset($this->MOD_MENU['display_details'][2]);
unset($this->MOD_MENU['display_details'][3]);
unset($this->MOD_MENU['display_details'][4]);
unset($this->MOD_MENU['display_details'][5]);
$this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
}
t3lib_SCbase::menuConfig();
}
/**
* Main function for Extension Manager module.
*
* @return void
*/
function main() {
global $BE_USER,$LANG,$TYPO3_CONF_VARS;
if (empty($this->MOD_SETTINGS['mirrorListURL'])) $this->MOD_SETTINGS['mirrorListURL'] = $TYPO3_CONF_VARS['EXT']['em_mirrorListURL'];
// Starting page:
$this->content.=$this->doc->startPage('Extension Manager');
$this->content.=$this->doc->header('Extension Manager');
$this->content.=$this->doc->spacer(5);
// Commands given which is executed regardless of main menu setting:
if ($this->CMD['showExt']) { // Show details for a single extension
$this->showExtDetails($this->CMD['showExt']);
} elseif ($this->CMD['requestInstallExtensions']) { // Show details for a single extension
$this->requestInstallExtensions($this->CMD['requestInstallExtensions']);
} elseif ($this->CMD['importExt'] || $this->CMD['uploadExt']) { // Imports an extension from online rep.
$err = $this->importExtFromRep($this->CMD['importExt'],$this->CMD['extVersion'],$this->CMD['loc'],$this->CMD['uploadExt']);
if ($err) {
$this->content.=$this->doc->section('',$GLOBALS['TBE_TEMPLATE']->rfw($err));
}
if(!$err && $this->CMD['importExt']) {
$this->installTranslationsForExtension($this->CMD['importExt'], $this->getMirrorURL());
}
} elseif ($this->CMD['importExtInfo']) { // Gets detailed information of an extension from online rep.
$this->importExtInfo($this->CMD['importExtInfo'],$this->CMD['extVersion']);
} else { // No command - we show what the menu setting tells us:
$menu = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.menu').' '.
t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']);
if (t3lib_div::inList('0,1,2',$this->MOD_SETTINGS['function'])) {
$menu.=' Group by: '.t3lib_BEfunc::getFuncMenu(0,'SET[listOrder]',$this->MOD_SETTINGS['listOrder'],$this->MOD_MENU['listOrder']).
'&nbsp;&nbsp;Show:&nbsp;'.t3lib_BEfunc::getFuncMenu(0,'SET[display_details]',$this->MOD_SETTINGS['display_details'],$this->MOD_MENU['display_details']).'<br />';
}
if (t3lib_div::inList('0,1',$this->MOD_SETTINGS['function'])) {
$menu.='Display shy extensions:&nbsp;&nbsp;'.t3lib_BEfunc::getFuncCheck(0,'SET[display_shy]',$this->MOD_SETTINGS['display_shy']);
}
if (t3lib_div::inList('2',$this->MOD_SETTINGS['function']) && strlen($this->fe_user['username'])) {
$menu.='Only my extensions:&nbsp;&nbsp;'.t3lib_BEfunc::getFuncCheck(0,'SET[display_own]',$this->MOD_SETTINGS['display_own']);
}
if (t3lib_div::inList('0,1,2',$this->MOD_SETTINGS['function'])) {
$menu.='&nbsp;&nbsp;Show obsolete:&nbsp;&nbsp;'.t3lib_BEfunc::getFuncCheck(0,'SET[display_obsolete]',$this->MOD_SETTINGS['display_obsolete']);
}
$this->content.=$this->doc->section('','<span class="nobr">'.$menu.'</span>');
$this->content.=$this->doc->spacer(10);
switch((string)$this->MOD_SETTINGS['function']) {
case '0':
// Lists loaded (installed) extensions
$this->extensionList_loaded();
break;
case '1':
// Lists the installed (available) extensions
$this->extensionList_installed();
break;
case '2':
// Lists the extensions available from online rep.
$this->extensionList_import();
break;
case '3':
// Shows the settings screen
$this->alterSettings();
break;
case '4':
// Allows to set the translation preferences and check the status
$this->translationHandling();
break;
default:
$this->extObjContent();
break;
}
}
// Shortcuts:
if ($BE_USER->mayMakeShortcut()) {
$this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon('CMD','function',$this->MCONF['name']));
}
if (empty($this->MOD_SETTINGS['mirrorListURL'])) $this->MOD_SETTINGS['mirrorListURL'] = $TYPO3_CONF_VARS['EXT']['em_mirrorListURL'];
// Starting page:
$this->content.=$this->doc->startPage('Extension Manager');
$this->content.=$this->doc->header('Extension Manager');
$this->content.=$this->doc->spacer(5);
// Commands given which is executed regardless of main menu setting:
if ($this->CMD['showExt']) { // Show details for a single extension
$this->showExtDetails($this->CMD['showExt']);
} elseif ($this->CMD['requestInstallExtensions']) { // Show details for a single extension
$this->requestInstallExtensions($this->CMD['requestInstallExtensions']);
} elseif ($this->CMD['importExt'] || $this->CMD['uploadExt']) { // Imports an extension from online rep.
$err = $this->importExtFromRep($this->CMD['importExt'],$this->CMD['extVersion'],$this->CMD['loc'],$this->CMD['uploadExt']);
if ($err) {
$this->content.=$this->doc->section('',$GLOBALS['TBE_TEMPLATE']->rfw($err));
}
if(!$err && $this->CMD['importExt']) {
$this->installTranslationsForExtension($this->CMD['importExt'], $this->getMirrorURL());
}
} elseif ($this->CMD['importExtInfo']) { // Gets detailed information of an extension from online rep.
$this->importExtInfo($this->CMD['importExtInfo'],$this->CMD['extVersion']);
} else { // No command - we show what the menu setting tells us:
$menu = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.menu').' '.
t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']);
if (t3lib_div::inList('2',$this->MOD_SETTINGS['function']) && t3lib_div::inList('state',$this->MOD_SETTINGS['listOrder'])) {
$menu.='Category:&nbsp;&nbsp;'.t3lib_BEfunc::getFuncMenu(0,'SET[state]',$this->MOD_SETTINGS['state'],$this->MOD_MENU['state']).
'&nbsp;&nbsp;Group by:&nbsp;'.t3lib_BEfunc::getFuncMenu(0,'SET[listOrder]',$this->MOD_SETTINGS['listOrder'],$this->MOD_MENU['listOrder']).
'&nbsp;&nbsp;Show:&nbsp;'.t3lib_BEfunc::getFuncMenu(0,'SET[display_details]',$this->MOD_SETTINGS['display_details'],$this->MOD_MENU['display_details']).'<br />';
}
if ( t3lib_div::inList('2',$this->MOD_SETTINGS['function']) && t3lib_div::inList('cat',$this->MOD_SETTINGS['listOrder'])) {
$menu.='Category:&nbsp;&nbsp;'.t3lib_BEfunc::getFuncMenu(0,'SET[cat]',$this->MOD_SETTINGS['cat'],$this->MOD_MENU['cat']).
'&nbsp;&nbsp;Group by:&nbsp;'.t3lib_BEfunc::getFuncMenu(0,'SET[listOrder]',$this->MOD_SETTINGS['listOrder'],$this->MOD_MENU['listOrder']).
'&nbsp;&nbsp;Show:&nbsp;'.t3lib_BEfunc::getFuncMenu(0,'SET[display_details]',$this->MOD_SETTINGS['display_details'],$this->MOD_MENU['display_details']).'<br />';
}
if ( t3lib_div::inList('2',$this->MOD_SETTINGS['function']) && t3lib_div::inList('author_company',$this->MOD_SETTINGS['listOrder'])) {
$menu.='Group by:&nbsp;'.t3lib_BEfunc::getFuncMenu(0,'SET[listOrder]',$this->MOD_SETTINGS['listOrder'],$this->MOD_MENU['listOrder']).
'&nbsp;&nbsp;Show:&nbsp;'.t3lib_BEfunc::getFuncMenu(0,'SET[display_details]',$this->MOD_SETTINGS['display_details'],$this->MOD_MENU['display_details']).'<br />';
}
if (t3lib_div::inList('0,1',$this->MOD_SETTINGS['function'])) {
$menu.='Group by:&nbsp;'.t3lib_BEfunc::getFuncMenu(0,'SET[listOrder]',$this->MOD_SETTINGS['listOrder'],$this->MOD_MENU['listOrder']).
'&nbsp;&nbsp;Show:&nbsp;'.t3lib_BEfunc::getFuncMenu(0,'SET[display_details]',$this->MOD_SETTINGS['display_details'],$this->MOD_MENU['display_details']).'<br />';
}
if (t3lib_div::inList('0,1',$this->MOD_SETTINGS['function'])) {
$menu.='Display shy extensions:&nbsp;&nbsp;'.t3lib_BEfunc::getFuncCheck(0,'SET[display_shy]',$this->MOD_SETTINGS['display_shy']);
}
if (t3lib_div::inList('2',$this->MOD_SETTINGS['function']) && strlen($this->fe_user['username'])) {
$menu.='Only my extensions:&nbsp;&nbsp;'.t3lib_BEfunc::getFuncCheck(0,'SET[display_own]',$this->MOD_SETTINGS['display_own']);
}
if (t3lib_div::inList('0,1,2',$this->MOD_SETTINGS['function'])) {
$menu.='&nbsp;&nbsp;Show obsolete:&nbsp;&nbsp;'.t3lib_BEfunc::getFuncCheck(0,'SET[display_obsolete]',$this->MOD_SETTINGS['display_obsolete']);
}
$this->content.=$this->doc->section('','<span class="nobr">'.$menu.'</span>');
$this->content.=$this->doc->spacer(10);
switch((string)$this->MOD_SETTINGS['function']) {
case '0':
// Lists loaded (installed) extensions
$this->extensionList_loaded();
break;
case '1':
// Lists the installed (available) extensions
$this->extensionList_installed();
break;
case '2':
// Lists the extensions available from online rep.
$this->extensionList_import();
break;
case '3':
// Shows the settings screen
$this->alterSettings();
break;
case '4':
// Allows to set the translation preferences and check the status
$this->translationHandling();
break;
default:
$this->extObjContent();
break;
}
}
// Shortcuts:
if ($BE_USER->mayMakeShortcut()) {
$this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon('CMD','function',$this->MCONF['name']));
}
}
/**
......
}
}
/**
* Listing remote extensions from online repository
*
* @return void
*/
function extensionList_import() {
global $TYPO3_LOADED_EXT;
/**
* Listing remote extensions from online repository
*
* @return void
*/
function extensionList_import() {
global $TYPO3_LOADED_EXT;
$content='';
// Listing from online repository:
// Listing from online repository:
if ($this->listRemote) {
list($inst_list,) = $this->getInstalledExtensions();
$this->inst_keys = array_flip(array_keys($inst_list));
$this->detailCols[1]+=6;
// see if we have an extensionlist at all
$this->xmlhandler->loadExtensionsXML();
if (!count($this->xmlhandler->extensionsXML)) {
$content .= $this->fetchMetaData('extensions');
}
if($this->MOD_SETTINGS['display_own'] && strlen($this->fe_user['username'])) {
$this->xmlhandler->searchExtensionsXML($this->listRemote_search, $this->fe_user['username']);
} else {
$this->xmlhandler->searchExtensionsXML($this->listRemote_search);
}
if (count($this->xmlhandler->extensionsXML)) {
list($list,$cat) = $this->prepareImportExtList();
// Available extensions
if (is_array($cat[$this->MOD_SETTINGS['listOrder']])) {
$lines=array();
$lines[]=$this->extensionListRowHeader(' class="bgColor5"',array('<td><img src="clear.gif" width="18" height="1" alt="" /></td>'),1);
foreach($cat[$this->MOD_SETTINGS['listOrder']] as $catName => $extEkeys) {
if (count($extEkeys)) {
$lines[]='<tr><td colspan="'.(3+$this->detailCols[$this->MOD_SETTINGS['display_details']]).'"><br /></td></tr>';
$lines[]='<tr><td colspan="'.(3+$this->detailCols[$this->MOD_SETTINGS['display_details']]).'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/i/sysf.gif" width="18" height="16" align="top" alt="" /><strong>'.$this->listOrderTitle($this->MOD_SETTINGS['listOrder'],$catName).'</strong></td></tr>';
natcasesort($extEkeys);
reset($extEkeys);
while(list($extKey)=each($extEkeys)) {
$version = array_keys($list[$extKey]['versions']);
$version = end($version);
$ext = $list[$extKey]['versions'][$version];
$ext['downloadcounter_all'] = $list[$extKey]['downloadcounter'];
$ext['_ICON'] = $list[$extKey]['_ICON'];
$loadUnloadLink='';
if ($inst_list[$extKey]['type']!='S' && (!isset($inst_list[$extKey]) || $this->versionDifference($version,$inst_list[$extKey]['EM_CONF']['version'],$this->versionDiffFactor))) {
if (isset($inst_list[$extKey])) {
// update
$loc= ($inst_list[$extKey]['type']=='G'?'G':'L');
$aUrl = 'index.php?CMD[importExt]='.$extKey.'&CMD[extVersion]='.$version.'&CMD[loc]='.$loc;
$loadUnloadLink.= '<a href="'.htmlspecialchars($aUrl).'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/import_update.gif" width="12" height="12" title="Update the extension in \''.($loc=='G'?'global':'local').'\' from online repository to server" alt="" /></a>';
} else {
// import
$aUrl = 'index.php?CMD[importExt]='.$extKey.'&CMD[extVersion]='.$version.'&CMD[loc]=L';
$loadUnloadLink.= '<a href="'.htmlspecialchars($aUrl).'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/import.gif" width="12" height="12" title="Import this extension to \'local\' dir typo3conf/ext/ from online repository." alt="" /></a>';
}
} else {
$loadUnloadLink = '&nbsp;';
}
if (isset($inst_list[$extKey])) {
$theRowClass = t3lib_extMgm::isLoaded($extKey) ? 'em-listbg1' : 'em-listbg2';
} else {
$theRowClass = 'em-listbg3';
}
$lines[]=$this->extensionListRow($extKey,$ext,array('<td class="bgColor">'.$loadUnloadLink.'</td>'),$theRowClass,$inst_list,1,'index.php?CMD[importExtInfo]='.rawurlencode($extKey));
}
}
}
// CSH:
$content.= t3lib_BEfunc::cshItem('_MOD_tools_em', 'import_ter', $GLOBALS['BACK_PATH'],'|<br/>');
$onsubmit = "window.location.href='index.php?ter_connect=1&ter_search='+escape(this.elements['_lookUp'].value);return false;";
$content.= '</form><form action="index.php" method="post" onsubmit="'.htmlspecialchars($onsubmit).'">List or look up extensions<br />
<input type="text" name="_lookUp" value="'.htmlspecialchars($this->listRemote_search).'" /> <input type="submit" value="Look up" /><br /><br />';
$content.= '
<!-- TER Extensions list -->
<table border="0" cellpadding="2" cellspacing="1">'.implode(chr(10),$lines).'</table>';
$content.= '<br /><br /><strong>PRIVACY NOTICE:</strong><br /> '.$this->privacyNotice;
$this->content.=$this->doc->section('Extensions in TYPO3 Extension Repository (online) - Grouped by: '.$this->MOD_MENU['listOrder'][$this->MOD_SETTINGS['listOrder']],$content,0,1);
// Plugins which are NOT uploaded to repository but present on this server.
$content='';
$lines=array();
if (count($this->inst_keys)) {
reset($this->inst_keys);
while(list($extKey)=each($this->inst_keys)) {
if(strlen($this->listRemote_search) && !stristr($extKey,$this->listRemote_search)) continue;
$loadUnloadLink = t3lib_extMgm::isLoaded($extKey)?
'<a href="'.htmlspecialchars('index.php?CMD[showExt]='.$extKey.'&CMD[remove]=1&CMD[clrCmd]=1&SET[singleDetails]=info').'">'.$this->removeButton().'</a>':
'<a href="'.htmlspecialchars('index.php?CMD[showExt]='.$extKey.'&CMD[load]=1&CMD[clrCmd]=1&SET[singleDetails]=info').'">'.$this->installButton().'</a>';
if (in_array($extKey,$this->requiredExt)) $loadUnloadLink='<strong>'.$GLOBALS['TBE_TEMPLATE']->rfw('Rq').'</strong>';
$lines[]=$this->extensionListRow($extKey,$inst_list[$extKey],array('<td class="bgColor">'.$loadUnloadLink.'</td>'),t3lib_extMgm::isLoaded($extKey)?'em-listbg1':'em-listbg2');
}
}
if(count($lines)) {
$content.= 'This is the list of extensions which are available locally, but not in the repository.<br />The might be user-defined and should be prepended user_ then.<br /><br />';
$content.= '<table border="0" cellpadding="2" cellspacing="1">'.
$this->extensionListRowHeader(' class="bgColor5"',array('<td><img src="clear.gif" width="18" height="1" alt="" /></td>')).
implode('',$lines).'</table>';
$this->content.=$this->doc->spacer(20);
$this->content.=$this->doc->section('Extensions found only on this server',$content,0,1);
}
}
} else {
$content.= t3lib_BEfunc::cshItem('_MOD_tools_em', 'import_ter', $GLOBALS['BACK_PATH'],'|<br/>');
$onsubmit = "window.location.href='index.php?ter_connect=1&ter_search='+escape(this.elements['_lookUp'].value);return false;";
$content.= '</form><form action="index.php" method="post" onsubmit="'.htmlspecialchars($onsubmit).'">List or look up extensions<br />
<input type="text" name="_lookUp" value="'.htmlspecialchars($this->listRemote_search).'" /> <input type="submit" value="Look up" /><br /><br />';
$content.= '<p><strong>No matching extensions found.</strong></p>';
$content.= '<br /><br /><strong>PRIVACY NOTICE:</strong><br /> '.$this->privacyNotice;
$this->content.=$this->doc->section('Extensions in TYPO3 Extension Repository (online) - Grouped by: '.$this->MOD_MENU['listOrder'][$this->MOD_SETTINGS['listOrder']],$content,0,1);
}
} else {
// CSH
$content.= t3lib_BEfunc::cshItem('_MOD_tools_em', 'import', $GLOBALS['BACK_PATH'],'|<br/>');
$onsubmit = "window.location.href='index.php?ter_connect=1&ter_search='+escape(this.elements['_lookUp'].value);return false;";
$content.= '</form><form action="index.php" method="post" onsubmit="'.htmlspecialchars($onsubmit).'">List or look up <strong'.($this->MOD_SETTINGS['display_unchecked']?' style="color:#900;">all':' style="color:#090;">reviewed').'</strong> extensions<br />
<input type="text" name="_lookUp" value="" /> <input type="submit" value="Look up" /><br /><br />';
if ($this->CMD['fetchMetaData']) { // fetches mirror/extension data from online rep.
$content .= $this->fetchMetaData($this->CMD['fetchMetaData']);
} else {
$onCLick = "window.location.href='index.php?CMD[fetchMetaData]=extensions';return false;";
$content.= 'Connect to the current mirror and retrieve the current list of available plugins from the TYPO3 Extension Repository.<br />
<input type="submit" value="Retrieve/Update" onclick="'.htmlspecialchars($onCLick).'" />';
if(is_file(PATH_site.'typo3temp/extensions.bin')) {
$content .= ' (last update: '.date('Y-m-d H:i',filemtime(PATH_site.'typo3temp/extensions.bin')).')';
}
}
list($inst_list,) = $this->getInstalledExtensions();
$this->inst_keys = array_flip(array_keys($inst_list));
$this->detailCols[1]+=6;
$group = $this->MOD_SETTINGS['listOrder'];
$cat = $this->MOD_SETTINGS[$group];
$lookup = array ('cat' => array (
'be' => 'AND tx_chlightem_extension.category="be"',
'module' => 'AND tx_chlightem_extension.category="module"',
'fe' => 'AND tx_chlightem_extension.category="fe"',
'plugin' => 'AND tx_chlightem_extension.category="plugin"',
'misc' => 'AND tx_chlightem_extension.category="misc"',
'services' => 'AND tx_chlightem_extension.category="services"',
'templates' => 'AND tx_chlightem_extension.category="templates"',
'example' => 'AND tx_chlightem_extension.category="example"',
'doc' => 'AND tx_chlightem_extension.category="doc"',
'' => 'AND tx_chlightem_extension.category=""',
),
'state' => array (
'alpha' => 'AND tx_chlightem_extension.extstate="alpha"',
'beta' => 'AND tx_chlightem_extension.extstate="beta"',
'stable' => 'AND tx_chlightem_extension.extstate="stable"',
'experimental' => 'AND tx_chlightem_extension.extstate="experimental"',
'test' => 'AND tx_chlightem_extension.extstate="test"',
'obsolete' => 'AND tx_chlightem_extension.extstate="obsolete"',
),
'author_company' => array (
'author_company' => '',
),
);
$cmd = $lookup[$group][$cat];
if (!$this->MOD_SETTINGS['display_obsolete']) {
$cmd .= ' AND tx_chlightem_extension.extstate !="obsolete"';
}
if (!$this->MOD_SETTINGS['display_unsupported']) {
$cmd .= ' AND tx_chlightem_extension.reviewstate > 0';
}
if ($this->listRemote_search) {
$cmd .= ' AND tx_chlightem_extension.extkey LIKE "%'.$this->listRemote_search.'%"';
}
if($this->MOD_SETTINGS['display_own'] && strlen($this->fe_user['username'])) {
$cmd .= ' AND tx_chlightem_extension.ownerusername="'.$this->fe_user['username'].'"';
}
$results_at_a_time = 25;
$piBase = t3lib_div::makeInstance('em_tslib_pibase');
$piBase->cObj = t3lib_div::makeInstance('tslib_cObj');
if (t3lib_div::_GP('ter_pointer') != t3lib_div::_GP('t9r_backup') ) {
$piBase->ter_pointer = $_GET['t9r_backup'] = t3lib_div::_GP('ter_pointer');
$order = t3lib_div::_GP('ter_order');
} else {
$piBase->ter_pointer = t3lib_div::_GP('ter_pointer');
if (t3lib_div::_GP('ter_order')) {
$order = $this->order[t3lib_div::_GP('ter_order')];
$_GET['ter_order'] = $order;
} else {
$order = 'ASC';
}
}
if (t3lib_div::_GP('ter_sort')) {
$sort = t3lib_div::_GP('ter_sort');
} else {
$sort = 'extkey';
}
if ($group == 'author_company') {
$sort = 'ownerusername';
}
// Initializing the query parameters:
$piBase->internal["results_at_a_time"]=t3lib_div::intInRange($results_at_a_time,0,1000,9); // Number of results to show in a listing.
$pibase->internal['results_at_a_time'] = $results_at_a_time;
$piBase->internal["maxPages"]=t3lib_div::intInRange(5,0,1000,2); // The maximum number of "pages" in the browse-box: "Page 1", "Page 2", etc.
$piBase->internal["searchFieldList"]='';
$piBase->internal["orderByList"]= 'extkey,downloadcounter,category,extstate,version,title,ownerusername,lastuploaddate';
$piBase->internal["orderBy"] = $sort;
$piBase->internal["descFlag"] = $order;
$piBase->internal["currentTable"] = "tx_chlightem_extension";
$piBase->internal['pagefloat'] = 'center';
// Get number of records:
$res = $piBase->pi_exec_query('tx_chlightem_extension',1,$cmd);
list($piBase->internal['res_count']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
$lines=array();
$lines[]=$this->extensionListRowHeader(' class="bgColor5"',array('<td><img src="clear.gif" width="18" height="1" alt="" /></td>'),1);
$lines[]='<tr><td colspan="'.(3+$this->detailCols[$this->MOD_SETTINGS['display_details']]).'"><br /></td></tr>';
$lines[]='<tr><td colspan="'.(3+$this->detailCols[$this->MOD_SETTINGS['display_details']]).'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/i/sysf.gif" width="18" height="16" align="top" alt="" /><strong>'.$this->listOrderTitle($this->MOD_SETTINGS['listOrder'],$cat).'</strong></td></tr>';
$this->xmlhandler->extensionsXML = array();
// Make listing query, pass query to SQL database:
$res = $piBase->pi_exec_query('tx_chlightem_extension','',$cmd);
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$this->xmlhandler->extensionsXML[$row['extkey']]['extkey']=$row['extkey'];
$this->xmlhandler->extensionsXML[$row['extkey']]['uid']=$row['uid'];
$this->xmlhandler->extensionsXML[$row['extkey']]['downloadcounter']=$row['downloadcounter'];
$this->xmlhandler->extensionsXML[$row['extkey']]['icon']=$row['icon'];
$this->xmlhandler->extensionsXML[$row['extkey']]['type']=$row['type'];
$this->xmlhandler->extensionsXML[$row['extkey']]['lastuploaddate']=$row['lastuploaddate'];
}
mysql_free_result($res);
foreach ($this->xmlhandler->extensionsXML as $k => $v) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('*','tx_chlightem_extension','tx_chlightem_mm','tx_chlightem_version','AND tx_chlightem_extension.uid='.$v['uid']);
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['version']=$row['version'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['title']=$row['title'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['description']=$row['description'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['state']=$row['extstate'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['reviewstate']=$row['reviewstate'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['lastuploaddate']=$row['lastuploaddate'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['constraints']=unserialize($row['dependencies']);
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['author']=$row['authorname'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['author_email']=$row['authoremail'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['author_company']=$row['authorcompany'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['ownerusername']=$row['ownerusername'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['t3xfilemd5']=$row['t3xfilemd5'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['category']=$row['category'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['uploadcomment']=$row['uploadcomment'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['downloadcounter']=$row['downloadcounter'];
}
}
mysql_free_result($res);
if (count($this->xmlhandler->extensionsXML)) {
foreach ($this->xmlhandler->extensionsXML as $k => $v) {
// Unset extension key in installed keys array (for tracking)
if(isset($this->emObj->inst_keys[$k])) unset($this->emObj->inst_keys[$k]);
$version = end(array_keys($v['versions']));
$ext = $v['versions'][$version];
$ext['downloadcounter_all'] = $v['downloadcounter'];
$ext['downloadcounter'] = $ext['EM_CONF']['downloadcounter'];
$ext['_ICON'] = $v['icon'];
$loadUnloadLink='';
if ($inst_list[$v['extkey']]['type']!='S' && (!isset($inst_list[$v['extkey']]) || $this->versionDifference($version,$inst_list[$v['extkey']]['EM_CONF']['version'],$this->versionDiffFactor))) {
if (isset($inst_list[$v['extkey']])) {
// update
$loc= ($inst_list[$v['extkey']]['type']=='G'?'G':'L');
$aUrl = 'index.php?CMD[importExt]='.$v['extkey'].'&CMD[extVersion]='.$version.'&CMD[loc]='.$loc;
$loadUnloadLink.= '<a href="'.htmlspecialchars($aUrl).'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/import_update.gif" width="12" height="12" title="Update the extension in \''.($loc=='G'?'global':'local').'\' from online repository to server" alt="" /></a>';
} else {
// import
$aUrl = 'index.php?CMD[importExt]='.$v['extkey'].'&CMD[extVersion]='.$version.'&CMD[loc]=L';
$loadUnloadLink.= '<a href="'.htmlspecialchars($aUrl).'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/import.gif" width="12" height="12" title="Import this extension to \'local\' dir typo3conf/ext/ from online repository." alt="" /></a>';
}
} else {
$loadUnloadLink = '&nbsp;';
}
if (isset($inst_list[$v['extkey']])) {
$theRowClass = t3lib_extMgm::isLoaded($v['extkey']) ? 'em-listbg1' : 'em-listbg2';
} else {
$theRowClass = 'em-listbg3';
}
$lines[]=$this->extensionListRow($v['extkey'],$ext,array('<td class="bgColor">'.$loadUnloadLink.'</td>'),$theRowClass,$inst_list,1,'index.php?CMD[importExtInfo]='.rawurlencode($v['extkey']));
}
} else {
$lines[] = '<strong>No matching extensions found.<strong><br>';
}
// CSH:
$content.= t3lib_BEfunc::cshItem('_MOD_tools_em', 'import_ter', $GLOBALS['BACK_PATH'],'|<br/>');
$onsubmit = "window.location.href='index.php?ter_connect=1&ter_search='+escape(this.elements['_lookUp'].value);return false;";
$content.= '</form><form action="index.php" method="post" onsubmit="'.htmlspecialchars($onsubmit).'">List or look up extensions<br />
<input type="text" name="_lookUp" value="'.htmlspecialchars($this->listRemote_search).'" /> <input type="submit" value="Look up" /><br /><br />';
$content.= '
<!-- TER Extensions list -->
<table border="0" cellpadding="2" cellspacing="1">'.implode(chr(10),$lines).'</table>';
unset($lines);
$content.=$piBase->pi_list_browseresults(1,'width="1%"',array ( 'activeLinkWrap' => '<td nowrap="nowrap"><p style="background-color:#FFFF00">|</p></td>',
'showResultsWrap' => '<td width="99%" align="right" nowrap="nowrap"><p style="padding-right:100px">|</p></td></tr></table>',
'browseLinksWrap' => '<table width="100%"><tr>|',
)
);
$content.= '<br /><br /><strong>PRIVACY NOTICE:</strong><br /> '.$this->privacyNotice;
$this->content.=$this->doc->section('Extensions in TYPO3 Extension Repository (online) - Grouped by: '.$this->MOD_MENU['listOrder'][$this->MOD_SETTINGS['listOrder']],$content,0,1);
} else {
// CSH
$content.= t3lib_BEfunc::cshItem('_MOD_tools_em', 'import', $GLOBALS['BACK_PATH'],'|<br/>');
$onsubmit = "window.location.href='index.php?ter_connect=1&ter_search='+escape(this.elements['_lookUp'].value);return false;";
$content.= '</form><form action="index.php" method="post" onsubmit="'.htmlspecialchars($onsubmit).'">List or look up extensions<br />
<input type="text" name="_lookUp" value="" /> <input type="submit" value="Look up" /><br /><br />';
if ($this->CMD['fetchMetaData']) { // fetches mirror/extension data from online rep.
$content .= $this->fetchMetaData($this->CMD['fetchMetaData']);
} else {
$onCLick = "window.location.href='index.php?CMD[fetchMetaData]=extensions';return false;";
$content.= 'Connect to the current mirror and retrieve the current list of available plugins from the TYPO3 Extension Repository.<br />
<input type="submit" value="Retrieve/Update" onclick="'.htmlspecialchars($onCLick).'" />';
if(is_file(PATH_site.'typo3temp/extensions.bin')) {
$content .= ' (last update: '.date('Y-m-d H:i',filemtime(PATH_site.'typo3temp/extensions.bin')).')';
}
}
$content .= '<br /><br /><strong>PRIVACY NOTICE:</strong><br />'.$this->privacyNotice;
$this->content.=$this->doc->section('Extensions in TYPO3 Extension Repository',$content,0,1);
}
// Upload:
if ($this->importAtAll()) {
$content= '</form><form action="index.php" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" method="post">
Upload extension file (.t3x):<br />
<input type="file" size="60" name="upload_ext_file" /><br />
... to location:<br />
<select name="CMD[loc]">';
if ($this->importAsType('L')) $content.='<option value="L">Local (../typo3conf/ext/)</option>';
if ($this->importAsType('G')) $content.='<option value="G">Global (typo3/ext/)</option>';
if ($this->importAsType('S')) $content.='<option value="S">System (typo3/sysext/)</option>';
$content.='</select><br />
<input type="checkbox" value="1" name="CMD[uploadOverwrite]" /> Overwrite any existing extension!<br />
<input type="submit" name="CMD[uploadExt]" value="Upload extension file" /><br />
';
} else $content=$this->noImportMsg();
$this->content.=$this->doc->spacer(20);
$this->content.=$this->doc->section('Upload extension file directly (.t3x):',$content,0,1);
$content.= "<br /><br /><strong>Typo3:</strong><br />Total Memory Usage: " . $this->memory_get_usage() / 1024 . " KBytes <br/>\n";
$this->content.=$this->doc->section('Extensions in TYPO3 Extension Repository',$content,0,1);
}
// Upload:
if ($this->importAtAll()) {
$content= '</form><form action="index.php" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" method="post">
Upload extension file (.t3x):<br />
<input type="file" size="60" name="upload_ext_file" /><br />
... to location:<br />
<select name="CMD[loc]">';
if ($this->importAsType('L')) $content.='<option value="L">Local (../typo3conf/ext/)</option>';
if ($this->importAsType('G')) $content.='<option value="G">Global (typo3/ext/)</option>';
if ($this->importAsType('S')) $content.='<option value="S">System (typo3/sysext/)</option>';
$content.='</select><br />
<input type="checkbox" value="1" name="CMD[uploadOverwrite]" /> Overwrite any existing extension!<br />
<input type="submit" name="CMD[uploadExt]" value="Upload extension file" /><br />
';
} else $content=$this->noImportMsg();
$this->content.=$this->doc->spacer(20);
$this->content.=$this->doc->section('Upload extension file directly (.t3x):',$content,0,1);
}
/**
......
*
*********************************/
/**
* Returns detailed info about an extension in the online repository
*
* @param string Extension repository uid + optional "private key": [uid]-[key].
* @param [type] $version: ...
* @return void
*/
function importExtInfo($extKey, $version='') {
// "Go back" link
$content = '<a href="index.php" class="typo3-goBack"><img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/goback.gif','width="14" height="14"').' alt="" /> Go back</a>';
$this->content.= $this->doc->section('',$content);
/**
* Returns detailed info about an extension in the online repository
*
* @param string Extension repository uid + optional "private key": [uid]-[key].
* @param [type] $version: ...
* @return void
*/
function importExtInfo($extKey, $version='') {
// "Go back" link
$content = '<a href="index.php" class="typo3-goBack"><img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/goback.gif','width="14" height="14"').' alt="" /> Go back</a>';
$this->content.= $this->doc->section('',$content);
$content = '';
// Fetch remote data:
$this->xmlhandler->loadExtensionsXML();
$this->xmlhandler->extensionsXML = array($extKey => $this->xmlhandler->extensionsXML[$extKey]);
list($fetchData,) = $this->prepareImportExtList();
$versions = array_keys($fetchData[$extKey]['versions']);
$version = ($version == '') ? end($versions) : $version;
$opt = array();
foreach(array_keys($fetchData[$extKey]['versions']) as $ver) {
$opt[]='<option value="'.$ver.'"'.(($version == $ver) ? ' selected="selected"' : '').'>'.$ver.'</option>';
}
// "Select version" box:
$onClick = 'window.location.href=\'index.php?CMD[importExtInfo]='.$extKey.'&CMD[extVersion]=\'+document.pageform.extVersion.options[document.pageform.extVersion.selectedIndex].value; return false;';
$select='<select name="extVersion">'.implode('',$opt).'</select> <input type="submit" value="Load details" onclick="'.htmlspecialchars($onClick).'" /> or<br /><br />';
if ($this->importAtAll()) {
$onClick = '
window.location.href=\'index.php?CMD[importExt]='.$extKey.'\'
+\'&CMD[extVersion]=\'+document.pageform.extVersion.options[document.pageform.extVersion.selectedIndex].value
+\'&CMD[loc]=\'+document.pageform.loc.options[document.pageform.loc.selectedIndex].value;
return false;';
$select.='
<input type="submit" value="Import/Update" onclick="'.htmlspecialchars($onClick).'"> to:
<select name="loc">'.
($this->importAsType('G',$fetchData['emconf_lockType'])?'<option value="G">Global: '.$this->typePaths['G'].$extKey.'/'.(@is_dir(PATH_site.$this->typePaths['G'].$extKey)?' (OVERWRITE)':' (empty)').'</option>':'').
($this->importAsType('L',$fetchData['emconf_lockType'])?'<option value="L">Local: '.$this->typePaths['L'].$extKey.'/'.(@is_dir(PATH_site.$this->typePaths['L'].$extKey)?' (OVERWRITE)':' (empty)').'</option>':'').
($this->importAsType('S',$fetchData['emconf_lockType'])?'<option value="S">System: '.$this->typePaths['S'].$extKey.'/'.(@is_dir(PATH_site.$this->typePaths['S'].$extKey)?' (OVERWRITE)':' (empty)').'</option>':'').
'</select>';
} else $select.= $this->noImportMsg();
$content.= $select;
$this->content.= $this->doc->section('Select command',$content,0,1);
// Details:
$eInfo = $fetchData[$extKey]['versions'][$version];
$content='<strong>'.$fetchData[$extKey]['_ICON'].' &nbsp;'.$eInfo['EM_CONF']['title'].' ('.$extKey.', '.$version.')</strong><br /><br />';
$content.=$this->extInformationArray($extKey,$eInfo,1);
$this->content.=$this->doc->spacer(10);
$this->content.=$this->doc->section('Remote Extension Details',$content,0,1);
}
/**
* Fetches metadata and stores it to the corresponding place. This includes the mirror list,
* extension XML files.
*
* @param string Type of data to fetch: (mirrors)
* @param boolean If true the method doesn't produce any output
* @return void
*/
function fetchMetaData($metaType) {
global $TYPO3_CONF_VARS;
switch($metaType) {
case 'mirrors':
$mfile = t3lib_div::tempnam('mirrors');
$mirrorsFile = t3lib_div::getURL($this->MOD_SETTINGS['mirrorListURL']);
if($mirrorsFile===false) {
t3lib_div::unlink_tempfile($mfile);
$content = '<p>The mirror list was not updated, it could not be fetched from '.$this->MOD_SETTINGS['mirrorListURL'].'. Possible reasons: network problems, allow_url_fopen is off, curl is not enabled in Install tool.</p>';
} else {
t3lib_div::writeFile($mfile, $mirrorsFile);
$mirrors = implode('',gzfile($mfile));
t3lib_div::unlink_tempfile($mfile);
$mirrors = $this->xmlhandler->parseMirrorsXML($mirrors);
if(is_array($mirrors) && count($mirrors)) {
t3lib_BEfunc::getModuleData($this->MOD_MENU, array('extMirrors' => serialize($mirrors)), $this->MCONF['name'], '', 'extMirrors');
$this->MOD_SETTINGS['extMirrors'] = serialize($mirrors);
$content = '<p>The mirror list has been updated and now contains '.count($mirrors).' entries.</p>';
}
else {
$content = '<p>'.$mirrors.'<br />The mirror list was not updated as it contained no entries.</p>';
}
}
break;
case 'extensions':
$this->fetchMetaData('mirrors'); // if we fetch the extensions anyway, we can as well keep this up-to-date
$mirror = $this->getMirrorURL();
$extfile = $mirror.'extensions.xml.gz';
$extmd5 = t3lib_div::getURL($mirror.'extensions.md5');
if(is_file(PATH_site.'typo3temp/extensions.xml.gz')) $localmd5 = md5_file(PATH_site.'typo3temp/extensions.xml.gz');
if($extmd5 === false) {
$content .= '<p>Error: The extension MD5 sum could not be fetched from '.$mirror.'extensions.md5. Possible reasons: network problems, allow_url_fopen is off, curl is not enabled in Install tool.</p>';
} elseif($extmd5 == $localmd5) {
$content .= '<p>The extension list has not changed remotely, it has thus not been fetched.</p>';
} else {
$extXML = t3lib_div::getURL($extfile);
if($extXML === false) {
$content .= '<p>Error: The extension list could not be fetched from '.$extfile.'. Possible reasons: network problems, allow_url_fopen is off, curl is not enabled in Install tool.</p>';
} else {
t3lib_div::writeFile(PATH_site.'typo3temp/extensions.xml.gz', $extXML);
$content .= $this->xmlhandler->parseExtensionsXML(implode('',gzfile(PATH_site.'typo3temp/extensions.xml.gz')));
$this->xmlhandler->saveExtensionsXML();
}
}
break;
}
return $content;
$this->xmlhandler->extensionsXML = array();
// Make listing query, pass query to SQL database:
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','tx_chlightem_extension','tx_chlightem_extension.extkey="'.$extKey.'"');
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$this->xmlhandler->extensionsXML[$row['extkey']]['extkey']=$row['extkey'];
$this->xmlhandler->extensionsXML[$row['extkey']]['uid']=$row['uid'];
$this->xmlhandler->extensionsXML[$row['extkey']]['downloadcounter']=$row['downloadcounter'];
$this->xmlhandler->extensionsXML[$row['extkey']]['icon']=$row['icon'];
$this->xmlhandler->extensionsXML[$row['extkey']]['type']=$row['type'];
}
mysql_free_result($res);
foreach ($this->xmlhandler->extensionsXML as $k => $v) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('*','tx_chlightem_extension','tx_chlightem_mm','tx_chlightem_version','AND tx_chlightem_extension.uid='.$v['uid']);
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['version']=$row['version'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['title']=$row['title'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['description']=$row['description'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['state']=$row['extstate'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['reviewstate']=$row['reviewstate'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['lastuploaddate']=$row['lastuploaddate'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['constraints']=unserialize($row['dependencies']);
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['author']=$row['authorname'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['author_email']=$row['authoremail'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['author_company']=$row['authorcompany'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['ownerusername']=$row['ownerusername'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['t3xfilemd5']=$row['t3xfilemd5'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['category']=$row['category'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['uploadcomment']=$row['uploadcomment'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['downloadcounter']=$row['downloadcounter'];
}
}
mysql_free_result($res);
$versions = array_keys($this->xmlhandler->extensionsXML[$extKey]['versions']);
$version = ($version == '') ? end($versions) : $version;
$opt = array();
foreach(array_keys($this->xmlhandler->extensionsXML[$extKey]['versions']) as $ver) {
$opt[]='<option value="'.$ver.'"'.(($version == $ver) ? ' selected="selected"' : '').'>'.$ver.'</option>';
}
// "Select version" box:
$onClick = 'window.location.href=\'index.php?CMD[importExtInfo]='.$extKey.'&CMD[extVersion]=\'+document.pageform.extVersion.options[document.pageform.extVersion.selectedIndex].value; return false;';
$select='<select name="extVersion">'.implode('',$opt).'</select> <input type="submit" value="Load details" onclick="'.htmlspecialchars($onClick).'" /> or<br /><br />';
if ($this->importAtAll()) {
$onClick = '
window.location.href=\'index.php?CMD[importExt]='.$extKey.'\'
+\'&CMD[extVersion]=\'+document.pageform.extVersion.options[document.pageform.extVersion.selectedIndex].value
+\'&CMD[loc]=\'+document.pageform.loc.options[document.pageform.loc.selectedIndex].value;
return false;';
$select.='
<input type="submit" value="Import/Update" onclick="'.htmlspecialchars($onClick).'"> to:
<select name="loc">'.
($this->importAsType('G',$this->xmlhandler->extensionsXML['emconf_lockType'])?'<option value="G">Global: '.$this->typePaths['G'].$extKey.'/'.(@is_dir(PATH_site.$this->typePaths['G'].$extKey)?' (OVERWRITE)':' (empty)').'</option>':'').
($this->importAsType('L',$this->xmlhandler->extensionsXML['emconf_lockType'])?'<option value="L">Local: '.$this->typePaths['L'].$extKey.'/'.(@is_dir(PATH_site.$this->typePaths['L'].$extKey)?' (OVERWRITE)':' (empty)').'</option>':'').
($this->importAsType('S',$this->xmlhandler->extensionsXML['emconf_lockType'])?'<option value="S">System: '.$this->typePaths['S'].$extKey.'/'.(@is_dir(PATH_site.$this->typePaths['S'].$extKey)?' (OVERWRITE)':' (empty)').'</option>':'').
'</select>';
} else $select.= $this->noImportMsg();
$content.= $select;
$this->content.= $this->doc->section('Select command',$content,0,1);
// Details:
$eInfo = $this->xmlhandler->extensionsXML[$extKey]['versions'][$version];
$content='<strong>'.$this->xmlhandler->extensionsXML[$extKey]['_ICON'].' &nbsp;'.$eInfo['EM_CONF']['title'].' ('.$extKey.', '.$version.')</strong><br /><br />';
$content.=$this->extInformationArray($extKey,$eInfo,1);
$this->content.=$this->doc->spacer(10);
$this->content.=$this->doc->section('Remote Extension Details',$content,0,1);
}
/**
* Fetches metadata and stores it to the corresponding place. This includes the mirror list,
* extension XML files.
*
* @param string Type of data to fetch: (mirrors)
* @param boolean If true the method doesn't produce any output
* @return void
*/
function fetchMetaData($metaType) {
global $TYPO3_CONF_VARS;
switch($metaType) {
case 'mirrors':
$mfile = t3lib_div::tempnam('mirrors');
$mirrorsFile = t3lib_div::getURL($this->MOD_SETTINGS['mirrorListURL']);
if($mirrorsFile===false) {
t3lib_div::unlink_tempfile($mfile);
$content = '<p>The mirror list was not updated, it could not be fetched from '.$this->MOD_SETTINGS['mirrorListURL'].'. Possible reasons: network problems, allow_url_fopen is off, curl is not enabled in Install tool.</p>';
} else {
t3lib_div::writeFile($mfile, $mirrorsFile);
$mirrors = implode(chr(10), gzfile($mfile));
t3lib_div::unlink_tempfile($mfile);
$mirrors = $this->xmlhandler->parseMirrorsXML($mirrors);
if(is_array($mirrors) && count($mirrors)) {
t3lib_BEfunc::getModuleData($this->MOD_MENU, array('extMirrors' => serialize($mirrors)), $this->MCONF['name'], '', 'extMirrors');
$this->MOD_SETTINGS['extMirrors'] = serialize($mirrors);
$content = '<p>The mirror list has been updated and now contains '.count($mirrors).' entries.</p>';
}
else {
$content = '<p>'.$mirrors.'<br />The mirror list was not updated as it contained no entries.</p>';
}
}
break;
case 'extensions':
$this->fetchMetaData('mirrors'); // if we fetch the extensions anyway, we can as well keep this up-to-date
$mirror = $this->getMirrorURL();
$extfile = $mirror.'extensions.xml.gz';
$extmd5 = t3lib_div::getURL($mirror.'extensions.md5');
if(is_file(PATH_site.'typo3temp/extensions.xml.gz')) $localmd5 = md5_file(PATH_site.'typo3temp/extensions.xml.gz');
if($extmd5 === false) {
$content .= '<p>Error: The extension MD5 sum could not be fetched from '.$mirror.'extensions.md5. Possible reasons: network problems, allow_url_fopen is off, curl is not enabled in Install tool.</p>';
} elseif($extmd5 == $localmd5) {
$content .= '<p>The extension list has not changed remotely, it has thus not been fetched.</p>';
} else {
$extXML = t3lib_div::getURL($extfile);
if($extXML === false) {
$content .= '<p>Error: The extension list could not be fetched from '.$extfile.'. Possible reasons: network problems, allow_url_fopen is off, curl is not enabled in Install tool.</p>';
} else {
t3lib_div::writeFile(PATH_site.'typo3temp/extensions.xml.gz', $extXML);
$filepath = $this->getMirrorURL();
$content .= "Memory (Before): " . $this->memory_get_usage() / 1024 . " KBytes <br/>\n";
$tStart = microtime(true);
$gz = gzopen(PATH_site.'typo3temp/extensions.xml.gz', 'rb');
if ($gz) {
fseek($gz,51,SEEK_CUR);
$res = $GLOBALS['TYPO3_DB']->sql('tx_chlightem_extension','truncate table tx_chlightem_extension');
$extC = 0;
$res = $GLOBALS['TYPO3_DB']->sql('tx_chlightem_version','truncate table tx_chlightem_version');
$verC = 0;
$res = $GLOBALS['TYPO3_DB']->sql('tx_chlightem_mm','truncate table tx_chlightem_mm');
$char = '';
$pos = 0;
while (!gzeof($gz)) {
$char .= gzgets($gz, 4096);
$pos = strpos($char,"</extension>");
if ($pos) {
$extC++;
$buffer = substr($char,0,$pos+12);
$char = substr($char,$pos+12);
$result = $this->xmlhandler->parseExtensionsXML($buffer);
$extKey = key($this->xmlhandler->extXMLResult);
// too be very sure extKey exists
if (is_array($this->xmlhandler->extXMLResult[$extKey])) {
$version = array_keys($this->xmlhandler->extXMLResult[$extKey]['versions']);
$version = end($version);
$res = $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_chlightem_extension', array (
'crdate' => time(),
'extkey' => $extKey,
'downloadcounter' => $this->xmlhandler->extXMLResult[$extKey]['downloadcounter'],
'icon' => '<img alt="" src="'.$filepath.$extKey{0}.'/'.$extKey{1}.'/'.$extKey.'_'.$version.'.gif" />',
'category' => $this->xmlhandler->extXMLResult[$extKey]['versions'][$version]['category'],
'extstate' => $this->xmlhandler->extXMLResult[$extKey]['versions'][$version]['state'],
'version' => $version,
'title' => $this->xmlhandler->extXMLResult[$extKey]['versions'][$version]['title'],
'reviewstate' => $this->xmlhandler->extXMLResult[$extKey]['versions'][$version]['reviewstate'],
'ownerusername' => $this->xmlhandler->extXMLResult[$extKey]['versions'][$version]['ownerusername'],
'lastuploaddate' => $this->xmlhandler->extXMLResult[$extKey]['versions'][$version]['lastuploaddate'],
)
);
echo $GLOBALS['TYPO3_DB']->sql_error();
$query1 = '';
$q1str = array();
$query2 = '';
$q2str = array();
foreach ($this->xmlhandler->extXMLResult[$extKey]['versions'] as $k => $v) {
$verC++;
$qArr = array( $verC,
0,
time(),
$k,
$v['title'],
$v['description'],
$v['state'],
$v['reviewstate'],
$v['downloadcounter'],
$v['lastuploaddate'],
serialize($v['dependencies']),
$v['authorname'],
$v['authoremail'],
$v['authorcompany'],
$v['ownerusername'],
$v['t3xfilemd5'],
$v['category'],
$v['uploadcomment'],
);
$q1str[] = '\''.implode('\',\'',$qArr).'\'';
$qArr = array ( $extC,
$verC,
'',
''
);
$q2str[] = '\''.implode('\',\'',$qArr).'\'';
}
$query1 = 'INSERT INTO `tx_chlightem_version` VALUES ('. implode('),(',$q1str).');';
$query2 = 'INSERT INTO `tx_chlightem_mm` VALUES ('. implode('),(',$q2str).');';
$res = $GLOBALS['TYPO3_DB']->sql_query($query1);
echo $GLOBALS['TYPO3_DB']->sql_error();
$res = $GLOBALS['TYPO3_DB']->sql_query($query2);
echo $GLOBALS['TYPO3_DB']->sql_error();
$this->xmlhandler->extXMLResult = array();
}
}
}
gzclose($gz);
unset($this->xmlhandler->extXMLResult);
unset($this->xmlhandler->reviewStates);
unset($buffer);
unset($char);
unset($query1);
unset($query2);
unset($pos);
unset($q1str);
unset($q2str);
unset($qArr);
$content.= "Memory (After): " . $this->memory_get_usage() / 1024 . " KBytes <br/>\n";
$runTime = (microtime(true)-$tStart);
$content.= "Runtime: $runTime ms";
$content.= "<p>The extensions list has been updated and now contains $extC extension entries.</p>";
} else {
$content.= "<p>Function gzopen fails!</p>";
}
}
}
break;
}
return $content;
}
/**
......
}
/**
* Imports an extensions from the online repository
* NOTICE: in version 4.0 this changed from "importExtFromRep_old($extRepUid,$loc,$uploadFlag=0,$directInput='',$recentTranslations=0,$incManual=0,$dontDelete=0)"
*
* @param string Extension key
* @param string Version
* @param string Install scope: "L" or "G" or "S"
* @param boolean If true, extension is uploaded as file
* @param boolean If true, extension directory+files will not be deleted before writing the new ones. That way custom files stored in the extension folder will be kept.
* @param array Direct input array (like from kickstarter)
* @return string Return false on success, returns error message if error.
*/
function importExtFromRep($extKey,$version,$loc,$uploadFlag=0,$dontDelete=0,$directInput='') {
/**
* Imports an extensions from the online repository
* NOTICE: in version 4.0 this changed from "importExtFromRep_old($extRepUid,$loc,$uploadFlag=0,$directInput='',$recentTranslations=0,$incManual=0,$dontDelete=0)"
*
* @param string Extension key
* @param string Version
* @param string Install scope: "L" or "G" or "S"
* @param boolean If true, extension is uploaded as file
* @param boolean If true, extension directory+files will not be deleted before writing the new ones. That way custom files stored in the extension folder will be kept.
* @param array Direct input array (like from kickstarter)
* @return string Return false on success, returns error message if error.
*/
function importExtFromRep($extKey,$version,$loc,$uploadFlag=0,$dontDelete=0,$directInput='') {
$uploadSucceed = false;
$uploadedTempFile = '';
if (is_array($directInput)) {
......
} else return 'No extension key in file. Strange...';
} else return 'Wrong file format. No data recognized, '.$fetchData;
} else return 'No file uploaded! Probably the file was too large for PHPs internal limit for uploadable files.';
} else {
$this->xmlhandler->loadExtensionsXML();
// Fetch extension from TER:
if(!strlen($version)) {
$versions = array_keys($this->xmlhandler->extensionsXML[$extKey]['versions']);
$version = end($versions);
}
$fetchData = $this->terConnection->fetchExtension($extKey, $version, $this->xmlhandler->extensionsXML[$extKey]['versions'][$version]['t3xfilemd5'], $this->getMirrorURL());
}
// At this point the extension data should be present; so we want to write it to disc:
if ($this->importAsType($loc)) {
if (is_array($fetchData)) { // There was some data successfully transferred
if ($fetchData[0]['extKey'] && is_array($fetchData[0]['FILES'])) {
$extKey = $fetchData[0]['extKey'];
if(!isset($fetchData[0]['EM_CONF']['constraints'])) $fetchData[0]['EM_CONF']['constraints'] = $this->xmlhandler->extensionsXML[$extKey]['versions'][$version]['dependencies'];
$EM_CONF = $this->fixEMCONF($fetchData[0]['EM_CONF']);
if (!$EM_CONF['lockType'] || !strcmp($EM_CONF['lockType'],$loc)) {
// check dependencies, act accordingly if ext is loaded
list($instExtInfo,)=$this->getInstalledExtensions();
$depStatus = $this->checkDependencies($extKey, $EM_CONF, $instExtInfo);
if(t3lib_extMgm::isLoaded($extKey) && !$depStatus['returnCode']) {
$this->content .= $depStatus['html'];
if ($uploadedTempFile) {
$this->content .= '<input type="hidden" name="CMD[alreadyUploaded]" value="'.$uploadedTempFile.'" />';
}
} else {
$res = $this->clearAndMakeExtensionDir($fetchData[0],$loc,$dontDelete);
if (is_array($res)) {
$extDirPath = trim($res[0]);
if ($extDirPath && @is_dir($extDirPath) && substr($extDirPath,-1)=='/') {
$emConfFile = $this->construct_ext_emconf_file($extKey,$EM_CONF);
$dirs = $this->extractDirsFromFileList(array_keys($fetchData[0]['FILES']));
$res = $this->createDirsInPath($dirs,$extDirPath);
if (!$res) {
$writeFiles = $fetchData[0]['FILES'];
$writeFiles['ext_emconf.php']['content'] = $emConfFile;
$writeFiles['ext_emconf.php']['content_md5'] = md5($emConfFile);
// Write files:
foreach($writeFiles as $theFile => $fileData) {
t3lib_div::writeFile($extDirPath.$theFile,$fileData['content']);
if (!@is_file($extDirPath.$theFile)) {
$content.='Error: File "'.$extDirPath.$theFile.'" could not be created!!!<br />';
} elseif (md5(t3lib_div::getUrl($extDirPath.$theFile)) != $fileData['content_md5']) {
$content.='Error: File "'.$extDirPath.$theFile.'" MD5 was different from the original files MD5 - so the file is corrupted!<br />';
}
}
// No content, no errors. Create success output here:
if (!$content) {
$content='SUCCESS: '.$extDirPath.'<br />';
$uploadSucceed = true;
// Fix TYPO3_MOD_PATH for backend modules in extension:
$modules = t3lib_div::trimExplode(',',$EM_CONF['module'],1);
if (count($modules)) {
foreach($modules as $mD) {
$confFileName = $extDirPath.$mD.'/conf.php';
if (@is_file($confFileName)) {
$content.= $this->writeTYPO3_MOD_PATH($confFileName,$loc,$extKey.'/'.$mD.'/').'<br />';
} else $content.='Error: Couldn\'t find "'.$confFileName.'"<br />';
}
}
// NOTICE: I used two hours trying to find out why a script, ext_emconf.php, written twice and in between included by PHP did not update correct the second time. Probably something with PHP-A cache and mtime-stamps.
// But this order of the code works.... (using the empty Array with type, EMCONF and files hereunder).
// Writing to ext_emconf.php:
$sEMD5A = $this->serverExtensionMD5Array($extKey,array('type' => $loc, 'EM_CONF' => array(), 'files' => array()));
$EM_CONF['_md5_values_when_last_written'] = serialize($sEMD5A);
$emConfFile = $this->construct_ext_emconf_file($extKey,$EM_CONF);
t3lib_div::writeFile($extDirPath.'ext_emconf.php',$emConfFile);
$content.='ext_emconf.php: '.$extDirPath.'ext_emconf.php<br />';
$content.='Type: '.$loc.'<br />';
// Remove cache files:
if (t3lib_extMgm::isLoaded($extKey)) {
if ($this->removeCacheFiles()) {
$content.='Cache-files are removed and will be re-written upon next hit<br />';
}
list($new_list)=$this->getInstalledExtensions();
$content.=$this->updatesForm($extKey,$new_list[$extKey],1,'index.php?CMD[showExt]='.$extKey.'&SET[singleDetails]=info');
}
// Install / Uninstall:
if(!$this->CMD['standAlone']) {
$content = '<a href="index.php" class="typo3-goBack"><img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/goback.gif','width="14" height="14"').' alt="" /> Go back</a><br />'.$content;
$content.='<h3>Install / Uninstall Extension:</h3>';
$content.= $new_list[$extKey] ?
'<a href="'.htmlspecialchars('index.php?CMD[showExt]='.$extKey.'&CMD[remove]=1&CMD[clrCmd]=1&SET[singleDetails]=info').'">'.$this->removeButton().' Uninstall extension</a>' :
'<a href="'.htmlspecialchars('index.php?CMD[showExt]='.$extKey.'&CMD[load]=1&CMD[clrCmd]=1&SET[singleDetails]=info').'">'.$this->installButton().' Install extension</a>';
} else {
$content = 'Extension has been imported.<br /><br /><a href="javascript:opener.top.content.document.forms[0].submit();window.close();">Close window and recheck dependencies</a>';
}
}
} else $content = $res;
} else $content = 'Error: The extension path "'.$extDirPath.'" was different than expected...';
} else $content = $res;
}
} else $content = 'Error: The extension can only be installed in the path '.$this->typePaths[$EM_CONF['lockType']].' (lockType='.$EM_CONF['lockType'].')';
} else $content = 'Error: No extension key!!! Why? - nobody knows... (Or no files in the file-array...)';
} else $content = 'Error: The datatransfer did not succeed. '.$fetchData;
} else $content = 'Error: Installation is not allowed in this path ('.$this->typePaths[$loc].')';
$this->content.=$this->doc->section('Extension import results',$content,0,1);
if ($uploadSucceed && $uploadedTempFile) {
t3lib_div::unlink_tempfile($uploadedTempFile);
}
return false;
} else {
$this->xmlhandler->extensionsXML = array();
// Make listing query, pass query to SQL database:
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','tx_chlightem_extension','tx_chlightem_extension.extkey="'.$extKey.'"');
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$this->xmlhandler->extensionsXML[$row['extkey']]['extkey']=$row['extkey'];
$this->xmlhandler->extensionsXML[$row['extkey']]['uid']=$row['uid'];
$this->xmlhandler->extensionsXML[$row['extkey']]['downloadcounter']=$row['downloadcounter'];
$this->xmlhandler->extensionsXML[$row['extkey']]['icon']=$row['icon'];
$this->xmlhandler->extensionsXML[$row['extkey']]['type']=$row['type'];
}
mysql_free_result($res);
foreach ($this->xmlhandler->extensionsXML as $k => $v) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('*','tx_chlightem_extension','tx_chlightem_mm','tx_chlightem_version','AND tx_chlightem_extension.uid='.$v['uid']);
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['version']=$row['version'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['title']=$row['title'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['description']=$row['description'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['state']=$row['extstate'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['reviewstate']=$row['reviewstate'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['lastuploaddate']=$row['lastuploaddate'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['constraints']=unserialize($row['dependencies']);
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['author']=$row['authorname'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['author_email']=$row['authoremail'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['author_company']=$row['authorcompany'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['ownerusername']=$row['ownerusername'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['t3xfilemd5']=$row['t3xfilemd5'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['category']=$row['category'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['uploadcomment']=$row['uploadcomment'];
$this->xmlhandler->extensionsXML[$v['extkey']]['versions'][$row['version']]['EM_CONF']['downloadcounter']=$row['downloadcounter'];
}
}
mysql_free_result($res);
// Fetch extension from TER:
if(!strlen($version)) {
$versions = array_keys($this->xmlhandler->extensionsXML[$extKey]['versions']);
$version = ($version == '') ? end($versions) : $version;
};
$fetchData = $this->terConnection->fetchExtension($extKey, $version, $this->xmlhandler->extensionsXML[$extKey]['versions'][$version]['EM_CONF']['t3xfilemd5'], $this->getMirrorURL());
}
// At this point the extension data should be present; so we want to write it to disc:
if ($this->importAsType($loc)) {
if (is_array($fetchData)) { // There was some data successfully transferred
if ($fetchData[0]['extKey'] && is_array($fetchData[0]['FILES'])) {
$extKey = $fetchData[0]['extKey'];
if(!isset($fetchData[0]['EM_CONF']['constraints'])) $fetchData[0]['EM_CONF']['constraints'] = $this->xmlhandler->extensionsXML[$extKey]['versions'][$version]['EM_CONF']['dependencies'];
$EM_CONF = $this->fixEMCONF($fetchData[0]['EM_CONF']);
if (!$EM_CONF['lockType'] || !strcmp($EM_CONF['lockType'],$loc)) {
// check dependencies, act accordingly if ext is loaded
list($instExtInfo,)=$this->getInstalledExtensions();
$depStatus = $this->checkDependencies($extKey, $EM_CONF, $instExtInfo);
if(t3lib_extMgm::isLoaded($extKey) && !$depStatus['returnCode']) {
$this->content .= $depStatus['html'];
} else {
$res = $this->clearAndMakeExtensionDir($fetchData[0],$loc,$dontDelete);
if (is_array($res)) {
$extDirPath = trim($res[0]);
if ($extDirPath && @is_dir($extDirPath) && substr($extDirPath,-1)=='/') {
$emConfFile = $this->construct_ext_emconf_file($extKey,$EM_CONF);
$dirs = $this->extractDirsFromFileList(array_keys($fetchData[0]['FILES']));
$res = $this->createDirsInPath($dirs,$extDirPath);
if (!$res) {
$writeFiles = $fetchData[0]['FILES'];
$writeFiles['ext_emconf.php']['content'] = $emConfFile;
$writeFiles['ext_emconf.php']['content_md5'] = md5($emConfFile);
// Write files:
foreach($writeFiles as $theFile => $fileData) {
t3lib_div::writeFile($extDirPath.$theFile,$fileData['content']);
if (!@is_file($extDirPath.$theFile)) {
... This diff was truncated because it exceeds the maximum size that can be displayed.
(1-1/8)