Example #1
0
 /**
  * Main constructor
  *
  * @param Conf    $conf    App Configuration
  * @param Picture $picture Picture
  * @param array   $params  Print params
  * @param string  $format  Image format
  */
 public function __construct(Conf $conf, Picture $picture, $params, $format)
 {
     $orientation = 'P';
     $w = $picture->getWidth();
     $h = $picture->getHeight();
     if ($params['crop'] !== false) {
         if ($params['crop']['w'] < $w) {
             $w = $params['crop']['w'];
         }
         if ($params['crop']['h']) {
             $h = $params['crop']['h'];
         }
     }
     if ($w > $h) {
         $orientation = 'L';
     }
     parent::__construct($orientation, 'mm', 'A4', true, 'UTF-8');
     $this->_conf = $conf;
     $this->_picture = $picture;
     $this->_params = $params;
     $this->_image_format = $format;
     $this->setCreator('Bach - ' . PDF_CREATOR);
     $this->setTitle($picture->getName());
 }
Example #2
0
    foreach ($display['headers'] as $key => $header) {
        $response[$key] = $header;
    }
    $response->body($display['content']);
});
$app->get('/viewer/:image_params+', function ($img_params) use($app, $conf, $app_base_url) {
    $img = array_pop($img_params);
    $path = null;
    if (count($img_params) > 0) {
        $path = '/' . implode('/', $img_params);
    }
    $picture = null;
    if ($img === DEFAULT_PICTURE) {
        $picture = new Picture($conf, DEFAULT_PICTURE, $app_base_url);
    } else {
        $picture = new Picture($conf, $img, $app_base_url, $path);
    }
    $args = array('img' => $img, 'picture' => $picture, 'iip' => $picture->isPyramidal());
    if ($picture->isPyramidal()) {
        $iip = $conf->getIIP();
        $args['iipserver'] = $iip['server'];
    } else {
        $args['image_format'] = 'default';
    }
    if (file_exists('../web/themes/styles/themes.css')) {
        $args['themes'] = 'themes';
    }
    $app->render('index.html.twig', $args);
});
$app->get('/print/:format(/:series)/:image(/:display)', function ($format, $series_path, $image, $display = false) use($app, $conf, $viewer) {
    $picture = $viewer->getImage($series_path, $image);
Example #3
0
//404 handler
$app->notFound(function () use($app) {
    $app->render('404.html.twig');
});
//custom error handler
$app->error(function (\Exception $e) use($app, $conf, $app_base_url) {
    $resuUri = $app->request()->getResourceUri();
    $etype = get_class($e);
    Analog::error('exception \'' . $etype . '\' with message \'' . $e->getMessage() . '\' in ' . $e->getFile() . ':' . $e->getLine() . "\nStack trace:\n" . $e->getTraceAsString());
    if ((substr($resuUri, 0, 10) === '/ajax/img/' || substr($resuUri, 0, 21) === '/ajax/representative/') && APP_DEBUG !== true) {
        $format = 'default';
        preg_match('/.*\\/format\\/(.*)/', $resuUri, $matches);
        if (isset($matches[1])) {
            $format = $matches[1];
        }
        $picture = new Picture($conf, DEFAULT_PICTURE, $app_base_url);
        $display = $picture->getDisplay($format);
        $response = $app->response();
        foreach ($display['headers'] as $key => $header) {
            $response[$key] = $header;
        }
        $response->body($display['content']);
    } else {
        $app->render('50x.html.twig', array('exception' => $e));
    }
});
//main route
$app->get('/', function () use($app, $app_base_url) {
    $app->redirect($app_base_url . '/viewer/' . DEFAULT_PICTURE);
});
//include routes files
Example #4
0
 /**
  * Test for remote informations stuff
  *
  * @return void
  */
 public function testRemoteInfos()
 {
     $uri = Viewer\Picture::getRemoteInfosURI($this->_conf->getRemoteInfos(), null, 'tech.jpg');
     $this->string($uri)->isIdenticalTo('http://UT.bach.localhost/infosimage/tech.jpg');
     $rinfos = Viewer\Picture::getRemoteInfos($this->_conf->getRemoteInfos(), null, 'tech.jpg');
     $this->boolean($rinfos)->isFalse();
     $rinfos = Viewer\Picture::getRemoteInfos($this->_conf->getRemoteInfos(), null, 'tech.jpg', TESTS_DIR . '/data/bach_remote_infos');
     $this->string($rinfos)->isIdenticalTo('<a target="_blank" href="http://UT.bach.localhost/document/test"' . '>Test</a>' . "\n");
     $config_path = APP_DIR . '/../tests/config/config-remotepleade.yml';
     $conf = new Viewer\Conf($config_path);
     $rinfos = Viewer\Picture::getRemoteInfos($conf->getRemoteInfos(), null, 'tech.jpg');
     $this->boolean($rinfos)->isFalse();
     $rinfos = Viewer\Picture::getRemoteInfos($conf->getRemoteInfos(), null, 'tech.jpg', TESTS_DIR . '/data/pleade_remote_infos');
     $this->string($rinfos)->isIdenticalTo('<a href="http://pleade.test.localhost/ead.html?id=Test&amp;c=' . 'Test_1" title="">Test</a>');
 }
Example #5
0
 */
$app->get('/ajax/img(/:series)/:image(/format/:format)', function ($series_path = null, $image, $format = 'default') use($app, $viewer) {
    $picture = $viewer->getImage($series_path, $image);
    $display = $picture->getDisplay($format);
    $response = $app->response();
    foreach ($display['headers'] as $key => $header) {
        $response[$key] = $header;
    }
    $response->body($display['content']);
});
$app->get('/ajax/representative/:series/format/:format', function ($series_path = null, $format) use($app, $conf, $app_base_url) {
    $request = $app->request;
    $start = $request->params('s');
    $end = $request->params('e');
    $series = new Series($conf, $series_path, $app_base_url, $start, $end);
    $picture = new Picture($conf, $series->getRepresentative(), $app_base_url, $series->getFullPath());
    $app->redirect($picture->getUrl($series, $format));
});
$app->get('/ajax/series/infos/:series/:image', function ($series_path, $img) use($app, $conf, $app_base_url) {
    $request = $app->request;
    $start = $request->params('s');
    $end = $request->params('e');
    $series = new Series($conf, $series_path, $app_base_url, $start, $end);
    if ($img !== null) {
        $series->setImage($img);
    }
    $infos = $series->getInfos();
    echo json_encode($infos);
});
$app->get('/ajax/image/infos/:image_params+', function ($img_params) use($app, $conf) {
    $img = array_pop($img_params);
Example #6
0
 /**
  * Get list of cseries thumbnails
  *
  * @param array $fmt Thumbnail format form configuration
  *
  * @return array
  */
 public function getThumbs($fmt)
 {
     $ret = array();
     $thumbs = array();
     $ret['meta'] = $fmt;
     foreach ($this->_content as $c) {
         $p = new Picture($this->_conf, $c, null, $this->_full_path);
         $path = null;
         if ($p->isPyramidal()) {
             $path = $p->getFullPath();
         } else {
             $path = $c;
         }
         $thumbs[] = array('name' => $c, 'path' => $path);
     }
     $ret['thumbs'] = $thumbs;
     return $ret;
 }