Ejemplo n.º 1
0
 public function getAnswer($r)
 {
     $ident = $r->get('identifier');
     $search_result = Dase_Atom_Feed::retrieve($r->app_root . '/search.atom?c=dase_help&q=@identifier:"' . $ident . '"&limit=100');
     foreach ($search_result->entries as $e) {
         $meta = $e->getMetadata('answer');
         $r->renderResponse($meta['text']);
     }
     $r->renderError(401);
 }
Ejemplo n.º 2
0
 public function getCart($r)
 {
     $u = $this->user;
     $tag = new Dase_DBO_Tag($this->db);
     $tag->dase_user_id = $u->id;
     $tag->type = 'cart';
     if ($tag->findOne()) {
         $t = new Dase_Template($r);
         $json_url = $r->app_root . '/tag/' . $tag->id . '.json';
         $t->assign('json_url', $json_url);
         $t->assign('items', Dase_Atom_Feed::retrieve($r->app_root . '/tag/' . $tag->id . '.atom', $u->eid, $u->getHttpPassword()));
         $t->assign('is_admin', 1);
         if ('list' == $u->display) {
             $t->assign('display', 'list');
         }
         if ($u->can('admin', $tag) && 'hide' != $u->controls_status) {
             $t->assign('bulkedit', 1);
         }
         $r->renderResponse($t->fetch('item_set/tag.tpl'));
     } else {
         $r->renderError(404);
     }
 }
Ejemplo n.º 3
0
 public function postToCreateSample($r)
 {
     $resp = array();
     $url = "http://daseproject.org/collection/sample.atom";
     $feed = Dase_Atom_Feed::retrieve($url);
     $coll_ascii_id = $feed->getAsciiId();
     $feed->ingest($r, true);
     $cm = new Dase_DBO_CollectionManager($this->db);
     $cm->dase_user_eid = $u->eid;
     $cm->collection_ascii_id = $coll_ascii_id;
     $cm->auth_level = 'superuser';
     $cm->created = date(DATE_ATOM);
     $cm->insert();
     $login_url = APP_ROOT . '/login/form';
 }
Ejemplo n.º 4
0
 public function getSearch($r)
 {
     $r->checkCache();
     $tpl = new Dase_Template($r);
     //default slidehow max of 100
     $json_url = $r->app_root . '/' . $r->url . '&format=json&max=100';
     $tpl->assign('json_url', $json_url);
     $feed_url = $r->app_root . '/' . $r->url . '&format=atom';
     $tpl->assign('feed_url', $feed_url);
     $feed = Dase_Atom_Feed::retrieve($feed_url);
     //single hit goes directly to item
     $count = $feed->getCount();
     if (1 == $count) {
         //todo use preg_replace and guarentee only one replacement
         $url = str_replace('search?', 'search/item?', $r->url);
         $r->renderRedirect($r->app_root . '/' . $url . '&num=1');
     }
     if (0 == $count) {
         $coll = $r->get('collection_ascii_id');
         if (!$coll) {
             //won't go back to collection page unless
             //just one collection is being searched
             $coll_array = $r->get('c', true);
             if (1 == count($coll_array)) {
                 $coll = $coll_array[0];
             }
         }
         if ($coll) {
             $params['msg'] = 'no items found';
             $params['failed_query'] = $feed->getQuery();
             $r->renderRedirect($r->app_root . '/collection/' . $coll, $params);
         } else {
             $params['msg'] = 'no items found';
             $params['failed_query'] = $feed->getQuery();
             $r->renderRedirect($r->app_root . '/collections', $params);
         }
     }
     $end = $this->start + $this->max;
     if ($end > $count) {
         $end = $count;
     }
     $tpl->assign('start', $this->start);
     $tpl->assign('end', $end);
     $tpl->assign('sort', $r->get('sort'));
     $tpl->assign('items', $feed);
     if ('list' == $r->get('display')) {
         $tpl->assign('display', 'list');
     } else {
         $tpl->assign('display', 'grid');
     }
     $r->renderResponse($tpl->fetch('item_set/search.tpl'));
 }
Ejemplo n.º 5
0
 public function getSearch($r)
 {
     $tpl = new Dase_Template($r);
     $courses = Dase_Atom_Categories::load(file_get_contents($r->app_root . '/sets/utexas/courses.cats'));
     $tpl->assign('courses', $courses);
     $feed = Dase_Atom_Feed::retrieve($r->app_root . '/tags/search.atom?q=' . $r->get('q'));
     $tpl->assign('sets', $feed);
     $tpl->assign('q', $r->get('q'));
     $r->renderResponse($tpl->fetch('tags/list.tpl'));
 }
Ejemplo n.º 6
0
 public function getItem($r)
 {
     $user = $r->getUser();
     if (!$user->can('read', $this->item)) {
         $r->renderError(401, 'user cannot read this item');
     }
     //a bit inefficient since the setup item get is unecessary, assuming atom feed error reporting
     $t = new Dase_Template($r);
     $feed = Dase_Atom_Feed::retrieve($r->app_root . '/item/' . $r->get('collection_ascii_id') . '/' . $r->get('serial_number') . '.atom?type=feed', $user->eid, $user->getHttpPassword());
     if ($user->can('write', $this->item)) {
         $t->assign('is_admin', 1);
     }
     $t->assign('item', $feed);
     $r->renderResponse($t->fetch('item/display.tpl'));
 }
Ejemplo n.º 7
0
 public function getCollection($r)
 {
     $tpl = new Dase_Template($r);
     $tpl->assign('collection', Dase_Atom_Feed::retrieve($r->app_root . '/collection/' . $r->get('collection_ascii_id') . '.atom'));
     $r->renderResponse($tpl->fetch('collection/browse.tpl'));
 }
Ejemplo n.º 8
0
 public function getTagItem($r)
 {
     $u = $r->getUser();
     $tag_ascii_id = $r->get('tag_ascii_id');
     $tag_item_id = $r->get('tag_item_id');
     $t = new Dase_Template($r);
     //$t->assign('item',Dase_Atom_Feed::retrieve($r->app_root.'/tag/'.$u->eid.'/'.$tag_ascii_id.'/'.$tag_item_id.'?format=atom',$u->eid,$u->getHttpPassword()));
     $t->assign('item', Dase_Atom_Feed::retrieve($r->app_root . '/tag/item/' . $this->tag->id . '/' . $tag_item_id . '?format=atom', $u->eid, $u->getHttpPassword()));
     $r->renderResponse($t->fetch('item/display.tpl'));
 }