SimplePortal

Customization => Blocks and Modifications => Topic started by: AngelinaBelle on March 02, 2010, 04:48:46 PM

Title: Customized Article Block
Post by: AngelinaBelle on March 02, 2010, 04:48:46 PM
This is a replacement for sp_articles.
It reproduces some of the functionality of Recent Posts Board News, but is based on Article Categories instead of Boards. The block "template" is different from the Recent Posts Board News "template", and can be customized with CSS.
 
In general, Recent Posts Board News may be preferable, because it is easier on the users. And easier for the admin to maintain through SimplePortal upgrades.
 
Behavior of existing article blocks will be unaffected.
I have just replaced the code I posted here earlier with an improved version, and have included a version for SMF 2.0
I have provided two versions of this function
* SMF 1.1.11 version
* SMF 2.0 RC3 version
Both of these have been tested against the upcoming SimplePortal 2.3.2 release (currently undergoing debug testing)
 
This mod adds the following features:     
 
       Within the new "articles with message body" display, I have used 4 new CSS classes
                    You may add some CSS to style.js for theme-specific style effects.  Below is a CSS sample.

I have used Simple Portal Image resizing on [img] in the message body.
I have attempted to control the size of any embedded objects ([pdf], AEVA) with CSS. This is more or less successful, and requires a CSS file, portal_resize.css in Themes/default. The php files are attached. The CSS is below.

Code: (CSS for the message bodies) [Select]
.sp_articles_withbody_title
{
/* more or less like h2 */
   font-size: 150%;
   align: center;
}
.sp_articles_author
{
   font-size: smaller;
   font-variant: small-caps;
   align: center;
}
.sp_articles_body, .sp_articles_more
{
}

Code: [Select]
/* 
.sp_articles_body img
{
   max-height: 100px;
   width: auto;
}
html .sp_articles_body img
{
   width: expression( document.body.clientWidth > 99 ? "100px" : "auto" ); /* sets max-width for IE<8 */
}   
*/

.sp_articles_body embed, .sp_articles_body object
{
   max-height: 200px;
   max-width: 200px;
}
html .sp_articles_body embed, html .sp_articles_body object
{
   width: expression( document.body.clientWidth > 199 ? "200px" : "auto" ); /* sets max-width for IE<8 */
}
html .sp_articles_body embed, html .sp_articles_body object
{
   height: expression( this.scrollHeight > 199 ? "200px" : "auto" ); /* sets max-height for IE<8 */
}
.sp_articles_body table.maeva, #saeva1
{
   max-height: 200px;
   max-width: 200px;
}
html .sp_articles_body table.maeva, html #saeva1
{
   width: expression( document.body.clientWidth > 199 ? "200px" : "auto" ); /* sets max-width for IE<8 */
}
html .sp_articles_body table.maeva, html #saeva1
{   
   height: expression( this.scrollHeight > 199 ? "200px" : "auto" ); /* sets max-height for IE<8 */
}
-------------------
Improvements to the SMF2.0 version now have it passing HTML validation.
Title: Re: Customized Article Block
Post by: AngelinaBelle on March 18, 2010, 04:50:46 PM
Improved code for customized article block
Title: Re: Customized Article Block
Post by: ataru on March 20, 2010, 12:15:31 PM
will it show an abstract in articles block?
Title: Re: Customized Article Block
Post by: AngelinaBelle on March 21, 2010, 09:05:25 AM
There is no abstract.  The article block shows SimplePortal articles, which are simply "new topic" posts that have been added to the Articles list.
 
You have two options for showing a shortened version of the article.
1) If you use the  tag to show how much of the article to show
2) If you use the truncate parameter of this block, all articles without the  tag will be truncated to no more than the number of characters you specify. If you leave truncate blank, you will get no truncation.
Title: Re: Customized Article Block
Post by: ataru on March 21, 2010, 06:08:51 PM
I meant a truncated part of the article as an abstract... ok that's good.

but i didn't understand how to install it.

where do I have to put that code?

Itried to replace sp_articles function in PortalBlocks.php, and added CSS code to Portal.css in the default theme directory, but it doesn't work. got a title and a blank page
Title: Re: Customized Article Block
Post by: ataru on March 21, 2010, 06:26:55 PM
I'm using sp 2.3.1 on a SMF 2.0 RC3
Title: Re: Customized Article Block
Post by: AngelinaBelle on March 21, 2010, 08:22:44 PM
I am sorry I did not state that the posted version of sp_articles is only for SMF 1.1.x.
I have updated my original post to contain this important information.
 
