Author Topic: Comment box in a popup window  (Read 7292 times)

0 Members and 1 Guest are viewing this topic.

Offline batu544

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Free Celebrity wallpapers
Comment box in a popup window
« on: August 04, 2010, 10:01:23 PM »
Hi All-
            Is it possible to display the comment box in a modal popup window ?? means If someone clicks on the link called "add your comment" , a new modal popup window  will be displayed to enter the comment and after successfully posting a comment it will be auto closed.



Thanks,
batu544
« Last Edit: August 04, 2010, 10:23:50 PM by batu544 »

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Re: Comment box in a popup window
« Reply #1 on: August 07, 2010, 02:23:58 PM »
Hello batu,

I have written instructions for it like this goes. With me the whole one functions perfectly!

Indeed, my article waits for connection

=> http://www.4homepages.de/forum/index.php?topic=27667.0

Offline batu544

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Free Celebrity wallpapers
Re: Comment box in a popup window
« Reply #2 on: August 08, 2010, 09:25:07 AM »
Thanks Sumale.nin for your response and also for the MOD, but my changes/requirement is little bit different and I am currently doing the changes for myself.. I will update my website with this changes in this week only.. :)  . but I must say thank you, because I got the idea of auto closing popup window from your comment_popup.php .

After implementing the changes.. I will post the codes here.. for experts reviews..  :wink:


Thank you.. !!

Updates...

I am almost done with my changes.. but I don't think, the same changes will be required by any other webmasters.. so I am not posting all the code changes..

Here is how my comments.php file looks like...

