2004-08-06 09:35:07 +00:00
|
|
|
<?php
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-06 21:12:59 +00:00
|
|
|
// | PhpWebGallery - a PHP based picture gallery |
|
|
|
|
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
2007-01-23 22:03:06 +00:00
|
|
|
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
2004-08-06 09:35:07 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
2007-02-25 11:42:25 +00:00
|
|
|
// | file : $Id$
|
2004-08-06 09:35:07 +00:00
|
|
|
// | last update : $Date$
|
|
|
|
// | last modifier : $Author$
|
|
|
|
// | revision : $Revision$
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | This program is free software; you can redistribute it and/or modify |
|
|
|
|
// | it under the terms of the GNU General Public License as published by |
|
|
|
|
// | the Free Software Foundation |
|
|
|
|
// | |
|
|
|
|
// | This program is distributed in the hope that it will be useful, but |
|
|
|
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
|
// | General Public License for more details. |
|
|
|
|
// | |
|
|
|
|
// | You should have received a copy of the GNU General Public License |
|
|
|
|
// | along with this program; if not, write to the Free Software |
|
|
|
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
|
|
|
// | USA. |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
2006-12-01 23:31:19 +00:00
|
|
|
function get_icon($date, $is_child_date = false)
|
2004-08-06 09:35:07 +00:00
|
|
|
{
|
2006-12-07 23:21:54 +00:00
|
|
|
global $page, $user, $lang;
|
2004-08-06 09:35:07 +00:00
|
|
|
|
2006-02-13 22:15:56 +00:00
|
|
|
if (empty($date))
|
2004-08-21 13:50:54 +00:00
|
|
|
{
|
2006-12-07 23:21:54 +00:00
|
|
|
return '';
|
2004-08-21 13:50:54 +00:00
|
|
|
}
|
|
|
|
|
2006-12-07 23:21:54 +00:00
|
|
|
if (isset($page['get_icon_cache'][$date]))
|
2006-02-13 22:15:56 +00:00
|
|
|
{
|
2006-12-07 23:21:54 +00:00
|
|
|
if (! $page['get_icon_cache'][$date] )
|
|
|
|
return '';
|
|
|
|
return $page['get_icon_cache']['_icons_'][$is_child_date];
|
2006-02-13 22:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})/', $date, $matches))
|
2006-12-07 23:21:54 +00:00
|
|
|
{// date can be empty, no icon to display
|
|
|
|
$page['get_icon_cache'][$date] = false;
|
|
|
|
return '';
|
2006-02-13 22:15:56 +00:00
|
|
|
}
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2006-02-13 22:15:56 +00:00
|
|
|
list($devnull, $year, $month, $day) = $matches;
|
2004-08-06 09:35:07 +00:00
|
|
|
$unixtime = mktime( 0, 0, 0, $month, $day, $year );
|
2006-02-13 22:15:56 +00:00
|
|
|
if ($unixtime === false // PHP 5.1.0 and above
|
|
|
|
or $unixtime === -1) // PHP prior to 5.1.0
|
|
|
|
{
|
2006-12-07 23:21:54 +00:00
|
|
|
$page['get_icon_cache'][$date] = false;
|
|
|
|
return '';
|
2006-02-13 22:15:56 +00:00
|
|
|
}
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-08-06 09:35:07 +00:00
|
|
|
$diff = time() - $unixtime;
|
|
|
|
$day_in_seconds = 24*60*60;
|
2006-12-07 23:21:54 +00:00
|
|
|
$page['get_icon_cache'][$date] = false;
|
2004-08-06 09:35:07 +00:00
|
|
|
if ( $diff < $user['recent_period'] * $day_in_seconds )
|
|
|
|
{
|
2006-12-07 23:21:54 +00:00
|
|
|
if ( !isset($page['get_icon_cache']['_icons_'] ) )
|
|
|
|
{
|
|
|
|
$icons = array(false => 'recent', true => 'recent_by_child' );
|
|
|
|
$title = $lang['recent_image'].' '.$user['recent_period']
|
|
|
|
.' '.$lang['days'];
|
|
|
|
foreach ($icons as $key => $icon)
|
|
|
|
{
|
|
|
|
$icon_url = get_themeconf('icon_dir').'/'.$icon.'.png';
|
|
|
|
$size = getimagesize( PHPWG_ROOT_PATH.$icon_url );
|
|
|
|
$icon_url = get_root_url().$icon_url;
|
|
|
|
$output = '<img title="'.$title.'" src="'.$icon_url.'" class="icon" style="border:0;';
|
|
|
|
$output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)" />';
|
|
|
|
$page['get_icon_cache']['_icons_'][$key] = $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$page['get_icon_cache'][$date] = true;
|
2004-08-06 09:35:07 +00:00
|
|
|
}
|
2006-12-07 23:21:54 +00:00
|
|
|
if (! $page['get_icon_cache'][$date] )
|
|
|
|
return '';
|
|
|
|
return $page['get_icon_cache']['_icons_'][$is_child_date];
|
2004-08-06 09:35:07 +00:00
|
|
|
}
|
|
|
|
|
2006-12-07 23:21:54 +00:00
|
|
|
|
2006-03-16 22:34:45 +00:00
|
|
|
function create_navigation_bar(
|
|
|
|
$url, $nb_element, $start, $nb_element_page, $clean_url = false
|
|
|
|
)
|
2004-08-06 09:35:07 +00:00
|
|
|
{
|
2004-12-13 22:54:44 +00:00
|
|
|
global $lang, $conf;
|
|
|
|
|
|
|
|
$pages_around = $conf['paginate_pages_around'];
|
2006-10-17 02:03:14 +00:00
|
|
|
$start_str = $clean_url ? '/start-' :
|
|
|
|
( ( strstr($url, '?')===false ? '?':'&') . 'start=' );
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-12-13 22:59:25 +00:00
|
|
|
$navbar = '';
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-12-13 22:54:44 +00:00
|
|
|
// current page detection
|
|
|
|
if (!isset($start)
|
|
|
|
or !is_numeric($start)
|
|
|
|
or (is_numeric($start) and $start < 0))
|
2004-08-06 09:35:07 +00:00
|
|
|
{
|
|
|
|
$start = 0;
|
|
|
|
}
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-12-13 22:54:44 +00:00
|
|
|
// navigation bar useful only if more than one page to display !
|
|
|
|
if ($nb_element > $nb_element_page)
|
2004-08-06 09:35:07 +00:00
|
|
|
{
|
2004-12-13 22:59:25 +00:00
|
|
|
// current page and last page
|
2004-12-13 22:54:44 +00:00
|
|
|
$cur_page = ceil($start / $nb_element_page) + 1;
|
|
|
|
$maximum = ceil($nb_element / $nb_element_page);
|
|
|
|
|
|
|
|
// link to first page ?
|
|
|
|
if ($cur_page != 1)
|
|
|
|
{
|
2006-03-16 22:34:45 +00:00
|
|
|
$navbar.=
|
|
|
|
'<a href="'.$url.'" rel="start">'
|
|
|
|
.$lang['first_page']
|
|
|
|
.'</a>';
|
2004-12-13 22:54:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-13 22:59:25 +00:00
|
|
|
$navbar.= $lang['first_page'];
|
2004-12-13 22:54:44 +00:00
|
|
|
}
|
2004-12-13 22:59:25 +00:00
|
|
|
$navbar.= ' | ';
|
2004-12-13 22:54:44 +00:00
|
|
|
// link on previous page ?
|
2006-03-16 22:34:45 +00:00
|
|
|
if ($start != 0)
|
2004-08-06 09:35:07 +00:00
|
|
|
{
|
|
|
|
$previous = $start - $nb_element_page;
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2006-03-16 22:34:45 +00:00
|
|
|
$navbar.=
|
|
|
|
'<a href="'
|
|
|
|
.$url.($previous > 0 ? $start_str.$previous : '')
|
|
|
|
.'" rel="prev">'
|
|
|
|
.$lang['previous_page']
|
|
|
|
.'</a>';
|
2004-08-06 09:35:07 +00:00
|
|
|
}
|
2004-12-13 22:54:44 +00:00
|
|
|
else
|
|
|
|
{
|
2004-12-13 22:59:25 +00:00
|
|
|
$navbar.= $lang['previous_page'];
|
2004-12-13 22:54:44 +00:00
|
|
|
}
|
2006-02-10 02:10:41 +00:00
|
|
|
$navbar.= ' |';
|
2004-12-13 22:54:44 +00:00
|
|
|
|
|
|
|
if ($cur_page > $pages_around + 1)
|
|
|
|
{
|
2006-03-16 22:34:45 +00:00
|
|
|
$navbar.= ' <a href="'.$url.'">1</a>';
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2005-01-08 00:18:39 +00:00
|
|
|
if ($cur_page > $pages_around + 2)
|
|
|
|
{
|
|
|
|
$navbar.= ' ...';
|
|
|
|
}
|
2004-12-13 22:54:44 +00:00
|
|
|
}
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-12-13 22:54:44 +00:00
|
|
|
// inspired from punbb source code
|
|
|
|
for ($i = $cur_page - $pages_around, $stop = $cur_page + $pages_around + 1;
|
|
|
|
$i < $stop;
|
|
|
|
$i++)
|
2004-08-06 09:35:07 +00:00
|
|
|
{
|
2004-12-13 22:54:44 +00:00
|
|
|
if ($i < 1 or $i > $maximum)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if ($i != $cur_page)
|
2004-08-06 09:35:07 +00:00
|
|
|
{
|
2004-12-13 22:54:44 +00:00
|
|
|
$temp_start = ($i - 1) * $nb_element_page;
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2006-03-16 22:34:45 +00:00
|
|
|
$navbar.=
|
|
|
|
' '
|
|
|
|
.'<a href="'.$url
|
|
|
|
.($temp_start > 0 ? $start_str.$temp_start : '')
|
|
|
|
.'">'
|
|
|
|
.$i
|
|
|
|
.'</a>';
|
2004-08-06 09:35:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-16 22:34:45 +00:00
|
|
|
$navbar.=
|
|
|
|
' '
|
|
|
|
.'<span class="pageNumberSelected">'
|
|
|
|
.$i
|
|
|
|
.'</span>';
|
2004-08-06 09:35:07 +00:00
|
|
|
}
|
|
|
|
}
|
2004-12-13 22:54:44 +00:00
|
|
|
|
|
|
|
if ($cur_page < ($maximum - $pages_around))
|
|
|
|
{
|
|
|
|
$temp_start = ($maximum - 1) * $nb_element_page;
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2005-01-08 00:18:39 +00:00
|
|
|
if ($cur_page < ($maximum - $pages_around - 1))
|
|
|
|
{
|
|
|
|
$navbar.= ' ...';
|
|
|
|
}
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2006-03-16 22:34:45 +00:00
|
|
|
$navbar.= ' <a href="'.$url.$start_str.$temp_start.'">'.$maximum.'</a>';
|
2004-12-13 22:54:44 +00:00
|
|
|
}
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-12-13 22:59:25 +00:00
|
|
|
$navbar.= ' | ';
|
2004-12-13 22:54:44 +00:00
|
|
|
// link on next page ?
|
2006-03-16 22:34:45 +00:00
|
|
|
if ($nb_element > $nb_element_page
|
|
|
|
and $start + $nb_element_page < $nb_element)
|
2004-08-06 09:35:07 +00:00
|
|
|
{
|
|
|
|
$next = $start + $nb_element_page;
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2006-03-16 22:34:45 +00:00
|
|
|
$navbar.=
|
|
|
|
'<a href="'.$url.$start_str.$next.'" rel="next">'
|
|
|
|
.$lang['next_page']
|
|
|
|
.'</a>';
|
2004-08-06 09:35:07 +00:00
|
|
|
}
|
2004-12-13 22:54:44 +00:00
|
|
|
else
|
|
|
|
{
|
2004-12-13 22:59:25 +00:00
|
|
|
$navbar.= $lang['next_page'];
|
2004-12-13 22:54:44 +00:00
|
|
|
}
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-12-18 22:05:30 +00:00
|
|
|
$navbar.= ' | ';
|
2004-12-13 22:54:44 +00:00
|
|
|
// link to last page ?
|
|
|
|
if ($cur_page != $maximum)
|
|
|
|
{
|
|
|
|
$temp_start = ($maximum - 1) * $nb_element_page;
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2006-03-16 22:34:45 +00:00
|
|
|
$navbar.=
|
|
|
|
'<a href="'.$url.$start_str.$temp_start.'" rel="last">'
|
|
|
|
.$lang['last_page']
|
|
|
|
.'</a>';
|
2004-12-13 22:54:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-13 22:59:25 +00:00
|
|
|
$navbar.= $lang['last_page'];
|
2004-12-13 22:54:44 +00:00
|
|
|
}
|
2004-08-06 09:35:07 +00:00
|
|
|
}
|
2004-12-13 22:59:25 +00:00
|
|
|
return $navbar;
|
2004-08-06 09:35:07 +00:00
|
|
|
}
|
|
|
|
|
2004-10-23 09:00:26 +00:00
|
|
|
/**
|
|
|
|
* returns the list of categories as a HTML string
|
|
|
|
*
|
|
|
|
* categories string returned contains categories as given in the input
|
|
|
|
* array $cat_informations. $cat_informations array must be an association
|
2006-03-22 01:01:47 +00:00
|
|
|
* of {category_id => category_name}. If url input parameter is null,
|
2004-10-23 09:00:26 +00:00
|
|
|
* returns only the categories name without links.
|
|
|
|
*
|
|
|
|
* @param array cat_informations
|
|
|
|
* @param string url
|
|
|
|
* @param boolean replace_space
|
|
|
|
* @return string
|
|
|
|
*/
|
2004-10-21 21:17:46 +00:00
|
|
|
function get_cat_display_name($cat_informations,
|
2006-03-22 01:01:47 +00:00
|
|
|
$url = '',
|
2004-10-21 21:17:46 +00:00
|
|
|
$replace_space = true)
|
2004-08-06 09:35:07 +00:00
|
|
|
{
|
2004-12-12 21:06:39 +00:00
|
|
|
global $conf;
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-08-06 09:35:07 +00:00
|
|
|
$output = '';
|
2004-10-21 21:17:46 +00:00
|
|
|
$is_first = true;
|
|
|
|
foreach ($cat_informations as $id => $name)
|
2004-08-06 09:35:07 +00:00
|
|
|
{
|
2004-10-21 21:17:46 +00:00
|
|
|
if ($is_first)
|
|
|
|
{
|
|
|
|
$is_first = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-12 21:06:39 +00:00
|
|
|
$output.= $conf['level_separator'];
|
2004-10-21 21:17:46 +00:00
|
|
|
}
|
|
|
|
|
2006-03-22 01:01:47 +00:00
|
|
|
if ( !isset($url) )
|
2004-10-21 21:17:46 +00:00
|
|
|
{
|
|
|
|
$output.= $name;
|
|
|
|
}
|
2006-03-22 01:01:47 +00:00
|
|
|
elseif ($url == '')
|
|
|
|
{
|
2007-02-08 01:31:05 +00:00
|
|
|
$output.= '<a href="'
|
2007-01-23 22:03:06 +00:00
|
|
|
.make_index_url(
|
2006-04-06 02:23:54 +00:00
|
|
|
array(
|
|
|
|
'category'=>$id,
|
|
|
|
'cat_name'=>$name
|
2007-01-23 22:03:06 +00:00
|
|
|
)
|
2006-04-06 02:23:54 +00:00
|
|
|
)
|
|
|
|
.'">';
|
2006-03-22 01:01:47 +00:00
|
|
|
$output.= $name.'</a>';
|
|
|
|
}
|
2004-10-21 21:17:46 +00:00
|
|
|
else
|
|
|
|
{
|
2007-02-08 01:31:05 +00:00
|
|
|
$output.= '<a href="'.PHPWG_ROOT_PATH.$url.$id.'">';
|
2005-08-18 17:59:00 +00:00
|
|
|
$output.= $name.'</a>';
|
2004-10-21 21:17:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($replace_space)
|
|
|
|
{
|
|
|
|
return replace_space($output);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $output;
|
2004-08-06 09:35:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-20 17:23:42 +00:00
|
|
|
/**
|
|
|
|
* returns the list of categories as a HTML string, with cache of names
|
|
|
|
*
|
|
|
|
* categories string returned contains categories as given in the input
|
|
|
|
* array $cat_informations. $uppercats is the list of category ids to
|
|
|
|
* display in the right order. If url input parameter is empty, returns only
|
|
|
|
* the categories name without links.
|
|
|
|
*
|
|
|
|
* @param string uppercats
|
|
|
|
* @param string url
|
|
|
|
* @param boolean replace_space
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function get_cat_display_name_cache($uppercats,
|
2006-03-22 01:01:47 +00:00
|
|
|
$url = '',
|
2004-11-20 17:23:42 +00:00
|
|
|
$replace_space = true)
|
|
|
|
{
|
2004-12-12 21:06:39 +00:00
|
|
|
global $cat_names, $conf;
|
2004-11-20 17:23:42 +00:00
|
|
|
|
|
|
|
if (!isset($cat_names))
|
|
|
|
{
|
|
|
|
$query = '
|
|
|
|
SELECT id,name
|
|
|
|
FROM '.CATEGORIES_TABLE.'
|
|
|
|
;';
|
|
|
|
$result = pwg_query($query);
|
|
|
|
while ($row = mysql_fetch_array($result))
|
|
|
|
{
|
|
|
|
$cat_names[$row['id']] = $row['name'];
|
|
|
|
}
|
|
|
|
}
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-11-20 17:23:42 +00:00
|
|
|
$output = '';
|
|
|
|
$is_first = true;
|
|
|
|
foreach (explode(',', $uppercats) as $category_id)
|
|
|
|
{
|
|
|
|
$name = $cat_names[$category_id];
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-11-20 17:23:42 +00:00
|
|
|
if ($is_first)
|
|
|
|
{
|
|
|
|
$is_first = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-12 21:06:39 +00:00
|
|
|
$output.= $conf['level_separator'];
|
2004-11-20 17:23:42 +00:00
|
|
|
}
|
|
|
|
|
2006-03-22 01:01:47 +00:00
|
|
|
if ( !isset($url) )
|
2004-11-20 17:23:42 +00:00
|
|
|
{
|
|
|
|
$output.= $name;
|
|
|
|
}
|
2006-03-22 01:01:47 +00:00
|
|
|
elseif ($url == '')
|
|
|
|
{
|
|
|
|
$output.= '
|
2007-02-08 01:31:05 +00:00
|
|
|
<a href="'
|
2006-04-06 02:23:54 +00:00
|
|
|
.make_index_url(
|
|
|
|
array(
|
|
|
|
'category'=>$category_id,
|
|
|
|
'cat_name'=>$name
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.'">'.$name.'</a>';
|
2006-03-22 01:01:47 +00:00
|
|
|
}
|
2004-11-20 17:23:42 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$output.= '
|
2007-02-08 01:31:05 +00:00
|
|
|
<a href="'.PHPWG_ROOT_PATH.$url.$category_id.'">'.$name.'</a>';
|
2004-11-20 17:23:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($replace_space)
|
|
|
|
{
|
|
|
|
return replace_space($output);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-06 09:35:07 +00:00
|
|
|
/**
|
2006-03-15 22:44:35 +00:00
|
|
|
* returns the HTML code for a category item in the menu (for the main page)
|
2004-08-06 09:35:07 +00:00
|
|
|
*
|
|
|
|
* HTML code generated uses logical list tags ul and each category is an
|
|
|
|
* item li. The paramter given is the category informations as an array,
|
2006-12-07 23:21:54 +00:00
|
|
|
* used keys are : id, name, nb_images, max_date_last, date_last
|
2006-12-01 23:31:19 +00:00
|
|
|
* count_images, count_categories
|
2004-08-06 09:35:07 +00:00
|
|
|
*
|
2004-11-23 22:31:24 +00:00
|
|
|
* @param array categories
|
2004-08-06 09:35:07 +00:00
|
|
|
* @return string
|
|
|
|
*/
|
2004-11-23 22:31:24 +00:00
|
|
|
function get_html_menu_category($categories)
|
2004-08-06 09:35:07 +00:00
|
|
|
{
|
|
|
|
global $page, $lang;
|
|
|
|
|
2004-11-23 22:31:24 +00:00
|
|
|
$ref_level = 0;
|
2005-12-09 22:54:51 +00:00
|
|
|
$level = 0;
|
2005-09-25 18:31:55 +00:00
|
|
|
$menu = '';
|
2006-02-12 21:52:16 +00:00
|
|
|
|
|
|
|
// $page_cat value remains 0 for special sections
|
2006-02-10 02:10:41 +00:00
|
|
|
$page_cat = 0;
|
2006-03-15 22:44:35 +00:00
|
|
|
if (isset($page['category']))
|
2006-02-10 02:10:41 +00:00
|
|
|
{
|
2006-03-15 22:44:35 +00:00
|
|
|
$page_cat = $page['category'];
|
2006-02-10 02:10:41 +00:00
|
|
|
}
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-11-23 22:31:24 +00:00
|
|
|
foreach ($categories as $category)
|
|
|
|
{
|
2005-09-25 18:31:55 +00:00
|
|
|
$level = substr_count($category['global_rank'], '.') + 1;
|
2004-11-23 22:31:24 +00:00
|
|
|
if ($level > $ref_level)
|
|
|
|
{
|
2005-11-18 22:45:16 +00:00
|
|
|
$menu.= "\n<ul>";
|
2005-09-25 18:31:55 +00:00
|
|
|
}
|
|
|
|
else if ($level == $ref_level)
|
|
|
|
{
|
2005-11-18 22:45:16 +00:00
|
|
|
$menu.= "\n</li>";
|
2004-11-23 22:31:24 +00:00
|
|
|
}
|
|
|
|
else if ($level < $ref_level)
|
|
|
|
{
|
2004-12-13 23:53:45 +00:00
|
|
|
// we may have to close more than one level at the same time...
|
2005-09-25 18:31:55 +00:00
|
|
|
$menu.= "\n</li>";
|
2005-11-18 22:45:16 +00:00
|
|
|
$menu.= str_repeat("\n</ul></li>",($ref_level-$level));
|
2004-11-23 22:31:24 +00:00
|
|
|
}
|
|
|
|
$ref_level = $level;
|
2004-08-06 09:35:07 +00:00
|
|
|
|
2005-11-18 22:45:16 +00:00
|
|
|
$menu.= "\n\n".'<li';
|
2006-02-10 02:10:41 +00:00
|
|
|
if ($category['id'] == $page_cat)
|
2004-11-23 22:31:24 +00:00
|
|
|
{
|
- new : HTML BODY identifier to let CSS stylesheets manage specific
behaviour.
- deletion : admin/search useless
- improvement : in admin/user_list, special behaviour for true/false fields
(expand, show_comments)
- new : gallery_title and gallery_description are displayed at the top of
each page.
- improvement : simplification in HTML for categories menu.
- improvement : standardization of presentation in all public pages
(identification, registration, search, profile, notification, comments,
etc.)
(not in ChangeLog, below this line)
- add forgotten notification.php (should have been added in a previous
commit)
- [template cclear] deletion of useless class .bouton
- [template cclear] for test purpose, new presentation of register page
(using FORM.filter)
- [template cclear] adaptation of admin/group_list from template default
- [template cclear] deletion of obsolete admin/infos_images
- [template cclear] deletion of obsolete admin/search_username
- [template cclear] new icon register.png
git-svn-id: http://piwigo.org/svn/trunk@850 68402e56-0260-453c-a942-63ccdbb3a9ee
2005-08-25 22:43:47 +00:00
|
|
|
$menu.= ' class="selected"';
|
2004-11-23 22:31:24 +00:00
|
|
|
}
|
- new : HTML BODY identifier to let CSS stylesheets manage specific
behaviour.
- deletion : admin/search useless
- improvement : in admin/user_list, special behaviour for true/false fields
(expand, show_comments)
- new : gallery_title and gallery_description are displayed at the top of
each page.
- improvement : simplification in HTML for categories menu.
- improvement : standardization of presentation in all public pages
(identification, registration, search, profile, notification, comments,
etc.)
(not in ChangeLog, below this line)
- add forgotten notification.php (should have been added in a previous
commit)
- [template cclear] deletion of useless class .bouton
- [template cclear] for test purpose, new presentation of register page
(using FORM.filter)
- [template cclear] adaptation of admin/group_list from template default
- [template cclear] deletion of obsolete admin/infos_images
- [template cclear] deletion of obsolete admin/search_username
- [template cclear] new icon register.png
git-svn-id: http://piwigo.org/svn/trunk@850 68402e56-0260-453c-a942-63ccdbb3a9ee
2005-08-25 22:43:47 +00:00
|
|
|
$menu.= '>';
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2006-04-06 02:23:54 +00:00
|
|
|
$url = make_index_url(
|
|
|
|
array(
|
|
|
|
'category'=>$category['id'],
|
|
|
|
'cat_name'=>$category['name']
|
|
|
|
)
|
|
|
|
);
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2006-02-10 02:10:41 +00:00
|
|
|
$menu.= "\n".'<a href="'.$url.'"';
|
2006-02-12 21:52:16 +00:00
|
|
|
if ($page_cat != 0
|
|
|
|
and $category['id'] == $page['cat_id_uppercat'])
|
2006-02-10 02:10:41 +00:00
|
|
|
{
|
|
|
|
$menu.= ' rel="up"';
|
|
|
|
}
|
2006-04-29 10:29:32 +00:00
|
|
|
$menu.= '>'.$category['name'].'</a>';
|
2004-08-06 09:35:07 +00:00
|
|
|
|
2007-02-20 01:40:40 +00:00
|
|
|
if ( $category['count_images']>0 )
|
|
|
|
{// at least one direct or indirect image
|
2006-12-01 23:31:19 +00:00
|
|
|
$menu.= "\n".'<span class="';
|
2007-02-20 01:40:40 +00:00
|
|
|
// at least one image in this category -> class menuInfoCat
|
|
|
|
$menu.= ($category['nb_images'] > 0 ? "menuInfoCat"
|
2006-12-01 23:31:19 +00:00
|
|
|
: "menuInfoCatByChild").'"';
|
|
|
|
$menu.= ' title="';
|
|
|
|
$menu.= ' '.get_display_images_count
|
|
|
|
(
|
|
|
|
$category['nb_images'],
|
|
|
|
$category['count_images'],
|
|
|
|
$category['count_categories'],
|
2007-02-22 20:20:30 +00:00
|
|
|
false,
|
|
|
|
' / '
|
2006-12-01 23:31:19 +00:00
|
|
|
).'">';
|
2007-02-20 01:40:40 +00:00
|
|
|
// show total number of images
|
|
|
|
$menu.= '['.$category['count_images'].']';
|
2005-08-18 21:31:21 +00:00
|
|
|
$menu.= '</span>';
|
2004-11-23 22:31:24 +00:00
|
|
|
}
|
2006-12-08 00:12:44 +00:00
|
|
|
$child_date_last = @$category['max_date_last']> @$category['date_last'];
|
2006-12-07 23:21:54 +00:00
|
|
|
$menu.= get_icon($category['max_date_last'], $child_date_last);
|
2004-08-06 09:35:07 +00:00
|
|
|
}
|
2005-11-18 22:45:16 +00:00
|
|
|
|
|
|
|
$menu.= str_repeat("\n</li></ul>",($level));
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-08-06 09:35:07 +00:00
|
|
|
return $menu;
|
|
|
|
}
|
2004-10-23 17:56:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* returns HTMLized comment contents retrieved from database
|
|
|
|
*
|
|
|
|
* newlines becomes br tags, _word_ becomes underline, /word/ becomes
|
|
|
|
* italic, *word* becomes bolded
|
|
|
|
*
|
|
|
|
* @param string content
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function parse_comment_content($content)
|
|
|
|
{
|
2006-02-10 02:10:41 +00:00
|
|
|
$pattern = '/(https?:\/\/\S*)/';
|
|
|
|
$replacement = '<a href="$1" rel="nofollow">$1</a>';
|
2006-02-09 20:38:07 +00:00
|
|
|
$content = preg_replace($pattern, $replacement, $content);
|
2006-02-10 02:10:41 +00:00
|
|
|
|
|
|
|
$content = nl2br($content);
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-10-23 17:56:46 +00:00
|
|
|
// replace _word_ by an underlined word
|
2006-02-09 20:38:07 +00:00
|
|
|
$pattern = '/\b_(\S*)_\b/';
|
|
|
|
$replacement = '<span style="text-decoration:underline;">$1</span>';
|
2004-10-23 17:56:46 +00:00
|
|
|
$content = preg_replace($pattern, $replacement, $content);
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-10-23 17:56:46 +00:00
|
|
|
// replace *word* by a bolded word
|
2006-02-09 20:38:07 +00:00
|
|
|
$pattern = '/\b\*(\S*)\*\b/';
|
|
|
|
$replacement = '<span style="font-weight:bold;">$1</span>';
|
2004-10-23 17:56:46 +00:00
|
|
|
$content = preg_replace($pattern, $replacement, $content);
|
2006-03-21 01:27:21 +00:00
|
|
|
|
2004-10-23 17:56:46 +00:00
|
|
|
// replace /word/ by an italic word
|
2006-02-10 02:10:41 +00:00
|
|
|
$pattern = "/\/(\S*)\/(\s)/";
|
|
|
|
$replacement = '<span style="font-style:italic;">$1$2</span>';
|
|
|
|
$content = preg_replace($pattern, $replacement, $content);
|
2004-10-23 17:56:46 +00:00
|
|
|
|
2006-04-25 20:38:11 +00:00
|
|
|
$content = '<div>'.$content.'</div>';
|
2004-10-23 17:56:46 +00:00
|
|
|
return $content;
|
|
|
|
}
|
2005-08-17 14:25:38 +00:00
|
|
|
|
|
|
|
function get_cat_display_name_from_id($cat_id,
|
2006-03-22 01:01:47 +00:00
|
|
|
$url = '',
|
2005-08-17 14:25:38 +00:00
|
|
|
$replace_space = true)
|
|
|
|
{
|
|
|
|
$cat_info = get_cat_info($cat_id);
|
2005-08-18 17:59:00 +00:00
|
|
|
return get_cat_display_name($cat_info['name'], $url, $replace_space);
|
2005-08-17 14:25:38 +00:00
|
|
|
}
|
2006-03-30 00:37:07 +00:00
|
|
|
|
2006-04-02 22:26:19 +00:00
|
|
|
/**
|
|
|
|
* Returns an HTML list of tags. It can be a multi select field or a list of
|
|
|
|
* checkboxes.
|
|
|
|
*
|
|
|
|
* @param string HTML field name
|
|
|
|
* @param array selected tag ids
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function get_html_tag_selection(
|
|
|
|
$tags,
|
|
|
|
$fieldname,
|
|
|
|
$selecteds = array(),
|
|
|
|
$forbidden_categories = null
|
|
|
|
)
|
|
|
|
{
|
|
|
|
global $conf;
|
2006-04-06 02:23:54 +00:00
|
|
|
|
2006-04-18 22:57:05 +00:00
|
|
|
if (count ($tags) == 0 )
|
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
2006-04-02 22:26:19 +00:00
|
|
|
$output = '<ul class="tagSelection">';
|
|
|
|
foreach ($tags as $tag)
|
|
|
|
{
|
|
|
|
$output.=
|
|
|
|
'<li>'
|
|
|
|
.'<label>'
|
|
|
|
.'<input type="checkbox" name="'.$fieldname.'[]"'
|
2007-02-14 01:37:38 +00:00
|
|
|
.' value="'.$tag['id'].'"'
|
2006-04-02 22:26:19 +00:00
|
|
|
;
|
|
|
|
|
2007-02-14 01:37:38 +00:00
|
|
|
if (in_array($tag['id'], $selecteds))
|
2006-04-02 22:26:19 +00:00
|
|
|
{
|
|
|
|
$output.= ' checked="checked"';
|
|
|
|
}
|
2006-04-06 02:23:54 +00:00
|
|
|
|
2006-04-02 22:26:19 +00:00
|
|
|
$output.=
|
|
|
|
' />'
|
2006-04-29 10:29:32 +00:00
|
|
|
.' '. $tag['name']
|
2006-04-02 22:26:19 +00:00
|
|
|
.'</label>'
|
|
|
|
.'</li>'
|
|
|
|
."\n"
|
|
|
|
;
|
|
|
|
}
|
|
|
|
$output.= '</ul>';
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
function name_compare($a, $b)
|
|
|
|
{
|
2006-05-15 21:22:43 +00:00
|
|
|
return strcmp(strtolower($a['name']), strtolower($b['name']));
|
2006-04-02 22:26:19 +00:00
|
|
|
}
|
|
|
|
|
2006-03-30 00:37:07 +00:00
|
|
|
/**
|
|
|
|
* exits the current script (either exit or redirect)
|
|
|
|
*/
|
|
|
|
function access_denied()
|
|
|
|
{
|
|
|
|
global $user, $lang;
|
|
|
|
|
|
|
|
$login_url =
|
|
|
|
get_root_url().'identification.php?redirect='
|
|
|
|
.urlencode(urlencode($_SERVER['REQUEST_URI']));
|
|
|
|
|
|
|
|
if ( isset($user['is_the_guest']) and !$user['is_the_guest'] )
|
|
|
|
{
|
|
|
|
echo '<div style="text-align:center;">'.$lang['access_forbiden'].'<br />';
|
|
|
|
echo '<a href="'.get_root_url().'identification.php">'.$lang['identification'].'</a> ';
|
|
|
|
echo '<a href="'.make_index_url().'">'.$lang['home'].'</a></div>';
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-12-08 00:12:44 +00:00
|
|
|
set_status_header(401);
|
2006-12-11 06:04:53 +00:00
|
|
|
redirect_html($login_url);
|
2006-03-30 00:37:07 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-28 05:12:25 +00:00
|
|
|
|
2006-12-13 01:05:38 +00:00
|
|
|
/**
|
|
|
|
* exits the current script with 403 code
|
|
|
|
* @param string msg a message to display
|
|
|
|
* @param string alternate_url redirect to this url
|
|
|
|
*/
|
|
|
|
function page_forbidden($msg, $alternate_url=null)
|
|
|
|
{
|
|
|
|
set_status_header(403);
|
|
|
|
if ($alternate_url==null)
|
|
|
|
$alternate_url = make_index_url();
|
|
|
|
redirect_html( $alternate_url,
|
|
|
|
'<div style="text-align:left; margin-left:5em;margin-bottom:5em;">
|
|
|
|
<h1 style="text-align:left; font-size:36px;">Forbidden</h1><br/>'
|
|
|
|
.$msg.'</div>',
|
|
|
|
5 );
|
|
|
|
}
|
|
|
|
|
2007-02-23 13:18:34 +00:00
|
|
|
/**
|
|
|
|
* exits the current script with 400 code
|
|
|
|
* @param string msg a message to display
|
|
|
|
* @param string alternate_url redirect to this url
|
|
|
|
*/
|
|
|
|
function bad_request($msg, $alternate_url=null)
|
|
|
|
{
|
|
|
|
set_status_header(400);
|
|
|
|
if ($alternate_url==null)
|
|
|
|
$alternate_url = make_index_url();
|
|
|
|
redirect_html( $alternate_url,
|
|
|
|
'<div style="text-align:left; margin-left:5em;margin-bottom:5em;">
|
|
|
|
<h1 style="text-align:left; font-size:36px;">Bad request</h1><br/>'
|
|
|
|
.$msg.'</div>',
|
|
|
|
5 );
|
|
|
|
}
|
|
|
|
|
2006-04-28 05:12:25 +00:00
|
|
|
/**
|
|
|
|
* exits the current script with 404 code when a page cannot be found
|
|
|
|
* @param string msg a message to display
|
|
|
|
* @param string alternate_url redirect to this url
|
|
|
|
*/
|
|
|
|
function page_not_found($msg, $alternate_url=null)
|
|
|
|
{
|
2006-12-08 00:12:44 +00:00
|
|
|
set_status_header(404);
|
2006-04-28 05:12:25 +00:00
|
|
|
if ($alternate_url==null)
|
|
|
|
$alternate_url = make_index_url();
|
2006-12-11 06:04:53 +00:00
|
|
|
redirect_html( $alternate_url,
|
2006-04-28 05:12:25 +00:00
|
|
|
'<div style="text-align:left; margin-left:5em;margin-bottom:5em;">
|
|
|
|
<h1 style="text-align:left; font-size:36px;">Page not found</h1><br/>'
|
|
|
|
.$msg.'</div>',
|
|
|
|
5 );
|
|
|
|
}
|
2006-11-14 02:53:24 +00:00
|
|
|
|
|
|
|
/* returns the title to be displayed above thumbnails on tag page
|
|
|
|
*/
|
|
|
|
function get_tags_content_title()
|
|
|
|
{
|
|
|
|
global $page;
|
|
|
|
$title = count($page['tags']) > 1 ? l10n('Tags') : l10n('Tag');
|
|
|
|
$title.= ' ';
|
|
|
|
|
|
|
|
for ($i=0; $i<count($page['tags']); $i++)
|
|
|
|
{
|
|
|
|
$title.= $i>0 ? ' + ' : '';
|
|
|
|
|
|
|
|
$title.=
|
|
|
|
'<a href="'
|
|
|
|
.make_index_url(
|
|
|
|
array(
|
|
|
|
'tags' => array( $page['tags'][$i] )
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.'" title="'
|
|
|
|
.l10n('See pictures linked to this tag only')
|
|
|
|
.'">'
|
|
|
|
.$page['tags'][$i]['name']
|
|
|
|
.'</a>';
|
|
|
|
|
|
|
|
if ( count($page['tags'])>2 )
|
|
|
|
{
|
|
|
|
$other_tags = $page['tags'];
|
|
|
|
unset ( $other_tags[$i] );
|
|
|
|
$title.=
|
|
|
|
'<a href="'
|
|
|
|
.make_index_url(
|
|
|
|
array(
|
|
|
|
'tags' => $other_tags
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.'" style="border:none;" title="'
|
|
|
|
.l10n('remove this tag')
|
|
|
|
.'"><img src="'
|
|
|
|
.get_root_url().get_themeconf('icon_dir').'/remove_s.png'
|
|
|
|
.'" alt="x" style="vertical-align:bottom;" class="button"/>'
|
|
|
|
.'</a>';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return $title;
|
|
|
|
}
|
2006-12-08 00:12:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the http status header (200,401,...)
|
|
|
|
*/
|
|
|
|
function set_status_header($code, $text='')
|
|
|
|
{
|
|
|
|
if (empty($text))
|
|
|
|
{
|
|
|
|
switch ($code)
|
|
|
|
{
|
|
|
|
case 200: $text='OK';break;
|
|
|
|
case 301: $text='Moved permanently';break;
|
|
|
|
case 302: $text='Moved temporarily';break;
|
|
|
|
case 304: $text='Not modified';break;
|
|
|
|
case 400: $text='Bad request';break;
|
|
|
|
case 401: $text='Authorization required';break;
|
|
|
|
case 403: $text='Forbidden';break;
|
|
|
|
case 404: $text='Not found';break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
header("HTTP/1.1 $code $text");
|
|
|
|
header("Status: $code $text");
|
2007-01-23 01:22:52 +00:00
|
|
|
trigger_action('set_status_header', $code, $text);
|
2006-12-08 00:12:44 +00:00
|
|
|
}
|
2007-01-30 07:00:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set a class to display a counter
|
2007-02-16 21:28:50 +00:00
|
|
|
* .zero .one .plural
|
2007-01-30 07:00:17 +00:00
|
|
|
*/
|
|
|
|
function set_span_class($count)
|
|
|
|
{
|
|
|
|
if ($count > 1)
|
|
|
|
{
|
2007-02-16 21:28:50 +00:00
|
|
|
return 'plural';
|
2007-01-30 07:00:17 +00:00
|
|
|
}
|
|
|
|
return ( $count == 0 ) ? 'zero':'one';
|
|
|
|
}
|
2006-04-02 22:26:19 +00:00
|
|
|
?>
|