public function executeEdit()
 {
     // embed javascripts for edit-in-place and auto-completer
     $response = sfContext::getInstance()->getResponse();
     $response->addJavascript('prototype.js');
     $response->addJavascript('effects.js');
     $response->addJavascript('controls.js');
     $response->addJavascript('/deppPropelActAsTaggableBehaviorPlugin/js/tags_cleaner.js');
     $response->addStylesheet('/deppPropelActAsTaggableBehaviorPlugin/css/depp_tagging.css');
     // read some config parameters and defaults
     $anonymous_tagging = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_anonymous_tagging', get_class($this->content)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_anonymous_tagging', true));
     $allows_tagging_removal = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_allows_tagging_removal', get_class($this->content)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_allows_tagging_removal', 'all'));
     $tagging_removal_credentials = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_tagging_removal_credentials', get_class($this->content)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_tagging_removal_credentials', array()));
     $user = @sfContext::getInstance()->getUser();
     $tags = $this->content->getTags(array());
     $user_tags = array();
     $this->editable_tags_as_string = deppPropelActAsTaggableToolkit::getTagsAsString($tags);
     $user_id = deppPropelActAsTaggableToolkit::getUserId();
     if (!$anonymous_tagging && $user->isAuthenticated() && !is_null($user_id) && $user_id !== '') {
         $user_tags = $this->content->getUserTags(array(), $user_id);
         if ($allows_tagging_removal == 'self' && !$user->hasCredential($tagging_removal_credentials, false)) {
             $this->editable_tags_as_string = deppPropelActAsTaggableToolkit::getTagsAsString($user_tags);
         }
     }
     $this->visible_tags_as_string = deppPropelActAsTaggableToolkit::getTagsAsTaggedString(array('other' => array_diff($tags, $user_tags), 'user' => $user_tags));
     $this->anonymous_tagging = $anonymous_tagging;
 }
 public function executeEdit()
 {
     // embed javascripts for edit-in-place and auto-completer
     $response = sfContext::getInstance()->getResponse();
     $response->addJavascript('prototype.js');
     $response->addJavascript('effects.js');
     $response->addJavascript('controls.js');
     $response->addStylesheet('/deppPropelActAsTaggableBehaviorPlugin/css/depp_tagging.css');
     // read some config parameters and defaults
     $anonymous_tagging = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_anonymous_tagging', get_class($this->content)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_anonymous_tagging', true));
     $allows_tagging_removal = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_allows_tagging_removal', get_class($this->content)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_allows_tagging_removal', 'all'));
     $tagging_removal_credentials = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_tagging_removal_credentials', get_class($this->content)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_tagging_removal_credentials', array()));
     // fetch di TUTTI i tag legati al content (come nomi completi di triple)
     $this->tags = $this->content->getTags(array('is_triple' => true));
     // sono considerati teseo_tags tutti i tag con ns teseo e geoteseo
     $teseo_tags = $this->content->getTags(array('is_triple' => true, 'namespace' => 'teseo', 'return' => 'value'));
     $geo_tags = $this->content->getTags(array('is_triple' => true, 'namespace' => 'geoteseo', 'return' => 'value'));
     $this->teseo_tags = array_merge($teseo_tags, $geo_tags);
     // tag aggiunti da utenti reali (user_id in not null)
     $this->user_tags = $this->content->getUserTags(array('is_triple' => true, 'return' => 'value'));
     $user = @sfContext::getInstance()->getUser();
     $user_id = deppPropelActAsTaggableToolkit::getUserId();
     // i removable_tags sono quelli aggiunti dagli utenti (di default)
     if ($user->isAuthenticated()) {
         $this->removable_tags = $this->user_tags;
     } else {
         $this->removable_tags = array();
     }
     // tag aggiunti dall'utente loggato e override eventuale dei removable_tags
     // (se la configurazione lo prevede)
     $this->my_tags = array();
     if (!$anonymous_tagging && $user->isAuthenticated() && !is_null($user_id) && $user_id !== '') {
         $this->my_tags = $this->content->getUserTags(array('is_triple' => true, 'return' => 'value'), $user_id);
         if ($allows_tagging_removal == 'self' && !$user->hasCredential($tagging_removal_credentials, false)) {
             $this->removable_tags = $this->my_tags;
         }
     }
     $this->anonymous_tagging = $anonymous_tagging;
     $this->allows_tagging_removal = $allows_tagging_removal;
     $this->tagging_removal_credentials = $tagging_removal_credentials;
 }
 public function executeEditAjax()
 {
     // fetch request parameters and taggable content
     $content_id = $this->getRequestParameter('content_id');
     $content_peer = $this->getRequestParameter('content_type') . 'Peer';
     $content = call_user_func(array($content_peer, 'retrieveByPK'), $content_id);
     $tags_as_string = deppPropelActAsTaggableToolkit::getTagsAsString(strip_tags($this->getRequestParameter('usertags')));
     // a setTags remove the tags and add them back
     $content->setTags(tags_as_string);
     $content->save();
     // get all tags, forcing the cache override (directly from the DB)
     $tags = $content->getTags(array(), true);
     // if necessary, get users' tags
     $anonymous_tagging = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_anonymous_tagging', get_class($content)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_anonymous_tagging', true));
     $user = @sfContext::getInstance()->getUser();
     $user_tags = array();
     $user_id = deppPropelActAsTaggableToolkit::getUserId();
     if (!$anonymous_tagging && $user->isAuthenticated() && !is_null($user_id) && $user_id !== '') {
         $user_tags = $content->getUserTags(array(), $user_id);
     }
     // set the value to be returned by AJAX
     // it's the visible string, with <spam> tags
     $this->value = deppPropelActAsTaggableToolkit::getTagsAsTaggedString(array('other' => array_diff($tags, $user_tags), 'user' => $user_tags));
 }
