Ejemplo n.º 1
0
 public function getAnalysisContent(Analyse $analysis, $nameFrom)
 {
     $html = "<div>";
     $html .= "<span>Olá! {$nameFrom} enviou uma Análise para você do Bureau Inteligencia!</span>";
     $html .= "<div style='display: inline-block; border: 1px solid #710E0E; border-top-width: 3px; border-left: 0; border-right: 0; width: 95%; height: auto; margin-bottom: 15px; margin-top: 15px; padding: 5px 0;'>";
     $html .= "<div style='width: 132px; height: 132px; float: left;'>";
     $html .= "<img src='" . LinkController::getBaseURL() . "/images/bg-logo.gif'/>";
     //$html .=            "<div style='z-index: 1000; position: absolute;'>";
     //$html .=                $this->objectFlash();
     //$html .=            "</div>";
     $html .= "</div>";
     $html .= "<a style='float: left; margin-left: 10px; margin-top: 35px; border: 0' href='" . LinkController::getBaseURL() . "'>";
     $html .= "<img style='border: 0;' src='" . LinkController::getBaseURL() . "/images/escrito-bureau.gif'/>";
     $html .= "</a>";
     $html .= "</div>";
     $html .= "<div style='color: #333333;'>";
     $html .= "<h1 style='text-align: center; margin: 0; padding: 0; font-size: 28.5px; font-weight: bold; letter-spacing: -1px'>" . $analysis->title() . "</h1>";
     $html .= "<br />";
     //$html .=        "<div style='font-weight: normal; font-size: 13px; letter-spacing: -0.3px; line-height: 30px; text-align: left;'>";
     //$html .=                $analysis->text();
     //$html .=        "</div>";
     $html .= "<div style='width: 90%; margin: 5px auto; padding: 5px; background-color: #EEEEEE;'>";
     $html .= "<a href='" . LinkController::getBaseURL() . "/analise/" . $analysis->link() . ".html' style='font-size: 16px; font-weight: bold; color: #710E0E !important;'>" . LinkController::getBaseURL() . "/analise/" . $analysis->link() . ".html</a>";
     $html .= "</div>";
     $html .= "</div>";
     $html .= "</div>";
     return $html;
 }
Ejemplo n.º 2
0
 /**     
  * @param Analyse $analysis
  * @return ArrayObject 
  */
 public function getCommentsOfAnAnalysis(Analyse $analysis)
 {
     $statement = "SELECT comment.*, users.name AS nameUser FROM comment \r\n            LEFT OUTER JOIN users ON comment.username = users.username\r\n            WHERE analysis_id = :id ORDER BY datetime DESC";
     $query = $this->session->prepare($statement);
     $query->bindParam(":id", $analysis->id());
     $query->execute();
     return $this->buildArrayComments($query->fetchAll(PDO::FETCH_ASSOC));
 }
 /**     
  * @param type $current
  * @return Analyse 
  */
 protected function buildObject($current)
 {
     $subarea = new SubArea($current['subareaName'], $current['theme']);
     $state = new State($current['idState'], $current['uf'], $current['nameState']);
     $analysis = new Analyse($current['title'], $subarea, $state, $current['date']);
     $analysis->setLink($current['link']);
     return $analysis;
 }
Ejemplo n.º 4
0
 function parse_text($texte)
 {
     // substitution variables internes
     if (count(self::$vars) > 0) {
         $texte = str_replace(array_keys(self::$vars), array_values(self::$vars), $texte);
     }
     // substition simples
     $texte = substitutions($texte);
     // laisser les infos pour les connectés ou non connectés
     $texte = $this->filtre_connecte($texte);
     // traitement dans le cas d'un formulaire
     $texte = $this->traitement_formulaire($texte);
     $parseur = new Analyse(Variable::lire(self::PREFIXE . '_allow_debug'));
     $contenu = Variable::lire(self::PREFIXE . '_use_cache') ? $parseur->parse_string_with_cache($texte, $this->cache_dir) : $parseur->parse_string($texte);
     $texte = $contenu->evaluer();
     $parseur->terminer();
     return $texte;
 }
 function imprimer()
 {
     Analyse::echo_debug("[SI {$this->nom}]");
     if ($this->contenu[0]) {
         $this->contenu[0]->imprimer();
     }
     Analyse::echo_debug("[SINON {$this->nom}]");
     if ($this->contenu[1]) {
         $this->contenu[1]->imprimer();
     }
     Analyse::echo_debug("[FINSI {$this->nom}]");
 }
 function evaluer(&$substitutions = array())
 {
     if (DEBUG_EVAL) {
         Analyse::echo_debug("Eval contenu {$this->idx}");
     }
     $val = '';
     foreach ($this->elements as $element) {
         if (DEBUG_EVAL) {
             Analyse::echo_debug("CONT:eval " . $element->type());
             $element->imprimer();
         }
         $val .= $element->evaluer($substitutions);
     }
     return $val;
 }
