} if ($previewButton || $confirmButton) { // Compare the old and new lists. Extract the transforms where needed. $isPronoun = $modelType == 'P'; $regenTransforms = array(); // Recalculate transforms when // (1) the form list has changed OR // (2) an accent was added in the exponent and some forms contain accents OR // (3) the exponent changed (other than by adding an accent) // We do NOT do anything when the isLoc values change. // We do propagate the change to all InflectedForms when the values for recommended change. foreach ($inflections as $infl) { if (!equalArrays($forms[$infl->id], $newForms[$infl->id]) || $exponentAccentAdded && anyAccents($newForms[$infl->id]) || $exponentChanged) { $regenTransforms[$infl->id] = array(); foreach ($newForms[$infl->id] as $tuple) { $transforms = FlexStringUtil::extractTransforms($newExponent, $tuple['form'], $isPronoun); if ($transforms) { $regenTransforms[$infl->id][] = $transforms; } else { $errorMessage[] = "Nu pot extrage transformările între {$newExponent} și " . htmlentities($tuple['form']) . "."; } } } } // Now load the affected lexems. For each lexem, inflection and transform // list, generate a new form. $lexems = Lexem::loadByCanonicalModel($modelType, $modelNumber); $regenForms = array(); foreach ($lexems as $l) { $regenRow = array(); foreach ($regenTransforms as $inflId => $variants) {
assertEquals('a', $t[0]->transfTo); assertEquals('ă', $t[1]->transfFrom); assertEquals('ă', $t[1]->transfTo); assertEquals('a', $t[2]->transfFrom); assertEquals('', $t[2]->transfTo); assertEquals('ă', $t[3]); assertEquals(1, $t[4]); $t = FlexStringUtil::extractTransforms("n'ailon", "nailo'ane", 0); assertEquals(4, count($t)); assertEquals('o', $t[0]->transfFrom); assertEquals('oa', $t[0]->transfTo); assertEquals('', $t[1]->transfFrom); assertEquals('e', $t[1]->transfTo); assertEquals('a', $t[2]); assertEquals(2, $t[3]); $t = FlexStringUtil::extractTransforms("n'ailon", "n'ailonului", 0); assertEquals(2, count($t)); assertEquals('', $t[0]->transfFrom); assertEquals('ului', $t[0]->transfTo); assertEquals(NO_ACCENT_SHIFT, $t[1]); assertEquals(1, FlexStringUtil::countVowels('abc')); assertEquals(2, FlexStringUtil::countVowels('abcde')); assertEquals(8, FlexStringUtil::countVowels('aeiouăâî')); assertEquals('cásă', AdminStringUtil::internalize("c'as~a", false)); assertEquals("c'asă", AdminStringUtil::internalize("c'as~a", true)); assertEquals("cas'ă", FlexStringUtil::placeAccent("casă", 1, '')); assertEquals("c'asă", FlexStringUtil::placeAccent("casă", 2, '')); assertEquals("casă", FlexStringUtil::placeAccent("casă", 3, '')); assertEquals("ap'ă", FlexStringUtil::placeAccent("apă", 1, '')); assertEquals("'apă", FlexStringUtil::placeAccent("apă", 2, '')); assertEquals("apă", FlexStringUtil::placeAccent("apă", 3, ''));