public static function updateConfig($projectId, $config) { $project = new LexiconProjectModel($projectId); $configModel = new LexConfiguration(); JsonDecoder::decode($configModel, $config); $project->config = $configModel; $decoder = new JsonDecoder(); $decoder->decodeMapOf('', $project->inputSystems, $config['inputSystems']); $project->write(); }
public function run($userId, $mode = 'test') { $testMode = $mode != 'run'; $message = "Fix Lexicon View Settings to default to visible\n\n"; $projectlist = new ProjectListModel(); $projectlist->read(); foreach ($projectlist->entries as $projectParams) { // foreach existing project $projectId = $projectParams['id']; $project = new ProjectModel($projectId); if ($project->appName == 'lexicon') { $project = new LexiconProjectModel($projectId); $message .= "Inspecting project {$project->projectName}.\n"; $showFieldUpdated = 0; $roleShowFieldUpdated = 0; foreach ($project->config->roleViews as $role => $roleView) { foreach ($roleView->fields as $fieldName => $field) { if (!$field->show) { $field->show = true; $showFieldUpdated++; $roleShowFieldUpdated++; } } } $userShowFieldUpdated = 0; foreach ($project->config->userViews as $userId => $userView) { foreach ($userView->fields as $fieldName => $field) { if (!$field->show) { $field->show = true; $showFieldUpdated++; $userShowFieldUpdated++; } } } if ($showFieldUpdated > 0) { $message .= " Changed {$showFieldUpdated} View Settings fields to be visible. This comprised: \n"; $message .= " - Changed {$roleShowFieldUpdated} role-based View Settings fields to be visible.\n"; $message .= " - Changed {$userShowFieldUpdated} user-based View Settings fields to be visible.\n\n"; if (!$testMode) { $message .= " Saving changes to project {$project->projectName}.\n\n"; $project->write(); } } else { $message .= " No invisible View Settings fields found/changed.\n\n"; } } } return $message; }
$question1 = QuestionCommands::updateQuestion($testProject, array('id' => '', 'textRef' => $text1, 'title' => $constants['testText1Question1Title'], 'description' => $constants['testText1Question1Content'])); $question2 = QuestionCommands::updateQuestion($testProject, array('id' => '', 'textRef' => $text1, 'title' => $constants['testText1Question2Title'], 'description' => $constants['testText1Question2Content'])); $template1 = QuestionTemplateCommands::updateTemplate($testProject, array('id' => '', 'title' => 'first template', 'description' => 'not particularly interesting')); $template2 = QuestionTemplateCommands::updateTemplate($testProject, array('id' => '', 'title' => 'second template', 'description' => 'not entirely interesting')); $answer1 = QuestionCommands::updateAnswer($testProject, $question1, array('id' => '', 'content' => $constants['testText1Question1Answer']), $managerUserId); $answer1Id = array_keys($answer1)[0]; $answer2 = QuestionCommands::updateAnswer($testProject, $question2, array('id' => '', 'content' => $constants['testText1Question2Answer']), $managerUserId); $answer2Id = array_keys($answer2)[0]; $comment1 = QuestionCommands::updateComment($testProject, $question1, $answer1Id, array('id' => '', 'content' => $constants['testText1Question1Answer1Comment']), $managerUserId); $comment2 = QuestionCommands::updateComment($testProject, $question2, $answer2Id, array('id' => '', 'content' => $constants['testText1Question2Answer2Comment']), $managerUserId); } elseif ($site == 'languageforge') { // Set up LanguageForge E2E test envrionment here $testProjectModel = new LexiconProjectModel($testProject); $testProjectModel->addInputSystem("th-fonipa", "tipa", "Thai"); $testProjectModel->config->entry->fields[LexiconConfigObj::LEXEME]->inputSystems[] = 'th-fonipa'; $testProjectId = $testProjectModel->write(); // setup to mimic file upload $fileName = $constants['testEntry1']['senses'][0]['pictures'][0]['fileName']; $file = array(); $file['name'] = $fileName; $_FILES['file'] = $file; // put a copy of the test file in tmp $tmpFilePath = sys_get_temp_dir() . "/CopyOf{$fileName}"; copy(dirname(TestPath) . "/php/common/{$fileName}", $tmpFilePath); $response = LexUploadCommands::uploadImageFile($testProjectId, 'sense-image', $tmpFilePath); // cleanup tmp file if it still exists if (file_exists($tmpFilePath) and !is_dir($tmpFilePath)) { @unlink($tmpFilePath); } // put uploaded file into entry1 $constants['testEntry1']['senses'][0]['pictures'][0]['fileName'] = $response->data->fileName;