Ejemplo n.º 7
0
 /**
  * process a task only one page
  * @param  integer $id task id
  * @return none
  */
 public function work($id)
 {
     // get task infomation
     $task = $this->_db->query("select * from task where `id`={$id}");
     $task = $task->fetch_array();
     $count = $task['count'];
     $page = $task['page'] + 1;
     $id = $task['id'];
     // get new data
     parent::__construct($task['keyword'], $page);
     $data = $this->results();
     // fill data into database
     $this->datain($data, $id);
     // update task infomation
     $count += count($data);
     $this->_db->query("update `task` set `page`={$page} ,`count`={$count} where id={$id}");
 }
 function imprimer()
 {
     Analyse::echo_debug("[DEBUT {$this->nom}, args: ", $this->args, "]");
     $this->contenu->imprimer();
     Analyse::echo_debug("[FIN {$this->nom}]");
 }
Ejemplo n.º 9
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted(RequestsPatterns::$TITLE, 'subarea', 'state', 'text')) {
    if (RequestsPatterns::postParamsSent(RequestsPatterns::$TITLE, 'subarea', 'state', 'text')) {
        require_once 'PublicationController.php';
        require_once 'Publication.php';
        require_once 'Analyse.php';
        require_once 'PublicationDao.php';
        require_once '../core/generics/SubArea.php';
        require_once '../core/generics/State.php';
        $controller = new PublicationController(new PublicationDao(Connection::connect()));
        $publication = new Analyse($_POST[RequestsPatterns::$TITLE], new SubArea(null, $_POST['subarea']), new State($_POST['state']), date("Y-m-d"));
        $publication->setText($_POST['text']);
        try {
            $controller->saveAnalysis($publication);
            print_r($jsonResponse->response(true, "Análise inserida com sucesso!")->serialize());
        } catch (Exception $err) {
            print_r($jsonResponse->response(false, $err->getMessage())->serialize());
        }
    } else {
        print_r($jsonResponse->response(false, "Todos os campos devem ser preenchidos.")->serialize());
    }
} else {
    print_r($jsonResponse->response(false, "Alguns parâmetros não foram configurados")->serialize());
}
Ejemplo n.º 10
0
 public function check_cache()
 {
     Analyse::cleanup_cache($this->cache_dir, 1);
     $this->redirect();
 }
Ejemplo n.º 11
0
 function imprimer()
 {
     Analyse::echo_debug("[TEST_VRAI {$this->nom} {$args}]");
     if ($this->contenu[0]) {
         $this->contenu[0]->imprimer();
     }
     Analyse::echo_debug("[TEST_FAUX {$this->nom}]");
     if ($this->contenu[1]) {
         $this->contenu[1]->imprimer();
     }
     Analyse::echo_debug("[TEST_FIN {$this->nom}]");
 }
Ejemplo n.º 12
0
<?php

