Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acadre stream wrapper + Acadre text format #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions os2web_acadre_esdh.features.filter.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* @file
* os2web_acadre_esdh.features.filter.inc
*/

/**
* Implements hook_filter_default_formats().
*/
function os2web_acadre_esdh_filter_default_formats() {
$formats = array();

// Exported format: OS2Web Acadre ESDH.
$formats['os2web_acadre_esdh'] = array(
'format' => 'os2web_acadre_esdh',
'name' => 'OS2Web Acadre ESDH',
'cache' => 1,
'status' => 1,
'weight' => 0,
'filters' => array(
'filter_url' => array(
'weight' => -50,
'status' => 1,
'settings' => array(
'filter_url_length' => 72,
),
),
'filter_html' => array(
'weight' => -49,
'status' => 1,
'settings' => array(
'allowed_html' => '<em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <thead> <tfoot> <tbody> <h1> <h2> <h3> <b> <i> <p> <br /> <br> <a>',
'filter_html_help' => 1,
'filter_html_nofollow' => 1,
),
),
'filter_htmlcorrector' => array(
'weight' => -46,
'status' => 1,
'settings' => array(),
),
),
);

return $formats;
}
3 changes: 2 additions & 1 deletion os2web_acadre_esdh.info
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ version = 7.x-1.0-beta1
dependencies[] = ctools
dependencies[] = features
dependencies[] = os2web_esdh_provider
features[features_api][] = api:1
features[features_api][] = api:2
features[filter][] = os2web_acadre_esdh
files[] = plugins/cm/acadre.inc
files[] = plugins/cp/acadre.inc
files[] = plugins/cp/ArpService.class.inc
Expand Down
49 changes: 46 additions & 3 deletions os2web_acadre_esdh.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
* This module implements Acadre ESDH backend for use in os2web
*/

include_once('os2web_acadre_esdh.features.inc');

define('ACADRE_MM_IMPORT_DIR', 'public://acadre');
define('ACADRE_MM_IMPORT_DIR', 'acadre://');
define('ACADRE_MM_DEFAULT_APPROVED', '62,59,64,53,54,56,57,63,58,51,55,61,68,69,42');

// MM settings.
define('MM_BPA_BODY_FORMAT', 'os2web_acadre_esdh');

/**
* Implements hook_ctools_plugin_directory().
*
Expand Down Expand Up @@ -149,3 +150,45 @@ function os2web_acadre_esdh_os2web_help($sections) {
// return t('Missing documentation.');
// }
//}

/**
* Implements hook_stream_wrappers().
*
* Custom Acadre stream wrapper to avoid problems when moving files.
*/
function os2web_acadre_esdh_stream_wrappers() {
return array(
'acadre' => array(
'name' => t('Acadre'),
'class' => 'AcadreStreamWrapper',
'description' => t('Stream wrapper to the Acadre ESDH integration.'),
'type' => STREAM_WRAPPERS_LOCAL_HIDDEN,
),
);
}

/**
* Acadre (acadre://) stream wrapper class.
*
* Provides support for storing Acadre documents with the Drupal file
* interface.
*/
class AcadreStreamWrapper extends DrupalPublicStreamWrapper {

/**
* {@inheritdoc}
*/
public function getDirectoryPath() {
$path = variable_get('os2web_acadre_stream_wrapper_path', 'acadre');
$path = $path ? '/' . $path : '';
return parent::getDirectoryPath() . $path;
}

/**
* {@inheritdoc}
*/
public function getExternalUrl() {
$path = str_replace('\\', '/', $this->getTarget());
return $GLOBALS['base_url'] . '/' . self::getDirectoryPath() . '/' . drupal_encode_path($path);
}
}