Index: trunk/extensions/Deployment/Deployment.i18n.php |
— | — | @@ -17,4 +17,14 @@ |
18 | 18 | $messages['en'] = array( |
19 | 19 | // General |
20 | 20 | 'deployment-desc' => 'Provides a way to install extensions via GUI and update them and the wiki itself via another GUI', |
| 21 | + |
| 22 | + // Filesystem: Direct |
| 23 | + |
| 24 | + |
| 25 | + // Filesystem: FTP |
| 26 | + 'deploy-ftp-not-loaded' => 'The FTP PHP extension is not available', |
| 27 | + 'deploy-ftp-ssl-not-loaded' => 'The loaded FTP PHP extension does not support SSL', |
| 28 | + 'deploy-ftp-username-required' => 'FTP username is required', |
| 29 | + 'deploy-ftp-password-required' => 'FTP password is required', |
| 30 | + 'deploy-ftp-hostname-required' => 'FTP hostname is required', |
21 | 31 | ); |
Index: trunk/extensions/Deployment/includes/filesystems/FtpFilesystem.php |
— | — | @@ -18,16 +18,78 @@ |
19 | 19 | class FtpFilesystem extends Filesystem { |
20 | 20 | |
21 | 21 | /** |
| 22 | + * A list of options. |
| 23 | + * |
| 24 | + * @var array |
| 25 | + */ |
| 26 | + protected $options = array(); |
| 27 | + |
| 28 | + /** |
| 29 | + * The FTP connection link. |
| 30 | + * |
| 31 | + * @var unknown_type |
| 32 | + */ |
| 33 | + protected $connection; |
| 34 | + |
| 35 | + /** |
22 | 36 | * Constructor. |
23 | 37 | */ |
24 | | - public function __construct() { |
| 38 | + public function __construct( $options ) { |
| 39 | + $this->options = $options; |
25 | 40 | |
| 41 | + // Check if possible to use ftp functions. |
| 42 | + if ( !extension_loaded('ftp') ) { |
| 43 | + $this->addError( 'deploy-ftp-not-loaded' ); |
| 44 | + return false; |
| 45 | + } |
| 46 | + |
| 47 | + // Check for missing required options. |
| 48 | + if ( !array_key_exists( 'username', $options ) ) { |
| 49 | + $this->addError( 'deploy-ftp-username-required' ); |
| 50 | + } |
| 51 | + |
| 52 | + if ( !array_key_exists( 'password', $options ) ) { |
| 53 | + $this->addError( 'deploy-ftp-password-required' ); |
| 54 | + } |
| 55 | + |
| 56 | + if ( !array_key_exists( 'hostname', $options ) ) { |
| 57 | + $this->addError( 'deploy-ftp-hostname-required' ); |
| 58 | + } |
| 59 | + |
| 60 | + // Set default option values for those not provided. |
| 61 | + if ( !array_key_exists( 'port', $options ) ) { |
| 62 | + $options['port'] = 21; |
| 63 | + } |
| 64 | + |
| 65 | + if ( !array_key_exists( 'timeout', $options ) ) { |
| 66 | + $options['timeout'] = 240; |
| 67 | + } |
| 68 | + |
| 69 | + // Other option handling. |
| 70 | + $options['ssl'] = array_key_exists( 'connection_type', $options ) && $options['connection_type'] == 'ftps'; |
| 71 | + |
| 72 | + // Store the options. |
| 73 | + $this->options = $options; |
26 | 74 | } |
27 | 75 | |
28 | 76 | /** |
29 | 77 | * @see Filesystem::connect |
30 | 78 | */ |
31 | 79 | public function connect() { |
| 80 | + if ( $this->options['ssl'] && function_exists( 'ftp_ssl_connect' ) ) { |
| 81 | + // TODO |
| 82 | + } |
| 83 | + else { |
| 84 | + // If this is true, ftp_ssl_connect was not defined, so add an error. |
| 85 | + if ( $this->options['ssl'] ) { |
| 86 | + $this->addError( 'deploy-ftp-ssl-not-loaded' ); |
| 87 | + } |
| 88 | + |
| 89 | + // TODO |
| 90 | + } |
| 91 | + |
| 92 | + // TODO |
| 93 | + |
32 | 94 | return true; |
33 | 95 | } |
34 | 96 | |
Index: trunk/extensions/Deployment/includes/Filesystem.php |
— | — | @@ -25,6 +25,13 @@ |
26 | 26 | abstract class Filesystem { |
27 | 27 | |
28 | 28 | /** |
| 29 | + * Array for storing error messages. |
| 30 | + * |
| 31 | + * @var array of string |
| 32 | + */ |
| 33 | + protected $errors = array(); |
| 34 | + |
| 35 | + /** |
29 | 36 | * Creates a connection to the filesystem. |
30 | 37 | * |
31 | 38 | * @return boolean Indicates whether the connection has been established. |
— | — | @@ -265,7 +272,7 @@ |
266 | 273 | */ |
267 | 274 | public function __construct() { |
268 | 275 | // TODO |
269 | | - } |
| 276 | + } |
270 | 277 | |
271 | 278 | public static function findFolder() { |
272 | 279 | // TODO |
— | — | @@ -323,6 +330,34 @@ |
324 | 331 | */ |
325 | 332 | public function removeDir( $path, $recursive = false ) { |
326 | 333 | $this->delete( $path, $recursive ); |
| 334 | + } |
| 335 | + |
| 336 | + /** |
| 337 | + * Returns an array with all errors. |
| 338 | + * |
| 339 | + * @return array |
| 340 | + */ |
| 341 | + public function getErrors() { |
| 342 | + return $this->errors; |
327 | 343 | } |
328 | 344 | |
| 345 | + /** |
| 346 | + * Adds an error message created from a message key to the log file and stores it for further use. |
| 347 | + * |
| 348 | + * @param string $errorMessageKey |
| 349 | + */ |
| 350 | + protected function addError( $errorMessageKey ) { |
| 351 | + $this->addErrorMessage( wfMsg( $errorMessageKey ) ); |
| 352 | + } |
| 353 | + |
| 354 | + /** |
| 355 | + * Adds an error message to the log file and stores it for further use. |
| 356 | + * |
| 357 | + * @param string $error |
| 358 | + */ |
| 359 | + protected function addErrorMessage( $error ) { |
| 360 | + $this->errors[] = $error; |
| 361 | + wfDebug( $error ); |
| 362 | + } |
| 363 | + |
329 | 364 | } |
\ No newline at end of file |