6 * Constructor class for data kept in external repositories
8 * External repositories might be populated by maintenance/async
9 * scripts, thus partial moving of data may be possible, as well
10 * as possibility to have any storage format (i.e. for archives)
15 /* Fetch data from given URL */
16 function fetchFromURL($url) {
17 global $wgExternalStores;
19 if (!$wgExternalStores)
22 @list
($proto,$path)=explode('://',$url,2);
27 $store =& ExternalStore
::getStoreObject( $proto );
28 if ( $store === false )
30 return $store->fetchFromURL($url);
34 * Get an external store object of the given type
36 function &getStoreObject( $proto ) {
37 global $wgExternalStores;
38 if (!$wgExternalStores)
40 /* Protocol not enabled */
41 if (!in_array( $proto, $wgExternalStores ))
44 $class='ExternalStore'.ucfirst($proto);
45 /* Preloaded modules might exist, especially ones serving multiple protocols */
46 if (!class_exists($class)) {
47 if (!include_once($class.'.php'))
55 * Store a data item to an external store, identified by a partial URL
56 * The protocol part is used to identify the class, the rest is passed to the
57 * class itself as a parameter.
58 * Returns the URL of the stored data item, or false on error
60 function insert( $url, $data ) {
61 list( $proto, $params ) = explode( '://', $url, 2 );
62 $store =& ExternalStore
::getStoreObject( $proto );
63 if ( $store === false ) {
66 return $store->store( $params, $data );