Code: [Select]
<?php 
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: commnets.php                                         *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.6                                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) f&#252;r weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/
$main_template 'comment_live';
define('GET_CACHES'1);
define('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
$user_access get_permission();
include(
ROOT_PATH.'includes/page_header.php');

if (!
$image_id) {
    
redirect($url);
}

$additional_sql "";
if (!empty(
$additional_image_fields)) {
  foreach (
$additional_image_fields as $key => $val) {
    
$additional_sql .= ", i.".$key;
  }
}

$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name").get_user_table_field(", u.""user_email")."
        FROM ("
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = i.user_id)
        WHERE i.image_id = 
$image_id AND i.image_active = 1 AND c.cat_id = i.cat_id";
$image_row $site_db->query_firstrow($sql);
$cat_id = (isset($image_row['cat_id'])) ? $image_row['cat_id'] : 0;
$is_image_owner = ($image_row['user_id'] > USER_AWAITING && $user_info['user_id'] == $image_row['user_id']) ? 0;

if (!
check_permission("auth_viewcat"$cat_id) || !check_permission("auth_viewimage"$cat_id) || !$image_row) {
  
redirect($url);
}
//-----------------------------------------------------
//--- Save Comment ------------------------------------
//-----------------------------------------------------
$error 0;
if (
$action == "postcomment" && isset($HTTP_POST_VARS[URL_ID])) {
  
$id intval($HTTP_POST_VARS[URL_ID]);
  
$sql "SELECT cat_id, image_allow_comments
          FROM "
.IMAGES_TABLE."
          WHERE image_id = 
$id";
  
$row $site_db->query_firstrow($sql);

  if (
$row['image_allow_comments'] == || !check_permission("auth_postcomment"$row['cat_id']) || !$row) {
    
$msg $lang['comments_deactivated'];
  }
  else {
    
$user_name un_htmlspecialchars(trim($HTTP_POST_VARS['user_name']));
    
$comment_headline un_htmlspecialchars(trim($HTTP_POST_VARS['comment_headline']));
    
$comment_text un_htmlspecialchars(trim($HTTP_POST_VARS['comment_text']));

    
$captcha = (isset($HTTP_POST_VARS['captcha'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['captcha'])) : "";

    
// Flood Check
    
$sql "SELECT comment_ip, comment_date
            FROM "
.COMMENTS_TABLE."
            WHERE image_id = 
$id
            ORDER BY comment_date DESC
            LIMIT 1"
;
    
$spam_row $site_db->query_firstrow($sql);
    
$spamtime $spam_row['comment_date'] + 180;

    if (
$session_info['session_ip'] == $spam_row['comment_ip'] && time() <= $spamtime && $user_info['user_level'] != ADMIN)  {
      
$msg .= (($msg != "") ? "<br />" "").$lang['spamming'];
      
$error 1;
    }

    
$user_name_field get_user_table_field("""user_name");
    if (!empty(
$user_name_field)) {
      if (
$site_db->not_empty("SELECT $user_name_field FROM ".USERS_TABLE." WHERE $user_name_field = '".strtolower($user_name)."' AND ".get_user_table_field("""user_id")." <> '".$user_info['user_id']."'")) {
        
$msg .= (($msg != "") ? "<br />" "").$lang['username_exists'];
        
$error 1;
      }
    }
    if (
$user_name == "")  {
      
$msg .= (($msg != "") ? "<br />" "").$lang['name_required'];
      
$error 1;
    }
//    if ($comment_headline == "")  {
//      $msg .= (($msg != "") ? "<br />" : "").$lang['headline_required'];
//      $error = 1;
//    }
    
if ($comment_text == "")  {
      
$msg .= (($msg != "") ? "<br />" "").$lang['comment_required'];
      
$error 1;
    }

    if (
$captcha_enable_comments && !captcha_validate($captcha)) {
      
$msg .= (($msg != "") ? "<br />" "").$lang['captcha_required'];
      
$error 1;
    }

    if (!
$error)  {
      
$sql "INSERT INTO ".COMMENTS_TABLE."
              (image_id, user_id, user_name, comment_headline, comment_text, comment_ip, comment_date)
              VALUES
              (
$id, ".$user_info['user_id'].", '$user_name', '$comment_headline', '$comment_text', '".$session_info['session_ip']."', ".time().")";
      
$site_db->query($sql);
      
$commentid $site_db->get_insert_id();
      
update_comment_count($id$user_info['user_id']);
      
$msg "<script type=\"text/javascript\">
        window.setTimeout('self.close()', 10);
        </script>\n"
;
      echo 
$msg;
     } elseif (
$error) {
 echo '<div style="padding: 10px">' $msg '</div>';
 }
  }
  unset(
$row);
  unset(
$spam_row);
}

if (
$image_allow_comments == 0) {
  
//-----------------------------------------------------
  //--- BBCode & Form -----------------------------------
  //-----------------------------------------------------
  
$allow_posting check_permission("auth_postcomment"$cat_id);
  
$bbcode "";
  if (
$config['bb_comments'] == && $allow_posting) {
    
$site_template->register_vars(array(
      
"lang_bbcode" => $lang['bbcode'],
      
"lang_tag_prompt" => $lang['tag_prompt'],
      
"lang_link_text_prompt" => $lang['link_text_prompt'],
      
"lang_link_url_prompt" => $lang['link_url_prompt'],
      
"lang_link_email_prompt" => $lang['link_email_prompt'],
      
"lang_list_type_prompt" => $lang['list_type_prompt'],
      
"lang_list_item_prompt" => $lang['list_item_prompt']
    ));
    
$bbcode $site_template->parse_template("bbcode");
  }
  if (!
$allow_posting) {
    
$comment_form_live "";
  }
  else {
    
$user_name = (isset($HTTP_POST_VARS['user_name']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['user_name'])), 2) : (($user_info['user_level'] != GUEST) ? format_text($user_info['user_name'], 2) : "");
    
$comment_headline = (isset($HTTP_POST_VARS['comment_headline']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['comment_headline'])), 2) : "";
    
$comment_text = (isset($HTTP_POST_VARS['comment_text']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['comment_text'])), 2) : "";

    
$site_template->register_vars(array(
      
"bbcode" => $bbcode,
      
"user_name" => $user_name,
      
"comment_headline" => $comment_headline,
      
"comment_text" => $comment_text,
      
"url_form" => $site_sess->url(ROOT_PATH."comments.php?image_id=$image_id"),
      
"image_id" => $image_id,
      
"lang_post_comment" => $lang['post_comment'],
      
"lang_name" => $lang['name'],
      
"lang_headline" => $lang['headline'],
      
"lang_comment" => $lang['comment'],
      
"lang_captcha" => $lang['captcha'],
      
"lang_captcha_desc" => $lang['captcha_desc'],
      
"captcha_comments" => (bool)$captcha_enable_comments
    
));
    
