Пример #1
0
 /**
  * Different from __clone(). We save the object to the database to assign it an ID. We also clone its descendants,
  * relations, sources and tags.
  **/
 public function cloneMeaning($newLexemId, $newParentId)
 {
     $clone = $this->parisClone();
     $clone->lexemId = $newLexemId;
     $clone->parentId = $newParentId;
     $clone->save();
     // Clone its tags
     $mtms = MeaningTagMap::get_all_by_meaningId($this->id);
     foreach ($mtms as $mtm) {
         $mtmClone = $mtm->parisClone();
         $mtmClone->meaningId = $clone->id;
         $mtmClone->save();
     }
     // Clone its sources
     $mss = MeaningSource::get_all_by_meaningId($this->id);
     foreach ($mss as $ms) {
         $msClone = $ms->parisClone();
         $msClone->meaningId = $clone->id;
         $msClone->save();
     }
     // Clone its relations
     $relations = Relation::get_all_by_meaningId($this->id);
     foreach ($relations as $r) {
         $rc = $r->parisClone();
         $rc->meaningId = $clone->id;
         $rc->save();
     }
     // Clone its children
     $children = Meaning::get_all_by_parentId($this->id);
     foreach ($children as $child) {
         $child->cloneMeaning($newLexemId, $clone->id);
     }
 }
Пример #2
0
<?php

require_once "../phplib/util.php";
$value = util_getRequestParameter('value');
$deleteId = util_getRequestParameter('deleteId');
$submitButton = util_getRequestParameter('submitButton');
if ($deleteId) {
    $mt = MeaningTag::get_by_id($deleteId);
    $mtms = MeaningTagMap::get_all_by_meaningTagId($mt->id);
    if (count($mtms)) {
        FlashMessage::add("Nu pot șterge eticheta «{$mt->value}», deoarece unele sensuri o folosesc.", 'error');
    } else {
        $mt->delete();
        FlashMessage::add("Am șters eticheta «{$mt->value}».", 'info');
    }
    util_redirect('etichete-sensuri');
}
if ($submitButton) {
    util_assertModerator(PRIV_ADMIN);
    $values = explode(',', $value);
    foreach ($values as $value) {
        $value = trim($value);
        if ($value && !MeaningTag::get_by_value($value)) {
            $mt = Model::factory('MeaningTag')->create();
            $mt->value = $value;
            $mt->save();
        }
    }
    FlashMessage::add('Etichetele au fost salvate.', 'info');
    util_redirect('etichete-sensuri');
}
Пример #3
0
function goodForVariant($meanings)
{
    if (empty($meanings)) {
        return true;
    }
    if (count($meanings) > 1) {
        return false;
    }
    $m = $meanings[0];
    $mss = MeaningSource::get_all_by_meaningId($m->id);
    $mtms = MeaningTagMap::get_all_by_meaningId($m->id);
    $relations = Relation::get_all_by_meaningId($m->id);
    return count($mss) && !$m->internalRep && !$m->internalComment && empty($mtms) && empty($relations);
}