Skip to content

Instantly share code, notes, and snippets.

@undertext
Created October 6, 2014 09:28
Show Gist options
  • Save undertext/0c0510a5e029fd6c8707 to your computer and use it in GitHub Desktop.
Save undertext/0c0510a5e029fd6c8707 to your computer and use it in GitHub Desktop.
<?php
/**
* Implements hook_stream_wrappers.
*/
function fics_stream_wrapper_stream_wrappers() {
return array(
'fics' => array(
'name' => t('FICS'),
'class' => 'FICSStreamWrapper',
'description' => t('Provides fics path.'),
'type' => STREAM_WRAPPERS_LOCAL_HIDDEN,
),
);
}
/**
* FICS (fics://) stream wrapper class.
*
* Provides support for storing fics documents with the Drupal file
* interface.
*/
class FICSStreamWrapper extends DrupalPublicStreamWrapper {
/**
* Implements abstract public function getDirectoryPath()
*/
public function getDirectoryPath() {
return parent::getDirectoryPath() . '/fics';
}
function getExternalUrl() {
$path = str_replace('\\', '/', $this->getTarget());
return $GLOBALS['base_url'] . '/' . self::getDirectoryPath() . '/' . drupal_encode_path($path);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment