<?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'); ?>
/** * Genera i files di testo degli atti * ATTO_ID_i.txt - i num progressivo del testo */ function run_stlab_genera_testi_atti($task, $args, $options) { static $loaded; // load application context if (!$loaded) { _loader(); } $files_path = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . "stlab"; if (array_key_exists('files_path', $options)) { $files_path = strtolower($options['files_path']); } $verbose = false; $offset = null; $limit = null; $act_types = array(); if (array_key_exists('verbose', $options)) { $verbose = true; } if (array_key_exists('offset', $options)) { $offset = $options['offset']; } if (array_key_exists('limit', $options)) { $limit = $options['limit']; } if (array_key_exists('types', $options)) { $act_types = explode(",", $options['types']); } echo "memory usage: " . memory_get_usage() . "\n"; $start_time = time(); $msg = sprintf("generazione files dei testi degli atti\n"); echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true)); // creazione del file di archivio $zip = new ZipArchive(); $zip_file_name = $files_path . DIRECTORY_SEPARATOR . "testi.zip"; if (!file_exists($zip_file_name)) { $res = $zip->open($zip_file_name, ZIPARCHIVE::CREATE); } else { $res = $zip->open($zip_file_name); } if ($res !== TRUE) { throw new Exception("Impossibile creare l'archivio testi.zip: " . $res); } // set dei limiti $c = new Criteria(); if (!is_null($limit)) { $c->setLimit($limit); } if (!is_null($offset)) { $c->setOffset($offset); } // estrazione documenti $c->addJoin(OppDocumentoPeer::ATTO_ID, OppAttoPeer::ID); if (count($act_types)) { $c->add(OppAttoPeer::TIPO_ATTO_ID, $act_types, Criteria::IN); } $docs = OppDocumentoPeer::doSelect($c); $n_docs = count($docs); foreach ($docs as $cnt => $doc) { printf("%5d/%5d: ", $c->getOffset() + $cnt + 1, $c->getOffset() + $n_docs); // definizione nome nell'archivio (attoID_docID) $file_name = $doc->getAttoId() . "_" . $doc->getId() . ".txt"; // aggiunta testo all'archivio $zip->addFromString($file_name, $doc->getTesto()); printf(" %d_%d ok (%d)\n", $doc->getAttoId(), $doc->getId(), memory_get_usage()); } // chiusura archivio e scrittura su file system $zip->close(); $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)); }
/** * retrieve the object related to the generator * * @return void * @author Guglielmo Celata **/ public function getRelatedObject(BaseObject $object) { $related_model_getter = sfConfig::get(sprintf('propel_behavior_deppPropelActAsCommunityNewsGeneratorBehavior_%s_rel_model_getter', get_class($object)), ''); $related_id_getter = sfConfig::get(sprintf('propel_behavior_deppPropelActAsCommunityNewsGeneratorBehavior_%s_rel_id_getter', get_class($object)), ''); $related_model = call_user_func(array($object, $related_model_getter)); $related_id = call_user_func(array($object, $related_id_getter)); // sfLogger::getInstance()->info('xxx:'.$related_model); // sfLogger::getInstance()->info('xxx:'.$related_id); // awful patch to have it work // else it fails with segmentation fault (only for OppDocumento objects) if ($related_model == 'OppDocumento') { $rel_obj = OppDocumentoPeer::retrieveByPK($related_id); } else { $rel_obj = call_user_func_array($related_model . 'Peer::retrieveByPK', array($related_id)); } // sfLogger::getInstance()->info('xxx'); return $rel_obj; }
public function executeDocumento() { $this->documento = OppDocumentoPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($this->documento); if (!$this->getUser()->hasCredential('noemend') && $this->documento->getOppAtto()->getTipoAttoId() != 12 && $this->documento->getOppAtto()->getTipoAttoId() != 15 && $this->documento->getOppAtto()->getTipoAttoId() != 16 && $this->documento->getOppAtto()->getTipoAttoId() != 17) { $this->getResponse()->addJavascript("/sfEmendPlugin/emend.boot.js"); } $this->getResponse()->setTitle($this->documento->getOppAtto()->getOppTipoAtto()->getDescrizione() . ' ' . $this->documento->getOppAtto()->getRamo() . '. ' . $this->documento->getOppAtto()->getNumfase() . ' / ' . $this->documento->getTitolo() . ' - ' . sfConfig::get('app_main_title')); $this->response->addMeta('description', 'Il testo integrale riguardante ' . $this->documento->getOppAtto()->getOppTipoAtto()->getDescrizione() . ' ' . $this->documento->getOppAtto()->getRamo() . '. ' . $this->documento->getOppAtto()->getNumfase() . ' ' . $this->documento->getOppAtto()->getTitolo(), true); $c = new Criteria(); $cton1 = $c->getNewCriterion(OppDocumentoPeer::ATTO_ID, $this->documento->getAttoId(), Criteria::EQUAL); $cton2 = $c->getNewCriterion(OppDocumentoPeer::ID, $this->getRequestParameter('id'), Criteria::NOT_IN); $cton1->addAnd($cton2); $c->add($cton1); $this->documenti_correlati = OppDocumentoPeer::doSelect($c); }
<?php define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/../..')); define('SF_APP', 'fe'); define('SF_ENVIRONMENT', 'dev'); define('SF_DEBUG', true); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; sfContext::getInstance(); $testo = ""; $c = new Criteria(); $c->add(OppAttoPeer::TIPO_ATTO_ID, 1); $c->add(OppAttoPeer::RAMO, 'C'); $rss = OppAttoPeer::doSelect($c); foreach ($rss as $rs) { $c = new Criteria(); $c->add(OppDocumentoPeer::ATTO_ID, $rs->getId()); $docs = OppDocumentoPeer::doSelect($c); if (count($docs) > 1) { foreach ($docs as $doc) { $testo = $testo . $rs->getId() . " - " . $doc->getTitolo() . "\n"; } $testo = $testo . "------------ \n"; } } echo $testo; mail("*****@*****.**", "ERRORE - Comunicati Governo", $testo, "From: ScriptVotazioniSenato"); ?>
<?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(); $config = array("doctype" => 'auto', "add-xml-decl" => false, "add-xml-space" => false, "assume-xml-procins" => false, "bare" => false, "break-before-br" => false, "clean" => false, "drop-empty-paras" => true, "drop-font-tags" => false, "drop-proprietary-attributes" => false, "enclose-block-text" => false, "enclose-text" => false, "escape-cdata" => false, "fix-bad-comments" => true, "fix-uri" => true, "hide-comments" => false, "hide-endtags" => false, "indent-cdata" => false, "input-xml" => false, "join-classes" => false, "join-styles" => true, "logical-emphasis" => false, "lower-literals" => true, "ncr" => true, "numeric-entities" => false, "output-xhtml" => true, "output-xml" => false, "quote-ampersand" => true, "quote-marks" => false, "quote-nbsp" => true, "repeated-attributes" => true, "replace-color" => false, "show-body-only" => true, "uppercase-attributes" => false, "uppercase-tags" => false, "word-2000" => true, "indent" => false, "indent-attributes" => false, "literal-attributes" => false, "markup" => true, "wrap-asp" => false, "wrap-attributes" => false, "wrap-jste" => true, "wrap-php" => true, "wrap-script-literals" => false, "wrap-sections" => true, "wrap" => 0, "new-empty-tags" => 'cfelse', "ascii-chars" => false); $c = new Criteria(); //$c->add(OppDocumentoPeer::ID,1149); //$c->setLimit(10); $results = OppDocumentoPeer::doSelect($c); foreach ($results as $result) { echo $result->getId() . "\n"; $testo = $result->getTesto(); //echo $testo; $chr_encoding = mb_detect_encoding($testo, 'ASCII,ISO-8859-1,WINDOWS-1252,UTF-8'); echo "*********************" . $chr_encoding . "******************************** \n"; switch ($chr_encoding) { case 'UTF-8': $tidy_enc = 'utf8'; break; case 'ASCII': $tidy_enc = 'ascii'; break; case 'WINDOWS-1252': $tidy_enc = 'win1252'; break; case 'ISO-8859-1': $tidy_enc = 'latin1';