Documentation TYPO3 par Ameos

class.em_terconnection.php

00001 <?php
00002 /* **************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  (c) 2006 Karsten Dambekalns <karsten@typo3.org>
00007 *  All rights reserved
00008 *
00009 *  This script is part of the TYPO3 project. The TYPO3 project is
00010 *  free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  The GNU General Public License can be found at
00016 *  http://www.gnu.org/copyleft/gpl.html.
00017 *  A copy is found in the textfile GPL.txt and important notices to the license
00018 *  from the author is found in LICENSE.txt distributed with these scripts.
00019 *
00020 *
00021 *  This script is distributed in the hope that it will be useful,
00022 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024 *  GNU General Public License for more details.
00025 *
00026 *  This copyright notice MUST APPEAR in all copies of the script!
00027 ***************************************************************/
00028 
00029 
00030 if (!defined('SOAP_1_2'))       {
00031         require_once('class.nusoap.php');
00032 #       require_once('/usr/share/php/SOAP/Client.php');
00033 }
00034 require_once('class.em_soap.php');
00035 
00046 class SC_mod_tools_em_terconnection {
00047         var $wsdlURL;
00048         var $emObj;
00049 
00059         function fetchExtension($extKey, $version, $expectedMD5, $mirrorURL) {
00060                 $mirrorURL .= $extKey{0}.'/'.$extKey{1}.'/'.$extKey.'_'.$version.'.t3x';
00061                 $t3x = t3lib_div::getURL($mirrorURL);
00062                 $MD5 = md5($t3x);
00063 
00064                 if($t3x===false) return 'The T3X file could not be fetched. Possible reasons: network problems, allow_url_fopen is off, curl is not enabled in Install tool.';
00065 
00066                 if($MD5 == $expectedMD5) {
00067                                 // Fetch and return:
00068                         return $this->decodeExchangeData($t3x);
00069                 } else {
00070                         return 'Error: MD5 hash of downloaded file not as expected:<br />'.$MD5.' != '.$expectedMD5;
00071                 }
00072         }
00073 
00082         function fetchTranslation($extKey, $lang, $mirrorURL) {
00083                 $mirrorURL .= $extKey{0}.'/'.$extKey{1}.'/'.$extKey.'-l10n/'.$extKey.'-l10n-'.$lang.'.zip';
00084                 $l10n = t3lib_div::getURL($mirrorURL);
00085 
00086                 if($l10n !== false) {
00087                         return array($l10n);
00088                 } else {
00089                         return 'Error: Translation could not be fetched.';
00090                 }
00091         }
00092 
00100         function fetchTranslationStatus($extKey, $mirrorURL) {
00101 
00102                 $url = $mirrorURL . $extKey{0}.'/'.$extKey{1}.'/'.$extKey.'-l10n/'.$extKey.'-l10n.xml';
00103                 $remote = t3lib_div::getURL($url);
00104 
00105                 if($remote !== false) {
00106                         $parsed = $this->emObj->xmlhandler->parseL10nXML($remote);
00107                         return $parsed['languagePackIndex'];
00108                 }
00109 
00110                 return FALSE;
00111         }
00112 
00121         function decodeServerData($externalData)        {
00122                 $parts = explode(':',$externalData,4);
00123                 $dat = base64_decode($parts[2]);
00124                         // compare hashes ignoring any leading whitespace. See bug #0000365.
00125                 if (ltrim($parts[0])==md5($dat))        {
00126                         if ($parts[1]=='gzcompress')    {
00127                                 if (function_exists('gzuncompress'))    {
00128                                         $dat = gzuncompress($dat);
00129                                 } else return 'Decoding Error: No decompressor available for compressed content. gzuncompress() function is not available!';
00130                         }
00131                         $listArr = unserialize($dat);
00132 
00133                         if (is_array($listArr)) {
00134                                 return $listArr;
00135                         } else {
00136                                 return 'Error: Unserialized information was not an array - strange!';
00137                         }
00138                 } else return 'Error: MD5 hashes in T3X data did not match!';
00139         }
00140 
00148         function decodeExchangeData($str)       {
00149                 $parts = explode(':',$str,3);
00150                 if ($parts[1]=='gzcompress')    {
00151                         if (function_exists('gzuncompress'))    {
00152                                 $parts[2] = gzuncompress($parts[2]);
00153                         } else return 'Decoding Error: No decompressor available for compressed content. gzcompress()/gzuncompress() functions are not available!';
00154                 }
00155                 if (md5($parts[2]) == $parts[0])        {
00156                         $output = unserialize($parts[2]);
00157                         if (is_array($output))  {
00158                                 return array($output,'');
00159                         } else return 'Error: Content could not be unserialized to an array. Strange (since MD5 hashes match!)';
00160                 } else return 'Error: MD5 mismatch. Maybe the extension file was downloaded and saved as a text file by the browser and thereby corrupted!? (Always select "All" filetype when saving extensions)';
00161         }
00162 
00163 
00170         function makeUploadDataFromArray($uploadArray)  {
00171                 if (is_array($uploadArray))     {
00172                         $serialized = serialize($uploadArray);
00173                         $md5 = md5($serialized);
00174 
00175                         $content = $md5.':';
00176                         $content.= 'gzcompress:';
00177                         $content.= gzcompress($serialized);
00178                 }
00179                 return $content;
00180         }
00181 
00188         function uploadToTER($em) {
00189                 $uArr = $this->emObj->makeUploadArray($em['extKey'],$em['extInfo']);
00190                 if(!is_array($uArr)) return $uArr;
00191 
00192                         // Render new version number:
00193                 $newVersionBase = $em['extInfo']['EM_CONF']['version'];
00194                 switch((string)$em['upload']['mode']) {
00195                         case 'new_dev':
00196                                 $cmd='dev';
00197                                 break;
00198                         case 'new_sub':
00199                                 $cmd='sub';
00200                                 break;
00201                         case 'new_main':
00202                                 $cmd='main';
00203                                 break;
00204                         case 'custom':
00205                                 $newVersionBase = $em['upload']['version'];
00206                         case 'latest':
00207                         default:
00208                                 $cmd='';
00209                                 break;
00210                 }
00211                 $versionArr = $this->emObj->renderVersion($newVersionBase, $cmd);
00212                 $em['version'] = $versionArr['version'];
00213 
00214                         // Create dependency / conflict information:
00215                 $dependenciesArr = array ();
00216                 $extKeysArr = $uArr['EM_CONF']['constraints']['depends'];
00217 
00218                 if (is_array($extKeysArr)) {
00219                         foreach ($extKeysArr as $extKey => $version) {
00220                                 if (strlen($extKey)) {
00221                                         $dependenciesArr [] = array (
00222                                                 'kind' => 'depends',
00223                                                 'extensionKey' => utf8_encode($extKey),
00224                                                 'versionRange' => utf8_encode($version),
00225                                         );
00226                                 }
00227                         }
00228                 }
00229 
00230                 $extKeysArr = $uArr['EM_CONF']['constraints']['conflicts'];
00231                 if (is_array($extKeysArr)) {
00232                         foreach ($extKeysArr as $extKey => $version) {
00233                                 if (strlen($extKey)) {
00234                                         $dependenciesArr [] = array (
00235                                                 'kind' => 'conflicts',
00236                                                 'extensionKey' => utf8_encode($extKey),
00237                                                 'versionRange' => utf8_encode($version),
00238                                         );
00239                                 }
00240                         }
00241                 }
00242 
00243                         // Compile data for SOAP call:
00244                 $accountData = array(
00245                         'username' => $em['user']['fe_u'],
00246                         'password' => $em['user']['fe_p']
00247                 );
00248                 $extensionData = array (
00249                         'extensionKey' => utf8_encode($em['extKey']),
00250                         'version' => utf8_encode($em['version']),
00251                         'metaData' => array (
00252                                 'title' => utf8_encode($uArr['EM_CONF']['title']),
00253                                 'description' => utf8_encode($uArr['EM_CONF']['description']),
00254                                 'category' => utf8_encode($uArr['EM_CONF']['category']),
00255                                 'state' => utf8_encode($uArr['EM_CONF']['state']),
00256                                 'authorName' => utf8_encode($uArr['EM_CONF']['author']),
00257                                 'authorEmail' => utf8_encode($uArr['EM_CONF']['author_email']),
00258                                 'authorCompany' => utf8_encode($uArr['EM_CONF']['author_company']),
00259                         ),
00260                         'technicalData' => array (
00261                                 'dependencies' => $dependenciesArr,
00262                                 'loadOrder' => utf8_encode($uArr['EM_CONF']['loadOrder']),
00263                                 'uploadFolder' => (boolean) intval($uArr['EM_CONF']['uploadfolder']),
00264                                 'createDirs' => utf8_encode($uArr['EM_CONF']['createDirs']),
00265                                 'shy' => (boolean) intval($uArr['EM_CONF']['shy']),
00266                                 'modules' => utf8_encode($uArr['EM_CONF']['module']),
00267                                 'modifyTables' => utf8_encode($uArr['EM_CONF']['modify_tables']),
00268                                 'priority' => utf8_encode($uArr['EM_CONF']['priority']),
00269                                 'clearCacheOnLoad' => (boolean) intval($uArr['EM_CONF']['clearCacheOnLoad']),
00270                                 'lockType' => utf8_encode($uArr['EM_CONF']['lockType']),
00271                         ),
00272                         'infoData' => array(
00273                                 'codeLines' => intval($uArr['misc']['codelines']),
00274                                 'codeBytes' => intval($uArr['misc']['codebytes']),
00275                                 'codingGuidelinesCompliance' => utf8_encode($uArr['EM_CONF']['CGLcompliance']),
00276                                 'codingGuidelinesComplianceNotes' => utf8_encode($uArr['EM_CONF']['CGLcompliance_note']),
00277                                 'uploadComment' => utf8_encode($em['upload']['comment']),
00278                                 'techInfo' => unserialize($uArr['techInfo']),
00279                         ),
00280                 );
00281 
00282                 $filesData = array();
00283                 foreach ($uArr['FILES'] as $filename => $infoArr) {
00284                         $content = version_compare(phpversion(), '5.1.0', '<') ? base64_encode($infoArr['content']) : $infoArr['content']; // bug in 5.0.x and NuSOAP - no automatic encoding
00285                         $filesData['fileData'][] = array (
00286                                 'name' => utf8_encode($infoArr['name']),
00287                                 'size' => intval($infoArr['size']),
00288                                 'modificationTime' => intval($infoArr['mtime']),
00289                                 'isExecutable' => intval($infoArr['is_executable']),
00290                                 'content' => $content,
00291                                 'contentMD5' => $infoArr['content_md5'],
00292                         );
00293                 }
00294 
00295                 $soap = t3lib_div::makeInstance('em_soap');
00296                 $soap->init(array('wsdl'=>$this->wsdlURL,'soapoptions'=> array('trace'=>1,'exceptions'=>0)));
00297                 $response = $soap->call('uploadExtension', array('accountData' => $accountData, 'extensionData' => $extensionData, 'filesData' => $filesData));
00298 
00299                 if($response===false) {
00300                     switch(true) {
00301                         case is_string($soap->error):
00302                             return $soap->error;
00303                             break;
00304                         default:
00305                             return $soap->error->faultstring;
00306                     }
00307                 }
00308 
00309                 return $response;
00310         }
00311 }
00312 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6