/* Enjoy!!! Dino Ciuffetti - dam2k@users.sourceforge.net * * * 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; version 2 of the License. * * 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 (COPYING); if not, go to http://www.fsf.org/ or write * to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * */ /* MAIN FILE FOR COMMENTATOR cmsdAm PLUGIN */ /* Variables that we can use $comments_per_page number of comments for each page $comments_td_color[0] background color number 1 $comments_td_color[1] background color 2 */ /* Variables that we probably can use $PageMaxRows number of comments for each pagee $users cmsdam users class instance $cms cmsdam cms class instance $page page number $section section name $client_ip IP addres of the client */ include ("plugins/commentator/configure.php"); Class CmsDam_Commentator /* This class is the core of cmsdam_commentator */ { var $comments; // comments array var $page_comments; // comments array after paginator var $total_ncomments; // total comment numbers var $page_ncomments; // comment numbers for page $page function CmsDam_Commentator() { // CmsDam_Commentator Constructor $this->CmsDam_Commentator_List(); } function CmsDam_Comment_limiter($conf) { // This function is the commentator limiter // Global $conf, $PageMaxRows, $cms, $page, $section, $client_ip; // TODO: Implement this method!! return true; } function CmsDam_Commentator_Add($comment_text) { // Add a comment for the present section Global $conf, $PageMaxRows, $cms, $page, $section, $client_ip; if (!$this->CmsDam_Comment_limiter($conf)) { // Comment limiter check failed! // Are u trying to flood us?!!! return false; } if (strlen(trim($comment_text)) <= 1) { // Text check return true; } // echo "DEBUG: Comment: $comment_text"; if (!$cms->sections->comment_add ($comment_text)) { // Add comment $cms->logs->log_note(5, "WARNING: Commentator plugin: error adding comment for section \"$section\", text: $comment_text"); return false; } $cms->logs->log_note(7, "NOTE: Commentator plugin: comment added for section \"$section\", text: $comment_text"); return true; } function CmsDam_Commentator_List() { Global $PageMaxRows, $cms, $page, $section, $client_ip; $conf = new CmsDam_Commentator_Conf; // echo "DEBUG: comments_inputname " . $conf->comments_inputname; if (isset($PageMaxRows) && ($PageMaxRows > 0)) { // $PageMaxRows overrides $comments_per_page (conf file) $conf->comments_per_page = $PageMaxRows; } $cms->dbms->DB_connect(); if ($cms->dbms->db_connected != 1) { // DB not connected $cms->logs->log_note(4, "WARNING: Commentator plugin: error connetting to the DB!"); return false; } $inputname = $conf->comments_inputname; Global $$inputname; // echo "DEBUG: comments_inputname: " . $$inputname; if (isset($$inputname) && strlen($$inputname) > 0) { // A comment was added $this->CmsDam_Commentator_Add($$inputname); } // Comments array for section $section $this->comments = $cms->sections->comment_getarray(); $this->total_ncomments = count ($this->comments); // Number of comment pages for section $section $pages = $cms->paginator->paginator_pages ($conf->comments_per_page, $this->comments); if ($pages < 1) $pages = 1; if (($page <= 0) || ($page > $pages) || (!$page)) { // Page number is not valid $page = 1; } // Paginator!! $this->page_comments=$cms->paginator->paginator_array($conf->comments_per_page,$page,$this->comments); $this->page_ncomments = count ($this->page_comments); ?>
|
if ($page == 1) { // This is the first page echo " <<\n"; } else { // This is not the first page echo "sections->section_uri("$section", 1) . "&page=" . ($page - 1) . "#commentator\"> <<\n"; } echo " | \n";
?>
Pagina = $page ?> di = $pages ?> |
if ($page == $pages) { // This is the last page echo ">> \n"; } else { // This is not the last page echo "sections->section_uri("$section", 1) . "&page=" . ($page + 1) . "#commentator\">>> \n"; } echo " | \n";
?>
| Utente | Commento | Data |
| \n"; $username = $users->user_namebyid($this->page_comments[$i][2]); echo "" . $username . " | \n"; echo "\n"; echo "" . $this->page_comments[$i][1] . " | \n"; echo "\n"; echo "" . $this->page_comments[$i][4] . " | \n"; echo "
| if (isset($conf->comments_submitimage) && (trim(strlen($conf->comments_submitimage)) >= 1)) { echo ''; } else { echo ''; } ?> |