• [MOD] Last comments v1.2.0 4 0 5 1
Currently:  

Author Topic: [MOD] Last comments v1.2.0  (Read 212585 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Last comments v1.2.0
« on: May 09, 2005, 07:38:44 AM »
This mod will show last comments.
I've split this mod on two parts:
  • Part 1 - last comments on home page (or any other pages)
  • Part 2 - A separate page with list of all comments, with paging
Works with 4images v1.7/1.7.1


-------- [ Part 1 ] --------

---------- [ Changed files ] ----------

index.php
lang/<your language>/main.php
templates/<your template>/home.html



---------- [ New file ] ----------

templates/<your template>/last_comment_bit.html

---------- [ Installation ] ----------

Step 1
Open index.php
Find:
Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------

Insert above:/*
  MOD LAST COMMENTS
  START INSERT
*/
//Settings
$num 7//how many comments to show
$thumb_size 48//max dim of thumbnails in pixels
$text_len 200//max lenght of the text to show (bbcode and html are counted too)
//End settings

$last_comments "";
$additional_sql "";
if (!empty(
$additional_image_fields))
{
  foreach (
$additional_image_fields as $key => $val)
  {
    
$additional_sql .= ", i.".$key;
  }
}
if (!empty(
$additional_user_fields))
{
  foreach (
$additional_user_fields as $key => $val)
  {
    
$additional_sql .= ", s.".$key." as comment_".$key.", u.".$key." as image_user_".$key;
  }
}
$sql "SELECT c.image_id, c.comment_id, c.user_id as comment_user_id, c.user_name as guest_user_name, c.comment_headline, c.comment_text, c.comment_date, i.cat_id, i.user_id, i.image_name, i.image_media_file, i.image_thumb_file".get_user_table_field(", u.""user_name")." as user_name".get_user_table_field(", s.""user_name")." as comment_user_name $additional_sql
        FROM "
.COMMENTS_TABLE." c
        LEFT JOIN "
.IMAGES_TABLE." i ON i.image_id = c.image_id
        LEFT JOIN "
.USERS_TABLE." u ON ".get_user_table_field("u.""user_id")." = i.user_id
        LEFT JOIN "
.USERS_TABLE." s ON ".get_user_table_field("s.""user_id")." = c.user_id
        WHERE i.image_active = 1 AND i.image_allow_comments = 1 AND i.cat_id NOT IN ("
.get_auth_cat_sql('auth_readcomment''NOTIN').") AND i.cat_id NOT IN (".get_auth_cat_sql('auth_viewcat''NOTIN').") AND i.cat_id NOT IN (".get_auth_cat_sql('auth_viewimage''NOTIN').")
        ORDER BY c.comment_date DESC
        LIMIT "
.$num;
$result $site_db->query($sql);
$bgcounter 1;
while (
$row $site_db->fetch_array($result))
{
  
$row_bg_number = ($bgcounter++ % == 0) ? 2;
  if (empty(
$row['image_thumb_file']))
  {
    
$thumb_file ICON_PATH."/".get_file_extension($row['image_media_file']).".gif";
  }
  else
  {
    
$thumb_file = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$row['cat_id']."/".$row['image_thumb_file'];
  }
  
$thumb_info = @getimagesize($thumb_file);
  
$width = ($thumb_info[0]) ? $thumb_info[0] : $thumb_size;
  
$height = ($thumb_info[1]) ? $thumb_info[1] : $thumb_size;
  if (
$width $thumb_size && $height $thumb_size)
  {
    
$ratio $width $height;
    if (
$ratio 1) {
      
$new_width $thumb_size;
      
$new_height round(($thumb_size/$width) * $height);
    }else {
      
$new_width round(($thumb_size/$height) * $width);
      
$new_height $thumb_size;
    }
  }
  else
  {
    
$new_width $width;
    
$new_height $height;
  }
  
$view_image true;
  
$thumb "<img src=\"".$thumb_file."\" border=\"".$config['image_border']."\" width=\"".$new_width."\" height=\"".$new_height."\" alt=\"".$row['image_name']."\" />";
/*
  $view_image = check_permission('auth_viewcat', $row['cat_id']);
  $thumb = "<img src=\"".$thumb_file."\"".(($view_image) ? "" : " onClick=\"alert('".(($lang['auth_alert'][$cat_id]) ? $lang['auth_alert'][$cat_id] : $lang['auth_alert']['default'])."');\"")." border=\"".$config['image_border']."\" width=\"".$new_width."\" height=\"".$new_height."\" alt=\"".$row['image_name']."\" />";
*/
  
$image_user_name = ($row['user_id'] != GUEST) ? $row['user_name'] : $lang['userlevel_guest'];
  
$image_user_url = ($row['user_id'] != GUEST) ? $site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;user_id=".$row['user_id']) : "";
  
$comment_user_name = ($row['comment_user_id'] == GUEST) ? ((empty($row['guest_user_name'])) ? $lang['userlevel_guest'] : $row['guest_user_name']) : $row['comment_user_name'];
  
$comment_user_url = ($row['comment_user_id'] != GUEST) ? $site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;user_id=".$row['comment_user_id']) : "";
  
$text $row['comment_text'];
  if (
strlen($text) > $text_len)
  {
    
$text substr($text0$text_len)." ...";
  }
  
$site_template->register_vars(array(
    
"last_comments_more" => "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showcomments""&")."\">".$lang['last_comments_more']."</a>",
    
"comment_image" => ($view_image) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$row['image_id'])."\">".$thumb."</a>" $thumb,
    
"comment_guest" => ($row['comment_user_id'] == GUEST && !empty($row['guest_user_name'])) ? $lang['userlevel_guest'] : "",
    
"comment_image_name" => ($view_image) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$row['image_id'])."\">".stripslashes($row['image_name'])."</a>" stripslashes($row['image_name']),
    
"image_cat_name" => (check_permission('auth_viewcat'$row['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$row['cat_id'])."\">".$cat_cache[$row['cat_id']]['cat_name']."</a>" $cat_cache[$row['cat_id']]['cat_name'],
    
"image_user_name" =>   ($image_user_url) ? "<a href=\"".$image_user_url."\">".$image_user_name."</a>" $image_user_name,
    
"image_user_url" => $image_user_url,
    
"image_user_id" => $row['user_id'],
    
"comment_user_name" => ($comment_user_url) ? "<a href=\"".$comment_user_url."\">".$comment_user_name."</a>" $comment_user_name,
    
"comment_user_url" => $comment_user_url,
    
"comment_user_id" => $row['comment_user_id'],
    
"comment_headline" => format_text($row['comment_headline'], 0$config['wordwrap_comments'], 00),
    
"comment_text" => format_text($text$config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments']),
    
"comment_date" => format_date($config['date_format']." ".$config['time_format'], $row['comment_date']),
    
"comment_image_openwindow" => ($view_image) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$row['image_id'])."\"  onclick=\"opendetailwindow()\" target=\"detailwindow\">".$thumb."</a>" $thumb,
    
"comment_image_name_openwindow" => ($view_image) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$row['image_id'])."\"  onclick=\"opendetailwindow()\" target=\"detailwindow\">".stripslashes($row['image_name'])."</a>" stripslashes($row['image_name']),
    
"row_bg_number" => $row_bg_number
  
));
  
$additional_field_array = array();
  if (!empty(
$additional_image_fields))
  {
    foreach (
$additional_image_fields as $key => $val)
    {
      
$additional_field_array[$key] = (!empty($row[$key])) ? format_text($row[$key], 1) : REPLACE_EMPTY;
      
$additional_field_array['lang_'.$key] = $val[0];
    }
  }
  if (!empty(
$additional_user_fields))
  {
    foreach (
$additional_user_fields as $key => $val)
    {
      
$additional_field_array["comment_".$key] = (!empty($row["comment_".$key])) ? format_text($row["comment_".$key], 1) : REPLACE_EMPTY;
      
$additional_field_array["image_user_".$key] = (!empty($row["image_user_".$key])) ? format_text($row["image_user_".$key], 1) : REPLACE_EMPTY;
      
$additional_field_array['lang_user_'.$key] = $val[0];
    }
  }
  if (!empty(
$additional_field_array))
  {
    
$site_template->register_vars($additional_field_array);
  }
  
$last_comments .= $site_template->parse_template("last_comment_bit");
}
/*
if (empty($last_comments))
{
  $last_comments = $lang['no_comments'];
}
*/
$site_template->register_vars(array(
  
"lang_last_comments" => $lang['last_comments'],
  
"last_comments" => $last_comments
));
/*
  MOD LAST COMMENTS
  START INSERT
*/
(edit settings on top of the inserted code)


Step 2
Open lang/<your language>/main.php
At the end, above closing ?> insert:$lang['last_comments'] = "Last comments";
$lang['last_comments_more'] = "More comments";



Step 3
Open templates/<your template>/home.html
Insert in the place where you want to show last comments:
Code: (template) [Select]
{if last_comments}
                  <table width="450" border="0" cellspacing="0" cellpadding="1">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="3">
                          <tr>
                            <td class="head1" valign="top" colspan="5">{lang_last_comments}</td>
                          </tr>
                          {last_comments}
                        </table>
                      </td>
                    </tr>
                  </table>
                  <br />
{endif last_comments}
(this is just an example based on default template)


Step 4
Create a new template templates/<your template>/last_comment_bit.html with the folowing code:
Code: (template) [Select]
              <TR class="row{row_bg_number}">
                <TD width="50" height="50" align="center" rowspan="2">
                  {comment_image}
                </TD>
                <TD rowspan="2" >{comment_image_name}</TD>
                <TD rowspan="2" >[{image_cat_name}]</TD>
                 <td rowspan="2" nowrap>
                  By: {comment_user_name}{if comment_guest} ({comment_guest}){endif comment_guest}<br />
                  {comment_date}
                </td>
               <TD>{comment_headline}</TD>
              </tr>
              <tr class="row{row_bg_number}">
                <TD>{comment_text}</TD>
              </TR>
(this is just an example based on default template)



----------- [ Customization ] ------------

The following new tags are avalable to use in templates/<your template>/home.html template:

{lang_last_comments} - text "Last comments"
{last_comments} - list of last comments
{last_comments_more} - link "More comments" (required Part 2)


The following tags are avalable to use in templates/<your template>/last_comment_bit.html template:

{comment_image} - thumbnail of the image
{comment_guest} - text "Guest" if comment by a guest with entered name
{comment_image_name} - name of the image
{image_cat_name} - name of the category where the image is
{image_user_name} - username of the image
{comment_user_name} - username who posted the comment
{comment_user_id} - userid who posted the comment
{comment_headline} - headline of the comment
{comment_text} - the comment text
{comment_date} - the date when comment was posted
{row_bg_number} - number 1 or 2, needed for comment class style

New since v1.1.0:

{comment_user_url} - address to user profile for comment user
{image_user_url} - address to user profile for image user
{image_user_id} - image user ID
{lang_additionalImageFieldName} - text for additional image field
{additionalImageFieldName} - text for additional image field
{lang_user_additionalUserFieldName} - text for additional user field
{comment_additionalUserFieldName} - additional user field for comment user
{image_user_additionaUserFieldName} - additional user field for image user

New since v1.2.0:

{comment_image_openwindow} - thumbnail of the image with a link opens in new window
{comment_image_name_openwindow} - name of the image with a link opens in new window.
« Last Edit: April 19, 2009, 10:12:18 PM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Last comments v1 Part 2
« Reply #1 on: May 09, 2005, 07:39:43 AM »
-------- [ Part 2 ] --------
[MOD] All Comments (Alle Kommentare)
« Last Edit: August 28, 2010, 10:25:17 PM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline artpics

  • Full Member
  • ***
  • Posts: 173
    • View Profile
    • my site
Re: [MOD] Last comments v1
« Reply #2 on: May 09, 2005, 09:47:12 AM »
 :D :D brilliant that looks so good ,10 out of 10  v@no

thanks sooooooo much   :D


Offline martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
Re: [MOD] Last comments v1
« Reply #3 on: May 09, 2005, 05:10:30 PM »
very nice!

I'm eagerly waiting for part two  :)



MAяTRIX


Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: [MOD] Last comments v1
« Reply #4 on: May 09, 2005, 05:16:32 PM »
Me too,waiting for the part two :)

