4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Rembrandt on December 01, 2009, 06:57:23 PM

Title: [MOD] Top Member with the most Comments
Post by: Rembrandt on December 01, 2009, 06:57:23 PM
Hi!

Mit dieser Modifikation werden die User mit den meisten Kommentaren angezeigt.
Angezeigt werden: Rang, - Username, - anzahl Kommentare, - das Datum des letzten eintrages, - bei welchen Bild, - und wann war der User zuletzt Online.

Demo: Demo (http://www.demo.vienna-pictures.com/top_member.php)

Neue Dateien:
top_member.php
top_member.html


1.) erstellt einen neue datei "top_member.php" und kopiert sie in euren 4images root. //creates a new file "top_member.php" and copy it into your root 4images

<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: top_member.php                                              *
 *        Copyright: (C) 2002-2009 Jan Sorgalla                           *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.7                                                *
 *     File Version: 1.0.0 (by Rembrandt www.vienna-pictures.com)         *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/

$main_template = 'top_member';

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');

 $cache_id = create_cache_id(
  'page.top_member',
  array(
    $user_info[$user_table_fields['user_id']],
    $cat_id,
    $config['template_dir'],
    $config['language_dir']
  )
);

if (!$cache_page_top || !$content = get_cache_file($cache_id)) {
if ($cache_page_top) {
  // Always append session id if cache is enabled
  $old_session_mode = $site_sess->mode;
  $site_sess->mode = 'get';
}

ob_start();

$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");

$sql = "SELECT MAX(comment_id) AS anzahl ,user_name,image_id,comment_date
FROM ".COMMENTS_TABLE."
GROUP BY user_name
ORDER BY anzahl ASC";    
$result = $site_db->query($sql);
while ($image_row = $site_db->fetch_array($result)){
    $image_test[]= $image_row['anzahl'];
   }

 $sql = "SELECT o.comment_id ,o.user_name, o.image_id, o.comment_date,o.comment_headline, u.user_comments,u.user_id, u.user_name,u.user_lastaction,i.image_id,i.cat_id,i.image_name
            FROM (".COMMENTS_TABLE." o,".USERS_TABLE." u,".IMAGES_TABLE." i)
            WHERE comment_id IN (".implode(", ",$image_test).") AND o.user_name = u.user_name AND i.image_id = o.image_id AND i.image_active = 1
            ORDER BY user_comments DESC
            LIMIT 100
            ";

$result = $site_db->query($sql);

 $comments = "<table style=\"width:".$config['image_table_width'].";\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"0\"summary=\"comments\">";
  $comments .= "<tr class=\"imagerow2\">\n";
$comments .= "<td  class=\"head1\"style=\"width:5%;text-align:center; \"><b>".$lang['top_comments_ranking']."</b></td>\n";
$comments .= "<td  class=\"head1\"style=\"width:20%;text-align:center; \"><b>".$lang['top_comments_user']."</b></td>\n";
$comments .= "<td  class=\"head1\"style=\"width:8%;text-align:center; \"><b>".$lang['top_comments_comments']."</b></td>\n";
$comments .= "<td  class=\"head1\"style=\"width:15%;text-align:center; \"><b>".$lang['top_comments_date']."</b></td>\n";
$comments .= "<td  class=\"head1\"style=\"width:28%;text-align:center; \"><b>".$lang['top_comments_images']."</b></td>\n";
$comments .= "<td  class=\"head1\"style=\"width:15%;text-align:center; \"><b>".$lang['top_comments_lastaction']."</b></td>\n";
$comments .= "</tr>\n";

$count = 0;
  $bgcounter = 0;
$rank = 1;
  while ($row = $site_db->fetch_array($result)){
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$comments .= "<tr class=\"imagerow".$row_bg_number."\">\n";
  
  $comments .= "<td  style=\"width:5%;text-align:center; \">".$rank++."</td>\n";
if (isset($row[$user_table_fields['user_name']]) && $row['user_id'] != GUEST) {
$user_profile_link = (!empty($url_show_profile)) ? preg_replace("/{user_id}/", $row['user_id'], $url_show_profile) : ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$row['user_id'];
  $comments .= "<td  style=\"width:20%;text-align:center; \"><a href=\"".$site_sess->url($user_profile_link)."\">".format_text($row[$user_table_fields['user_name']])."</a></td>\n";
}
else {
 $comments .= "<td  style=\"width:20%;text-align:center; \">".$lang['userlevel_guest']."</td>\n";
}
 $comments .= "<td  style=\"width:8%;text-align:center; \">".format_text($row[$user_table_fields['user_comments']])."</td>\n";
 $comments .= "<td  style=\"width:15%;text-align:center; \">".date("d-m-Y H:i",$row['comment_date'])."</td>\n";
  $comments .= (in_array($row['cat_id'], explode(",", $cat_id_sql)) != $row['cat_id']) ? "<td style=\"width:28%;text-align:center; \"><a href=".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$row['image_id']).">" .format_text($row['image_name'], 2)."</a></td>\n" : "<td style=\"width:28%;text-align:center; \">".format_text($row['image_name'], 2)."</td>\n";
  $comments .= "<td  style=\"width:15%;text-align:center; \">".date("d-m-Y H:i",$row['user_lastaction'])."</td>\n";

$count++;
    if ($count == $comments_num) {
      $comments .= "</tr>\n";
      $count = 0;
    }

  } // end while

  if ($count > 0)  {
    $leftover = ($comments_num - $count);
    if ($leftover >= 1) {
      for ($f = 0; $f < $leftover; $f++) {
        $comments .= "<td style=\"width:".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      $comments .= "</tr>\n";
    }
  }
  $comments .= "</table>\n";

$site_template->register_vars("comments_rank", $comments);
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'];
if ($cat_id && isset($cat_cache[$cat_id])) {
  $clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
}
$clickstream .= $lang['top_comments']."</span>";

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream,
"lang_top_comments" => $lang['top_comments'],
"lang_comments_member" => $lang['top_comments_member'],
"lang_comments_ranking" => $lang['top_comments_ranking'],
"lang_comments_user"  =>$lang['top_comments_user'],
"lang_comments_comments" => $lang['top_comments_comments'],
"lang_comments_date" => $lang['top_comments_date'],
"lang_comments_images" => $lang['top_comments_images'],
"lang_comments_lastaction" => $lang['top_comments_lastaction'],
));
$site_template->print_template($site_template->parse_template($main_template));