There are a small number of changes required for SMF 2.0, but they make a big difference.
 
Do you still have a copy of your old PortalBlocks, SimplePortal 2.3.1 for SMF 2.0RC3?
 
I would like to test the the version of sp_articles for SMF 2.0RC3, and will post it when I am certain of it.
 
I am sorry my original posting led you astray. I will post to this topic again when the SMF 2.0 version is ready.
 
 
Title: Re: Customized Article Block
Post by: ataru on March 21, 2010, 08:32:25 PM
no problem, really... i've got a test site where to try any new mod.

I'd really like to have that mod working in SMF2.0, I use articles to show news in sportal, and now I'm using board news block for it, but it's not so good as your modded articles block.


but my php's not so good :)
Title: Re: Customized Article Block
Post by: ataru on March 22, 2010, 11:23:37 AM
I made something:

Code: [Select]
function sp_articles($parameters, $id, $return_parameters = false)

{

global $smcFunc, $modSettings, $scripturl, $txt, $color_profile;



$block_parameters = array(

'limit' => 'int',

'type' => 'select',

'image' => 'select',

// AngelinaBelle Display message or header only, and truncate message to an integer value         
         'displaymessage' => 'select',

         'truncate' => 'int'

         );
           

     
//AngelinaBelle -- options for displaymessage
   $display_Subject='Solo titolo';
   $display_Message='Titolo e testo dell\'articolo';     
   if ($return_parameters)   
   {     
         
// AngelinaBelle: displaymessage _options are usually set in language/SPortal.<language>.php, while the message is set in the SPortalAdmin language file.
      $txt['sp_param_sp_articles_displaymessage'] = 'Mostra titolo o testo dell\'articolo';
      $helptxt['sp_param_sp_articles_displaymessage'] = 'Mostra solo il titolo (default) o anche il testo del messaggio';
      $txt['sp_param_sp_articles_displaymessage_options'] = $display_Subject . '|' . $display_Message;
     
//AngelinaBelle -- options for truncate
      $txt['sp_param_sp_articles_truncate'] = 'Taglia l\'articolo';
      $helptxt['sp_param_sp_articles_truncate'] = 'Se è stato scelto di mostrare il tersto dell\'articolo, indica il numero di caratteri da visualizzare prima che l\'articolo tagliato';
     
      return $block_parameters;
   }

$limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];

$type = empty($parameters['type']) ? 0 : 1;

$image = empty($parameters['image']) ? 0 : (int) $parameters['image'];

//AngelinaBelle   
   $displaymessage = ( empty($parameters['displaymessage']) ? False : ( ($parameters['displaymessage'] == 1) ? True : False ) );


$request = $smcFunc['db_query']('','

SELECT

m.id_topic, m.subject, m.poster_name, m.body, m.poster_time, c.picture, c.name,

mem.id_member, mem.real_name, mem.avatar,

at.id_attach, at.attachment_type, at.filename

FROM {db_prefix}sp_articles AS a

INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)

INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)

INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)

LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)

LEFT JOIN {db_prefix}attachments AS at ON (at.id_member = mem.id_member)

WHERE {query_see_board}

AND a.approved = {int:approved}

ORDER BY {raw:type}

LIMIT {int:limit}',

array(

'approved' => 1,

'type' => $type ? 'RAND()' : 'm.poster_time DESC',

'limit' => $limit,

)

);

$articles = array();

$colorids = array();

while ($row = $smcFunc['db_fetch_assoc']($request))

{

if (!empty($row['id_member']))

$colorids[$row['id_member']] = $row['id_member'];



if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')

{

$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';

$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';

}

else

{

$avatar_width = '';

$avatar_height = '';

}



$articles[] = array(

'id' => $row['id_topic'],

'name' => $row['subject'],

'body' => $row['body'],

'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',

'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>',

'read_more' => ' (<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">...</a>)',

'poster' => array(

'id' => $row['id_member'],

'name' => $row['real_name'],

'href' => $scripturl . '?action=profile;u=' . $row['id_member'],

'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',

),

'image' => array(

'href' => $row['picture'],

'image' => '<img src="' . $row['picture'] . '" alt="' . $row['name'] . '" />',

),

'avatar' => array(

'name' => $row['avatar'],

'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),

'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),

'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])

),

);

}