Offline waleed

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: [MOD] Last comments v1
« Reply #5 on: May 09, 2005, 06:33:16 PM »
Quote
very nice!

I'm eagerly waiting for part two   :)

waiting waiting waiting :)

Offline universal

  • Full Member
  • ***
  • Posts: 213
    • View Profile
    • http://www.funny.lt
Re: [MOD] Last comments v1
« Reply #6 on: May 10, 2005, 01:21:01 PM »
{last_comments}
</tr> this you can delete :)

btw greate mod ;) waiting for part 2 :)
Again this addres?!
http://www.funny.lt

Offline universal

  • Full Member
  • ***
  • Posts: 213
    • View Profile
    • http://www.funny.lt
Re: [MOD] Last comments v1
« Reply #7 on: May 10, 2005, 03:09:57 PM »
V@no,
Maybe possible to ask you, to show how to do some modifications?
If we put a admin links in these comments? :)
Again this addres?!
http://www.funny.lt

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Last comments v1
« Reply #8 on: May 10, 2005, 03:16:42 PM »
that will be avalable in part 2
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline b.o.fan

  • Sr. Member
  • ****
  • Posts: 314
    • View Profile
    • http://www.wartenaufden15.de
Re: [MOD] Last comments v1
« Reply #9 on: May 11, 2005, 05:53:41 PM »
i´m waiting for Part II too.

