dmBridge PHP API
DMObjectView.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 
00015 class DMObjectView extends DMTemplateEngineView implements DMURIAddressable {
00016 
00020    private $comment_form;
00021 
00025    private $object;
00026 
00030    private $query;
00031 
00035    private $tag_form;
00036 
00043    public function __construct(DMTemplate $tpl, DMSession $session,
00044          DMObject $obj, DMObjectQuery $query = null) {
00045       parent::__construct($tpl, $session, $obj->getCollection());
00046       $this->setHelper(new DMObjectTemplateHelper($this, $session));
00047       $this->setCommentForm(new DMObjectCommentForm());
00048       $this->setTagForm(new DMTagForm());
00049       $this->object = $obj;
00050       $this->query = $query;
00051       $obj->getViewer()->setHelper($this->getHelper());
00052       $obj->getViewer()->viewerWillRender();
00053    }
00054 
00058    public function getCommentForm() {
00059       return $this->comment_form;
00060    }
00061 
00065    public function setCommentForm(DMObjectCommentForm $form) {
00066       $this->comment_form = $form;
00067    }
00068 
00072    public function getObject() {
00073       return $this->object;
00074    }
00075 
00079    public function setObject(DMObject $obj) {
00080       $this->object = $obj;
00081    }
00082 
00086    public function getQuery() {
00087       return $this->query;
00088    }
00089 
00093    public function setQuery(DMObjectQuery $query) {
00094       $this->query = $query;
00095    }
00096 
00103    public function getResultsView() {
00104       return $this->getSession()->getResultsView();
00105    }
00106 
00110    public function getTagForm() {
00111       return $this->tag_form;
00112    }
00113 
00117    public function setTagForm(DMTagForm $form) {
00118       $this->tag_form = $form;
00119    }
00120 
00125    public function getURI() {
00126       return $this->getObject()->getURI();
00127    }
00128 
00137    public function getViewForNextObject() {
00138       if (!$this->getQuery()) {
00139          return null;
00140       }
00141       $all = $this->getQuery()->getSearchResults();
00142       $count = count($all);
00143       for ($i = 0; $i < $count; $i++) {
00144          if ($all[$i]->equals($this->object)) {
00145             if (array_key_exists($i + 1, $all)) {
00146                return new DMObjectView($this->getTemplate(),
00147                      $this->getSession(), $all[$i + 1],
00148                      $this->getQuery());
00149             }
00150          }
00151       }
00152       return null;
00153    }
00154 
00163    public function getViewForPreviousObject() {
00164       if (!$this->getQuery()) {
00165          return null;
00166       }
00167       $all = $this->getQuery()->getSearchResults();
00168       $count = count($all);
00169       for ($i = 0; $i < $count; $i++) {
00170          if ($all[$i]->equals($this->object)) {
00171             if (array_key_exists($i - 1, $all)) {
00172                return new DMObjectView($this->getTemplate(),
00173                      $this->getSession(), $all[$i - 1],
00174                      $this->getQuery());
00175             }
00176          }
00177       }
00178       return null;
00179    }
00180 
00186    public function getViewerDefinitionForMediaType($type) {
00187       return $this->object->getCollection()
00188                   ->getViewerDefinitionForMediaType($type);
00189    }
00190 
00191 }
00192 
 All Data Structures Functions Variables