예제 #1
0
파일: main.php 프로젝트: Anaphore/viewer
$app->hook('slim.before.dispatch', function () use($app, $conf, $lang, $app_base_url) {
    //let's send view parameters before dispatching
    $v = $app->view();
    $ui = $conf->getUI();
    $v->setData('app_base_url', $app_base_url);
    $v->setData('app_web_url', str_replace(array('/index.php', '/debug.php'), array('', ''), $app_base_url));
    $v->setData('enable_right_click', $ui['enable_right_click']);
    $v->setData('lang', $lang);
    $v->setData('negate', $ui['negate']);
    $v->setData('contrast', $ui['contrast']);
    $v->setData('brightness', $ui['brightness']);
    $v->setData('print', $ui['print']);
    $v->setData('comment', $conf->getComment());
    $fmts = $conf->getFormats();
    $v->setData('thumb_format', $fmts['thumb']);
    $remote_infos = $conf->getRemoteInfos();
    if ($remote_infos !== false) {
        $v->setData('remote_method', $remote_infos['method']);
        $v->setData('remote_uri', $remote_infos['uri']);
    }
});
//set default conditions
Route::setDefaultConditions(array('image' => '.+\\.[a-zA-Z]{3,4}', 'series' => '.+', 'format' => 'full|' . implode('|', array_keys($conf->getFormats()))));
//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);
예제 #2
0
파일: Picture.php 프로젝트: Anaphore/viewer
 /**
  * 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>');
 }