dmBridge PHP API
DMMonocle2Viewer.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 DMMonocle2Viewer extends DMAbstractViewer
00023 implements DMObjectViewerDelegate {
00024 
00025    function viewerWillRender() {
00026       $root_uri = dirname($_SERVER['PHP_SELF'])
00027          . "/system/viewers/DMMonocle2Viewer";
00028 
00029       $this->getHelper()->addStylesheetTag(
00030             $root_uri . "/styles/dmmonocle.css");
00031       $this->getHelper()->addBodyScriptTag(
00032             "http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js");
00033       $this->getHelper()->addBodyScriptTag(
00034             $root_uri . "/scripts/dmmonocle.js");
00035       $this->getHelper()->addBodyScriptCode(
00036          sprintf('YUI().use("node", "anim", "event-custom", "event-key", "slider", function(Y) {
00037                Y.on("domready", function(e) {
00038                   var monocle = new DMMonocle(
00039                      Y,
00040                      {
00041                         alias: "%s",
00042                         ptr: %d,
00043                         fullSize: {
00044                            width: %d,
00045                            height: %d
00046                         }
00047                      },
00048                      "%s",
00049                      "%s");
00050                   monocle.init();
00051                });
00052             });',
00053          $this->getObject()->getCollection()->getAlias(),
00054          $this->getObject()->getPtr(),
00055          $this->getObject()->getWidth(),
00056          $this->getObject()->getHeight(),
00057          dirname($_SERVER['PHP_SELF']) . "/system/viewers/DMMonocle2Viewer",
00058          DMConfigIni::getInstance()->getString("contentdm.getimage_exe.path")));
00059    }
00060 
00064    public function getHTMLTag() {
00065       /* an alternative "viewer" for users who do not have javascript
00066       enabled; will be embedded in a <noscript> tag below. */
00067       $alt_viewer = new DMGenericImageViewer();
00068       $alt_viewer->setObject($this->getObject());
00069       $alt_viewer->setMediaType($this->getMediaType());
00070       $alt_viewer->setWidth($this->getWidth());
00071       $alt_viewer->setHeight($this->getHeight());
00072       return sprintf(
00073          '<div id="dmMonocle" style="width:%s; height:%s">
00074             <noscript>%s</noscript>
00075          </div>',
00076          $this->getWidth(),
00077          $this->getHeight(),
00078          $alt_viewer->getHTMLTag());
00079    }
00080 
00084    public function getHTMLTagNoJS() {
00085       // dmMonocle requires javascript; sorry
00086       return $this->getHtmlTag();
00087    }
00088 
00095    public function isLowBandwidthCompatible() {
00096       return true;
00097    }
00098 
00102    public function getName() {
00103       return "dmMonocle 2 Image Viewer";
00104    }
00105 
00106 }
00107 
 All Data Structures Functions Variables