SimplePortal

Customization => Custom Coding => Topic started by: worm82075 on March 03, 2010, 10:04:57 AM

Title: Displaying Message Icons On Portal
Post by: worm82075 on March 03, 2010, 10:04:57 AM
While I wait patiently for support I thought I might trouble you good folks further for some custom coding.
I've been using SimplePortal since it's inception. Originally it displayed message icons instead of sp specific post and topic icons. I use approximately 20 different custom icons to elude to the nature of topics and the posts within. I really need my message icons back on the portal. If anyone can point me in the right direction it would be much appreciated.
Title: Re: Displaying Message Icons On Portal
Post by: AngelinaBelle on March 03, 2010, 10:12:56 AM
Allude?
Where are you talking about displaying message icons on the portal?
In the Articles that are displayed between the top and bottom blocks?
In a "Recent Posts/Topics" block? or in an "Articles" block?
 
 
Title: Re: Displaying Message Icons On Portal
Post by: worm82075 on March 03, 2010, 10:50:34 AM
Yes, allude. Sorry for my poor grammar.

I would like them to display in the recent posts and topics blocks.
Title: Re: Displaying Message Icons On Portal
Post by: AngelinaBelle on March 03, 2010, 11:17:47 AM
I think this can be adresssed in custom coding, in the same way that the articles block allows you to choose between category icon, poster avatar, or none.
 
This is actually not so difficult.
Do you know how to get started on this?
Title: Re: Displaying Message Icons On Portal
Post by: worm82075 on March 03, 2010, 11:36:34 AM
Custom coding? As in custom PHP blocks? if so then no I haven't a clue. I'm pretty proficient at altering code under direction but writing it from scratch is a whole other ballgame.

If you are indeed referring to custom php blocks I could probably piece it together given time and research but that will have to wait as my site is currently without any admin controls for sp.
Title: Re: Displaying Message Icons On Portal
Post by: AngelinaBelle on March 03, 2010, 12:47:37 PM
OK.  I've recently done some custom coding in the Articles block, so this is fresh in my mind, so I think I can help. 
 
I'm pretty sure it is not that complicated.  I will get back to you after I check to make sure this is true!
 
I have other things going on today, but may have something for you to try tomorrow or Friday.
Title: Re: Displaying Message Icons On Portal
Post by: AngelinaBelle on March 03, 2010, 08:20:15 PM
Here's what I found out:
It is possible to have the topic icon for a recent TOPICS block, just using the existing tools.
 
