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                   monocle.init();
00050                });
00051             });',
00052          $this->getObject()->getCollection()->getAlias(),
00053          $this->getObject()->getPtr(),
00054          $this->getObject()->getWidth(),
00055          $this->getObject()->getHeight(),
00056          DMConfigIni::getInstance()->getString("contentdm.getimage_exe.path")));
00057    }
00058 
00062    public function getHTMLTag() {
00063       /* an alternative "viewer" for users who do not have javascript
00064       enabled; will be embedded in a <noscript> tag below. */
00065       $alt_viewer = new DMGenericImageViewer($this->getObject(),
00066          $this->getMediaType(), $this->getWidth(), $this->getHeight());
00067       return sprintf(
00068          '<div id="dmMonocle" style="width:%s; height:%s">
00069             <noscript>%s</noscript>
00070          </div>',
00071          $this->getWidth(),
00072          $this->getHeight(),
00073          $alt_viewer->getHTMLTag());
00074    }
00075 
00079    public function getHTMLTagNoJS() {
00080       // dmMonocle requires javascript; sorry
00081       return $this->getHtmlTag();
00082    }
00083 
00087    public function getName() {
00088       return "dmMonocle 2 Image Viewer";
00089    }
00090 
00091 }
00092 
 All Data Structures Functions Variables