source: tags/release-1_3_3/template/default/htmlfunctions.inc.php @ 552

Last change on this file since 552 was 552, checked in by (none), 20 years ago

This commit was manufactured by cvs2svn to create tag
'release-1_3_3'.

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