|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2010 Marcus Krause <marcus#exp2010@t3sec.info> 00006 * Steffen Kamper <info@sk-typo3.de> 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 * 00018 * This script is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 * GNU General Public License for more details. 00022 * 00023 * This copyright notice MUST APPEAR in all copies of the script! 00024 ***************************************************************/ 00025 /** 00026 * class.em_repository_mirrors 00027 * 00028 * Module: Extension manager - Repository mirrors 00029 * 00030 * $Id: class.tx_em_repository_mirrors.php 1887 2010-02-19 22:22:54Z mkrause $ 00031 * 00032 * @author Marcus Krause <marcus#exp2010@t3sec.info> 00033 * @author Steffen Kamper <info@sk-typo3.de> 00034 */ 00035 00036 /** 00037 * Repository mirrors object for extension manager. 00038 * 00039 * @author Marcus Krause <marcus#exp2010@t3sec.info> 00040 * @author Steffen Kamper <info@sk-typo3.de> 00041 * 00042 * @since 2010-02-11 00043 * @package TYPO3 00044 * @subpackage EM 00045 */ 00046 class tx_em_Repository_Mirrors { 00047 00048 /** 00049 * Keeps mirrors. 00050 * 00051 * @var array 00052 */ 00053 protected $mirrors = array(); 00054 00055 /** 00056 * Keeps currently select mirror. 00057 * 00058 * Is array index. 00059 * 00060 * @var integer 00061 */ 00062 protected $currentMirror; 00063 00064 /** 00065 * Keeps information if a mirror should 00066 * be randomly selected. 00067 * 00068 * @var boolean 00069 */ 00070 protected $isRandomSelection = TRUE; 00071 00072 /** 00073 * Class constructor. 00074 * 00075 * @access public 00076 * @return void 00077 */ 00078 function __construct() { 00079 // empty constructor 00080 } 00081 00082 /** 00083 * Method selects one specific mirror to be used. 00084 * 00085 * @access public 00086 * @param integer $mirrorID an order number (>=1) of mirror or NULL for random selection 00087 * @return void 00088 * @see $currentMirror 00089 */ 00090 public function setSelect($mirrorID = NULL) { 00091 if (is_null($mirrorID)) { 00092 $this->isRandomSelection = TRUE; 00093 } else { 00094 if (is_int($mirrorID) && $mirrorID >= 1 && $mirrorID <= count($this->mirrors)) { 00095 $this->currentMirror = $mirrorID - 1; 00096 } 00097 } 00098 } 00099 00100 /** 00101 * Method returns one mirror for use. 00102 * 00103 * Mirror has previously been selected or is chosen 00104 * randomly. 00105 * 00106 * @access public 00107 * @return array array of a mirror's properties or NULL in case of errors 00108 */ 00109 public function getMirror() { 00110 $sumMirrors = count($this->mirrors); 00111 if ($sumMirrors > 0) { 00112 if (!is_int($this->currentMirror)) { 00113 $this->currentMirror = rand(0, $sumMirrors - 1); 00114 } 00115 return $this->mirrors[$this->currentMirror]; 00116 } 00117 return NULL; 00118 } 00119 00120 /** 00121 * Method returns all available mirrors. 00122 * 00123 * @access public 00124 * @return array multidimensional array with mirrors and their properties 00125 * @see $mirrors, setMirrors() 00126 */ 00127 public function getMirrors() { 00128 return $this->mirrors; 00129 } 00130 00131 /** 00132 * Method sets available mirrors. 00133 * 00134 * @access public 00135 * @param array $mirrors multidimensional array with mirrors and their properties to set 00136 * @return void 00137 * @see $mirrors, getMirrors() 00138 */ 00139 public function setMirrors(array $mirrors) { 00140 if (count($mirrors) >= 1) { 00141 $this->mirrors = $mirrors; 00142 } 00143 } 00144 } 00145 00146 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/repository/class.tx_em_repository_mirrors.php'])) { 00147 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/repository/class.tx_em_repository_mirrors.php']); 00148 } 00149 00150 ?>
1.8.0