Skip to main content
Topic: [ADDON] SimplePortal (Read 155720 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

Re: [ADDON] SimplePortal

Reply #105

Quote from: [SiNaN] – Also, in Profiles admin list, you should use the label field for the name column. It would be nice to have the numbers for articles, blocks, categories, pages and shoutboxes centered and set to 0 if empty too.

I made the change to sources/subs/Portal.subs.php and that did fix the issue. Is the above something else I need to do? If so, I'm not sure how to accomplish this...non-programmer here.

Re: [ADDON] SimplePortal

Reply #106

Quote from: Spuds – Done, done and done, thanks for the input ... There are many places things are not centered in columns (in elk), that was a stylistic approach as far as I know.

Long text looks fine when aligned to sides, however, I think numbers and short text should be centered in tables. Also, I think it would be better if you used name field for the edit page. My intention was to allow for translation of the profile names through the use of $ prefix.

Quote from: Spuds – All easter eggs must die with fire ! :P ... Also let me fix this  ... Spuds removed it in histhe Elkarte port  ;)

PS Now I did leave some eggs in place, like the ones in the info/about area, so don't fret, there is still weird stuff in place!

lol Good to know that there is still part of me in there! The most stupid best one I had put in there was the Eliana Day but unfortunately I was forced to remove it. :P

Quote from: b4pjoe – I made the change to sources/subs/Portal.subs.php and that did fix the issue. Is the above something else I need to do? If so, I'm not sure how to accomplish this...non-programmer here.

They aren't really important. You wouldn't experience any issues if you didn't apply them.

 

Re: [ADDON] SimplePortal

Reply #107

Quote from: Spuds –
Quote from: Ruth – Maybe Spuds can help us with this code and transform it for ElkArte?  O:-)  I don't know, if this is possible and how much work it would be. I think, such block is a very needful thing and I would be very glad to use it.