To do that, I made some changes in sp_recent, in PortalBlocks.
See if you like this:
Code: [Select]
function sp_recent($parameters, $id, $return_parameters = false)
{
 global $context, $txt, $scripturl, $settings, $user_info, $color_profile;
 $block_parameters = array(
  'boards' => 'boards',
  'limit' => 'int',
  'type' => 'select',
  'display' => 'select',
  //AngelinaBelle
  'image' => 'select'
 );
 if ($return_parameters)
 {
 //AngelinaBelle
  $txt['sp_param_sp_recent_image'] = "Image:";
  $txt['sp_param_sp_recent_image_options'] = 'Standard Post/Topic|Message Icon';
  $helptxt['sp_param_sp_recent_image']= 'Display the standard Post/Topic icon, or the message icon';
 
  return $block_parameters;
 }
 $image = empty($parameters['image']) ? 0 : (int)$parameters['image'];
 $boards = !empty($parameters['boards']) ? explode('|', $parameters['boards']) : null;
 $limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;
 $type = 'ssi_recent' . (empty($parameters['type']) ? 'Posts' : 'Topics');
 $display = empty($parameters['display']) ? 'compact' : 'full';
//AngelinaBelle -- options for
 if (!empty($boards))
 {
  $temp_query_see_board = $user_info['query_see_board'];
  $user_info['query_see_board'] .= ' AND b.ID_BOARD IN (' . implode(', ', $boards) . ')';
 }
 $items = $type($limit, null, 'array');
 if (!empty($temp_query_see_board))
  $user_info['query_see_board'] = $temp_query_see_board;
 if (empty($items))
 {
  echo '
        ', $txt['error_sp_no_posts_found'];
  return;
 }
 else
  $items[count($items) - 1]['is_last'] = true;
 $colorids = array();
 foreach ($items as $item)
  $colorids[] = $item['poster']['id'];
 if (!empty($colorids) && sp_loadColors($colorids) !== false)
 {
  foreach ($items as $k => $p)
  {
   if (!empty($color_profile[$p['poster']['id']]['link']))
    $items[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
  }
 }
 if ($display == 'compact')
 {
  foreach ($items as $key => $item)
   echo '
        <a href="', $item['href'], '">', $item['subject'], '</a> <span class="smalltext">', $txt[525], ' ', $item['poster']['link'], $item['new'] ? '' : ' <a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '<br />[', $item['time'], ']</span><br />', empty($item['is_last']) ? '<hr />' : '';
 }
 elseif ($display == 'full')
 {
  echo '
        <table class="sp_fullwidth">';
  foreach ($items as $item)
  {
   //AngelinaBelle -- choose which image to use
   $item_image = (($image==0 || $parameters['type']=0 ) ? (sp_embed_image(empty($parameters['type']) ? 'post' : 'topic')) : $item['icon'] );
   echo '
         <tr>
          <td class="sp_recent_icon sp_center">
           ', $item_image, '
          </td>
          <td class="sp_recent_subject">
           <a href="', $item['href'], '">', $item['subject'], '</a>
           ', $item['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '<br />[', $item['board']['link'], ']
          </td>
          <td class="sp_recent_info sp_right">
           ', $item['poster']['link'], '<br />', $item['time'], '
          </td>
         </tr>';
  }
  echo '
        </table>';
 }
}

If you need this also for recent POSTS, then the work also requires a change to SSI.php.  I am not so experienced and bold with SMF to feel confident changing things that might be called by lots of other things, so I am a little hesitant to do it. I could do it. It would be easy...
 
Remember, please, to save a copy of your current version of PortalBlocks.php.
Then replace the function sp_recent with the one I just made. If you don't like it, you can always switch back.
Title: Re: Displaying Message Icons On Portal
Post by: Chen Zhen on March 06, 2010, 12:14:24 AM

If you need this also for recent POSTS, then the work also requires a change to SSI.php.  I am not so experienced and bold with SMF to feel confident changing things that might be called by lots of other things, so I am a little hesitant to do it. I could do it. It would be easy...
 
Remember, please, to save a copy of your current version of PortalBlocks.php.
Then replace the function sp_recent with the one I just made. If you don't like it, you can always switch back.

IMAO - When you need to use a function but want to change it, just copy the whole sub-routine into a block.
Change the name of the function and make your edits.

To execute it, simply call it.
 Sometimes a few variables need to be predefined before calling a function, but not in all cases.

ie. for the above code try this:
Code: [Select]
/*  Recent messages block with topic icons (if your theme uses them) */
/* For SMF 1.1.1x and Simple Portal 2.3.1 */

sp_recent_2($parameters, $id, $return_parameters = false);

function sp_recent_2($parameters, $id, $return_parameters = false)
{
 global $context, $txt, $scripturl, $settings, $user_info, $color_profile;
 $block_parameters = array(
  'boards' => 'boards',
  'limit' => 'int',
  'type' => 'select',
  'display' => 'select',
  'image' => 'select',
 );
 if ($return_parameters)
 {
 /* AngelinaBelle */
  $txt['sp_param_sp_recent_image'] = 'Image:';
  $txt['sp_param_sp_recent_image_options'] = 'Standard Post/Topic|Message Icon';
  $helptxt['sp_param_sp_recent_image'] = 'Display the standard Post/Topic icon, or the message icon';
 
  return $block_parameters;
 }
 $image = empty($parameters['image']) ? 0 : (int)$parameters['image'];
 $boards = !empty($parameters['boards']) ? explode('|', $parameters['boards']) : null;
 $limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;
 $type = 'ssi_recent' . (empty($parameters['type']) ? 'Posts' : 'Topics');
 $display = empty($parameters['display']) ? 'compact' : 'full';
/* AngelinaBelle -- options for */
 if (!empty($boards))
 {
  $temp_query_see_board = $user_info['query_see_board'];
  $user_info['query_see_board'] .= ' AND b.ID_BOARD IN (' . implode(', ', $boards) . ')';
 }
 $items = $type($limit, null, 'array');
 if (!empty($temp_query_see_board))
  $user_info['query_see_board'] = $temp_query_see_board;
 if (empty($items))
 {
  echo '
        ', $txt['error_sp_no_posts_found'];
  return;
 }
 else
  $items[count($items) - 1]['is_last'] = true;
 $colorids = array();
 foreach ($items as $item)
  $colorids[] = $item['poster']['id'];
 if (!empty($colorids) && sp_loadColors($colorids) !== false)
 {
  foreach ($items as $k => $p)
  {
   if (!empty($color_profile[$p['poster']['id']]['link']))
    $items[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
  }
 }
 if ($display == 'compact')
 {
  foreach ($items as $key => $item)
   echo '
        <a href="', $item['href'], '">', $item['subject'], '</a> <span class="smalltext">', $txt[525], ' ', $item['poster']['link'], $item['new'] ? '' : ' <a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '<br />[', $item['time'], ']</span><br />', empty($item['is_last']) ? '<hr />' : '';
 }
 elseif ($display == 'full')
 {
  echo '
        <table class="sp_fullwidth">';
  foreach ($items as $item)
  {
   /* AngelinaBelle -- choose which image to use */
   $item_image = (($image==0 || $parameters['type']=0 ) ? (sp_embed_image(empty($parameters['type']) ? 'post' : 'topic')) : $item['icon'] );
   echo '
         <tr>
          <td class="sp_recent_icon sp_center">
           ', $item_image, '
          </td>
          <td class="sp_recent_subject">
           <a href="', $item['href'], '">', $item['subject'], '</a>
           ', $item['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '<br />[', $item['board']['link'], ']
          </td>
          <td class="sp_recent_info sp_right">
           ', $item['poster']['link'], '<br />', $item['time'], '
          </td>
         </tr>';
  }
  echo '
        </table>';
 }
}

worm82075:

If I understand you correctly, your custom theme has topic icons and this I assume will display them.
Currently for testing I do not have a theme that has topic icons installed on any of my SMF 1.1.1x versions, therefore I was not able to test this fully as of yet. (I tested it but all my current themes only display text for thread headers)

What theme are you using worm82075?  If I install the same theme on one of my SMF 1.1.1x test forums I can test this fully.

UD
Title: Re: Displaying Message Icons On Portal
Post by: AngelinaBelle on March 06, 2010, 02:01:11 PM
IMAO - When you need to use a function but want to change it, just copy the whole sub-routine into a block.
Change the name of the function and make your edits.

To execute it, simply call it.
Yeah -- good point. A renamed SSI function replacement won't interfere with anything calling the SSI function. Especially if I don't even put it in SSI.
 
I'm just awfully timid.
Title: Re: Displaying Message Icons On Portal
Post by: worm82075 on March 06, 2010, 08:25:20 PM
All of my themes are based off of my default so that each theme need only have it's own images and an index.template.php.

Are we talking about the same icons?  I'm talking about the smf message icons. You know;(http://simpleportal.net/Themes/default/images/post/xx.gif), (http://simpleportal.net/Themes/default/images/post/thumbup.gif), (http://simpleportal.net/Themes/default/images/post/thumbdown.gif), (http://simpleportal.net/Themes/default/images/post/exclamation.gif), etc...etc....

See the pic attached. I'd like to see my custom icons back on the portal like they were originally at SP's inception.
Title: Re: Displaying Message Icons On Portal
Post by: Chen Zhen on March 06, 2010, 09:05:13 PM
All of my themes are based off of my default so that each theme need only have it's own images and an index.template.php.

Are we talking about the same icons?  I'm talking about the smf message icons. You know;(http://simpleportal.net/Themes/default/images/post/xx.gif), (http://simpleportal.net/Themes/default/images/post/thumbup.gif), (http://simpleportal.net/Themes/default/images/post/thumbdown.gif), (http://simpleportal.net/Themes/default/images/post/exclamation.gif), etc...etc....

See the pic attached. I'd like to see my custom icons back on the portal like they were originally at SP's inception.

Some themes have icons for each board (graphic pics or graphic text - whatever).. I am going to check out your forum and run a test site with the same SMF version and theme. I see it is the topic icons you want displayed.

Angelina - When copying a whole function, renaming it and using it in the block there is nothing to be timid about since no existing files are being tampered with.   ;)
 

UD
Title: Re: Displaying Message Icons On Portal
Post by: AngelinaBelle on March 07, 2010, 08:04:49 AM
Underdog,
It never even occured to me that putting a renamed block function in a block would even work. Some parts of SimplePortal, I haven't traced through yet.
 
If you are running with this, I'll leave it.
 
worm82075
Looks like Underdog is running with the ball, now.
Title: Re: Displaying Message Icons On Portal
Post by: Chen Zhen on March 08, 2010, 11:21:50 PM
Underdog,
It never even occured to me that putting a renamed block function in a block would even work. Some parts of SimplePortal, I haven't traced through yet.
 
If you are running with this, I'll leave it.
 
worm82075
Looks like Underdog is running with the ball, now.

Gee thanks.   :0  lol.

I was just pointing out how you can copy functions and change/use them without having to edit any php files.

I will finish this up later this week when I have more time.

UD

 

Title: Re: Displaying Message Icons On Portal
Post by: AngelinaBelle on March 09, 2010, 10:24:28 AM
Oh! when you said you were testing it out on your own test forum, I figured you had written some code. Since you seem to be more experienced than me, I figured that was a good thing. I'm still around.  Just shout.
Title: Re: Displaying Message Icons On Portal
Post by: Chen Zhen on March 12, 2010, 04:47:17 PM
Try this...

Code: [Select]
/*  Recent Posts block for SMF 1.1.1x  */

global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $func, $boardurl;

/* Adjustable variables */
$paramters = array();
$numPosts = 10;
$exclude_boards = null;
$format = 'vertical';
$msg_new = '[new]';
$postby = 'Posted By:';
$intro_statement = '';
$end_statement = '';
$showColor = true;   
$default_icon = 'xx';
$numPosts = (int) $numPosts;

/*  Main code  */   
   
   // Pass all the parematers
   foreach($paramters as $myparam)
   {
      if ($myparam['parameter_name'] == 'format')
         $format =  $myparam['data'];
      if ($myparam['parameter_name'] == 'numPosts')
         $numPosts = (int) $myparam['data'];
      if ($myparam['parameter_name'] == 'showcolor')
      {
         if ($myparam['data'] == 'true')
            $showColor = true;
         else
            $showColor = false;
      }
   
   }
/* Intro Statement */   
   echo $intro_statement;

   if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
      $exclude_boards = array($modSettings['recycle_board']);
   else
      $exclude_boards = empty($exclude_boards) ? array() : $exclude_boards;

   /*  Query all the posts  */
   $request = db_query("
      SELECT
         m.posterTime, m.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, icon, m.ID_BOARD, b.name AS bName, mg.onlineColor, mg.ID_GROUP,
         IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled
      FROM ({$db_prefix}messages AS m, {$db_prefix}boards AS b)
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
          LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))
         
         " . (!$user_info['is_guest'] ? "
         LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = m.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
         LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = m.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
      WHERE m.ID_MSG >= " . ($modSettings['maxMsgID'] - 25 * min($numPosts, 5)) . "
         AND b.ID_BOARD = m.ID_BOARD" . (empty($exclude_boards) ? '' : "
         AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . "
         AND $user_info[query_see_board]
      ORDER BY m.ID_MSG DESC
      LIMIT $numPosts", __FILE__, __LINE__);
   $posts = array();
   while ($row = mysql_fetch_assoc($request))
   {
if ($row['icon'] == false)
{$row['icon'] = $default_icon;}
      $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '
')));
      if ($func['strlen']($row['body']) > 128)
         $row['body'] = $func['substr']($row['body'], 0, 128) . '...';

      /*  Censor the post info  */
      censorText($row['subject']);
      censorText($row['body']);
      /*  Feed the array with the info from the db  */
      $posts[] = array(
         'board' => array(
            'id' => $row['ID_BOARD'],
            'name' => $row['bName'],
            'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
            'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
         ),
         'topic' => $row['ID_TOPIC'],
                        'icon' => '<img src="' . $boardurl.'/Themes/default/images/post/'.$row['icon'].'.gif" alt="~" title="'.$row['subject'].'" border="0" />',
         'poster' => array(
            'id' => $row['ID_MEMBER'],
            'name' => $row['posterName'],
            'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
            'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>',
            'colorlink'  => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"><font color="' . $row['onlineColor'] . '">' . $row['posterName'] . '</font></a>',
         ),
         'subject' => $row['subject'],
         'short_subject' => shorten_subject($row['subject'], 25),
         'preview' => $row['body'],
         'time' => timeformat($row['posterTime']),
         'timestamp' => forum_time(true, $row['posterTime']),
         'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
         'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#msg' . $row['ID_MSG'] . '">' . $row['subject'] . '</a>',
         'new' => !empty($row['isRead']),
         'new_from' => $row['new_from'],
      );
   }
   mysql_free_result($request);
   
   
   if  (empty($posts))
      return;

   echo '
      <table border="0">';
   
   if ($format == 'vertical')
   {
      foreach ($posts as $post)
      {
         
         echo '
            <tr>
               <td valign="top">
                 
                  '.$post['icon'].'</td><td valign="top"><span class="smalltext"><a href="', $post['href'], '"><b>', $post['subject'], '</b></a>
                  ', $postby, ' ', ($showColor == true ? $post['poster']['colorlink'] : $post['poster']['link']), '
                  ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $msg_new . '" border="0" /></a>', '
                  <br />', $post['time'], '
                  </span>
                  <hr />
               </td>
         
            </tr>';
      }
   }
   else
   {
      foreach ($posts as $post)
         echo '
            <tr>
               <td align="right" valign="top">
                  [', $post['board']['link'], ']
               </td>
               <td valign="top">
                  <a href="', $post['href'], '">', $post['subject'], '</a>
                  ', $postby, ' ', ($showColor == true ? $post['poster']['colorlink'] : $post['poster']['link']), '
                  ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $msg_new . '" border="0" /></a>', '
               </td>
               <td align="right" nowrap="nowrap">
                  ', $post['time'], '
               </td>
            </tr>';
   }
   echo '
      </table>';
   
   
   
