1 | <?php |
---|
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-03-26 19:36:38 +0000 (Fri, 26 Mar 2004) $ |
---|
10 | // | last modifier : $Author: z0rglub $ |
---|
11 | // | revision : $Revision: 395 $ |
---|
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 | // +-----------------------------------------------------------------------+ |
---|
27 | |
---|
28 | function get_icon( $date_comparaison ) |
---|
29 | { |
---|
30 | global $user, $conf, $lang; |
---|
31 | $difference = time() - $date_comparaison; |
---|
32 | $jours = 24*60*60; |
---|
33 | $output = ''; |
---|
34 | $title = $lang['recent_image'].' '; |
---|
35 | if ( $difference < $user['long_period'] * $jours ) |
---|
36 | { |
---|
37 | $icon_url = './template/'.$user['template'].'/theme/'; |
---|
38 | if ( $difference < $user['short_period'] * $jours ) |
---|
39 | { |
---|
40 | $icon_url.= 'new_short.gif'; |
---|
41 | $title .= $user['short_period']; |
---|
42 | } |
---|
43 | else |
---|
44 | { |
---|
45 | $icon_url.= 'new_long.gif'; |
---|
46 | $title .= $user['long_period']; |
---|
47 | } |
---|
48 | $title .= ' '.$lang['days']; |
---|
49 | $size = getimagesize( $icon_url ); |
---|
50 | $output = '<img title="'.$title.'" src="'.$icon_url.'" style="border:0;'; |
---|
51 | $output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="" />'; |
---|
52 | } |
---|
53 | return $output; |
---|
54 | } |
---|
55 | |
---|
56 | function create_navigation_bar( $url, $nb_element, $start, |
---|
57 | $nb_element_page, $link_class ) |
---|
58 | { |
---|
59 | global $lang; |
---|
60 | $navigation_bar = ""; |
---|
61 | // 0. détection de la page en cours |
---|
62 | if( !isset( $start ) |
---|
63 | || !is_numeric( $start ) |
---|
64 | || ( is_numeric( $start ) && $start < 0 ) ) |
---|
65 | { |
---|
66 | $start = 0; |
---|
67 | } |
---|
68 | // on n'affiche la bare de navigation que si on plus de 1 page |
---|
69 | if ( $nb_element > $nb_element_page ) |
---|
70 | { |
---|
71 | // 1.une page précédente ? |
---|
72 | if ( $start != 0 ) |
---|
73 | { |
---|
74 | $previous = $start - $nb_element_page; |
---|
75 | $navigation_bar.= '<a href="'; |
---|
76 | $navigation_bar.= add_session_id( $url.'&start='.$previous ); |
---|
77 | $navigation_bar.= '" class="'.$link_class.'">'.$lang['previous_page']; |
---|
78 | $navigation_bar.= '</a>'; |
---|
79 | $navigation_bar.= ' | '; |
---|
80 | } |
---|
81 | // 2.liste des numéros de page |
---|
82 | $maximum = ceil ( $nb_element / $nb_element_page ); |
---|
83 | for ( $i = 1; $i <= $maximum; $i++ ) |
---|
84 | { |
---|
85 | $temp_start = ( $i - 1 ) * $nb_element_page; |
---|
86 | if ( $temp_start == $start ) |
---|
87 | { |
---|
88 | $navigation_bar.= ' <span style="font-weight:bold;">'.$i.'</span> '; |
---|
89 | } |
---|
90 | else |
---|
91 | { |
---|
92 | $navigation_bar.= ' <a href="'; |
---|
93 | $navigation_bar.= add_session_id( $url.'&start='.$temp_start ); |
---|
94 | $navigation_bar.= '" class="'.$link_class.'">'.$i.'</a> '; |
---|
95 | } |
---|
96 | } |
---|
97 | // 3.une page suivante ? |
---|
98 | if ( $nb_element > $nb_element_page |
---|
99 | && $start + $nb_element_page < $nb_element ) |
---|
100 | { |
---|
101 | $next = $start + $nb_element_page; |
---|
102 | $navigation_bar.= ' | <a href="'; |
---|
103 | $navigation_bar.= add_session_id( $url.'&start='.$next ); |
---|
104 | $navigation_bar.= '" class="'.$link_class.'">'.$lang['next_page'].'</a>'; |
---|
105 | } |
---|
106 | } |
---|
107 | return $navigation_bar; |
---|
108 | } |
---|
109 | |
---|
110 | // |
---|
111 | // Pick a language, any language ... |
---|
112 | // |
---|
113 | function language_select($default, $select_name = "language") |
---|
114 | { |
---|
115 | global $lang_info; |
---|
116 | $dir = opendir(PHPWG_ROOT_PATH . 'language'); |
---|
117 | $available_lang= array(); |
---|
118 | |
---|
119 | while ( $file = readdir($dir) ) |
---|
120 | { |
---|
121 | if (is_dir ( realpath(PHPWG_ROOT_PATH.'language/'.$file) ) |
---|
122 | && !is_link(realpath(PHPWG_ROOT_PATH . 'language/' . $file)) |
---|
123 | && isset($lang_info['language'][$file])) |
---|
124 | { |
---|
125 | $available_lang[$file] = $lang_info['language'][$file]; |
---|
126 | } |
---|
127 | } |
---|
128 | closedir($dir); |
---|
129 | @asort($available_lang); |
---|
130 | @reset($available_lang); |
---|
131 | |
---|
132 | $lang_select = '<select name="' . $select_name . '" onchange="this.form.submit()">'; |
---|
133 | while ( list($code, $displayname) = @each($available_lang) ) |
---|
134 | { |
---|
135 | $selected = ( strtolower($default) == strtolower($code) ) ? ' selected="selected"' : ''; |
---|
136 | $lang_select .= '<option value="' . $code . '"' . $selected . '>' . ucwords($displayname) . '</option>'; |
---|
137 | } |
---|
138 | $lang_select .= '</select>'; |
---|
139 | |
---|
140 | return $lang_select; |
---|
141 | } |
---|
142 | |
---|
143 | // |
---|
144 | // Pick a template/theme combo, |
---|
145 | // |
---|
146 | function style_select($default_style, $select_name = "style") |
---|
147 | { |
---|
148 | $dir = opendir(PHPWG_ROOT_PATH . 'template'); |
---|
149 | $style_select = '<select name="' . $select_name . '">'; |
---|
150 | while ( $file = readdir($dir) ) |
---|
151 | { |
---|
152 | if (is_dir ( realpath(PHPWG_ROOT_PATH.'template/'.$file) ) |
---|
153 | && !is_link(realpath(PHPWG_ROOT_PATH . 'template/' . $file)) |
---|
154 | && !strstr($file,'.')) |
---|
155 | { |
---|
156 | $selected = ( $file == $default_style ) ? ' selected="selected"' : ''; |
---|
157 | $style_select .= '<option value="' . $file . '"' . $selected . '>' . $file . '</option>'; |
---|
158 | } |
---|
159 | } |
---|
160 | closedir($dir); |
---|
161 | return $style_select; |
---|
162 | } |
---|
163 | |
---|
164 | // The function get_cat_display_name returns a string containing the list |
---|
165 | // of upper categories to the root category from the lowest category shown |
---|
166 | // example : "anniversaires - fete mere 2002 - animaux - erika" |
---|
167 | // You can give this parameters : |
---|
168 | // - $style : the style of the span tag for the lowest category, |
---|
169 | // "font-style:italic;" for example |
---|
170 | function get_cat_display_name( $cat_informations, $separator, |
---|
171 | $url = 'category.php?cat=', $replace_space = true) |
---|
172 | { |
---|
173 | $output = ''; |
---|
174 | $i=0; |
---|
175 | while ( list ($id, $name) = each($cat_informations)) |
---|
176 | { |
---|
177 | if ( $i ) $output.= $separator; |
---|
178 | $i++; |
---|
179 | if (empty($style) && empty($url) || ($i == count( $cat_informations))) |
---|
180 | $output.= $name; |
---|
181 | elseif (!empty($url)) |
---|
182 | $output.= '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.$url.$id).'">'.$name."</a>"; |
---|
183 | else |
---|
184 | $output.= '<span style="'.$style.'">'.$name.'</span>'; |
---|
185 | } |
---|
186 | if ( $replace_space ) return replace_space( $output ); |
---|
187 | else return $output; |
---|
188 | } |
---|
189 | ?> |
---|