Skip to content

Commit

Permalink
Dev Fixed issues with survey translation: Disable feature if no addit…
Browse files Browse the repository at this point in the history
…ional languages.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@9385 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Andrie de Vries committed Nov 1, 2010
1 parent 96b3ab3 commit 7fc9192
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 47 deletions.
9 changes: 5 additions & 4 deletions admin/translate.php
Expand Up @@ -32,6 +32,7 @@
// TODO need to do some validation here on surveyid

$surveyinfo=getSurveyInfo($surveyid);
$tolang="";
if (isset($_GET['tolang']))
{
$tolang = $_GET['tolang'];
Expand All @@ -50,15 +51,15 @@
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$supportedLanguages = getLanguageData(false);
$baselangdesc = $supportedLanguages[$baselang]['description'];
if(isset($tolang))
if($tolang != "")
{
$tolangdesc = $supportedLanguages[$tolang]['description'];
}

$translateoutput = "";
$translateoutput .= "<form name='translatemenu' id='translatemenu' "
."action='$scriptname' method='get' >";
$translateoutput .= showTranslateAdminmenu();
$translateoutput .= showTranslateAdminmenu($surveyid, $survey_title, $tolang, $scriptname);
$translateoutput .= "</form>";

$translateoutput .= "<p style='margin:0;font-size:1px;line-height:1px;height:1px;'>&nbsp;</p>\n"; //CSS Firefox 2 transition fix
Expand All @@ -69,7 +70,7 @@



if (isset($tolang) && $actionvalue=="translateSave")
if ($tolang != "" && $actionvalue=="translateSave")
// Saves translated values to database
{
foreach($tab_names as $type)
Expand Down Expand Up @@ -104,7 +105,7 @@
$actionvalue = "";
} // end if

if (isset($tolang))
if ($tolang != "")
// Display tabs with fields to translate, as well as input fields for translated values
{

Expand Down
92 changes: 49 additions & 43 deletions admin/translate_functions.php
Expand Up @@ -45,14 +45,17 @@ function menuSeparator()

/**
* showTranslateAdminmenu() creates the main menu options for the survey translation page
* @global string scriptname, $surveyid, $survey_title, $imageurl, $clang, $action,
$tolang, $activated, $publicurl
* @param string $surveyid The survey ID
* @param string $survey_title
* @param string $tolang
* @param string $activated
* @param string $scriptname
* @global string $imageurl, $clang, $publicurl
* @return string
*/
function showTranslateAdminmenu()
function showTranslateAdminmenu($surveyid, $survey_title, $tolang, $scriptname)
{
global $scriptname, $surveyid, $survey_title, $imageurl, $clang, $action,
$tolang, $activated, $publicurl;
global $imageurl, $clang, $publicurl;

$baselang = GetBaseLanguageFromSurveyID($surveyid);
$supportedLanguages = getLanguageData(false);
Expand All @@ -79,49 +82,52 @@ function showTranslateAdminmenu()

// Test / execute survey button

$sumquery1 = "SELECT * FROM ".db_table_name('surveys')." inner join ".db_table_name('surveys_languagesettings')." on (surveyls_survey_id=sid and surveyls_language=language) WHERE sid=$surveyid"; //Getting data for this survey
$sumresult1 = db_select_limit_assoc($sumquery1, 1) ; //Checked
$surveyinfo = $sumresult1->FetchRow();
if ($tolang != "")
{
$sumquery1 = "SELECT * FROM ".db_table_name('surveys')." inner join ".db_table_name('surveys_languagesettings')." on (surveyls_survey_id=sid and surveyls_language=language) WHERE sid=$surveyid"; //Getting data for this survey
$sumresult1 = db_select_limit_assoc($sumquery1, 1) ; //Checked
$surveyinfo = $sumresult1->FetchRow();

$surveyinfo = array_map('FlattenText', $surveyinfo);
$activated = $surveyinfo['active'];
$surveyinfo = array_map('FlattenText', $surveyinfo);
$activated = $surveyinfo['active'];

if ($activated == "N")
{
$menutext=$clang->gT("Test This Survey");
$menutext2=$clang->gTview("Test This Survey");
} else
{
$menutext=$clang->gT("Execute This Survey");
$menutext2=$clang->gTview("Execute This Survey");
}
if (count(GetAdditionalLanguagesFromSurveyID($surveyid)) == 0)
{
$adminmenu .= menuItem($menutext, $menutext2, "do.png", "$publicurl/index.php?sid=$surveyid&amp;newtest=Y&amp;lang=$baselang");
if ($activated == "N")
{
$menutext=$clang->gT("Test This Survey");
$menutext2=$clang->gTview("Test This Survey");
} else
{
$menutext=$clang->gT("Execute This Survey");
$menutext2=$clang->gTview("Execute This Survey");
}
if (count(GetAdditionalLanguagesFromSurveyID($surveyid)) == 0)
{
$adminmenu .= menuItem($menutext, $menutext2, "do.png", "$publicurl/index.php?sid=$surveyid&amp;newtest=Y&amp;lang=$baselang");

}
else
{
$icontext = $clang->gT($menutext);
$icontext2 = $clang->gT($menutext);
$adminmenu .= "<a href='#' id='dosurvey' class='dosurvey'"
. "title=\"".$icontext2."\" accesskey='d'>"
. "<img src='$imageurl/do.png' alt='$icontext' />"
. "</a>\n";

$tmp_survlangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$tmp_survlangs[] = $baselang;
rsort($tmp_survlangs);
// Test Survey Language Selection Popup
$adminmenu .="<div class=\"langpopup\" id=\"dosurveylangpopup\">"
.$clang->gT("Please select a language:")."<ul>";
foreach ($tmp_survlangs as $tmp_lang)
}
else
{
$adminmenu .= "<li><a accesskey='d' onclick=\"$('.dosurvey').qtip('hide');"
."\" target='_blank' href='{$publicurl}/index.php?sid=$surveyid&amp;"
."newtest=Y&amp;lang={$tmp_lang}'>".getLanguageNameFromCode($tmp_lang,false)."</a></li>";
$icontext = $clang->gT($menutext);
$icontext2 = $clang->gT($menutext);
$adminmenu .= "<a href='#' id='dosurvey' class='dosurvey'"
. "title=\"".$icontext2."\" accesskey='d'>"
. "<img src='$imageurl/do.png' alt='$icontext' />"
. "</a>\n";

$tmp_survlangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$tmp_survlangs[] = $baselang;
rsort($tmp_survlangs);
// Test Survey Language Selection Popup
$adminmenu .="<div class=\"langpopup\" id=\"dosurveylangpopup\">"
.$clang->gT("Please select a language:")."<ul>";
foreach ($tmp_survlangs as $tmp_lang)
{
$adminmenu .= "<li><a accesskey='d' onclick=\"$('.dosurvey').qtip('hide');"
."\" target='_blank' href='{$publicurl}/index.php?sid=$surveyid&amp;"
."newtest=Y&amp;lang={$tmp_lang}'>".getLanguageNameFromCode($tmp_lang,false)."</a></li>";
}
$adminmenu .= "</ul></div>";
}
$adminmenu .= "</ul></div>";
}

// End of survey-bar-left
Expand Down
Binary file added images/translate_disabled.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7fc9192

Please sign in to comment.