require_once 'util/RequestsPatterns.php';
$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted('title', 'text', 'analysis_id')) {
    if (RequestsPatterns::postParamsSent('title', 'text', 'analysis_id')) {
        if (Session::isLogged()) {
            require_once 'core/User/User.php';
            require_once 'Publication.php';
            require_once 'Analyse.php';
            require_once 'PublicationController.php';
            require_once 'PublicationDao.php';
            require_once 'Comment.php';
            $user = Session::getLoggedUser();
            $analysis = new Analyse(null);
            $analysis->setId($_POST['analysis_id']);
            $user->comment(new Comment(date("Y-m-d H:i:s"), $_POST['title'], $_POST['text']), $analysis);
            $controller = new PublicationController(new PublicationDao(Connection::connect()));
            try {
                if ($controller->comment($analysis)) {
                    print_r($jsonResponse->response(true, "Comentário enviado com sucesso!")->serialize());
                } else {
                    print_r($jsonResponse->response(false, "Falha ao eviar comentário. Tente novamente")->serialize());
                }
            } catch (Exception $err) {
                print_r($jsonResponse->response(false, $err->getMessage())->serialize());
            }
        } else {
            print_r($jsonResponse->response(false, "Faça o login para poder deixar seu comentário")->serialize());
        }
    } else {
Ejemplo n.º 13
0
 /**     
  * @param type $pub
  * @return Analyse 
  */
 private function buildAnalysis($pub)
 {
     $publication = new Analyse($pub['title'], null, null, $pub['date']);
     $publication->setId($pub['id']);
     $publication->setLink($pub['link']);
     return $publication;
 }
Ejemplo n.º 14
0
 function process_token(&$atoken)
 {
     //if (DEBUG_PARSER) { Analyse::echo_debug("enter process_token ", $atoken);}
     $token_type = PexToken::TXT;
     if ($atoken == '<') {
         $no_match = false;
         $token = next($this->tokens);
         if (DEBUG_PARSER) {
             Analyse::echo_debug("Next PexToken:[{$token}]");
         }
         // Optimisation (gain: ~= 0,1 sec. sur index standard)
         if ($token[0] != 'T' && strpos($token, '/T') !== 0 && strpos($token, '//T') !== 0 && $token[0] != 'R' && strpos($token, '/R') !== 0) {
             //if (DEBUG_PARSER) { Analyse::echo_debug("N'est pas une boucle thelia");}
             $no_match = true;
         } else {
             // Get token type
             if (strpos($token, 'THELIA_') === 0) {
                 $token_type = PexToken::OBS;
             } else {
                 if (strpos($token, '/THELIA_') === 0) {
                     $token_type = PexToken::FBS;
                 } else {
                     if (strpos($token, 'TEST_') === 0) {
                         $token_type = PexToken::OBT;
                     } else {
                         if (strpos($token, '/TEST_') === 0) {
                             $token_type = PexToken::EBT;
                         } else {
                             if (strpos($token, '//TEST_') === 0) {
                                 $token_type = PexToken::FBT;
                             } else {
                                 if (strpos($token, 'T_') === 0) {
                                     $token_type = PexToken::OBC;
                                 } else {
                                     if (strpos($token, '/T_') === 0) {
                                         $token_type = PexToken::EBC;
                                     } else {
                                         if (strpos($token, '//T_') === 0) {
                                             $token_type = PexToken::FBC;
                                         } else {
                                             if (strpos($token, 'REM') === 0) {
                                                 $token_type = PexToken::OCM;
                                             } else {
                                                 if (strpos($token, '/REM') === 0) {
                                                     $token_type = PexToken::FCM;
                                                 } else {
                                                     if (strpos($token, 'REPETER') === 0) {
                                                         $token_type = PexToken::OBR;
                                                     } else {
                                                         if (strpos($token, '/REPETER') === 0) {
                                                             $token_type = PexToken::FBR;
                                                         } else {
                                                             if (strpos($token, 'T:') === 0) {
                                                                 $token_type = PexToken::OBCV;
                                                             } else {
                                                                 if (strpos($token, '/T:') === 0) {
                                                                     $token_type = PexToken::EBCV;
                                                                 } else {
                                                                     if (strpos($token, '//T:') === 0) {
                                                                         $token_type = PexToken::FBCV;
                                                                     } else {
                                                                         //if (DEBUG_PARSER) { Analyse::echo_debug("Token type texte");}
                                                                         $no_match = true;
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ($no_match) {
             prev($this->tokens);
             $token = $atoken;
         }
     } else {
         if ($atoken == '#') {
             // Traiter les cas similaires à ##REF
             $tmp = next($this->tokens);
             if ($tmp == '#') {
                 $token = '#';
                 prev($this->tokens);
             } else {
                 $token = '#' . $tmp;
                 $this->add_var($token);
             }
         } else {
             $token = $atoken;
         }
     }
     //if (DEBUG_PARSER) { Analyse::echo_debug( "Token:[$token], type $token_type"); }
     // Dans un commentaire, on attend la fin sans rien analyser
     if ($this->in_comment && $token_type !== PexToken::FCM) {
         //if (DEBUG_PARSER) { Analyse::echo_debug("ignore: $token_type:", $token); }
         return 'vide';
     }
     // BOUCLE SIMPLE et boucle REPETER
     if ($token_type === PexToken::OBS || $token_type === PexToken::OBR) {
         if ($token_type === PexToken::OBS) {
             $boucle = new BoucleSimple(substr($token, 7));
         } else {
             $boucle = new BoucleRepeter(substr($token, 8));
         }
         array_push($this->pile_nom_boucles, $token);
         // Parse args se fait avant le push, car les variables dans les args doivent être valuées
         // par la boucle enclosante.
         $boucle->set_args($this->parse_args());
         array_push($this->pile_boucle_courante, $boucle);
         //if (DEBUG_PARSER) { Analyse::echo_debug("Push boucle courante $boucle->nom\n", $this->pile_boucle_courante); }
         $boucle->ajouter($this->parse_content());
         // Skip remaining > TODO check >
         $this->skipto('>');
         return $boucle;
     } else {
         if ($token_type === PexToken::FBS || $token_type === PexToken::FBR) {
             $this->controle_fermeture_boucle($token);
             array_pop($this->pile_boucle_courante);
             //if (DEBUG_PARSER) { Analyse::echo_debug("Pop boucle courante $token\n", $this->pile_boucle_courante); }
             return 'stop';
         } else {
             if ($token_type === PexToken::OBC) {
                 $boucle = new BoucleConditionnelle(substr($token, 2));
                 $this->skipto('>');
                 array_push($this->pile_nom_boucles, $token);
                 //if (DEBUG_PARSER) { Analyse::echo_debug("Push boucle conditionnelle $token\n", $this->pile_boucle_courante); }
                 // Si
                 $boucle->ajouter($this->parse_content());
                 $this->skipto('>');
                 array_push($this->pile_nom_boucles, '/' . $token);
                 //if (	const ) { Analyse::echo_debug("Push SI boucle conditionnelle $token\n", $this->pile_boucle_courante); }
                 // Sinon
                 $boucle->ajouter($this->parse_content());
                 $this->skipto('>');
                 return $boucle;
             } else {
                 if ($token_type === PexToken::EBC) {
                     //if (DEBUG_PARSER) { Analyse::echo_debug("Controle fermeture SI: $token\n", $this->pile_boucle_courante); }
                     $this->controle_fermeture_boucle($token);
                     return 'stop';
                 } else {
                     if ($token_type === PexToken::FBC) {
                         //if (DEBUG_PARSER) { Analyse::echo_debug("Controle fermeture ELSE: $token\n", $this->pile_boucle_courante);}
                         $this->controle_fermeture_boucle($token);
                         return 'stop';
                     } else {
                         if ($token_type === PexToken::OBCV) {
                             $var = substr($token, 2);
                             // Ajouter la variable à la boucle enclosante
                             $this->add_var($var);
                             $boucle = new BoucleConditionnelleVariable($var);
                             $this->skipto('>');
                             array_push($this->pile_nom_boucles, $token);
                             //if (DEBUG_PARSER) { Analyse::echo_debug("Push boucle conditionnelle $token\n", $this->pile_boucle_courante); }
                             // Si
                             $boucle->ajouter($this->parse_content());
                             $this->skipto('>');
                             array_push($this->pile_nom_boucles, '/' . $token);
                             //if (	const ) { Analyse::echo_debug("Push SI boucle conditionnelle $token\n", $this->pile_boucle_courante); }
                             // Sinon
                             $boucle->ajouter($this->parse_content());
                             $this->skipto('>');
                             return $boucle;
                         } else {
                             if ($token_type === PexToken::EBCV) {
                                 //if (DEBUG_PARSER) { Analyse::echo_debug("Controle fermeture SI: $token\n", $this->pile_boucle_courante); }
                                 $this->controle_fermeture_boucle($token);
                                 return 'stop';
                             } else {
                                 if ($token_type === PexToken::FBCV) {
                                     //if (DEBUG_PARSER) { Analyse::echo_debug("Controle fermeture ELSE: $token\n", $this->pile_boucle_courante);}
                                     $this->controle_fermeture_boucle($token);
                                     return 'stop';
                                 } else {
                                     if ($token_type === PexToken::OBT) {
                                         $boucle = new BoucleTest(substr($token, 5));
                                         // Parse args se fait avant le push, car les variables dans les args doivent être valuées
                                         // par la boucle enclosante.
                                         $boucle->set_args($this->parse_args());
                                         array_push($this->pile_nom_boucles, $token);
                                         //if (DEBUG_PARSER) { Analyse::echo_debug("Push boucle Test $boucle->nom\n", $this->pile_boucle_courante);}
                                         // Si
                                         $boucle->ajouter($this->parse_content());
                                         $this->skipto('>');
                                         array_push($this->pile_nom_boucles, '/' . $token);
                                         // Sinon
                                         $boucle->ajouter($this->parse_content());
                                         $this->skipto('>');
                                         return $boucle;
                                     } else {
                                         if ($token_type === PexToken::EBT) {
                                             //if (DEBUG_PARSER) { Analyse::echo_debug("Controle fermeture TEST SI: $token\n", $this->pile_boucle_courante);}
                                             $this->controle_fermeture_boucle($token);
                                             return 'stop';
                                         } else {
                                             if ($token_type === PexToken::FBT) {
                                                 //if (DEBUG_PARSER) { Analyse::echo_debug("Controle fermeture TEST ELSE: $token\n", $this->pile_boucle_courante); }
                                                 $this->controle_fermeture_boucle($token);
                                                 return 'stop';
                                             } else {
                                                 if ($token_type === PexToken::OCM) {
                                                     //if (DEBUG_PARSER) { Analyse::echo_debug("Ouverture commentaire: $token\n", $this->pile_boucle_courante); }
                                                     $this->in_comment = true;
                                                     return 'vide';
                                                 } else {
                                                     if ($token_type === PexToken::FCM) {
                                                         //if (DEBUG_PARSER) { Analyse::echo_debug("Controle fermeture TEST ELSE: $token\n", $this->pile_boucle_courante); }
                                                         $this->in_comment = false;
                                                         $this->skipto('>');
                                                         return 'vide';
                                                     } else {
                                                         if ($token !== '') {
                                                             return new PexTexte($token);
                                                         } else {
                                                             return 'vide';
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 15
0
 public function comment(Comment $comment, Analyse $analysis)
 {
     $comment->setUser($this);
     $analysis->addComment($comment);
 }
Ejemplo n.º 16
0
 function imprimer()
 {
     Analyse::echo_debug($this->texte);
 }
Ejemplo n.º 17
0
<?php

// module test
include 'Controller.class.php';
// test Spider class
$spider = new Spider('深圳娃娃鱼事件');
echo $spider->get(1);
// test Controller class
$controller = new Controller();
for ($i = 0; $i < 2; $i++) {
    $controller->work(5);
}
$controller->work(5);
$controller->task('深圳多名官员吃娃娃鱼');
// test Analyse class
$analyse = new Analyse('深圳多名官员吃娃娃鱼', 1);
echo $analyse->total();
var_dump($analyse->results());
 public static function printAnalysis(Analyse $publication)
 {
     $html = "<li>";
     $html .= "<span class='date-publication'>[";
     $html .= $publication->getDateFormatted();
     $html .= "]</span>";
     $html .= "<a target='_blank' href='" . LinkController::getBaseURL() . "/analise/" . $publication->link() . ".html'>";
     $html .= $publication->title();
     $html .= "</a><br />";
     $qtdComments = $publication->getComments()->count();
     $html .= "<span class='number-comments'>";
     $html .= $qtdComments . ' ' . ($qtdComments == 1 ? "comentário" : "comentários");
     $html .= "</span>";
     $html .= "</li>";
     echo $html;
 }
Ejemplo n.º 19
0
 public function getAnalysisId()
 {
     return $this->analysis->id();
 }
Ejemplo n.º 20
0
        $dayCount++;
    }
}
$classCalculator = new ClassCalculator();
$classCalc[0]['min'] = 100;
$classCalc[0]['max'] = 0;
$classCalc[1]['min'] = 100;
$classCalc[1]['max'] = 0;
$classCalc[2]['min'] = 100;
$classCalc[2]['max'] = 0;
foreach ($timezones as $city) {
    for ($i = 0; $i <= 2; $i++) {
        if ($classCalc[$i]['min'] > $city->getDay($i)->getSentimentIndex()) {
            $classCalc[$i]['min'] = $city->getDay($i)->getSentimentIndex();
        }
        if ($classCalc[$i]['max'] < $city->getDay($i)->getSentimentIndex()) {
            $classCalc[$i]['max'] = $city->getDay($i)->getSentimentIndex();
        }
    }
}
$analyse = new Analyse($timezones);
//Jeder Tag hat eigene max und min
$analyse->setMaxMinSentimentIndex(0, $classCalc[0]['max'], $classCalc[0]['min']);
$analyse->setMaxMinSentimentIndex(1, $classCalc[1]['max'], $classCalc[1]['min']);
$analyse->setMaxMinSentimentIndex(2, $classCalc[2]['max'], $classCalc[2]['min']);
//Max und Min für alle 3 Tage
// $analyse->setMaxMinSentimentIndex(0, max($classCalc[0]['max'],$classCalc[1]['max'],$classCalc[1]['max']), min($classCalc[0]['min'],$classCalc[1]['min'],$classCalc[2]['min']));
// $analyse->setMaxMinSentimentIndex(1, max($classCalc[0]['max'],$classCalc[1]['max'],$classCalc[1]['max']), min($classCalc[0]['min'],$classCalc[1]['min'],$classCalc[2]['min']));
// $analyse->setMaxMinSentimentIndex(2, max($classCalc[0]['max'],$classCalc[1]['max'],$classCalc[1]['max']), min($classCalc[0]['min'],$classCalc[1]['min'],$classCalc[2]['min']));
echo "Daten wurden neu geladen. <a href='index.html'>Zur&uuml;k zur Tabelle</a>";
file_put_contents('data.json', json_encode($analyse));