[dev] [commit] r958 - phplib/models wwwbase/admin
automailer at dexonline.ro
automailer at dexonline.ro
Mon Aug 26 17:38:58 EEST 2013
Author: cata
Date: Mon Aug 26 17:38:58 2013
New Revision: 958
Log:
When merging two lexems, join their meaning trees.
When deleting a lexem, delete its references in the Synonym table.
Modified:
phplib/models/Lexem.php
phplib/models/Synonym.php
wwwbase/admin/lexemEdit.php
Modified: phplib/models/Lexem.php
==============================================================================
--- phplib/models/Lexem.php Mon Aug 26 17:17:10 2013 (r957)
+++ phplib/models/Lexem.php Mon Aug 26 17:38:58 2013 (r958)
@@ -402,6 +402,7 @@
InflectedForm::deleteByLexemId($this->id);
Meaning::deleteByLexemId($this->id);
LexemSource::deleteByLexemId($this->id);
+ Synonym::deleteByLexemId($this->id);
}
// Clear the variantOfId field for lexems having $this as main.
$lexemsToClear = Lexem::get_all_by_variantOfId($this->id);
Modified: phplib/models/Synonym.php
==============================================================================
--- phplib/models/Synonym.php Mon Aug 26 17:17:10 2013 (r957)
+++ phplib/models/Synonym.php Mon Aug 26 17:38:58 2013 (r958)
@@ -21,6 +21,13 @@
$s->delete();
}
}
+
+ public static function deleteByLexemId($lexemId) {
+ $synonyms = self::get_all_by_lexemId($lexemId);
+ foreach ($synonyms as $s) {
+ $s->delete();
+ }
+ }
}
?>
Modified: wwwbase/admin/lexemEdit.php
==============================================================================
--- wwwbase/admin/lexemEdit.php Mon Aug 26 17:17:10 2013 (r957)
+++ wwwbase/admin/lexemEdit.php Mon Aug 26 17:38:58 2013 (r958)
@@ -305,6 +305,16 @@
foreach ($defs as $def) {
LexemDefinitionMap::associate($other->id, $def->id);
}
+
+ // Add meanings from $lexem to $other and renumber their displayOrder
+ $counter = Model::factory('Meaning')->where('lexemId', $other->id)->count();
+ $meanings = Model::factory('Meaning')->where('lexemId', $lexem->id)->order_by_asc('displayOrder')->find_many();
+ foreach ($meanings as $m) {
+ $m->lexemId = $other->id;
+ $m->displayOrder = ++$counter;
+ $m->save();
+ }
+
$lexem->delete();
util_redirect("lexemEdit.php?lexemId={$other->id}");
}
More information about the Dev
mailing list