function getModelType() { if ($this->mt === null) { $this->mt = ModelType::get_by_code($this->modelType); } return $this->mt; }
function validateAdd($mt) { if (!$mt->code) { FlashMessage::add('Codul nu poate fi vid.'); } if (ModelType::get_by_code($mt->code)) { FlashMessage::add("Codul '{$mt->code}' este deja folosit."); } if (!$mt->description) { FlashMessage::add('Descrierea nu poate fi vidă. Ea trebuie să indice partea de vorbire și este vizibilă la afișarea paradigmelor.'); } return FlashMessage::getMessage() == null; }
$models[] = $m; $models[] = FlexModel::create('MF', $modelNumber, '', $m->exponent); } else { $models[] = Model::factory('FlexModel')->where('modelType', $modelType)->where('number', $modelNumber)->find_one(); } } $hasInvariableModel = $hasInvariableModel || $modelType == 'I'; } } // Always add the Invariable model if (!$hasInvariableModel) { $models[] = Model::factory('FlexModel')->where('modelType', 'I')->where('number', '1')->find_one(); } $modelTypes = array(); foreach ($models as $m) { $modelTypes[] = ModelType::get_by_code($m->modelType); } $lexems = Model::factory('Lexem')->table_alias('l')->select('l.*')->join('LexemModel', 'lm.lexemId = l.id', 'lm')->where('lm.modelType', 'T')->where_like('l.reverse', "{$reverseSuffix}%")->order_by_asc('l.formNoAccent')->limit(20)->find_many(); // $lmMatrix[$i][$j] = lexem model (with inflected forms) for lexem $i and model $j $lmMatrix = array(); foreach ($lexems as $l) { $lm = $l->getFirstLexemModel(); $lmArray = array(); foreach ($models as $m) { // Force a reload $lm = LexemModel::get_by_id($lm->id); $lm->modelType = $m->modelType; $lm->modelNumber = $m->number; $lm->generateInflectedFormMap(); $lmArray[] = $lm; }
<?php require_once "../phplib/util.php"; define('MODEL_TYPE', 'SP'); define('MODEL_TYPE_DESCRIPTION', 'Substantiv propriu'); $INFLECTIONS = array(1 => 'Substantiv propriu, Nominativ-Acuzativ, singular, nearticulat', 2 => 'Substantiv propriu, Genitiv-Dativ, singular, nearticulat', 3 => 'Substantiv propriu, Nominativ-Acuzativ, plural, nearticulat', 4 => 'Substantiv propriu, Genitiv-Dativ, plural, nearticulat', 5 => 'Substantiv propriu, Nominativ-Acuzativ, singular, articulat', 6 => 'Substantiv propriu, Genitiv-Dativ, singular, articulat', 7 => 'Substantiv propriu, Nominativ-Acuzativ, plural, articulat', 8 => 'Substantiv propriu, Genitiv-Dativ, plural, articulat'); /** Also, don't forget to edit templates/common/paradigm/current/paradigm.ihtml accordingly. **/ $existingMT = ModelType::get_by_code(MODEL_TYPE); if ($existingMT) { die('Tipul de model ' . MODEL_TYPE . " există deja.\n"); } $mt = Model::factory('ModelType')->create(); $mt->code = MODEL_TYPE; $mt->description = MODEL_TYPE_DESCRIPTION; $mt->canonical = MODEL_TYPE; $mt->save(); foreach ($INFLECTIONS as $rank => $description) { $i = Model::factory('Inflection')->create(); $i->description = $description; $i->modelType = MODEL_TYPE; $i->rank = $rank; $i->save(); } $m = Model::factory('FlexModel')->create(); $m->modelType = MODEL_TYPE; $m->number = '1'; $m->description = ''; $m->exponent = 'exponent'; $m->flag = 0; $m->save();
<?php require_once "../phplib/util.php"; setlocale(LC_ALL, "ro_RO.utf8"); DebugInfo::disable(); $locVersion = util_getRequestParameter('locVersion'); $modelType = util_getRequestParameter('modelType'); $modelType = ModelType::get_by_code($modelType); // Use the ModelType object from this point on if (!$locVersion || !$modelType) { FlashMessage::add('Date incorecte'); util_redirect('scrabble'); } LocVersion::changeDatabase($locVersion); $models = FlexModel::loadByType($modelType->code); $lexemModels = array(); foreach ($models as $m) { $lexemModels[] = getLexemModel($m->exponent, $modelType->code, $m->number); } SmartyWrap::addCss('paradigm'); SmartyWrap::assign('page_title', 'Modele de flexiune'); SmartyWrap::assign('models', $models); SmartyWrap::assign('lexemModels', $lexemModels); SmartyWrap::assign('locVersion', $locVersion); SmartyWrap::assign('modelType', $modelType); SmartyWrap::display('modele-flexiune.ihtml'); /*************************************************************************/ /** * Returns a LexemModel for a given word and model. Creates one if one doesn't exist. **/ function getLexemModel($form, $modelType, $modelNumber)
SmartyWrap::assign('adjModels', FlexModel::loadByType('A')); } $inputValues = array(); foreach ($inflections as $infl) { $inputValues[$infl->id] = array(); foreach ($newForms[$infl->id] as $form) { $inputValues[$infl->id][] = array('form' => $form, 'isLoc' => 1, 'recommended' => 1); } } if (!$previewButton && !$confirmButton) { RecentLink::createOrUpdate("Editare model: {$model}"); } SmartyWrap::assign('inflections', $inflections); SmartyWrap::assign('inflectionMap', Inflection::mapById($inflections)); SmartyWrap::assign('modelType', $modelType); SmartyWrap::assign('adjModelType', ModelType::get_by_code('A')); SmartyWrap::assign('modelNumber', $modelNumber); SmartyWrap::assign('newModelNumber', $newModelNumber); SmartyWrap::assign('exponent', $exponent); SmartyWrap::assign('newExponent', $newExponent); SmartyWrap::assign('description', $model->description); SmartyWrap::assign('newDescription', $newDescription); SmartyWrap::assign('participleNumber', $participleNumber); SmartyWrap::assign('newParticipleNumber', $newParticipleNumber); SmartyWrap::assign('newForms', $newForms); SmartyWrap::assign('inputValues', $inputValues); SmartyWrap::assign('recentLinks', RecentLink::loadForUser()); SmartyWrap::assign('wasPreviewed', $previewButton); SmartyWrap::assign('errorMessage', $errorMessage); SmartyWrap::assign('sectionTitle', "Editare model {$modelType}{$modelNumber}"); SmartyWrap::addCss('paradigm', 'jqueryui');
public static function canonicalize($code) { $mt = ModelType::get_by_code($code); return $mt->canonical; }