| 172 |
} |
} |
| 173 |
|
|
| 174 |
/** |
/** |
| 175 |
|
* Implementation of hook_init(). |
| 176 |
|
*/ |
| 177 |
|
function bitcache_init() { |
| 178 |
|
foreach (array('token', 'services') as $module) { |
| 179 |
|
if (module_exists($module)) { |
| 180 |
|
module_load_include('inc', 'bitcache', 'bitcache.' . $module); |
| 181 |
|
} |
| 182 |
|
} |
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
/** |
| 186 |
* Implementation of hook_form_alter(). |
* Implementation of hook_form_alter(). |
| 187 |
*/ |
*/ |
| 188 |
function bitcache_form_alter(&$form, $form_state, $form_id) { |
function bitcache_form_alter(&$form, $form_state, $form_id) { |
| 428 |
} |
} |
| 429 |
|
|
| 430 |
////////////////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////////////////// |
|
// Services API hooks |
|
|
|
|
|
/** |
|
|
* Implementation of hook_service(). |
|
|
*/ |
|
|
function bitcache_service() { |
|
|
return array( |
|
|
array( |
|
|
'#method' => 'bitcache.exists', |
|
|
'#callback' => 'bitcache_exists', |
|
|
'#return' => 'boolean', |
|
|
'#args' => array( |
|
|
array('#name' => 'id', '#type' => 'string', '#optional' => FALSE, '#description' => t('The bitstream\'s identifier (SHA-1 fingerprint).')), |
|
|
), |
|
|
'#help' => t('Determines whether a given bitstream exists.'), |
|
|
), |
|
|
array( |
|
|
'#method' => 'bitcache.get', |
|
|
'#callback' => 'bitcache_get_contents', |
|
|
'#return' => 'base64', |
|
|
'#args' => array( |
|
|
array('#name' => 'id', '#type' => 'string', '#optional' => FALSE, '#description' => t('The bitstream\'s identifier (SHA-1 fingerprint).')), |
|
|
), |
|
|
'#help' => t('Retrieves the contents of the given bitstream.'), |
|
|
), |
|
|
array( |
|
|
'#method' => 'bitcache.put', |
|
|
'#callback' => 'bitcache_put', |
|
|
'#return' => 'boolean', |
|
|
'#args' => array( |
|
|
array('#name' => 'id', '#type' => 'string', '#optional' => FALSE, '#description' => t('The bitstream\'s identifier (SHA-1 fingerprint).')), |
|
|
array('#name' => 'data', '#type' => 'base64', '#optional' => FALSE, '#description' => t('The bitstream\'s contents.')), |
|
|
), |
|
|
'#help' => t('Stores the contents of the given bitstream.'), |
|
|
), |
|
|
array( |
|
|
'#method' => 'bitcache.delete', |
|
|
'#callback' => 'bitcache_delete', |
|
|
'#return' => 'boolean', |
|
|
'#args' => array( |
|
|
array('#name' => 'id', '#type' => 'string', '#optional' => FALSE, '#description' => t('The bitstream\'s identifier (SHA-1 fingerprint).')), |
|
|
), |
|
|
'#help' => t('Deletes the given bitstream.'), |
|
|
), |
|
|
); |
|
|
} |
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////// |
|
| 431 |
// Bitcache repository API |
// Bitcache repository API |
| 432 |
|
|
| 433 |
/** |
/** |
| 860 |
} |
} |
| 861 |
return $path; |
return $path; |
| 862 |
} |
} |
| 863 |
|
|
| 864 |
|
function bitcache_token_replace($text) { |
| 865 |
|
if (module_exists('token')) { |
| 866 |
|
return token_replace($text); |
| 867 |
|
} |
| 868 |
|
else { // simple fallback token support |
| 869 |
|
$tokens = array( |
| 870 |
|
'[file-directory-path]' => file_directory_path(), |
| 871 |
|
'[file-directory-temp]' => file_directory_temp(), |
| 872 |
|
'[site-host]' => $_SERVER['HTTP_HOST'], |
| 873 |
|
); |
| 874 |
|
return str_replace(array_keys($tokens), array_values($tokens), $text); |
| 875 |
|
} |
| 876 |
|
} |