/* Ending Statement */
   echo $end_statement;


You can make some specific adjustments from the top of the block.

UD
Title: Re: Displaying Message Icons On Portal
Post by: Chen Zhen on March 13, 2010, 11:51:37 PM

Worm -
Does this block work the way you want?

If so.. mark the thread solved.


UD
Title: Re: Displaying Message Icons On Portal
Post by: worm82075 on March 14, 2010, 12:03:24 PM
Yes it does work well but I would also like the same functionality for recent topics. Perhaps another variable that defines posts or topics. Thanks by the way.
Title: Re: Displaying Message Icons On Portal
Post by: Chen Zhen on March 14, 2010, 10:44:43 PM
Recent Topics and Posts Block for SMF 1.1.1x

Adjustments can be set in the top of the block.

Imao - Set up the block with No Title from the style options at the bottom while editing the block.

PHP Portal Block:
Code: [Select]
/*  START - SMF 1.1.1x Recent Topics and Posts Block  */


/*             Adjustable variables        */
/* Set $numPosts or $numTopics to 0 to disable */
$paramters = array();
$numPosts = 10;
$numTopics = 10;
$exclude_boards_topics = null;
$exclude_boards_posts = null;
$format = 'vertical';
$msg_new = '[new]';
$postby = 'Posted By:';
$showColor = true;   
$default_icon = 'xx';

