source: extensions/Front2Back/Front2Back.php @ 14518

Last change on this file since 14518 was 12387, checked in by mistic100, 12 years ago

remove a prefilter

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1<?php 
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4function Front2Back_content($content, $image)
5{
6  global $template, $conf, $user;
7  $conf['Front2Back'] = explode(',', $conf['Front2Back']);
8  load_language('plugin.lang', F2B_PATH);
9
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']);
20
21  /* Is there a verso file ? */
22  if (is_file($verso_dir.$verso_file)) 
23  {
24    $template->assign('VERSO_URL', $verso_dir.$verso_file);
25
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  {
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    }
57  }
58  else if (!empty($conf['Front2Back'][7]['default']))
59  {
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    }
68  }
69  else
70  {
71    $conf['Front2Back'][7] = array(l10n('See back'), l10n('See front'));
72  }
73 
74  $template->set_filename('Front2Back', dirname(__FILE__) . '/template/Front2Back.tpl');
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':
87      $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('Front2Back', true));
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  }
97
98}
99
100?>
Note: See TracBrowser for help on using the repository browser.