function getImportantActs($xml_url, $xsl_filename, $n_nodes)
{
    try {
        // read the xml from url
        $xmldoc = new DomDocument();
        $xmldoc->load($xml_url);
        // read xslt file
        $xsldoc = new DomDocument();
        $xsldoc->load($xsl_filename);
        $xsl = new XSLTProcessor();
        $xsl->importStyleSheet($xsldoc);
        // trasforma XML secondo l'XSLT ed estrae il contenuto del div
        $transformed_xml = new SimpleXMLElement($xsl->transformToXML($xmldoc));
        $nodes = $transformed_xml->children();
        // write values to screen
        $cnt = 0;
        foreach ($nodes as $node) {
            $cnt++;
            $atto = OppAttoPeer::retrieveByPK($node['atto_id']);
            printf("\t%d. %s => %f\n", $cnt, $atto->getTitoloCompleto(), $node['totale']);
            if ($cnt >= $n_nodes) {
                break;
            }
        }
    } catch (Exception $e) {
        printf("Errore durante la scrittura del file: %s\n", $e->getMessage());
    }
}
 public function executeAttiutenti()
 {
     // costruzione del criterio di ordinamento
     switch ($this->type) {
         case 'commenti':
             $order_clause = ' order by nb_commenti desc ';
             break;
         case 'monitor':
             $order_clause = ' order by n_monitoring_users desc ';
             break;
         case 'voti':
             $order_clause = ' order by (ut_fav+ut_contr) desc ';
             break;
         default:
             $order_clause = '';
             break;
     }
     $limit = 5;
     $con = Propel::getConnection(OppAttoPeer::DATABASE_NAME);
     // estrazione degli atti (sia positivi che negativi)
     $sql = sprintf("select id from opp_atto where legislatura=17 %s limit %d;", $order_clause, $limit);
     $stm = $con->createStatement();
     $rs = $stm->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     // estrazione atti che verificano
     $atti = array();
     while ($rs->next()) {
         $row = $rs->getRow();
         $atti[] = OppAttoPeer::retrieveByPK($row['id']);
     }
     $this->atti = $atti;
 }
 /**
  * check if the user is indirectly monitoring the act
  * indirect monitoring means the user is monitoring a tag associated to the act
  *
  * @return void
  * @author Guglielmo Celata
  **/
 public function isIndirectlyMonitoringAct($act_id)
 {
     $user_monitored_tags_pks = $this->getMonitoredPks('Tag');
     $c = new Criteria();
     $c->addJoin(OppAttoPeer::ID, TaggingPeer::TAGGABLE_ID);
     $c->add(TaggingPeer::TAG_ID, $user_monitored_tags_pks, Criteria::IN);
     $c->add(OppAttoPeer::ID, $act_id);
     $count = OppAttoPeer::doCount($c);
     return $count > 0 ? true : false;
 }
 /**
  * retrieve the main atto (portante)
  *
  * @param Criteria $c 
  * @return OppAtto
  * @author Guglielmo Celata
  */
 public function getAttoPortante(Criteria $c = null)
 {
     if (is_null($c)) {
         $c = new Criteria();
     }
     $c->add(OppAttoHasEmendamentoPeer::PORTANTE, 1);
     $c->add(OppAttoHasEmendamentoPeer::EMENDAMENTO_ID, $this->getId());
     $c->addJoin(OppAttoHasEmendamentoPeer::ATTO_ID, OppAttoPeer::ID);
     return OppAttoPeer::doSelectOne($c);
 }
 /**
  * torna i ddl collegati agli interventi delle cariche
  *
  * @param string $cariche_ids 
  * @return array di OppAtto
  * @author Guglielmo Celata
  */
 public static function getDDLCollegatiCariche($cariche_ids)
 {
     $con = Propel::getConnection(self::DATABASE_NAME);
     $sql = sprintf("select i.atto_id, count(i.atto_id) n_interventi from opp_intervento i where i.carica_id in (%s) group by i.atto_id order by n_interventi desc", implode(",", $cariche_ids));
     $stm = $con->createStatement();
     $rs = $stm->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     $ddl = array();
     while ($rs->next()) {
         $row = $rs->getRow();
         $ddl[] = OppAttoPeer::retrieveByPK($row['atto_id']);
     }
     return $ddl;
 }
 /**
  * torna i ddl collegati agli emendamenti firmati dalle cariche
  *
  * @param string $cariche_ids 
  * @return array di OppAtto
  * @author Guglielmo Celata
  */
 public static function getDDLCollegatiCariche($cariche_ids)
 {
     $con = Propel::getConnection(self::DATABASE_NAME);
     $sql = sprintf("select ae.atto_id, count(ae.atto_id) n_emendamenti from opp_carica_has_emendamento ce, opp_emendamento e, opp_atto_has_emendamento ae where ae.emendamento_id=e.id and e.id=ce.emendamento_id and ce.carica_id in (%s) and ae.portante=1 group by ae.atto_id order by n_emendamenti desc", implode(",", $cariche_ids));
     $stm = $con->createStatement();
     $rs = $stm->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     $ddl = array();
     while ($rs->next()) {
         $row = $rs->getRow();
         $ddl[] = OppAttoPeer::retrieveByPK($row['atto_id']);
     }
     return $ddl;
 }
 protected function setPage($page_name = null)
 {
     // Get page from request if not given as parameter (default behaviour)
     if (is_null($page_name)) {
         $page_name = $this->getRequestParameter('page', $this->startPage);
     }
     // Handle case insensitivity
     $page_name = strtolower($page_name);
     // Support default page if not specified in namespace
     if (substr($page_name, -1) == ':') {
         $page_name .= $this->startPage;
     }
     // Retrieve the page, or start a new one if cannot be found
     $this->page = nahoWikiPagePeer::retrieveByName($page_name);
     if (!$this->page) {
         return;
     }
     // Retrieve the revision
     $revision = $this->getRequestParameter('revision', $this->page->getLatestRevision());
     $this->revision = $this->page->getRevision($revision);
     if (!$this->revision) {
         $this->initNewRevision();
     }
     // Generate the URI parameters to keep trace of the requested page
     $this->uriParams = 'page=' . $this->page->getName();
     if ($this->revision->getRevision() != $this->page->getLatestRevision()) {
         $this->uriParams .= '&revision=' . $this->revision->getRevision();
     }
     // Permissions management
     $this->canView = $this->page->canView($this->getUser());
     $this->canEdit = $this->page->canEdit($this->getUser());
     // Retriev item name and type of item (tab and breadcrumbs)
     list($tipo, $id) = split("_", $this->page->getName());
     switch ($tipo) {
         case 'atto':
             $this->item = OppAttoPeer::retrieveByPK($id);
             $this->item_name = Text::denominazioneAttoShort($this->item);
             break;
         case 'votazione':
             $this->item = OppVotazionePeer::retrieveByPK($id);
             $this->item_name = $this->item->getTitolo();
             break;
         case 'emendamento':
             $this->item = OppEmendamentoPeer::retrieveByPK($id);
             $attoPortante = $this->item->getAttoPortante();
             $this->item_name = "Emendamento " . $this->item->getTitolo() . " relativo a " . Text::denominazioneAttoShort($attoPortante) . " - " . $attoPortante->getTitolo();
             break;
     }
     $this->item_type = $tipo;
 }
