public static function getIndexChartsPoliticiansInConstituency($ramo, $data, $circoscrizione_slug, $con = null)
 {
     if (is_null($con)) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $circoscrizione = self::getCircoscrizioneNameFromSlug($circoscrizione_slug);
     $sql = sprintf("select pc.id, p.id as politico_id, p.nome, p.cognome, g.acronimo, c.circoscrizione, pc.assenze/(pc.presenze+pc.missioni+pc.assenze)*100.0 as perc_assenze, pc.assenze as assenze, (pc.presenze+pc.missioni+pc.assenze) as votazioni, pc.indice from opp_politician_history_cache pc, opp_carica c, opp_politico p, opp_carica_has_gruppo cg, opp_gruppo g where p.id=c.politico_id and c.id=pc.chi_id and cg.carica_id=c.id and cg.gruppo_id=g.id and cg.data_fine is null and c.data_fine is null and pc.chi_tipo='P' and pc.data='%s' and pc.ramo='%s' and c.circoscrizione='%s' and p.id not in (select politico_id from opp_carica where tipo_carica_id in (2,3,5,6,7) and data_fine is null) and p.id not in (%s) and c.data_inizio <  '%s' - interval 365 day order by pc.indice desc", $data, $ramo, $circoscrizione, implode(",", OppPoliticoPeer::getPresidentiCamereIds()), $data);
     $stm = $con->createStatement();
     $rs = $stm->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     $items = array();
     while ($rs->next()) {
         $row = $rs->getRow();
         $items[] = $row;
     }
     return $items;
 }
 public function _add_data_inizio_incarico($politicians, $ramo, $data)
 {
     $items = array();
     foreach ($politicians as $politician) {
         $politician_obj = OppPoliticoPeer::retrieveByPK($politician['politico_id']);
         $carica_corrente = $politician_obj->getCaricaDepSenCorrente();
         $data_inizio_incarico = $carica_corrente->getDataInizio();
         if ($data_inizio_incarico > sfConfig::get('app_legislatura_data_inizio', 2008)) {
             $politician['data_inizio_incarico'] = strftime('%d/%m/%Y', strtotime($data_inizio_incarico));
         }
         array_push($items, $politician);
     }
     return $items;
 }
):</th>
	  				<th class="evident W20_100" scope="col"><br/>smetti di monitorare:</th>
					</tr>
	  		</thead>
	  		<tbody>
	  	  <?php 
    foreach ($monitored_politicians as $politician) {
        ?>
  	  
	  			<tr id="pol_<?php 
        echo $politician->getId();
        ?>
">
	  				<th scope="row"><p class="politician-id">
	  				  <?php 
        echo image_tag(OppPoliticoPeer::getThumbUrl($politician->getId()), 'icona parlamentare');
        ?>
	  				  <?php 
        echo link_to($politician, '@parlamentare?' . $politician->getUrlParams());
        ?>
</p>
	  				</th>
	  				<td><p class="float-right"><a class="btn-open-table action" href="#">
	  				  <?php 
        echo format_number_choice('[0]|[1]1 nuova|(1,+Inf]%1% nuove', array('%1%' => $politician->getNNewNews($sf_user->getAttribute('last_login', null, 'subscriber'))), $politician->getNNewNews($sf_user->getAttribute('last_login', null, 'subscriber')));
        ?>
                    <?php 
        if ($politician->getLastNews()) {
            ?>
 
	            - ultima: <?php 
$t = new lime_test(14, new lime_output_color());
$test_user_id = 8;
$t->diag('unit test for the sending of the newsletter');
$t->diag('Tests beginning');
// clean the database
$t->diag('Cleaning previously created test records');
$c = new Criteria();
$c->add(OppAttoPeer::PARLAMENTO_ID, 999999);
$existing_records = OppAttoPeer::doSelect($c);
foreach ($existing_records as $rec) {
    $t->diag('Cleaning record ' . get_class($rec) . "(" . $rec->getId() . ")");
    $rec->delete();
}
$c = new Criteria();
$c->add(OppPoliticoPeer::ID, 999999);
$existing_records = OppPoliticoPeer::doSelect($c);
foreach ($existing_records as $rec) {
    $t->diag('Cleaning record ' . get_class($rec) . "(" . $rec->getId() . ")");
    $rec->delete();
}
$t->diag('Create the test act object');
$obj = new OppAtto();
$obj->setTipoAttoId(1);
$obj->setParlamentoId(999999);
$obj->setRamo('S');
$obj->setNumFase(914);
$obj->setDataPres('2008-11-01');
$obj->setDescrizione("Una descrizione di prova");
$obj->save();
$related_news = getRelatedNews($obj);
$n_related_news = count($related_news);
                 echo "*" . data_format(trim($data_fine[0])) . "*";
             }
         }
         echo "\n";
     }
 } else {
     $uri = "http://legislature.camera.it/altre_sezionism/10247/10262/10264/documentoxml.asp?menu=&Let=" . $lettera;
     $html = file_get_html($uri);
     $deps = $html->find('a[href*=framedeputato]');
     foreach ($deps as $dep) {
         echo $dep->plaintext . "\t";
         $c = new Criteria();
         $c->clearSelectColumns();
         $c->addSelectColumn(OppPoliticoPeer::ID);
         $c->addAsColumn('FULLNAME', 'CONCAT_WS(" ", ' . OppPoliticoPeer::COGNOME . ', ' . OppPoliticoPeer::NOME . ')');
         $rs = OppPoliticoPeer::doSelectRS($c);
         $pol_id = 0;
         $k = 0;
         while ($rs->next()) {
             if ($rs->getString(2) == trim($dep->plaintext)) {
                 $pol_id = $rs->getInt(1) . "\t";
                 $k++;
             }
         }
         if ($pol_id == 0) {
             echo "POLITICO ID NON TROVATO \t";
         } elseif ($k == 1) {
             echo $pol_id . "\t";
         } else {
             echo "TROVATO PIU' DI UN POLITICO \t";
         }
 public function getRibelliList($voto_gruppi = null)
 {
     if (is_null($voto_gruppi)) {
         $voto_gruppi = OppVotazioneHasCaricaPeer::doSelectGroupByGruppo($this->getId());
     }
     $ribelli_id = array();
     $ribelli = array();
     foreach ($voto_gruppi as $gruppo => $risultato) {
         if ($gruppo != 'Gruppo Misto') {
             $c = new Criteria();
             $c->add(OppGruppoPeer::NOME, $gruppo);
             $gruppo_id = $risultato['id'];
             $c = new Criteria();
             $c->add(OppVotazioneHasGruppoPeer::VOTAZIONE_ID, $this->getId());
             $c->add(OppVotazioneHasGruppoPeer::GRUPPO_ID, $gruppo_id);
             $voto_gruppo = OppVotazioneHasGruppoPeer::doSelectOne($c);
             if ($voto_gruppo) {
                 if ($voto_gruppo->getVoto() != 'nv') {
                     unset($risultato['Assente']);
                     unset($risultato['In missione']);
                     arsort($risultato);
                     array_shift($risultato);
                     $c = new Criteria();
                     $c->clearSelectColumns();
                     $c->addSelectColumn(OppCaricaPeer::POLITICO_ID);
                     $c->addSelectColumn(OppGruppoPeer::NOME);
                     $c->addSelectColumn(OppCaricaPeer::CIRCOSCRIZIONE);
                     $c->addSelectColumn(OppVotazioneHasCaricaPeer::VOTO);
                     $c->addJoin(OppCaricaPeer::ID, OppVotazioneHasCaricaPeer::CARICA_ID, Criteria::LEFT_JOIN);
                     $c->addJoin(OppCaricaPeer::ID, OppCaricaHasGruppoPeer::CARICA_ID, Criteria::LEFT_JOIN);
                     $c->addJoin(OppCaricaHasGruppoPeer::GRUPPO_ID, OppGruppoPeer::ID, Criteria::LEFT_JOIN);
                     $c->add(OppGruppoPeer::NOME, $gruppo, Criteria::EQUAL);
                     $c->add(OppVotazioneHasCaricaPeer::VOTAZIONE_ID, $this->getId(), Criteria::EQUAL);
                     $c->add(OppVotazioneHasCaricaPeer::VOTO, array_keys($risultato), Criteria::IN);
                     $c->add(OppCaricaHasGruppoPeer::DATA_INIZIO, $this->getOppSeduta()->getData(), Criteria::LESS_EQUAL);
                     $cton1 = $c->getNewCriterion(OppCaricaHasGruppoPeer::DATA_FINE, $this->getOppSeduta()->getData(), Criteria::GREATER_EQUAL);
                     $cton2 = $c->getNewCriterion(OppCaricaHasGruppoPeer::DATA_FINE, null, Criteria::ISNULL);
                     $cton1->addOr($cton2);
                     $c->add($cton1);
                     $rs = OppCaricaPeer::doSelectRS($c);
                     while ($rs->next()) {
                         $ribelli1[$rs->getInt(1)] = array('id' => $rs->getInt(1), 'gruppo' => $rs->getString(2), 'circoscrizione' => $rs->getString(3), 'voto_gruppo' => $voto_gruppo->getVoto(), 'voto' => $rs->getString(4));
                         array_push($ribelli_id, $rs->getInt(1));
                     }
                 }
             }
         }
     }
     $c = new Criteria();
     $c->add(OppPoliticoPeer::ID, $ribelli_id, Criteria::IN);
     $c->addAscendingOrderByColumn(OppPoliticoPeer::COGNOME);
     $rs1 = OppPoliticoPeer::doSelectRS($c);
     while ($rs1->next()) {
         $ribelli[$rs1->getString(3) . ' ' . $rs1->getString(2)] = $ribelli1[$rs1->getInt(1)];
     }
     return $ribelli;
 }
<?php

define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..'));
define('SF_APP', 'fe');
define('SF_ENVIRONMENT', 'dev');
define('SF_DEBUG', false);
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
sfContext::getInstance();
print "Fetching data... \n";
$c = new Criteria();
$c->add(OppCaricaPeer::DATA_FINE, NULL, Criteria::EQUAL);
$c->add(OppCaricaPeer::LEGISLATURA, 16, Criteria::EQUAL);
$cariche = OppCaricaPeer::doSelect($c);
foreach ($cariche as $carica) {
    $parlamentare = OppPoliticoPeer::RetrieveByPk($carica->getPoliticoId());
    $report = $carica->getReport();
    $presenze = $report['Astenuto'] + $report['Contrario'] + $report['Favorevole'] + $report['Partecipante votazione non valida'] + $report['Presidente di turno'] + $report['Richiedente la votazione e non votante'] + $report['Voto segreto'];
    $numero_votazioni = $report['Astenuto'] + $report['Contrario'] + $report['Favorevole'] + $report['Partecipante votazione non valida'] + $report['Presidente di turno'] + $report['Richiedente la votazione e non votante'] + $report['Voto segreto'] + $report['Assente'] + $report['In missione'];
    $gruppi = OppCaricaHasGruppoPeer::doSelectGruppiPerCarica($carica->getId());
    foreach ($gruppi as $nome => $gruppo) {
        $data_inizio = split("/", $gruppo['data_inizio']);
        $di = "20" . $data_inizio[2] . "-" . $data_inizio[0] . "-" . $data_inizio[1];
        if ($data_fine != '') {
            $data_fine = split("/", $gruppo['data_fine']);
            $df = "20" . $data_fine[2] . "-" . $data_fine[0] . "-" . $data_fine[1];
        } else {
            $df = '';
        }
        $ribelle_count = $parlamentare->getRibelleReport($carica->getId(), $report['carica'] == 'Deputato' ? 'C' : 'S', $nome, $di, $df);
    }
    print "id carica:" . $carica->getId() . " presenze:" . $presenze . " assenze:" . $report['Assente'] . " missioni:" . $report['In missione'] . "\n";
 public function executePolitician()
 {
     $this->politician_id = $this->getRequestParameter('id');
     $this->politician = OppPoliticoPeer::retrieveByPK($this->politician_id);
     $this->n_news = oppNewsPeer::countNewsForItem('OppPolitico', $this->politician_id);
     $this->getResponse()->setTitle('tutte le notizie sul parlamentare ' . $this->politician->getNome() . ' ' . $this->politician->getCognome() . ' - ' . sfConfig::get('app_main_title'));
     $this->response->addMeta('description', 'Tutte le notizie aggiornate quotidianamente su cosa fa in Parlamento ' . $this->politician->getNome() . ' ' . $this->politician->getCognome(), true);
     $c = new Criteria();
     $c->add(OppCaricaPeer::TIPO_CARICA_ID, array(1, 4, 5), Criteria::IN);
     $c->add(OppCaricaPeer::DATA_FINE, null, Criteria::ISNULL);
     $c->add(OppCaricaPeer::POLITICO_ID, $this->politician_id);
     $this->carica = OppCaricaPeer::doSelectOne($c);
     $c = oppNewsPeer::getNewsForItemCriteria('OppPolitico', $this->politician_id);
     $c->addDescendingOrderByColumn(NewsPeer::DATE);
     if ($this->hasRequestParameter('itemsperpage')) {
         $this->getUser()->setAttribute('itemsperpage', $this->getRequestParameter('itemsperpage'));
     }
     $itemsperpage = $this->getUser()->getAttribute('itemsperpage', sfConfig::get('app_pagination_limit'));
     $pager = new deppNewsPager('News', $itemsperpage);
     $pager->setCriteria($c);
     $pager->setPage($this->getRequestParameter('page', 1));
     $pager->init();
     $this->pager = $pager;
 }
               ?>
                  <?php 
           }
           ?>
               </p>
                <?php 
       }
       ?>
               </th>
               <th scope="row" style="border-bottom:0px;">
                 <?php 
       foreach ($lontani as $pos => $lontano) {
           ?>
                 <p class="politician-id">
                 <?php 
           echo image_tag(OppPoliticoPeer::getThumbUrl($lontano[1]->getOppPolitico()->getId()), 'icona parlamentare');
           ?>
                  <?php 
           echo link_to($lontano[1]->getOppPolitico()->getNome() . " " . $lontano[1]->getOppPolitico()->getCognome(), '@parlamentare?' . $lontano[1]->getOppPolitico()->getUrlParams());
           ?>
                <?php 
           $gruppi = OppCaricaHasGruppoPeer::doSelectGruppiPerCarica($lontano[1]->getId());
           ?>
 	
                  <?php 
           foreach ($gruppi as $nome => $gruppo) {
               ?>
                  <?php 
               if (!$gruppo['data_fine']) {
                   ?>
                   <?php 
?>
</p>
       </div>   			                             
    </div>
 </div>     


<div class="W45_100 float-left">
   <div class="float-container">
   <p style="font-size:20px; font-weight:bold; padding: 5px;"><?php 
echo ($parlamentare1->getTipoCaricaId() == 1 ? 'On. ' : 'Sen. ') . link_to($parlamentare2->getOppPolitico()->getNome() . '&nbsp;' . $parlamentare2->getOppPolitico()->getCognome(), '@parlamentare?' . $parlamentare2->getOppPolitico()->getUrlParams());
echo ' (' . $parlamentare2->getOppPolitico()->getGruppoCorrente()->getAcronimo() . ')';
?>
</p>
       <?php 
echo image_tag(OppPoliticoPeer::getPictureUrl($parlamentare2->getOppPolitico()->getId()), array('class' => 'portrait-91x126 float-left', 'alt' => $parlamentare2->getOppPolitico()->getNome() . ' ' . $parlamentare2->getOppPolitico()->getCognome(), 'width' => '91', 'height' => '126'));
?>
         <div class="politician-more-info">
			<p><label><?php 
echo $parlamentare2->getLegislatura() . "&#186; legislatura: ";
?>
</label>in carica dal
				<?php 
echo $parlamentare2->getDataInizio('d/m/Y');
?>
</p>
       <p><label>voti ribelli:</label>    			                             	
          <?php 
echo round($parlamentare2->getRibelle() * 100 / $parlamentare2->getPresenze(), 1) . '% (' . link_to($parlamentare2->getRibelle(), '@parlamentare_voti?id=' . $parlamentare2->getOppPolitico()->getId() . '&slug=' . $parlamentare2->getOppPolitico()->getSlug() . '&filter_vote_rebel=1') . ' volte su ' . $parlamentare2->getPresenze() . ' votazioni )';
?>
       </p>
예제 #11
0
?>
  <?php 
foreach ($ribelli as $ribelle) {
    ?>
  
   <tr class="<?php 
    echo $tr_class;
    ?>
">
   <?php 
    $tr_class = $tr_class == 'even' ? 'odd' : 'even';
    ?>
  	  <th scope="row">
  	   <p class="politician-id">
            <?php 
    echo image_tag(OppPoliticoPeer::getThumbUrl($ribelle['politico_id']), 'icona parlamentare');
    ?>
	
            <?php 
    echo link_to(sprintf("%s %s", $ribelle['politico_cognome'], $ribelle['politico_nome']), '@parlamentare?id=' . $ribelle['politico_id'] . '&slug=' . slugify($ribelle['politico_nome'] . ' ' . $ribelle['politico_cognome']));
    echo ' (' . $ribelle['gruppo_acronimo'] . ')';
    ?>
           </p>
          </th>
	  <td><?php 
    echo $ribelle['voto'];
    ?>
</td>
	  <td><?php 
    echo $ribelle['voto_gruppo'];
    ?>
<?php

define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..'));
define('SF_APP', 'fe');
define('SF_ENVIRONMENT', 'dev');
define('SF_DEBUG', false);
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
sfContext::getInstance();
$c = new Criteria();
$c->addJoin(OppCaricaPeer::POLITICO_ID, OppPoliticoPeer::ID);
$c->add(OppCaricaPeer::LEGISLATURA, 16);
//$c->Limit(1);
$rss = OppPoliticoPeer::doSelect($c);
foreach ($rss as $rs) {
    $newfile = "foto/" . $rs->getId();
    $dl = "http://openpolis.depplab.net/politician/picture?content_id=" . $rs->getId();
    copy($dl, $newfile);
}
/**
 * generate textual representation for a news
 *
 * @param News $news 
 * @param String $generator_model 
 * @param Array $pks 
 * @param BaseObject $generator 
 * @param Array $options 
 *   context  - 0: box, 1: news per politico, 2:pagina di un atto, 3: argomento
 *   in_mail  - if the news lives in a mail or not
 * @return string (html)
 * @author Guglielmo Celata
 */
function news_text(News $news, $generator_model, $pks, $generator, $options = array())
{
    sfLoader::loadHelpers('Asset');
    // default value for context
    if (!array_key_exists('context', $options)) {
        $context = CONTEXT_LIST;
    } else {
        $context = $options['context'];
    }
    // default value for in_mail
    if (!array_key_exists('in_mail', $options)) {
        $in_mail = false;
    } else {
        $in_mail = $options['in_mail'];
    }
    $news_string = "";
    // notizie di gruppo (votazioni, interventi o emendamenti)
    if (count($pks) == 0) {
        if ($generator_model == 'OppVotazioneHasAtto') {
            if ($news->getPriority() == 1) {
                $news_string .= content_tag('p', $news->getRamoVotazione() == 'C' ? 'Camera -  ' : 'Senato - ');
                $news_string .= content_tag('p', 'si &egrave; svolta almeno una VOTAZIONE');
            } else {
                $news_string .= "<p>";
                $news_string .= $news->getRamoVotazione() == 'C' ? 'Camera -  ' : 'Senato - ';
                $news_string .= 'si &egrave; svolta una VOTAZIONE</p>';
                if ($context == CONTEXT_LIST) {
                    $atto = call_user_func_array(array($news->getRelatedMonitorableModel() . 'Peer', 'retrieveByPK'), $news->getRelatedMonitorableId());
                    $atto_link = link_to_in_mail($atto->getRamo() . '.' . $atto->getNumfase() . ' ' . $atto->getTitolo(true), 'atto/index?id=' . $atto->getId(), array('title' => $atto->getTitolo(true)));
                    $news_string .= 'per ' . OppTipoAttoPeer::retrieveByPK($news->getTipoAttoId())->getDenominazione() . ' ';
                    $news_string .= '<p>' . $atto_link . '</p>';
                }
            }
        }
        if ($generator_model == 'OppIntervento') {
            $news_string .= "<p>";
            $news_string .= OppSedePeer::retrieveByPK($news->getSedeInterventoId())->getRamo() == 'C' ? 'Camera -  ' : 'Senato - ';
            $news_string .= 'C\'&egrave; stato <strong>almeno un intervento</strong> in ';
            if (OppSedePeer::retrieveByPK($news->getSedeInterventoId())->getTipologia() != 'Assemblea') {
                $news_string .= OppSedePeer::retrieveByPK($news->getSedeInterventoId())->getTipologia();
            }
            $news_string .= ' ' . OppSedePeer::retrieveByPK($news->getSedeInterventoId())->getDenominazione();
            if ($context = CONTEXT_LIST) {
                $news_string .= '   per ' . OppTipoAttoPeer::retrieveByPK($news->getTipoAttoId())->getDescrizione() . '</p> ';
                // link all'atto
                $atto = call_user_func_array(array($news->getRelatedMonitorableModel() . 'Peer', 'retrieveByPK'), array($news->getRelatedMonitorableId()));
                $atto_link = link_to_in_mail($atto->getRamo() . '.' . $atto->getNumfase() . ' ' . $atto->getTitolo(true), 'atto/index?id=' . $atto->getId(), array('title' => $atto->getTitolo(true)));
                $news_string .= '<p>' . $atto_link . '</p>';
            } else {
                $news_string .= '</p>';
            }
        }
        if ($generator_model == 'OppEmendamento') {
            $related_monitorable_model = $news->getRelatedMonitorableModel();
            if ($related_monitorable_model == 'OppAtto') {
                $atto = OppAttoPeer::retrieveByPK($news->getRelatedMonitorableId());
                $n_pres = $atto->countPresentedEmendamentiAtDate($news->getDate());
                if ($n_pres > 1) {
                    $news_string .= content_tag('p', sprintf("Sono stati presentati %s", link_to($n_pres . " emendamenti", '/emendamenti_atto/' . $atto->getId())));
                } else {
                    $news_string .= content_tag('p', sprintf("&Egrave; stato presentato %s", link_to("un emendamento", '/emendamenti_atto/' . $atto->getId())));
                }
            } else {
                if ($related_monitorable_model == 'OppPolitico') {
                    // fetch del politico
                    $politico = OppPoliticoPeer::retrieveByPK($news->getRelatedMonitorableId());
                    $n_signs = $politico->countSignedEmendamentiAtDate($news->getDate());
                    if ($n_signs > 1) {
                        $news_string .= content_tag('p', "Ha firmato <b>{$n_signs}</b> emendamenti");
                    } else {
                        $news_string .= content_tag('p', "Ha firmato un emendamento");
                    }
                }
            }
        }
        return $news_string;
    }
    // eccezione per firma, quando in pagina argomenti
    // corregge bug #307
    if ($context == CONTEXT_TAG && $generator_model == 'OppCaricaHasAtto') {
        $atto = $generator->getOppAtto();
        $carica = $generator->getOppCarica();
        $tipo = $atto->getOppTipoAtto();
        $tipo_firma = $generator->getTipo();
        switch ($tipo_firma) {
            case "P":
                $tipo_firma = 'presenta';
                break;
            case "C":
                $tipo_firma = 'firma';
                break;
            case "R":
                $tipo_firma = '&egrave; relatore';
                break;
        }
        $atto_link = link_to_in_mail(troncaTesto(Text::denominazioneAtto($atto, 'list', true), 200), 'atto/index?id=' . $atto->getId(), array('title' => $atto->getTitolo(true)));
        $politico = $carica->getOppPolitico();
        $politico_link = link_to_in_mail($politico, '@parlamentare?' . $politico->getUrlParams(), array('title' => 'Vai alla scheda del politico'));
        $news_string .= '<p>';
        $news_string .= $politico_link;
        $news_string .= " <strong>" . $tipo_firma . "</strong> ";
        if ($tipo_firma == '&egrave; relatore') {
            $news_string .= "dell'atto ";
        } else {
            $news_string .= "l'atto ";
        }
        $news_string .= $tipo->getDescrizione() . "</p>";
        $news_string .= '<p>' . $atto_link . '</p>';
        return $news_string;
    }
    if ($generator) {
        $related_monitorable_model = $news->getRelatedMonitorableModel();
        if ($related_monitorable_model == 'OppPolitico') {
            // fetch del politico
            $c = new Criteria();
            $c->add(OppPoliticoPeer::ID, $news->getRelatedMonitorableId());
            $politici = OppPoliticoPeer::doSelect($c);
            if (count($politici) == 0) {
                return 'empty OppPolitico:' . $news->getRelatedMonitorableId();
            }
            $politico = $politici[0];
            // link al politico
            $politico_link = link_to_in_mail($politico->getNome() . ' ' . $politico->getCognome(), '@parlamentare?' . $politico->getUrlParams(), array('title' => 'Vai alla scheda del politico'));
            // nuovo incarico
            if ($generator_model == 'OppCarica') {
                if ($context != CONTEXT_POLITICO) {
                    $news_string .= "<p><strong>assume l'incarico di " . $generator->getCarica() . "</strong> il politico</p>";
                    $news_string .= "<p>" . $politico_link . "</p>";
                } else {
                    $news_string .= "<p><strong>Assume l'incarico di " . $generator->getCarica() . "</strong></p>";
                }
            } else {
                if ($generator_model == 'OppCaricaHasGruppo') {
                    if ($context != CONTEXT_POLITICO) {
                        $news_string .= "<p><strong>si unisce al gruppo " . $generator->getOppGruppo()->getNome() . "</strong> il politico</p>";
                        $news_string .= "<p>" . $politico_link . "</p>";
                    } else {
                        $news_string .= "<p><strong>Si unisce al gruppo " . $generator->getOppGruppo()->getNome() . "</strong></p>";
                    }
                } else {
                    if ($generator_model == 'OppIntervento') {
                        $atto = $generator->getOppAtto();
                        $tipo = $atto->getOppTipoAtto();
                        $atto_link = link_to_in_mail(troncaTesto(Text::denominazioneAtto($atto, 'list', true), 200), 'atto/index?id=' . $atto->getId(), array('title' => $atto->getTitolo(true)));
                        if ($context == CONTEXT_LIST) {
                            $news_string .= "<p>" . $politico_link . " <strong>interviene</strong>";
                            if ($generator->getUrl() != NULL) {
                                if (substr_count($generator->getUrl(), '@') > 0) {
                                    $int_urls = explode("@", $generator->getUrl());
                                    $intervento_link = " [vai ai testi";
                                    foreach ($int_urls as $cnt => $int_url) {
                                        if (!preg_match('#^http://#', $int_url)) {
                                            $int_url = sfConfig::get('app_url_sito_camera', 'http://nuovo.camera.it/') . $int_url;
                                        }
                                        $intervento_link .= " " . link_to($cnt + 1, $int_url) . ",";
                                    }
                                    $intervento_link = rtrim($intervento_link, ",");
                                    $intervento_link .= "]";
                                } else {
                                    $intervento_link = " [" . link_to('vai al testo', $generator->getUrl()) . "]";
                                }
                            } else {
                                $intervento_link = "";
                            }
                            $news_string .= $intervento_link . " in ";
                            if ($generator->getOppSede()->getId() != 35 && $generator->getOppSede()->getId() != 36) {
                                $news_string .= $generator->getOppSede()->getTipologia() . " ";
                            }
                            $news_string .= strtoupper($generator->getOppSede()->getDenominazione()) . " su ";
                            $news_string .= $tipo->getDescrizione() . "</p>";
                            $news_string .= "<p>" . $atto_link . "</p>";
                        }
                        if ($context == CONTEXT_ATTO) {
                            $news_string .= "<p>";
                            if ($generator->getOppSede()->getId() != 35 && $generator->getOppSede()->getId() != 36) {
                                $news_string .= $generator->getOppSede()->getTipologia() . " - ";
                            }
                            $news_string .= ucfirst(strtolower($generator->getOppSede()->getDenominazione()));
                            $news_string .= $politico_link . " <strong>&egrave; intervenuto</strong>";
                            if ($generator->getUrl() != NULL) {
                                if (substr_count($generator->getUrl(), '@') > 0) {
                                    $int_urls = explode("@", $generator->getUrl());
                                    $intervento_link = " [vai ai testi";
                                    foreach ($int_urls as $cnt => $int_url) {
                                        if (!preg_match('#^http://#', $int_url)) {
                                            $int_url = sfConfig::get('app_url_sito_camera', 'http://nuovo.camera.it/') . $int_url;
                                        }
                                        $intervento_link .= " " . link_to($cnt + 1, $int_url) . ",";
                                    }
                                    $intervento_link = rtrim($intervento_link, ",");
                                    $intervento_link .= "]";
                                } else {
                                    $intervento_link = " [" . link_to('vai al testo', $generator->getUrl()) . "]";
                                }
                            } else {
                                $intervento_link = "";
                            }
                            $news_string .= $intervento_link . " sull'atto </p>";
                        }
                        if ($context == CONTEXT_POLITICO) {
                            $news_string .= "<p><strong>Interviene</strong>";
                            if ($generator->getUrl() != NULL) {
                                if (substr_count($generator->getUrl(), '@') > 0) {
                                    $int_urls = explode("@", $generator->getUrl());
                                    $intervento_link = " [vai ai testi";
                                    foreach ($int_urls as $cnt => $int_url) {
                                        if (!preg_match('#^http://#', $int_url)) {
                                            $int_url = sfConfig::get('app_url_sito_camera', 'http://nuovo.camera.it/') . $int_url;
                                        }
                                        $intervento_link .= " " . link_to($cnt + 1, $int_url) . ",";
                                    }
                                    $intervento_link = rtrim($intervento_link, ",");
                                    $intervento_link .= "]";
                                } else {
                                    $intervento_link = " [" . link_to('vai al testo', $generator->getUrl()) . "]";
                                }
                            } else {
                                $intervento_link = "";
                            }
                            $news_string .= $intervento_link . " in ";
                            $news_string .= $generator->getOppSede()->getTipologia() . " ";
                            $news_string .= strtoupper($generator->getOppSede()->getDenominazione()) . " su ";
                            $news_string .= $tipo->getDescrizione() . "</p>";
                            $news_string .= "<p>" . $atto_link . "</p>";
                        }
                    } else {
                        if ($generator_model == 'OppCaricaHasAtto') {
                            $atto = $generator->getOppAtto();
                            $tipo = $atto->getOppTipoAtto();
                            $tipo_firma = $generator->getTipo();
                            switch ($tipo_firma) {
                                case "P":
                                    $tipo_firma = 'presenta';
                                    break;
                                case "C":
                                    $tipo_firma = 'firma';
                                    break;
                                case "R":
                                    $tipo_firma = '&egrave; relatore';
                                    break;
                            }
                            $atto_link = link_to_in_mail(troncaTesto(Text::denominazioneAtto($atto, 'list', true), 200), 'atto/index?id=' . $atto->getId(), array('title' => $atto->getTitolo()));
                            if ($context == CONTEXT_POLITICO) {
                                $news_string .= '<p><strong>' . ucfirst($tipo_firma) . "</strong> ";
                            } else {
                                $news_string .= '<p>' . $politico_link . " <strong>" . $tipo_firma . "</strong> ";
                            }
                            if ($context != CONTEXT_ATTO) {
                                $news_string .= $tipo->getDescrizione() . "</p>";
                                $news_string .= '<p>' . $atto_link . '</p>';
                            } else {
                                if ($tipo_firma == '&egrave; relatore') {
                                    $news_string .= "dell'atto</p>";
                                } else {
                                    $news_string .= "l'atto</p>";
                                }
                            }
                        } else {
                            if ($generator_model == 'OppCaricaHasEmendamento') {
                                $emendamento = $generator->getOppEmendamento();
                                $tipo_firma = $generator->getTipo();
                                switch ($tipo_firma) {
                                    case "P":
                                        $tipo_firma = 'presenta';
                                        break;
                                    case "C":
                                        $tipo_firma = 'firma';
                                        break;
                                    case "R":
                                        $tipo_firma = '&egrave; relatore';
                                        break;
                                }
                                $news_string .= "<p>";
                                if ($context == CONTEXT_POLITICO) {
                                    $news_string .= '<strong>' . ucfirst($tipo_firma) . "</strong> ";
                                } else {
                                    $news_string .= $politico_link . " <strong>" . $tipo_firma . "</strong> ";
                                }
                                if ($tipo_firma == '&egrave; relatore') {
                                    $news_string .= "dell'emendamento";
                                } else {
                                    $news_string .= "l'emendamento";
                                }
                                $news_string .= ' "' . link_to_in_mail($emendamento->getTitoloCompleto(), '@singolo_emendamento?id=' . $emendamento->getId()) . '"';
                                if ($context != CONTEXT_ATTO) {
                                    $atto = $emendamento->getAttoPortante();
                                    // tipo di atto e genere per gli articoli e la desinenza
                                    $tipo = $atto->getOppTipoAtto();
                                    if (in_array($tipo->getId(), array(1, 10, 11, 12, 13, 15, 16, 17))) {
                                        $gender = 'm';
                                    } else {
                                        $gender = 'f';
                                    }
                                    $news_string .= " riferito " . ($gender == 'm' ? 'al ' : 'alla ');
                                    $news_string .= $atto->getOppTipoAtto()->getDescrizione() . " ";
                                    $news_string .= link_to_in_mail(troncaTesto(Text::denominazioneAtto($atto, 'list'), 200), 'atto/index?id=' . $atto->getId());
                                }
                            } else {
                                $news_string .= $generator_model;
                            }
                        }
                    }
                }
            }
        } else {
            if ($related_monitorable_model == 'OppAtto') {
                // fetch dell'atto
                $c = new Criteria();
                $c->add(OppAttoPeer::ID, $news->getRelatedMonitorableId());
                $atti = OppAttoPeer::doSelectJoinOppTipoAtto($c);
                // detect a void query
                if (count($atti) == 0) {
                    return 'empty OppAtto:' . $news->getRelatedMonitorableId();
                }
                $atto = $atti[0];
                // tipo di atto e genere per gli articoli e la desinenza
                $tipo = $atto->getOppTipoAtto();
                if (in_array($tipo->getId(), array(1, 10, 11, 12, 13, 15, 16, 17))) {
                    $gender = 'm';
                } else {
                    $gender = 'f';
                }
                // link all'atto
                $atto_link = link_to_in_mail(troncaTesto(Text::denominazioneAtto($atto, 'list', true), 200), 'atto/index?id=' . $atto->getId(), array('title' => $atto->getTitolo(true)));
                // presentazione o passaggio di stato
                if ($generator_model == 'OppAtto') {
                    if ($tipo->getId() == 1 && $news->getSucc() !== null) {
                        // passaggio di stato (cambio ramo?)
                        // fetch dell'oggetto succ
                        $succ_atto = OppAttoPeer::retrieveByPK($news->getSucc());
                        $succ_atto_link = link_to_in_mail($succ_atto->getRamo() . "." . $succ_atto->getNumFase(), 'atto/index?id=' . $succ_atto->getId(), array('title' => $succ_atto->getTitolo(true)));
                        $this_atto_link = link_to_in_mail($atto->getRamo() . "." . $atto->getNumFase(), 'atto/index?id=' . $atto->getId(), array('title' => $atto->getTitolo(true)));
                        $news_string .= "<p>";
                        $news_string .= "il ddl {$this_atto_link}, approvato ";
                        if ($atto->getRamo() == 'C') {
                            $news_string .= "alla Camera, ";
                        } else {
                            $news_string .= "al Senato, ";
                        }
                        $news_string .= "<strong>&egrave; ora approdato ";
                        if ($succ_atto->getRamo() == 'C') {
                            $news_string .= "alla Camera</strong> ";
                        } else {
                            $news_string .= "al Senato</strong> ";
                        }
                        $news_string .= "come {$succ_atto_link}.";
                        $news_string .= "</p>";
                    } else {
                        // presentazione atto
                        switch ($tipo_atto = $tipo->getId()) {
                            case 13:
                                $news_string .= "<p>Comunicato del governo: ";
                                $news_string .= $atto_link . "</p>";
                                break;
                            case 14:
                                $news_string .= "<p>";
                                $news_string .= $news->getRamoVotazione() == 'C' ? 'Camera -  ' : 'Senato - ';
                                $news_string .= "<strong>Svolta</strong> audizione ";
                                $news_string .= $atto_link . "</p>";
                                break;
                            default:
                                $news_string .= "<p>";
                                $news_string .= $news->getRamoVotazione() == 'C' ? 'Camera -  ' : 'Senato - ';
                                $news_string .= "<strong>Presentat" . ($gender == 'm' ? 'o' : 'a') . "</strong> ";
                                if ($context != 0) {
                                    $news_string .= $tipo->getDescrizione() . "</p>";
                                    $news_string .= "<p>" . $atto_link . "</p>";
                                } else {
                                    $news_string .= "</p>";
                                }
                                break;
                        }
                    }
                } else {
                    if ($generator_model == 'OppIntervento') {
                        $politico = $generator->getOppCarica()->getOppPolitico();
                        $politico_link = link_to_in_mail($politico, '@parlamentare?' . $politico->getUrlParams(), array('title' => 'Vai alla scheda del politico'));
                        $news_string .= "<p>" . $politico_link . " <strong>interviene</strong>";
                        if ($generator->getUrl() != NULL) {
                            if (substr_count($generator->getUrl(), '@') > 0) {
                                $int_urls = explode("@", $generator->getUrl());
                                $intervento_link = " [vai ai testi";
                                foreach ($int_urls as $cnt => $int_url) {
                                    if (!preg_match('#^http://#', $int_url)) {
                                        $int_url = sfConfig::get('app_url_sito_camera', 'http://nuovo.camera.it/') . $int_url;
                                    }
                                    $intervento_link .= " " . link_to_in_mail($cnt + 1, $int_url) . ",";
                                }
                                $intervento_link = rtrim($intervento_link, ",");
                                $intervento_link .= "]";
                            } else {
                                $intervento_link = " [" . link_to_in_mail('vai al testo', $generator->getUrl()) . "]";
                            }
                        } else {
                            $intervento_link = "";
                        }
                        $news_string .= $intervento_link . " in ";
                        if ($generator->getOppSede()->getId() != 35 && $generator->getOppSede()->getId() != 36) {
                            $news_string .= $generator->getOppSede()->getTipologia() . " ";
                        }
                        $news_string .= strtoupper($generator->getOppSede()->getDenominazione());
                        $news_string .= $news->getRamoVotazione() == 'C' ? ' alla Camera su' : ' al Senato su';
                        $news_string .= " " . $tipo->getDescrizione() . "</p>";
                        $news_string .= '<p>' . $atto_link . '</p>';
                    } else {
                        if ($generator_model == 'OppCaricaHasAtto') {
                            $tipo_firma = $generator->getTipo();
                            switch ($tipo_firma) {
                                case "P":
                                    $tipo_firma = 'presentato';
                                    break;
                                case "C":
                                    $tipo_firma = 'firmato';
                                    break;
                                case "R":
                                    $tipo_firma = '&egrave; relatore';
                                    break;
                            }
                            $politico = $generator->getOppCarica()->getOppPolitico();
                            $politico_link = link_to_in_mail($politico, '@parlamentare?' . $politico->getUrlParams(), array('title' => 'Vai alla scheda del politico'));
                            if ($tipo_firma != '&egrave; relatore') {
                                $news_string .= "<p>";
                                $news_string .= $politico_link;
                                $news_string .= " <strong>ha " . $tipo_firma . "</strong> ";
                                $news_string .= $tipo->getDescrizione() . "</p>";
                                $news_string .= '<p>' . $atto_link . '</p>';
                            }
                        } else {
                            if ($generator_model == 'OppAttoHasSede') {
                                $news_string .= "<p>";
                                $news_string .= $news->getRamoVotazione() == 'C' ? 'Camera -  ' : 'Senato - ';
                                $news_string .= "<strong>&egrave; all'esame</strong> in ";
                                $news_string .= $generator->getOppSede()->getTipologia() . " ";
                                $news_string .= content_tag('b', strtoupper($generator->getOppSede()->getDenominazione()));
                                if ($context != 0) {
                                    $news_string .= " " . $tipo->getDescrizione() . "</p>";
                                    $news_string .= "<p>" . $atto_link . "</p>";
                                } else {
                                    $news_string .= "</p>";
                                }
                            } else {
                                if ($generator_model == 'OppVotazioneHasAtto') {
                                    $news_string .= "<p>";
                                    $news_string .= $news->getRamoVotazione() == 'C' ? 'Camera -  ' : 'Senato - ';
                                    if ($news->getPriority() == 1) {
                                        $news_string .= link_to(' <strong>si &egrave; svolta la votazione finale</strong>', '@votazione?' . $generator->getOppVotazione()->getUrlParams());
                                    } else {
                                        $news_string .= " si &egrave; svolta la votazione per " . link_to($generator->getOppVotazione()->getTitolo(), '@votazione?' . $generator->getOppVotazione()->getUrlParams());
                                    }
                                    if ($context != 0) {
                                        $news_string .= " relativa a " . $tipo->getDescrizione() . "</p>";
                                        $news_string .= "<p>" . $atto_link . "</p>";
                                    } else {
                                        $news_string .= "</p>";
                                    }
                                } else {
                                    if ($generator_model == 'OppAttoHasIter') {
                                        $news_string .= "<p>";
                                        $news_string .= $news->getRamoVotazione() == 'C' ? 'Camera -  ' : 'Senato - ';
                                        $news_string .= content_tag('b', news_text_for_iter($generator->getOppIter()->getId(), $gender));
                                        $news_string .= articolo($tipo->getId()) . $tipo->getDescrizione() . "</p>";
                                        if ($context != CONTEXT_ATTO) {
                                            $news_string .= "<p>" . $atto_link . "</p>";
                                        } else {
                                            $news_string .= "";
                                        }
                                    } else {
                                        if ($generator_model == 'Tagging') {
                                            $news_string .= "<p>" . articolo($tipo->getId());
                                            $news_string .= $tipo->getDescrizione() . " ";
                                            $news_string .= $atto_link . " ";
                                            $news_string .= "presentat" . ($gender == 'm' ? 'o' : 'a') . " ";
                                            if ($news->getRamoVotazione() == 'C') {
                                                $news_string .= ' alla Camera ';
                                            } else {
                                                if ($news->getRamoVotazione() == 'S') {
                                                    $news_string .= ' al Senato ';
                                                }
                                            }
                                            $news_string .= "il " . $news->getDataPresentazioneAtto('d/m/Y') . " ";
                                            $news_string .= "&egrave; stat" . ($gender == 'm' ? 'o' : 'a') . " <b>aggiunt" . ($gender == 'm' ? 'o' : 'a') . " al monitoraggio dell'argomento ";
                                            $news_string .= $generator->getTag()->getTripleValue() . "</b></p>";
                                        } else {
                                            if ($generator_model == 'OppDocumento') {
                                                $news_string .= "<p>";
                                                $news_string .= $news->getRamoVotazione() == 'C' ? 'Camera -  ' : 'Senato - ';
                                                $news_string .= "E' disponibile il <strong>nuovo documento</strong> ";
                                                $news_string .= '"' . link_to($generator->getTitolo(), 'atto/documento?id=' . $generator->getId()) . '"';
                                                if ($context != CONTEXT_ATTO) {
                                                    $news_string .= " riferito " . ($gender == 'm' ? 'al ' : 'alla ');
                                                    $news_string .= $generator->getOppAtto()->getOppTipoAtto()->getDescrizione() . "</p>";
                                                    $news_string .= "<p>" . link_to($generator->getOppAtto()->getRamo() . "." . $generator->getOppAtto()->getNumfase() . " " . troncaTesto(Text::denominazioneAtto($generator->getOppAtto(), 'list'), 200), 'atto/index?id=' . $generator->getOppAtto()->getId()) . "</p>";
                                                }
                                            } else {
                                                if ($generator_model == 'OppAttoHasEmendamento') {
                                                    $emendamento = $generator->getOppEmendamento();
                                                    $news_string .= "<p>";
                                                    $news_string .= $news->getRamoVotazione() == 'C' ? 'Camera -  ' : 'Senato - ';
                                                    $news_string .= "E' stato presentato  ";
                                                    $news_string .= " in " . $emendamento->getOppSede()->getDenominazione();
                                                    $news_string .= " l'<b>emendamento</b> ";
                                                    $news_string .= '"' . link_to_in_mail($emendamento->getTitoloCompleto(), '@singolo_emendamento?id=' . $emendamento->getId()) . '"';
                                                    if ($context != CONTEXT_ATTO) {
                                                        $news_string .= " riferito " . ($gender == 'm' ? 'al ' : 'alla ');
                                                        $news_string .= $generator->getOppAtto()->getOppTipoAtto()->getDescrizione() . " ";
                                                        $news_string .= link_to_in_mail(troncaTesto(Text::denominazioneAtto($generator->getOppAtto(), 'list'), 200), 'atto/index?id=' . $generator->getOppAtto()->getId());
                                                    }
                                                    $news_string .= "</p>";
                                                } else {
                                                    if ($generator_model == 'OppEmendamentoHasIter') {
                                                        $emendamento = $generator->getOppEmendamento();
                                                        $atti = $emendamento->getOppAttoHasEmendamentosJoinOppAtto();
                                                        $news_string .= "<p>";
                                                        $news_string .= $news->getRamoVotazione() == 'C' ? 'Camera:  ' : 'Senato: ';
                                                        $news_string .= $emendamento->getOppSede()->getDenominazione() . " - ";
                                                        $news_string .= "L'<b>emendamento</b> ";
                                                        $news_string .= '"' . link_to_in_mail($emendamento->getTitoloCompleto(), '@singolo_emendamento?id=' . $emendamento->getId()) . '"';
                                                        if ($context != CONTEXT_ATTO) {
                                                            $news_string .= " riferito " . ($gender == 'm' ? 'al ' : 'alla ');
                                                            $news_string .= $atto_link;
                                                        }
                                                        $news_string .= " &egrave; stato " . content_tag('b', strtolower($generator->getOppEmIter()->getFase()));
                                                    } else {
                                                        if ($generator_model == 'OppEsitoSeduta') {
                                                            $sede = $generator->getOppSede();
                                                            $news_string .= "<p>";
                                                            $news_string .= $news->getRamoVotazione() == 'C' ? 'Camera - ' : 'Senato - ';
                                                            $news_string .= "<strong>Si &egrave; svolta una seduta</strong> in ";
                                                            if ($sede->getTipologia() != 'Assemblea') {
                                                                $news_string .= $sede->getTipologia() . ' ';
                                                            }
                                                            $news_string .= $sede->getDenominazione() . ' ';
                                                            if ($generator->getTipologia() != 'Assemblea') {
                                                                $news_string .= " (" . $generator->getTipologia() . ") ";
                                                            }
                                                            $news_string .= "<strong><a class='external' target='_blank' href=" . $generator->getUrl() . ">";
                                                            $news_string .= $generator->getEsito();
                                                            $news_string .= "</a></strong>";
                                                            if ($context != CONTEXT_ATTO) {
                                                                $news_string .= " per il disegno di legge<br/>";
                                                                $news_string .= $atto_link;
                                                            }
                                                            $news_string .= "</p>";
                                                        } else {
                                                            $news_string .= $generator_model;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            } else {
                if ($related_monitorable_model == 'Tag') {
                    // tag fetch
                    $tag = TagPeer::retrieveByPK($news->getRelatedMonitorableId());
                    if ($generator_model == 'Tagging') {
                        $tagging_pks = array_values(unserialize($news->getGeneratorPrimaryKeys()));
                        $tagging_id = $tagging_pks[0];
                        $tagging = TaggingPeer::retrieveByPK($tagging_id);
                        $taggable_model = $tagging->getTaggableModel();
                        $taggable_id = $tagging->getTaggableId();
                        $tagged_obj = call_user_func_array(array($taggable_model . 'Peer', 'retrieveByPK'), array($taggable_id));
                        if ($taggable_model == 'OppAtto') {
                            // the tagged object is an atto
                            $atto = $tagged_obj;
                            // tipo di atto e genere per gli articoli e la desinenza
                            $tipo = $atto->getOppTipoAtto();
                            if (in_array($tipo->getId(), array(1, 10, 11, 12, 13, 15, 16, 17))) {
                                $gender = 'm';
                            } else {
                                $gender = 'f';
                            }
                            $atto_link = link_to_in_mail(troncaTesto(Text::denominazioneAtto($atto, 'list', true), 200), 'atto/index?id=' . $atto->getId(), array('title' => $atto->getTitolo()));
                            $news_string .= "<p>" . articolo($tipo->getId());
                            $news_string .= $tipo->getDescrizione() . " ";
                            $news_string .= $atto_link . " ";
                            $news_string .= "presentat" . ($gender == 'm' ? 'o' : 'a') . " ";
                            if ($atto->getRamo() == 'C') {
                                $news_string .= ' alla Camera ';
                            } else {
                                if ($atto->getRamo() == 'S') {
                                    $news_string .= ' al Senato ';
                                }
                            }
                            $news_string .= "il " . $atto->getDataPres('d/m/Y') . " ";
                            $news_string .= "&egrave; stat" . ($gender == 'm' ? 'o' : 'a') . " <b>aggiunt" . ($gender == 'm' ? 'o' : 'a') . " al monitoraggio dell'argomento ";
                            if ($context != CONTEXT_TAG) {
                                $news_string .= $generator->getTag()->getTripleValue();
                            }
                            $news_string .= "</b></p>";
                        }
                        if ($taggable_model == 'OppEmendamento') {
                            $emendamento = $tagged_obj;
                            $emendamento_link = link_to_in_mail($emendamento->getTitoloCompleto(), '@singolo_emendamento?id=' . $emendamento->getId());
                            $news_string .= "<p>";
                            $relatedAttos = $emendamento->getOppAttoHasEmendamentosJoinOppAtto();
                            $ddl_em = "";
                            if (count($relatedAttos) > 0) {
                                if (count($relatedAttos) == 1) {
                                    $ddl_em = " relativo al ddl ";
                                } else {
                                    $ddl_em = " relativo ai ddl ";
                                }
                                foreach ($relatedAttos as $relatedAtto) {
                                    $atto = $relatedAtto->getOppAtto();
                                    $ddl_em = $ddl_em . " " . link_to($atto->getRamo() . '.' . $atto->getNumfase(), '@singolo_atto?id=' . $atto->getId(), array('title' => $atto->getTitolo()));
                                }
                            }
                            $news_string .= "l'emendamento " . $emendamento_link . ", presentato il " . $emendamento->getDataPres('d/m/Y') . ", " . $ddl_em . " &egrave; stato <b>aggiunto al monitoraggio dell'argomento ";
                            if ($context != CONTEXT_TAG) {
                                $news_string .= $generator->getTag()->getTripleValue();
                            }
                            $news_string .= "</b></p>";
                        }
                    }
                }
            }
        }
    } else {
        sfLogger::getInstance()->info('xxx: errore per: ' . $generator_model . ': chiavi: ' . $news->getGeneratorPrimaryKeys());
    }
    if ($in_mail) {
        $sf_site_url = sfConfig::get('sf_site_url', 'openparlamento');
        $news_string = str_replace('./symfony', $sf_site_url, $news_string);
        # per il test e per sicurezza
        $news_string = str_replace('a href=', 'a style="color: #339;" href=', $news_string);
    }
    return $news_string;
}
 public function executeWidget()
 {
     function tronca($testo, $caratteri)
     {
         if (strlen($testo) <= $caratteri) {
             return $testo;
         }
         $nuovo = wordwrap($testo, $caratteri, "|");
         $nuovotesto = explode("|", $nuovo);
         return $nuovotesto[0] . "...";
     }
     $this->bg_color = $this->getRequestParameter('bg_color');
     $this->text_color = $this->getRequestParameter('textcolor');
     $this->pos = $this->getRequestParameter('pos');
     // $this->border_color=retrieveByPk($this->getRequestParameter('border_color'));
     $atto = OppAttoPeer::retrieveByPk($this->getRequestParameter('bill_id'));
     $this->id = $atto->getId();
     $this->tipo = $atto->getOppTipoAtto()->getDescrizione();
     if (substr_count($this->tipo, 'interrogazione') > 0) {
         $this->tipo = 'interrrogazione';
     }
     if (substr_count($this->tipo, 'risoluzione') > 0) {
         $this->tipo = 'risoluzione';
     }
     if (substr_count($this->tipo, 'odg') > 0) {
         $this->tipo = 'ordine del giorno';
     }
     if (substr_count($this->tipo, 'dlgs') > 0) {
         $this->tipo = 'dlgs';
     }
     $this->ramo = $atto->getRamo();
     $this->numfase = $atto->getNumfase();
     $this->datapres = $atto->getDataPres();
     $this->status = $atto->getStatoFase();
     $this->status_data = $atto->getStatoLastDate();
     $this->fav = $atto->getUtFav();
     $this->contr = $atto->getUtContr();
     $this->monitor = $atto->getNMonitoringUsers();
     $this->commenti = $atto->getNbPublicComments();
     $titolo = "";
     $titolos = explode(" ", Text::denominazioneAtto($atto, 'list'));
     for ($x = 1; $x < count($titolos); $x++) {
         $titolo = $titolo . " " . $titolos[$x];
     }
     $this->titolo = tronca(trim($titolo), 180);
     $f_signers = OppAttoPeer::doSelectPrimiFirmatari($atto->getId());
     if (count($f_signers) > 0) {
         $this->firmatario = OppPoliticoPeer::retrieveByPk(key($f_signers));
     }
 }
        ?>
" id="carica-<?php 
        echo $carica_id;
        ?>
">
                <?php 
        $tr_class = $tr_class == 'even' ? 'odd' : 'even';
        ?>
                  <td><?php 
        echo ++$cnt;
        ?>
</td>
                  <th scope="row">  
                    <p class="politician-id">
                      <?php 
        echo image_tag(OppPoliticoPeer::getThumbUrl($politico['politico_id']), array('width' => '40', 'height' => '53'));
        ?>
                      <?php 
        $fullName = $politico['nome'] . " " . $politico['cognome'];
        echo link_to($fullName . " (" . $politico['acronimo'] . ")", '@parlamentare?id=' . $politico['politico_id'] . '&slug=' . slugify($fullName), array('class' => 'folk2'));
        ?>
                    </p>
                  </th>
                  <td>
                    <?php 
        echo $politico['circoscrizione'];
        ?>
                  </td>
                  <td>
                    <?php 
        foreach ($cariche_interne = OppCaricaInternaPeer::getPermanentiAttuali($carica_id) as $c => $carica_interna) {
%)|da 10 a 15 anni di incarichi: <?php 
    echo $sg[2] . ' (' . round($sg[2] * 100 / array_sum($sg), 2);
    ?>
%)|da 5 a 10 anni di incarichi: <?php 
    echo $sg[1] . ' (' . round($sg[1] * 100 / array_sum($sg), 2);
    ?>
%)|con+meno di 5 anni di incarichi: <?php 
    echo $sg[0] . ' (' . round($sg[0] * 100 / array_sum($sg), 2);
    ?>
%)&chd=t:<?php 
    echo "{$sg['4']},{$sg['3']},{$sg['2']},{$sg['1']},{$sg['0']}";
    ?>
&chco=FF0000,FFFF10">
	    <p>
	    Con maggior anni di incarichi: <?php 
    echo link_to(OppPoliticoPeer::retrieveByPk($max_gruppi[$k][0])->getNome() . " " . OppPoliticoPeer::retrieveByPk($max_gruppi[$k][0])->getCognome(), "@parlamentare?" . OppPoliticoPeer::retrieveByPk($max_gruppi[$k][0])->getUrlParams()) . ", " . $max_gruppi[$k][1];
    ?>
.
	    </p>
	  <?php 
}
?>
		
	</div>
</div>

<?php 
slot('breadcrumbs');
?>
  <?php 
echo link_to("home", "@homepage");
 public function _get_most_something($crit, $tipo_carica, $field, $limit = null)
 {
     sfLoader::loadHelpers(array('Url', 'Tag', 'Slugger'));
     // if limit was not passed, then get it from config file
     if (is_null($limit)) {
         $limit = sfConfig::get('app_api_classifiche_limit', 5);
     }
     $c = clone $crit;
     $c->add(OppCaricaPeer::TIPO_CARICA_ID, $tipo_carica);
     $c->addDescendingOrderByColumn($field);
     $c->setLimit($limit);
     $rs = OppCaricaPeer::doSelectRS($c);
     $results = array();
     while ($rs->next()) {
         $record = array();
         $record['img_src'] = OppPoliticoPeer::getThumbUrl($rs->getInt(2));
         $record['nome'] = $rs->getString(3) . ' ' . $rs->getString(4);
         $record['nome_link'] = url_for('@parlamentare?id=' . $rs->getInt(2) . '&slug=' . slugify($record['nome']));
         $record['gruppi'] = '';
         $gruppi = OppCaricaHasGruppoPeer::doSelectGruppiPerCarica($rs->getInt(1));
         foreach ($gruppi as $nome => $gruppo) {
             if (!$gruppo['data_fine']) {
                 $record['gruppi'] = " ({$nome})";
             }
         }
         switch ($field) {
             case OppCaricaPeer::PRESENZE:
                 $num_votazioni = $rs->getInt(6) + $rs->getInt(7) + $rs->getInt(8);
                 $record['descr'] = "%s% - %d su %d";
                 $record['values'] = array(number_format($rs->getInt(6) * 100 / $num_votazioni, 2), $rs->getInt(6), $num_votazioni);
                 break;
             case OppCaricaPeer::ASSENZE:
                 $num_votazioni = $rs->getInt(6) + $rs->getInt(7) + $rs->getInt(8);
                 $record['descr'] = "%s% - %d su %d";
                 $record['values'] = array(number_format($rs->getInt(7) * 100 / $num_votazioni, 2), $rs->getInt(7), $num_votazioni);
                 break;
             case OppCaricaPeer::INDICE:
                 $record['descr'] = "indice di attivit&agrave;: %5.2f";
                 $record['values'] = array($rs->getFloat(9));
                 break;
             case OppPoliticoPeer::N_MONITORING_USERS:
                 $record['descr'] = "&egrave; monitorato da %d utenti";
                 $record['values'] = array($rs->getInt(13));
                 break;
             case OppCaricaPeer::RIBELLE:
                 $record['descr'] = "voti diversi dal suo gruppo: %d su %d";
                 $record['values'] = array($rs->getInt(12), $rs->getInt(6));
                 break;
         }
         $results[] = $record;
     }
     return $results;
 }
<?php

define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..'));
define('SF_APP', 'fe');
define('SF_ENVIRONMENT', 'dev');
define('SF_DEBUG', true);
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
sfContext::getInstance();
print "Fetching data... \n";
$xml = simplexml_load_file('http://www.openpolis.it/api/senatori');
foreach ($xml->charges->charge as $charge) {
    $politico = OppPoliticoPeer::RetrieveByPk($charge->politicianid);
    if ($politico == null) {
        $xml = simplexml_load_file('http://www.openpolis.it/api/politician/id/' . $charge->politicianid);
        $nome = $xml->politician->firstname;
        $cognome = $xml->politician->lastname;
        echo "{$nome} {$cognome} \n";
        $politico = new OppPolitico();
        $politico->setId($charge->politicianid);
        $politico->setNome($nome);
        $politico->setCognome($cognome);
        $politico->save();
    }
    $carica = new OppCarica();
    $carica->setId($charge->id);
    $carica->setPoliticoId($charge->politicianid);
    $carica->setCarica($charge->chargetype);
    $carica->setDataInizio($charge->datestart);
    $carica->setGruppo($charge->group);
    $carica->setLegislatura(16);
    $carica->setCircoscrizione($charge->constituency);
echo include_component('parlamentare', 'monitoringalso', array('item' => $parlamentare));
?>

          </div>
        
    </div>
</div>

<?php 
if ($carica) {
    ?>
<div class="row">
    <div class="sixcol">
        
        <?php 
    if ($carica->getDataInizio('Y-m-d') > date("Y-m-d", strtotime('today - 365 days')) || in_array($carica->getPoliticoId(), array_merge(OppPoliticoPeer::getPresidentiCamereIds(), OppPoliticoPeer::getMembriGovernoIds()))) {
        ?>
          <!-- il box non viene proprio visualizzato -->
        <?php 
    } else {
        ?>

        <!-- INDICE DI PRODUTTIVITA' -->
        <h5 class="subsection-alt" style="margin-top:0px;">
          Nuovo indice di produttività parlamentare <?php 
        echo image_tag('/images/ico-new.png');
        ?>
        </h5>

            <p class="tools-container"><a class="ico-help" href="#">come viene calcolato</a></p>
            <div style="display: none;" class="help-box float-container">
            $k = explode("-", $k);
            ?>
      <tr class="<?php 
            echo $tr_class;
            ?>
">
      <?php 
            $tr_class = $tr_class == 'even' ? 'odd' : 'even';
            ?>
        <th scope="row">  
        <p class="politician-id">
            <?php 
            $politico = OppCaricaPeer::retrieveByPk($k[0])->getOppPolitico();
            ?>
          <?php 
            echo image_tag(OppPoliticoPeer::getThumbUrl($politico->getId()), array('width' => '40', 'height' => '53'));
            ?>
                               <?php 
            echo link_to((OppSedePeer::retrieveByPk($sede_id)->getRamo() == 'CS' ? OppCaricaPeer::retrieveByPk($k[0])->getTipoCaricaId() == 1 ? 'On. ' : 'Sen. ' : '') . $politico->getNome() . " " . $politico->getCognome(), '@parlamentare?' . $politico->getUrlParams());
            ?>
        <?php 
            echo $k[1] != "componente" ? " (" . ucfirst($k[1]) . ")" : "";
            ?>
        </p>
        </th>
        <td>
          <?php 
            echo OppGruppoPeer::retrieveByPk($g)->getAcronimo();
            ?>
        </td>
        <td>
 public function executeAttiInEvidenza()
 {
     $namespace = $this->getRequestParameter('namespace');
     setlocale(LC_TIME, 'it_IT');
     sfLoader::loadHelpers(array('Tag', 'Url', 'DeppNews'));
     $feed = new sfRss2ExtendedFeed();
     $feed->initialize(array('title' => 'Atti in evidenza', 'link' => url_for('@homepage', true), 'feedUrl' => $this->getRequest()->getURI(), 'siteUrl' => 'http://' . sfConfig::get('sf_site_url'), 'image' => 'http://' . sfConfig::get('sf_site_url') . '/images/logo-openparlamento.png', 'language' => 'it', 'authorEmail' => '*****@*****.**', 'authorName' => 'Openparlamento', 'description' => "Openparlamento.it - il progetto Openpolis per la trasparenza del Parlamento", 'sy_updatePeriod' => 'daily', 'sy_updateFrequency' => '1', 'sy_updateBase' => '2000-01-01T12:00+00:00'));
     $atti = OppAttoPeer::getAttiInEvidenza($namespace);
     foreach ($atti as $atto) {
         $description = $atto->getOppTipoAtto()->getDescrizione() . ($atto->getRamo() == 'C' ? ' alla Camera' : ' al Senato');
         $f_signers = OppAttoPeer::doSelectPrimiFirmatari($atto->getId());
         if (count($f_signers) > 0) {
             $c = new Criteria();
             $c->add(OppPoliticoPeer::ID, key($f_signers));
             $f_signer = OppPoliticoPeer::doSelectOne($c);
             $description .= ' di ' . $f_signer->getCognome() . (count($f_signers) > 1 ? ' e altri' : '');
         }
         $description .= ", presentato il " . $atto->getDataPres('d/M/Y');
         $item = new sfRss2ExtendedItem();
         $aggiuntivo_only = true;
         $item->initialize(array('title' => Text::denominazioneAtto($atto, 'list', $aggiuntivo_only), 'link' => url_for('@singolo_atto?id=' . $atto->getId(), true), 'permalink' => url_for('@singolo_atto?id=' . $atto->getId(), true), 'pubDate' => $atto->getStatoLastDate('U') ? $atto->getStatoLastDate('U') : $atto->getDataPres('U'), 'uniqueId' => $atto->getId(), 'description' => $description, 'authorEmail' => '*****@*****.**', 'authorName' => 'Openparlamento'));
         $feed->addItem($item);
     }
     $this->_send_output($feed);
     return sfView::NONE;
 }
	            <?php 
    $c_signers = OppEmendamentoPeer::doSelectCoFirmatari($emendamento->getId());
    ?>
	            <?php 
    if (count($c_signers) > 0) {
        ?>
	            <span style="margin-bottom: 0px; font-size:13px; font-weight:normal">e altri <?php 
        echo count($c_signers);
        ?>
 cofirmatari ... [ <a class="btn-open action" href="#" style="display: inline;">apri</a> <a style="display: none;" class="btn-close action" href="#">chiudi</a> ]</span>
	              <div style="display: none; line-height:1.2em;font-size:13px; font-weight:normal;" class="more-results float-container">
	              <?php 
        $i = 0;
        foreach ($c_signers as $key => $cf) {
            $i++;
            $pol = OppPoliticoPeer::retrieveByPk($key);
            echo link_to($pol->getNome() . " " . $pol->getCognome(), '@parlamentare?' . $pol->getUrlParams()) . ($i < count($c_signers) ? ', ' : '.');
        }
        ?>
	               </div>

	             <?php 
    }
    ?>


	          </h6></li></ul>                  
	        <?php 
}
?>
예제 #23
0
?>
        
     <?php 
while ($parlamentari->next()) {
    ?>
      <tr class="<?php 
    echo $tr_class;
    ?>
">
      <?php 
    $tr_class = $tr_class == 'even' ? 'odd' : 'even';
    ?>
        <th scope="row">
          <p class="politician-id">
            <?php 
    echo image_tag('/images/ico-type-politico-portrait.png', array('width' => '40', 'height' => '53', 'highsrc' => OppPoliticoPeer::getThumbUrl($parlamentari->getInt(2))));
    ?>
	
            <?php 
    use_helper('Slugger');
    $slugParlamentare = slugify($parlamentari->getString(3) . ' ' . $parlamentari->getString(4));
    echo link_to($parlamentari->getString(3) . ' ' . $parlamentari->getString(4), '@parlamentare?id=' . $parlamentari->getInt(2) . '&slug=' . $slugParlamentare);
    ?>
            <?php 
    $gruppi = OppCaricaHasGruppoPeer::doSelectGruppiPerCarica($parlamentari->getInt(1));
    ?>
  	
	        <?php 
    foreach ($gruppi as $nome => $gruppo) {
        ?>
	          <?php 
">
   <?php 
    $tr_class = $tr_class == 'even' ? 'odd' : 'even';
    ?>
 
   <th scope="row">
   <h3 class="position-<?php 
    echo $color;
    ?>
"><?php 
    echo $i;
    ?>
</h3>
   <p class="politician-id">
   <?php 
    echo image_tag(OppPoliticoPeer::getThumbUrl($parlamentari->getInt(2)), array('width' => '40', 'height' => '53'));
    ?>
	
    <?php 
    use_helper('Slugger');
    $slugParlamentare = slugify($parlamentari->getString(2) . ' ' . $parlamentari->getString(3));
    echo link_to($parlamentari->getString(3) . ' ' . $parlamentari->getString(4), '@parlamentare?id=' . $parlamentari->getInt(2) . '&slug=' . $slugParlamentare);
    ?>
    <?php 
    $gruppi = OppCaricaHasGruppoPeer::doSelectGruppiPerCarica($parlamentari->getInt(1));
    ?>
  	
    <?php 
    foreach ($gruppi as $nome => $gruppo) {
        ?>
	<?php 
예제 #25
0
                $info_array = explode('*', $primi_firmatari[$ind]);
                ?>
			  <?php 
                echo link_to(image_tag(OppPoliticoPeer::getThumbUrl($ind), array('width' => '40')) . $info_array[1], '@parlamentare_old?id=' . $ind);
                ?>
			  <?php 
                $primi_index++;
                ?>
			<?php 
            }
            ?>
  	
          </td>
		  <td>
		    <?php 
            echo link_to(image_tag(OppPoliticoPeer::getThumbUrl($id), array('width' => '40')) . $relatore, '@parlamentare_old?id=' . $id);
            ?>
	
		  </td>
		</tr>  	       
	  <?php 
        }
        ?>
		  	        
    <?php 
    }
    ?>
  </tbody>
</table>
<?php 
}
예제 #26
0
    echo $lancio->getRamo() == 'C' ? ' alla Camera' : ' al Senato';
    ?>
	<?php 
    $f_signers = OppAttoPeer::doSelectPrimiFirmatari($lancio->getId());
    ?>
	<?php 
    if (count($f_signers) > 0) {
        ?>
		<?php 
        $c = new Criteria();
        ?>
		<?php 
        $c->add(OppPoliticoPeer::ID, key($f_signers), Criteria::EQUAL);
        ?>
		<?php 
        $f_signer = OppPoliticoPeer::doSelectOne($c);
        ?>
		<?php 
        echo ' di ' . $f_signer->getCognome() . (count($f_signers) > 1 ? ' e altri' : '');
        ?>
	<?php 
    }
    ?>
   
	</p>			
	<div class="user-votes"><span class="green thumb-up"><?php 
    echo $lancio->getUtFav();
    ?>
</span> <span class="red thumb-down"><?php 
    echo $lancio->getUtContr();
    ?>
 $c->addSelectColumn(OppPoliticoPeer::ID);
 $c->addAsColumn('FULLNAME', 'CONCAT_WS(" ", ' . OppPoliticoPeer::COGNOME . ', ' . OppPoliticoPeer::NOME . ')');
 $rs = OppPoliticoPeer::doSelectRS($c);
 $pol_id = 0;
 $k = 0;
 while ($rs->next()) {
     if ($rs->getString(2) == trim($sen->plaintext)) {
         $pol_id = $rs->getInt(1) . "\t";
         $k++;
     }
 }
 if ($pol_id == 0) {
     $cognome = explode(" ", trim($sen->plaintext));
     $c = new Criteria();
     $c->add(OppPoliticoPeer::COGNOME, $cognome[0] . "%", Criteria::LIKE);
     $results = OppPoliticoPeer::doSelect($c);
     if (count($results) > 0) {
         echo "Potrebbe essere:";
         foreach ($results as $result) {
             echo " " . $result->getCognome() . " " . $result->getNome() . " [" . $result->getId() . "]\t";
         }
     } else {
         echo "POLITICO ID NON TROVATO \t";
     }
 } elseif ($k == 1) {
     echo $pol_id . "\t";
 } else {
     echo "TROVATO PIU' DI UN POLITICO \t";
 }
 if ($sen->next_sibling()) {
     if ($sen->next_sibling()->tag == "span") {
?>
   

	      <?php 
echo include_partial('default/listNotice', array('filters' => $filters, 'results' => $n_parlamentari, 'route' => '@parlamentari?ramo=' . $sf_params->get('ramo')));
?>
		
	</div>
	<div class="threecol last"></div>
</div>

<div class="row">
	<div class="twelvecol">
		
		<?php 
include_partial('list', array('parlamentari' => $parlamentari, 'numero_parlamentari' => $numero_parlamentari, 'presidenti_ids' => OppPoliticoPeer::getPresidentiCamereIds(), 'membri_governo_ids' => OppPoliticoPeer::getMembriGovernoIds()));
?>
		
	</div>
</div>


<div class="row">
	
	<div class="twelvecol">
		
		<a name="decaduti"></a>
		<h5 class="subsection">variazioni nella legislatura:</h5>  
		  <?php 
include_partial('list', array('parlamentari' => $parlamentari_decaduti, 'numero_parlamentari' => $numero_parlamentari));
?>
/**
 * Fetch politicians' images from op_openpolis via remote getPolImage API call and store resized versions in the local db
 */
function run_opp_sync_polimages($task, $args)
{
    static $loaded;
    // load application context
    if (!$loaded) {
        _loader();
    }
    if (count($args) > 1) {
        throw new Exception('Uso: opp-sync-polimages [$POL_ID].');
    }
    echo pakeColor::colorize('FEtching politicians... ', array('fg' => 'cyan', 'bold' => true));
    $start_time = microtime(true);
    if (count($args) == 1) {
        $pol_id = $args[0];
        $pol = OppPoliticoPeer::retrieveByPK($pol_id);
        if (!$pol instanceof OppPolitico) {
            throw new Exception('Politico sconosciuto: ' . $pol_id . '.');
        }
        $politicians = array($pol);
    } else {
        $c = new Criteria();
        $politicians = OppPoliticoPeer::doSelect($c);
    }
    foreach ($politicians as $pol) {
        opp_sync_politician_image($pol);
    }
    $total_time = microtime(true) - $start_time;
    echo pakeColor::colorize('All done! ', array('fg' => 'green', 'bold' => true));
    echo 'Processed ';
    echo pakeColor::colorize(count($politicians), array('fg' => 'cyan'));
    echo ' users in ';
    echo pakeColor::colorize(sprintf("%f", $total_time), array('fg' => 'cyan'));
    echo " seconds\n";
}
예제 #30
0
<?php

define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..'));
define('SF_APP', 'fe');
define('SF_ENVIRONMENT', 'dev');
define('SF_DEBUG', true);
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
sfContext::getInstance();
print "Fetching data... \n";
$c = new Criteria();
$parlamentare = OppPoliticoPeer::retrieveByPk(4);
$xml = simplexml_load_file('http://openpolis.depplab.net/api/politician/id/4');
$picture = $xml->politician->image;
$parlamentare->setPicture($picture);
$parlamentare->save();
/*	
foreach ($parlamentari as $parlamentare)
{
  $xml = simplexml_load_file('http://www.openpolis.it/api/politician/id/'.$parlamentare->getOpId());
  $nome = $xml->politician->firstname;
  $cognome = $xml->politician->lastname;
  $politico = new OppPolitico();
  $politico->setId($parlamentare->getOpId());
  $politico->setNome($nome);
  $politico->setCognome($cognome);
  $politico->save();
  echo "$nome $cognome\n";
}
*/
print "done.\n";