/** * @param LexProjectModel $projectModel * @param string $fieldName * @param string $jsonFilePath * @return bool true on success, false otherwise * @throws \Exception */ public static function CreateFromJson($projectModel, $fieldName, $jsonFilePath) { $optionList = new LexOptionListModel($projectModel); $listCode = LexConfig::flexOptionlistCode($fieldName); if (!$optionList->readByProperty('code', $listCode)) { $optionList->name = LexConfig::flexOptionlistName($listCode); $optionList->code = $listCode; $optionList->canDelete = false; $optionList->readFromJson($jsonFilePath); $optionList->write(); return true; } return false; }
/** * Initialize the optionlists in a project */ public function initializeNewProject() { // setup default option lists $optionList = new LexOptionListModel($this); $listCode = LexiconConfigObj::flexOptionlistCode(LexiconConfigObj::POS); if (!$optionList->readByProperty('code', $listCode)) { $optionList->name = LexiconConfigObj::flexOptionlistName($listCode); $optionList->code = $listCode; $optionList->canDelete = false; $optionList->readFromJson(APPPATH . 'json/languageforge/lexicon/partOfSpeech.json'); $optionList->write(); } /* $optionList = new LexOptionListModel($this); $optionList->name = 'Semantic Domains'; $optionList->code = 'semdom'; $optionList->canDelete = false; $optionList->readFromJson(APPPATH . 'json/languageforge/lexicon/semdom.json'); $optionList->write(); // we should have a default list for every delivered field that is an option list type $optionList = new LexOptionListModel($this); $optionList->name = 'Environments'; $optionList->code = 'environments'; $optionList->canDelete = false; $optionList->readFromJson($environmentsFilePath); $optionList->write(); */ // repeat for other delivered option list types }