コード例 #1
0
$firma = new OppCaricaHasAtto();
$firma->setTipo('P');
$firma->setOppCarica($car);
$firma->setOppAtto($obj);
$firma->setData($obj->getDataPres());
$firma->save();
$pol_related_news = getRelatedNews($pol);
$n_pol_related_news = count($pol_related_news);
$t->ok($n_pol_related_news == 3, 'Three news related to the politician');
dumpNews($t, "news related to the politician", $pol_related_news);
$related_news = getRelatedNews($obj);
$n_related_news = count($related_news);
$t->ok($n_related_news == 5, 'Five news related to the act (no new news)');
dumpNews($t, "news related to the act", $related_news);
$t->diag('Get a site');
$sede = OppSedePeer::retrieveByPK(11);
$t->diag('Add an intervention on the act by the politician');
$int = new OppIntervento();
$int->setData('2008-11-20');
$int->setOppCarica($car);
$int->setOppSede($sede);
$int->setOppAtto($obj);
$int->save();
$pol_related_news = getRelatedNews($pol);
$n_pol_related_news = count($pol_related_news);
$t->ok($n_pol_related_news == 4, 'Four news related to the politician');
dumpNews($t, "news related to the politician", $pol_related_news);
$related_news = getRelatedNews($obj);
$n_related_news = count($related_news);
$t->ok($n_related_news == 7, 'Seven news related to the act (two more, detailed and group)');
dumpNews($t, "news related to the act", $related_news);
コード例 #2
0
/**
 * 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 è 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;
}