$content = ob_get_contents();
ob_end_clean();

if ($cache_page_top) {
  // Reset session mode
  $site_sess->mode = $old_session_mode;

  save_cache_file($cache_id, $content);
}

} // end if get_cache_file()

echo $content;

include(ROOT_PATH.'includes/page_footer.php');
?>



2.) erstellt eine neue datei "top_member.html" und kopiert sie in euer templates verzeichniss. //creates a new file "top_member.html" and copy it into your template directories.
Code: [Select]
{header}
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tablehead">
        <tr>
          <td width="100%" colspan="4"><table cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td width="6"><img src="{template_url}/images/header_top_left.gif" width="6" height="6" alt="" /></td>
        <td width="100%"><img src="{template_url}/images/header_top.gif" width="100%" height="6" alt="" /></td>
<td width="6"><img src="{template_url}/images/header_top_right.gif" width="6" height="6" alt="" /></td>
    </tr>
</table>
</td>
        </tr>
        <tr>
          <td width="6"><img src="{template_url}/images/header_left.gif" width="6" height="60" alt="" /></td>
          <td width="100%"><img src="{template_url}/images/header_logo.gif" width="405" height="60" alt="" /></td>
          <td width="225" align="right">
            <form method="post" action="{url_search}">
              <table border="0" cellspacing="0" cellpadding="1">
                <tr>
                  <td>
                    <input type="text" name="search_keywords" size="15" class="searchinput" />
                  </td>
                  <td>
                    <input type="submit" value="{lang_search}" class="button" name="submit" />
                  </td>
                </tr>
                <tr valign="top">
                  <td colspan="2"><a href="{url_search}" class="smalltext">{lang_advanced_search}</a></td>
                </tr>
              </table>
            </form>
          </td>
          <td align="right" width="6"><img src="{template_url}/images/header_right.gif" width="6" height="60" alt="" /></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td class="bordercolor">
      <table width="100%" border="0" cellspacing="1" cellpadding="0">
        <tr>
          <td class="tablebgcolor">
            <table width="100%" border="0" cellspacing="1" cellpadding="0">
              <tr>
                <td class="navbar" height="23">
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td><img src="{template_url}/images/spacer.gif" width="4" height="4" alt="" />{clickstream}</td>
                      <td align="right">
