dmBridge PHP API
DMTESearchController.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 
00016 class DMTESearchController extends DMAbstractController {
00017 
00018    public function index($alias) {
00019       $alias = (strlen($alias)) ? $alias : "/dmdefault";
00020       $col = DMCollectionFactory::getCollection(
00021             DMCollection::getSanitizedAlias($alias));
00022 
00023       $ts = $this->getTemplateSet();
00024       if (!$ts) {
00025          throw new DMUnavailableModelException(
00026                DMLocalizedString::getString("INVALID_TPL_SET"));
00027       }
00028       $allowed_collections = $ts->getAuthorizedCollections();
00029       $col = (count($allowed_collections) == 1)
00030          ? $allowed_collections[0] : $col;
00031 
00032       // make sure we aren't viewing something we shouldn't be
00033       try {
00034          if (!$this->getTemplateSet()->isAuthorizedToViewCollection($col)) {
00035             throw new DMSecurityException(
00036                DMLocalizedString::getString("ACCESS_DENIED_TO_COL"));
00037          }
00038       } catch (DMSecurityException $e) {
00039          require_once($this->getTemplateSet()->getErrorTemplate()
00040                ->getAbsolutePathname());
00041          die;
00042       }
00043 
00044       // entering this view should erase any browse/search results we had
00045       // generated previously
00046       $this->getSession()->unsetQuery();
00047       $this->getSession()->unsetResultsView();
00048 
00049       // Render compound or single template depending on what the object is
00050       $path = "/templates/search/index.html.php";
00051       $tpl = $this->getTemplateSet()->getTemplateAtPathname($path);
00052       global $view;
00053       $view = new DMSearchView($tpl, $this->getSession(),
00054             $col);
00055    }
00056 
00057 }
00058 
 All Data Structures Functions Variables