integrate_whos_online

Started by Kindred, October 30, 2006, 04:57:33 PM

Previous topic - Next topic

Kindred

In an effort to improve the "Who's Online and where" display that Orstio was such a god to add, I have done a little playing...

I added a bunch of defined actions to the array and also added some functionality that lets you use the same array for multiple components (i.e. I didn't want to code 4 different if statements for the most popular gallery components, so I used an "OR" and then select the option from the return sprintf.

I also decided that there were too many IFs being processed. Since you can only be ding one action at a time, to lighten the load I used an: "if - else if" structure.

To use these, you can open components/com_smf/smf.php and replace function integrate_whos_online with the following:


function integrate_whos_online ($actions) {

global $txt, $database, $mosConfig_db, $mosConfig_dbprefix, $db_name;
//First, we need to add the new language strings
add_to_txt();

//it must be the main page
if (!isset($actions['option']))
return $txt['who_home'];

//let's make sure there is an option...
if (isset($actions['option'])){
//still the main page
if ($actions['option']=='com_frontpage')
return $txt['who_home'];
//It's the forum ;)
else if ($actions['option']=='com_smf')
return $txt['who_index'];
//let's try the content
else if ($actions['option']=='com_content'){
if (isset($actions['task'])){
if($actions['task']=='view'){
mysql_select_db($mosConfig_db);
$mos_find_article = mysql_query ("SELECT title
FROM {$mosConfig_dbprefix}content
WHERE id = $actions[id]
LIMIT 1");
list ($article_name) = mysql_fetch_row($mos_find_article);
mysql_select_db($db_name);
return sprintf($txt['who_article'], $actions['id'], $actions['Itemid'], $article_name);
}
if ($actions['task']=='section'){
mysql_select_db($mosConfig_db);
$mos_find_article = mysql_query ("SELECT title
FROM {$mosConfig_dbprefix}sections
WHERE id = $actions[id]
LIMIT 1");
list ($section_name) = mysql_fetch_row($mos_find_article);
mysql_select_db($db_name);
return sprintf($txt['who_section'], $actions['id'], $actions['Itemid'], $section_name);
}
if ($actions['task']=='blogsection'){
mysql_select_db($mosConfig_db);
$mos_find_article = mysql_query ("SELECT title
FROM {$mosConfig_dbprefix}sections
WHERE id = $actions[id]
LIMIT 1");
list ($section_name) = mysql_fetch_row($mos_find_article);
mysql_select_db($db_name);
return sprintf($txt['who_blogsection'], $actions['id'], $actions['Itemid'], $section_name);
}
if ($actions['task']=='category'){
mysql_select_db($mosConfig_db);
$mos_find_article = mysql_query ("SELECT title
FROM {$mosConfig_dbprefix}categories
WHERE id = $actions[id]
LIMIT 1");
list ($category_name) = mysql_fetch_row($mos_find_article);
mysql_select_db($db_name);
return sprintf($txt['who_category'], $actions['id'], $actions['Itemid'], $category_name);
}
if ($actions['task']=='blogcategory'){
mysql_select_db($mosConfig_db);
$mos_find_article = mysql_query ("SELECT title
FROM {$mosConfig_dbprefix}categories
WHERE id = $actions[id]
LIMIT 1");
list ($category_name) = mysql_fetch_row($mos_find_article);
mysql_select_db($db_name);
return sprintf($txt['who_blogcategory'], $actions['id'], $actions['Itemid'], $category_name);
}
}
}
else if ($actions['option']=='com_newsfeeds'){
if (isset($actions['task'])){
if ($actions['task']=='view')
return sprintf($txt['who_newsfeeds'], $actions['Itemid']);
}
}
//Site search
else if ($actions['option']=='com_search')
return sprintf($txt['who_sitesearch'], $actions['Itemid']);

//Hmm...attention shoppers in aisle Itemid
else if ($actions['option']=='com_virtuemart'){
return sprintf($txt['who_virtuemart'], $actions['Itemid']);
}
//How about the Wiki?
else if (($actions['option']=='com_wikidoc') || ($actions['option']=='com_jd-wiki'))  {
return sprintf($txt['who_wiki'], $actions['option'], $actions['Itemid']);
}
//How about the Games?
else if ($actions['option']=='com_dcs_flashgames')  {
return sprintf($txt['who_games'], $actions['option'], $actions['Itemid']);
}
//How about the Links?
else if (($actions['option']=='com_bookmarks') || ($actions['option']=='com_links'))  {
return sprintf($txt['who_links'], $actions['option'], $actions['Itemid']);
}
//How about the Link exchange?
else if ($actions['option']=='com_linkexchange')  {
return sprintf($txt['who_linkexchange'], $actions['option'], $actions['Itemid']);
}
//How about the Guestbook?
else if (($actions['option']=='com_easygb') || ($actions['option']=='com_guestbook'))  {
return sprintf($txt['who_guestbook'], $actions['option'], $actions['Itemid']);
}
//How about the Contact page?
else if (($actions['option']=='com_staff') || ($actions['option']=='com_contact'))  {
return sprintf($txt['who_contact'], $actions['option'], $actions['Itemid']);
}
//How about the gallery?
else if (($actions['option']=='com_gallery2') || ($actions['option']=='com_zoom') || ($actions['option']=='com_rsgallery2') || ($actions['option']=='com_coppermine'))  {
return sprintf($txt['who_gallery'], $actions['option'], $actions['Itemid']);
}
//How about the Polls?
else if (($actions['option']=='com_exitpoll') || ($actions['option']=='com_poll'))  {
return sprintf($txt['who_polls'], $actions['option'], $actions['Itemid']);
}
//How about the Credits?
else if ($actions['option']=='com_jm-credits')  {
return sprintf($txt['who_credits'], $actions['option'], $actions['Itemid']);
}
//How about the Glossary?
else if ($actions['option']=='com_glossary')  {
return sprintf($txt['who_glossary'], $actions['option'], $actions['Itemid']);
}
//How about the Review Pages?
else if ($actions['option']=='com_simple_review')  {
return sprintf($txt['who_review'], $actions['option'], $actions['Itemid']);
}
//How about the Classifieds?
else if (($actions['option']=='com_classifieds') || ($actions['option']=='com_noah'))  {
return sprintf($txt['who_classifieds'], $actions['option'], $actions['Itemid']);
}
//How about the Recipes?
else if (($actions['option']=='com_ricettario') || ($actions['option']=='com_pccookbook'))  {
return sprintf($txt['who_recipes'], $actions['option'], $actions['Itemid']);
}
//How about the Writing Section?
else if ($actions['option']=='com_ewriting')  {
return sprintf($txt['who_writing'], $actions['option'], $actions['Itemid']);
}
else {
return sprintf($txt['who_other'], $actions['option'], $actions['Itemid']);
}
}
}
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Kindred

#1
and these are the additional lines added to smf_integration_arrays.php


Replace the WIKI line with the following:

$txt['who_wiki'] = 'Viewing the <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Wiki</a>.';
$txt['who_games'] = 'Playing the <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Games</a>.';
$txt['who_links'] = 'Viewing the <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Links</a>.';
$txt['who_linkexchange'] = 'Viewing the <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Link Exchange</a>.';
$txt['who_guestbook'] = 'Viewing the <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Guestbook</a>.';
$txt['who_contact'] = 'Viewing the <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Contact</a> Page.';
$txt['who_gallery'] = 'Viewing the <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Gallery</a>.';
$txt['who_polls'] = 'Viewing the <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Polls</a>.';
$txt['who_credits'] = 'Viewing the <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Credits</a> Page.';
$txt['who_glossary'] = 'Viewing the <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Glossary</a>.';
$txt['who_review'] = 'Viewing the <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Reviews</a>.';
$txt['who_classifieds'] = 'Viewing the <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Classifieds</a>.';
$txt['who_recipes'] = 'Viewing the <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Recipe</a> Book.';
$txt['who_ewriting'] = 'Viewing <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Writing</a> Section.';
$txt['who_other'] = 'Viewing <a href="' . ($mosConfig_sef !='1' ? $mosConfig_live_site . '/index.php?option=%s&amp;Itemid=%d' : sefReltoAbs ('index.php?option=%s&amp;Itemid=%d')) . '">Something Else</a>.';
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Orstio

Awesome!

Thanks Kindred.  I'll put this into the CVS.  :)

Aravot

Great addition, thanks Kindred.

Advertisement: