source: trunk/template/default/htmlfunctions.inc.php @ 25

Last change on this file since 25 was 25, checked in by z0rglub, 21 years ago

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 KB
Line 
1<?php
2/***************************************************************************
3 *                           htmlfunctions.inc.php                         *
4 *                            -------------------                          *
5 *   application          : PhpWebGallery 1.3                              *
6 *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
7 *                                                                         *
8 ***************************************************************************
9
10 ***************************************************************************
11 *                                                                         *
12 *   This program is free software; you can redistribute it and/or modify  *
13 *   it under the terms of the GNU General Public License as published by  *
14 *   the Free Software Foundation;                                         *
15 *                                                                         *
16 ***************************************************************************/
17
18include( PREFIX_INCLUDE.'./template/'.$user['template'].'/theme/conf.php' );
19$user['lien_expanded']='./template/'.$user['template'].'/theme/expanded.gif';
20$user['lien_collapsed']='./template/'.$user['template'].'/theme/collapsed.gif';
21include_once( PREFIX_INCLUDE.'./template/'.$user['template'].'/style.inc.php');
22
23function get_icon( $date_comparaison )
24{
25  global $user, $conf;
26  $difference = time() - $date_comparaison;
27  $jours = 24*60*60;
28  $output = '';
29  if ( $difference < $user['long_period'] * $jours )
30  {
31    $icon_url = './template/'.$user['template'].'/theme/';
32    if ( $difference < $user['short_period'] * $jours )
33    {
34      $icon_url.= 'new_short.gif';
35    }
36    else
37    {
38      $icon_url.= 'new_long.gif';
39    }
40    $size = getimagesize( $icon_url );
41    $output = '<img src="'.$icon_url.'" style="border:0;';
42    $output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="" />';
43  }
44  return $output;
45}
46
47function create_navigation_bar( $url, $nb_element, $start,
48                                $nb_element_page, $link_class )
49{
50  global $lang;
51  $navigation_bar = "";
52  // 0. détection de la page en cours
53  if( !isset( $start )
54      || !is_numeric( $start )
55      || ( is_numeric( $start ) && $start < 0 ) )
56  {
57    $start = 0;
58  }
59  // on n'affiche la bare de navigation que si on plus de 1 page
60  if ( $nb_element > $nb_element_page )
61  {
62    // 1.une page précédente ?
63    if ( $start != 0 )
64    {
65      $previous = $start - $nb_element_page;
66      $navigation_bar.= '<a href="';
67      $navigation_bar.= add_session_id( $url.'&amp;start='.$previous );
68      $navigation_bar.= '" class="'.$link_class.'">'.$lang['previous_page'];
69      $navigation_bar.= '</a>';
70      $navigation_bar.= ' | ';
71    }
72    // 2.liste des numéros de page
73    $maximum = ceil ( $nb_element / $nb_element_page );
74    for ( $i = 1; $i <= $maximum; $i++ )
75    {
76      $temp_start = ( $i - 1 ) * $nb_element_page;
77      if ( $temp_start == $start )
78      {
79        $navigation_bar.= ' <span style="font-weight:bold;">'.$i.'</span> ';
80      }
81      else
82      {
83        $navigation_bar.= ' <a href="';
84        $navigation_bar.= add_session_id( $url.'&amp;start='.$temp_start );
85        $navigation_bar.= '" class="'.$link_class.'">'.$i.'</a> ';
86      }
87    }
88    // 3.une page suivante ?
89    if ( $nb_element > $nb_element_page
90         && $start + $nb_element_page < $nb_element )
91    {
92      $next = $start + $nb_element_page;
93      $navigation_bar.= ' | <a href="';
94      $navigation_bar.= add_session_id( $url.'&amp;start='.$next );
95      $navigation_bar.= '" class="'.$link_class.'">'.$lang['next_page'].'</a>';
96    }
97  }
98  return $navigation_bar;
99}
100
101function get_frame_start()
102{
103  return '<table style="width:';
104}
105/*
106function get_frame_begin()
107{
108  return ';">
109            <tr>
110              <td style="border:1px dashed gray;width:100%;padding:5px;background-color:white;">';
111}
112
113function get_frame_end()
114{
115  return '
116              </td>
117            </tr>   
118          </table>';
119}
120*/
121
122function get_frame_begin()
123{
124  global $user;
125  $path = './template/'.$user['template'].'/theme/';
126  $size_01 = getimagesize( $path.'01.gif' );
127  $size_02 = getimagesize( $path.'02.gif' );
128  $size_03 = getimagesize( $path.'03.gif' );
129  return ';">
130            <tr>
131              <td><img src="'.$path.'01.gif" style="width:'.$size_01[0].'px;display:box;" alt="" /></td>
132              <td><img src="'.$path.'02.gif" style="display:box;width:100%;height:'.$size_02[1].'px;" alt="" /></td>
133              <td><img src="'.$path.'03.gif" style="display:box;width:'.$size_03[0].'px;" alt="" /></td>
134            </tr>
135            <tr>
136              <td style="background:url('.$path.'04.gif);"></td>
137              <td style="background:url('.$path.'05.gif);width:100%;">';
138}
139       
140function get_frame_end()
141{
142  global $user;
143  $path = './template/'.$user['template'].'/theme/';
144  $size_08 = getimagesize( $path.'08.gif' );
145  return '
146              </td>
147              <td style="background:url('.$path.'06.gif);"></td>
148            </tr>
149            <tr>
150              <td><img src="'.$path.'07.gif" alt="" /></td>
151              <td><img src="'.$path.'08.gif" style="width:100%;height:'.$size_08[1].'px;" alt="" /></td>
152              <td><img src="'.$path.'09.gif" alt="" /></td>
153            </tr>   
154          </table>';
155}
156
157function initialize_template()
158{
159  global $vtp, $handle, $user, $lang;
160
161  $vtp->setGlobalVar( $handle, 'charset', $lang['charset'] );
162  $vtp->setGlobalVar( $handle, 'style', $user['style'] );
163  $vtp->setGlobalVar( $handle, 'frame_start', get_frame_start() );
164  $vtp->setGlobalVar( $handle, 'frame_begin', get_frame_begin() );
165  $vtp->setGlobalVar( $handle, 'frame_end',   get_frame_end() );
166  $vtp->setVarF( $handle, 'header',
167                 './template/'.$user['template'].'/header.htm' );
168  $vtp->setVarF( $handle, 'footer',
169                 './template/'.$user['template'].'/footer.htm' );
170}
171
172function display_category( $category, $indent, $handle )
173{
174  global $user,$lang,$vtp;
175
176  $vtp->addSession( $handle, 'category' );
177  $vtp->setVar( $handle, 'category.indent', $indent );
178
179  if ( $user['expand'] or count( $category['subcats'] ) == 0 )
180  {
181    $vtp->addSession( $handle, 'bullet_wo_link' );
182    $vtp->setVar( $handle, 'bullet_wo_link.bullet_url',
183                  $user['lien_collapsed'] );
184    $vtp->closeSession( $handle, 'bullet_wo_link' );
185  }
186  else
187  {
188    $vtp->addSession( $handle, 'bullet_w_link' );
189    $url = './category.php?cat='.$page['cat'];
190    $url.= '&amp;expand='.$category['expand_string'];
191    if ( $page['cat'] == 'search' )
192    {
193      $url.= '&amp;search='.$_GET['search'].'&amp;mode='.$_GET['mode'];
194    }
195    $vtp->setVar( $handle, 'bullet_w_link.bullet_link', add_session_id($url) );
196    if ( $category['expanded'] )
197    {
198      $vtp->setVar( $handle, 'bullet_w_link.bullet_url',
199                    $user['lien_expanded'] );
200    }
201    else
202    {
203      $vtp->setVar( $handle, 'bullet_w_link.bullet_url',
204                    $user['lien_collapsed'] );
205    }
206    $vtp->closeSession( $handle, 'bullet_w_link' );
207  }
208
209  $url = './category.php?cat='.$category['id'];
210  $url.= '&amp;expand='.$category['expand_string'];
211  $vtp->setVar( $handle, 'category.link_url', add_session_id( $url ) );
212
213  $name = $category['name'];
214  if ( $name == '' ) $name = str_replace( '_', ' ', $category['dir'] );
215  $vtp->setVar( $handle, 'category.link_name', $name );
216
217  if ( $category['id_uppercat'] == '' )
218  {
219    $vtp->setVar( $handle, 'category.name_style', 'font-weight:bold;' );
220  }
221  if ( count( $category['subcats'] ) > 0 )
222  {
223    $vtp->addSession( $handle, 'subcat' );
224    $vtp->setVar( $handle, 'subcat.nb_subcats', count($category['subcats']) );
225    $vtp->closeSession( $handle, 'subcat' );
226  }
227  $vtp->setVar( $handle, 'category.total_cat', $category['nb_images'] );
228  $vtp->setVar( $handle, 'category.cat_icon',get_icon($category['date_last']));
229  $vtp->closeSession( $handle, 'category' );
230
231  // recursive call
232  if ( $category['expanded'] )
233  {
234    foreach ( $category['subcats'] as $subcat ) {
235      display_category( $subcat, $indent.str_repeat( '&nbsp', 2 ), $handle );
236    }
237  }
238}
239?>
Note: See TracBrowser for help on using the repository browser.