Give this a try and let me know if its what you want.
Code: [Select]
 global $context, $settings, $scripturl, $txt, $user_info, $modSettings, $posts, $color_profile;

 $db = database();

 $exclude_boards = null;
 $num_recent = !empty($parameters[0]) ? $parameters[0] : (isset($_GET['limit']) ? (int) $_GET['limit'] : 20);
 $show_body = !empty($parameters[1]) ? $parameters[1] : false;

 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;

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

 // Find all the posts in distinct topics.  Newer ones will have higher IDs.
 $request = $db->query('', '
 SELECT
 m.poster_time, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, t.num_replies, t.num_views, b.name AS bName,
 IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
 IFNULL(lt.id_msg, IFNULL(lmr.ID_MSG, 0)) >= m.id_msg_modified AS is_read,
 IFNULL(lt.id_msg, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ', LEFT(m.body, 384) AS body, m.smileys_enabled, mf.icon
 FROM ({db_prefix}messages AS m, {db_prefix}topics AS t, {db_prefix}boards AS b, {db_prefix}messages AS ms)
 INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
 LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
 LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:id_member})
 LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:id_member})' : '') . '
 WHERE t.id_last_msg >= ' . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . '
 AND t.id_last_msg = m.id_msg
 AND b.id_board = t.id_board' . (empty($exclude_boards) ? '' : '
 AND b.id_board NOT IN ({array_int:exclude_boards})') . '
 AND {raw:query_see_board}
 AND ms.id_msg = t.id_last_msg
 ORDER BY t.id_last_msg DESC
 LIMIT {int:limit}',
 array(
 'id_member' => $user_info['id'],
 'exclude_boards' => $exclude_boards,
 'query_see_board' => $user_info['query_wanna_see_board'],
 'limit' => (int) $num_recent,
 )
 );
 $posts = array();
 $color_ids = array();
 while ($row = $db->fetch_assoc($request))
 {
 // Shorten the body if needed
 if ($show_body)
 {
 $ellip = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0" title="' . $row['subject'] . '">…</a>';
 $row['body'] = Util::shorten_html(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), 128, $ellip, false);
 censorText($row['body']);
 }

 // Censor the subject.
 $row['subject'] = preg_replace('/^' . preg_quote($txt['response_prefix']) . '/', '', $row['subject']);
 censorText($row['subject']);

 // Collect the color ids :)
 $color_ids[$row['id_member']] = $row['id_member'];

 if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
 $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';

 // Build the array.
 $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['poster_name'],
 'href' => empty($row['id_member']) ? '' : $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['poster_name'] . '</a>'
 ),
 'subject' => $row['subject'],
 'short_subject' => Util::shorten_text($row['subject'], 25),
 'preview' => $show_body ? $row['body'] : '',
 'time' => standardTime($row['poster_time']),
 'timestamp' => forum_time(true, $row['poster_time']),
 '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['is_read']),
 'new_from' => $row['new_from'],
 'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.png" style="vertical-align: middle;" alt="' . $row['icon'] . '" />',
 'views' => $row['num_views'],
 'replies' => $row['num_replies'],
 );
 }
 $db->free_result($request);

 // Colorization
 if (!empty($color_ids) && sp_loadColors($color_ids) !== false)
 {
 foreach ($posts as $key => $value)
 {
 if (!empty($color_profile[$value['poster']['id']]['link']))
 $posts[$key]['poster']['link'] = $color_profile[$value['poster']['id']]['link'];
 }
 }

 $context['recent_topics'] = $posts;

 // Just return if we have no results
 if (empty($posts))
 return $txt['error_sp_no_posts_found'];

 echo '
 <div>';

 foreach ($posts as $post)
 {
 echo '
 <div style="display: table-cell; padding: 0 8px" class="centericon">
 ', $post['icon'], '
 </div>
 <div class="" style="display: table-cell">
 <a href="', $post['href'], '">', $post['subject'], '</a>
 ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><span class="new_posts"> ' . $txt['new'] . '</span></a>';

 echo '
 <div class="middletext">
 ', $txt['by'], ' ', $post['poster']['link'], ' ', $txt['in'], ' ', $post['board']['link'], '
 </br />
 ', $post['time'], ' | ', $txt['views'], ': ', $post['views'], ' | ', $txt['replies'], ': ', $post['replies'], '
 </div>';
 
 if ($show_body)
 echo '
 <div class="middletext">
 ', $post['preview'], '
 </div>';
 
 echo '
 </div>
 <hr>';
 }

 echo '
 </div>';


Do I need to change the code in a file somewhere for this to fix the recent topics order or should this code be placed in a custom PHP block?


Re: [ADDON] SimplePortal

Reply #109

Thanks Ruth. I have it working now. My only wish is that it would be formatted as the normal Recent Topics left or right block but in the correct order.

Re: [ADDON] SimplePortal

Reply #110

QuoteLong text looks fine when aligned to sides, however, I think numbers and short text should be centered in tables. Also, I think it would be better if you used name field for the edit page. My intention was to allow for translation of the profile names through the use of $ prefix.
I see, makes sense ... I'll back that edit out on the next push.

Quick question, what issue was being addressed in parse_bbc with the pufff edits ?

Re: [ADDON] SimplePortal

Reply #111

From what I remember, when you pass an array of tags as $parse_tags when using parse_bbc(), it will (re)load all the tags regardless. When we were running parse_bbc() on a dozen of shouts with only selected tags passed by $parse_tags, it brought the server down to its knees. I had to implement my own caching-like mechanism to prevent that. Those are the puff edits.

There is also the parse_bbc('sp') edit made to that function, which is even better. It had taken me quite some time to figure out what was going on. The issue was reported here:

http://simpleportal.net/index.php?topic=8151.0

Re: [ADDON] SimplePortal

Reply #112

Thanks, that helps. 

Those parse_bbc edits are some of the largest remaining source edits and I did not see a way to avoid those with a hook etc.  Not that I want to add many others hooks to my all time favorite function ;)