/* Get globals and set (int) for max */

global $context, $settings, $scripturl, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $func, $boardurl;
$numPosts = (int) $numPosts;
$numTopics = (int) $numTopics;

/*  These are for the images used in the titles below */
$posts_icon = $boardurl.'/Themes/default/images/post/xx.gif';
$topics_icon = $boardurl.'/Themes/default/images/topic/normal_post.gif';

/* These are the titles and/or ending statements */
$intro_posts = '<div class="smalltext" style="text-align: center; color: #216095;"><img src="'.$posts_icon.'" alt="" title="Recent Posts" width="16" height="16" /><strong>Recent Posts</strong></div><hr />';
$ending_posts = '<br />';
$intro_topics = '<div class="smalltext" style="text-align: center; color: #216095;"><img src="'.$topics_icon.'" alt="" title="Recent Topics" width="16" height="16" /><strong>Recent Topics</strong></div><hr />';
$ending_topics = '<br />';

/*  START - Recent Posts  */     
if ($numPosts > 0)
{   
   foreach($paramters as $myparam)
   {
      if ($myparam['parameter_name'] == 'format')
         $format =  $myparam['data'];
      if ($myparam['parameter_name'] == 'numPosts')
         $numPosts = (int) $myparam['data'];
      if ($myparam['parameter_name'] == 'showcolor')
      {
         if ($myparam['data'] == 'true')
            $showColor = true;
         else
            $showColor = false;
      }
   
   }
/* Intro Statement */   
   echo $intro_posts;

   if ($exclude_boards_posts === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
      $exclude_boards_posts = array($modSettings['recycle_board']);
   else
      $exclude_boards_posts = empty($exclude_boards_posts) ? array() : $exclude_boards_posts;
   
   $request = db_query("
      SELECT
         m.posterTime, m.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, icon, m.ID_BOARD, b.name AS bName, mg.onlineColor, mg.ID_GROUP,
         IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled
      FROM ({$db_prefix}messages AS m, {$db_prefix}boards AS b)
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
          LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))
         
         " . (!$user_info['is_guest'] ? "
         LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = m.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
         LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = m.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
      WHERE m.ID_MSG >= " . ($modSettings['maxMsgID'] - 25 * min($numPosts, 5)) . "
         AND b.ID_BOARD = m.ID_BOARD" . (empty($exclude_boards_posts) ? '' : "
         AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards_posts) . ")") . "
         AND $user_info[query_see_board]
      ORDER BY m.ID_MSG DESC
      LIMIT $numPosts", __FILE__, __LINE__);
   $posts = array();
   while ($row = mysql_fetch_assoc($request))
   {
if ($row['icon'] == false)
{$row['icon'] = $default_icon;}
      $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '
')));
      if ($func['strlen']($row['body']) > 128)
         $row['body'] = $func['substr']($row['body'], 0, 128) . '...';

      /*  Censor post subject  */
      censorText($row['subject']);
      censorText($row['body']);
     
      $posts[] = array(
         'board' => array(
            'id' => $row['ID_BOARD'],
            'name' => $row['bName'],
            'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
            'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
         ),
         'topic' => $row['ID_TOPIC'],
                        'icon' => '<img src="' . $boardurl.'/Themes/default/images/post/'.$row['icon'].'.gif" alt="~" title="'.$row['subject'].'" border="0" />',
         'poster' => array(
            'id' => $row['ID_MEMBER'],
            'name' => $row['posterName'],
            'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
            'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>',
            'colorlink'  => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"><font color="' . $row['onlineColor'] . '">' . $row['posterName'] . '</font></a>',
         ),
         'subject' => $row['subject'],
         'short_subject' => shorten_subject($row['subject'], 25),
         'preview' => $row['body'],
         'time' => timeformat($row['posterTime']),
         'timestamp' => forum_time(true, $row['posterTime']),
         'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
         'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#msg' . $row['ID_MSG'] . '">' . $row['subject'] . '</a>',
         'new' => !empty($row['isRead']),
         'new_from' => $row['new_from'],
      );
   }
   mysql_free_result($request);
   
   
   if  (empty($posts))
      return;

   echo '
      <table border="0">';
   
   if ($format == 'vertical')
   {
      foreach ($posts as $post)
      {
         
         echo '
            <tr>
               <td valign="top">
                 
                  '.$post['icon'].'</td><td valign="top"><span class="smalltext"><a href="', $post['href'], '"><b>', $post['subject'], '</b></a>
                  ', $postby, ' ', ($showColor == true ? $post['poster']['colorlink'] : $post['poster']['link']), '
                  ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $msg_new . '" border="0" /></a>', '
                  <br />', $post['time'], '
                  </span>
                  <hr />
               </td>
         
            </tr>';
      }
   }
   else
   {
      foreach ($posts as $post)
         echo '
            <tr>
               <td align="right" valign="top">
                  [', $post['board']['link'], ']
               </td>
               <td valign="top">
                  <a href="', $post['href'], '">', $post['subject'], '</a>
                  ', $postby, ' ', ($showColor == true ? $post['poster']['colorlink'] : $post['poster']['link']), '
                  ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $msg_new . '" border="0" /></a>', '
               </td>
               <td align="right" nowrap="nowrap">
                  ', $post['time'], '
               </td>
            </tr>';
   }
   echo '
      </table>';   
   
