예제 #1
0
 public static function recordTags($phrase, $model, $obj)
 {
     $tags = TagTools::splitPhrase($phrase);
     foreach ($tags as $settag) {
         $tag = new Tag();
         if ($model == "etime") {
             $modelTag = new EtimeTag();
         } else {
             $modelTag = new EventTag();
         }
         $tag->setTag($settag);
         $c = new Criteria();
         $c->add(TagPeer::NORMALIZED_TAG, $tag->getNormalizedTag());
         $tag_exists = TagPeer::doSelectOne($c);
         if (!$tag_exists) {
             $tag->save();
         } else {
             $tag = $tag_exists;
         }
         if ($model == "etime") {
             $modelTag->setEtime($obj);
         } else {
             $modelTag->setEvent($obj);
         }
         $modelTag->setTag($tag);
         $modelTag->save();
     }
     return true;
 }
예제 #2
0
 /**
  * Executes index action
  *
  */
 public function executeShow()
 {
     $c = new Criteria();
     $c->add(TagPeer::NORMALIZED_TAG, $this->getRequestParameter('tag'));
     $this->tag = TagPeer::doSelectOne($c);
     $this->events = EventPeer::getTaggedEvents($this->getRequestParameter('tag'));
     $this->forward404Unless($this->events);
 }
 protected function doClean($value)
 {
     $criteria = new Criteria();
     $criteria->add(TagPeer::JOTAG, $value);
     $object = TagPeer::doSelectOne($criteria);
     if (is_null($object)) {
         throw new sfValidatorError($this, 'invalid', array('value' => $value));
     }
     return $object->getId();
 }
예제 #4
0
 private function listTags()
 {
     $c = new Criteria();
     $c->add(TagPeer::NAME, $this->getRequestParameter('name'));
     $tag = TagPeer::doSelectOne($c);
     $this->getResponse()->setTitle(sprintf('Planeta PHP.pl - Wpisy dla tagu: %s', $tag->getName()));
     $c = new Criteria();
     $c->addJoin(PostTagPeer::POST_ID, PostPeer::ID, Criteria::LEFT_JOIN);
     $c->add(PostTagPeer::TAG_ID, $tag->getId());
     return $c;
 }
예제 #5
0
 public function executeIndex()
 {
     $name = $this->getRequestParameter('tag', '');
     $c = new Criteria();
     if ($name) {
         $c->add(TagPeer::NAME, $name);
         $tag = TagPeer::doSelectOne($c);
         $this->forward404Unless($tag);
         $c->clear();
         $c->addJoin(PostTagPeer::POST_ID, PostPeer::ID, Criteria::LEFT_JOIN);
         $c->add(PostTagPeer::TAG_ID, $tag->getId());
     }
     $c->addDescendingOrderByColumn(PostPeer::CREATED_AT);
     $c->setLimit(sfConfig::get('app_posts_in_feed', 10));
     $c->add(PostPeer::DELETED, false);
     $posts = PostPeer::doSelect($c);
     $this->feed = $this->createFeed($posts, $name);
     ReaderPeer::increment();
 }
예제 #6
0
파일: Topic.php 프로젝트: kotow/work
 public function getIndexPage()
 {
     try {
         $c = new Criteria();
         $c->add(TagPeer::TAG_ID, 'website_page_index');
         $tag = TagPeer::doSelectOne($c);
         $c = new Criteria();
         $c->add(RelationPeer::ID1, $this->getId());
         $c->addJoin(RelationPeer::ID2, TagrelationPeer::ID);
         $c->add(TagrelationPeer::TAG_ID, $tag->getId());
         $relation = RelationPeer::doSelectOne($c);
         if ($relation) {
             $indexPage = Document::getDocumentInstance($relation->getId2());
             return $indexPage;
         } else {
             return null;
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
예제 #7
0
 /**
  * Get the associated Tag object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Tag The associated Tag object.
  * @throws     PropelException
  */
 public function getTag(PropelPDO $con = null)
 {
     if ($this->aTag === null && $this->tag_id !== null) {
         $c = new Criteria(TagPeer::DATABASE_NAME);
         $c->add(TagPeer::ID, $this->tag_id);
         $this->aTag = TagPeer::doSelectOne($c, $con);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aTag->addTaggings($this);
         		 */
     }
     return $this->aTag;
 }
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);
}
define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/../..'));
define('SF_APP', 'fe');
define('SF_ENVIRONMENT', 'dev');
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();
include "../parser/lista_tags_macrotags.php";
if (count($tags) == count($macrotags)) {
    //Tagga OGGETTI TAGGATI con $tag anche con $macrotag
    foreach ($tags as $k => $tag) {
        $c = new Criteria();
        $c->add(TagPeer::ID, $tag);
        $result = TagPeer::doSelectOne($c);
        if ($result) {
            for ($x = 0; $x <= 1; $x++) {
                $c = new Criteria();
                $c->add(TagPeer::ID, $macrotags[$k][$x]);
                $mt = TagPeer::doSelectOne($c);
                if ($mt) {
                    echo $result->getId() . "\t" . $result->getTripleValue() . "\t" . $mt->getId() . "\t" . $mt->getTripleValue() . "\n";
                } elseif ($macrotags[$k][$x] != 0) {
                    echo "!!!! " . $result->getId() . "\t" . $result->getTripleValue() . " \t errore non esiste macrotag=\t" . $macrotags[$k][$x] . "\n";
                }
            }
        } else {
            echo "!!!! \terrore non esiste TAG=\t" . $tag . "\t\n";
        }
    }
} else {
    echo "!!!!! Gli array hanno un numero di elementi diversi!";
}
예제 #10
0
 /**
  * Retrives a tag by his name.
  *
  * @param      String      $tagname
  * @return     Tag
  */
 public static function retrieveByTagname($tagname)
 {
     $c = new Criteria();
     $c->add(TagPeer::NAME, $tagname);
     return TagPeer::doSelectOne($c);
 }
예제 #11
0
파일: Document.php 프로젝트: kotow/work
 public static function getDocumentsByTag($tagId)
 {
     try {
         if (BackendService::loadTagsRelations()) {
             if (array_key_exists('tagsRelations', $_SESSION) && array_key_exists($tagId, $_SESSION['tagsRelations'])) {
                 $docs = $_SESSION['tagsRelations'][$tagId];
             }
             foreach ($docs as $docId) {
                 $document = self::getDocumentInstance($docId);
                 if ($document) {
                     $documents[] = $document;
                 }
             }
         } else {
             $c = new Criteria();
             $c->add(TagPeer::TAG_ID, $tagId);
             $tag = TagPeer::doSelectOne($c);
             if (!$tag) {
                 return null;
             }
             $c = new Criteria();
             $c->add(TagrelationPeer::TAG_ID, $tag->getId());
             $tagRelations = TagrelationPeer::doSelect($c);
             $documents = array();
             foreach ($tagRelations as $tagRelation) {
                 $document = self::getDocumentInstance($tagRelation->getId());
                 if ($document) {
                     $documents[] = $document;
                 }
             }
         }
         return $documents;
     } catch (Exception $e) {
         return null;
     }
 }
예제 #12
0
 /**
  * extracts an id from a value   
  *
  * @param string $value (triple value)
  * @return id
  * @author Guglielmo Celata
  */
 public static function getIdFromTagValue($tag_value)
 {
     $c = new Criteria();
     $c->add(TagPeer::TRIPLE_VALUE, $tag_value);
     $tag = TagPeer::doSelectOne($c);
     if ($tag instanceof Tag) {
         return $tag->getId();
     } else {
         return null;
     }
 }