Do you think its maybe worth while add those puff edits to the core, seems like a decent improvement for addons etc and I don't immediately see any downside.

parse_bbc('sp')  LOL, I missed that one, that has to stay.  I still have a branch where I replaced parse_bbc with a OOP version, very robust and configurable.  Only slight downside was it was significantly slower (including parsing plain text) than whats there now :P I even tried two existing OOP libraries with the same results.  Some day I may redo it in Zephir just to see ..

Re: [ADDON] SimplePortal

Reply #113

Quote from: Spuds – Thanks, that helps. 

Those parse_bbc edits are some of the largest remaining source edits and I did not see a way to avoid those with a hook etc.  Not that I want to add many others hooks to my all time favorite function ;)

Do you think its maybe worth while add those puff edits to the core, seems like a decent improvement for addons etc and I don't immediately see any downside.
If you think the changes are fine and useful, feel free to include them in the core. Being able to limit the tags that would be parsed is a really nice feature and indispensable for some mods. I even considered writing my own little basic parser before I came up with this fix. By the way, I'm not sure but I probably intend this line
Code: [Select]
			$parse_tag_cache = array($tags_cache_id => array($bbc_codes, $disabled));
to be this:
Code: [Select]
			$parse_tag_cache[$tags_cache_id] = array($bbc_codes, $disabled);

Quote from: Spuds – parse_bbc('sp')  LOL, I missed that one, that has to stay.  I still have a branch where I replaced parse_bbc with a OOP version, very robust and configurable.  Only slight downside was it was significantly slower (including parsing plain text) than whats there now :P I even tried two existing OOP libraries with the same results.  Some day I may redo it in Zephir just to see ..
Well, parse_bbc() is probably the function that needs a change the most; but it's too big mess with. So, good luck! :D

Re: [ADDON] SimplePortal

Reply #114

QuoteBeing able to limit the tags that would be parsed is a really nice feature and indispensable for some mods.
nods thats how I felt once one explained what issue was.  I think it should be in the core as it seems improper that an addon needs to install a patch so things work as they should.  I'll check your update as well, from a quick look I think you are right.

QuoteWell, parse_bbc() is probably the function that needs a change the most; but it's too big mess with. So, good luck! :D
Oh yes, and it certainly has the most impact to performance etc (it received a small speed boost through a few missing optimizations, but its at it limit).  Thats why I'm so tentative about it, lots of downside I'm afraid.




Re: [ADDON] SimplePortal

Reply #115

Is it possible to set the portal so that it can be read with a mobile phone? It would make sense hide right and left at the phone see the tables .

I made a screen shoot .
Mobile phone is Sony Xperia Z with Android 4.4.4

Re: [ADDON] SimplePortal

Reply #116

It should be disabling the portal when on a mobile device, that is if Elk correctly sniffs the device as mobile (right now that is a browser sniff so its not as reliable as it could be).

Could you post what your user agent string is for the device, just curious as to why ElkArte may mis-identify it.  You can get that by going to http://whatsmyuseragent.com/



Last Edit: October 09, 2014, 07:44:43 am by Spuds

Re: [ADDON] SimplePortal

Reply #117

A long while ago, one thing I did with simple portal and "mobile" was to pile the blocks in a single column, then collapse all the blocks except the "main body", and finally attach an "on click" to the title of each block for expanding the block.
The result was not perfect (because of the order of appearance, but it was not so bad as well.
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON] SimplePortal

Reply #118

Thats a good approach as well, may think about doing that instead of simply turning it off for mobile (not tablet) devices.   First step is to figure out why the "detection" is not working ... I tried the emulator in chrome with a Xperia selected as the device and it shut the portal off as expected so not sure. 

We could of course "dump" our detection class and use one like https://github.com/serbanghita/Mobile-Detect in 1.1

Re: [ADDON] SimplePortal

Reply #119

So - on my test forum, it looks like html articles don't work - I get to see the html tags in the output as text.