if ($submitButton) { // Re-rank the inflections according to the order in $inflectionIds $modelTypeMap = array(); foreach ($inflectionIds as $inflId) { $infl = Inflection::get_by_id($inflId); $rank = array_key_exists($infl->modelType, $modelTypeMap) ? $modelTypeMap[$infl->modelType] + 1 : 1; $modelTypeMap[$infl->modelType] = $rank; $infl->rank = $rank; $infl->save(); } // Add a new inflection if one is given if ($newDescription) { $infl = Model::factory('Inflection')->create(); $infl->description = $newDescription; $infl->modelType = $newModelType; $infl->rank = $modelTypeMap[$newModelType] + 1; $infl->save(); } util_redirect('flexiuni'); } // Tag inflections which can be safely deleted (only those that aren't being used by any model) $inflections = Model::factory('Inflection')->order_by_asc('modelType')->order_by_asc('rank')->find_many(); $usedInflectionIds = db_getArray('select distinct inflectionId from ModelDescription'); foreach ($inflections as $infl) { $infl->canDelete = !in_array($infl->id, $usedInflectionIds); } SmartyWrap::assign('suggestHiddenSearchForm', true); SmartyWrap::assign('inflections', $inflections); SmartyWrap::assign('modelTypes', ModelType::loadCanonical()); SmartyWrap::addJs('jqTableDnd'); SmartyWrap::display('flexiuni.tpl');
} else { $l = Lexem::create($m->exponent, $modelType, $m->number, ''); $l->isLoc = true; $paradigm = getNewForms($l, $locVersion); } $lexems[] = $l; $paradigms[] = $paradigm; } smarty_assign('modelsToDisplay', $modelsToDisplay); smarty_assign('lexems', $lexems); smarty_assign('paradigms', $paradigms); } else { smarty_assign('selectedLocVersion', $locVersions[0]->name); // LocVersion::changeDatabase($locVersion); } $modelTypes = ModelType::loadCanonical(); $models = FlexModel::loadByType($modelType ? $modelType : $modelTypes[0]->code); smarty_assign('page_title', 'Modele de flexiune'); smarty_assign('locVersions', $locVersions); smarty_assign('modelTypes', $modelTypes); smarty_assign('models', $models); smarty_displayCommonPageWithSkin('modele-flexiune.ihtml'); /*************************************************************************/ /** * Load the forms to display for a model when a lexem already exists. This code is specific to each LOC version. */ function getExistingForms($lexemId, $locVersion) { if ($locVersion >= '5.0') { return InflectedForm::loadByLexemIdMapByInflectionRank($lexemId); } else {
<?php require_once "../../phplib/util.php"; util_assertModerator(PRIV_EDIT); util_assertNotMirror(); $models = FlexModel::loadByType('A'); smarty_assign('recentLinks', RecentLink::loadForUser()); smarty_assign('canEditWotd', util_isModerator(PRIV_WOTD)); smarty_assign("allStatuses", util_getAllStatuses()); smarty_assign("allModeratorSources", Model::factory('Source')->where('canModerate', true)->order_by_asc('displayOrder')->find_many()); smarty_assign('modelTypes', ModelType::loadCanonical()); smarty_assign('models', $models); smarty_displayWithoutSkin('admin/index.ihtml');