source: extensions/Front2Back/Front2Back.php @ 11218

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

some tests to avoid errors, css bug with IE

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
RevLine 
[3339]1<?php 
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
[9782]4function 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 
74  $template->set_filenames(array('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->set_prefilter('picture', 'Front2Back_toolbar_prefilter');
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
98} 
99
[11217]100function Front2Back_toolbar_prefilter($content, &$smarty)
101{
102  $search = '{/if}{/strip}{*caddie management END*}';
103  $replacement = $search."\n".file_get_contents(F2B_PATH.'template/Front2Back.tpl');
104  return str_replace($search, $replacement, $content);
105}
106
[9782]107?>
Note: See TracBrowser for help on using the repository browser.