예제 #1
0
파일: Tag.php 프로젝트: rakeshraushan/dase
 public static function listAsFeed($db, $app_root, $category = '')
 {
     //public ONLY!!!!!!
     $feed = new Dase_Atom_Feed();
     $feed->setId($app_root . '/sets');
     $feed->setFeedType('sets');
     $feed->setUpdated(date(DATE_ATOM));
     $feed->addAuthor();
     if ($category) {
         $scheme = '';
         $parts = explode('}', $category);
         if (1 == count($parts)) {
             $term = $parts[0];
         } elseif (2 == count($parts)) {
             $scheme = urldecode(trim($parts[0], '{'));
             $scheme = str_replace('http://daseproject.org/category/', '', $scheme);
             $term = $parts[1];
         } else {
             return $feed->asXml();
         }
         /***************newly refactored*******************/
         $tag_cat = new Dase_DBO_TagCategory($db);
         $tag_cat->term = $term;
         $tag_cat->scheme = $scheme;
         $in_set = array();
         $category_label = $term;
         foreach ($tag_cat->find() as $tc) {
             $in_set[] = $tc->tag_id;
             $category_label = $tc->label;
         }
         $feed->setTitle('Sets for ' . $category_label);
         $tags = new Dase_DBO_Tag($db);
         $tags->is_public = true;
         $tags->orderBy('updated DESC');
         foreach ($tags->find() as $tag) {
             $tag = clone $tag;
             if (!$tag->item_count) {
                 $tag->updateItemCount();
             }
             if ($tag->ascii_id and in_array($tag->id, $in_set)) {
                 $entry = $tag->injectAtomEntryData($feed->addEntry('set'), null, $app_root);
                 $entry->addCategory($tag->item_count, "http://daseproject.org/category/item_count");
             }
         }
         /*********************************************/
     } else {
         $feed->setTitle('All Public Sets');
         $tags = new Dase_DBO_Tag($db);
         $tags->is_public = true;
         $tags->orderBy('updated DESC');
         foreach ($tags->find() as $tag) {
             $tag = clone $tag;
             if (!$tag->item_count) {
                 $tag->updateItemCount();
             }
             if ($tag->ascii_id) {
                 //compat: make sure tag has ascii_id
                 $entry = $tag->injectAtomEntryData($feed->addEntry('set'), null, $app_root);
                 $entry->addCategory($tag->item_count, "http://daseproject.org/category/item_count");
             }
         }
     }
     $feed->sortByTitle();
     return $feed->asXml();
 }
예제 #2
0
 function getTagsAsAtom($app_root)
 {
     $feed = new Dase_Atom_Feed();
     $feed->setTitle($this->eid . ' sets');
     $feed->setId($app_root . '/user/' . $this->eid . '/sets');
     $feed->setFeedType('sets');
     $feed->setUpdated(date(DATE_ATOM));
     $feed->addAuthor();
     $tags = new Dase_DBO_Tag($this->db);
     $tags->dase_user_id = $this->id;
     $tags->orderBy('updated DESC');
     $tag_count_lookup = $this->getTagCountLookup();
     foreach ($tags->find() as $tag) {
         if ($tag->ascii_id) {
             //compat: make sure tag has ascii_id
             if (isset($tag_count_lookup[$tag->id])) {
                 $count = $tag_count_lookup[$tag->id];
             } else {
                 $count = 0;
             }
             $entry = $tag->injectAtomEntryData($feed->addEntry('set'), $this, $app_root);
             $entry->addCategory($count, "http://daseproject.org/category/item_count");
         }
     }
     return $feed->asXml();
 }