Beispiel #1
0
function addTagsToExperiment($eid, $tag_list)
{
    global $db;
    $zipped_list = array();
    foreach ($tag_list as $t) {
        if (!array_key_exists($t['value'], $zipped_list)) {
            $zipped_list[$t['value']] = $t['weight'];
        } else {
            // If the tag is already present with a lower weight, then replace with higher weight
            if ($zipped_list[$t['value']] < $t['weight']) {
                $zipped_list[$t['value']] = $t['weight'];
            }
        }
    }
    $tag_cache = array();
    foreach ($zipped_list as $k => $v) {
        $id = -1;
        if (!array_key_exists($k, $tag_cache)) {
            $id = getTagId($k);
            if ($id == -1) {
                $id = addTag($k, $v > 0 ? 1 : 0);
            }
            $tag_cache[$k] = $id;
        } else {
            $id = $tag_cache[$k];
        }
        addTagToExperiment($eid, $id, $v);
    }
    updateTimeModifiedForExperiment($eid);
    return true;
}
Beispiel #2
0
         foreach ($name as $n) {
             if (strlen($n) > 1) {
                 $tid = getTagId(safeString($n));
                 if ($tid == -1) {
                     $tid = addTag(safeString($n), 1);
                 }
                 addTagToExperiment($eid, $tid, 1);
             }
         }
         foreach ($desc as $n) {
             if (strlen($n) > 1) {
                 $tid = getTagId(safeString($n));
                 if ($tid == -1) {
                     $tid = addTag(safeString($n), 1);
                 }
                 addTagToExperiment($eid, $tid, 1);
             }
         }
     }
     break;
 case "migrateimgs":
     $s3 = new S3(AWS_ACCESS_KEY, AWS_SECRET_KEY);
     $url = "http://s3.amazonaws.com/isenseimgs/";
     $img_dir = PIC_DIR . 's3/';
     $dir = opendir($img_dir);
     while (($file = readdir($dir)) !== false) {
         $id = substr($file, 0, strpos($file, ".") + 1);
         $ext = substr($file, strpos($file, ".") + 1, 3);
         if (strlen($ext) < 3) {
             continue;
         }