<a href="{url_top_comments}"><b>{lang_top_comments}</b></a>&nbsp;
<a href="{url_top_images}"><b>{lang_top_images}</b></a>&nbsp;
<a href="{url_new_images}"><b>{lang_new_images}</b></a>&nbsp;
 </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="150" class="row2" valign="top">
                  <table width="150" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="head2" height="20"><img src="{template_url}/images/spacer.gif" alt="" width="4" height="4" />{lang_registered_user}</td>
                    </tr>
                    <tr>
                      <td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>
                    <tr>
                      <td align="center" class="row1">{user_box}</td>
                    </tr>
                    <tr>
                      <td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>
                  </table>
                  {if random_image}
                  <table width="150" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="head2" height="20"> <img src="{template_url}/images/spacer.gif" alt="" width="4" height="4" />{lang_random_image}</td>
                    </tr>
                    <tr>
                      <td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>
                    <tr>
                      <td align="center" class="row1">
   <br />
                        {random_image}
<br />
                        <br />
                      </td>
                    </tr>
                    <tr>
                      <td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>
                  </table>
                  {endif random_image}
                </td>
                <td width="1" class="bordercolor" valign="top"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
                <td width="18" valign="top"><img src="{template_url}/images/spacer.gif" alt="" width="18" height="18" /></td>
                <td width="100%" valign="top">
 <br />
                  <span class="title">{lang_comments_member}</span>
                  <hr size="1" />
                  <table width="100%" border="0" cellspacing="0" cellpadding="1">
                    <tr>
                      <td class="bordercolor">
                        {comments_rank}
                      </td>
                    </tr>
                  </table>
                  <p>&nbsp;</p>
                </td>
                <td width="19" valign="top"><img src="{template_url}/images/spacer.gif" alt="" width="19" height="19" /></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tablebottom">
        <tr>
          <td width="6" nowrap><img src="{template_url}/images/footer_left.gif" width="6" height="19" alt="" /></td>
          <td width="100%"></td>
          <td width="6" nowrap><img src="{template_url}/images/footer_right.gif" width="6" height="19" alt="" /></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
{footer}


3.) sucht in eurer templates/home.html: //search in your templates / home.html:
Code: [Select]
<a href="{url_top_images}"><b>{lang_top_images}</b></a>&nbsp;

und fügt darüber ein: //above
Code: [Select]
<a href="{url_top_comments}"><b>{lang_top_comments}</b></a>&nbsp;

4.) sucht in lang/deutsch/main.php: //search in lang/yourLang/main.php:

//-----------------------------------------------------
//--- Comments ----------------------------------------
//-----------------------------------------------------


fügt darunter ein: //below

//#################################### Start Top Comments #################################################
$lang['top_comments'] = "Top Kommentare";
$lang['top_comments_member'] = "Mitglieder mit den meisten Kommentaren";
$lang['top_comments_ranking']= "Rang";
$lang['top_comments_user']= "Mitglied";
$lang['top_comments_comments']= "Kommentare";
$lang['top_comments_date']= "Datum";
$lang['top_comments_images']= "Bildname";
$lang['top_comments_lastaction']= "Zuletzt Online";
//#################################### End Top Comments #################################################

