예제 #1
0
<?php

$atto = OppAttoPeer::retrieveByPK($result->propel_id);
$tipo_atto = OppTipoAttoPeer::retrieveByPK($result->tipo_atto_id);
?>

<?php 
echo $tipo_atto->getDescrizione();
?>
 - 
<?php 
echo link_to_in_mail(highlight_keywords($atto->getTitoloCompleto(), $term, sfConfig::get('app_lucene_result_highlighter', '<strong class="highlight">%s</strong>')), add_highlight_qs($result->getInternalUri(), $term));
?>
-
presentato il <?php 
echo $atto->getDataPres('d/m/Y');
?>

예제 #2
0
<?php

$documento = OppDocumentoPeer::retrieveByPK($result->propel_id);
$atto = $documento->getOppAtto();
$tipo_atto = $atto->getOppTipoAtto();
?>


<?php 
echo link_to_in_mail(highlight_keywords($tipo_atto->getDescrizione() == 'comunicato del governo' ? sprintf("Comunicato del governo - %s", $atto->getTitolo()) : sprintf("%s", $documento->getTitoloCompleto()), $term, sfConfig::get('app_lucene_result_highlighter', '<strong class="highlight">%s</strong>')), add_highlight_qs($result->getInternalUri(), $term));
?>
 -
presentato il <?php 
echo $atto->getDataPres('d/m/Y');
?>

/**
 * generate the html representation for the given news
 *
 * @param string $news 
 * @return string (html)
 * @author Guglielmo Celata
 */