$smcFunc['db_free_result']($request);



if (empty($articles))

{

echo '

', $txt['error_sp_no_articles_found'];

return;

}



if (!empty($colorids) && sp_loadColors($colorids) !== false)

{

foreach ($articles as $k => $p)

{

if (!empty($color_profile[$p['poster']['id']]['link']))

$articles[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];

}

}



if (empty($image))

{

echo '

<ul class="sp_list">';



foreach ($articles as $article)

{

echo '

<li>', sp_embed_image('topic'), ' ', $article['link'];


if ( $displaymessage )

{

echo '

<br>';

$nobbcode = str_replace("[img]","<",str_replace("[/img]",">",$article['body']));

$nobbcode = strip_tags(str_replace("[", "<", str_replace("]", ">", $nobbcode)));

if(strlen($nobbcode)>$parameters['truncate'])
{
$cut_string=substr($nobbcode, 0,$parameters['truncate']);
$last_space=strrpos($cut_string," ");
$def_string=substr($cut_string, 0,$last_space);
echo $def_string . $article['read_more'];
}else{
echo $nobbcode;
}

}

echo '

</li>';

}


echo '

</ul>';

}

else

{

echo '

<table class="sp_fullwidth sp_articles">';



foreach ($articles as $article)

{

echo '

<tr>

<td class="sp_sp_articles sp_center">';



if (!empty($article['avatar']['href']) && $image == 1)

echo '<img src="', $article['avatar']['href'], '" alt="', $article['poster']['name'], '" width="40" />';

elseif (!empty($article['image']['href']) && $image == 2)

echo '<img src="', $article['image']['href'], '" alt="', $article['name'], '" width="40" />';



echo '</td>

<td>

', $article['link'];

if ( $displaymessage )

{

echo '

<br>';

$nobbcode = str_replace("[img]","<",str_replace("[/img]",">",$article['body']));

$nobbcode = strip_tags(str_replace("[", "<", str_replace("]", ">", $nobbcode)));

if(strlen($nobbcode)>$parameters['truncate'])
{
$cut_string=substr($nobbcode, 0,$parameters['truncate']);
$last_space=strrpos($cut_string," ");
$def_string=substr($cut_string, 0,$last_space);
echo $def_string . $article['read_more'];
}else{
echo $nobbcode;
}

}

echo '

</td>

</tr>';

}



echo '

</table>';

}

}

it seems to work in SMF 2.0 RC3 and SP 2.3.1

it has no integration in aeva and no categories options, but that's all i can do.
Title: Re: Customized Article Block
Post by: AngelinaBelle on March 22, 2010, 01:26:31 PM
The thing that makes my mod no good for SMF 2.0 is the way the sql query is written.
You can see the difference in SimplePortals versions fo sp_articles for SMF 1.x  and SMF 2.0
 
The calls to execute the query and fetch the results have changed, and the SQL query needs to be rewritten and tested.
 
I will be happy to share some code with you when I think it is 'beta test' ready. It would be no help to either of us if I give you something completely untried.
 
I'm glad you are eager for the upgrade. I will let you know soon.
 
Title: Re: Customized Article Block
Post by: ataru on March 23, 2010, 04:25:34 AM
Thanks a lot! ;D
Title: Re: Customized Article Block
Post by: AngelinaBelle on March 31, 2010, 09:34:40 AM
I have now done some testing on a version for SMF 2.0, and I think it will work.
 
My recent experience tells me it is preferable to use Recent Posts/Topics in "full" mode Board News if at all possible, because it is much easier on the content providers. You can even select a single message ID to display.
 
If you simply MUST collect stuff from a number of boards into one Article Category for Portal or page=display, this mod is for you.
 
 
 
 
Title: Re: Customized Article Block
Post by: AngelinaBelle on April 05, 2010, 01:36:36 PM
Latest update to SMf2.0RC3 version -- a couple of fixes now have it passing HTML validation.
Title: Re: Customized Article Block
Post by: jimerosoft on April 06, 2010, 01:10:25 AM
Thanks for you input.. ^^
Title: Re: Customized Article Block
Post by: AngelinaBelle on April 14, 2010, 11:30:38 AM
Update to 2.0RC3 version. Changes made to topic attachment.
Code: (find) [Select]
$txt[525]
Code: (replace) [Select]
$txt['by']

