'; } return $output; } function create_navigation_bar($url, $nb_element, $start, $nb_element_page, $link_class) { global $lang, $conf; $pages_around = $conf['paginate_pages_around']; $navbar = ''; // current page detection if (!isset($start) or !is_numeric($start) or (is_numeric($start) and $start < 0)) { $start = 0; } // navigation bar useful only if more than one page to display ! if ($nb_element > $nb_element_page) { // current page and last page $cur_page = ceil($start / $nb_element_page) + 1; $maximum = ceil($nb_element / $nb_element_page); // link to first page ? if ($cur_page != 1) { $navbar.= ''.$lang['first_page']; $navbar.= ''; } else { $navbar.= $lang['first_page']; } $navbar.= ' | '; // link on previous page ? if ( $start != 0 ) { $previous = $start - $nb_element_page; $navbar.= ''; } else { $navbar.= $lang['previous_page']; } $navbar.= ' |'; if ($cur_page > $pages_around + 1) { $navbar.= ' 1'; if ($cur_page > $pages_around + 2) { $navbar.= ' ...'; } } // inspired from punbb source code for ($i = $cur_page - $pages_around, $stop = $cur_page + $pages_around + 1; $i < $stop; $i++) { if ($i < 1 or $i > $maximum) { continue; } else if ($i != $cur_page) { $temp_start = ($i - 1) * $nb_element_page; $navbar.= ' '; } else { $navbar.= ' '; $navbar.= $i.''; } } if ($cur_page < ($maximum - $pages_around)) { $temp_start = ($maximum - 1) * $nb_element_page; if ($cur_page < ($maximum - $pages_around - 1)) { $navbar.= ' ...'; } $navbar.= ' '.$maximum.''; } $navbar.= ' | '; // link on next page ? if ( $nb_element > $nb_element_page && $start + $nb_element_page < $nb_element ) { $next = $start + $nb_element_page; $navbar.= ''; } else { $navbar.= $lang['next_page']; } $navbar.= ' | '; // link to last page ? if ($cur_page != $maximum) { $temp_start = ($maximum - 1) * $nb_element_page; $navbar.= ''.$lang['last_page']; $navbar.= ''; } else { $navbar.= $lang['last_page']; } } return $navbar; } // // Pick a language, any language ... // function language_select($default, $select_name = "language") { $available_lang = get_languages(); $lang_select = ''; return $lang_select; } /** * 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 * of {category_id => category_name}. If url input parameter is empty, * returns only the categories name without links. * * @param array cat_informations * @param string url * @param boolean replace_space * @return string */ function get_cat_display_name($cat_informations, $url = 'category.php?cat=', $replace_space = true) { global $conf; $output = ''; $is_first = true; foreach ($cat_informations as $id => $name) { if ($is_first) { $is_first = false; } else { $output.= $conf['level_separator']; } if ($url == '') { $output.= $name; } else { $output.= ''; $output.= $name.''; } } if ($replace_space) { return replace_space($output); } else { return $output; } } /** * 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, $url = 'category.php?cat=', $replace_space = true) { global $cat_names, $conf; 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']; } } $output = ''; $is_first = true; foreach (explode(',', $uppercats) as $category_id) { $name = $cat_names[$category_id]; if ($is_first) { $is_first = false; } else { $output.= $conf['level_separator']; } if ($url == '') { $output.= $name; } else { $output.= ' '.$name.''; } } if ($replace_space) { return replace_space($output); } else { return $output; } } /** * returns the HTML code for a category item in the menu (for category.php) * * 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, * used keys are : id, name, nb_images, date_last * * @param array categories * @return string */ function get_html_menu_category($categories) { global $page, $lang; $ref_level = 0; $level = 0; $menu = ''; // $page_cat value remains 0 for special sections $page_cat = 0; if (isset($page['cat']) and is_numeric($page['cat']) ) { $page_cat = $page['cat']; } foreach ($categories as $category) { $level = substr_count($category['global_rank'], '.') + 1; if ($level > $ref_level) { $menu.= "\n",($ref_level-$level)); } $ref_level = $level; $menu.= "\n\n".''; if ($category['nb_images'] > 0) { $menu.= "\n".''; $menu.= '['.$category['nb_images'].']'; $menu.= ''; $menu.= get_icon($category['date_last']); } } $menu.= str_repeat("\n",($level)); return $menu; } /** * 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) { $pattern = '/(https?:\/\/\S*)/'; $replacement = '$1'; $content = preg_replace($pattern, $replacement, $content); $content = nl2br($content); // replace _word_ by an underlined word $pattern = '/\b_(\S*)_\b/'; $replacement = '$1'; $content = preg_replace($pattern, $replacement, $content); // replace *word* by a bolded word $pattern = '/\b\*(\S*)\*\b/'; $replacement = '$1'; $content = preg_replace($pattern, $replacement, $content); // replace /word/ by an italic word $pattern = "/\/(\S*)\/(\s)/"; $replacement = '$1$2'; $content = preg_replace($pattern, $replacement, $content); $content = '
'.$content.'
'; return $content; } function get_cat_display_name_from_id($cat_id, $url = 'category.php?cat=', $replace_space = true) { $cat_info = get_cat_info($cat_id); return get_cat_display_name($cat_info['name'], $url, $replace_space); } ?>