コード例 #1
0
 public function __construct()
 {
     parent::__construct();
     $this->type = self::FIELDLIST;
     $this->fieldOrder = new ArrayOf();
     $this->fields = new MapOf(function ($data) {
         switch ($data['type']) {
             case self::FIELDLIST:
                 return new LexConfigFieldList();
             case self::MULTITEXT:
                 return new LexConfigMultiText();
             case self::MULTIPARAGRAPH:
                 return new LexConfigMultiParagraph();
             case self::OPTIONLIST:
                 return new LexConfigOptionList();
             case self::MULTIOPTIONLIST:
                 return new LexConfigMultiOptionList();
             case self::PICTURES:
                 return new LexConfigPictures();
             default:
                 $type = $data['type'];
                 throw new \Exception("Unknown field list config type: {$type}");
         }
     });
 }
コード例 #2
0
 public function __construct()
 {
     parent::__construct();
     $this->type = LexConfig::MULTITEXT;
     $this->displayMultiline = false;
     $this->width = 20;
     $this->inputSystems = new ArrayOf();
 }
コード例 #3
0
 /**
  * @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;
 }
コード例 #4
0
 public function __construct()
 {
     $this->tasks = new MapOf(function ($data) {
         switch ($data['type']) {
             case LexTask::DASHBOARD:
                 return new LexTaskDashboard();
             case LexTask::SEMDOM:
                 return new LexTaskSemdom();
             default:
                 return new LexTask();
         }
     });
     $this->roleViews = new MapOf(function () {
         return new LexRoleViewConfig();
     });
     $this->userViews = new MapOf(function () {
         return new LexUserViewConfig();
     });
     // default tasks values
     $this->tasks[LexTask::VIEW] = new LexTask();
     $this->tasks[LexTask::DASHBOARD] = new LexTaskDashboard();
     $this->tasks[LexTask::GATHERTEXTS] = new LexTask();
     $this->tasks[LexTask::SEMDOM] = new LexTaskSemdom();
     $this->tasks[LexTask::WORDLIST] = new LexTask();
     $this->tasks[LexTask::DBE] = new LexTask();
     $this->tasks[LexTask::ADDMEANINGS] = new LexTask();
     $this->tasks[LexTask::ADDGRAMMAR] = new LexTask();
     $this->tasks[LexTask::ADDEXAMPLES] = new LexTask();
     $this->tasks[LexTask::REVIEW] = new LexTask();
     $this->tasks[LexTask::IMPORTEXPORT] = new LexTask();
     $this->tasks[LexTask::CONFIGURATION] = new LexTask();
     // default entry fields values
     $this->entry = new LexConfigFieldList();
     $this->entry->fieldOrder[] = LexConfig::LEXEME;
     $this->entry->fieldOrder[] = LexConfig::CITATIONFORM;
     //$this->entry->fieldOrder[] = LexConfig::ENVIRONMENTS; // Disabled 05-2016
     $this->entry->fieldOrder[] = LexConfig::PRONUNCIATION;
     $this->entry->fieldOrder[] = LexConfig::CVPATTERN;
     $this->entry->fieldOrder[] = LexConfig::TONE;
     $this->entry->fieldOrder[] = LexConfig::LOCATION;
     $this->entry->fieldOrder[] = LexConfig::ETYMOLOGY;
     $this->entry->fieldOrder[] = LexConfig::ETYMOLOGYGLOSS;
     $this->entry->fieldOrder[] = LexConfig::ETYMOLOGYCOMMENT;
     $this->entry->fieldOrder[] = LexConfig::ETYMOLOGYSOURCE;
     $this->entry->fieldOrder[] = LexConfig::NOTE;
     $this->entry->fieldOrder[] = LexConfig::LITERALMEANING;
     $this->entry->fieldOrder[] = LexConfig::ENTRYBIBLIOGRAPHY;
     $this->entry->fieldOrder[] = LexConfig::ENTRYRESTRICTIONS;
     $this->entry->fieldOrder[] = LexConfig::SUMMARYDEFINITION;
     $this->entry->fieldOrder[] = LexConfig::ENTRYIMPORTRESIDUE;
     $this->entry->fieldOrder[] = LexConfig::SENSES_LIST;
     $this->entry->fields[LexConfig::LEXEME] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::LEXEME]->label = 'Word';
     $this->entry->fields[LexConfig::LEXEME]->inputSystems[] = 'th';
     $this->entry->fields[LexConfig::SENSES_LIST] = new LexConfigFieldList();
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::DEFINITION;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::GLOSS;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::PICTURES;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::POS;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::SEMDOM;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::SCIENTIFICNAME;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::ANTHROPOLOGYNOTE;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::SENSEBIBLIOGRAPHY;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::DISCOURSENOTE;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::ENCYCLOPEDICNOTE;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::GENERALNOTE;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::GRAMMARNOTE;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::PHONOLOGYNOTE;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::SENSERESTRCTIONS;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::SEMANTICSNOTE;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::SOCIOLINGUISTICSNOTE;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::SOURCE;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::USAGES;
     //$this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::REVERSALENTRIES; // Disabled 05-2016
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::SENSETYPE;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::ACADEMICDOMAINS;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::SENSEPUBLISHIN;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::ANTHROPOLOGYCATEGORIES;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::SENSEIMPORTRESIDUE;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::STATUS;
     $this->entry->fields[LexConfig::SENSES_LIST]->fieldOrder[] = LexConfig::EXAMPLES_LIST;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::DEFINITION] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::DEFINITION]->label = 'Definition';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::DEFINITION]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::POS] = new LexConfigOptionList();
     $listCode = LexConfig::flexOptionlistCode(LexConfig::POS);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::POS]->label = LexConfig::flexOptionlistName($listCode);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::POS]->listCode = $listCode;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SEMDOM] = new LexConfigMultiOptionList();
     $listCode = LexConfig::flexOptionlistCode(LexConfig::SEMDOM);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SEMDOM]->label = LexConfig::flexOptionlistName($listCode);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SEMDOM]->listCode = $listCode;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST] = new LexConfigFieldList();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fieldOrder[] = LexConfig::EXAMPLE_SENTENCE;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fieldOrder[] = LexConfig::EXAMPLE_TRANSLATION;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fieldOrder[] = LexConfig::REFERENCE;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fieldOrder[] = LexConfig::EXAMPLEPUBLISHIN;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::EXAMPLE_SENTENCE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::EXAMPLE_SENTENCE]->label = 'Sentence';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::EXAMPLE_SENTENCE]->inputSystems[] = 'th';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::EXAMPLE_TRANSLATION] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::EXAMPLE_TRANSLATION]->label = 'Translation';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::EXAMPLE_TRANSLATION]->inputSystems[] = 'en';
     //$this->entry->fields[LexConfig::CUSTOM_FIELDS_LIST] = new LexConfigFieldList();
     //$this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::CUSTOM_FIELDS_LIST] = new LexConfigFieldList();
     //$this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::CUSTOM_FIELDS_LIST] = new LexConfigFieldList();
     /*  Configuration for less common fields (mostly used in FLEx are defined below) */
     $this->entry->fields[LexConfig::CITATIONFORM] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::CITATIONFORM]->label = 'Citation Form';
     $this->entry->fields[LexConfig::CITATIONFORM]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::CITATIONFORM]->inputSystems[] = 'th';
     /*
     ENVIRONMENTS disabled 05-2016
     $this->entry->fields[LexConfig::ENVIRONMENTS] = new LexConfigMultiOptionList();
     $listCode = LexConfig::flexOptionlistCode(LexConfig::ENVIRONMENTS);
     $this->entry->fields[LexConfig::ENVIRONMENTS]->label = LexConfig::flexOptionlistName($listCode);
     $this->entry->fields[LexConfig::ENVIRONMENTS]->listCode = $listCode;
     $this->entry->fields[LexConfig::ENVIRONMENTS]->hideIfEmpty = true;
     */
     $this->entry->fields[LexConfig::PRONUNCIATION] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::PRONUNCIATION]->label = 'Pronunciation';
     $this->entry->fields[LexConfig::PRONUNCIATION]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::PRONUNCIATION]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::CVPATTERN] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::CVPATTERN]->label = 'CV Pattern';
     $this->entry->fields[LexConfig::CVPATTERN]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::CVPATTERN]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::TONE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::TONE]->label = 'Tone';
     $this->entry->fields[LexConfig::TONE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::TONE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::LOCATION] = new LexConfigOptionList();
     $listCode = LexConfig::flexOptionlistCode(LexConfig::LOCATION);
     $this->entry->fields[LexConfig::LOCATION]->label = LexConfig::flexOptionlistName($listCode);
     $this->entry->fields[LexConfig::LOCATION]->listCode = $listCode;
     $this->entry->fields[LexConfig::LOCATION]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::ETYMOLOGY] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::ETYMOLOGY]->label = 'Etymology';
     $this->entry->fields[LexConfig::ETYMOLOGY]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::ETYMOLOGY]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::ETYMOLOGYGLOSS] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::ETYMOLOGYGLOSS]->label = 'Etymology Gloss';
     $this->entry->fields[LexConfig::ETYMOLOGYGLOSS]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::ETYMOLOGYGLOSS]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::ETYMOLOGYCOMMENT] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::ETYMOLOGYCOMMENT]->label = 'Etymology Comment';
     $this->entry->fields[LexConfig::ETYMOLOGYCOMMENT]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::ETYMOLOGYCOMMENT]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::ETYMOLOGYSOURCE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::ETYMOLOGYSOURCE]->label = 'Etymology Source';
     $this->entry->fields[LexConfig::ETYMOLOGYSOURCE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::ETYMOLOGYSOURCE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::NOTE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::NOTE]->label = 'Note';
     $this->entry->fields[LexConfig::NOTE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::NOTE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::LITERALMEANING] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::LITERALMEANING]->label = 'Literal Meaning';
     $this->entry->fields[LexConfig::LITERALMEANING]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::LITERALMEANING]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::ENTRYBIBLIOGRAPHY] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::ENTRYBIBLIOGRAPHY]->label = 'Bibliography';
     $this->entry->fields[LexConfig::ENTRYBIBLIOGRAPHY]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::ENTRYBIBLIOGRAPHY]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::ENTRYRESTRICTIONS] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::ENTRYRESTRICTIONS]->label = 'Restrictions';
     $this->entry->fields[LexConfig::ENTRYRESTRICTIONS]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::ENTRYRESTRICTIONS]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SUMMARYDEFINITION] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SUMMARYDEFINITION]->label = 'Summary Definition';
     $this->entry->fields[LexConfig::SUMMARYDEFINITION]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SUMMARYDEFINITION]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::ENTRYIMPORTRESIDUE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::ENTRYIMPORTRESIDUE]->label = 'Import Residue';
     $this->entry->fields[LexConfig::ENTRYIMPORTRESIDUE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::ENTRYIMPORTRESIDUE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::GLOSS] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::GLOSS]->label = 'Gloss';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::GLOSS]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::GLOSS]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::PICTURES] = new LexConfigPictures();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::PICTURES]->label = 'Pictures';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::PICTURES]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::PICTURES]->captionLabel = 'Captions';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::PICTURES]->captionHideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::PICTURES]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SCIENTIFICNAME] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SCIENTIFICNAME]->label = 'Scientific Name';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SCIENTIFICNAME]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SCIENTIFICNAME]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ANTHROPOLOGYNOTE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ANTHROPOLOGYNOTE]->label = 'Anthropology Note';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ANTHROPOLOGYNOTE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ANTHROPOLOGYNOTE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSEBIBLIOGRAPHY] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSEBIBLIOGRAPHY]->label = 'Bibliography';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSEBIBLIOGRAPHY]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSEBIBLIOGRAPHY]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::DISCOURSENOTE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::DISCOURSENOTE]->label = 'Discourse Note';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::DISCOURSENOTE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::DISCOURSENOTE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ENCYCLOPEDICNOTE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ENCYCLOPEDICNOTE]->label = 'Encyclopedic Note';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ENCYCLOPEDICNOTE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ENCYCLOPEDICNOTE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::GENERALNOTE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::GENERALNOTE]->label = 'General Note';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::GENERALNOTE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::GENERALNOTE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::GRAMMARNOTE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::GRAMMARNOTE]->label = 'Grammar Note';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::GRAMMARNOTE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::GRAMMARNOTE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::PHONOLOGYNOTE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::PHONOLOGYNOTE]->label = 'Phonology Note';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::PHONOLOGYNOTE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::PHONOLOGYNOTE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSERESTRCTIONS] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSERESTRCTIONS]->label = 'Restrictions';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSERESTRCTIONS]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSERESTRCTIONS]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SEMANTICSNOTE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SEMANTICSNOTE]->label = 'Semantics Note';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SEMANTICSNOTE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SEMANTICSNOTE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SOCIOLINGUISTICSNOTE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SOCIOLINGUISTICSNOTE]->label = 'Sociolinguistics Note';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SOCIOLINGUISTICSNOTE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SOCIOLINGUISTICSNOTE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SOURCE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SOURCE]->label = 'Source';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SOURCE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SOURCE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::USAGES] = new LexConfigMultiOptionList();
     $listCode = LexConfig::flexOptionlistCode(LexConfig::USAGES);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::USAGES]->label = LexConfig::flexOptionlistName($listCode);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::USAGES]->listCode = $listCode;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::USAGES]->hideIfEmpty = true;
     // TODO This needs to be a taglist DDW 2014-07
     /*
     REVERSALENTRIES disabled 05-2016
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::REVERSALENTRIES] = new LexConfigMultiOptionList();
     $listCode = LexConfig::flexOptionlistCode(LexConfig::REVERSALENTRIES);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::REVERSALENTRIES]->label = LexConfig::flexOptionlistName($listCode);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::REVERSALENTRIES]->listCode = $listCode;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::REVERSALENTRIES]->hideIfEmpty = true;
     */
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSETYPE] = new LexConfigOptionList();
     $listCode = LexConfig::flexOptionlistCode(LexConfig::SENSETYPE);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSETYPE]->label = LexConfig::flexOptionlistName($listCode);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSETYPE]->listCode = $listCode;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSETYPE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ACADEMICDOMAINS] = new LexConfigMultiOptionList();
     $listCode = LexConfig::flexOptionlistCode(LexConfig::ACADEMICDOMAINS);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ACADEMICDOMAINS]->label = LexConfig::flexOptionlistName($listCode);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ACADEMICDOMAINS]->listCode = $listCode;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ACADEMICDOMAINS]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSEPUBLISHIN] = new LexConfigMultiOptionList();
     $listCode = LexConfig::flexOptionlistCode(LexConfig::SENSEPUBLISHIN);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSEPUBLISHIN]->label = LexConfig::flexOptionlistName($listCode);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSEPUBLISHIN]->listCode = $listCode;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSEPUBLISHIN]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ANTHROPOLOGYCATEGORIES] = new LexConfigMultiOptionList();
     $listCode = LexConfig::flexOptionlistCode(LexConfig::ANTHROPOLOGYCATEGORIES);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ANTHROPOLOGYCATEGORIES]->label = LexConfig::flexOptionlistName($listCode);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ANTHROPOLOGYCATEGORIES]->listCode = $listCode;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::ANTHROPOLOGYCATEGORIES]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSEIMPORTRESIDUE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSEIMPORTRESIDUE]->label = 'Import Residue';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSEIMPORTRESIDUE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::SENSEIMPORTRESIDUE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::STATUS] = new LexConfigOptionList();
     $listCode = LexConfig::flexOptionlistCode(LexConfig::STATUS);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::STATUS]->label = LexConfig::flexOptionlistName($listCode);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::STATUS]->listCode = $listCode;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::STATUS]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::REFERENCE] = new LexConfigMultiText();
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::REFERENCE]->label = 'Reference';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::REFERENCE]->hideIfEmpty = true;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::REFERENCE]->inputSystems[] = 'en';
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::EXAMPLEPUBLISHIN] = new LexConfigMultiOptionList();
     $listCode = LexConfig::flexOptionlistCode(LexConfig::EXAMPLEPUBLISHIN);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::EXAMPLEPUBLISHIN]->label = LexConfig::flexOptionlistName($listCode);
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::EXAMPLEPUBLISHIN]->listCode = $listCode;
     $this->entry->fields[LexConfig::SENSES_LIST]->fields[LexConfig::EXAMPLES_LIST]->fields[LexConfig::EXAMPLEPUBLISHIN]->hideIfEmpty = true;
     // default role views values
     $this->roleViews[LexRoles::OBSERVER] = new LexRoleViewConfig();
     $this->roleViews[LexRoles::OBSERVER_WITH_COMMENT] = new LexRoleViewConfig();
     $this->roleViews[LexRoles::CONTRIBUTOR] = new LexRoleViewConfig();
     $this->roleViews[LexRoles::MANAGER] = new LexRoleViewConfig();
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::LEXEME] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::DEFINITION] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::POS] = new LexViewFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::SEMDOM] = new LexViewFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::EXAMPLE_SENTENCE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::EXAMPLE_TRANSLATION] = new LexViewMultiTextFieldConfig(true);
     // Less common fields are visible by default
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::GLOSS] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::PICTURES] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::CITATIONFORM] = new LexViewMultiTextFieldConfig(true);
     //$this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::ENVIRONMENTS] = new LexViewFieldConfig(true); // Disabled 05-2016
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::PRONUNCIATION] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::CVPATTERN] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::TONE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::LOCATION] = new LexViewFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::ETYMOLOGY] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::ETYMOLOGYGLOSS] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::ETYMOLOGYCOMMENT] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::ETYMOLOGYSOURCE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::NOTE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::LITERALMEANING] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::ENTRYBIBLIOGRAPHY] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::ENTRYRESTRICTIONS] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::SUMMARYDEFINITION] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::ENTRYIMPORTRESIDUE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::SCIENTIFICNAME] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::ANTHROPOLOGYNOTE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::SENSEBIBLIOGRAPHY] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::DISCOURSENOTE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::ENCYCLOPEDICNOTE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::GENERALNOTE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::GRAMMARNOTE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::PHONOLOGYNOTE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::SENSERESTRCTIONS] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::SEMANTICSNOTE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::SOCIOLINGUISTICSNOTE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::SOURCE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::USAGES] = new LexViewFieldConfig(true);
     //$this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::REVERSALENTRIES] = new LexViewFieldConfig(true); // Disabled 05-2016
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::SENSETYPE] = new LexViewFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::ACADEMICDOMAINS] = new LexViewFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::SENSEPUBLISHIN] = new LexViewFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::ANTHROPOLOGYCATEGORIES] = new LexViewFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::SENSEIMPORTRESIDUE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::STATUS] = new LexViewFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::REFERENCE] = new LexViewMultiTextFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER]->fields[LexConfig::EXAMPLEPUBLISHIN] = new LexViewFieldConfig(true);
     $this->roleViews[LexRoles::OBSERVER_WITH_COMMENT]->fields = clone $this->roleViews[LexRoles::OBSERVER]->fields;
     $this->roleViews[LexRoles::CONTRIBUTOR]->fields = clone $this->roleViews[LexRoles::OBSERVER]->fields;
     $this->roleViews[LexRoles::MANAGER]->fields = clone $this->roleViews[LexRoles::OBSERVER]->fields;
     $this->roleViews[LexRoles::OBSERVER]->showTasks[LexTask::VIEW] = true;
     $this->roleViews[LexRoles::OBSERVER]->showTasks[LexTask::DASHBOARD] = true;
     $this->roleViews[LexRoles::OBSERVER]->showTasks[LexTask::GATHERTEXTS] = false;
     $this->roleViews[LexRoles::OBSERVER]->showTasks[LexTask::SEMDOM] = false;
     $this->roleViews[LexRoles::OBSERVER]->showTasks[LexTask::WORDLIST] = false;
     $this->roleViews[LexRoles::OBSERVER]->showTasks[LexTask::DBE] = true;
     $this->roleViews[LexRoles::OBSERVER]->showTasks[LexTask::ADDMEANINGS] = false;
     $this->roleViews[LexRoles::OBSERVER]->showTasks[LexTask::ADDGRAMMAR] = false;
     $this->roleViews[LexRoles::OBSERVER]->showTasks[LexTask::ADDEXAMPLES] = false;
     $this->roleViews[LexRoles::OBSERVER]->showTasks[LexTask::REVIEW] = false;
     $this->roleViews[LexRoles::OBSERVER_WITH_COMMENT]->showTasks = clone $this->roleViews[LexRoles::OBSERVER]->showTasks;
     $this->roleViews[LexRoles::CONTRIBUTOR]->showTasks = clone $this->roleViews[LexRoles::OBSERVER]->showTasks;
     $this->roleViews[LexRoles::CONTRIBUTOR]->showTasks[LexTask::ADDMEANINGS] = true;
     $this->roleViews[LexRoles::CONTRIBUTOR]->showTasks[LexTask::ADDGRAMMAR] = true;
     $this->roleViews[LexRoles::CONTRIBUTOR]->showTasks[LexTask::ADDEXAMPLES] = true;
     $this->roleViews[LexRoles::MANAGER]->showTasks = clone $this->roleViews[LexRoles::CONTRIBUTOR]->showTasks;
     $this->roleViews[LexRoles::MANAGER]->showTasks[LexTask::GATHERTEXTS] = true;
     $this->roleViews[LexRoles::MANAGER]->showTasks[LexTask::SEMDOM] = true;
     $this->roleViews[LexRoles::MANAGER]->showTasks[LexTask::WORDLIST] = true;
     $this->roleViews[LexRoles::MANAGER]->showTasks[LexTask::REVIEW] = true;
 }
