Ejemplo n.º 1
0
 static function loadAllForLexems($lexems)
 {
     $map = array();
     foreach ($lexems as $l) {
         $vs = Visual::get_all_by_lexemeId($l->id);
         foreach ($vs as $v) {
             $map[$v->id] = $v;
         }
         $vts = VisualTag::get_all_by_lexemeId($l->id);
         foreach ($vts as $vt) {
             $v = Visual::get_by_id($vt->imageId);
             $map[$v->id] = $v;
         }
     }
     foreach ($map as $v) {
         $v->ensureThumb();
     }
     return array_values($map);
 }
Ejemplo n.º 2
0
$tagLexemId = util_getRequestParameter('tagLexemId');
$tagLabel = util_getRequestParameter('tagLabel');
$textXCoord = util_getRequestParameter('textXCoord');
$textYCoord = util_getRequestParameter('textYCoord');
$imgXCoord = util_getRequestParameter('imgXCoord');
$imgYCoord = util_getRequestParameter('imgYCoord');
$addTagButton = util_getRequestParameter('addTagButton');
// Tag the image specified by $fileName. Create a Visual object if one doesn't exist, then redirect to it.
if ($fileName) {
    $v = Visual::get_by_path($fileName);
    if (!$v) {
        $v = Visual::createFromFile($fileName);
    }
    util_redirect("?id={$v->id}");
}
$v = Visual::get_by_id($id);
if ($saveButton) {
    $v->lexemeId = $lexemId;
    $v->revised = $revised;
    $v->save();
    util_redirect("?id={$v->id}");
}
if ($addTagButton) {
    $vt = Model::factory('VisualTag')->create();
    $vt->imageId = $v->id;
    $vt->lexemeId = $tagLexemId;
    $vt->label = $tagLabel;
    $vt->textXCoord = $textXCoord;
    $vt->textYCoord = $textYCoord;
    $vt->imgXCoord = $imgXCoord;
    $vt->imgYCoord = $imgYCoord;
Ejemplo n.º 3
0
<?php

require_once '../../phplib/util.php';
$visualId = util_getRequestParameter('visualId');
$page = util_getRequestParameter('page');
$limit = util_getRequestParameter('rows');
$usage = util_getRequestParameter('usage');
$resp = array();
$tags = array();
if ($usage == 'table') {
    $total = Model::factory('VisualTag')->where('imageId', $visualId)->count();
    $lines = Model::factory('VisualTag')->where('imageId', $visualId)->limit($limit)->offset(($page - 1) * $limit)->find_many();
} else {
    if ($usage == 'gallery') {
        $image = Visual::get_by_id($visualId);
        $dims = array('width' => $image->width, 'height' => $image->height);
        $lines = VisualTag::get_all_by_imageId($visualId);
    }
}
foreach ($lines as $line) {
    $row = Lexem::get_by_id($line->lexemeId);
    $tags[] = array('id' => $line->id, 'label' => $line->label, 'textX' => $line->textXCoord, 'textY' => $line->textYCoord, 'imgX' => $line->imgXCoord, 'imgY' => $line->imgYCoord, 'lexeme' => !empty($row) ? $row->formUtf8General : '');
}
if ($usage == 'table') {
    $resp = array('total' => ceil($total / $limit), 'page' => $page, 'records' => $total, 'rows' => $tags);
} else {
    if ($usage == 'gallery') {
        $resp = array('dims' => $dims, 'tags' => $tags);
    }
}
echo json_encode($resp);