예제 #1
0
파일: 00112.php 프로젝트: florinp/dexonline
<?php

$lexemIds = db_getArray('select distinct lexemId from Meaning');
foreach ($lexemIds as $lexemId) {
    $t = Meaning::loadTree($lexemId);
    renumber($t, '');
}
/**************************************************************************/
function renumber($t, $prefix)
{
    if (empty($t)) {
        return;
    }
    if ($prefix) {
        $prefix .= '.';
    }
    foreach ($t as $i => $tuple) {
        $m = $tuple['meaning'];
        $m->breadcrumb = $prefix . ($i + 1);
        $m->save();
        renumber($tuple['children'], $m->breadcrumb);
    }
}
예제 #2
0
파일: Lexem.php 프로젝트: florinp/dexonline
 public function delete()
 {
     if ($this->id) {
         if ($this->hasModelType('VT')) {
             $this->deleteParticiple();
         }
         if ($this->hasModelType('VT') || $this->hasModelType('V')) {
             $this->deleteLongInfinitive();
         }
         LexemDefinitionMap::deleteByLexemId($this->id);
         Meaning::delete_all_by_lexemId($this->id);
         Relation::delete_all_by_lexemId($this->id);
         LexemModel::delete_all_by_lexemId($this->id);
     }
     // Clear the variantOfId field for lexems having $this as main.
     $lexemsToClear = Lexem::get_all_by_variantOfId($this->id);
     foreach ($lexemsToClear as $l) {
         $l->variantOfId = null;
         $l->save();
     }
     parent::delete();
 }
예제 #3
0
<?php

require_once "../../phplib/util.php";
$id = util_getRequestParameter('id');
$m = Meaning::get_by_id($id);
$l = Lexem::get_by_id($m->lexemId);
$results = array('lexem' => $l->formNoAccent, 'breadcrumb' => $m->breadcrumb, 'htmlRep' => $m->htmlRep);
print json_encode($results);
예제 #4
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);
     }
 }
예제 #5
0
            log_userLog("Edited lexem {$lexem->id} ({$lexem->form})");
            util_redirect("lexemEdit.php?lexemId={$lexem->id}");
        }
    } else {
        // Case 2: Validation failed
    }
    // Case 1-2: Page was submitted
    SmartyWrap::assign('variantIds', $variantIds);
    SmartyWrap::assign('meanings', Meaning::convertTree($meanings));
} else {
    // Case 3: First time loading this page
    foreach ($lexem->getLexemModels() as $lm) {
        $lm->loadInflectedFormMap();
    }
    SmartyWrap::assign('variantIds', $lexem->getVariantIds());
    SmartyWrap::assign('meanings', Meaning::loadTree($lexem->id));
}
$definitions = Definition::loadByLexemId($lexem->id);
foreach ($definitions as $def) {
    $def->internalRepAbbrev = AdminStringUtil::expandAbbreviations($def->internalRep, $def->sourceId);
    $def->htmlRepAbbrev = AdminStringUtil::htmlize($def->internalRepAbbrev, $def->sourceId);
}
$searchResults = SearchResult::mapDefinitionArray($definitions);
$definitionLexem = mb_strtoupper(AdminStringUtil::internalize($lexem->form, false));
$meaningTags = Model::factory('MeaningTag')->order_by_asc('value')->find_many();
$ss = $lexem->structStatus;
$oss = $original->structStatus;
// syntactic sugar
$canEdit = array('general' => util_isModerator(PRIV_EDIT), 'defStructured' => util_isModerator(PRIV_EDIT), 'description' => util_isModerator(PRIV_EDIT), 'form' => !$lexem->isLoc() || util_isModerator(PRIV_LOC), 'hyphenations' => $ss == Lexem::STRUCT_STATUS_IN_PROGRESS || util_isModerator(PRIV_EDIT), 'loc' => (int) util_isModerator(PRIV_LOC), 'meanings' => $ss == Lexem::STRUCT_STATUS_IN_PROGRESS || util_isModerator(PRIV_EDIT), 'paradigm' => util_isModerator(PRIV_EDIT), 'pronunciations' => $ss == Lexem::STRUCT_STATUS_IN_PROGRESS || util_isModerator(PRIV_EDIT), 'sources' => util_isModerator(PRIV_LOC | PRIV_EDIT), 'structStatus' => $oss == Lexem::STRUCT_STATUS_NEW || $oss == Lexem::STRUCT_STATUS_IN_PROGRESS || util_isModerator(PRIV_EDIT), 'tags' => util_isModerator(PRIV_LOC | PRIV_EDIT), 'variants' => $ss == Lexem::STRUCT_STATUS_IN_PROGRESS || util_isModerator(PRIV_EDIT));
// Prepare a list of models for each LexemModel, to be used in the paradigm drop-down.
$models = array();
예제 #6
0
 public function import()
 {
     if (!$this->_canCallApi()) {
         $this->addError('Api is not setup');
         return $this->response->withRedirect('/');
     }
     $tokenRow = Setting::getAccessToken();
     $quizlet = new Quizlet();
     $quizlet->setAccessToken($tokenRow->value);
     $terms = $quizlet->getTerms();
     if (empty($terms)) {
         $this->addSuccess('0 terms downloaded');
         return $this->response->withRedirect('/');
     }
     $insertCount = 0;
     foreach ($terms as $term) {
         $row = Meaning::findOne(array('word' => $term->term));
         # meaning already exists
         if ($row) {
             continue;
         }
         $insertId = Meaning::insert(array('word' => $term->term, 'meaning' => $term->definition, 'created' => date('Y-m-d H:i:s')));
         $insertCount++;
     }
     $this->addSuccess($insertCount . ' terms downloaded');
     return $this->response->withRedirect('/');
 }