$comment_form_live $site_template->parse_template("comment_form_live");
  }
  
$site_template->register_vars("comment_form_live"$comment_form_live);
  unset(
$comment_form_live);
  
$site_template->print_template($site_template->parse_template($main_template));
// end if allow_comments



//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"msg" => $msg,
  
"clickstream" => $clickstream,
  
"lang_category" => $lang['category'],
  
"lang_added_by" => $lang['added_by'],
  
"lang_description" => $lang['description'],
  
"lang_keywords" => $lang['keywords'],
  
"lang_date" => $lang['date'],
  
"lang_hits" => $lang['hits'],
  
"lang_downloads" => $lang['downloads'],
  
"lang_rating" => $lang['rating'],
  
"lang_votes" => $lang['votes'],
  
"lang_author" => $lang['author'],
  
"lang_comment" => $lang['comment'],
  
"lang_prev_image" => $lang['prev_image'],
  
"lang_next_image" => $lang['next_image'],
  
"lang_file_size" => $lang['file_size']
));

//$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>


Could any php/4image guru review this code and let me know the unwanted parts, so that I can remove it from here...


If anyone wants a demo of this changes .. they can visit any images which is under wallpaper section and try to download any size image..  ( not original version.. Its under development.. :wink:  )

Thank you.
« Last Edit: August 08, 2010, 12:12:14 PM by batu544 »

Rembrandt

  • Guest
Re: Comment box in a popup window
« Reply #3 on: August 08, 2010, 02:12:23 PM »
@batu, you can test this one

create a new folder in your root, call it "js" and copy the attachment in the new folder

search in details.php:
 if (!$error)  {
insert above:

if ($error == 1) {
     
$site_template->register_vars("msg"$msg);
?> 
<body onLoad="Popup.show('popdiv');"></body> 
<? 
    


search:
"lang_bbcode" => $lang['bbcode'],
insert above:
"show_div" => "<span><a href=\"#\" onclick=\"Popup.show('popdiv',Screen.getBody(),'center center',{'constrainToScreen':true});;return false;\">Click Here To Show Comment Form</a></span>",


search in details.html:
Code: [Select]
{comment_form}and replace:
Code: [Select]
<script type="text/javascript" src="./js/popup.js"></script>                 
 <div id="popdiv" style="border:1px solid black;display:none;width:200px;height:200px;">
{comment_form}</div>
{show_div}

thats all :)

mfg Andi
« Last Edit: August 08, 2010, 06:14:52 PM by Rembrandt »

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: Comment box in a popup window
« Reply #4 on: August 08, 2010, 04:44:05 PM »
hi,
very nice!
but one thing: is it possible to open the popup in the middle of the window?
now i have to scroll down.. and see the popup near the end of my site.

Rembrandt

  • Guest
Re: Comment box in a popup window
« Reply #5 on: August 08, 2010, 06:14:14 PM »
..
but one thing: is it possible to open the popup in the middle of the window? ...

"show_div" => "<span><a href=\"#\" onclick=\"Popup.show('popdiv',Screen.getBody(),'center center',{'constrainToScreen':true});;return false;\">Click Here To Show Comment Form</a></span>",


mfg Andi

Offline batu544

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Free Celebrity wallpapers
Re: Comment box in a popup window
« Reply #6 on: August 08, 2010, 07:03:19 PM »
@Rembrandt,
                    Thank you for your help.. but I have already implemented the other way to achieve this..


Regards...
batu544