/**
 * Genera un elenco csv di atti con i loro tag (id)
 * ATTO_ID, N_TAG, TAG_ID_1, TAG_ID_2, ...
 */
function run_stlab_genera_atti_tags_csv($task, $args, $options)
{
    static $loaded;
    // load application context
    if (!$loaded) {
        _loader();
    }
    $file_path = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . "stlab" . DIRECTORY_SEPARATOR . "atti_tags.csv";
    $act_types = array();
    if (array_key_exists('file_path', $options)) {
        $file_path = strtolower($options['file_path']);
    }
    if (array_key_exists('types', $options)) {
        $act_types = explode(",", $options['types']);
    }
    echo "memory usage: " . memory_get_usage() . "\n";
    $start_time = time();
    $msg = sprintf("generazione csv tag di ogni atto\n");
    echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true));
    $fh = fopen($file_path, 'w');
    // estrae tutti i DDL
    $c = new Criteria();
    if (count($act_types)) {
        $c->add(OppAttoPeer::TIPO_ATTO_ID, $act_types, Criteria::IN);
    }
    $atti = OppAttoPeer::doSelect($c);
    $n_atti = count($atti);
    foreach ($atti as $cnt => $atto) {
        $tags_ids = $atto->getTagsIds();
        if (count($tags_ids)) {
            $row = sprintf("%d,%d,%s", $atto->getId(), count($tags_ids), implode(",", $tags_ids));
            printf("%5d/%5d: %s\n", $cnt, $n_atti, $row);
            fprintf($fh, "%s\n", $row);
        }
    }
    fclose($fh);
    $msg = sprintf("%d atti elaborati\n", $cnt);
    echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true));
    $msg = sprintf(" [%4d sec] [%10d bytes]\n", time() - $start_time, memory_get_usage());
    echo pakeColor::colorize($msg, array('fg' => 'red', 'bold' => false));
}
 public function executeSioccupadi()
 {
     $options = array('limit' => 20, 'sort_by_relevance' => true);
     // estrazione tag, tipo firma, tipo atto
     // questo dovrebbe andare in TagPeer, ma romperebbe la neutralità del plugin
     $c = new Criteria();
     $c->addJoin(OppCaricaHasAttoPeer::ATTO_ID, OppAttoPeer::ID);
     $c->addJoin(TaggingPeer::TAGGABLE_ID, OppAttoPeer::ID);
     $c->addJoin(TagPeer::ID, TaggingPeer::TAG_ID);
     $c->add(OppCaricaHasAttoPeer::CARICA_ID, $this->carica->getId());
     $c->add(TaggingPeer::TAGGABLE_MODEL, 'OppAtto');
     $c->clearSelectColumns();
     $c->addSelectColumn(TagPeer::TRIPLE_VALUE);
     $c->addSelectColumn(OppCaricaHasAttoPeer::TIPO);
     $c->addSelectColumn(OppAttoPeer::TIPO_ATTO_ID);
     // costruzione array associativo dei tag
     $tags = array();
     $rs = TagPeer::doSelectRS($c);
     while ($rs->next()) {
         $value = $rs->getString(1);
         $tipo = $rs->getString(2);
         $tipo_atto_id = $rs->getInt(3);
         if (!array_key_exists($value, $tags)) {
             $tags[$value] = 0;
         }
         $tags[$value] += OppCaricaHasAttoPeer::get_fattore_firma($tipo) * OppAttoPeer::get_fattore_tipo_atto($tipo_atto_id);
     }
     // ordinamento per rilevanza, prima dello slice
     arsort($tags);
     // slice dell'array, se specificata l'opzione limit
     if (isset($options['limit']) && count($tags) > $options['limit']) {
         $this->n_remaining_tags = count($tags) - $options['limit'];
         $tags = array_slice($tags, 0, $options['limit'], true);
     }
     // ordinamento per triple_value, in caso sort_by_relevance non sia specificato
     if (!isset($options['sort_by_relevance']) || true !== $options['sort_by_relevance']) {
         krsort($tags);
     }
     $this->tags = $tags;
 }
 public function executeActsForType()
 {
     $this->type_id = $this->type->getId();
     $this->type_denominazione = $this->type->getDescrizione();
     // filtri per ramo e stato avanzamento
     $act_filtering_criteria = null;
     if ($this->filters['act_ramo'] != '0') {
         if (is_null($act_filtering_criteria)) {
             $act_filtering_criteria = new Criteria();
         }
         $act_filtering_criteria->add(OppAttoPeer::RAMO, $this->filters['act_ramo']);
     }
     if ($this->filters['act_stato'] != '0') {
         if (is_null($act_filtering_criteria)) {
             $act_filtering_criteria = new Criteria();
         }
         $act_filtering_criteria->add(OppAttoPeer::STATO_COD, $this->filters['act_stato']);
     }
     $blocked_items_pks = sfBookmarkingPeer::getAllNegativelyBookmarkedIds($this->user_id);
     if (array_key_exists('OppAtto', $blocked_items_pks)) {
         if (is_null($act_filtering_criteria)) {
             $act_filtering_criteria = new Criteria();
         }
         $blocked_acts_pks = $blocked_items_pks['OppAtto'];
         $act_filtering_criteria->add(OppAttoPeer::ID, $blocked_acts_pks, Criteria::NOT_IN);
     }
     $indirectly_monitored_acts = OppAttoPeer::doSelectIndirectlyMonitoredByUser($this->user, $this->type, $this->tag_filtering_criteria, $this->my_monitored_tags_pks, $act_filtering_criteria);
     if ($this->filters['tag_id'] == '0') {
         $directly_monitored_acts = OppAttoPeer::doSelectDirectlyMonitoredByUser($this->user, $this->type, $act_filtering_criteria);
     } else {
         $directly_monitored_acts = array();
     }
     $monitored_acts = OppAttoPeer::merge($indirectly_monitored_acts, $directly_monitored_acts);
     $this->n_total_acts = count($monitored_acts);
     if ($this->filters['act_type_id'] == 0) {
         $monitored_acts = array_slice($monitored_acts, 0, sfConfig::get('app_monitored_acts_per_type_limit'));
     }
     $this->monitored_acts = $monitored_acts;
 }
 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 
    echo link_to('chiudi', '#', array('class' => 'btn-close action', 'style' => 'display:none'));
    ?>
 ]
