Skip to content

Commit

Permalink
api config setting
Browse files Browse the repository at this point in the history
  • Loading branch information
smartinkc committed Jul 30, 2019
1 parent 8a3e896 commit 97f87c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Multilingual.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
class Multilingual extends AbstractExternalModule
{
function redcap_survey_page($project_id, $record, $instrument){
echo '<script type="text/javascript">' . str_replace('APP_PATH_IMAGES', APP_PATH_IMAGES, str_replace('REDCAP_LANGUAGE_VARIABLE', $this->languageVariable($project_id), str_replace('REDCAP_AJAX_URL', $this->getUrl("index.php", true), file_get_contents($this->getModulePath() . 'js/multilingual_survey.js')))) . '</script>';
$api_endpoint = $this->getProjectSetting('use-api-endpoint', $project_id);
echo '<script type="text/javascript">' . str_replace('APP_PATH_IMAGES', APP_PATH_IMAGES, str_replace('REDCAP_LANGUAGE_VARIABLE', $this->languageVariable($project_id), str_replace('REDCAP_AJAX_URL', $this->getUrl("index.php", true, ($api_endpoint == true ? true : false)), file_get_contents($this->getModulePath() . 'js/multilingual_survey.js')))) . '</script>';
echo '<link rel="stylesheet" type="text/css" href="' . $this->getUrl('css/multilingual.css') . '">';
}

function redcap_survey_complete($project_id, $record, $instrument){
echo '<script type="text/javascript">' . str_replace('REDCAP_LANGUAGE_VARIABLE', $this->languageVariable($project_id), str_replace('REDCAP_AJAX_URL', $this->getUrl("index.php", true), file_get_contents($this->getModulePath() . 'js/multilingual_survey_complete.js'))) . '</script>';
$api_endpoint = $this->getProjectSetting('use-api-endpoint', $project_id);
echo '<script type="text/javascript">' . str_replace('REDCAP_LANGUAGE_VARIABLE', $this->languageVariable($project_id), str_replace('REDCAP_AJAX_URL', $this->getUrl("index.php", true, ($api_endpoint == true ? true : false)), file_get_contents($this->getModulePath() . 'js/multilingual_survey_complete.js'))) . '</script>';
}

function redcap_data_entry_form($project_id, $record, $instrument){
Expand All @@ -22,6 +24,8 @@ function redcap_data_entry_form($project_id, $record, $instrument){
}

function redcap_every_page_top($project_id){
$api_endpoint = $this->getProjectSetting('use-api-endpoint', $project_id);

if(strpos($_SERVER['REQUEST_URI'], 'online_designer.php') !== false && isset($_GET['page'])){
echo '<link rel="stylesheet" type="text/css" href="' . $this->getUrl('css/multilingual.css') . '">';
echo '<script type="text/javascript">' . str_replace('REDCAP_LANGUAGE_VARIABLE', $this->languageVariable($project_id), str_replace('REDCAP_AJAX_URL', $this->getUrl("index.php", true), file_get_contents($this->getModulePath() . 'js/multilingual_setup.js'))) . '</script>';
Expand All @@ -30,8 +34,8 @@ function redcap_every_page_top($project_id){
echo '<script type="text/javascript">' . str_replace('REDCAP_LANGUAGE_VARIABLE', $this->languageVariable($project_id), str_replace('REDCAP_AJAX_URL', $this->getUrl("index.php", true), file_get_contents($this->getModulePath() . 'js/multilingual_export.js'))) . '</script>';
}
elseif($_GET['__return'] == 1){
echo '<script type="text/javascript">' . str_replace('APP_PATH_IMAGES', APP_PATH_IMAGES, str_replace('REDCAP_LANGUAGE_VARIABLE', $this->languageVariable($project_id), str_replace('REDCAP_AJAX_URL', $this->getUrl("index.php", true), file_get_contents($this->getModulePath() . 'js/multilingual_survey_return.js')))) . '</script>';
echo '<link rel="stylesheet" type="text/css" href="' . $this->getUrl('css/multilingual.css') . '">';
echo '<script type="text/javascript">' . str_replace('APP_PATH_IMAGES', APP_PATH_IMAGES, str_replace('REDCAP_LANGUAGE_VARIABLE', $this->languageVariable($project_id), str_replace('REDCAP_AJAX_URL', $this->getUrl("index.php", true, ($api_endpoint == true ? true : false)), file_get_contents($this->getModulePath() . 'js/multilingual_survey_return.js')))) . '</script>';
echo '<link rel="stylesheet" type="text/css" href="' . $this->getUrl('css/multilingual.css', true, ($api_endpoint == true ? true : false)) . '">';
}
}

Expand Down
8 changes: 8 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
"no-auth-pages": [
"index"
],

"system-settings": [
{
"key": "use-api-endpoint",
"name": "<b>Use API endpoint for public surveys</b>",
"type": "checkbox"
}
],

"project-settings": [
{
Expand Down

0 comments on commit 97f87c2

Please sign in to comment.