function community_news_text($news)
{
    $news_string = "";
    // fetch generator model
    $generator_model = $news->getGeneratorModel();
    // fetch related model and object (item)
    $related_model = $news->getRelatedModel();
    $related_id = $news->getRelatedId();
    $item = call_user_func_array($related_model . 'Peer::retrieveByPK', array($related_id));
    if (is_null($item)) {
        return "notizia su oggetto inesistente: ({$related_model}:{$related_id})";
    }
    // build item link
    switch ($related_model) {
        case 'OppPolitico':
            // link al politico
            $item_type = 'il parlamentare';
            $link = link_to_in_mail($item, '@parlamentare?' . $item->getUrlParams(), array('title' => 'Vai alla scheda del politico'));
            break;
        case 'OppDocumento':
            // link al documento
            $link = link_to_in_mail($item->getTitolo(), '@documento?id=' . $related_id, array('title' => $item->getTitolo()));
            $related_atto = OppAttoPeer::retrieveByPK($item->getAttoId());
            // costruzione del link all'atto relativo al documento
            if (in_array($related_atto->getTipoAttoId(), array(1, 3, 4, 5, 6, 10, 11, 14))) {
                $atto_article = 'all\'';
            } elseif (in_array($related_atto->getTipoAttoId(), array(12, 13, 15, 16, 17))) {
                $atto_article = 'al ';
            } else {
                $atto_article = 'alla ';
            }
            $atto_link = $atto_article . $related_atto->getOppTipoAtto()->getDescrizione() . " ";
            $atto_link .= link_to_in_mail(Text::denominazioneAtto($related_atto, 'list', true), 'atto/index?id=' . $related_atto->getId(), array('title' => $related_atto->getTitolo()));
            break;
        case 'OppAtto':
            // link all'atto
            if (in_array($item->getTipoAttoId(), array(1, 10, 11, 12, 13, 15, 16, 17))) {
                $gender = 'm';
            } else {
                $gender = 'f';
            }
            $item_type = articolo($item->getTipoAttoId()) . $item->getOppTipoAtto()->getDescrizione() . " ";
            $link = link_to_in_mail(Text::denominazioneAtto($item, 'list'), 'atto/index?id=' . $related_id, array('title' => $item->getTitolo()));
            break;
        case 'OppVotazione':
            // link alla votazione
            $item_type = 'la votazione';
            $link = link_to_in_mail($item->getTitolo(), '@votazione?' . $item->getUrlParams(), array('title' => 'Vai alla pagina della votazione'));
            break;
        case 'OppEmendamento':
            // link all'emendamento
            $item_type = 'l\'emendamento';
            $link = link_to_in_mail($item->getTitoloCompleto(), '@singolo_emendamento?id=' . $item->getId(), array('title' => 'Vai alla pagina dell\'emendamento'));
            break;
        case 'Tag':
            // link all'argomento
            $item_type = 'l\'argomento';
            $link = link_to_in_mail($item->getTripleValue(), '@argomento?triple_value=' . $item->getTripleValue(), array('title' => 'Vai alla pagina dell\'argomento'));
            break;
    }
    // build html code
    switch ($generator_model) {
        case 'sfEmendComment':
            // link al documento
            $link = link_to_in_mail($item->getTitolo(), '@documento?id=' . $related_id, array('title' => $item->getTitolo()));
            if ($news->getType() == 'C') {
                return sprintf("<div class='ico-type float-left'>%s</div><p>%s ha commentato il documento</p><p><strong>%s</strong></p><p>relativo %s</p>", image_tag('/images/ico-type-commento.png', array('alt' => 'commento')), strtolower($news->getUsername()), $link, $atto_link);
            }
            break;
        case 'sfComment':
            return sprintf("<div class='ico-type float-left'>%s</div><p>%s ha commentato %s</p><p> %s</p>", image_tag('/images/ico-type-commento.png', array('alt' => 'commento')), strtolower($news->getUsername()), $item_type, $link);
            break;
        case 'Monitoring':
            if ($news->getType() == 'C') {
                if ($news->getTotal() > 0) {
                    if ($news->getTotal() > 1) {
                        return sprintf("<div class='ico-type float-left'>%s</div><p>un utente si è aggiunto agli altri %d che stanno monitorando %s</p><p> %s", image_tag('/images/ico-type-monitoring.png', array('alt' => 'monitor')), $news->getTotal(), $item_type, $link);
                    } else {
                        return sprintf("<div class='ico-type float-left'>%s</div><p>un utente si è aggiunto a un altro che sta monitorando %s</p><p> %s", image_tag('/images/ico-type-monitoring.png', array('alt' => 'monitor')), $item_type, $link);
                    }
                } else {
                    return sprintf("<div class='ico-type float-left'>%s</div><p>un primo utente ha avviato il monitoraggio per %s</p><p> %s", image_tag('/images/ico-type-monitoring.png', array('alt' => 'monitor')), $item_type, $link);
                }
            } else {
                return sprintf("<div class='ico-type float-left'>%s</div><p>un utente ha smesso di monitorare %s</p><p> %s</p>", image_tag('/images/ico-type-monitoring.png', array('alt' => 'monitor')), $item_type, $link);
            }
            break;
        case 'sfVoting':
            if ($news->getType() == 'C') {
                if ($news->getVote() == 1) {
                    $fav_contr = '<span style="color:green; font-weight:bold;">favorevoli</span>';
                } else {
                    $fav_contr = '<span style="color:red; font-weight:bold;">contrari</span>';
                }
                if ($news->getTotal() > 0) {
                    if ($news->getTotal() > 1) {
                        return sprintf("<div class='ico-type float-left'>%s</div><p>un utente si è aggiunto agli altri %d %s al%s </p><p> %s</p>", image_tag('/images/ico-type-votazione-user.png', array('alt' => 'voto')), $news->getTotal(), $fav_contr, $item_type, $link);
                    } else {
                        if (substr_count($fav_contr, 'favorevoli') == 1) {
                            $fav_contr = '<span style="color:green; font-weight:bold;">favorevole</span>';
                        } else {
                            $fav_contr = '<span style="color:red; font-weight:bold;">contrario</span>';
                        }
                        return sprintf("<div class='ico-type float-left'>%s</div><p>un utente si è aggiunto a un altro %s al%s</p><p>%s</p>", image_tag('/images/ico-type-votazione-user.png', array('alt' => 'voto')), $fav_contr, $item_type, $link);
                    }
                } else {
                    if (substr_count($fav_contr, 'favorevoli') == 1) {
                        $fav_contr = '<span style="color:green; font-weight:bold;">favorevole</span>';
                    } else {
                        $fav_contr = '<span style="color:red; font-weight:bold;">contrario</span>';
                    }
                    return sprintf("<div class='ico-type float-left'>%s</div><p>un utente &egrave; %s al%s</p><p> %s</p>", image_tag('/images/ico-type-votazione-user.png', array('alt' => 'voto')), $fav_contr, $item_type, $link);
                }
            } else {
                return sprintf("<div class='ico-type float-left'>%s</div><p>utente ha ritirato il suo voto per %s</p><p> %s</p>", image_tag('/images/ico-type-votazione-user.png', array('alt' => 'voto')), $item_type, $link);
            }
            break;
        case 'nahoWikiRevision':
            return sprintf("<div class='ico-type float-left'>%s</div><p>%s ha modificato la descrizione wiki per %s</p><p> %s</p>", image_tag('/images/ico-type-descrizione.png', array('alt' => 'wiki!')), strtolower($news->getUsername()), $item_type, $link);
            break;
    }
}