コード例 #5
0
 /**
  * @param string $liftFilePath
  * @param LexProjectModel $projectModel
  * @param string $mergeRule (use LiftMergeRule const)
  * @param boolean $skipSameModTime
  * @param boolean $deleteMatchingEntry
  * @return LiftImport
  */
 public function merge($liftFilePath, $projectModel, $mergeRule = LiftMergeRule::CREATE_DUPLICATES, $skipSameModTime = true, $deleteMatchingEntry = false)
 {
     ini_set('max_execution_time', 180);
     // Sufficient time to import webster.  TODO Make this async CP 2014-10
     $entryList = new LexEntryListModel($projectModel);
     $entryList->read();
     $hasExistingData = $entryList->count != 0;
     $savedInputSystems = array();
     if (!$hasExistingData) {
         $projectModel->config->clearAllInputSystems();
         // save and clear input systems
         $savedInputSystems = $projectModel->inputSystems->getArrayCopy();
         $projectModel->inputSystems->exchangeArray(array());
     }
     $reader = new \XMLReader();
     $reader->open($liftFilePath);
     $this->liftDecoder = new LiftDecoder($projectModel);
     $this->stats = new LiftImportStats($entryList->count);
     $this->report = new ImportErrorReport();
     $this->liftImportNodeError = new LiftImportNodeError(LiftImportNodeError::FILE, basename($liftFilePath));
     $liftRangeDecoder = new LiftRangeDecoder($projectModel);
     $liftRangeFiles = array();
     // Key: filenames. Value: parsed files.
     $liftRanges = array();
     // Key: @id attributes of <range> elements. Value: parsed <range> elements.
     $liftFolderPath = dirname($liftFilePath);
     while ($reader->read()) {
         // Read LIFT ranges in the header of the LIFT file
         if ($reader->nodeType == \XMLReader::ELEMENT && $reader->localName == 'range') {
             $node = $reader->expand();
             $rangeId = $node->attributes->getNamedItem('id')->textContent;
             $rangeHref = $node->attributes->getNamedItem('href')->textContent;
             $hrefPath = parse_url($rangeHref, PHP_URL_PATH);
             $rangeFilename = basename($hrefPath);
             $rangeFilePath = null;
             $rangeImportNodeError = new LiftRangeImportNodeError(LiftRangeImportNodeError::FILE, $rangeFilename);
             if (!array_key_exists($rangeFilename, $liftRangeFiles)) {
                 // Haven't parsed the .lift-ranges file yet. We'll assume it is alongside the .lift file.
                 $rangeFilePath = $liftFolderPath . "/" . $rangeFilename;
                 if (file_exists($rangeFilePath)) {
                     $sxeNode = simplexml_load_file($rangeFilePath);
                     $parsedRanges = $liftRangeDecoder->decode($sxeNode);
                     $liftRanges = array_merge($liftRanges, $parsedRanges);
                     $liftRangeFiles[] = $rangeFilename;
                 } else {
                     // Range file was NOT found in alongside the .lift file
                     $rangeImportNodeError->addRangeFileNotFound(basename($liftFilePath));
                 }
             }
             // pull out the referenced range
             if (isset($liftRanges[$rangeId])) {
                 $range = $liftRanges[$rangeId];
             } else {
                 $range = null;
                 if (file_exists($rangeFilePath)) {
                     // Range was NOT found in referenced .lift-ranges file after parsing it
                     $rangeImportNodeError->addRangeNotFound($rangeId);
                 }
             }
             // Range elements defined in LIFT file override any values defined in .lift-ranges file.
             if ($node->hasChildNodes()) {
                 $rangeNode = self::domNode_to_sxeNode($node);
                 $range = $liftRangeDecoder->readRange($rangeNode, $range);
                 $liftRanges[$rangeId] = $range;
             }
             if ($rangeImportNodeError->hasErrors()) {
                 $this->liftImportNodeError->addSubnodeError($rangeImportNodeError);
             }
         }
         // Read the custom 'fields' spec in the header of the LIFT file
         if ($reader->nodeType == \XMLReader::ELEMENT && $reader->localName == 'fields') {
             $isInFieldsSectionOfLift = true;
             $this->liftDecoder->liftFields = array();
             while ($isInFieldsSectionOfLift && $reader->read()) {
                 if ($reader->nodeType == \XMLReader::ELEMENT && $reader->localName == 'field') {
                     $node = $reader->expand();
                     $sxeNode = self::domNode_to_sxeNode($node);
                     $LiftFieldTag = (string) $sxeNode['tag'];
                     $liftField = array();
                     /** @var \SimpleXMLElement $element */
                     foreach ($sxeNode as $element) {
                         if ($element->getName() === 'form') {
                             $inputSystemTag = (string) $element['lang'];
                             $liftField[$inputSystemTag] = (string) $element->{'text'};
                         }
                     }
                     $this->liftDecoder->liftFields[$LiftFieldTag] = $liftField;
                 } elseif ($reader->nodeType == \XMLReader::END_ELEMENT && $reader->localName == 'fields') {
                     $isInFieldsSectionOfLift = false;
                 }
             }
         }
         // Read an entry node
         if ($reader->nodeType == \XMLReader::ELEMENT && $reader->localName == 'entry') {
             $this->stats->importEntries++;
             $node = $reader->expand();
             $sxeNode = self::domNode_to_sxeNode($node);
             $guid = $reader->getAttribute('guid');
             $existingEntry = $entryList->searchEntriesFor('guid', $guid);
             if ($existingEntry) {
                 $entry = new LexEntryModel($projectModel, $existingEntry['id']);
                 $dateModified = $reader->getAttribute('dateModified');
                 if (self::differentModTime($dateModified, $entry->authorInfo->modifiedDate) || !$skipSameModTime) {
                     if ($mergeRule == LiftMergeRule::CREATE_DUPLICATES) {
                         $entry = new LexEntryModel($projectModel);
                         $this->readEntryWithErrorReport($sxeNode, $entry, $mergeRule);
                         $entry->guid = '';
                         $entry->write();
                         $this->stats->entriesDuplicated++;
                     } else {
                         if (isset($sxeNode->{'lexical-unit'})) {
                             $this->readEntryWithErrorReport($sxeNode, $entry, $mergeRule);
                             $entry->write();
                             $this->stats->entriesMerged++;
                         } elseif (isset($sxeNode->attributes()->{'dateDeleted'}) && $deleteMatchingEntry) {
                             LexEntryModel::remove($projectModel, $existingEntry['id']);
                             $this->stats->entriesDeleted++;
                         }
                     }
                 } else {
                     // skip because same mod time and skip enabled
                     if (!isset($sxeNode->{'lexical-unit'}) && isset($sxeNode->attributes()->{'dateDeleted'}) && $deleteMatchingEntry) {
                         LexEntryModel::remove($projectModel, $existingEntry['id']);
                         $this->stats->entriesDeleted++;
                     }
                 }
             } else {
                 if (isset($sxeNode->{'lexical-unit'})) {
                     $entry = new LexEntryModel($projectModel);
                     $this->readEntryWithErrorReport($sxeNode, $entry, $mergeRule);
                     $entry->write();
                     $this->stats->newEntries++;
                 }
             }
         }
     }
     $reader->close();
     // put back saved input systems if none found in the imported data
     if (!$hasExistingData && $projectModel->inputSystems->count() <= 0) {
         $projectModel->inputSystems->exchangeArray($savedInputSystems);
     }
     // add lift ranges
     if ($mergeRule != LiftMergeRule::IMPORT_LOSES) {
         foreach ($liftRanges as $liftRangeCode => $liftRange) {
             // add everything except semantic domains
             if (strpos($liftRangeCode, 'semantic-domain') === false) {
                 self::rangeToOptionList($projectModel, $liftRangeCode, LexConfig::flexOptionlistName($liftRangeCode), $liftRange);
             }
         }
     }
     $this->report->nodeErrors[] = $this->liftImportNodeError;
     if ($this->report->hasError()) {
         error_log($this->report->toString());
     }
     return $this;
 }
