dmBridge PHP API
DMMonocleViewer.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 
00022 class DMMonocleViewer extends DMAbstractViewer
00023 implements DMObjectViewerDelegate {
00024 
00025    function viewerWillRender() {
00026       $root_uri = dirname($_SERVER['PHP_SELF'])
00027          . "/system/viewers/DMMonocleViewer";
00028 
00029       // build script deploys the minified version
00030       $dmmonocle_version
00031       = file_exists(dirname(__FILE__) . "/scripts/dmmonocle.min.js")
00032          ? "dmmonocle.min.js" : "dmmonocle.js";
00033 
00034       $this->getHelper()->addHeadScriptTag(
00035             dirname($_SERVER['PHP_SELF']) . "/includes/js/jquery-1.3.2.min.js");
00036       $this->getHelper()->addBodyScriptTag(
00037             $root_uri . "/scripts/jquery.event.drag-1.5.min.js");
00038       $this->getHelper()->addBodyScriptTag(
00039             $root_uri . "/scripts/jquery-ui-1.7.1.custom.min.js");
00040       $this->getHelper()->addBodyScriptTag(
00041             $root_uri . "/scripts/" . $dmmonocle_version);
00042    }
00043 
00047    public function getHTMLTag() {
00048       /* an alternative "viewer" for users who do not have javascript
00049       enabled; will be embedded in a <noscript> tag below. */
00050       $alt_viewer = new DMGenericImageViewer($this->getObject(),
00051          $this->getMediaType(), $this->getWidth(), $this->getHeight());
00052 
00053       return sprintf(
00054          '<div id="dmMonocle" style="width:%spx; height:%spx">
00055             <noscript>%s</noscript>
00056          </div>
00057          <script type="text/javascript">
00058          $(window).ready(function() {
00059             dmMonocle(%d, %d, %d, "%s", "%s");
00060          });
00061          </script>',
00062          $this->getWidth(),
00063          $this->getHeight(),
00064          $alt_viewer->getHTMLTag(),
00065          $this->getObject()->getWidth(),
00066          $this->getObject()->getHeight(),
00067          $this->getObject()->getPtr(),
00068          $this->getObject()->getCollection()->getAlias(),
00069          DMConfigIni::getInstance()->getString("contentdm.getimage_exe.path")
00070       );
00071    }
00072 
00076    public function getHTMLTagNoJS() {
00077       // dmMonocle requires javascript; sorry
00078       return $this->getHtmlTag();
00079    }
00080 
00084    public function getName() {
00085       return "dmMonocle Image Viewer";
00086    }
00087 
00088 }
00089 
 All Data Structures Functions Variables