[3339] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
[9782] | 4 | function Front2Back_content($content, $image) |
---|
[3339] | 5 | { |
---|
[11217] | 6 | global $template, $conf, $user; |
---|
| 7 | $conf['Front2Back'] = explode(',', $conf['Front2Back']); |
---|
| 8 | load_language('plugin.lang', F2B_PATH); |
---|
[3339] | 9 | |
---|
[11217] | 10 | /* dirs and files */ |
---|
| 11 | if (empty($conf['Front2Back'][0])) { |
---|
| 12 | $verso_dir = str_replace($image['file'], null, $image['path']) . $conf['Front2Back'][1]; |
---|
| 13 | $hd_dir = str_replace($image['file'], null, $image['path']) . $conf['Front2Back'][2]; |
---|
| 14 | } else { |
---|
| 15 | $verso_dir = PHPWG_ROOT_PATH . $conf['Front2Back'][0] . $conf['Front2Back'][1]; |
---|
| 16 | $hd_dir = PHPWG_ROOT_PATH . $conf['Front2Back'][0] . $conf['Front2Back'][2]; |
---|
| 17 | } |
---|
| 18 | $verso_file = get_filename_wo_extension($image['file']) . $conf['Front2Back'][3] . '.' . get_extension($image['file']); |
---|
| 19 | $rotat_file = get_filename_wo_extension($image['file']) . '-r.' . get_extension($image['file']); |
---|
[9782] | 20 | |
---|
[11217] | 21 | /* Is there a verso file ? */ |
---|
| 22 | if (is_file($verso_dir.$verso_file)) |
---|
| 23 | { |
---|
| 24 | $template->assign('VERSO_URL', $verso_dir.$verso_file); |
---|
[9782] | 25 | |
---|
[11217] | 26 | if (is_file($hd_dir.$verso_file)) { |
---|
| 27 | $template->assign('VERSO_HD', $hd_dir.$verso_file); |
---|
| 28 | } |
---|
| 29 | } |
---|
| 30 | /* useless section, just for retrocompatibility */ |
---|
| 31 | else if (is_file($verso_dir.$rotat_file)) |
---|
| 32 | { |
---|
| 33 | $template->assign('VERSO_URL', $verso_dir.$rotat_file); |
---|
| 34 | |
---|
| 35 | if (is_file($hd_dir.$rotat_file)) { |
---|
| 36 | $template->assign('VERSO_HD', $hd_dir.$rotat_file); |
---|
| 37 | } |
---|
| 38 | } |
---|
| 39 | /* otherwise */ |
---|
| 40 | else |
---|
| 41 | { |
---|
| 42 | return $content; |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | /* link name */ |
---|
| 46 | $conf['Front2Back'][7] = unserialize($conf['Front2Back'][7]); |
---|
| 47 | if (!empty($conf['Front2Back'][7][$user['language']])) |
---|
| 48 | { |
---|
[11218] | 49 | if (strpos($conf['Front2Back'][7][$user['language']], '|') !== false) |
---|
| 50 | { |
---|
| 51 | $conf['Front2Back'][7] = explode('|', $conf['Front2Back'][7][$user['language']]); |
---|
| 52 | } |
---|
| 53 | else |
---|
| 54 | { |
---|
| 55 | $conf['Front2Back'][7] = array($conf['Front2Back'][7][$user['language']], $conf['Front2Back'][7][$user['language']]); |
---|
| 56 | } |
---|
[11217] | 57 | } |
---|
| 58 | else if (!empty($conf['Front2Back'][7]['default'])) |
---|
| 59 | { |
---|
[11218] | 60 | if (strpos($conf['Front2Back'][7]['default'], '|') != false) |
---|
| 61 | { |
---|
| 62 | $conf['Front2Back'][7] = explode('|', $conf['Front2Back'][7]['default']); |
---|
| 63 | } |
---|
| 64 | else |
---|
| 65 | { |
---|
| 66 | $conf['Front2Back'][7] = array($conf['Front2Back'][7]['default'], $conf['Front2Back'][7]['default']); |
---|
| 67 | } |
---|
[11217] | 68 | } |
---|
| 69 | else |
---|
| 70 | { |
---|
| 71 | $conf['Front2Back'][7] = array(l10n('See back'), l10n('See front')); |
---|
| 72 | } |
---|
| 73 | |
---|
[12387] | 74 | $template->set_filename('Front2Back', dirname(__FILE__) . '/template/Front2Back.tpl'); |
---|
[11217] | 75 | $template->assign(array( |
---|
| 76 | 'F2B_PATH' => F2B_PATH, |
---|
| 77 | 'F2B_position' => $conf['Front2Back'][4], |
---|
| 78 | 'F2B_switch_mode' => $conf['Front2Back'][5], |
---|
| 79 | 'F2B_transition' => $conf['Front2Back'][6], |
---|
| 80 | 'F2B_see_back' => $conf['Front2Back'][7][0], |
---|
| 81 | 'F2B_see_front' => $conf['Front2Back'][7][1], |
---|
| 82 | )); |
---|
| 83 | |
---|
| 84 | switch ($conf['Front2Back'][4]) |
---|
| 85 | { |
---|
| 86 | case 'toolbar': |
---|
[12387] | 87 | $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('Front2Back', true)); |
---|
[11217] | 88 | return $content; |
---|
| 89 | break; |
---|
| 90 | case 'top': |
---|
| 91 | return $template->parse('Front2Back', true)."\n".$content; |
---|
| 92 | break; |
---|
| 93 | case 'bottom': |
---|
| 94 | return $content."\n".$template->parse('Front2Back', true); |
---|
| 95 | break; |
---|
| 96 | } |
---|
[9782] | 97 | |
---|
[11217] | 98 | } |
---|
| 99 | |
---|
[9782] | 100 | ?> |
---|