function getNamesFromValues($values)
{
    $tagvalues = explode(",", $values);
    $tagnames = array();
    foreach ($tagvalues as $tagvalue) {
        $c = new Criteria();
        $c->add(TagPeer::TRIPLE_VALUE, $tagvalue);
        $tag = TagPeer::doSelectOne($c);
        if ($tag instanceof Tag) {
            $tagnames[] = $tag->getName();
        } else {
            $tagnames[] = deppPropelActAsTaggableToolkit::transformTagStringIntoTripleString($tagvalue, 'user', 'tag');
        }
    }
    return implode(",", $tagnames);
}
$tagged_with_tag127 = TagPeer::getTaggedWith('tag1, tag2, tag7', array('nb_common_tags' => 2));
$t->ok(count($tagged_with_tag127) == 6, 'the "nb_common_tags" option of getTaggedWith() returns objects tagged with a certain number of tags within a set of specific tags.');
// these tests check the isTaggable() method
$t->diag('detecting if a model is taggable or not');
$t->ok(deppPropelActAsTaggableToolkit::isTaggable(TEST_CLASS) === true, 'it is possible to tell if a model is taggable from its name.');
$object = _create_object();
$t->ok(deppPropelActAsTaggableToolkit::isTaggable($object) === true, 'it is possible to tell if a model is taggable from one of its instances.');
$t->ok(deppPropelActAsTaggableToolkit::isTaggable('Tristan\'s cat') === false, 'Tristan\'s cat is not taggable, and that is fine.');
TagPeer::doDeleteAll();
TaggingPeer::doDeleteAll();
call_user_func(array(_create_object()->getPeer(), 'doDeleteAll'));
// these tests check for the application of triple tags
$t->diag('applying triple tagging');
$t->ok(deppPropelActAsTaggableToolkit::extractTriple('ns:key=value') === array('ns:key=value', 'ns', 'key', 'value'), 'triple extracted successfully.');
$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.');
 /**
  * Removes a tag or a set of tags from the object. As usual, the second
  * parameter might be an array of tags or a comma-separated string.
  *
  * @param      BaseObject  $object
  * @param      mixed       $tagname
  */
 public function removeTagForIndex($tagname)
 {
     $tagname = deppPropelActAsTaggableToolkit::explodeTagString($tagname);
     if (is_array($tagname)) {
         foreach ($tagname as $tag) {
             $this->removeTagForIndex($tag);
         }
     } else {
         $tagname = deppPropelActAsTaggableToolkit::cleanTagName($tagname);
         sfContext::getInstance()->getLogger()->info('{opp_debug}' . $tagname);
         $tag_object = TagPeer::retrieveByTagname($tagname);
         $tagging = TaggingForIndexPeer::retrieveByTagAndAtto($tag_object->getId(), $this->getId());
         $tagging->delete();
     }
 }
 /**
  * Removes a tag or a set of tags from the object. As usual, the second
  * parameter might be an array of tags or a comma-separated string.
  *
  * @param      BaseObject  $object
  * @param      mixed       $tagname
  */
 public function removeTag(BaseObject $object, $tagname)
 {
     $tagname = deppPropelActAsTaggableToolkit::explodeTagString($tagname);
     if (is_array($tagname)) {
         foreach ($tagname as $tag) {
             $this->removeTag($object, $tag);
         }
     } else {
         $tagname = deppPropelActAsTaggableToolkit::cleanTagName($tagname);
         $tags = self::get_tags($object);
         $saved_tags = $this->getSavedTags($object);
         if (isset($tags[$tagname])) {
             unset($tags[$tagname]);
             self::set_tags($object, $tags);
         }
         if (isset($saved_tags[$tagname])) {
             unset($saved_tags[$tagname]);
             self::set_saved_tags($object, $saved_tags);
             self::add_removed_tag($object, $tagname);
         }
     }
 }