/* Ending Statement */
   echo $ending_posts;
}
/*  END - Recent Posts  */

/*  START - Recent Topics  */   
if ($numTopics > 0)
{   
   foreach($paramters as $myparam)
   {
      if ($myparam['parameter_name'] == 'format')
         $format =  $myparam['data'];
      if ($myparam['parameter_name'] == 'numTopics')
         $numTopics = (int) $myparam['data'];
      if ($myparam['parameter_name'] == 'showcolor')
      {
         if ($myparam['data'] == 'true')
            $showColor = true;
         else
            $showColor = false;
      }
     
   }
   
   echo $intro_topics;


   if ($exclude_boards_topics === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
      $exclude_boards_topics = array($modSettings['recycle_board']);
   else
      $exclude_boards_topics = empty($exclude_boards_topics) ? array() : $exclude_boards_topics;

   $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
   $icon_sources = array();
   foreach ($stable_icons as $icon)
      $icon_sources[$icon] = 'images_url';
   
   $request = db_query("
      SELECT
         m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName, mg.onlineColor, mg.ID_GROUP,
         IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
      FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
         LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))
         " . (!$user_info['is_guest'] ? "
         LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
         LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
      WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($numTopics, 5)) . "
         AND t.ID_LAST_MSG = m.ID_MSG
         AND b.ID_BOARD = t.ID_BOARD" . (empty($exclude_boards_topics) ? '' : "
         AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards_topics) . ")") . "
         AND $user_info[query_see_board]
         AND ms.ID_MSG = t.ID_FIRST_MSG
      ORDER BY t.ID_LAST_MSG DESC
      LIMIT $numTopics", __FILE__, __LINE__);
   $posts = array();
   while ($row = mysql_fetch_assoc($request))
   {
if ($row['icon'] == false)
{$row['icon'] = $default_icon;}
      $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '
')));
      if ($func['strlen']($row['body']) > 128)
         $row['body'] = $func['substr']($row['body'], 0, 128) . '...';

      /* Censor the subject */
      censorText($row['subject']);
      censorText($row['body']);

      if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
         $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';
     
      $posts[] = array(
         'board' => array(
            'id' => $row['ID_BOARD'],
            'name' => $row['bName'],
            'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
            'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
         ),
         'topic' => $row['ID_TOPIC'],
         'poster' => array(
            'id' => $row['ID_MEMBER'],
            'name' => $row['posterName'],
            'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
            'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>',
            'colorlink'  => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"><font color="' . $row['onlineColor'] . '">' . $row['posterName'] . '</font></a>',
         ),
         'subject' => $row['subject'],
         'short_subject' => shorten_subject($row['subject'], 25),
         'preview' => $row['body'],
         'time' => timeformat($row['posterTime']),
         'timestamp' => forum_time(true, $row['posterTime']),
         'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
         'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
         'new' => !empty($row['isRead']),
         'new_from' => $row['new_from'],
         'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="~" title ="'.$row['subject'].'" border="0" />',
      );
   }
   mysql_free_result($request);
   
   if  (empty($posts))
      return;

   echo '
      <table border="0">';
   
   if ($format == 'vertical')
   {
      foreach ($posts as $post)
      {     
         echo '
            <tr>
               <td valign="top">
                 
                  '.$post['icon'].'</td><td valign="top"><span class="smalltext"><a href="', $post['href'], '"><b>', $post['subject'], '</b></a>
                  ', $postby, ' ', ($showColor == true ? $post['poster']['colorlink'] : $post['poster']['link']), '
                  ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $msg_new . '" border="0" /></a>', '
                  <br />', $post['time'], '
                  </span>
                  <hr />
               </td>
         
            </tr>';
      }
   }
   else
   {
      foreach ($posts as $post)
         echo '
            <tr>
               <td align="right" valign="top">
                  [', $post['board']['link'], ']
               </td>
               <td valign="top">
                  <a href="', $post['href'], '">', $post['subject'], '</a>
                  ', $postby, ' ', ($showColor == true ? $post['poster']['colorlink'] : $post['poster']['link']), '
                  ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $msg_new . '" border="0" /></a>', '
               </td>
               <td align="right" nowrap="nowrap">
                  ', $post['time'], '
               </td>
            </tr>';
   }
   echo '
      </table>';   
   
   echo $ending_topics;
}
/*  END - Recent Topics  */

/*  END - SMF 1.1.1x Recent Topics and Posts Block  */

<<<<<<<<<<>>>>>>>>>>

If you want the Topics to also display the most recent posts icon in that topic...

In the above code, Find:
Code: [Select]
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon

Replace with:
Code: [Select]
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, ms.icon


UD
Title: Re: Displaying Message Icons On Portal
Post by: MultiformeIngegno on March 15, 2010, 05:47:59 AM
A chance of having this for rc3....? :)
SimplePortal 2.3.8 © 2008-2024, SimplePortal