diff --git a/application/controllers/admin/questions.php b/application/controllers/admin/questions.php index 7ab3eda752b..a9d571a0e2e 100644 --- a/application/controllers/admin/questions.php +++ b/application/controllers/admin/questions.php @@ -1219,7 +1219,7 @@ public function index($sa, $surveyid, $gid, $qid = null) $aData['surveyid'] = $surveyid; $aData['gid'] = $gid; $questionTemplateAttributes = Question::model()->getAdvancedSettingsWithValues($qid, $eqrow['type'], $surveyid); - $aData['aQuestionTemplateAttributes'] = \QuestionTemplate::getQuestionTemplateList($eqrow['type']); + $aData['aQuestionTemplateAttributes'] = $questionTemplateAttributes['question_template']; } else { $aData['aQuestionTemplateAttributes']['core'] = array('title'=>'Default', 'preview'=>\LimeSurvey\Helpers\questionHelper::getQuestionThemePreviewUrl($eqrow['type'])); } diff --git a/application/models/TemplateManifest.php b/application/models/TemplateManifest.php index cb83b6a2156..f716655c106 100755 --- a/application/models/TemplateManifest.php +++ b/application/models/TemplateManifest.php @@ -162,12 +162,16 @@ public function extendsFile($sFile) if (!file_exists($this->path.$sFile) && !file_exists($this->viewPath.$sFile)) { // Copy file from mother template to local directory - $sRfilePath = $this->getFilePath($sFile, $this); - $sLfilePath = (pathinfo($sFile, PATHINFO_EXTENSION) == 'twig') ? $this->viewPath.$sFile : $this->path.$sFile; - copy($sRfilePath, $sLfilePath); + $sSourceFilePath = $this->getFilePath($sFile, $this); + $sDestinationFilePath = (pathinfo($sFile, PATHINFO_EXTENSION) == 'twig') ? $this->viewPath.$sFile : $this->path.$sFile; + + //PHP 7 seems not to create the folder on copy automatically. + @mkdir(dirname($sDestinationFilePath), 0775, true); + + copy($sSourceFilePath, $sDestinationFilePath); // If it's a css or js file from config... must update DB and XML too.... - $sExt = pathinfo($sLfilePath, PATHINFO_EXTENSION); + $sExt = pathinfo($sDestinationFilePath, PATHINFO_EXTENSION); if ($sExt == "css" || $sExt == "js") { // Check if that CSS/JS file is in DB/XML diff --git a/application/third_party/gtranslate-api/GTranslate.php b/application/third_party/gtranslate-api/GTranslate.php index 884b7b366ef..dda4b1d934f 100644 --- a/application/third_party/gtranslate-api/GTranslate.php +++ b/application/third_party/gtranslate-api/GTranslate.php @@ -61,14 +61,14 @@ class GTranslate * @access private * @var String */ - private $url = "http://ajax.googleapis.com/ajax/services/language/translate"; + private $url = "https://www.googleapis.com/language/translate/v2"; /** * Google Translate (TM) Api Version * @access private * @var String */ - private $api_version = "1.0"; + private $api_version = "2"; /** * Comunication Transport Method @@ -163,9 +163,9 @@ private function parseLanguageFile() private function urlFormat($lang_pair,$string) { $parameters = array( - "v" => $this->api_version, "q" => $string, - "langpair"=> implode("|",$lang_pair) + "source" => $lang_pair[0], + "target" => $lang_pair[1], ); if(!empty($this->api_key)) @@ -173,16 +173,10 @@ private function urlFormat($lang_pair,$string) $parameters["key"] = $this->api_key; } - if( empty($this->user_ip) ) - { - if( !empty($_SERVER["REMOTE_ADDR"]) ) - { - $parameters["userip"] = $_SERVER["REMOTE_ADDR"]; - } - } else - { - $parameters["userip"] = $this->user_ip; - } + else + { + $parameters["key"] = getGlobalSetting('googletranslateapikey'); + } $url = ""; @@ -274,8 +268,11 @@ public function query($lang_pair,$string) private function requestHttp($url) { - - return GTranslate::evalResponse(json_decode(file_get_contents($this->url."?".$url))); + $fullurl = $this->url."?".$url; + $return = file_get_contents($fullurl); + $json = json_decode($return); + return GTranslate::evalResponse($json); + } /** @@ -308,16 +305,14 @@ private function requestCurl($url) private function evalResponse($json_response) { - - switch($json_response->responseStatus) - { - case 200: - return $json_response->responseData->translatedText; - break; - default: - throw new GTranslateException("Unable to perform Translation:".$json_response->responseDetails); - break; - } + if (isset($json_response->data->translations)) + { + return $json_response->data->translations[0]->translatedText; + } + else + { + throw new GTranslateException("Unable to perform Translation:".$json_response->data); + } } diff --git a/application/views/admin/survey/Question/editQuestion_view.php b/application/views/admin/survey/Question/editQuestion_view.php index c9cdd51591e..03ff9c9c715 100644 --- a/application/views/admin/survey/Question/editQuestion_view.php +++ b/application/views/admin/survey/Question/editQuestion_view.php @@ -17,6 +17,7 @@ $aQuestionTypeGroups = array(); $aQuestionTypeList = Question::typeList(); $question_template_preview = \LimeSurvey\Helpers\questionHelper::getQuestionThemePreviewUrl($eqrow['type']); +$selected = null; foreach ( $aQuestionTypeList as $key=> $questionType) { @@ -245,10 +246,12 @@