<?php

if (count($related_tags) > 0) {
    ?>
<div class="evidence-box float-container">
  
  <h5 class="subsection">Argomenti correlati</h5>
  	<p class="pad10">
  	  <?php 
    foreach ($related_tags as $tag_name => $relevance) {
        ?>
  	    <?php 
        list($tag, $namespace, $key, $value) = deppPropelActAsTaggableToolkit::extractTriple($tag_name);
        ?>
  	    <?php 
        echo link_to(strtolower($value), '@argomento?triple_value=' . $value, array('class' => 'folk' . $relevance));
        ?>
  	    &nbsp;&nbsp;
  	  <?php 
    }
    ?>
  	</p>
  
</div>
<?php 
}
 private function _fetchTags($content)
 {
     // read some config parameters and defaults
     $anonymous_tagging = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_anonymous_tagging', get_class($content)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_anonymous_tagging', true));
     $allows_tagging_removal = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_allows_tagging_removal', get_class($content)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_allows_tagging_removal', 'all'));
     $tagging_removal_credentials = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_tagging_removal_credentials', get_class($content)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_tagging_removal_credentials', array()));
     // fetch the associated tags
     $this->tags = $content->getTags(array('is_triple' => true));
     // sono considerati teseo_tags tutti i tag con ns teseo e geoteseo
     $teseo_tags = $content->getTags(array('is_triple' => true, 'namespace' => 'teseo', 'return' => 'value'));
     $geo_tags = $content->getTags(array('is_triple' => true, 'namespace' => 'geoteseo', 'return' => 'value'));
     $this->teseo_tags = array_merge($teseo_tags, $geo_tags);
     // tag aggiunti da utenti reali (user_id in not null)
     $this->user_tags = $content->getUserTags(array('is_triple' => true, 'return' => 'value'));
     // i removable_tags sono quelli aggiunti dagli utenti (di default)
     $this->removable_tags = $this->user_tags;
     // tag aggiunti dall'utente loggato e override eventuale dei removable_tags
     // (se la configurazione lo prevede)
     $this->my_tags = array();
     $user = @sfContext::getInstance()->getUser();
     $user_id = deppPropelActAsTaggableToolkit::getUserId();
     if (!$anonymous_tagging && $user->isAuthenticated() && !is_null($user_id) && $user_id !== '') {
         $this->my_tags = $content->getUserTags(array('is_triple' => true, 'return' => 'value'), $user_id);
         if ($allows_tagging_removal == 'self' && !$user->hasCredential($tagging_removal_credentials, false)) {
             $this->removable_tags = $this->my_tags;
         }
     }
 }
Esempio n. 10
0
 /**
  * Retrieves a tag by his triple_name (given the whole triplet string). 
  * If it does not exist, creates it (but does not
  * save it)
  * If tags exist, having that triple value, then return the FIRST ONE
  *
  * @param      String      $tagname  the whole triplet
  * @return     Tag
  */
 public static function retrieveOrCreateByTripleValue($tagname)
 {
     // retrieve or create the tag
     $triple = deppPropelActAsTaggableToolkit::extractTriple($tagname);
     list($tagname, $triple_namespace, $triple_key, $triple_value) = $triple;
     $tag = self::retrieveFirstByTripleValue($triple_value);
     if (!$tag) {
         $tag = new Tag();
         $tag->setName($tagname);
         $tag->setTripleNamespace($triple_namespace);
         $tag->setTripleKey($triple_key);
         $tag->setTripleValue($triple_value);
         $tag->setIsTriple(!is_null($triple_namespace));
     }
     return $tag;
 }