$t->ok(deppPropelActAsTaggableToolkit::extractTriple('ns:key') === array('ns:key', null, null, null), 'ns:key is not a triple.'); $t->ok(deppPropelActAsTaggableToolkit::extractTriple('ns') === array('ns', null, null, null), 'ns is not a triple.'); $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:key=toto'); $object->save(); $object_tags = $object->getTags(); $t->ok($object->hasTag('ns:key=value'), 'object has triple tag'); $tag = TagPeer::retrieveOrCreateByTagname('ns:key=value'); $t->ok($tag->getIsTriple(), 'a triple tag created from a string is identified as a triple.'); $tag = TagPeer::retrieveOrCreateByTagname('tutu'); $t->ok(!$tag->getIsTriple(), 'a non tripled tag created from a string is not identified as a triple.'); // these tests check the retrieval of the tags of one object, based on // triple-tags constraints $t->diag('retrieving triple tags, and extracting only parts of it'); $object = _create_object(); $object->addTag('geo:lat=50.7'); $object->addTag('geo:long=6.1'); $object->addTag('de:city=Aachen'); $object->addTag('fr:city=Aix la Chapelle'); $object->addTag('en:city=Aix Chapel'); $object->save(); // get all the tags $tags = $object->getTags(); $t->ok(count($tags) == 5, 'The addTags() method permits to create triple tags, that can be retrieved using getTags().'); $id = $object->getPrimaryKey();
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(); $c = new Criteria(); $teseo_tags = OppTeseoPeer::doSelect($c); foreach ($teseo_tags as $teseo_tag) { $teseo_tag_id = $teseo_tag->getId(); $teseo_tag_value = trim($teseo_tag->getDenominazione()); $teseo_tag_tipo_id = $teseo_tag->getTipoTeseoId(); if ($teseo_tag_tipo_id == 0) { continue; } $teseo_tag_tipo = OppTipoTeseoPeer::retrieveByPK($teseo_tag_tipo_id); $teseo_tag_tipo_name = $teseo_tag_tipo->getTipo(); echo $teseo_tag_id . ": " . $teseo_tag_value . "\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) {