Une fonction php qui rajoute des tiret aux espace blanc ? - PHP - Programmation
Marsh Posté le 26-02-2005 à 02:42:44
As-tu au moins fait une recherche ??
C'est une fonction tellement "basique" que je m'etonnes que tu n'ai rien trouve lors de ta recherche, si recherche avant le post il y a eu ...
Pour un truc basique regarde cette fonction www.php.net/str_replace.
Si tu veux un truc plus "puissant", regarde du cote des expressions regulieres.
Marsh Posté le 26-02-2005 à 03:08:23
oui j'ai fait des recherches
mais trouvé pile ça c pas evident..
ton lien est mort
Marsh Posté le 26-02-2005 à 04:25:04
str_replace marche très bien, mais pour rendre une chaîne de caractère compatible avec les url (c'est bien ce que tu veux faire au final ?), strtr est plus adapté.
http://www.php.net/manual/fr/function.strtr.php
Marsh Posté le 26-02-2005 à 14:28:01
cerel a écrit : As-tu au moins fait une recherche ?? |
pour les "minilien" de php faut remplacer les underscores des fonction par des tirets...
www.php.net/str-replace
Marsh Posté le 26-02-2005 à 15:40:05
ben en fait ca marche, mais kand j'assigne $var a ma variable qui contient le texte, ca m'affiche que le 1er mot et s'arrete au 1er espace
comment ça se fait ?
c un problemme d'assignation a la variable ?
car meme en mettant que ça :
$var1 = $content_heading;
sans rien d'autre (simple assignation) et bien j'ai egalement que le 1er mot qui s'affiche....
probleme de syntaxe ?
merci beaucoup
Marsh Posté le 26-02-2005 à 15:42:48
laurent74 > Fait un echo de $content_heading et de $var1 jsute aprés cette assignation.
Marsh Posté le 26-02-2005 à 15:43:41
comme beaucoup de forummeurs ici, je n'ai pas fait bac V !!
alors poste ton code si tu veux qu'ont te trouve les eventuelles erreurs...
Marsh Posté le 26-02-2005 à 15:44:51
KangOl a écrit : comme beaucoup de forummeurs ici, je n'ai pas fait bac V !! |
bac V?
C'est pas l'école Irma d'habitude?
Marsh Posté le 26-02-2005 à 15:47:21
C'etait trop loin de chez moi
Marsh Posté le 26-02-2005 à 15:47:28
oui ben c bizarre
echo $content_heading; m'affiche donc le contenue dans la variable dans ma page php
mais c egalement uniquement le 1er mot.....
Hors la variable $content_heading; est appelé 1 ligne plus bas et affiche bien la phrase entière......
Merde alors la....
Marsh Posté le 26-02-2005 à 15:49:46
Et c'est quoi cette ligne entre les deux?
Comme dit "KangOl", poste ton code, ca sera plus simple de voir ce qui va pas.
Marsh Posté le 26-02-2005 à 15:51:16
*hummour = on*
montre ton code... ça sera plus simple pour t'aider... on fait pas de la télépatie !!
*hummour = off*
Marsh Posté le 26-02-2005 à 15:57:07
Désoler c'est assez long, ce code est pas de moi mais je l'ai modifié, mon but est de faire de l'url rewriting, et ca marche impec (j'ai des lien .html) mais j'aimerais affiché le nom de l'article dans l'url, ca marche aussi (avec le $content_heading), mais j'ai pas les tiret (juste les espaces)...
<?php
require_once("class2.php" );
if(e_QUERY){
$tmp = explode(".", e_QUERY);
$action = $tmp[0];
$sub_action = $tmp[1];
$id = $tmp[2];
unset($tmp);
}else{
require_once(HEADERF);
$text = "<a href='article'>".LAN_59." ".LAN_57."</a>\n<br />\n<a href='".e_SELF."?review'>".LAN_59." ".LAN_58."</a>";
$ns -> tablerender(LAN_60, $text);
require_once(FOOTERF);
exit;
}
$query="";
if($action == "content" ){
$sub_action=intval($sub_action);
$query = "content_id='".$sub_action."' ";
$page = LAN_60. " /";
}
if($action == "article" ){
if(is_numeric($sub_action)){
$query = "content_id='".$sub_action."' ";
$page = LAN_1." /";
}elseif($sub_action == "cat" ){
if($id == "0" ){
$page = LAN_57." / ".LAN_61;
}else{
$query = "content_id='".$id."' " ;
$page = LAN_1. " / " .LAN_3. " / ";
}
}else{
$page = LAN_50;
}
}
if($action == "review" ){
if(is_numeric($sub_action)){
$page = LAN_2." /";
$query = "content_id='".$sub_action."' ";
}elseif($sub_action == "cat" ){
$page = LAN_2." / ".LAN_3." /";
$query = "content_id='".$id."' ";
}else{
$page = LAN_35;
}
}
if($query){
// echo $query; exit;
if($sql -> db_Select("content", "*", $query)){
$row = $sql -> db_Fetch(); extract($row);
define("e_PAGETITLE", $page." ".$content_heading);
}
}else{
define("e_PAGETITLE", $page);
}
$highlight_search = FALSE;
if(IsSet($_POST['highlight_search'])){
$highlight_search = TRUE;
}
require_once(HEADERF);
require_once(e_HANDLER."emailprint_class.php" );
$ep = new emailprint;
$textemailprint = $ep -> render_emailprint("article",$sub_action);
/*
$ep = "<div style='text-align:right'>
<a href='email.php?article.".$sub_action."'><img src='".e_IMAGE."generic/friend.gif' style='border:0' alt='email to someone' /></a>
<a href='print.php?content.".$sub_action."'><img src='".e_IMAGE."generic/printer.gif' style='border:0' alt='printer friendly' /></a>
</div>";
*/
require_once(e_HANDLER."comment_class.php" );
$cobj = new comment;
require_once(e_HANDLER."rate_class.php" );
$rater = new rater;
if(IsSet($_POST['commentsubmit'])){
$tmp = explode(".", e_QUERY);
if(!$sql -> db_Select("content", "content_comment", "content_id='$sub_action' " )){
header("location:".e_BASE."index.php" );
exit;
}else{
$row = $sql -> db_Fetch();
if($row[0] && (ANON===TRUE || USER===TRUE)){
$cobj -> enter_comment($_POST['author_name'], $_POST['comment'], "content", $sub_action, $pid, $_POST['subject']);
clear_cache("comment.content.{$sub_action}" );
}
}
}
// content page -------------------------------------------------------------------------------------------------------------------------------------------------------------------
if($action == "content" ){
if(!$sql -> db_Select("content", "*", "content_id=$sub_action AND content_type=1" )){
header("location: ".e_BASE."index.php" );
exit;
}
$row = $sql -> db_Fetch(); extract($row);
if(!check_class($content_class)){
$ns->tablerender(LAN_52, "<div style='text-align:center'>".LAN_54."</div>" );
require_once(FOOTERF);
exit;
}
if($cache = retrieve_cache("content.$sub_action" )){
echo $aj -> formtparev($cache);
}else{
ob_start();
$text = ($content_parent ? $aj -> tpa($content_content, "nobreak", "admin", $highlight_search) : $aj -> tpa($content_content, "off", "admin", $highlight_search));
$caption = $aj -> tpa($content_subheading, "off", "admin" );
$ns -> tablerender($caption, $text);
if($pref['cachestatus']){
$cache = $aj -> formtpa(ob_get_contents(), "admin" );
set_cache("content.$sub_action", $cache);
}
}
if($content_comment){
if($cache = retrieve_cache("comment.content.$sub_action" )){
echo $aj -> formtparev($cache);
}else{
ob_start();
unset($text);
if($comment_total = $sql -> db_Select("comments", "*", "comment_item_id='$sub_action' AND comment_type='1' AND comment_pid='0' ORDER BY comment_datestamp" )){
$width = 0;
while($row = $sql -> db_Fetch()){
if($pref['nested_comments']){
$text = $cobj -> render_comment($row, "content" , "comment", $sub_action, $width, $content_heading);
$ns -> tablerender(LAN_5, $text);
}else{
$text .= $cobj -> render_comment($row, "content" , "comment", $sub_action, $width, $content_heading);
}
}
if(!$pref['nested_comments']){$ns -> tablerender(LAN_5, $text); }
if($pref['cachestatus']){
$cache = $aj -> formtpa(ob_get_contents(), "admin" );
set_cache("comment.content.$sub_action", $cache);
}
}
}
if(ADMIN && getperms("B" ) && $comment_total){
echo "<div style='text-align:right'><a href='".e_ADMIN."modcomment.php?content.$sub_action'>".LAN_29."</a></div><br />";
}
$cobj -> form_comment("comment", "content", $sub_action, $content_heading);
}
}
// ##### Review List -----------------------------------------------------------------------------------------------------------------------------------------------------------
if($action == "review" ){
if(is_numeric($sub_action)){
$cachestr = ($id ? "review.item.$sub_action.$id" : "review.item.$sub_action" );
if($cache = retrieve_cache($cachestr)){
echo $aj -> formtparev($cache);
}else{
ob_start();
if($sql -> db_Select("content", "*", "content_id=$sub_action" )){
$row = $sql -> db_Fetch(); extract($row);
if(!check_class($content_class)){
$ns -> tablerender(LAN_52, "<div style='text-align:center'>".LAN_53."</div>" );
require_once(FOOTERF);
exit;
}
$sql2 = new db;
$gen = new convert;
$sql2 -> db_Select("content", "content_id, content_summary", "content_id=$content_parent" );
list($content_id_, $content_summary_) = $sql2-> db_Fetch();
$datestamp = ereg_replace(" -.*", "", $gen->convert_date($content_datestamp, "long" ));
$sql2 -> db_Select("user", "*", "user_id=$content_author" );
$row = $sql2 -> db_Fetch(); extract($row);
if(is_numeric($content_author)){
$sql2 -> db_Select("user", "*", "user_id=$content_author" );
$row = $sql2 -> db_Fetch(); extract($row);
}else{
$tmp = explode("^", $content_author);
$user_name = $tmp[0];
$user_email = $tmp[1];
}
$text .= ($content_summary_ ? "<a href='".e_SELF."?review.cat.$content_id_'><img src='".e_IMAGE."link_icons/".$content_summary_."' alt='' style='float:left; border:0' /></a>" : "" )."
<span class='mediumtext'><b>$content_heading</b></span>
<br />
<span class='smalltext'>".LAN_43."$user_name".LAN_44."$datestamp</span>
<br /><br />
$content_summary
<br /><br />";
$content_content = $aj -> tpa($content_content, "off", "admin", $highlight_search);
$reviewpages = explode("[newpage]",$content_content);
$totalpages = count($reviewpages);
if(strstr($content_content, "{EMAILPRINT}" ) || $content_pe_icon){
$content_content = str_replace("{EMAILPRINT}", $textemailprint, $content_content);
$epflag = TRUE;
}
if($totalpages > 1){
$text .= $reviewpages[(!$id ? 0 : $id)]."<br /><br />";
if($id != 0){ $text .= "<a href='content.php?review.$sub_action.".($id-1)."'>".LAN_25." <<</a> "; }
for($c=1; $c<= $totalpages; $c++){
$text .= ($c == ($id+1) ? "<span style='text-decoration: underline;'>$c</span> " : "<a href='content.php?review.$sub_action.".($c-1)."'>$c</a> " );
}
if(($id+1) != $totalpages){ $text .= "<a href='content.php?review.$sub_action.".($id+1)."'>>> ".LAN_26."</a> "; }
if($epflag){ $text .= $textemailprint; }
$content_heading .= ", ".LAN_63." ".($id+1);
$cachestr = ($id ? "review.item.$sub_action.$id" : "review.item.$sub_action" );
}else{
$text .= $content_content."\n<br />\n";
if($epflag){ $text .= $textemailprint; }
$cachestr = "review.item.$sub_action";
$comflag = TRUE;
}
$text .= "<br /><br />
".LAN_42.":
<table style='width:".($content_review_score*2)."px'>
<tr class='border'>
<td class='caption' style='width:100%; text-align:right'>$content_review_score%</td>
</tr>
</table>\n";
}
$text .= "<div style='text-align:right'><a href='".e_SELF."?review.cat.$content_id_'>>> ".LAN_27."</a><br />
<a href='".e_SELF."?review'><< ".LAN_28."</a></div>";
$ns -> tablerender($caption, $text);
if($pref['cachestatus']){
$cache = $aj -> formtpa(ob_get_contents(), "admin" );
set_cache("review.item.$sub_action", $cache);
}
}
if($sql -> db_Select("content", "*", "content_id=$sub_action" )){
$row = $sql -> db_Fetch(); extract($row);
}
if($content_comment){
if($cache = retrieve_cache("comment.content.$sub_action" )){
echo $aj -> formtparev($cache);
}else{
ob_start();
unset($text);
if($comment_total = $sql -> db_Select("comments", "*", "comment_item_id='$sub_action' AND comment_type='1' AND comment_pid='0' ORDER BY comment_datestamp" )){
$width = 0;
while($row = $sql -> db_Fetch()){
if($pref['nested_comments']){
$text = $cobj -> render_comment($row, "content" , "comment", $sub_action, $width, $content_heading);
$ns -> tablerender(LAN_5, $text);
}else{
$text .= $cobj -> render_comment($row, "content" , "comment", $sub_action, $width, $content_heading);
}
}
if(!$pref['nested_comments']){$ns -> tablerender(LAN_5, $text); }
if($pref['cachestatus']){
$cache = $aj -> formtpa(ob_get_contents(), "admin" );
set_cache("comment.content.$sub_action", $cache);
}
}
}
if(ADMIN && getperms("B" )){
echo "<div style='text-align:right'><a href='".e_ADMIN."modcomment.php?content.$sub_action'>".LAN_29."</a></div><br />";
}
$cobj -> form_comment("comment", "content", $sub_action, $content_heading);
}
require_once(FOOTERF);
exit;
}
if($sub_action == "cat" ){
if($id){
$query = "content_parent=$id AND content_type=3 ORDER BY content_datestamp DESC LIMIT 0,10";
}else{
$query = "content_parent=0 AND content_type=3 ORDER BY content_datestamp DESC LIMIT 0,10";
}
if($cache = retrieve_cache("review.cat.$id" )){
echo $aj -> formtparev($cache);
}else{
ob_start();
if($sql -> db_Select("content", "*", "content_id=$id" ) || !$id){
$row = $sql -> db_Fetch(); extract($row);
$category = $content_heading;
if($sql -> db_Select("content", "*", $query)){
$text = "<br />";
$icon = $content_summary;
$cat_id = $content_id;
$sql2 = new db;
$gen = new convert;
$text .= "<table style='width:95%'>\n";
while($row = $sql -> db_Fetch()){
extract($row);
if(check_class($content_class)){
if(is_numeric($content_author)){
$sql2 -> db_Select("user", "*", "user_id=$content_author" );
$row = $sql2 -> db_Fetch(); extract($row);
}else{
$tmp = explode("^", $content_author);
$user_name = $tmp[0];
$user_email = $tmp[1];
}
$datestamp = ereg_replace(" -.*", "", $gen->convert_date($content_datestamp, "long" ));
$text .= "<tr><td style='width:5%; text-align:center; vertical-align:top'>".($icon ? "<img src='".e_IMAGE."link_icons/".$icon."' alt='' />" : " " )."</td>
<td style='width:95%'>
<b><span class='mediumtext'><a href='".e_SELF."?review.$content_id'>$content_heading</a></span></b>
<br />
<span class='smalltext'>".LAN_43."$user_name".LAN_44."$datestamp</span>
<br />
$content_summary
<br />
<table style='width:".($content_review_score*2)."px'>
<tr class='border'>
<td class='caption' style='width:100%; text-align:right'>$content_review_score%</td>
</tr>
</table>\n<br />\n</td></tr>\n";
}
}
}else{
$text .= "<table><tr><td>".LAN_45."</td></tr>";
}
$text .= "</table><div style='text-align:right'><a href='".e_SELF."?review'><< ".LAN_30."</a></div>";
$ns -> tablerender(LAN_32.": ".$category, $text);
if($pref['cachestatus']){
$cache = $aj -> formtpa(ob_get_contents(), "admin" );
set_cache("review.cat.$id", $cache);
}
unset($text);
if($sql -> db_Select("content", "content_id, content_heading, content_datestamp ", "content_parent=$id AND content_type=3 ORDER BY content_datestamp DESC LIMIT 10,200" )){
while($row = $sql -> db_Fetch()){
extract($row);
if(!is_object($gen)){ $gen = new convert; }
$datestamp = ereg_replace(" -.*", "", $gen->convert_date($content_datestamp, "long" ));
$text .= "<img src='".e_IMAGE."generic/hme.png' alt='' style='vertical-align:middle' /> <a href='".e_SELF."?review.$content_id'>$content_heading</a> ($datestamp)<br />";
}
$ns -> tablerender(LAN_46.": ".$category, $text);
}
}
}
unset($text);
if($sql -> db_Select("content", "content_id, content_heading, content_datestamp ", "content_subheading REGEXP('^-$id-') AND content_type=3 ORDER BY content_datestamp DESC LIMIT 10,200" )){
while($row = $sql -> db_Fetch()){
extract($row);
$datestamp = ereg_replace(" -.*", "", $gen->convert_date($content_datestamp, "long" ));
$text .= "<img src='".e_IMAGE."generic/hme.png' alt='' style='vertical-align:middle' /> <a href='".e_SELF."?review.$content_id'>$content_heading</a> ($datestamp)<br />";
}
$ns -> tablerender(LAN_62.": ".$category, $text);
}
require_once(FOOTERF);
exit;
}
if($cache = retrieve_cache("review.main" )){
echo $aj -> formtparev($cache);
}else{
ob_start();
if($sql -> db_Select("content", "*", "content_type=3 ORDER BY content_datestamp DESC LIMIT 0,10" )){
$text = "<br />";
$sql2 = new db;
$gen = new convert;
while($row = $sql -> db_Fetch()){
extract($row);
if(check_class($content_class)){
$summary = $content_summary;
$rev_id = $content_id;
$category = $content_parent;
if(is_numeric($content_author)){
$sql2 -> db_Select("user", "*", "user_id=$content_author" );
$row = $sql2 -> db_Fetch(); extract($row);
}else{
$tmp = explode("^", $content_author);
$user_name = $tmp[0];
$user_email = $tmp[1];
}
$sql2 -> db_Select("content", "content_id, content_summary", "content_id=$category" );
$row = $sql2 -> db_Fetch(); extract($row);
$datestamp = ereg_replace(" -.*", "", $gen->convert_date($content_datestamp, "long" ));
$text .= (file_exists(e_IMAGE."link_icons/$content_summary" ) ? "<a href='".e_SELF."?review.cat.$content_id'><img src='".e_IMAGE."link_icons/".$content_summary."' alt='' style='float:left; border:0' /></a>" : " " )."
<b><span class='mediumtext'><a href='".e_SELF."?review.$rev_id'>$content_heading</a></span></b>
<br />
<span class='smalltext'>".LAN_43."<b>$user_name</b>".LAN_44."$datestamp</span>
<br />
$summary
<br />
<table style='width:".($content_review_score*2)."px'>
<tr class='border'>
<td class='caption' style='width:100%; text-align:right'>$content_review_score%</td>
</tr>
</table>\n<br />\n";
}
}
}else{
$ns -> tablerender(LAN_32, LAN_55);
require_once(FOOTERF);
exit;
}
$ns -> tablerender(LAN_32, $text);
if($sql -> db_Select("content", "*", "content_type=10" )){
$text = "<div style='text-align:center'>
<table class='fborder' style='width:95%'>\n";
while($row = $sql -> db_Fetch()){
extract($row);
$total = $sql2 -> db_Select("content", "content_class", "content_parent=$content_id AND content_type=3" );
if($total){
while($row2 = $sql2 -> db_Fetch()){
extract($row2);
if(!check_class($content_class)){
$total = $total - 1;
}
}
}
$text .= "<tr>
<td class='forumheader3' style='width:10%; text-align:center' rowspan='2'>
".($content_summary ? "<a href='".e_SELF."?review.cat.$content_id'><img src='".e_IMAGE."link_icons/".$content_summary."' alt='' style='vertical-align:middle; border:0' /></a>" : " " )."
</td>
<td class='forumheader' style='width:90%'><b><a href='".e_SELF."?review.cat.$content_id'>$content_heading</a></b></td>
</tr>
<tr>
<td class='forumheader3'>$content_subheading <span class='smalltext'>( $total ".($total==1 ? LAN_34 : LAN_33)." )</span></td>
</tr>\n";
}
$total = $sql2 -> db_Select("content", "*", "content_type=3 AND content_parent=0" );
if($total){
while($row2 = $sql2 -> db_Fetch()){
extract($row2);
if(!check_class($content_class)){
$total = $total - 1;
}
}
}
$text .= "<tr>
<td class='forumheader3' style='width:10%; text-align:center' rowspan='2'>
</td>
<td class='forumheader' style='width:90%'><b><a href='".e_SELF."?review.cat.0'>".LAN_61."</a></b></td>
</tr>
<tr>
<td class='forumheader3'><span class='smalltext'>( $total ".($total == 1 ? LAN_34 : LAN_33)." )</span></td>
</tr>\n";
$text .= "</table>\n</div>\n";
$ns -> tablerender(LAN_35, $text);
if($pref['cachestatus']){
$cache = $aj -> formtpa(ob_get_contents(), "admin" );
set_cache("review.main", $cache);
}
}
}
}
// ##### End ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// ##### Article List -----------------------------------------------------------------------------------------------------------------------------------------------------------
if($action == "article" ){
unset($text);
if(is_numeric($sub_action)){
$cachestr = ($id ? "article.item.$sub_action.$id" : "article.item.$sub_action" );
if($cache = retrieve_cache($cachestr)){
echo $aj -> formtparev($cache);
}else{
ob_start();
if($sql -> db_Select("content", "*", "content_id=$sub_action" )){
$row = $sql -> db_Fetch(); extract($row);
if(!check_class($content_class)){
$ns -> tablerender(LAN_52, "<div style='text-align:center'>".LAN_51."</div>" );
require_once(FOOTERF);
exit;
}
$category = $content_parent;
$sql2 = new db;
$gen = new convert;
$sql2 -> db_Select("content", "content_id, content_summary", "content_id=$category" );
list($content_id_, $content_summary_) = $sql2-> db_Fetch();
$datestamp = ereg_replace(" -.*", "", $gen->convert_date($content_datestamp, "long" ));
if(is_numeric($content_author)){
$sql2 -> db_Select("user", "*", "user_id=$content_author" );
$row = $sql2 -> db_Fetch(); extract($row);
}else{
$tmp = explode("^", $content_author);
$user_name = $tmp[0];
$user_email = $tmp[1];
}
$text .= ($content_summary_ ? "<a href='categorie-$content_id_.html'><img src='".e_IMAGE."link_icons/".$content_summary_."' alt='' style='float:left; border:0' /></a>" : "" )."
<span class='mediumtext'><b>$content_heading</b></span>
<br />
<span class='smalltext'>".LAN_43."<b>$user_name</b>".LAN_44."$datestamp</span>
<br /><br />
$content_summary
<br /><br />";
$content_content = $aj -> tpa($content_content, "off", "admin", $highlight_search);
$articlepages = explode("[newpage]",$content_content);
$totalpages = count($articlepages);
if(strstr($content_content, "{EMAILPRINT}" ) || $content_pe_icon){
$content_content = str_replace("{EMAILPRINT}", $textemailprint, $content_content);
$epflag = TRUE;
}
if($totalpages > 1){
$text .= $articlepages[(!$id ? 0 : $id)]."<br /><br />";
if($id != 0){ $text .= "<a href='articles-$sub_action.".($id-1).".html'>".LAN_25." <<</a> "; }
for($c=1; $c<= $totalpages; $c++){
$text .= ($c == ($id+1) ? "<span style='text-decoration: underline;'>$c</span> " : "<a href='articles-$sub_action.".($c-1).".html'>$c</a> " );
}
if(($id+1) != $totalpages){ $text .= "<a href='articles-$sub_action.".($id+1).".html'>>> ".LAN_26."</a> "; }
if($epflag){ $text .= $textemailprint; }
$content_heading .= ", ".LAN_63." ".($id+1);
$cachestr = ($id ? "article.item.$sub_action.$id" : "article.item.$sub_action" );
}else{
$text .= $content_content."\n<br />\n";
if($epflag){ $text .= $textemailprint; }
$cachestr = "article.item.$sub_action";
$comflag = TRUE;
}
}
$text .= "<br /><div style='text-align:right'><a href='categorie- $content_id_.html'>>> ".LAN_36."</a><br />
<a href='article'><< ".LAN_37."</a></div>";
$ns -> tablerender($caption, $text);
if($pref['cachestatus']){
$cache = $aj -> formtpa(ob_get_contents(), "admin" );
set_cache($cachestr, $cache);
}
}
if($sql -> db_Select("content", "*", "content_id=$sub_action" )){
$row = $sql -> db_Fetch(); extract($row);
}
$totalpages = substr_count($content_content, "[newpage]" );
$comflag = ($totalpages == $id ? TRUE : FALSE);
if($comflag){
unset($text);
if($ratearray = $rater -> getrating("article", $sub_action)){
$text = LAN_64;
for($c=1; $c<= $ratearray[1]; $c++){
$text .= "<img src='".e_IMAGE."rate/box.png' alt='' style='vertical-align:middle' />";
}
if($ratearray[1] < 10){
for($c=9; $c>=$ratearray[1]; $c--){
$text .= "<img src='".e_IMAGE."rate/empty.png' alt='' style='vertical-align:middle' />";
}
}
$text .= "<img src='".e_IMAGE."rate/boxend.png' alt='' style='vertical-align:middle' />";
if($ratearray[2] == "" ){ $ratearray[2] = 0; }
$text .= " ".$ratearray[1].".".$ratearray[2]." - ".$ratearray[0]." ";
$text .= ($ratearray[0] == 1 ? LAN_38 : LAN_39);
}else{
$text .= LAN_65;
}
if(!$rater -> checkrated("article", $sub_action) && USER){
$text .= "<br />\n<div class='smalltext' style='text-align:right'>".
$rater -> rateselect(" ".LAN_40, "article", $sub_action)."</div>";
}else if(USER){
$text .= " - ".LAN_41;
}
$ns -> tablerender(LAN_42, $text);
}
if($content_comment && $comflag){
if($cache = retrieve_cache("comment.content.$sub_action" )){
echo $aj -> formtparev($cache);
}else{
ob_start();
unset($text);
if($comment_total = $sql -> db_Select("comments", "*", "comment_item_id='$sub_action' AND comment_type='1' AND comment_pid='0' ORDER BY comment_datestamp" )){
$width = 0;
while($row = $sql -> db_Fetch()){
if($pref['nested_comments']){
$text = $cobj -> render_comment($row, "content" , "comment", $sub_action, $width, $content_heading);
$ns -> tablerender(LAN_5, $text);
}else{
$text .= $cobj -> render_comment($row, "content" , "comment", $sub_action, $width, $content_heading);
}
}
if(!$pref['nested_comments']){$ns -> tablerender(LAN_5, $text); }
if($pref['cachestatus']){
$cache = $aj -> formtpa(ob_get_contents(), "admin" );
set_cache("comment.content.$sub_action", $cache);
}
}
}
if(ADMIN && getperms("B" )){
echo "<div style='text-align:right'><a href='".e_ADMIN."modcomment.php?content.$sub_action'>".LAN_29."</a></div><br />";
}
$cobj -> form_comment("comment", "content", $sub_action, $content_heading);
}
require_once(FOOTERF);
exit;
}
if($sub_action == "cat" ){
if($id){
$query = "content_parent=$id AND content_type=0 ORDER BY content_datestamp DESC LIMIT 0,10";
}else{
$query = "content_parent=0 AND content_type=0 ORDER BY content_datestamp DESC LIMIT 0,10";
}
if($cache = retrieve_cache("article.cat.$id" )){
echo $aj -> formtparev($cache);
}else{
ob_start();
if($sql -> db_Select("content", "*", "content_id=$id" ) || !$id){
$row = $sql -> db_Fetch(); extract($row);
$caption = LAN_47.": ".$content_heading;
$category = $content_heading;
if($sql -> db_Select("content", "*", $query)){
$text = "<br />";
$icon = $content_summary;
$cat_id = $content_id;
$sql2 = new db;
$gen = new convert;
$text .= "<table style='width:95%'>\n";
while($row = $sql -> db_Fetch()){
extract($row);
if(check_class($content_class)){
$sql2 -> db_Select("user", "*", "user_id=$content_author" );
$row = $sql2 -> db_Fetch(); extract($row);
if(is_numeric($content_author)){
$sql2 -> db_Select("user", "*", "user_id=$content_author" );
$row = $sql2 -> db_Fetch(); extract($row);
}else{
$tmp = explode("^", $content_author);
$user_name = $tmp[0];
$user_email = $tmp[1];
}
$datestamp = ereg_replace(" -.*", "", $gen->convert_date($content_datestamp, "long" ));
$text .= "<tr><td style='width:5%; text-align:center; vertical-align:top'>".($icon ? "<img src='".e_IMAGE."link_icons/".$icon."' alt='' />" : " " )."</td>
<td style='width:50%'>
<b><span class='mediumtext'><a href='articles-$content_id-$content_heading.html'>$content_heading</a></span></b>
<br />
<span class='smalltext'>".LAN_43." $user_name ".LAN_44." $datestamp</span>
<br />
$content_summary
<br /><br />\n</td>
<td style='width:45%'>
<b><span class='mediumtext'><a href='articles-$content_id.html'>$content_heading</a></span></b>
<br />
<span class='smalltext'>".LAN_43." $user_name ".LAN_44." $datestamp</span>
<br />
$content_summary
<br /><br />\n</td>
</tr>\n";
}
}
}else{
$text .= "<table><tr><td>".LAN_45."</td></tr>";
}
$text .= "</table>\n<div style='text-align:right'><a href='article.html'><< ".LAN_37."</a></div>";
$ns -> tablerender($caption, $text);
if($pref['cachestatus']){
$cache = $aj -> formtpa(ob_get_contents(), "admin" );
set_cache("article.cat.$id", $cache);
}
}
}
unset($text);
if($sql -> db_Select("content", "content_id, content_heading, content_datestamp ", "content_parent=$id AND content_type=0 ORDER BY content_datestamp DESC LIMIT 10,200" )){
while($row = $sql -> db_Fetch()){
extract($row);
if(!is_object($gen)){ $gen = new convert; }
$datestamp = ereg_replace(" -.*", "", $gen->convert_date($content_datestamp, "long" ));
$text .= "<img src='".e_IMAGE."generic/hme.png' alt='' style='vertical-align:middle' /> <a href='articles-$content_id.html'>$content_heading</a> ($datestamp)<br />";
}
$ns -> tablerender(LAN_46.": ".$category, $text);
}
require_once(FOOTERF);
exit;
}
if($cache = retrieve_cache("article.main" )){
echo $aj -> formtparev($cache);
}else{
ob_start();
if($sql -> db_Select("content", "*", "content_type=0 ORDER BY content_datestamp DESC LIMIT 0,10" )){
$text = "<br />
<table style='width:95%'>";
$sql2 = new db;
$gen = new convert;
while($row = $sql -> db_Fetch()){
extract($row);
if(check_class($content_class)){
$summary = $content_summary;
$rev_id = $content_id;
$category = $content_parent;
$sql2 -> db_Select("content", "content_id, content_summary", "content_id=$category" );
$row = $sql2 -> db_Fetch(); extract($row);
if(is_numeric($content_author)){
$sql2 -> db_Select("user", "*", "user_id=$content_author" );
$row = $sql2 -> db_Fetch(); extract($row);
}else{
$tmp = explode("^", $content_author);
$user_name = $tmp[0];
$user_email = $tmp[1];
}
$datestamp = ereg_replace(" -.*", "", $gen->convert_date($content_datestamp, "long" ));
$text .= "<tr>\n<td style='width:5%; text-align:center; vertical-align:top'>\n";
$text .= ($content_summary && $content_parent ? "<a href='categorie-$content_id.html'><img src='".e_IMAGE."link_icons/".$content_summary."' alt='' style='border:0' /></a>" : " " )."
</td>\n<td style='width:95%'>
<b><span class='mediumtext'><a href='articles- $rev_id.html'>$content_heading</a></span></b>
<br />
<span class='smalltext'>".LAN_43."$user_name".LAN_44."$datestamp</span>
<br />
$summary
<br /><br />\n</td></tr>\n";
}
}
}else{
$ns -> tablerender(LAN_47, LAN_56);
require_once(FOOTERF);
exit;
}
$text .= "</table>";
$ns -> tablerender(LAN_47, $text);
if($sql -> db_Select("content", "*", "content_type=6" )){
$text = "<div style='text-align:center'>
<table class='fborder' style='width:95%'>\n";
while($row = $sql -> db_Fetch()){
extract($row);
$total = $sql2 -> db_Select("content", "content_class", "content_parent=$content_id AND content_type=0" );
if($total){
while($row2 = $sql2 -> db_Fetch()){
extract($row2);
if(!check_class($content_class)){
$total = $total - 1;
}
}
}
$text .= "<tr>
<td class='forumheader3' style='width:10%; text-align:center' rowspan='2'>
".($content_summary ? "<a href='categorie-$content_id.html'><img src='".e_IMAGE."link_icons/".$content_summary."' alt='' style='vertical-align:middle; border:0' /></a>" : " " )."
</td>
<td class='forumheader' style='width:90%'><b><a href='categorie-$content_id.html'>$content_heading</a></b></td>
</tr>
<tr>
<td class='forumheader3'>$content_subheading <span class='smalltext'>( $total ".($total==1 ? LAN_49 : LAN_48)." )</span></td>
</tr>\n";
}
$total = $sql2 -> db_Select("content", "*", "content_type=0 AND content_parent=0" );
if($total){
while($row2 = $sql2 -> db_Fetch()){
extract($row2);
if(!check_class($content_class)){
$total = $total - 1;
}
}
}
$text .= "<tr>
<td class='forumheader3' style='width:10%; text-align:center' rowspan='2'>
</td>
<td class='forumheader' style='width:90%'><b><a href='categorie-0.html'>".LAN_61."</a></b></td>
</tr>
<tr>
<td class='forumheader3'><span class='smalltext'>( $total ".($total==1 ? LAN_49 : LAN_48)." )</span></td>
</tr>\n";
$text .= "</table>\n</div>\n";
$ns -> tablerender(LAN_50, $text);
if($pref['cachestatus']){
$cache = $aj -> formtpa(ob_get_contents(), "admin" );
set_cache("article.main", $cache);
}
}
}
}
// ##### End ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
require_once(FOOTERF);
?>
Voila, merci beaucoup c un petit détail certainement a modifié, mais pour moi ca veut dire beaucoup
Marsh Posté le 26-02-2005 à 15:59:34
et la c la ligne qui affiche bien mon url comme je veut, valide et tous, mais dans le titre de l'article (mi a la fin de l'url) il y a les espaces entre les mots, je voudrais les petit tirets "-"
'<a href='articles-$content_id-$content_heading.html'>$content_heading</a>
bizarre ke j'arrive pas a choper toute la frase du $content_heading et que ça marche ici :-/
Marsh Posté le 26-02-2005 à 16:04:00
1/ tu peux pas n'afficher que l'essentiel ? je parie qu'il y a les 3/4 dont on en a rien a foutre
2/ et les balise [code] c'est pas pour les chiens
Marsh Posté le 26-02-2005 à 16:04:04
Berk des $content_heading au beau milieu des chaines de caractéres. Là, je suis pas sur que la variable soit bien prise.
PS : Désolé, j'ai la fleme de prendre le temps de regarder l'ensemble du code en détail.
PS2 : Dans tout ça, c'est vers quel endroit que se trouve le probléme?
Marsh Posté le 26-02-2005 à 16:09:51
ben j'ai remarké u ntruc, vers le code que j'ai mi dans le petit poste après, kand je fait un echo jsute a coté, j'ai bien la phrase qui s'affiche...........
Donc je pense que je doit mettre
$var1 = $content_heading;
$var1 = strtr($var1," ", "-" );
dans les environs de ce code....
Marsh Posté le 26-02-2005 à 16:13:04
super j'ai reussi
je l'ai mi ici
$datestamp = ereg_replace(" -.*", "", $gen->convert_date($content_datestamp, "long" ));
$var1 = $content_heading;
$var1 = strtr($var1," ", "-" );
$text .= "<tr><td style='width:5%; text-align:center; vertical-align:top'>".($icon ? "<img src='".e_IMAGE."link_icons/".$icon."' alt='' />" : " " )."</td>
<td style='width:50%'>
<b><span class='mediumtext'><a href='articles-$content_id-$var1.html'>$content_heading</a></span></b>
ca marche ))
merci laurent74
Marsh Posté le 26-02-2005 à 01:32:02
Bonjoru a tous
voila j'aimerais une fonction php qui capture une variable qui contient une phrase texte, et qui rajoute des tirets "-" a la places des espaces blancs qui separent les mots, ensuite j'assigne le resultat de cette fonction dans une nouvelle variable c'est possible ?
c'est vraiment TRES important pour moi, et je vous adorent ici
Merci beaucoup