Code: (find) [Select]
( ($txt['ssi_write_comment']==='') ? Comment :
$txt['sendtopic_comment'])$txt['ssi_write_comment']
Code: (replace) [Select]
( ($txt['ssi_write_comment']==='') ? 'Comment' :
$txt['sendtopic_comment'])
Title: Re: Customized Article Block
Post by: ataru on April 16, 2010, 05:43:22 AM
can i help with my modified one? i added choice of cutting off bbcodes, author and images from block:
i also modified truncate function to cut only after a space.

ehm... it's in italian language...

Code: [Select]
function sp_articles($parameters, $id, $return_parameters = false)
{
global $smcFunc, $modSettings, $scripturl, $user_info, $txt, $color_profile, $smcFunc, $context, $settings;
// Based on SimplePortal 2.3.1, modified by AngelinaBelle
//
//  * Display articles from all categories, or limit to a single category (code provided by SiNan on Simpleportal forum
//  * Display article title, author, etc. only, or display truncated article text
//  * Truncated article text length (in characters) -- truncation performed by sp_truncatetext
//
// New CSS classes used:
// sp_articles_withbody_title
// sp_articles_author
// sp_articles_body
// sp_articles_more
//
//

//AngelinaBelle -- code for categories provided by SiNaN
global $sourcedir;
require_once($sourcedir . '/Subs-PortalAdmin.php');

$block_parameters = array(
'limit' => 'int',
'type' => 'select',
'image' => 'select',
// [SiNaN] Select all categories, or just one article category (code from SiNaN)
'category' => array(0 => '(Tutte le Categorie)'),
// AngelinaBelle Display message or header only, and truncate message to an integer value
'displaymessage' => 'select',
'truncate' => 'int'
// added by ataru
'hidebbcode' => 'select',
'hideauthor' => 'select',
'hideprnt' => 'select',
        );
       

$categories = getCategoryInfo();
foreach ($categories as $category)
$block_parameters['category'][$category['id']] = $category['name'];
$txt['sp_param_sp_articles_category'] = 'Category';

//Ataru -- options for hideimages
   $hidebbcode_Subject='Mostra';
   $hidebbcode_Message='Non mostrare';
//Ataru -- options for hideauthor
   $hideauthor_Subject='Mostra';
   $hideauthor_Message='Non mostrare';
//Ataru -- options for hideprintreadmore
   $hideprnt_Subject='Mostra';
   $hideprnt_Message='Non mostrare';
//AngelinaBelle -- options for displaymessage
   $display_Subject='Solo titolo';
   $display_Message='Titolo e testo dell\'articolo';     
if ($return_parameters)
{

$txt['sp_param_sp_articles_category'] = 'Categoria';

// AngelinaBelle: displaymessage _options are usually set in language/SPortal.<language>.php, while the message is set in the SPortalAdmin language file.
      $txt['sp_param_sp_articles_displaymessage'] = 'Mostra titolo o testo dell\'articolo';
      $helptxt['sp_param_sp_articles_displaymessage'] = 'Mostra solo il titolo (default) o anche il testo del messaggio';
      $txt['sp_param_sp_articles_displaymessage_options'] = $display_Subject . '|' . $display_Message;
//Ataru -- hide images
      $txt['sp_param_sp_articles_hidebbcode_options'] = $hidebbcode_Subject . '|' . $hidebbcode_Message;
//Ataru -- hide author
      $txt['sp_param_sp_articles_hideauthor_options'] = $hideauthor_Subject . '|' . $hideauthor_Message;
//Ataru -- hide printreadmore
      $txt['sp_param_sp_articles_hideprnt_options'] = $hideprnt_Subject . '|' . $hideprnt_Message;

//Ataru -- hide bbcode
      $txt['sp_param_sp_articles_hidebbcode'] = 'BBCode (e immagini) nell\'articolo';
//Ataru -- hide author
      $txt['sp_param_sp_articles_hideauthor'] = 'Autore dell\'articolo';
//Ataru -- hide printreadmore
      $txt['sp_param_sp_articles_hideprnt'] = 'Pulsanti Stampa e Leggi l\'articolo';

//AngelinaBelle -- options for truncate
      $txt['sp_param_sp_articles_truncate'] = 'Taglia l\'articolo';
      $helptxt['sp_param_sp_articles_truncate'] = 'Se è stato scelto di mostrare il tersto dell\'articolo, indica il numero di caratteri da visualizzare prima che l\'articolo tagliato';

return $block_parameters;
}
$limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
$type = empty($parameters['type']) ? 0 : 1;
$image = empty($parameters['image']) ? 0 : (int) $parameters['image'];
//AngelinaBelle -- code for categories provided by SiNaN
$category = empty($parameters['category']) ? 0 : (int) $parameters['category'];
//AngelinaBelle
$displaymessage = ( empty($parameters['displaymessage']) ? False : ( ($parameters['displaymessage'] == 1) ? True : False ) );
//Ataru
$hidebbcode = ( empty($parameters['hidebbcode']) ? False : ( ($parameters['hidebbcode'] == 1) ? True : False ) );
$hideauthor = ( empty($parameters['hideauthor']) ? False : ( ($parameters['hideauthor'] == 1) ? True : False ) );
$hideprnt = ( empty($parameters['hideprnt']) ? False : ( ($parameters['hideprnt'] == 1) ? True : False ) );

//AngelinaBelle -- get m.body only if we need m.body. ; $sql_qry used for query string debugging.
$sql_qry='
SELECT
m.id_topic, m.subject, m.poster_name, c.picture, c.name,
' . (!$displaymessage ? '' : 'm.id_msg, m.body, m.smileys_enabled,
') . 'mem.id_member, mem.real_name, mem.avatar,
at.id_attach, at.attachment_type, at.filename
FROM {db_prefix}sp_articles AS a
INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}attachments AS at ON (at.id_member = mem.id_member)
WHERE {query_see_board}
AND a.approved = {int:approved}' . 
(!empty($category)
? '
AND a.id_category = {int:category}'
: ''
) . '
ORDER BY {raw:type}
LIMIT {int:limit}';

