public static function deleteByLexemId($lexemId) { $ifs = InflectedForm::get_all_by_lexemId($lexemId); foreach ($ifs as $if) { $if->delete(); } }
function getNewForms($lexem, $locVersion) { $ifArray = $lexem->generateParadigm(); if ($locVersion >= '5.0') { return InflectedForm::mapByInflectionRank($ifArray); } else { return InflectedForm::mapByInflectionId($ifArray); } }
/** * Delete lexems that do not have their own definitions. * Arguments for participles: 'A', ($adjectiveModel). * Arguments for long infinitives: 'F', ('107', '113'). */ private function _deleteDependentModels($inflId, $modelType, $modelNumbers) { // Load and hash all the definitionIds $ldms = LexemDefinitionMap::get_all_by_lexemId($this->id); $defHash = array(); foreach ($ldms as $ldm) { $defHash[$ldm->definitionId] = true; } // Iterate through all the forms of the desired inflection (participle / long infinitive) foreach ($this->getLexemModels() as $lm) { $ifs = InflectedForm::get_all_by_lexemModelId_inflectionId($lm->id, $inflId); foreach ($ifs as $if) { // Examine all lexems having one of the above forms $lexems = Lexem::get_all_by_formNoAccent($if->formNoAccent); foreach ($lexems as $l) { // Keep only the ones that have acceptable model types/numbers $acceptable = false; foreach ($l->getLexemModels() as $o) { if ($o->modelType == 'T' || $o->modelType == $modelType && in_array($o->modelNumber, $modelNumbers)) { $acceptable = true; } } // If $l has the right model, delete it unless it has its own definitions if ($acceptable) { $ownDefinitions = false; $ldms = LexemDefinitionMap::get_all_by_lexemId($l->id); foreach ($ldms as $ldm) { if (!array_key_exists($ldm->definitionId, $defHash)) { $ownDefinitions = true; } } if (!$ownDefinitions) { FlashMessage::add("Am șters automat lexemul {$l->formNoAccent}.", 'info'); $l->delete(); } } } } } }
} } $conjugations = NULL; $declensions = NULL; if ($searchType == SEARCH_INFLECTED || $searchType == SEARCH_LEXEM_ID || $searchType == SEARCH_FULL_TEXT || $searchType == SEARCH_MULTIWORD) { smarty_assign('results', $searchResults); // Maps lexems to arrays of inflected forms (some lexems may lack inflections) // Also compute the text of the link to the paradigm div, // which can be 'conjugări', 'declinări' or both if (!empty($lexems)) { $ifMaps = array(); $conjugations = false; $declensions = false; foreach ($lexems as $l) { if ($showParadigm) { $ifMaps[] = InflectedForm::loadByLexemIdMapByInflectionRank($l->id); } if ($l->modelType == 'V' || $l->modelType == 'VT') { $conjugations = true; } else { $declensions = true; } } $declensionText = $conjugations ? $declensions ? 'conjugări / declinări' : 'conjugări' : 'declinări'; $hasUnrecommendedForms = false; foreach ($ifMaps as $ifMap) { foreach ($ifMap as $rank => $ifs) { foreach ($ifs as $if) { $hasUnrecommendedForms |= !$if->recommended; } }
prepareDefForVersion($def); smarty_assign('def', $def); smarty_assign('lexemIds', $lexemIds); smarty_assign('user', userCache_get($def->userId)); smarty_displayWithoutSkin('common/update3Definitions.ihtml'); } print "</Definitions>\n"; } else { if ($export == 'lexems') { $lexemDbResult = db_execute("select * from Lexem where modDate >= '{$timestamp}' order by modDate, id"); print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; print "<Lexems>\n"; print "<NumResults>" . $lexemDbResult->rowCount() . "</NumResults>\n"; foreach ($lexemDbResult as $dbRow) { $lexem = Model::factory('Lexem')->create($dbRow); smarty_assign('ifs', InflectedForm::loadByLexemId($lexem->id)); smarty_assign('lexem', $lexem); smarty_displayWithoutSkin('common/update3Lexems.ihtml'); } print "</Lexems>\n"; } } } } } /****************************************************************************/ function userCache_init() { $GLOBALS['USER'] = array(); } function userCache_get($key)
if (!$result && count($errorMessage) <= 20) { $errorMessage[] = "Nu pot calcula una din formele lexemului " . htmlentities($l->form) . "."; } } } $regenForms[] = $regenRow; } // Now load the affected adjectives if the participle model changed if ($participleNumber != $newParticipleNumber) { $participleParadigms = array(); $participles = loadParticiplesForVerbModel($modelNumber, $participleNumber); foreach ($participles as $p) { $p->modelNumber = $newParticipleNumber; $ifs = $p->generateParadigm(); if (is_array($ifs)) { $participleParadigms[] = InflectedForm::mapByInflectionRank($ifs); } else { $errorMessage[] = "Nu pot declina participiul \"" . htmlentities($p->form) . "\" " . "conform modelului A{$newParticipleNumber}."; $participleParadigms[] = null; } } smarty_assign('participles', $participles); smarty_assign('participleParadigms', $participleParadigms); } if ($confirmButton) { // Save the transforms and model descriptions foreach ($regenTransforms as $inflId => $transformMatrix) { db_execute("delete from ModelDescription where modelId = {$model->id} and inflectionId = {$inflId}"); $variant = 0; foreach ($transformMatrix as $transforms) { $accentShift = array_pop($transforms);
<?php require_once "../../phplib/util.php"; util_assertModerator(PRIV_EDIT); error_log($_SERVER['REQUEST_URI']); $id = util_getRequestParameter('id'); $action = util_getRequestParameter('action'); $if = InflectedForm::get_by_id($id); if (!$if || $action != 'deny' && $action != 'allow') { http_response_code(404); exit; } $ff = ForbiddenForm::get_by_lexemModelId_inflectionId_variant($if->lexemModelId, $if->inflectionId, $if->variant); if ($action == 'deny') { if (!$ff) { $ff = ForbiddenForm::create($if); $ff->save(); } } else { // $action == 'allow' if ($ff) { $ff->delete(); } }
function delete() { InflectedForm::delete_all_by_lexemModelId($this->id); LexemSource::delete_all_by_lexemModelId($this->id); // delete_all_by_lexemModelId doesn't work for FullTextIndex because it doesn't have an ID column Model::factory('FullTextIndex')->where('lexemModelId', $this->id)->delete_many(); parent::delete(); }
/** Returns an array containing only the accented forms, not the entire InflectedForm objects **/ function loadIfArrayByLexemId($lexemId) { $ifs = InflectedForm::loadByLexemId($lexemId); $result = array(); foreach ($ifs as $if) { $result[] = $if->form; } return $result; }
if (!$hasInvariableModel) { $models[] = Model::factory('FlexModel')->where('modelType', 'I')->where('number', '1')->find_one(); } $lexems = Model::factory('Lexem')->where('modelType', 'T')->where_like('reverse', "{$reverseSuffix}%")->order_by_asc('formNoAccent')->limit(20)->find_many(); // $ifMapMatrix[$i][$j] = array of InflectedForms for lexem $i and model $j $ifMapMatrix = array(); foreach ($lexems as $l) { $origModelType = $l->modelType; $origModelNumber = $l->modelNumber; $ifMapArray = array(); foreach ($models as $m) { $l->modelType = $m->modelType; $l->modelNumber = $m->number; $if = $l->generateParadigm(); if (is_array($if)) { $ifMapArray[] = InflectedForm::mapByInflectionRank($if); } else { $ifMapArray[] = null; } } $l->modelType = $origModelType; $l->modelNumber = $origModelNumber; $ifMapMatrix[] = $ifMapArray; } // Load the definitions for each lexem $searchResults = array(); foreach ($lexems as $l) { $definitions = Definition::loadByLexemId($l->id); $searchResults[] = SearchResult::mapDefinitionArray($definitions); } smarty_assign('suffix', $suffix);
$lexem->regenerateParadigm(); log_userLog("Edited lexem {$lexem->id} ({$lexem->form})"); util_redirect("lexemEdit.php?lexemId={$lexem->id}"); } $definitions = Definition::loadByLexemId($lexem->id); $searchResults = SearchResult::mapDefinitionArray($definitions); $definitionLexem = mb_strtoupper(AdminStringUtil::internalize($lexem->form, false)); // Generate new inflected forms, but do not overwrite the old ones. $ifs = $lexem->generateParadigm(); if (!is_array($ifs)) { $infl = Inflection::get_by_id($ifs); if (!$errorMessage) { $errorMessage = "Nu pot genera flexiunea '" . htmlentities($infl->description) . "' " . "conform modelului {$lexem->modelType}{$lexem->modelNumber}."; } } else { $ifMap = InflectedForm::mapByInflectionRank($ifs); smarty_assign('ifMap', $ifMap); smarty_assign('searchResults', $searchResults); } $models = FlexModel::loadByType($lexem->modelType); $sources = LexemSources::getSourceArrayChecked($lexem->source); $sourceNames = LexemSources::getNamesOfSources($lexem->source); $canEditForm = !$lexem->isLoc || util_isModerator(PRIV_LOC); smarty_assign('lexem', $lexem); smarty_assign('sources', $sources); smarty_assign('sourceNames', $sourceNames); smarty_assign('searchResults', $searchResults); smarty_assign('definitionLexem', $definitionLexem); smarty_assign('homonyms', Model::factory('Lexem')->where('formNoAccent', $lexem->formNoAccent)->where_not_equal('id', $lexem->id)->find_many()); smarty_assign('suggestedLexems', loadSuggestions($lexem, 5)); smarty_assign('restrS', FlexStringUtil::contains($lexem->restriction, 'S'));
public function delete() { if ($this->id) { if ($this->modelType == 'VT') { $this->deleteParticiple($this->modelNumber); } if ($this->modelType == 'VT' || $this->modelType == 'V') { $this->deleteLongInfinitive(); } LexemDefinitionMap::deleteByLexemId($this->id); InflectedForm::deleteByLexemId($this->id); } parent::delete(); }
function dumpLexems($query, $fileName, $message) { log_scriptLog($message); $results = db_execute($query); $file = gzopen($fileName, 'wb9'); gzwrite($file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); gzwrite($file, "<Lexems>\n"); foreach ($results as $row) { $lexem = Model::factory('Lexem')->create($row); smarty_assign('lexem', $lexem); smarty_assign('ifs', InflectedForm::loadByLexemId($lexem->id)); gzwrite($file, smarty_fetch('xmldump/lexem.ihtml')); } gzwrite($file, "</Lexems>\n"); gzclose($file); }