'; } return $output; } function create_navigation_bar( $url, $nb_element, $start, $nb_element_page, $link_class ) { global $lang; $navigation_bar = ""; // 0. détection de la page en cours if( !isset( $start ) || !is_numeric( $start ) || ( is_numeric( $start ) && $start < 0 ) ) { $start = 0; } // on n'affiche la bare de navigation que si on plus de 1 page if ( $nb_element > $nb_element_page ) { // 1.une page précédente ? if ( $start != 0 ) { $previous = $start - $nb_element_page; $navigation_bar.= ''.$lang['previous_page']; $navigation_bar.= ''; $navigation_bar.= ' | '; } // 2.liste des numéros de page $maximum = ceil ( $nb_element / $nb_element_page ); for ( $i = 1; $i <= $maximum; $i++ ) { $temp_start = ( $i - 1 ) * $nb_element_page; if ( $temp_start == $start ) { $navigation_bar.= ' '.$i.' '; } else { $navigation_bar.= ' '.$i.' '; } } // 3.une page suivante ? if ( $nb_element > $nb_element_page && $start + $nb_element_page < $nb_element ) { $next = $start + $nb_element_page; $navigation_bar.= ' | '.$lang['next_page'].''; } } return $navigation_bar; } // // Pick a language, any language ... // function language_select($default, $select_name = "language") { $available_lang = get_languages(); $lang_select = ''; return $lang_select; } // // Pick a template/theme combo, // function style_select($default_style, $select_name = "style") { $templates = get_templates(); $style_selected = ''; return $style_selected; } /** * 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 separator * @param string url * @param boolean replace_space * @return string */ function get_cat_display_name($cat_informations, $separator, $url = 'category.php?cat=', $replace_space = true) { $output = ''; $is_first = true; foreach ($cat_informations as $id => $name) { if ($is_first) { $is_first = false; } else { $output.= $separator; } if ($url == '') { $output.= $name; } else { $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 separator * @param string url * @param boolean replace_space * @return string */ function get_cat_display_name_cache($uppercats, $separator, $url = 'category.php?cat=', $replace_space = true) { global $cat_names; 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.= $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, dir, nb_images, date_last, subcats (sub-array) * * @param array category * @return string */ function get_html_menu_category($category) { global $page, $lang; $menu = '
  • '; $url = add_session_id(PHPWG_ROOT_PATH.'category.php?cat='.$category['id']); $class = ''; if (isset($page['cat']) and is_numeric($page['cat']) and $category['id'] == $page['cat']) { $class = 'menuCategorySelected'; } else { $class = 'menuCategoryNotSelected'; } $name = $category['name']; if (empty($name)) { $name = str_replace('_', ' ', $category['dir']); } $menu.= ' '.$name.' '; if ($category['nb_images'] > 0) { $menu.= ' ['.$category['nb_images'].'] '.get_icon($category['date_last']); } // recursive call if ($category['expanded'] and count($category['subcats']) > 0) { $menu.= ' '; } $menu.= '
  • '; 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) { $content = nl2br($content); // replace _word_ by an underlined word $pattern = '/_([^\s]*)_/'; $replacement = '\1'; $content = preg_replace($pattern, $replacement, $content); // replace *word* by a bolded word $pattern = '/\*([^\s]*)\*/'; $replacement = '\1'; $content = preg_replace($pattern, $replacement, $content); // replace /word/ by an italic word $pattern = '/\/([^\s]*)\//'; $replacement = '\1'; $content = preg_replace($pattern, $replacement, $content); return $content; } ?>