es gibt ein neues Kommentarmodul
Features:
*nicht nur ein Artikel kann kommentiert werden sondern auch die Kommentare selbst
*Anzahl der Kommentarlevel theoretisch unbegrenzt, kann aber auf eine bestimmte Anzahl Ebenen eingeschränkt werden
*Darstellung der Kommentare in einer eingerückten Baumstruktur, je nachdem ob es sich um "Grundkommentare" oder Antworten auf Kommentare handelt. Jedes Einrück-Level lässt sich per CSS unterschiedlich darstellen.
*Spamschutz per "Countchas" aktivierbar
*Kommentar kann gleich online gehen oder erst nach Freischalten
*eMail-Alert bei neuem Kommentar
*Auf Mehrsprachigkeit ausgelegt
*Individuelle Anpassungsmöglichkeiten per CSS und Modul-Templates
*Kommentarmodul kann individuell für Artikel ein- oder ausgeschaltet werden
*Pflege der Kommentare über das Backend: online, offline, löschen, ändern. Löschfunktion wird nur dann eingeblendet, wenn Kommentar zuerst offline gesetzt wurde und keine Kinderelemente/-kommentare mehr vorhanden sind.
Neben der üblichen Installationsroutine ist es wichtig, sich den Abschnitt /****** begin configuration ******/ am Anfang des Outputs anzusehen und hier zumindest bei
$email_comment_alert
$main_url
$headline_comments_image
$path_countcha_1
$path_countcha_2
eigene Daten einzutragen. Die drei Bildchen für headline_comments_image und die beiden countchas dürft ihr auch selber machen...
ToDo: Zur Zeit orientiert sich die Zuordnung der Kommentare rein an der idart. Geplant ist eine Ausweitung der Zuordnung per "additional attributes", sprich z. B. die url wird nach Variablen durchsucht die dann zusätzlich zur idart in der DB-Tabelle gespeichert werden. So ließe sich z. B. auch eine Kommentierung innerhalb einer Bildergalerie realisieren, sofern der Dateiname und ggf. Pfad in der url oder sonstwo im Code als Variable auftaucht.
Wer gerne Detailinformationen zu den einzelnen Schritten einblenden möchte, der kann am Anfang des Output mal $debug auf "true" setzen und von einigen Zusatzinformationen erschlagen lassen. Wer's nicht braucht, lässt eben das "false" oder kann einfach alle if($debug=="true"){...} im Output rauslöschen. Macht das Ganze dann auch was schlanker
Weitere Informationen unter http://www.seamless-design.de/cms/front ... ?idcat=115
Also, viel Spaß damit
Markus
SQL-Statement zum Anlegen der DB-Tabelle:
Code: Alles auswählen
CREATE TABLE IF NOT EXISTS `comments_sd` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`idart` int(11) NOT NULL,
`url` varchar(200) COLLATE latin1_german1_ci NOT NULL,
`name` varchar(50) COLLATE latin1_german1_ci NOT NULL,
`email` varchar(50) COLLATE latin1_german1_ci NOT NULL,
`website` varchar(100) COLLATE latin1_german1_ci NOT NULL,
`text` text COLLATE latin1_german1_ci NOT NULL,
`parent_id` int(11) NOT NULL,
`level` int(11) NOT NULL,
`date` date NOT NULL,
`time` time NOT NULL,
`online` int(1) NOT NULL,
PRIMARY KEY (`id`)
)
Code: Alles auswählen
/***********************************************
* CONTENIDO MODUL - INPUT
*
* Modulname : comments_sd
* Author(s) : www.Seamless-Design.de Markus Hübner
* Copyright : www.Seamless-Design.de Markus Hübner
* Created : 11.09.2011
************************************************/
echo 'Kommentare erlauben? ';
if ("CMS_VALUE[10]" != "true") {
echo ' <input type="radio" name="CMS_VAR[10]" value="true"> ja';
} else {
echo ' <input type="radio" name="CMS_VAR[10]" value="true" checked> ja';
}
if ("CMS_VALUE[10]" != "false") {
echo ' <input type="radio" name="CMS_VAR[10]" value="false"> nein';
} else {
echo ' <input type="radio" name="CMS_VAR[10]" value="false" checked> nein';
}
echo '<font style="font-size:80%"><br/><br/>Die Konfiguration des Moduls erfolgt über die Variablen am Beginn des Modul-Outputs.<br/>
Wichtig: Kommentare können im Backend nur gelöscht werden, wenn keine Folgekommentare vorhanden sind UND sie zuerst offline gesetzt werden.<br/>
Ein Löschen per Tabellenzugriff über phpMyAdmin sollte nicht erfolgen, da sonst die Baumstruktur zusammenbrechen kann!</font>';
Code: Alles auswählen
<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : comments_sd
* Author(s) : www.Seamless-Design.de Markus Hübner
* Copyright : www.Seamless-Design.de Markus Hübner
* Created : 11.09.2011
************************************************/
$enable='CMS_VALUE[10]';
if($enable=="false" AND $contenido) echo '<p><font style="color: #DF1010; font-weight: 900; font-size: 15px;">COMMENTS DISABLED IN FRONTEND!</font></p>';
if($contenido) $enable="true"; // enables showing comments in backend, which are switched to "false" after being "true" while they are hidden in frontend
if($enable=="false")
{
echo '';
}
else
{
echo '<div class="c_sd_box_main">';
/****** begin configuration ******/
$display_countchas="true"; // true or false
$amount_countchas_total="8"; // how many countchas should be displayed if anti-spam is activated?
$path_countcha_1="upload/bullets/countcha_01.jpg"; // path to first symbol
$path_countcha_2="upload/bullets/countcha_02.jpg"; // path to second symbol
$debug="false"; // true or false. if you want to see several hints how this modul works, set it to true - have fun... ;O)
$mail_alert="true"; // if you want to get an email if there is a new comment, set it to true or otherwise false
$email_comment_alert="ich@domain.de"; // email-adress for email-alert
$maximum_comment_level=99; // after the xth level (level 1: 0=first comment ... level 6: 5=fifth answer ...) there is no possibility to answer an answer anymore
$standard_onlinestatus="0"; // 1: comment is immediately online after posting or 0: you have to set it online
$enable_br="true"; // true enables displaying <br/> within comment text, set to false to disable
$main_url="front_content.php"; //needed for correct link in comment-box
$main_url_email_alert="http://www.mein1job.de/cms/front_content.php"; //needed for correct link in email-alert
$headline_comments_image="upload/bullets/comments-bubble.jpg"; //path to image displayed before the headline
$template_form="comments_sd_commentform.html"; // template containing the comment form
$template_commentbox="comments_sd_commentbox.html"; // template containing the standard html-construct to display one posted comment
$template_commentbox_no_more_comments="comments_sd_commentbox_no_more_answers.html"; // template containing the standard html-construct to display one posted comment without the answer-this-comment-link
$template_form_commentchange="comments_sd_form_commentchange.html"; // template containing the backend-form to change contents of a comment
//if you want to configure the look: use the prepared css-styles.
/****** end configuration ******/
$commentname=mysql_real_escape_string(htmlspecialchars(strip_tags($_POST[commentname])));
$commentemail=mysql_real_escape_string(htmlspecialchars(strip_tags($_POST[commentemail])));
$commentwebsite=mysql_real_escape_string(htmlspecialchars(strip_tags($_POST[commentwebsite])));
$commentwebsite = str_replace("https://","",$commentwebsite);
$commentwebsite = str_replace("http://","",$commentwebsite);
$commenttext=mysql_real_escape_string(htmlspecialchars(strip_tags($_POST[commenttext])));
$amount=htmlspecialchars(strip_tags($_POST[amount]));
$countcha=htmlspecialchars(strip_tags($_POST[countcha]));
$show_form=htmlspecialchars(strip_tags($_GET[show_form]));
$parent_id=htmlspecialchars(strip_tags($_GET[parent_id]));
$level=htmlspecialchars(strip_tags($_GET[level]));
$timestamp = time();
$date = date("Y.m.d",$timestamp);
$time = date("H:i",$timestamp);
$url=$_SERVER["REQUEST_URI"];
if($contenido)
{
$url="/cms/front_content.php?idart=".$idart;
$reload_url="front_content.php?idcat=$idcat&idart=$idart&lang=$lang&client=$client&contenido=$contenido";
$change_id_select=htmlspecialchars(strip_tags($_POST[change_id_select]));
$change_name=htmlspecialchars(strip_tags($_POST[change_name])); if($change_name=="") $change_name="-";
$change_email=htmlspecialchars(strip_tags($_POST[change_email])); if($change_email=="") $change_email="-";
$change_www=htmlspecialchars(strip_tags($_POST[change_www])); if($change_www=="") $change_www="-";
$change_text=htmlspecialchars(strip_tags($_POST[change_text])); if($change_text=="") $change_text="-";
}
if ($debug=="true")
{
echo 'submit: '.$submit.'<br/>';
echo 'commentname: '.$commentname.'<br/>';
echo 'commentemail: '.$commentemail.'<br/>';
echo 'commentwebsite: '.$commentwebsite.'<br/>';
echo 'commenttext: '.$commenttext.'<br/>';
echo 'date: '.$date.'<br/>';
echo 'time: '.$time.'<br/>';
echo 'url: '.$url.'<br/>';
echo 'idart: '.$idart.'<br/>';
}
/****** begin backend functions ******/
if($contenido)
{
$toggle_id=htmlspecialchars(strip_tags($_GET[toggle_id]));
$toggle_onlinestatus=htmlspecialchars(strip_tags($_GET[onlinestatus]));
$erase=htmlspecialchars(strip_tags($_GET[erase]));
if($debug=="true")
{
echo 'toggle_id: '.$toggle_id.'<br/>';
echo 'online-status: '.$toggle_onlinestatus.'<br/>';
echo 'erase: '.$erase.'<br/>';
}
if($toggle_id!="" AND $toggle_onlinestatus!="")
{
$toggle = "UPDATE comments_sd Set online = $toggle_onlinestatus WHERE id = $toggle_id";
$update = mysql_query($toggle);
}
if($erase=="1")
{
$erase = "DELETE from comments_sd WHERE id = $toggle_id";
$erase = mysql_query($erase);
}
$query = "SELECT id FROM comments_sd WHERE idart='$idart' ORDER by id ASC";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
$ids_to_select[]=$row[id];
}
$select="<option>?</option>";
$amount_of_comments = mysql_num_rows($result); //edit blau1 contenido post Do Nov 10, 2011 7:19 pm http://forum.contenido.org/viewtopic.php?f=60&t=31573
if($amount_of_comments>0)
{
foreach($ids_to_select AS $element)
{
$select=$select.'<option>'.$element.'</option>';
}
}
echo '<div style="background-color: #FFE4E4;border: 1px solid #FFE4E4;border-radius: 5px;padding: 5px;margin-bottom: 10px;">';
echo '<strong>Inhalte eines Kommentars ändern</strong><br/><span style="font-size: 80%;">(Wenn für Feld <u>keine</u> Änderung gewünscht ist, bitte "-" im Feld belassen. Leer führt zu Löschung des Inhalts!)</span>';
if(!isset($tpl) || !is_object($tpl)) $tpl = new Template();
$tpl->reset();
$tpl->set('s', 'value_change_name', $change_name);
$tpl->set('s', 'value_change_email', $change_email);
$tpl->set('s', 'value_change_www', $change_www);
$tpl->set('s', 'value_change_text', $change_text);
$tpl->set('s', 'button_text', "update");
$tpl->set('s', 'select', $select);
$tpl->generate('templates/'.$template_form_commentchange);
echo '</div>';
if($change_id_select!="")
{
if($change_id_select=="?")
{
echo mi18n("please_select_a_change_id").'<br/>';
}
else
{
if($debug=="true") {echo $change_id_select.'<br/>';echo $change_name.'<br/>';echo $change_email.'<br/>';echo $change_www.'<br/>';echo $change_text.'<br/>';}
if($change_name!="-") mysql_query("UPDATE comments_sd SET name='$change_name' WHERE id='$change_id_select'");
if($change_email!="-") mysql_query("UPDATE comments_sd SET email='$change_email' WHERE id='$change_id_select'");
if($change_www!="-") mysql_query("UPDATE comments_sd SET website='$change_www' WHERE id='$change_id_select'");
if($change_text!="-") mysql_query("UPDATE comments_sd SET text='$change_text' WHERE id='$change_id_select'");
}
}
}
function backend_comment_options ($reload_url,$toggle_id,$onlinestatus,$commentemail,$has_child){
echo '<div class="c_sd_commentbox_backend_options">';
if($debug=="true") echo 'has child: '.$has_child.'<br/>';
if($onlinestatus=="0")
{
echo 'eMail: <a href="mailto:'.$commentemail.'">'.$commentemail.'</a> | ';
if($has_child!="true") echo '<a href="'.$reload_url.'&toggle_id='.$toggle_id.'&onlinestatus=0&erase=1"><img src="/contenido/images/delete.gif" alt="delete" title="delete"/></a> | ';
echo '<a href="'.$reload_url.'&toggle_id='.$toggle_id.'&onlinestatus=1&erase=0"><img src="/contenido/images/offline.gif" alt="offline" title="offline"/></a>';
}
if($onlinestatus=="1") echo 'eMail: <a href="mailto:'.$commentemail.'">'.$commentemail.'</a> |
<a href="'.$reload_url.'&toggle_id='.$toggle_id.'&onlinestatus=0&erase=0"><img src="/contenido/images/online.gif" alt="online" title="online"/></a>';
echo ' | id: '.$toggle_id;
echo '</div>';
}
/****** end backend functions ******/
/****** begin checking errors ******/
if($submit!="")
{
if($commentemail != "")
{
if(!preg_match("/^[\w-]+((\.|\+)[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$/i", $commentemail))
{
$errormessage_commentemail=mi18n("errormessage_commentemail").'<br/>';
}
else $errormessage_commentemail="";
}
if($commentwebsite != "")
{
if(!preg_match("/[w.0-9]{0,4}[a-zA-Z0-9.-]{2,40}[.][a-zA-Z]{2,7}/", $commentwebsite))
{
$errormessage_commentwebsite=mi18n("errormessage_commentwebsite").'<br/>';
}
else $errormessage_commentwebsite="";
}
if($commenttext=="") $errormessage_commenttext=mi18n("errormessage_commenttext").'<br/>';
else $errormessage_commenttext="";
if($display_countchas=="true")
{
if($amount!=$countcha) $errormessage_countchas=mi18n("errormessage_countchas").'<br/>';
else $errormessage_countchas="";
}
}
if($show_form=="true")
{
if($errormessage_commentemail!="" OR $errormessage_commentwebsite!="" OR $errormessage_commenttext!="" OR $errormessage_countchas!="")
{
echo '<h2>'.mi18n("headline_form").'</h2>';
echo '<p class="c_sd_box_errormessages">';
echo $errormessage_commentemail;
echo $errormessage_commentwebsite;
echo $errormessage_commenttext;
if($display_countchas=="true") echo $errormessage_countchas;
echo '<p>';
}
elseif ($submit!="")
{
echo '<h2>'.mi18n("headline_form").'</h2>';
if($standard_onlinestatus=="0") echo mi18n("confirmation");
if($standard_onlinestatus=="1") echo mi18n("confirmation_immediately_online");
$insert_data="true";
}
else echo '<h2>'.mi18n("headline_form").'</h2>';
}
/****** end checking errors ******/
/****** begin displaying form ******/
if($insert_data!="true" AND $show_form=="true")
{
if($display_countchas=="true")
{
$countchas_1="";
$countchas_2="";
$amount=rand(1,$amount_countchas_total); // amount of symbols to count
$amount_wrong_countchas=$amount_countchas_total-$amount;
$i=0;
while ($i<$amount_wrong_countchas)
{
$countchas_2=$countchas_2."<img src=\"".$path_countcha_2."\" border=\"0\" alt=\"\"></img> ";
$i=$i+1;
}
while ($i<$amount_countchas_total)
{
$countchas_1=$countchas_1."<img src=\"".$path_countcha_1."\" border=\"0\" alt=\"\"></img> ";
$i=$i+1;
}
}
if(!isset($tpl) || !is_object($tpl)) $tpl = new Template();
$tpl->reset();
$tpl->set('s', 'name', mi18n("name"));
$tpl->set('s', 'commentname', $commentname);
$tpl->set('s', 'email', mi18n("email"));
$tpl->set('s', 'commentemail', $commentemail);
$tpl->set('s', 'website', mi18n("website"));
$tpl->set('s', 'commentwebsite', $commentwebsite);
$tpl->set('s', 'text', mi18n("text"));
$tpl->set('s', 'commenttext', $commenttext);
$tpl->set('s', 'countchas_2', $countchas_2);
$tpl->set('s', 'countchas_1', $countchas_1);
$tpl->set('s', 'how_many_countchas', mi18n("how_many_countchas"));
$tpl->set('s', 'title_right_countcha', mi18n("title_right_countcha"));
$tpl->set('s', 'how_many_countchas_hint_spam', mi18n("how_many_countchas_hint_spam"));
$tpl->set('s', 'how_many_countchas_input', mi18n("how_many_countchas_input"));
$tpl->set('s', 'countchas', $countchas);
$tpl->set('s', 'title_right_countcha_input', mi18n("title_right_countcha_input"));
$tpl->set('s', 'amount', $amount);
$tpl->set('s', 'button_text', mi18n("button_text"));
$tpl->generate('templates/'.$template_form);
}
/****** end displaying form ******/
/****** begin displaying comment after confirmation and mysql-insert ******/
if($insert_data=="true")
{
/****** begin displaying comment after confirmation ******/
$stringposition=strpos ($url,'&'); //clear url from variables
$url_for_insert=substr($url,0,$stringposition);
echo'<p><a class="c_sd_link" href="'.$url_for_insert.'" title="'.mi18n("back_to_article").'">'.mi18n("back_to_article").'</a></p>';
/****** end displaying comment after confirmation ******/
/****** begin mysql-insert ******/
$insert="INSERT INTO comments_sd (idart, url, name, email, website, text, parent_id, level, date, time, online) VALUES ('$idart', '$url_for_insert', '$commentname', '$commentemail', '$commentwebsite', '$commenttext', '$parent_id', '$level', '$date', '$time', '$standard_onlinestatus')";
$insert = mysql_query($insert);
if($debug=="true") {if ($insert==true) {echo 'insert: success';} else echo 'insert: failure';}
/****** end mysql-insert ******/
/****** begin email-alert ******/
if($mail_alert=="true")
{
// eMail-header:
$link_new_comment=$main_url_email_alert.'?idcat='.$idcat.'&idart='.$idart;
$mail_header = mi18n("email_header");
$from="From: Website <no_reply@new_comment.com>\n";
$from .= "Reply-To: no_reply@new_comment.com\n";
$from .= "Content-Type: text/html\n";
$message=mi18n("email_message_new_comment_for").' <a href="'.$link_new_comment.'" target="_blank">'.$link_new_comment.'</a>';
// send eMail
$emails_in_array=explode("//",$email_comment_alert);
foreach($emails_in_array as $mailto)
{
mail($mailto, $mail_header, $message, $from);
}
}
/****** end email-alert ******/
}
/****** end displaying comment after confirmation and mysql-insert ******/
/****** begin displaying comments ******/
echo '<div class="c_sd_headline_comments">';
if($headline_comments_image!="") echo '<img src="'.$headline_comments_image.'" alt="'.mi18n("headline_comments").'" title alt="'.mi18n("headline_comments").'"/>';
echo mi18n("headline_comments").'</div><br/>';
if($show_form!="true") echo '<p><a class="c_sd_link" href="'.$main_url.'?idcat='.$idcat.'&idart='.$idart.'&show_form=true" title="'.mi18n("post_a_comment").'">'.mi18n("post_a_comment").'</a><p>';
if($show_form=="true")//for displaying form, the url contains &show_form - what blocks searching the correct data in the database. so it has to be cut
{
$stringposition=strpos ($url,'&');
$url=substr($url,0,$stringposition);
}
function datatransfer($commentname,$commentemail,$commentwebsite,$commentdate,$commenttime,$commenttext,$url,$main_url,$idart,$commentlevel,$comment_parent_id,$linktext,$id,$online,$reload_url,$has_child,$maximum_comment_level)
{
//echo 'reload_url: '.$reload_url.'<br/>';
global $array_displayed_comments,$contenido,$template_commentbox,$template_commentbox_no_more_comments,$enable_br;
if($enable_br=="true") $commenttext = nl2br($commenttext);// enables displaying <br/>
$d=explode("-",$commentdate);
$commentdate=sprintf("%02d.%02d.%04d", $d[2], $d[1], $d[0]);
$margin_left=$commentlevel*20;
$commentlevel=$commentlevel+1;
if(!isset($tpl) || !is_object($tpl))
{
$tpl = new Template();
}
$tpl->reset();
$tpl->set('s', 'margin_left', $margin_left);
$tpl->set('s', 'commentname', $commentname);
$tpl->set('s', 'commentwebsite', $commentwebsite);
$tpl->set('s', 'commentdate', $commentdate);
$tpl->set('s', 'commenttime', $commenttime);
$tpl->set('s', 'commenttext', $commenttext);
$tpl->set('s', 'url', $url); //currently not in use, the database table contains url, because the next step would be enabling comments for dynamic contents of articles. e.g. a picture-gallery -> the url contains besides the idart other information like name and path of picture
$tpl->set('s', 'main_url', $main_url);
$tpl->set('s', 'idart', $idart);
$tpl->set('s', 'commentlevel', $commentlevel);
$tpl->set('s', 'comment_parent_id', $comment_parent_id);
$tpl->set('s', 'linktext', $linktext);
if($commentlevel<=$maximum_comment_level)
$tpl->generate('templates/'.$template_commentbox);
else
$tpl->generate('templates/'.$template_commentbox_no_more_comments);
if($contenido) backend_comment_options ($reload_url,$id,$online,$commentemail,$has_child);
}
//$query = "SELECT parent_id, id,level FROM comments_sd WHERE url='$url' ORDER by id ASC"; //currently not possible, the database table contains url, because the next step would be enabling comments for dynamic contents of articles. e.g. a picture-gallery -> the url contains besides the idart other information like name and path of picture
if($edit)
{
// backend: count all comments (on- and offline)
$query = "SELECT parent_id, id,level FROM comments_sd WHERE idart='$idart' ORDER by id ASC";
}
else
{
//frontend: count comments which are online
$query = "SELECT parent_id, id,level FROM comments_sd WHERE idart='$idart' AND online = '1' ORDER by id ASC";
}
$result = mysql_query($query);
$amount_of_comments = mysql_num_rows($result);
if($amount_of_comments=="0")
{
echo mi18n("no_comments_yet");
}
else
{
echo mi18n("amount_of_comments_yet").' '.$amount_of_comments.'<br/>';
if($edit) echo '(online + offline)<br/>';
$maxlevel=0;
while ($row = mysql_fetch_array($result))// AND $i<=$maxlevel)
{
${'array_l_'.$row[level]}[]=$row[id];
if($maxlevel<$row[level]) $maxlevel=$row[level];
$array_level_id_parent_id[]=array($row[level],$row[id],$row[parent_id]);
}
if($debug=="true") echo 'maxlevel: '.$maxlevel.'<br/>';
}
if($debug=="true")
{
$i=0;
while($i<=$maxlevel)
{
echo 'level '.$i.': '; if(count(${'array_l_'.$i}) > 0) {foreach(${'array_l_'.$i} AS ${'element_l_'.$i}) echo ${'element_l_'.$i}." | ";} echo '<br/>';
$i++;
}
$i=0;
while($i<$amount_of_comments)
{
echo $all_comments[$i].'<br/>';
$i++;
}
echo '<br/>array_level_id_parent_id<br/>';
$i=0;
foreach($array_level_id_parent_id AS $element)
{
echo $i.' ';
print_r($element);
echo '<br/>';
$i++;
}
echo '<br/>array_level_id_parent_id - sorting<br/>';
}
/****** begin building comment ranking ******/
$array_used_comments=array();
$array_comment_ranking=array();
$levelcounter=1;
function unset_array_level_id_parent_id($element)
{
global $array_level_id_parent_id;
$i=0;
$n=count($array_level_id_parent_id);
while($i<$n)
{
if($array_level_id_parent_id[$i][1]==$element) unset($array_level_id_parent_id[$i]);
$i++;
}
}
function level_extractor($levelcounter)
{
global $array_level_id_parent_id;
foreach($array_level_id_parent_id AS $element)
{
if($element[0]==$levelcounter) $extracted_levels[]=$element;
}
return $extracted_levels;
}
function collect_level_parent_ids($extracted_levels)
{
foreach($extracted_levels AS $element)
{
$collected_level_parent_ids[]=$element[2];
}
$collected_level_parent_ids=array_unique($collected_level_parent_ids);
return $collected_level_parent_ids;
}
function integrate($parent_id,$ids_for_function_integrate)
{
global $array_comment_ranking;
$i=0;
foreach($array_comment_ranking AS $element) //search for parent_id to place the pointer for integration
{
if($element==$parent_id)
{
$pointer=$i+1;
break;
}
$i++;
}
$array_comment_ranking=array_merge(array_slice($array_comment_ranking, 0, $pointer), array_values($ids_for_function_integrate), array_slice($array_comment_ranking, $pointer));
if($debug=="true") {echo '<br/>integrate<br/>';print_r($array_comment_ranking);}
}
function collect_ids_to_integrate($collected_level_parent_ids)
{
global $array_level_id_parent_id;
foreach($collected_level_parent_ids AS $element)
{
$i=0;
$n=count($array_level_id_parent_id);
while($i<=$n)
{
if($element==$array_level_id_parent_id[$i][2])
{
$ids_to_integrate[]=$array_level_id_parent_id[$i];
}
$i++;
}
foreach($ids_to_integrate AS $element)
{
if($debug=="true") echo 'element: '.$element[1].'<br/>';
$i=0;
$n=count($array_level_id_parent_id);
while($i<=$n)
{
if($element[1]==$array_level_id_parent_id[$i][1])
{
unset($array_level_id_parent_id[$i]);
$array_level_id_parent_id=array_values($array_level_id_parent_id);
}
$i++;
}
}
$parent_id=$ids_to_integrate[0][2];
foreach($ids_to_integrate AS $element)
{
$ids_for_function_integrate[]=$element[1];
}
if($debug=="true") {echo 'parent_id: '.$parent_id.' '; echo 'ids to integrate: '; foreach($ids_for_function_integrate AS $element) {echo $element.',';} echo '<br/>';}
integrate($parent_id,$ids_for_function_integrate);
$ids_to_integrate=array(); // setting back, so childs of a further parent-id will not be appended to childs of previous parent-id
$ids_for_function_integrate=array();
}
}
//LEVEL 0
$array_comment_ranking=$array_l_0;
$array_used_comments=$array_l_0;
if($amount_of_comments>0)
{
foreach($array_comment_ranking AS $element)
{
unset_array_level_id_parent_id($element);
$array_level_id_parent_id=array_values($array_level_id_parent_id);
}
//LEVELS > 0
while($levelcounter<=$maxlevel)
{
$extracted_levels=level_extractor($levelcounter);
if($debug=="true") {echo '<br/>extracted_levels<br/>'; foreach($extracted_levels AS $element) {print_r($element); echo '<br/>';}}
$collected_level_parent_ids=collect_level_parent_ids($extracted_levels);
if($debug=="true") {echo '<br/>collected_level_parent_ids<br/>'; foreach($collected_level_parent_ids AS $element) {print_r($element); echo '<br/>';}}
$collected_ids_to_integrate=collect_ids_to_integrate($collected_level_parent_ids);
$levelcounter++;
}
}
/****** end building comment ranking ******/
if($debug=="true")
{
echo '<br/>array_used_comments:<br/>';
$i=0;
while($i<count($array_used_comments))
{
echo $array_used_comments[$i].'<br/>';
$i++;
}
echo '<br/>array_level_id_parent_id<br/>';
$i=0;
foreach($array_level_id_parent_id AS $element)
{
echo $i.' ';
print_r($element);
echo '<br/>';
$i++;
}
echo '<br/>array_comment_ranking:<br/>';
$i=0;
while($i<count($array_comment_ranking))
{
echo $array_comment_ranking[$i].'<br/>';
$i++;
}
}
/****** begin building the comment tree ******/
if($amount_of_comments>0)
{
echo '<div class="c_sd_box_comment_tree">';
foreach($array_comment_ranking AS $element)
{
$has_child="false";
$query = "SELECT * FROM comments_sd WHERE id='$element' ORDER by id ASC";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$has_child="";
if($contenido) // only needed for backend, not for frontend
{$array_children_element_l_0=array("");
$query_b = "SELECT id FROM comments_sd WHERE parent_id='$element' ORDER by id ASC";
$result_b = mysql_query($query_b);
$num_rows= mysql_num_rows($result_b);
if($num_rows>0) $has_child="true";
}
if($row[online]=="1" AND !$contenido) datatransfer ($row[name],$row[email],$row[website],$row[date],$row[time],$row[text],$url,$main_url,$idart,$row[level],$row[id],mi18n("answer_comment"),$row[id],$row[online],$reload_url,$has_child,$maximum_comment_level);
if($row[text]!="" AND $contenido) datatransfer ($row[name],$row[email],$row[website],$row[date],$row[time],$row[text],$url,$main_url,$idart,$row[level],$row[id],mi18n("answer_comment"),$row[id],$row[online],$reload_url,$has_child,$maximum_comment_level);
}
echo '</div>';
}
/****** end building the comment tree ******/
/****** end displaying comments ******/
echo '</div>';
}
?>
comments_sd_commentbox.html
Code: Alles auswählen
<div class="c_sd_commentbox_{commentlevel}" style="margin-left:{margin_left}px">
<table class="c_sd_commentbox">
<tr>
<td class="c_sd_commentbox_1_a">
<span class="c_sd_commentbox_name">{commentname}</span><br/>
<span class="c_sd_commentbox_website">web: <a href="http://{commentwebsite}" target="_blank" title="{commentwebsite}">{commentwebsite}</a></span>
</td>
<td class="c_sd_commentbox_1_b">
<span class="c_sd_commentbox_date">{commentdate}</span><br/>
<span class="c_sd_commentbox_time">{commenttime}</span>
</td>
</tr>
<tr>
<td colspan="2" class="c_sd_commentbox_2">{commenttext}</td>
</tr>
<tr>
<td colspan="2" class="c_sd_commentbox_3">
<a class="c_sd_link" href="{main_url}?idart={idart}&show_form=true&parent_id={comment_parent_id}&level={commentlevel}" title="{linktext}">{linktext}</a>
</td>
</tr>
</table>
</div>
Code: Alles auswählen
<div class="c_sd_commentbox_{commentlevel}" style="margin-left:{margin_left}px">
<table class="c_sd_commentbox">
<tr>
<td class="c_sd_commentbox_1_a">
<span class="c_sd_commentbox_name">{commentname}</span><br/>
<span class="c_sd_commentbox_website">web: <a href="http://{commentwebsite}" target="_blank" title="{commentwebsite}">{commentwebsite}</a></span>
</td>
<td class="c_sd_commentbox_1_b">
<span class="c_sd_commentbox_date">{commentdate}</span><br/>
<span class="c_sd_commentbox_time">{commenttime}</span>
</td>
</tr>
<tr>
<td colspan="2" class="c_sd_commentbox_2" style="border-bottom: 0px;">{commenttext}</td>
</tr>
</table>
</div>
Code: Alles auswählen
<form id="commentform" name="comments" method="post" action="">
<table>
<tr>
<td class="tabellenzelle_formular_ueberschrift">{name}</td>
<td><input type="text" name="commentname" value="{commentname}"/></td>
</tr>
<tr>
<td class="tabellenzelle_formular_ueberschrift">{email}</td>
<td><input type="text" name="commentemail" value="{commentemail}"/></td>
</tr>
<tr>
<td class="tabellenzelle_formular_ueberschrift">{website}</td>
<td><input type="text" name="commentwebsite" value="{commentwebsite}"/></td>
</tr>
<tr>
<td class="tabellenzelle_formular_ueberschrift">{text}</td>
<td><textarea cols="40" rows="10" name="commenttext">{commenttext}</textarea></td>
</tr>
</table>
{how_many_countchas} {title_right_countcha}<br/>
<span class="hinweis_klein">{how_many_countchas_hint_spam}</span><br/>
{countchas_2}{countchas_1}
<table>
<tr>
<td>{how_many_countchas_input}</td>
<td><input style="width: 40px;" type="text" name="countcha" value="{countchas}" size="1" maxlength="10"></input></td>
<td>{title_right_countcha_input}</td>
</tr>
</table>
<br/>
<input type="hidden" name="amount" value="{amount}"></input>
<input type="submit" class="button" name="submit" value="{button_text}">
</form>
<br/>
<br/>
Code: Alles auswählen
<form id="commentform" name="comments" method="post" action="">
<table>
<tr>
<td>comment-id</td>
<td>
<select name="change_id_select">
{select}
</select>
</td>
<td rowspan="4">Text<br/><textarea cols="30" rows="4" name="change_text"/>{value_change_text}</textarea></td>
</tr>
<tr>
<td>Name</td><td><input type="text" name="change_name" value="{value_change_name}" size="20"/></td>
</tr>
<tr>
<td>eMail</td><td><input type="text" name="change_email" value="{value_change_email}" size="20"/></td>
</tr>
<tr>
<td>www</td><td><input type="text" name="change_www" value="{value_change_www}" size="20"/></td>
</tr>
</table>
<span style="font-size: 80%;"><u>Wichtig:</u> Änderungen können nicht wieder rückgängig gemacht werden. Richtige Comment-ID eingetragen?</span><br/>
<input type="submit" class="button" name="submit" value="{button_text}">
</form>
Code: Alles auswählen
/* ###################################################### */
/* ##################### COMMENTS SD #################### */
/* ###################################################### */
a.c_sd_link {
color: #3d857d;
text-decoration: none;
background-image: url('../upload/bullets/link_text.jpg');
background-position: center left;
background-repeat: no-repeat;
padding-left: 20px;
}
a.c_sd_link:hover {
text-decoration: underline;
}
div.c_sd_box_main {
clear:both;
width: 90%;
border-left: 1px solid #999999;
border-top: 1px solid #999999;
border-radius: 5px;
margin-left: 10px;
margin-top: 10px;
padding-left: 10px;
padding-top: 10px;
}
div.c_sd_box_comment_tree {
margin-bottom: 20px;
}
div.c_sd_commentbox_1,
div.c_sd_commentbox_2,
div.c_sd_commentbox_3,
div.c_sd_commentbox_4,
div.c_sd_commentbox_5,
div.c_sd_commentbox_6,
div.c_sd_commentbox_7,
div.c_sd_commentbox_8,
div.c_sd_commentbox_9 {
clear: both;
width: 70%;
margin-top: 20px;
border: 1px solid #999999;
border-radius: 5px 5px;
}
div.c_sd_commentbox_1 {
border: 1px solid #000000;
background-color: #efefef;
}
div.c_sd_commentbox_backend_options {
width: 90%;
text-align: right;
}
div.c_sd_headline_comments {
color: #3d857d;
font-weight: 900;
font-size: 14px;
}
table.c_sd_commentbox {
width: 100%;
border-collapse: collapse;
}
td.c_sd_commentbox_1_a {
width: 80%;
font-weight: 900;
padding: 3px;
}
td.c_sd_commentbox_1_b {
width: 20%;
text-align: right;
padding: 3px;
}
td.c_sd_commentbox_2 {
color: #555555;
padding: 3px;
border-top: 1px dotted #999999;
border-bottom: 1px solid #999999;
}
td.c_sd_commentbox_3 {
text-align: right;
padding: 3px;
}
Code: Alles auswählen
<?xml version="1.0" encoding="ISO-8859-1"?>
<module><translation origin-language-id="1" origin-language-name="deutsch"><string><original>errormessage_commentemail</original>
<translation>Bitte gebe eine korrekte eMail-Adresse ein.</translation>
</string>
<string><original>errormessage_commentwebsite</original>
<translation>Bitte gebe eine korrekte Webadresse ein.</translation>
</string>
<string><original>errormessage_commenttext</original>
<translation>Bitte gebe Deinen Kommentar ein.</translation>
</string>
<string><original>errormessage_countchas</original>
<translation>Bitte gebe die korrekte Anzahl an Daumen ein.</translation>
</string>
<string><original>headline_form</original>
<translation>Kommentar schreiben:</translation>
</string>
<string><original>confirmation</original>
<translation>Vielen Dank, der Kommentar wird nach Prüfung freigeschaltet.</translation>
</string>
<string><original>name</original>
<translation>Name:</translation>
</string>
<string><original>email</original>
<translation>eMail-Adresse<br>(wird nicht veröffentlicht):</translation>
</string>
<string><original>website</original>
<translation>Website:</translation>
</string>
<string><original>text</original>
<translation>Kommentar:</translation>
</string>
<string><original>how_many_countchas</original>
<translation>Wie viele </translation>
</string>
<string><original>title_right_countcha</original>
<translation>Daumen siehst Du?</translation>
</string>
<string><original>how_many_countchas_hint_spam</original>
<translation>(Diese Abfrage dient zur Vermeidung vom Spam-Einträgen.)</translation>
</string>
<string><original>how_many_countchas_input</original>
<translation>Es sind </translation>
</string>
<string><original>title_right_countcha_input</original>
<translation>Daumen.</translation>
</string>
<string><original>button_text</original>
<translation>Abschicken</translation>
</string>
<string><original>back_to_article</original>
<translation>zurück zum Artikel</translation>
</string>
<string><original>email_header</original>
<translation>Neuer Kommentar!</translation>
</string>
<string><original>email_message_new_comment_for</original>
<translation>Es gibt einen neuen Kommentar für diesen Artikel:</translation>
</string>
<string><original>headline_comments</original>
<translation>Kommentare:</translation>
</string>
<string><original>post_a_comment</original>
<translation>Schreibe einen Kommentar!</translation>
</string>
<string><original>no_comments_yet</original>
<translation>Bisher wurde kein Kommentar verfasst.</translation>
</string>
<string><original>answer_comment</original>
<translation>auf Kommentar antworten</translation>
</string>
<string><original>amount_of_comments_yet</original>
<translation>Anzahl bisheriger Kommentare:</translation>
</string>
<string><original>confirmation_immediately_online</original>
<translation>Vielen Dank für den Kommentar.</translation>
</string>
</translation>
</module>
EDIT 08.03.2013: Anpassungen in der Modul-Ausgabe in punkto AMR-Linkprobleme vorgenommen -> http://forum.contenido.org/viewtopic.ph ... 56#p157456
----------------------------------------