$sql_params = array(
'approved' => 1,
'type' => $type ? 'RAND()' : 'm.poster_time DESC',
'limit' => $limit
);
if (!empty($category)) $sql_params['category'] = $category;

//debug
// echo 'SQL Query <pre>', print_r($sql_qry), "</pre><br/>\n";
// echo 'SQL Params<pre>', print_r($sql_params), "</pre><br/>\n";
// global $db_show_debug;
// $db_show_debug = true;
// if (isset($db_show_debug) && $db_show_debug === true)
// echo 'calling smcFunc with debugging ' ;
// else
// echo "calling smcFunc without debugging";

$request = $smcFunc['db_query']('', $sql_qry, $sql_params);

// echo 'just back from db_query ', "<br/>\n"; //debug

// echo 'request: <pre>', print_r($request),  "</pre><br/>\n";
$articles = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!empty($row['ID_MEMBER']))
$colorids[$row['ID_MEMBER']] = $row['ID_MEMBER'];

if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
}
else
{
$avatar_width = '';
$avatar_height = '';
}

//AngelinaBelle -- use it if you've got it.
censorText($row['subject']);

$articles[] = array(
'id' => $row['id_topic'],
'name' => $row['subject'],
'msg' => ( !$displaymessage ? NULL:
array(
'id' => $row['id_msg'],
'body' => $row['body'],
'smileys_enabled' => $row['smileys_enabled']
)
),
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>',
'poster' => array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
),
'image' => array(
'href' => $row['picture'],
'image' => '<img src="' . $row['picture'] . '" alt="' . $row['name'] . '" />',
),
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '" alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
),
);

}

$smcFunc['db_free_result']($request);

//debug
// echo "<b>there are ", count($articles), " articles</b> after free_request<br/>";
//AngelinaBelle -- temporarily disable some tags for this block's output (used in call to parse_bbc)
//Make sure to re-enable any tags that have been disabled (?)


$parse_tags = FALSE;
/*


// supressing some tags until things change in parse_bbc.
$supressTags = array(); // 'pdf','pdftest','flash','me'); // add more tags to the list, if you want
if (FALSE) //($supressTags !== array() && is_array($supressTags))
{
$parse_tags = array();
$temp = parse_bbc(FALSE);
foreach ($temp as $k => $code)
if ( ! in_array($code['tag'],$supressTags) ) $parse_tags[]=$code['tag'];
}
*/

