Exemplo n.º 1
0
    /**
     * Listing remote extensions from online repository
     *
     * @return	void
     */
    function extensionList_import()
    {
        global $TYPO3_LOADED_EXT;
        $content = '';
        // Listing from online repository:
        if ($this->listRemote) {
            list($inst_list, ) = $this->extensionList->getInstalledExtensions();
            $this->inst_keys = array_flip(array_keys($inst_list));
            $this->detailCols[1] += 6;
            // see if we have an extensionlist at all
            $this->extensionCount = $this->xmlHandler->countExtensions();
            if (!$this->extensionCount) {
                $content .= $this->fetchMetaData('extensions');
            }
            if ($this->MOD_SETTINGS['listOrder'] == 'author_company') {
                $this->listingLimit = $this->listingLimitAuthor;
            }
            $this->pointer = intval(t3lib_div::_GP('pointer'));
            $offset = $this->listingLimit * $this->pointer;
            if ($this->MOD_SETTINGS['display_own'] && strlen($this->fe_user['username'])) {
                $this->xmlHandler->searchExtensionsXML($this->listRemote_search, $this->fe_user['username'], $this->MOD_SETTINGS['listOrder'], TRUE);
            } else {
                $this->xmlHandler->searchExtensionsXML($this->listRemote_search, '', $this->MOD_SETTINGS['listOrder'], TRUE, FALSE, $offset, $this->listingLimit);
            }
            if (count($this->xmlHandler->extensionsXML)) {
                list($list, $cat) = $this->extensionList->prepareImportExtList(TRUE);
                // Available extensions
                if (is_array($cat[$this->MOD_SETTINGS['listOrder']])) {
                    $lines = array();
                    $lines[] = $this->extensionList->extensionListRowHeader(' class="t3-row-header"', 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']]) . '">' . t3lib_iconWorks::getSpriteIcon('apps-filetree-folder-default') . '<strong>' . htmlspecialchars($this->listOrderTitle($this->MOD_SETTINGS['listOrder'], $catName)) . '</strong></td></tr>';
                            natcasesort($extEkeys);
                            foreach ($extEkeys as $extKey => $value) {
                                $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]) || tx_em_Tools::versionDifference($version, $inst_list[$extKey]['EM_CONF']['version'], $this->versionDiffFactor))) {
                                    if (isset($inst_list[$extKey])) {
                                        // update
                                        if ($inst_list[$extKey]['EM_CONF']['state'] != 'excludeFromUpdates') {
                                            $loc = $inst_list[$extKey]['type'] == 'G' ? 'G' : 'L';
                                            $aUrl = t3lib_div::linkThisScript(array('CMD[importExt]' => $extKey, 'CMD[extVersion]' => $version, 'CMD[loc]' => $loc));
                                            $loadUnloadLink .= '<a href="' . htmlspecialchars($aUrl) . '" title="' . sprintf($GLOBALS['LANG']->getLL('do_update'), $loc == 'G' ? $GLOBALS['LANG']->getLL('global') : $GLOBALS['LANG']->getLL('local')) . '">' . t3lib_iconWorks::getSpriteIcon('actions-system-extension-update') . '</a>';
                                        } else {
                                            // extension is marked as "excludeFromUpdates"
                                            $loadUnloadLink .= t3lib_iconWorks::getSpriteIcon('status-dialog-warning', $GLOBALS['LANG']->getLL('excluded_from_updates'));
                                        }
                                    } else {
                                        // import
                                        $aUrl = t3lib_div::linkThisScript(array('CMD[importExt]' => $extKey, 'CMD[extVersion]' => $version, 'CMD[loc]' => 'L'));
                                        $loadUnloadLink .= '<a href="' . htmlspecialchars($aUrl) . '" title="' . $GLOBALS['LANG']->getLL('import_to_local_dir') . '">' . t3lib_iconWorks::getSpriteIcon('actions-system-extension-import') . '</a>';
                                    }
                                } else {
                                    $loadUnloadLink = '&nbsp;';
                                }
                                if (isset($inst_list[$extKey])) {
                                    $theRowClass = t3lib_extMgm::isLoaded($extKey) ? 'em-listbg1' : 'em-listbg2';
                                } else {
                                    $theRowClass = 'em-listbg3';
                                }
                                $lines[] = $this->extensionList->extensionListRow($extKey, $ext, array('<td class="bgColor">' . $loadUnloadLink . '</td>'), $theRowClass, $inst_list, 1, t3lib_div::linkThisScript(array('CMD[importExtInfo]' => rawurlencode($extKey))));
                                unset($list[$extKey]);
                            }
                        }
                    }
                    unset($list);
                    // headline and CSH
                    $headline = $GLOBALS['LANG']->getLL('extensions_repository_group_by') . ' ' . $this->MOD_MENU['listOrder'][$this->MOD_SETTINGS['listOrder']];
                    $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'import_ter', $headline);
                    $onsubmit = "window.location.href='" . $this->script . "&ter_connect=1&ter_search='+escape(this.elements['lookUp'].value);return false;";
                    $content .= '<form action="' . $this->script . '" method="post" onsubmit="' . htmlspecialchars($onsubmit) . '"><label for="lookUp">' . $GLOBALS['LANG']->getLL('list_or_look_up_extensions') . '</label><br />
							<input type="text" id="lookUp" name="lookUp" value="' . htmlspecialchars($this->listRemote_search) . '" /> <input type="submit" value="' . $GLOBALS['LANG']->getLL('look_up_button') . '" /></form><br /><br />';
                    $content .= $this->browseLinks();
                    $content .= '

					<!-- TER Extensions list -->
					<table border="0" cellpadding="2" cellspacing="1">' . implode(LF, $lines) . '</table>';
                    $content .= '<br />' . $this->browseLinks();
                    $content .= '<br /><br />' . $this->securityHint;
                    $content .= '<br /><br /><strong>' . $GLOBALS['LANG']->getLL('privacy_notice_header') . '</strong><br /> ' . $this->privacyNotice;
                    $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, FALSE, TRUE);
                    // Plugins which are NOT uploaded to repository but present on this server.
                    $content = '';
                    $lines = array();
                    if (count($this->inst_keys)) {
                        foreach ($this->inst_keys as $extKey => $value) {
                            $this->xmlHandler->searchExtensionsXMLExact($extKey, '', '', TRUE, TRUE);
                            if (strlen($this->listRemote_search) && !stristr($extKey, $this->listRemote_search) || isset($this->xmlHandler->extensionsXML[$extKey])) {
                                continue;
                            }
                            $loadUnloadLink = t3lib_extMgm::isLoaded($extKey) ? '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'CMD[remove]' => 1, 'CMD[clrCmd]' => 1, 'SET[singleDetails]' => 'info'))) . '">' . tx_em_Tools::removeButton() . '</a>' : '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'CMD[load]' => 1, 'CMD[clrCmd]' => 1, 'SET[singleDetails]' => 'info'))) . '">' . tx_em_Tools::installButton() . '</a>';
                            if (in_array($extKey, $this->requiredExt)) {
                                $loadUnloadLink = '<strong>' . tx_em_Tools::rfw($GLOBALS['LANG']->getLL('extension_required_short')) . '</strong>';
                            }
                            $lines[] = $this->extensionList->extensionListRow($extKey, $inst_list[$extKey], array('<td class="bgColor">' . $loadUnloadLink . '</td>'), t3lib_extMgm::isLoaded($extKey) ? 'em-listbg1' : 'em-listbg2');
                        }
                    }
                    if (count($lines)) {
                        $content .= $GLOBALS['LANG']->getLL('list_of_local_extensions') . '<br />' . $GLOBALS['LANG']->getLL('might_be_user_defined') . '<br /><br />';
                        $content .= '<table border="0" cellpadding="2" cellspacing="1">' . $this->extensionList->extensionListRowHeader(' class="t3-row-header"', 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($GLOBALS['LANG']->getLL('only_on_this_server'), $content, 0, 1);
                    }
                }
            } else {
                // headline and CSH
                $headline = $GLOBALS['LANG']->getLL('extensions_repository_group_by') . ' ' . $this->MOD_MENU['listOrder'][$this->MOD_SETTINGS['listOrder']];
                $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'import_ter', $headline);
                $onsubmit = "window.location.href='" . $this->script . "&ter_connect=1&ter_search='+escape(this.elements['lookUp'].value);return false;";
                $content .= '<form action="' . $this->script . '" method="post" onsubmit="' . htmlspecialchars($onsubmit) . '"><label for="lookUp">' . $GLOBALS['LANG']->getLL('list_or_look_up_extensions') . '</label><br />
					<input type="text" id="lookUp" name="lookUp" value="' . htmlspecialchars($this->listRemote_search) . '" /> <input type="submit" value="' . $GLOBALS['LANG']->getLL('look_up_button') . '" /></form><br /><br />';
                $content .= '<p><strong>' . $GLOBALS['LANG']->getLL('no_matching_extensions') . '</strong></p>';
                $content .= '<br /><br /><strong>' . $GLOBALS['LANG']->getLL('privacy_notice_header') . '</strong><br /> ' . $this->privacyNotice;
                $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, 0, TRUE);
            }
        } else {
            // section headline and CSH
            $headline = $GLOBALS['LANG']->getLL('in_repository');
            $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'import', $headline);
            $onsubmit = "window.location.href='" . $this->script . "&ter_connect=1&ter_search='+escape(this.elements['lookUp'].value);return false;";
            $content .= '<form action="' . $this->script . '" method="post" onsubmit="' . htmlspecialchars($onsubmit) . '"><label for="lookUp">' . $GLOBALS['LANG']->getLL('list_or_look_up_extensions') . '</label><br />
				<input type="text" id="lookUp" name="lookUp" value="" /> <input type="submit" value="' . $GLOBALS['LANG']->getLL('look_up_button') . '" /><br /><br />';
            if ($this->CMD['fetchMetaData']) {
                // fetches mirror/extension data from online rep.
                $content .= $this->fetchMetaData($this->CMD['fetchMetaData']);
            } else {
                $onCLick = 'window.location.href="' . t3lib_div::linkThisScript(array('CMD[fetchMetaData]' => 'extensions')) . '";return false;';
                $content .= $GLOBALS['LANG']->getLL('connect_to_ter') . '<br />
					<input type="submit" value="' . $GLOBALS['LANG']->getLL('retrieve_update') . '" onclick="' . htmlspecialchars($onCLick) . '" />';
                if (is_file(PATH_site . 'typo3temp/extensions.xml.gz')) {
                    $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
                    $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
                    $content .= ' ' . sprintf($GLOBALS['LANG']->getLL('ext_list_last_updated') . ' ', date($dateFormat . ', ' . $timeFormat, filemtime(PATH_site . 'typo3temp/extensions.xml.gz')), tx_em_Database::getExtensionCountFromRepository());
                }
            }
            $content .= '</form><br /><br />' . $this->securityHint;
            $content .= '<br /><br /><strong>' . $GLOBALS['LANG']->getLL('privacy_notice_header') . '</strong><br />' . $this->privacyNotice;
            $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, FALSE, TRUE);
        }
        // Upload:
        if ($this->importAtAll()) {
            $content = '<form action="' . $this->script . '" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" method="post">
			<label for="upload_ext_file">' . $GLOBALS['LANG']->getLL('upload_t3x') . '</label><br />
				<input type="file" size="60" id="upload_ext_file" name="upload_ext_file" /><br />' . $GLOBALS['LANG']->getLL('upload_to_location') . '<br />
				<select name="CMD[loc]">';
            if (tx_em_Tools::importAsType('L')) {
                $content .= '<option value="L">' . $GLOBALS['LANG']->getLL('local_folder') . '</option>';
            }
            if (tx_em_Tools::importAsType('G')) {
                $content .= '<option value="G">' . $GLOBALS['LANG']->getLL('global_folder') . '</option>';
            }
            if (tx_em_Tools::importAsType('S')) {
                $content .= '<option value="S">' . $GLOBALS['LANG']->getLL('system_folder') . '</option>';
            }
            $content .= '</select><br />
	<input type="checkbox" value="1" name="CMD[uploadOverwrite]" id="checkUploadOverwrite" /> <label for="checkUploadOverwrite">' . $GLOBALS['LANG']->getLL('overwrite_ext') . '</label><br />
	<input type="submit" name="CMD[uploadExt]" value="' . $GLOBALS['LANG']->getLL('upload_ext_file') . '" /></form><br />
			';
        } else {
            $content = tx_em_Tools::noImportMsg();
        }
        $this->content .= $this->doc->spacer(20);
        $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('upload_ext_directly'), $content, 0, 1);
    }