/**
  * Return some context files describing media for IxIF.
  *
  * @todo This is not used currently: the Wellcome uris are kept because they
  * are set for main purposes in the UniversalViewer.
  * @link https://gist.github.com/tomcrane/7f86ac08d3b009c8af7c
  */
 public function contextAction()
 {
     $ixif = $this->getParam('ixif');
     $name = '';
     switch ($ixif) {
         case '0/context.json':
             $name = 'ixif/context.json';
             break;
     }
     if ($name) {
         $filepath = physical_path_to($name);
         $src = file_get_contents($filepath);
         if ($src) {
             $src = json_decode($src);
             return $this->_sendJson($src);
         }
     }
     // Silently end without error.
     $this->_helper->viewRenderer->setNoRender();
 }
Пример #2
0
 /**
  * Helper to return image of the current image.
  *
  * @param string $type Derivative type of the image.
  * @return void
  */
 protected function _sendImage($type = null)
 {
     $request = $this->getRequest();
     $itemId = $request->getParam('id');
     $item = get_record_by_id('item', $itemId);
     if (empty($item)) {
         throw new Omeka_Controller_Exception_404();
     }
     $index = $request->getParam('image');
     // Get the index.
     if ($index != '000') {
         $index = preg_replace('`^[0]*`', '', $index);
         $index--;
     } else {
         $index = 0;
     }
     $bookreader = new BookReader($item);
     $part = $request->getParam('part');
     $bookreader->setPart($part);
     if (is_null($type)) {
         $scale = $request->getParam('scale');
         $type = $bookreader->getSizeType($scale);
         // Set a default, even it's normally useless.
         $type = $type ?: 'fullsize';
     }
     $imagesFiles = $bookreader->getLeaves();
     $file = $imagesFiles[$index];
     // No file, so a blank image
     if (empty($file)) {
         $filepath = 'images/blank.png';
         $image = file_get_contents(physical_path_to($filepath));
         $this->getResponse()->clearBody();
         $this->getResponse()->setHeader('Content-Type', 'image/jpeg');
         $this->getResponse()->setBody($image);
     } else {
         $this->_helper->redirector->gotoUrlAndExit($file->getWebPath($type));
     }
 }
Пример #3
0
 /**
  * Create an IIIF canvas object for a place holder.
  *
  * @return Standard object
  */
 protected function _iiifCanvasPlaceholder()
 {
     $canvas = array();
     $canvas['@id'] = WEB_ROOT . '/iiif/ixif-message/canvas/c1';
     $canvas['@type'] = 'sc:Canvas';
     $canvas['label'] = __('Placeholder image');
     $placeholder = 'images/placeholder.jpg';
     $canvas['thumbnail'] = src($placeholder);
     list($widthPlaceholder, $heightPlaceholder) = $this->_getWidthAndHeight(physical_path_to($placeholder));
     $canvas['width'] = $widthPlaceholder;
     $canvas['height'] = $heightPlaceholder;
     $image = array();
     $image['@id'] = WEB_ROOT . '/iiif/ixif-message/imageanno/placeholder';
     $image['@type'] = 'oa:Annotation';
     $image['motivation'] = "sc:painting";
     // There is only one image (parallel is not managed).
     $imageResource = array();
     $imageResource['@id'] = WEB_ROOT . '/iiif/ixif-message-0/res/placeholder';
     $imageResource['@type'] = 'dctypes:Image';
     $imageResource['width'] = $widthPlaceholder;
     $imageResource['height'] = $heightPlaceholder;
     $imageResource = (object) $imageResource;
     $image['resource'] = $imageResource;
     $image['on'] = WEB_ROOT . '/iiif/ixif-message/canvas/c1';
     $image = (object) $image;
     $images = array($image);
     $canvas['images'] = $images;
     $canvas = (object) $canvas;
     return $canvas;
 }