This repository has been archived by the owner on Nov 26, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #839 from oc666/httptransport
add curl and socket to update process of Joomla
- Loading branch information
Showing
11 changed files
with
192 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Platform | ||
* @subpackage HTTP | ||
* | ||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE | ||
*/ | ||
|
||
defined('JPATH_PLATFORM') or die(); | ||
|
||
/** | ||
* HTTP factory class. | ||
* | ||
* @package Joomla.Platform | ||
* @subpackage HTTP | ||
* @since 12.1 | ||
*/ | ||
class JHttpFactory | ||
{ | ||
|
||
/** | ||
* method to recieve Http instance. | ||
* | ||
* @param JRegistry $options Client options object. | ||
* @param mixed $adapters Adapter (string) or queue of adapters (array) to use for communication | ||
* | ||
* @return JHttp Joomla Http class | ||
* | ||
* @since 12.1 | ||
*/ | ||
public static function getHttp($options = null, $adapters = null) | ||
{ | ||
if (empty($options)) | ||
{ | ||
$options = new JRegistry; | ||
} | ||
return new JHttp($options, self::getAvailableDriver($options, $adapters)); | ||
} | ||
|
||
/** | ||
* Finds an available http transport object for communication | ||
* | ||
* @param JRegistery $options Option for creating http transport object | ||
* @param mixed $default Adapter (string) or queue of adapters (array) to use | ||
* | ||
* @return JHttpTransport Interface sub-class | ||
* | ||
* @since 12.1 | ||
*/ | ||
public static function getAvailableDriver(JRegistry $options, $default = null) | ||
{ | ||
if (is_null($default)) | ||
{ | ||
$available_adapters = self::getHttpTransports(); | ||
} | ||
else | ||
{ | ||
settype($default, 'array'); | ||
$available_adapters = $default; | ||
} | ||
// Check if there is available http transport adapters | ||
if (!count($available_adapters)) | ||
{ | ||
return false; | ||
} | ||
foreach ($available_adapters as $adapter) | ||
{ | ||
$class = 'JHttpTransport' . ucfirst($adapter); | ||
/** | ||
* on J!2.5 (PHP 5.2) the condition should be: | ||
* call_user_func_array(array($class, 'isSupported'), array()) | ||
*/ | ||
if ($class::isSupported()) | ||
{ | ||
return new $class($options); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Get the http transport handlers | ||
* | ||
* @return array An array of available transport handlers | ||
* | ||
* @since 12.1 | ||
* @todo make this function more generic cause the behaviour taken from cache (getStores) | ||
*/ | ||
public static function getHttpTransports() | ||
{ | ||
$basedir = __DIR__ . '/transport'; | ||
$handlers = JFolder::files($basedir, '.php'); | ||
|
||
$names = array(); | ||
foreach ($handlers as $handler) | ||
{ | ||
$names[] = substr($handler, 0, strrpos($handler, '.')); | ||
} | ||
|
||
return $names; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters