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