source: extensions/Front2Back/Front2Back.php @ 9782

Last change on this file since 9782 was 9782, checked in by mistic100, 13 years ago

[extensions] Front2Back

  • compatibility with 2.2.0
  • jQuery method for swap
  • localisation
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 KB
Line 
1<?php 
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4function 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?>
Note: See TracBrowser for help on using the repository browser.