:)


b.o.fan
www.wartenaufden15.de
i m using 1.78

Offline fotograf74

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: [MOD] Last comments v1
« Reply #10 on: June 15, 2005, 04:50:40 PM »
When you publish PART 2?
I want to integrate the Last Comments in a phpbb Forum.

Offline xerraire

  • Pre-Newbie
  • Posts: 5
    • View Profile
    • http://www.xerraire.com
Re: [MOD] Last comments v1
« Reply #11 on: June 15, 2005, 08:25:31 PM »
Hi
Where can I see a working demo of this mod?

:)
Barb

"Xerraire"
http://www.xerraire.com
Xerraire
Personal Site: http://www.xerraire.com
Photo Sharing Site: http://www.uniqueexposures.com/gallery

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [MOD] Last comments v1
« Reply #12 on: June 15, 2005, 08:30:05 PM »
Hi
Where can I see a working demo of this mod?

:)
Barb

"Xerraire"
http://www.xerraire.com

On my Page ;)
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline offroad4fun

  • Pre-Newbie
  • Posts: 5
    • View Profile
    • http://www.offroad4fun.at
Re: [MOD] Last comments v1
« Reply #13 on: June 16, 2005, 10:07:55 AM »
very cool mod!!!!:!: :!:  thx a lot!!  :wink:

you can see it here:  http://fotos.offroad4fun.at  :wink:

greets from vienna
----------------------------------
www.offroad4fun.at

Offline Deven316

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: [MOD] Last comments v1
« Reply #14 on: June 19, 2005, 07:11:47 AM »
Quick question...

If i installed this mod, could I show the latest comments on a non-4image gallery page such as the main page of my website which is in PHP?