1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | function Front2Back_content($content, $image) |
---|
5 | { |
---|
6 | global $template, $conf; |
---|
7 | |
---|
8 | /* Default values */ |
---|
9 | if (!isset($conf['Front2Back_dir'])) $conf['Front2Back_dir'] = 'verso/'; |
---|
10 | if (!isset($conf['Front2Back_parent'])) $conf['Front2Back_parent'] = 'thumbnail/'; |
---|
11 | if (!isset($conf['Front2Back_hd_parent'])) $conf['Front2Back_hd_parent'] = 'pwg_high/'; |
---|
12 | if (!isset($conf['Front2Back_path'])) |
---|
13 | $conf['Front2Back_inside']= true; |
---|
14 | else |
---|
15 | $conf['Front2Back_inside']= false; |
---|
16 | |
---|
17 | /* dirs and files */ |
---|
18 | if ( $conf['Front2Back_inside'] ) { |
---|
19 | $verso_dir = str_replace($image['file'], null, $image['path']) . $conf['Front2Back_parent'] . $conf['Front2Back_dir']; |
---|
20 | $hd_dir = str_replace($image['file'], null, $image['path']) . $conf['Front2Back_hd_parent'] . $conf['Front2Back_dir']; |
---|
21 | } else { |
---|
22 | $verso_dir = $conf['Front2Back_path'] . $conf['Front2Back_parent'] . $conf['Front2Back_dir']; |
---|
23 | $hd_dir = $conf['Front2Back_path'] . $conf['Front2Back_hd_parent'] . $conf['Front2Back_dir']; |
---|
24 | } |
---|
25 | $rotat_file = substr($image['file'],0,-4).'-r'.substr($image['file'],-4); |
---|
26 | |
---|
27 | $template->set_filenames(array('Front2Back' => dirname(__FILE__) . '/Front2Back.tpl') ); |
---|
28 | $template->assign('F2B_PATH', F2B_PATH); |
---|
29 | |
---|
30 | /* Is there a verso file ? */ |
---|
31 | if (is_file($verso_dir.$image['file'])) |
---|
32 | { |
---|
33 | $template->assign('VERSO_URL', $verso_dir.$image['file']); |
---|
34 | |
---|
35 | if (is_file($hd_dir.$image['file'])) { |
---|
36 | $template->assign('VERSO_HD', $hd_dir.$image['file']); |
---|
37 | } |
---|
38 | } |
---|
39 | /* useless section, just for retrocompatibility */ |
---|
40 | else if (is_file($verso_dir.$rotat_file)) |
---|
41 | { |
---|
42 | $template->assign('VERSO_URL', $verso_dir.$rotat_file); |
---|
43 | |
---|
44 | if (is_file($hd_dir.$rotat_file)) { |
---|
45 | $template->assign('VERSO_HD', $hd_dir.$rotat_file); |
---|
46 | } |
---|
47 | } |
---|
48 | /* otherwise */ |
---|
49 | else |
---|
50 | { |
---|
51 | return $content; |
---|
52 | } |
---|
53 | |
---|
54 | return $content . $template->parse('Front2Back', true); |
---|
55 | } |
---|
56 | |
---|
57 | ?> |
---|