for english lang/english/main.php: //below

//#################################### Start Top Comments #################################################
$lang['top_comments'] = "Top Comments";
$lang['top_comments_member'] = "Member with the most Comments";
$lang['top_comments_ranking']= "Ranking";
$lang['top_comments_user']= "Member";
$lang['top_comments_comments']= "Comments";
$lang['top_comments_date']= "Date";
$lang['top_comments_images']= "Image";
$lang['top_comments_lastaction']= "Last Action";
//#################################### End Top Comments #################################################



5.) sucht in includes/page_header.php: //search in includes/page_header.php:

"url_top_images" => $site_sess->url(ROOT_PATH."top.php"),


fügt darüber ein: //above:

//#################################### Start Top Comments #################################################
"url_top_comments" => $site_sess->url(ROOT_PATH."top_member.php"),
//#################################### End Top Comments #################################################


suche: //search:

"lang_new_images" => $lang['new_images'],


füge darüber ein: //above:

//#################################### Start Top Comments #################################################
"lang_top_comments" => $lang['top_comments'],                        
//#################################### End Top Comments #################################################


In der top_member.php wurde die Anzahl der anzuzeigenden User in der zweiten SQL abfrage auf "LIMIT 100" begrenzt, die Zahl könnt ihr nach eigenen ermessen ändern.
//In top_member.php was the number of users displayed in the second SQL query to "LIMIT 100" limited the number you can change according to its own measure.

Wie immer hoffe ich das ich nicht vergessen habe. :)

Viel Spass!

mfg Andi
Title: Re: [MOD] Top Member with the most Comments
Post by: milezone on December 24, 2009, 11:39:30 PM
Do you have a english version for this script?  I am not understanding how to install.  Thanks

TDL
Title: Re: [MOD] Top Member with the most Comments
Post by: V@nо on December 24, 2009, 11:45:10 PM
page translator is on top of each page.
Title: Re: [MOD] Top Member with the most Comments
Post by: milezone on December 26, 2009, 01:26:15 AM
Sorry for my dumb question, but I am not sure which languagethis is.  :-(

Russ
Title: Re: [MOD] Top Member with the most Comments
Post by: V@no on December 26, 2009, 01:44:17 AM
It's german.
4images is german software ;) for your information :)
Title: Re: [MOD] Top Member with the most Comments
Post by: Rembrandt on December 26, 2009, 07:02:08 AM
Hi!
.. but I am not sure which languagethis is.  ...

so.. i have only for you the mod translated :)
translate with google, which is so easy:

darüber > above
darunter  > below
suche > search
erstellt > created

mfg Andi
Title: Re: [MOD] Top Member with the most Comments
Post by: luener on April 16, 2010, 11:00:59 AM
Danke dafür...klappt prima..!

Gruß
Ralf
Title: Re: [MOD] Top Member with the most Comments
Post by: www.katzen.ag on July 26, 2010, 02:12:04 PM
Funktioniert prima!

Nur Limit 100 ist bei der sql Abfrage nicht zu finden. Hab es so gemacht:

Code: [Select]
$sql = "SELECT o.comment_id ,o.user_name, o.image_id, o.comment_date,o.comment_headline, u.user_comments,u.user_id, u.user_name,u.user_lastaction,i.image_id,i.cat_id,i.image_name
FROM (".COMMENTS_TABLE." o,".USERS_TABLE." u,".IMAGES_TABLE." i)
WHERE comment_id IN (".implode(", ",$image_test).") AND o.user_name = u.user_name AND i.image_id = o.image_id AND i.image_active = 1
  ORDER BY user_comments DESC LIMIT 100";

Demo:

http://www.katzen.ag/top_member.php (http://www.katzen.ag/top_member.php)