public static function getJobIdsByTag($tag) { $c = new Criteria(); $c->add(TaggingPeer::TAG_ID, $tag->getId()); $c->add(TaggingPeer::TAGGABLE_MODEL, "Job"); $ids = array(); $taggings = TaggingPeer::doSelect($c); foreach ($taggings as $t) { $ids[] = $t->getTaggableId(); } return $ids; }
private function reloadByTag($tagId) { $c = new Criteria(); $this->routeObject = TagPeer::retrieveByPK($tagId); $ids = TaggingPeer::getJobIdsByTag($this->routeObject); $c->add(JobPeer::ID, $ids, Criteria::IN); $this->route = "job_listby_tag"; $this->propelType = "name"; $this->renderStatus = true; $this->viewingCaption = " taggings for " . $this->routeObject->__toString(); return $c; }
/** * Returns the number of related Tagging objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Tagging objects. * @throws PropelException */ public function countTaggings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(TagPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collTaggings === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(TaggingPeer::TAG_ID, $this->id); $count = TaggingPeer::doCount($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return count of the collection. $criteria->add(TaggingPeer::TAG_ID, $this->id); if (!isset($this->lastTaggingCriteria) || !$this->lastTaggingCriteria->equals($criteria)) { $count = TaggingPeer::doCount($criteria, $con); } else { $count = count($this->collTaggings); } } else { $count = count($this->collTaggings); } } return $count; }
/** * Tags saving logic, runned after the object himself has been saved * * @param BaseObject $object */ public function postSave(BaseObject $object) { $tags = self::get_tags($object); $removed_tags = self::get_removed_tags($object); // save new tags foreach ($tags as $tagname) { $tag = TagPeer::retrieveOrCreateByTagName($tagname); $tag->save(); $tagging = new Tagging(); $tagging->setTagId($tag->getId()); $tagging->setTaggableId($object->getPrimaryKey()); $tagging->setTaggableModel(get_class($object)); $tagging->save(); } // remove removed tags $c = new Criteria(); $c->add(TagPeer::NAME, $removed_tags, Criteria::IN); $rs = TagPeer::doSelectRS($c); $removed_tag_ids = array(); while ($rs->next()) { $removed_tag_ids[] = $rs->getInt(1); } $c = new Criteria(); $c->add(TaggingPeer::TAG_ID, $removed_tag_ids, Criteria::IN); $c->add(TaggingPeer::TAGGABLE_ID, $object->getPrimaryKey()); $c->add(TaggingPeer::TAGGABLE_MODEL, get_class($object)); TaggingPeer::doDelete($c); $tags = array_merge(self::get_tags($object), $this->getSavedTags($object)); self::set_saved_tags($object, $tags); self::clear_tags($object); self::clear_removed_tags($object); }
<?php define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/../..')); define('SF_APP', 'fe'); define('SF_ENVIRONMENT', 'prod'); 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(); /** * Lo script prepara la normaliazzione dei tag di openparlamento * */ // estraggo tutti i tag di opp con il numero di atti (no emendamenti) associati $tagToDdl = TaggingPeer::CountTagForAtti('OppAtto', "('teseo')"); $tagToEm = TaggingPeer::CountTagForAtti('OppEmendamento', "('teseo')"); $tagToAll = array(); foreach ($tagToDdl as $key => $value) { if (array_key_exists($key, $tagToEm)) { $tagToAll[$key] = array($value[0], $value[1], $tagToEm[$key][1]); } else { $tagToAll[$key] = array($value[0], $value[1], 0); } } foreach ($tagToEm as $key => $value) { if (!array_key_exists($key, $tagToAll)) { $tagToAll[$key] = array($value[0], 0, $value[1]); } } foreach ($tagToAll as $key => $value) { echo $key . "\t" . $value[0] . "\t" . $value[1] . "\t" . $value[2] . "\n"; }
/** * torna array di tag id * * @return array of ID * @author Guglielmo Celata */ public function getTagsIds() { $tags_ids = TaggingPeer::getTagIDsByTaggableIDAndTaggableModel($this->getId(), 'OppAtto'); return $tags_ids; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(TaggingPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(TaggingPeer::DATABASE_NAME); $criteria->add(TaggingPeer::ID, $pks, Criteria::IN); $objs = TaggingPeer::doSelect($criteria, $con); } return $objs; }
$result[] = $tag->getName(); } $t->ok($result === array('ns:key=value', 'ns:key=tutu', 'ns:key=titi', 'ns:key=toto'), 'it is possible to search for triple tags by key.'); $tags_triple = TagPeer::getAll(null, array('triple' => true, 'value' => 'tutu')); $result = array(); foreach ($tags_triple as $tag) { $result[] = $tag->getName(); } $t->ok($result === array('ns:key=tutu'), 'it is possible to search for triple tags by value.'); $objects_triple = TagPeer::getTaggedWith(array(), array('namespace' => 'ns', 'model' => 'Post')); $t->ok(count($objects_triple) == 1, 'it is possible to retrieve objects tagged with certain triple tags.'); // these tests check for the behavior of the triple tags when the plugin is set // up so that namespace:key is a unique key // clean the database TagPeer::doDeleteAll(); TaggingPeer::doDeleteAll(); call_user_func(array(_create_object()->getPeer(), 'doDeleteAll')); sfConfig::set('app_deppPropelActAsTaggableBehaviorPlugin_triple_distinct', true); $t->diag('querying triple tagging'); $object = _create_object(); $object->addTag('tutu'); $object->save(); $object = _create_object(); $object->addTag('ns:key=value'); $object->addTag('ns:key=tutu'); $object->addTag('ns:key=titi'); $object->addTag('ns:second_key=toto'); $object->save(); $tags_triple = TagPeer::getAll(null, array('triple' => true, 'namespace' => 'ns')); $t->ok(count($tags_triple) == 2, 'it is possible to set up the plugin so that namespace:key is a unique key.'); $object2 = _create_object();
public function executeDdl2argomenti() { $this->tags = array(); $c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(TaggingPeer::TAG_ID); $c->addAsColumn("numtag", "COUNT(" . TaggingPeer::TAG_ID . ")"); $c->addJoin(TaggingPeer::TAGGABLE_ID, OppAttoPeer::ID); $c->add(TaggingPeer::TAGGABLE_MODEL, 'OppAtto'); $c->add(OppAttoPeer::TIPO_ATTO_ID, 1); $c->add(OppAttoPeer::LEGISLATURA, $this->leg); if ($this->approvato == true) { $c->addJoin(OppAttoPeer::ID, OppAttoHasIterPeer::ATTO_ID); $c->add(OppAttoHasIterPeer::ITER_ID, 16); } $c->addGroupByColumn("TAG_ID"); $c->addDescendingOrderByColumn("numtag"); $rs = TaggingPeer::doSelectRS($c); while ($rs->next()) { $this->tags[] = array($rs->getInt(1), $rs->getInt(2)); } }
/** * Calcola o ri-calcola la rilevanza degli argomenti, come somma della rilevanza degli atti taggati * Si può specificare il una data fino alla quale calcolare la rilevanza * Se sono passati degli ID (argomenti), sono interpretati come ID di argomenti e il calcolo è fatto solo per loro */ function run_opp_build_cache_tags($task, $args, $options) { static $loaded; // load application context if (!$loaded) { _loader(); } echo "memory usage: " . memory_get_usage() . "\n"; $data = ''; $verbose = false; $offset = null; $limit = null; $start_time = time(); if (array_key_exists('data', $options)) { $data = $options['data']; } 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 ($data != '') { $legislatura_corrente = OppLegislaturaPeer::getCurrent($data); $data_lookup = $data; } else { $legislatura_corrente = OppLegislaturaPeer::getCurrent(); $data = date('Y-m-d'); $data_lookup = OppTagHistoryCachePeer::fetchLastData(); } $msg = sprintf("calcolo rilevanza tag - fino a: %10s\n", $data); echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true)); if (count($args) > 0) { $tags_ids = $args; } else { $tags_ids = TaggingPeer::getActiveTagsIds('OppAtto'); } $n_tags = count($tags_ids); echo "memory usage: " . memory_get_usage() . "\n"; foreach ($tags_ids as $cnt => $tag_id) { printf("%5d/%6d) %40s %6d ... ", $cnt + 1, $n_tags, TagPeer::retrieveByPK($tag_id), $tag_id); $indice = OppIndiceRilevanzaPeer::calcola_rilevanza_tag($tag_id, $data, $verbose); // inserimento o aggiornamento del valore in opp_tag_history_cache $cache_record = OppTagHistoryCachePeer::retrieveByDataChiTipoChiId($data_lookup, 'S', $tag_id); if (!$cache_record) { $cache_record = new OppTagHistoryCache(); } $cache_record->setLegislatura($legislatura_corrente); $cache_record->setChiTipo('S'); $cache_record->setChiId($tag_id); $cache_record->setIndice($indice); $cache_record->setData($data); $cache_record->setUpdatedAt(date('Y-m-d H:i')); // forza riscrittura updated_at, per tenere traccia esecuzioni $cache_record->save(); unset($cache_record); $msg = sprintf("%7.2f", $indice); 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)); } $msg = sprintf("%d tag elaborati\n", $cnt + 1); echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true)); }
<?php /* * 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. * find all taggings related to a non-existing opp_atto record and remove them * */ 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(); $cnt = 0; echo "Processing all taggings\n"; $c = new Criteria(); $taggings = TaggingPeer::doSelect($c); foreach ($taggings as $i => $tagging) { $atto = $tagging->getTaggedAtto(); if (!$atto instanceof OppAtto) { $cnt++; echo $tagging->getID() . " - " . $tagging->getTaggableId() . "\n"; $tagging->delete(); } } echo "\n{$i} taggings processed ({$cnt} broken links deleted)\n";
$sfTag = TagPeer::retrieveOrCreateByTagname("{$teseo_tag_tipo_name}:{$teseo_tag_id}={$teseo_tag_value}"); $sfTag->save(); foreach ($teseo_tag->getOppTeseoHasTeseotts() as $teseo_tt) { $tt_id = $teseo_tt->getOppTeseott()->getId(); $tt_denominazione = $teseo_tt->getOppTeseott()->getDenominazione(); echo " TT" . $tt_id . ": " . $tt_denominazione . "\n"; $tt = OppTagHasTtPeer::retrieveByPK($sfTag->getId(), $tt_id); if (!$tt instanceof OppTagHasTt) { $tt = new OppTagHasTt(); } $tt->setTagId($sfTag->getId()); $tt->setTeseoTtId($tt_id); $tt->save(); } foreach ($teseo_tag->getOppAttoHasTeseos() as $atto_tag) { if (!$atto_tag->getOppAtto() instanceof OppAtto) { continue; } $atto_id = $atto_tag->getOppAtto()->getId(); $taggable_model = 'OppAtto'; echo " A" . $atto_id . ": " . substr($atto_tag->getOppAtto()->getTitolo(), 0, 80) . "\n"; $atto_has_tag = TaggingPeer::retrieveByTagAndTaggable($sfTag->getId(), $atto_id, $taggable_model); if (!$atto_has_tag instanceof Tagging) { $atto_has_tag = new Tagging(); } $atto_has_tag->setTagId($sfTag->getId()); $atto_has_tag->setTaggableId($atto_id); $atto_has_tag->setTaggableModel($taggable_model); $atto_has_tag->save(); } }
public function executeAutocomplete(sfWebRequest $request) { $this->renderText(json_encode(TaggingPeer::getNamesForAutocomplete($request->getParameter("q")))); return sfView::NONE; }
/** * calcola l'indice di rilevanza accumulato fino a una certa data, per un tag * come somma degli indici di rilevanza di tutti gli atti taggati con quel tag * * @param integer $tag_id * @param date $data * @param SimpleXMLElement $xml_node * @param boolean $verbose * @return float * @author Guglielmo Celata */ public static function calcolaRilevanzaTag($tag_id, $data, $xml_node, $verbose = false) { $tag_node = $xml_node->addChild('tag', null, self::$opp_ns); // estrazione array atti taggati con un tag $atti_ids = TaggingPeer::getTaggableIds($tag_id, 'OppAtto'); if ($verbose) { printf("tag: %10s\n", $tag_id); } $tag_node->addAttribute('id', $tag_id); $tag_node->addAttribute('n_atti', count($atti_ids)); $punteggio = 0.0; // --- estrazione rilevanza singoli atti --- foreach ($atti_ids as $cnt => $atto_id) { $punteggio += $d_punteggio = OppActHistoryCachePeer::getIndiceForAttoData($atto_id, $data); $atto_node = $tag_node->addChild('atto', null, self::$opp_ns); $atto_node->addAttribute('totale', $d_punteggio); $atto_node->addAttribute('atto_id', $atto_id); if ($verbose) { printf("atto: %10s totale: %7.2f\n", $atto_id, $d_punteggio); } } $tag_node->addAttribute('totale', $punteggio); return $punteggio; }
/** * 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 è 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\'è 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("È 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 = 'è 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 == 'è 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>è 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 = 'è 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 == 'è 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 = 'è 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 == 'è 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>è 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 = 'è 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 != 'è 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>è 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 è svolta la votazione finale</strong>', '@votazione?' . $generator->getOppVotazione()->getUrlParams()); } else { $news_string .= " si è 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 .= "è 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 .= " è 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 è 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 .= "è 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 . " è 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; }
/** * Tags saving logic, runned after the object himself has been saved * * @param BaseObject $object */ public function postSave(BaseObject $object) { $tags = self::get_tags($object); $removed_tags = self::get_removed_tags($object); // read some config parameters and defaults $anonymous_tagging = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_anonymous_tagging', get_class($object)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_anonymous_tagging', true)); $allows_tagging_removal = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_allows_tagging_removal', get_class($object)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_allows_tagging_removal', 'all')); $tagging_removal_credentials = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_tagging_removal_credentials', get_class($object)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_tagging_removal_credentials', array())); $use_unique_triple_values = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_use_unique_triple_values', get_class($object)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_use_unique_triple_values', false)); $user = @sfContext::getInstance()->getUser(); // save new tags foreach ($tags as $tagname) { if ($use_unique_triple_values) { $tag = TagPeer::retrieveOrCreateByTripleValue($tagname); } else { $tag = TagPeer::retrieveOrCreateByTagName($tagname); } $tag->save(); $tagging = TaggingPeer::retrieveOrCreateByTagAndTaggable($tag->getId(), $object->getPrimaryKey(), get_class($object)); $user_id = deppPropelActAsTaggableToolkit::getUserId(); if (!$anonymous_tagging && $user->isAuthenticated() && !is_null($user_id) && $user_id != '') { if ($tagging->isNew()) { $tagging->setUserId($user_id); } } $tagging->save(); } // remove removed tags $removed_tag_ids = array(); $c = new Criteria(); $c->add(TagPeer::NAME, $removed_tags, Criteria::IN); if (Propel::VERSION >= '1.3') { $rs = TagPeer::doSelectStmt($c); while ($row = $rs->fetch(PDO::FETCH_ASSOC)) { $removed_tag_ids[] = intval($row['ID']); } } else { $rs = TagPeer::doSelectRS($c); while ($rs->next()) { $removed_tag_ids[] = $rs->getInt(1); } } $c = new Criteria(); $c->add(TaggingPeer::TAG_ID, $removed_tag_ids, Criteria::IN); $c->add(TaggingPeer::TAGGABLE_ID, $object->getPrimaryKey()); $c->add(TaggingPeer::TAGGABLE_MODEL, get_class($object)); $user_id = deppPropelActAsTaggableToolkit::getUserId(); // for authenticated users that do not have tagging_removal_credentials // if the only tags they're allowed to remove are their own // then, remove only those tags // this only works, if anonymnous_tagging is set to false if (!$anonymous_tagging && $user->isAuthenticated() && !is_null($user_id) && $user_id != '' && $allows_tagging_removal == 'self' && !$user->hasCredential($tagging_removal_credentials, false)) { $c->add(TaggingPeer::USER_ID, $user_id); } // delete e non doDelete, in modo che anche sul tagging si possano attivare i behavior (per le news) // TaggingPeer::doDelete($c); $tags_to_delete = TaggingPeer::doSelect($c); foreach ($tags_to_delete as $tag_to_delete) { $tag_to_delete->delete(); } $tags = array_merge(self::get_tags($object), $this->getSavedTags($object)); self::set_saved_tags($object, $tags); self::clear_tags($object); self::clear_removed_tags($object); }
public function countTaggings($criteria = null, $distinct = false, $con = null) { include_once 'plugins/sfPropelActAsTaggableBehaviorPlugin/lib/model/om/BaseTaggingPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } $criteria->add(TaggingPeer::TAG_ID, $this->getID()); return TaggingPeer::doCount($criteria, $distinct, $con); }
if (count($tag_old) == count($tag_new)) { $number_tagging_ok = 0; $number_tagging_no = 0; //SOSTITUISCI OGGETTI TAGGATI CON NUOVO TAG foreach ($tag_old as $k => $old) { $c = new Criteria(); $c->add(TaggingPeer::TAG_ID, $old); $results = TaggingPeer::doSelect($c); foreach ($results as $rs) { $obj_tag = TagPeer::retrieveByPk($tag_new[$k]); if ($obj_tag) { $c = new Criteria(); $c->add(TaggingPeer::TAG_ID, $tag_new[$k]); $c->add(TaggingPeer::TAGGABLE_ID, $rs->getTaggableId()); $c->add(TaggingPeer::TAGGABLE_MODEL, $rs->getTaggableModel()); $r = TaggingPeer::doSelectOne($c); if (!$r) { $rs->setTagId($tag_new[$k]); $rs->save(); echo "sostituito " . $old . " con " . $tag_new[$k] . " in " . $rs->getTaggableId() . "\n"; $number_tagging_ok = $number_tagging_ok + 1; } else { $rs->delete(); $number_tagging_no = $number_tagging_no + 1; } } else { echo "non esiste tag con id=" . $tag_new[$k] . "\n"; } } } //SOSTITUISCI TAG MONITORATI CON NUOVO TAG
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = TaggingPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setID($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setTagId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setTaggableModel($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setTaggableId($arr[$keys[3]]); } }
/** * This is a method for emulating ON DELETE CASCADE for DBs that don't support this * feature (like MySQL or SQLite). * * This method is not very speedy because it must perform a query first to get * the implicated records and then perform the deletes by calling those Peer classes. * * This method should be used within a transaction if possible. * * @param Criteria $criteria * @param PropelPDO $con * @return int The number of affected rows (if supported by underlying database driver). */ protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con) { // initialize var to track total num of affected rows $affectedRows = 0; // first find the objects that are implicated by the $criteria $objects = TagPeer::doSelect($criteria, $con); foreach ($objects as $obj) { // delete related Tagging objects $c = new Criteria(TaggingPeer::DATABASE_NAME); $c->add(TaggingPeer::TAG_ID, $obj->getID()); $affectedRows += TaggingPeer::doDelete($c, $con); } return $affectedRows; }