コード例 #1
0
function insertAnnotation($req, $connection_name)
{
    $author = $req->getIp();
    //$allPostVars = $req->post();
    //print_r($allPostVars);
    //Array ( [sezione] => A [evento] => 1 [valutazione] => A10++ [commento] => Prova )
    $commento = $req->post('commento');
    $valutazione = $req->post('valutazione');
    $sezione = $req->post('sezione');
    $evento = $req->post('evento');
    if (null != $sezione && null != $evento && is_numeric($evento)) {
        $eventoNum = intval($evento);
        if ($eventoNum < 0) {
            $eventoNum = 0;
        }
        if ($eventoNum < 10) {
            $valutazione = $sezione . '0' . $eventoNum . $valutazione;
        } else {
            $valutazione = $sezione . $eventoNum . $valutazione;
        }
    }
    $annotation = new Annotation(array('author' => $author, 'source' => Source::WEB, 'sourceId' => '', 'text' => $valutazione . ' ' . $commento, 'textHtml' => $valutazione . ' ' . $commento, 'hashtags' => array()));
    $annotation->setConnection($connection_name);
    $annotation->save();
    $result = Parser::parse($valutazione);
    if ($result != false) {
        $evaluation = new Evaluation(array('annotation_id' => $annotation->id, 'sessione' => $result->sessione, 'evento' => $result->evento, 'punteggio' => $result->punteggio));
        $evaluation->setConnection($connection_name);
        $evaluation->save();
    }
}
コード例 #2
0
 }
 if (isset($elem_search->coordinates)) {
     $point = \GeoJson\GeoJson::jsonUnserialize($elem_search->coordinates);
 }
 // Entites https://dev.twitter.com/overview/api/entities
 $hashtags = [];
 foreach ($elem_search->entities->hashtags as $ht) {
     // lo # non c'e' se serve va messo
     $hashtags[] = $ht->text;
 }
 $ann = Annotation::on($connection_name)->where('sourceId', $id_tweet)->get();
 if ($ann->count() == 0) {
     $annotation = new Annotation(array('author' => $nick, 'source' => Source::TWITTER, 'sourceId' => $id_tweet, 'text' => $testo_tweet, 'textHtml' => parseTweet($testo_tweet), 'hashtags' => $hashtags));
     $annotation->setConnection($connection_name);
     $annotation->save();
     $result = Parser::parse($testo_tweet);
     if ($result != false) {
         $evaluation = new Evaluation(array('annotation_id' => $annotation->id, 'sessione' => $result->sessione, 'evento' => $result->evento, 'punteggio' => $result->punteggio));
         $evaluation->setConnection($connection_name);
         $evaluation->save();
     }
     $imageCount = 0;
     if (isset($elem_search->entities->media)) {
         foreach ($elem_search->entities->media as $media) {
             $imageCount++;
             $resources[] = $media->media_url;
             $dataImg = file_get_contents($media->media_url);
             $filename = basename($media->media_url);
             //"http://pbs.twimg.com/media/CPbPvS6UkAE7dYw.jpg",
             if ('' == trim($filename)) {
                 $url = $media->expanded_url;
コード例 #3
0
 if ($ann->count() == 0) {
     //TESTO
     if (isset($message->text)) {
         $testo = $message->text;
         if ($testo == '/start') {
             continue;
         }
         $annotation = new Annotation(array('author' => $author, 'source' => Source::TELEGRAM, 'sourceId' => $idMessaggio, 'text' => $testo, 'textHtml' => $testo, 'hashtags' => array()));
         $annotation->setConnection($connection_name);
         $annotation->save();
         //primo carattere @IndabaBot
         if (strpos($testo, '@IndabaBot') === false) {
             $result = Parser::parse($testo);
         } else {
             $testoDaParsare = mb_substr($testo, 11, strlen($testo) - 11, 'utf-8');
             $result = Parser::parse($testoDaParsare);
         }
         if ($result != false) {
             $evaluation = new Evaluation(array('annotation_id' => $annotation->id, 'sessione' => $result->sessione, 'evento' => $result->evento, 'punteggio' => $result->punteggio));
             $evaluation->setConnection($connection_name);
             $evaluation->save();
         }
     }
     //PHOTO
     if (isset($message->photo)) {
         $testo = 'Photo';
         $annotation = new Annotation(array('author' => $author, 'source' => Source::TELEGRAM, 'sourceId' => $idMessaggio, 'text' => $testo, 'textHtml' => $testo, 'hashtags' => array()));
         $annotation->setConnection($connection_name);
         $annotation->save();
         $big_file_id = -1;
         $big_file_whidth = 0;
コード例 #4
0
        //    [sms_id] => 2
        //    [author] => +393395039915
        //    [plainText] => 0054006500640074
        $sms_id = $sms->sms_id;
        $lastId = $sms_id;
        $author = $sms->author;
        $plainText = $sms->plainText;
        preg_match_all('/#(\\w+)/', $plainText, $matches);
        $hashtags = array();
        if (isset($matches) && count($matches) > 0) {
            foreach ($matches[1] as $val) {
                $hashtags[] = $val;
            }
        }
        $ann = Annotation::on($connection_name)->where('sourceId', $sms_id)->get();
        if ($ann->count() == 0) {
            $annotation = new Annotation(array('author' => $author, 'source' => Source::SMS, 'sourceId' => $sms_id, 'text' => $plainText, 'textHtml' => $plainText, 'hashtags' => $hashtags));
            $annotation->setConnection($connection_name);
            $annotation->save();
            $result = Parser::parse($plainText);
            if ($result != false) {
                $evaluation = new Evaluation(array('annotation_id' => $annotation->id, 'sessione' => $result->sessione, 'evento' => $result->evento, 'punteggio' => $result->punteggio));
                $evaluation->setConnection($connection_name);
                $evaluation->save();
            }
        }
    }
    $filesystem->put('last.sms', $lastId);
} catch (\Exception $e) {
    $log->addError($e->getFile() . ' on ' . $e->getLine() . ' ' . ' because : ' . $e->getMessage());
}
コード例 #5
0
 } else {
     $textPlain = $titolo . ' ' . $textPlain;
 }
 preg_match_all('/#(\\w+)/', $textPlain, $matches);
 $hashtags = array();
 if (isset($matches) && count($matches) > 0) {
     foreach ($matches[1] as $val) {
         $hashtags[] = $val;
     }
 }
 $ann = Annotation::on($connection_name)->where('sourceId', $mail_id)->get();
 if ($ann->count() == 0) {
     $annotation = new Annotation(array('author' => $from, 'source' => Source::EMAIL, 'sourceId' => $mail_id, 'text' => $textPlain, 'textHtml' => $textHtml, 'hashtags' => $hashtags));
     $annotation->setConnection($connection_name);
     $annotation->save();
     $result = Parser::parse($titolo);
     if ($result != false) {
         $evaluation = new Evaluation(array('annotation_id' => $annotation->id, 'sessione' => $result->sessione, 'evento' => $result->evento, 'punteggio' => $result->punteggio));
         $evaluation->setConnection($connection_name);
         $evaluation->save();
     }
     $attachments = $mail->getAttachments();
     foreach ($attachments as $attachment) {
         $filePath = $attachment->filePath;
         $data = file_get_contents($filePath);
         $fileName = $attachment->name;
         $filesystem->put($mail_id . '/' . $fileName, $data);
         $attachments = new Attachment(array('annotation_id' => $annotation->id, 'source' => Source::EMAIL, 'fileName' => $fileName, 'filePath' => $mail_id . '/' . $fileName));
         $attachments->setConnection($connection_name);
         $attachments->save();
         $filesystem_tmp->delete(basename($filePath));