</span>

<div class="more-results float-container" style="padding:0px 5px 5px 0px; display: none;">
<table class="disegni-decreti column-table">

  <tbody>
  <?php 
    foreach ($contros as $key => $contro) {
        ?>
    <?php 
        $rs = OppAttoPeer::retrieveByPk($contro);
        ?>
    <tr class="even">
    <th scope="row">
    <p class="content-meta">
    <span class="date"> 
    <?php 
        $tipo = OppTipoAttoPeer::retrieveByPk($rs->getTipoAttoId());
        ?>
  
      <?php 
        echo $tipo->getDescrizione();
        ?>
      </span>
    </p>
    <p>
/*
 * This file is part of the Openpolis project
 *
 * (c) 2008 Guglielmo Celata <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * Sets the values of the cache fields (stato_cod, stato_fase, stato_last_date)
 * for the opp_atto table, starting from the already inserted opp_atto_has_iter files
 *
 * This can also be used to re-create the cache
 */
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();
$attos = OppAttoPeer::doSelect(new Criteria());
$cnt = 0;
foreach ($attos as $atto) {
    $cnt++;
    $iter_steps = $atto->getOppAttoHasIters();
    echo "{$cnt}) " . $atto->getId() . "(" . count($iter_steps) . ")\n";
    foreach ($iter_steps as $step) {
        $step->save();
    }
}
echo "{$cnt} total\n";
<?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');
?>

 public function executeIndex()
 {
     $this->getResponse()->setTitle('Monitora i tuoi rappresentanti - ' . sfConfig::get('app_main_title'));
     $this->getResponse()->addMeta('description', 'Cosa fanno i tuoi rappresentanti? Tutte le attività parlamentari aggiornate quotidianamente.', true);
     deppFiltersAndSortVariablesManager::resetVars($this->getUser(), 'module', 'module', array('acts_filter', 'sf_admin/opp_atto/sort', 'votes_filter', 'sf_admin/opp_votazione/sort', 'pol_camera_filter', 'pol_senato_filter', 'sf_admin/opp_carica/sort', 'argomento/atti_filter', 'argomento_leggi/sort', 'argomento_nonleg/sort', 'monitoring_filter'));
     // ultime attivita' della community
     $this->latest_activities = CommunityNewsPeer::getLatestActivities(4);
     // ultime news dal parlamento
     $c = oppNewsPeer::getHomeNewsCriteria();
     $c->addDescendingOrderByColumn(NewsPeer::DATE);
     $itemsperpage = 4;
     $pager = new deppNewsPager('News', $itemsperpage);
     $pager->setCriteria($c);
     $pager->setPage($this->getRequestParameter('page', 1));
     $pager->init();
     $this->pager = $pager;
     // atti in evidenza
     $this->lanci = array();
     $c = new Criteria();
     $c->add(sfLaunchingPeer::LAUNCH_NAMESPACE, 'home');
     $c->add(sfLaunchingPeer::OBJECT_MODEL, 'OppAtto');
     $c->setLimit(8);
     $c->addDescendingOrderByColumn(sfLaunchingPeer::PRIORITY);
     $evidences = sfLaunchingPeer::doSelect($c);
     foreach ($evidences as $evidence) {
         $atto = OppAttoPeer::retrieveByPk($evidence->getObjectId());
         $this->lanci[] = $atto->getId();
     }
     // post del blog
     $this->post_pager = sfSimpleBlogPostPeer::getTaggedPager('in evidenza', sfConfig::get('app_sfSimpleBlog_post_max_per_page', 10), $this->getRequestParameter('page', 1));
     // estrae le circoscrizioni, compreso il valore 0
     $this->senato_constituencies = OppCaricaPeer::getAllConstituencies('senato', false);
     $this->camera_constituencies = OppCaricaPeer::getAllConstituencies('camera', false);
 }
    echo $tr_class == 'even' ? 'odd' : 'even';
    ?>
">
    <?php 
    $tr_class = $tr_class == 'even' ? 'odd' : 'even';
    ?>
  <th scope='row'>
   <a href="#<?php 
    echo $k;
    ?>
"><?php 
    echo OppSedePeer::retrieveByPk($k)->getDenominazione();
    ?>
</a></th>
  <td><?php 
    echo number_format(count(OppAttoPeer::getAttiPerCommissioneLastIter($k, 'approvato definitivamente', $leg)), 0, '', '.');
    ?>
</td>
  <td><?php 
    echo number_format($com[0], 0, '', '.');
    ?>
</td>
  <td><?php 
    echo number_format($com[1], 0, '', '.');
    ?>
</td>
  <td><?php 
    echo number_format($com[2], 0, '', '.');
    ?>
</td>
  <td><?php 
">
     <?php 
    $tr_class = $tr_class == 'even' ? 'odd' : 'even';
    ?>
       <th scope="row">
         <p class="content-meta">
           <span class="date"><?php 
    echo $veloce[0]->getDataPres('d/m/Y');
    ?>
,</span>
           <span><?php 
    echo $veloce[0]->getRamo() == 'C' ? 'presentato alla Camera' : 'presentato al Senato';
    ?>
             
             <?php 
    $f_signers = OppAttoPeer::getRecordsetFirmatari($veloce[0]->getId(), 'P');
    ?>
                 <?php 
    if ($f_signers->next()) {
        ?>
  
                   <?php 
        echo ' da ' . $f_signers->getString(2) . ' ' . $f_signers->getString(3) . ($f_signers->getString(6) != '' ? ' (' . $f_signers->getString(6) . ')' : '') . ($f_signers->next() ? ' e altri' : '');
        ?>
                 <?php 
    }
    ?>
           </span>
         </p>
         <p>
           <?php 
 /**
  * create as many news as the number of monitorable objects related to the 
  * generating object
  *
  * @param BaseObject $object - the generator object
  * @param int $priority - the priority (it's an override if not null)
  * @param bool $isSuccNews - flag to generate a succNews (only called from batch script)
  *
  * @return int - the number of generated news
  * @author Guglielmo Celata
  **/
 public function generateNews(BaseObject $object, $priority = null, $isSuccNews = null)
 {
     $n_gen_news = 0;
     // fetch the monitorable objects related to this generator
     $monitorable_objects = $this->getRelatedMonitorableObjects($object);
     foreach ($monitorable_objects as $obj) {
         // temporarily skip news generation when tagging emendamento
         if (get_class($object) == 'Tagging' && $object->getTaggableModel() == 'OppEmendamento') {
             continue;
         }
         $n = new News();
         $n->setGeneratorModel(get_class($object));
         $n->setGeneratorPrimaryKeys(serialize($this->getPrimaryKeysArray($object)));
         $n->setRelatedMonitorableModel(get_class($obj));
         $n->setRelatedMonitorableId($obj->getPrimaryKey());
         // the following methods store data related to the generating object in the cache
         // only data needed to sort, sum, average, or count, are cached
         if ($object->getCreatedAt() != null) {
             $n->setCreatedAt($object->getCreatedAt());
         }
         $n->setDate($object->getNewsDate());
         if (!is_null($priority)) {
             $n->setPriority($priority);
         } else {
             $n->setPriority($object->getNewsPriority());
         }
         # TODO: spostare le eccezioni fuori dal plugin, in un contesto di applicazione
         // eccezioni
         // eccezione per non generare notizia alla presentazione di un decreto legge
         if ($object instanceof OppAtto && $object->getTipoAttoId() == 12) {
             continue;
         }
         if ($obj instanceof OppAtto) {
             $n->setDataPresentazioneAtto($obj->getDataPres());
             $n->setTipoAttoId($obj->getOppTipoAtto()->getId());
             $n->setRamoVotazione($obj->getRamo());
         }
         // eccezione per modifica valore campo succ (opp_atto)
         if (isset($this->succNews) && $this->succNews || $isSuccNews) {
             $n->setSucc($object->getSucc());
             $succ_obj = OppAttoPeer::retrieveByPK($object->getSucc());
             $n->setDate($succ_obj->getDataPres('Y-m-d h:i:s'));
         }
         // eccezione per news generate dal tagging
         if ($object instanceof Tagging) {
             $n->setTagId($object->getTagId());
         }
         $n->save();
         $n_gen_news++;
     }
     return $n_gen_news;
 }
      <th scope="col">indice:</th>  
      <th scope="col">azioni:</th>
    </tr>
  </thead>

  <tbody>		
   <?php 
$tr_class = 'even';
?>
	
    <?php 
foreach ($pager->getResults() as $record) {
    ?>

      <?php 
    $atto = OppAttoPeer::retrieveByPK($record->getChiId());
    ?>
      
      <tr class="<?php 
    echo $tr_class;
    ?>
">
      <?php 
    $tr_class = $tr_class == 'even' ? 'odd' : 'even';
    ?>
        <td><?php 
    echo $atto->getOppTipoAtto()->getDenominazione();
    ?>
</td>
        <th scope="row">
          <?php 
 public function executeDdl2legge()
 {
     if ($this->gruppo != NULL) {
         $c = new Criteria();
         $c->add(OppGruppoPeer::ACRONIMO, $this->gruppo);
         $gruppo = OppGruppoPeer::doSelectOne($c);
         $cariche = OppCaricaHasGruppoPeer::getCarichePerGruppo($gruppo->getId(), 1);
         foreach ($cariche as $carica) {
             $componenti_gruppo[] = $carica->getCaricaId();
         }
     }
     if ($this->gruppo != NULL) {
         $c = new Criteria();
         $c->add(OppGruppoPeer::ACRONIMO, $this->gruppo);
         $gruppo = OppGruppoPeer::doSelectOne($c);
         $cariche = OppCaricaHasGruppoPeer::getCaricheGovernoPerGruppo($gruppo->getId(), 1);
         foreach ($cariche as $carica) {
             $componenti_gruppo[] = $carica;
         }
     }
     $arrs = array();
     $arr_alls = array();
     foreach (array(1, 2, 4) as $i) {
         $c = new Criteria();
         if ($this->gruppo != NULL) {
             $c->addJoin(OppAttoPeer::ID, OppCaricaHasAttoPeer::ATTO_ID);
             $c->add(OppCaricaHasAttoPeer::CARICA_ID, $componenti_gruppo, Criteria::IN);
             $c->add(OppCaricaHasAttoPeer::TIPO, 'P');
         }
         $c->add(OppAttoPeer::TIPO_ATTO_ID, 1);
         $c->add(OppAttoPeer::LEGISLATURA, $this->leg);
         $c->add(OppAttoPeer::INIZIATIVA, $i);
         $c->setDistinct(OppAttoPeer::ID);
         $atti = OppAttoPeer::doSelect($c);
         $c = new Criteria();
         if ($this->gruppo != NULL) {
             $c->addJoin(OppAttoPeer::ID, OppCaricaHasAttoPeer::ATTO_ID);
             $c->add(OppCaricaHasAttoPeer::CARICA_ID, $componenti_gruppo, Criteria::IN);
             $c->add(OppCaricaHasAttoPeer::TIPO, 'P');
         }
         $c->addJoin(OppAttoPeer::ID, OppAttoHasIterPeer::ATTO_ID);
         $c->add(OppAttoPeer::TIPO_ATTO_ID, 1);
         $c->add(OppAttoPeer::LEGISLATURA, $this->leg);
         $c->add(OppAttoPeer::INIZIATIVA, $i);
         $c->add(OppAttoHasIterPeer::ITER_ID, 16);
         $c->setDistinct(OppAttoPeer::ID);
         $leggi = OppAttoHasIterPeer::doSelect($c);
         $tempo_medio = 0;
         foreach ($leggi as $legge) {
             $ddl = $legge->getOppAtto();
             while ($ddl->getPred() != NULL) {
                 $ddl = OppAttoPeer::retrieveByPk($ddl->getPred());
             }
             //$this->data_pres=$ddl->getDataPres();
             //$this->data_appr=$legge->getData();
             $data_pres = strtotime($ddl->getDataPres());
             $data_appr = strtotime($legge->getData());
             $tempo_medio = $tempo_medio + ($data_appr - $data_pres) / 86400;
             $arr_alls[] = array($legge->getOppAtto(), ($data_appr - $data_pres) / 86400);
         }
         if (count($leggi) > 0) {
             $tempo_medio = intval($tempo_medio / count($leggi));
         } else {
             $tempo_medio = $tempo_medio;
         }
         $arrs[] = array(count($atti), count($leggi), $tempo_medio);
     }
     $this->arrs = $arrs;
     function cmp($a, $b)
     {
         if ($a[1] == $b[1]) {
             return 0;
         }
         return $a[1] < $b[1] ? -1 : 1;
     }
     usort($arr_alls, "cmp");
     $this->arr_alls = $arr_alls;
 }
<?php

define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..'));
define('SF_APP', 'fe');
define('SF_ENVIRONMENT', 'prod');
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->add(OppAttoPeer::ID, 8333);
$atti = OppAttoPeer::doSelect($c);
foreach ($atti as $atto) {
    $ctrl = 0;
    $fase_iter = "ok";
    $c1 = new Criteria();
    $c1->addJoin(OppAttoPeer::ID, OppAttoHasIterPeer::ATTO_ID);
    $c1->addJoin(OppIterPeer::ID, OppAttoHasIterPeer::ITER_ID);
    $c1->add(OppAttoPeer::ID, $atto->getId());
    $iters = OppAttoHasIterPeer::doSelect($c1);
    foreach ($iters as $iter) {
        if ($atto->getStatoCod() == 'IC' and $iter->getOppIter()->getCacheCod() == 'CO' || $iter->getOppIter()->getCacheCod() == 'RE' || $iter->getOppIter()->getCacheCod() == 'AP') {
            $ctrl = $iter->getOppIter()->getCacheCod();
            $fase_iter = $iter->getOppIter()->getFase();
            $data = $iter->getData();
            break;
        }
        if ($atto->getStatoCod() == 'CO' and $iter->getOppIter()->getCacheCod() == 'RE' || $iter->getOppIter()->getCacheCod() == 'AP') {
            $ctrl = $iter->getOppIter()->getCacheCod();
            $fase_iter = $iter->getOppIter()->getFase();
            $data = $iter->getData();
            break;
/**
 * Prepara uno o più atti, specificati dall'id nell'elenco argomenti per un test
 * Vengono rimossi tutti i dati accessori:
 *  firme, assrgnazioni in commissione, documenti, tagging, esiti, interventi
 * Sono resettati il titolo e l'md5
 *
 * Necessario per pulire un oggetto prima di un test di upgrade
 */
function run_opp_prepare_ddl_for_test($task, $args, $options)
{
    static $loaded;
    // load application context
    if (!$loaded) {
        _loader();
    }
    $dry_run = false;
    if (array_key_exists('dry-run', $options)) {
        $dry_run = true;
    }
    $con = Propel::getConnection(OppAttoPeer::DATABASE_NAME);
    echo "memory usage: " . memory_get_usage() . "\n";
    $start_time = time();
    try {
        $atti_rs = OppAttoPeer::getRSFromIDArray($args, $con);
    } catch (Exception $e) {
        throw new Exception("Specificare degli ID validi. \n" . $e);
    }
    $n_atti = $atti_rs->getRecordCount();
    $cnt = 0;
    while ($atti_rs->next()) {
        $a = $atti_rs->getRow();
        $atto_id = $a['id'];
        print "atto: {$atto_id}\n";
        $atto = OppAttoPeer::retrieveByPK($atto_id);
        $atto->setTitolo("");
        $atto->setMd5("");
        $atto->save();
        print "  titolo e md5 annullat1\n";
        # firme
        $items = $atto->getOppCaricaHasAttos(null, $con);
        $nitems = count($items);
        foreach ($items as $cnt => $item) {
            $item->delete($con);
        }
        print "  {$nitems} firme rimosse\n";
        # assegnazioni
        $items = $atto->getOppAttoHasSedes(null, $con);
        $nitems = count($items);
        foreach ($items as $cnt => $item) {
            $item->delete($con);
        }
        print "  {$nitems} assegnazioni in commissione rimosse\n";
        # tag (sf_tagging)
        $items = $atto->getTagsAsTaggingObjects(null, $con);
        $nitems = count($items);
        foreach ($items as $cnt => $item) {
            $item->delete($con);
        }
        print "  {$nitems} tagging dell'atto rimossi\n";
        # documenti
        $items = $atto->getOppDocumentos(null, $con);
        $nitems = count($items);
        foreach ($items as $cnt => $item) {
            $item->delete($con);
        }
        print "  {$nitems} documenti allegati rimossi\n";
        # iter
        $last_iter = $atto->getLastIter();
        $last_iter->delete();
        # relazioni
        $items = $atto->getRelazioni();
        $nitems = count($items);
        foreach ($items as $cnt => $item) {
            $item->delete($con);
        }
        print "  {$nitems} relazioni rimosse\n";
        # esito sedute
        $items = $atto->getOppEsitoSedutas();
        $nitems = count($items);
        foreach ($items as $cnt => $item) {
            $item->delete($con);
        }
        print "  {$nitems} esiti rimossi\n";
        # interventi
        $items = $atto->getOppInterventos();
        $nitems = count($items);
        foreach ($items as $cnt => $item) {
            $item->delete($con);
        }
        print "  {$nitems} interventi rimossi\n";
        print "\n";
    }
    $msg = sprintf("fine task\n");
    echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true));
    $msg = sprintf(" [%4d sec] [%10d bytes]\n", time() - $start_time, memory_get_usage());
    echo pakeColor::colorize($msg, array('fg' => 'red', 'bold' => false));
}
define('SF_APP', 'fe');
define('SF_ENVIRONMENT', 'test');
define('SF_DEBUG', true);
include dirname(__FILE__) . '/../bootstrap/unit.php';
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
sfContext::getInstance();
$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);
 /**
  * API (protetta da una API key)
  * torna flusso xml con gli atti in un certo intervallo di date
  * progetto op_fb
  *
  *   <opp xmlns="http://www.openpolis.it/2010/opp"
  *          xmlns:op="http://www.openpolis.it/2010/op"
  *          xmlns:xlink="http://www.w3.org/1999/xlink">
  *     <op:content> 
  *       <atto opp_id="38631">
  *         <legislatura>16</legislatura>
  *         <ramo>S</ramo>
  *         <numero>1611</numero>
  *         <titolo><![CDATA[
  *           [Ddl intercettazioni] Norme in materia di intercettazioni telefoniche, telematiche e ambientali. Modifica della disciplina in materia di astensione del giudice e degli atti di indagine. Integrazione della disciplina sulla responsabilità amministrativa delle persone giuridiche
  *           ]]>
  *         </titolo>
  *         <presentato_il>2009-06-11</presentato_il>
  *       </atto>
  *       <atto opp_id="51055">
  *         <legislatura>16</legislatura>
  *         <ramo>DL</ramo>
  *         <numero>29/10</numero>
  *         <tipo_atto>SDDL</tipo_atto>
  *         <titolo><![CDATA[
  *           [Decreto salva liste] Interpretazione autentica di disposizioni del procedimento elettorale e relativa disciplina di attuazione (G.U. n. 54 del 06/03/2010) 
  *           ]]>
  *         </titolo>
  *         <presentato_il>2010-03-05</presentato_il>
  *       </atto>
  *       <atto opp_id="36235">
  *         <legislatura>16</legislatura>
  *         <ramo>C</ramo>
  *         <numero>2350</numero>
  *         <titolo><![CDATA[
  *           [Testamento biologico e cure di fine vita] Disposizioni in materia di alleanza terapeutica, di consenso informato e di dichiarazioni anticipate di trattamento 
  *           ]]>
  *         </titolo>
  *         <presentato_il>2009-04-01</presentato_il>
  *       </atto>
  *     </op:content>
  *   </opp>
  *
  *       
  * Return error in case something's wrong
  * <opp xlmns="http://www.openpolis.it/2010/opp"
  *       xmlns:op="http://www.openpolis.it/2010/op"
  *   <op:error>Messaggio di errore</op:error>
  * </opp>
  * @return String
  * @author Guglielmo Celata
  **/
 public function executeElencoAtti()
 {
     $data_inizio = $this->getRequestParameter('data_inizio');
     $data_fine = $this->getRequestParameter('data_fine');
     $ramo = null;
     if ($this->hasRequestParameter('ramo')) {
         $ramo = $this->getRequestParameter('ramo');
     }
     $tipo_atto = null;
     if ($this->hasRequestParameter('tipo_atto')) {
         $tipo_atto = $this->getRequestParameter('tipo_atto');
     }
     $escludi_tipi = array();
     if ($this->hasRequestParameter('escludi_tipi')) {
         $escludi_tipi_str = urldecode($this->getRequestParameter('escludi_tipi'));
         $escludi_tipi = explode(",", $escludi_tipi_str);
     }
     $key = $this->getRequestParameter('key');
     $is_valid_key = deppApiKeysPeer::isValidKey($key);
     $resp_node = new SimpleXMLExtended('<opp xmlns="' . $this->opp_ns . '" ' . ' xmlns:op="' . $this->op_ns . '" ' . ' xmlns:xlink="' . $this->xlink_ns . '" >' . '</opp>');
     if ($is_valid_key) {
         // start producing xml
         $content_node = $resp_node->addChild('op:content', null, $this->op_ns);
         $atti = OppAttoPeer::getAttiInDateInterval($data_inizio, $data_fine, $ramo, $tipo_atto, $escludi_tipi);
         $atti_node = $content_node->addChild('atti', null, $this->opp_ns);
         $atti_node->addAttribute('n_atti', count($atti));
         foreach ($atti as $atto) {
             $titulo = $atto->getTitolo();
             $data_pres = $atto->getDataPres('Y-m-d');
             $ramo = $atto->getRamo();
             $numero = $atto->getNumfase();
             $legislatura = $atto->getLegislatura();
             $atto_node = $atti_node->addChild('atto', null, $this->opp_ns);
             $atto_node->addAttribute('opp_id', $atto->getId());
             $atto_node->addChild('legislatura', $legislatura);
             $atto_node->addChild('ramo', $ramo);
             $atto_node->addChild('numero', $numero);
             $tipo_atto = $atto_node->addChild('tipo_atto', $atto->getOppTipoAtto()->getDenominazione());
             // $tipo_atto->addAttribute('id', $atto->getTipoAttoId());
             $titulo_node = $atto_node->addChild('titolo', null);
             $titulo_node->addCData($titulo);
             $atto_node->addChild('presentato_il', $data_pres);
         }
     } else {
         $resp_node->addChild('op:error', 'Chiave di accesso non valida', $this->op_ns);
     }
     $xmlContent = $resp_node->asXML();
     $this->_send_output($xmlContent);
     return sfView::NONE;
 }
define('SF_APP', 'fe');
define('SF_ENVIRONMENT', 'test');
define('SF_DEBUG', true);
include dirname(__FILE__) . '/../bootstrap/unit.php';
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
sfContext::getInstance();
$t = new lime_test(2, new lime_output_color());
$t->diag('unit test to verify the mechanisms to upgrade the opp_atto.n_interventi field');
$t->diag('Tests beginning');
$atto_id = 12066;
$carica_id = 801;
$atto = OppAttoPeer::retrieveByPK($atto_id);
$n_interventi = $atto->getNInterventi();
$t->diag("L'atto {$atto_id} ha {$n_interventi} interventi");
$t->diag("Creato nuovo un intervento per la carica {$carica_id}");
$int_new = new OppIntervento();
$int_new->setAttoId($atto_id);
$int_new->setCaricaId($carica_id);
$int_new->setTipologia('Assemblea');
$int_new->setSedeId('36');
$int_new->setData('2009-02-06');
$int_new->setUrl('http://pippo.it');
$int_new->setNumero(2);
$int_new->save();
$atto = OppAttoPeer::retrieveByPK($atto_id);
$t->ok($atto->getNInterventi() == $n_interventi + 1, "L'atto ha ora un intervento in più (" . $atto->getNInterventi() . ")");
$t->diag("Rimosso l'intervento");
$int_new->delete();
$atto = OppAttoPeer::retrieveByPK($atto_id);
$t->ok($atto->getNInterventi() == $n_interventi, "L'atto ha ora di nuovo lo stesso n. di interventi (" . $atto->getNInterventi() . ")");
 /**
  * estrae il dettaglio degli interessi di un politico per gli argomenti, a una certa data
  *
  * @param string $carica_id 
  * @param string $argomenti_ids 
  * @param string $data 
  * @param string $fetch_interventi 
  * @return hash
  *         'firme_r' => [{'atto' => 1, 'punti_atto' => 232.23}, {'atto' => ID, 'punti_atto' => 12.34}, ...],
  *         'totale_firme_r' => 344.12,
  *         'firme_p' => [{'atto' => 2, 'punti_atto' => 123.45}, {'atto' => ID, 'punti_atto' => 23.34}, ...],
  *         'totale_firme_p' => 244.12,
  *         'firme_c' => [{'atto' => 3, 'punti_atto' => 234.56}, {'atto' => ID, 'punti_atto' => 34.56}, ...],
  *         'totale_firme_c' => 354.12,
  *         'interventi' => [{'atto' => 4, 'punti_atto' => 345.67, {'atto' => ID, 'punti_atto' => 56.67}, ...],
  *         'totale_interventi' => 456.12,
  *
  * @author Guglielmo Celata
  */
 public static function getDettaglioInteresseArgomenti($carica_id, $argomenti_ids, $data, $fetch_interventi = true)
 {
     $con = Propel::getConnection(self::DATABASE_NAME);
     $dettaglio = array();
     // estrazione di tutte le firme della carica relative ad atti taggati con argomento e del peso degli atti
     foreach (array('P', 'R', 'C') as $tipo_firma) {
         $dettaglio["firme_" . strtolower($tipo_firma)] = array();
         $dettaglio['totale_firme_' . strtolower($tipo_firma)] = 0;
         foreach (array(0, 1) as $is_omnibus) {
             if ($is_omnibus) {
                 $tagging_table = 'sf_tagging_for_index';
                 $tagging_conditions = "t.atto_id=ca.atto_id";
             } else {
                 $tagging_table = 'sf_tagging';
                 $tagging_conditions = "t.taggable_id=ca.atto_id and t.taggable_model='OppAtto'";
             }
             $sql = sprintf("select ca.atto_id, ah.indice, ah.priorita from opp_atto a, opp_carica_has_atto ca, {$tagging_table} t, opp_act_history_cache ah where a.id=ca.atto_id and (ca.tipo != 'P' or ca.tipo = 'P' and a.pred is null) and a.is_omnibus={$is_omnibus} and ca.tipo='%s' and ca.carica_id=%d and {$tagging_conditions} and ah.chi_tipo='A' and ah.data='%s' and ah.chi_id=ca.atto_id and t.tag_id in (%s) group by ca.atto_id", $tipo_firma, $carica_id, $data, implode(", ", $argomenti_ids));
             $stm = $con->createStatement();
             $rs = $stm->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
             // costruzione array del dettaglio firme
             $totale = 0;
             while ($rs->next()) {
                 $row = $rs->getRow();
                 $atto_id = $row['atto_id'];
                 $priorita = $row['priorita'];
                 $punti_atto = $row['indice'] / (double) $priorita;
                 $dettaglio["firme_" . strtolower($tipo_firma)][] = array('atto' => OppAttoPeer::retrieveByPK($atto_id), 'punti_atto' => $punti_atto);
                 $totale += OppCaricaHasAttoPeer::get_nuovo_fattore_firma($tipo_firma) * $punti_atto;
             }
             $dettaglio['totale_firme_' . strtolower($tipo_firma)] += $totale;
         }
     }
     if ($fetch_interventi) {
         $dettaglio["interventi"] = array();
         $dettaglio['totale_interventi'] = 0;
         foreach (array(0, 1) as $is_omnibus) {
             if ($is_omnibus) {
                 $tagging_table = 'sf_tagging_for_index';
                 $tagging_conditions = "t.atto_id=i.atto_id";
             } else {
                 $tagging_table = 'sf_tagging';
                 $tagging_conditions = "t.taggable_id=i.atto_id and t.taggable_model='OppAtto'";
             }
             // estrazione di tutti gli interventi della carica relativo ad atti taggati con argomento
             $sql = sprintf("select count(*) as ni, i.atto_id, ah.indice, ah.priorita from opp_atto a, opp_intervento i, {$tagging_table} t, opp_act_history_cache ah where a.id=i.atto_id and a.is_omnibus={$is_omnibus} and ah.chi_id=i.atto_id and i.carica_id = %d and ah.data='%s' and {$tagging_conditions} and t.tag_id in (%s)  group by i.atto_id order by i.atto_id;", $carica_id, $data, implode(", ", $argomenti_ids));
             $stm = $con->createStatement();
             $rs = $stm->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
             // costruzione array del dettaglio interventi
             $totale = 0;
             while ($rs->next()) {
                 $row = $rs->getRow();
                 $n_interventi = $row['ni'];
                 $atto_id = $row['atto_id'];
                 $priorita = $row['priorita'];
                 $punti_atto = $row['indice'] / (double) $priorita;
                 $dettaglio["interventi"][] = array('atto' => OppAttoPeer::retrieveByPK($atto_id), 'atto_id' => $atto_id, 'punti_atto' => $punti_atto, 'n_interventi' => $n_interventi);
                 $totale += OppCaricaHasAttoPeer::get_nuovo_fattore_firma('I') * $n_interventi * $punti_atto;
             }
             $dettaglio['totale_interventi'] += $totale;
         }
     }
     return $dettaglio;
 }
/**
 * Add one or more tags to  different acts
 */
function run_opp_add_tags_to_acts($task, $args, $options)
{
    static $loaded;
    // load application context
    if (!$loaded) {
        _loader();
    }
    if (array_key_exists('tags', $options)) {
        $tags = $options['tags'];
        $tags_names = trim(strip_tags(getNamesFromValues($tags)));
    } else {
        throw new Exception("No tags specified, use --tags=TAG1,TAG2");
    }
    echo "memory usage: " . memory_get_usage() . "\n";
    $start_time = time();
    $msg = sprintf("aggiunta dei tag %s\n", $tags);
    echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true));
    // lettura argomenti da stdin (id degli atti da taggare)
    stream_set_blocking(STDIN, false);
    $stdin_atti = array();
    while ($stdin = trim(fgets(STDIN))) {
        if ($stdin) {
            $stdin_atti[] = $stdin;
        }
    }
    if (count($stdin_atti)) {
        $msg = sprintf("%d atti letti da STDIN\n", count($stdin_atti));
        echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true));
    }
    $atti = array_merge($args, $stdin_atti);
    foreach ($atti as $atto_id) {
        $msg = sprintf("atto ID: {$atto_id} ...");
        echo pakeColor::colorize($msg, array('fg' => 'green', 'bold' => false));
        $atto = OppAttoPeer::retrieveByPK($atto_id);
        if ($atto instanceof OppAtto) {
            $atto->addTag($tags_names);
            $atto->save();
            $msg = sprintf("OK (%d)\n", memory_get_usage());
            echo pakeColor::colorize($msg, array('fg' => 'green', 'bold' => true));
        } else {
            $msg = sprintf("SKIP - Atto non in DB (%d)\n", memory_get_usage());
            echo pakeColor::colorize($msg, array('fg' => 'red', 'bold' => true));
        }
        unset($atto);
    }
}
 public function executeAct()
 {
     $this->act_id = $this->getRequestParameter('id');
     $this->act = OppAttoPeer::retrieveByPK($this->act_id);
     $this->n_news = oppNewsPeer::countNewsForItem('OppAtto', $this->act_id);
     $this->getResponse()->setTitle('tutte le notizie su ' . $this->act->getOppTipoAtto()->getDescrizione() . ' ' . Text::denominazioneAttoShort($this->act) . ' - ' . sfConfig::get('app_main_title'));
     $this->response->addMeta('description', 'Tutte le notizie aggiornate quotidianamente su presentazione e iter  ' . $this->act->getOppTipoAtto()->getDescrizione() . ' ' . Text::denominazioneAttoShort($this->act), true);
     $c = oppNewsPeer::getNewsForItemCriteria('OppAtto', $this->act_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;
 }
       echo ' alla Camera';
       ?>
           <?php 
   }
   ?>
           <?php 
   if ($ddl->getRamo() == 'S') {
       ?>
             <?php 
       echo ' al Senato';
       ?>
           <?php 
   }
   ?>
           <?php 
   $f_signers = OppAttoPeer::getRecordsetFirmatari($ddl->getId(), 'P');
   ?>
           
               <?php 
   if ($f_signers->next()) {
       ?>
 
                 <?php 
       echo ' da ' . $f_signers->getString(2) . ' ' . $f_signers->getString(3) . ($f_signers->getString(6) != '' ? ' (' . $f_signers->getString(6) . ')' : '') . ($f_signers->next() ? ' e altri' : '');
       ?>
               <?php 
   }
   ?>
         
           </span> 
         </p>
 public function votatoDaOpposizione()
 {
     return OppAttoPeer::isAttoVotatoDaOpposizione($this->getId());
 }