コード例 #6
0
 public function testLiftImportMerge_ExistingData_RangesChanged()
 {
     $liftFilePath = self::$environ->createTestLiftFile(self::liftWithRangesV0_13, 'LiftWithRangesV0_13.lift');
     self::$environ->createTestLiftFile(self::liftRangesV0_13, 'TestLangProj.lift-ranges');
     $project = self::$environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     $mergeRule = LiftMergeRule::IMPORT_WINS;
     $skipSameModTime = false;
     LiftImport::get()->merge($liftFilePath, $project, $mergeRule, $skipSameModTime);
     $optionList = new LexOptionListModel($project);
     $optionList->readByProperty('code', LexConfig::flexOptionlistCode(LexConfig::POS));
     $this->assertEquals(3, $optionList->items->count());
     $this->assertEquals('article', $optionList->items[0]->value);
     self::$environ->createTestLiftFile(self::liftRangesAnotherPosV0_13, 'TestLangProj.lift-ranges');
     $importer = LiftImport::get()->merge($liftFilePath, $project, $mergeRule, $skipSameModTime);
     $this->assertEquals(1, $importer->stats->existingEntries);
     $optionList = new LexOptionListModel($project);
     $optionList->readByProperty('code', LexConfig::flexOptionlistCode(LexConfig::ANTHROPOLOGYCATEGORIES));
     $this->assertEquals(0, $optionList->items->count());
     $optionList->readByProperty('code', LexConfig::flexOptionlistCode(LexConfig::STATUS));
     $this->assertEquals(4, $optionList->items->count());
     $optionList->readByProperty('code', LexConfig::flexOptionlistCode(LexConfig::ACADEMICDOMAINS));
     $this->assertEquals(2, $optionList->items->count());
     $optionList->readByProperty('code', LexConfig::flexOptionlistCode(LexConfig::POS));
     $this->assertEquals(1, $optionList->items->count());
     $this->assertEquals('adjunct', $optionList->items[0]->value);
 }