dmBridge PHP API
DMAPICollectionController.php
00001 <?php
00002 #
00003 # dmBridge: a data access framework for CONTENTdm(R)
00004 #
00005 # Copyright © 2009, 2010, 2011 Board of Regents of the Nevada System of Higher
00006 # Education, on behalf of the University of Nevada, Las Vegas
00007 #
00008 
00013 class DMAPICollectionController extends DMAbstractController {
00014 
00015    public function index() {
00016       $collections = array();
00017       foreach (DMCollection::getAuthorized() as $c) {
00018          $collections[] = $c;
00019       }
00020 
00021       $response = new DMHTTPResponse();
00022       $rep = DMHTTPResponseFactory::getRepresentation();
00023       $trans = DMHTTPResponseFactory::getTransformer();
00024       $rep->setBody($trans->transformCollections(DMCollection::getAuthorized()));
00025       $response->setRepresentation($rep);
00026       $response->send();
00027       die;
00028    }
00029 
00033    public function view($alias) {
00034       $alias = DMCollection::getSanitizedAlias($alias);
00035       if (!DMCollection::exists($alias)) {
00036          throw new DMUnavailableModelException("Invalid collection.");
00037       }
00038 
00039       $collection = DMCollectionFactory::getCollection($alias);
00040 
00041       $response = new DMHTTPResponse();
00042       $rep = DMHTTPResponseFactory::getRepresentation();
00043       $trans = DMHTTPResponseFactory::getTransformer();
00044       $rep->setBody($trans->transformCollection($collection));
00045       $response->setRepresentation($rep);
00046       $response->send();
00047       die;
00048    }
00049 
00050 }
 All Data Structures Functions Variables