//AngelinaBelle -- enable/disable AEVA embedding for this block's output
// AEVA code in parse_bbc disables AEVA if !empty($parse_tags)
$enableaeva=True;
if (array_key_exists('aeva_disable',$context))
{
$realaeva=$context['aeva_disable'];
$context['aeva_disable'] = ($enableaeva ? null : 1);

// echo 'context: realaeva ', $realaeva, "<br/>\n"; //debug
}
elseif (array_key_exists('aeva_enable',$modSettings))
{
$realaeva=$modSettings['aeva_enable'];
$modSettings['aeva_enable'] = ($enableaeva ? 1 : NULL);
// echo 'modSettings: realaeva ', $realaeva, "<br/>\n"; //debug
}
// echo 'modSettings: aeva_enable "', $modSettings['aeva_enable'], '"', "<br/>\n"; //debug


//AngelinaBelle -- if $displaymessage, then parse and (if necessary) truncate the message body
if ($displaymessage)
{

// require_once($sourcedir . '/Subs-Portal.php');
//debug
// echo 'func[strpos] ' , ( (!empty($smcFunc['strpos']) ) ? 'is set ' : 'is not set ') ,  "<br/>\n";
foreach ($articles as $k => $article)
{

// echo "working on article ", $k, "<br/>";  //debug
//  If article has a  tag, truncate there, put ... at the end
//  Else, if article is longer than $paramters['truncate'], truncate, put ... at the end
//  Else, don't truncate. Don't put ... at the end.
//
//
if ($parameters['hidebbcode'])
{
$nobbcode = str_replace("[img]","<",str_replace("[/img]",">",$article['msg']['body']));
$nobbcode = strip_tags(str_replace("[", "<", str_replace("]", ">", $nobbcode)));
$article['msg']['body'] = $nobbcode;
}

if (($cutoff = $smcFunc['strpos']($article['msg']['body'], '')) !== false)
$putdots =
  (
   (
     $cutoff <
      ($smcFunc['strlen']($article['msg']['body']) - $smcFunc['strlen']('')
      )
    )
  ? TRUE
  : FALSE
  );
elseif (!empty($parameters['truncate']) && $smcFunc['strlen']($article['msg']['body']) > $parameters['truncate'] )
{
$cutoff = $parameters['truncate'];
$putdots = TRUE;
}
else
{
$cutoff = FALSE;
$putdots = FALSE;
}
// echo 'cutoff ', (($cutoff === False) ? 'FALSE' : $cutoff ), "<br/>\n" ; //debug
// echo 'putdots ', (($putdots) ? 'TRUE' : 'FALSE' ), "<br/>\n"; //debug

if ( $cutoff !== FALSE )
//modifiche di ataru
// $article['msg']['body'] = $smcFunc['substr']($article['msg']['body'], 0, $cutoff);
// echo 'parsing article ', $k , "<br/>\n";//debug
// $article['msg']['body'] = parse_bbc($article['msg']['body'], $article['msg']['smileys_enabled'], $article['msg']['id'], $parse_tags);
{
$cut_string=substr($article['msg']['body'], 0,$cutoff);
$last_space=strrpos($cut_string," ");
$article['msg']['body']=substr($cut_string, 0,$last_space);
}

if ($putdots)
$article['msg']['body'] .= ' (<a href="'.$article['href'].'">...</a>)';

censorText($article['msg']['body']);

if ($modSettings['sp_resize_images'])
$article['msg']['body'] = preg_replace('~<img\s+src="([^"]+)"([^/>]+)/>~i', '<img src="$1"$2class="sp_article" />', $article['msg']['body']);
// I could come up with the correct preg_replace for <embed and <object, too. Perhaps another day.


//debug
// echo "<b>there are ", count($articles), " articles </b> after truncation<br/>";

$articles[$k]['msg']['body'] = $article['msg']['body'];
}
//debug
// echo "<b>there are ", count($articles), "articles </b> after foreach $articles <br/>";

//AngelinaBelle -- done parsing and truncating message bodies


//AngelinaBelle -- put AEVA settings back the way they were

if (array_key_exists('aeva_disable',$context))
{
// echo 'context: aeva_disable ', $context['aeva_disable'], "<br/>\n" ;//debug
$context['aeva_disable'] = $realaeva;
}
elseif (array_key_exists('aeva_enable',$modSettings))
{
// echo 'modsettings: aeva_enable "', $modSettings['aeva_enable'], '"', "<br/>\n" ; //debug
$modSettings['aeva_enable'] = $realaeva;
}


}

