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

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

improve the header of each file

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