[2] | 1 | <?php |
---|
[362] | 2 | // +-----------------------------------------------------------------------+ |
---|
| 3 | // | htmlfunctions.inc.php | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
| 5 | // | application : PhpWebGallery <http://phpwebgallery.net> | |
---|
| 6 | // | branch : BSF (Best So Far) | |
---|
| 7 | // +-----------------------------------------------------------------------+ |
---|
| 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2004-02-11 23:20:38 +0000 (Wed, 11 Feb 2004) $ |
---|
| 10 | // | last modifier : $Author: z0rglub $ |
---|
| 11 | // | revision : $Revision: 362 $ |
---|
| 12 | // +-----------------------------------------------------------------------+ |
---|
| 13 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 14 | // | it under the terms of the GNU General Public License as published by | |
---|
| 15 | // | the Free Software Foundation | |
---|
| 16 | // | | |
---|
| 17 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 20 | // | General Public License for more details. | |
---|
| 21 | // | | |
---|
| 22 | // | You should have received a copy of the GNU General Public License | |
---|
| 23 | // | along with this program; if not, write to the Free Software | |
---|
| 24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 25 | // | USA. | |
---|
| 26 | // +-----------------------------------------------------------------------+ |
---|
[2] | 27 | |
---|
[25] | 28 | $user['lien_expanded']='./template/'.$user['template'].'/theme/expanded.gif'; |
---|
| 29 | $user['lien_collapsed']='./template/'.$user['template'].'/theme/collapsed.gif'; |
---|
| 30 | |
---|
[2] | 31 | function get_icon( $date_comparaison ) |
---|
| 32 | { |
---|
| 33 | global $user, $conf; |
---|
| 34 | $difference = time() - $date_comparaison; |
---|
| 35 | $jours = 24*60*60; |
---|
| 36 | $output = ''; |
---|
| 37 | if ( $difference < $user['long_period'] * $jours ) |
---|
| 38 | { |
---|
[25] | 39 | $icon_url = './template/'.$user['template'].'/theme/'; |
---|
[2] | 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 | |
---|
| 55 | function 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.'&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.'&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.'&start='.$next ); |
---|
| 103 | $navigation_bar.= '" class="'.$link_class.'">'.$lang['next_page'].'</a>'; |
---|
| 104 | } |
---|
| 105 | } |
---|
| 106 | return $navigation_bar; |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | function get_frame_start() |
---|
| 110 | { |
---|
| 111 | return '<table style="width:'; |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | function get_frame_begin() |
---|
| 115 | { |
---|
| 116 | global $user; |
---|
[25] | 117 | $path = './template/'.$user['template'].'/theme/'; |
---|
[2] | 118 | $size_01 = getimagesize( $path.'01.gif' ); |
---|
| 119 | $size_02 = getimagesize( $path.'02.gif' ); |
---|
| 120 | $size_03 = getimagesize( $path.'03.gif' ); |
---|
| 121 | return ';"> |
---|
| 122 | <tr> |
---|
| 123 | <td><img src="'.$path.'01.gif" style="width:'.$size_01[0].'px;display:box;" alt="" /></td> |
---|
| 124 | <td><img src="'.$path.'02.gif" style="display:box;width:100%;height:'.$size_02[1].'px;" alt="" /></td> |
---|
| 125 | <td><img src="'.$path.'03.gif" style="display:box;width:'.$size_03[0].'px;" alt="" /></td> |
---|
| 126 | </tr> |
---|
| 127 | <tr> |
---|
| 128 | <td style="background:url('.$path.'04.gif);"></td> |
---|
| 129 | <td style="background:url('.$path.'05.gif);width:100%;">'; |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | function get_frame_end() |
---|
| 133 | { |
---|
| 134 | global $user; |
---|
[25] | 135 | $path = './template/'.$user['template'].'/theme/'; |
---|
[2] | 136 | $size_08 = getimagesize( $path.'08.gif' ); |
---|
| 137 | return ' |
---|
| 138 | </td> |
---|
| 139 | <td style="background:url('.$path.'06.gif);"></td> |
---|
| 140 | </tr> |
---|
| 141 | <tr> |
---|
| 142 | <td><img src="'.$path.'07.gif" alt="" /></td> |
---|
| 143 | <td><img src="'.$path.'08.gif" style="width:100%;height:'.$size_08[1].'px;" alt="" /></td> |
---|
| 144 | <td><img src="'.$path.'09.gif" alt="" /></td> |
---|
| 145 | </tr> |
---|
| 146 | </table>'; |
---|
| 147 | } |
---|
[25] | 148 | |
---|
[2] | 149 | function initialize_template() |
---|
| 150 | { |
---|
[351] | 151 | global $template, $user, $lang; |
---|
| 152 | |
---|
| 153 | $template->assign_vars(array( |
---|
[355] | 154 | 'T_START' => get_frame_start(), |
---|
| 155 | 'T_BEGIN' => get_frame_begin(), |
---|
| 156 | 'T_END' => get_frame_end() |
---|
[351] | 157 | ) |
---|
| 158 | ); |
---|
[2] | 159 | |
---|
[351] | 160 | |
---|
| 161 | global $vtp, $handle; |
---|
| 162 | if (isset($handle)) |
---|
| 163 | { |
---|
[2] | 164 | $vtp->setGlobalVar( $handle, 'frame_start', get_frame_start() ); |
---|
| 165 | $vtp->setGlobalVar( $handle, 'frame_begin', get_frame_begin() ); |
---|
| 166 | $vtp->setGlobalVar( $handle, 'frame_end', get_frame_end() ); |
---|
[351] | 167 | } |
---|
[2] | 168 | } |
---|
[25] | 169 | |
---|
[351] | 170 | function display_category( $category, $indent ) |
---|
[25] | 171 | { |
---|
[351] | 172 | global $user,$lang,$template, $vtp, $handle; |
---|
| 173 | |
---|
| 174 | $style=''; |
---|
| 175 | $url = './category.php?cat='.$category['id']; |
---|
| 176 | $url.= '&expand='.$category['expand_string']; |
---|
| 177 | $name = $category['name']; |
---|
| 178 | if ( $name == '' ) $name = str_replace( '_', ' ', $category['dir'] ); |
---|
| 179 | if ( $category['id_uppercat'] == '' ) |
---|
| 180 | { |
---|
| 181 | $style = 'font-weight:bold;'; |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | $template->assign_block_vars('category', array( |
---|
| 185 | 'LINK_NAME' => $name, |
---|
| 186 | 'INDENT' => $indent, |
---|
| 187 | 'NB_SUBCATS'=>$category['nb_sub_categories'], |
---|
| 188 | 'TOTAL_CAT'=>$category['nb_images'], |
---|
| 189 | 'CAT_ICON'=>get_icon($category['date_last']), |
---|
| 190 | |
---|
| 191 | 'T_NAME'=>$style, |
---|
| 192 | 'U_LINK' => add_session_id($url))); |
---|
[25] | 193 | |
---|
[345] | 194 | if ( $user['expand'] or $category['nb_sub_categories'] == 0 ) |
---|
[25] | 195 | { |
---|
[351] | 196 | $template->assign_block_vars('category.bulletnolink', array('BULLET_IMAGE' => $user['lien_collapsed'])); |
---|
[25] | 197 | } |
---|
| 198 | else |
---|
| 199 | { |
---|
[351] | 200 | $url = './category.php'; |
---|
| 201 | if (isset($page['cat'])) |
---|
[345] | 202 | { |
---|
[351] | 203 | $url .='?cat='.$page['cat']; |
---|
| 204 | $url.= '&expand='.$category['expand_string']; |
---|
[345] | 205 | } |
---|
| 206 | else if ($category['expand_string']<>'') |
---|
| 207 | { |
---|
[351] | 208 | $url.= '?expand='.$category['expand_string']; |
---|
[345] | 209 | } |
---|
[351] | 210 | |
---|
| 211 | if ( $category['expanded'] ) |
---|
[25] | 212 | { |
---|
[351] | 213 | $img=$user['lien_expanded']; |
---|
[25] | 214 | } |
---|
| 215 | else |
---|
| 216 | { |
---|
[351] | 217 | $img=$user['lien_collapsed']; |
---|
[25] | 218 | } |
---|
[351] | 219 | |
---|
| 220 | $template->assign_block_vars('category.bulletlink', array( |
---|
| 221 | 'BULLET_IMAGE' => $img, |
---|
| 222 | 'U_BULLET_LINK'=> add_session_id($url) |
---|
| 223 | )); |
---|
[25] | 224 | } |
---|
| 225 | |
---|
| 226 | // recursive call |
---|
| 227 | if ( $category['expanded'] ) |
---|
| 228 | { |
---|
| 229 | foreach ( $category['subcats'] as $subcat ) { |
---|
[351] | 230 | $template->assign_block_vars('category.subcat', array()); |
---|
| 231 | display_category( $subcat, $indent.str_repeat( ' ', 2 )); |
---|
[25] | 232 | } |
---|
| 233 | } |
---|
| 234 | } |
---|
[362] | 235 | ?> |
---|