if (empty($articles))
{
echo '
', $txt['error_sp_no_articles_found'];
return;
}
else
$articles[count($articles) - 1]['is_last']=True;

if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($articles as $k => $p)
{
if (!empty($color_profile[$p['poster']['id']]['link']))
$articles[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
}
}

//Begin article list output. Original code comes first
if ( !$displaymessage )

if (empty($image))
{
echo '
<ul class="sp_list">';
foreach ($articles as $article)
echo '
<li>', sp_embed_image('topic'), ' ', $article['link'], '</li>';

echo '
</ul>';
}
else
{
echo '
<table class="sp_fullwidth sp_articles">';
foreach ($articles as $article)
{
echo '
<tr>
<td class="sp_articles sp_center">';

if (!empty($article['avatar']['href']) && $image == 1)
echo '<img src="', $article['avatar']['href'], '" alt="', $article['poster']['name'], '" width="40" />';
elseif (!empty($article['image']['href']) && $image == 2)
echo '<img src="', $article['image']['href'], '" alt="', $article['name'], '" width="40" />';

echo '</td>
<td>';
if (!$hideauthor)
{
echo '
<span class="sp_articles_title">', $article['poster']['link'], '</span><br />';
}
echo '
', $article['link'], '
</td>
</tr>';
}

echo '
</table>';
}
}
else
{  //AngelinaBelle -- new displaymessage option -- display truncated message.
// echo "there are ", count($articles), "articles <br/>";
echo '
<table class="sp_fullwidth sp_articles">';

foreach ($articles as $article)
{
echo '
<tr><td>
';
// echo '<div>', "\n";


if (empty($image)) {}
else
{
if (!empty($article['avatar']['href']) && $image == 1)
$img_guts = $article['avatar']['href'] .  '" alt="' .  $article['poster']['name'];
elseif (!empty($article['image']['href']) && $image == 2)
$img_guts = $article['image']['href'] . '" alt="' .  $article['name'];

if ( isset($img_guts) && !empty($img_guts) )
echo '<img class="sp_articles_icon" src="', $img_guts, '" width="40" /></td>';
}
echo '<td>';
//link to print article
if (!$hideprnt)
{
echo '    <div style="float: right;" class="sp_articles_more"> <a href="', $article['href']. ';action=printpage', '">Stampa</a>', "</div>\n";
}

//article title
// echo '    <p class="sp_articles_withbody_title">';
echo  $article['link'] ;
// echo  '</p>', "\n";
//byline
if (!$hideauthor)
{
echo '     <span class="sp_articles_author">', $txt[525], ' ', $article['poster']['link'], '    </span>';
}

//date and time
// $article['time'], // Let's leave this out for now.

// Begin Truncated Message Body
echo '<div class="sp_articles_body">', $article['msg']['body'], '</div>';

if (!$hideprnt)
{
// More and comment links after message
echo '<table width="100%">'. "\n<tr>";
//Another link to the article
echo '<td><span class="sp_articles_more"> <a href="', $article['href'], '">Leggi l\'articolo</a></span></td>'. "\n";
//comments
echo '<td><span class="sp_articles_more"> <a href="', $article['href']. ';action=post' , '">',
( ($txt['ssi_write_comment']==='') ? Comment : $txt['ssi_write_comment'])
, '</a></span></td>', "\n";
echo "</tr>\n</table>" , "\n";
}

// A separator if this is not the last article
if ( empty($article['is_last'])) echo '
<hr />';
echo '</td></tr>' . "\n";
}
echo "</table>\n";
// handle sp_resize-ing.
// at this point, it is too late to alter the header in php, so we'll have to do it in js.
// This css file should contain resize directives for embed and object only, since many
// browsers don't follow the rules for max-height and max-width.
if ($modSettings['sp_resize_images'])
{
echo '
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var cssNode = document.createElement("link");
cssNode.type = "text/css";
cssNode.rel = "stylesheet";
cssNode.href = "', $settings['default_theme_url'], '/portal_resize.css";
cssNode.media = "screen";
cssNode.title = "dynamicLoadedSheet";
document.getElementsByTagName("head")[0].appendChild(cssNode);
// ]]></script>';
}

}

}
SimplePortal 2.3.7 © 2008-2021, SimplePortal