Country Flags in Online_extended and Chatbox

e107 CMS » Forums » e107 Code » Plugin Requests << Previous thread | Next thread >>
Go to page  1 2
nuclear
Jun 13 2010, 05:36AM
Registered Member #56095
Joined: May 29 2010, 01:04PM
Posts: 10
I need a plugin to show every user on chatbox and online_extended near their name the country flag.

Example of Coutnry flag in online_extended -> www(dot)xtreme-jumps(dot)eu
Example of Country Flags in online_extended and chatbox, too -> kz(dot)extreme(dot)net
Go to top
nuclear
Jun 21 2010, 11:35AM
Registered Member #56095
Joined: May 29 2010, 01:04PM
Posts: 10
Bump.
Go to top
septor
Jun 21 2010, 01:59PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2647
This can be done by editing the template of the chatbox and online_extended menu (both may require actual code hacking) and including the user's location (by using I mean converting the country to it's respective flag).

This would require user's to fill in this information, which can be done by making the location field mandatory.
Go to top
Website
nuclear
Jun 22 2010, 12:40PM
Registered Member #56095
Joined: May 29 2010, 01:04PM
Posts: 10
Can't this be done easier ? I mean the country you choose at registering it's flag you'll use.
Go to top
septor
Jun 22 2010, 07:03PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2647
I'm pretty sure I just listed the easiest way to do this as what you are requesting isn't part of the plugins you mentioned.
Go to top
Website
nuclear
Jun 25 2010, 10:02AM
Registered Member #56095
Joined: May 29 2010, 01:04PM
Posts: 10
I really don't know how to make it... can you be more specific where and what must i do...

My experience in PHP/E107 things is ... it isn't
Go to top
septor
Jun 25 2010, 02:14PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2647
Just so I'm clear; you want the user's country flag to be next to their name in the chatbox and in the online_extended menu, correct?
Go to top
Website
nuclear
Jun 25 2010, 03:12PM
Registered Member #56095
Joined: May 29 2010, 01:04PM
Posts: 10
Yes, probably based on IP location...
[ Edited Jun 25 2010, 03:28PM ]
Go to top
septor
Jun 25 2010, 03:25PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2647
I'll dig into the plugins and see what I can do.
Go to top
Website
Tgtje
Jun 26 2010, 04:12AM
  • e107 Support Team
Registered Member #30653
Joined: Sep 18 2006, 01:25AM
Location: Born, The Netherlands
Posts: 1988
[-link-]

this is the one used by xtreme

found here : [-link-]
[ Edited Jun 26 2010, 04:14AM ]
Go to top
Website
septor
Jun 26 2010, 01:53PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2647
You're probably better off using Tgtje's suggestion as I have no idea when I'll have time to present results.
Go to top
Website
nuclear
Jun 26 2010, 03:13PM
Registered Member #56095
Joined: May 29 2010, 01:04PM
Posts: 10
I installed it ... but both online extended and chatbox are not working... The flags still don't appear
Go to top
septor
Jun 26 2010, 04:40PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2647
I may have time to do some research tomorrow evening. Please don't wait for me to give you the answers you need though as I cannot give you a set in stone time when I'll have the answers.

What you're basically going to want to do is this:

Find a location that has all the country flags you're after (Google famfamfam, there's excellent flag images there that will do perfectly, imo). Upload those to e107_files/images/flags directory (create that dir if it doesn't exist).

Now you're going to want open up the online_extended plugin (online_extended_menu.php) and locate where the user's username is displayed (I believe the variable is $oname, use your texteditors find function to locate all occurrences of $oname).

Now the real tricky part comes, IIRC the {EXTENDED} shortcode works in plugins, so getting the user's location is going to be the easy part. The hard part is making sure the value of their location matches the images flag name (eg: I'm from the USA, the image of the USA flag would need to be named usa.png, otherwise it won't display).

Moving along, let's assume the names all match up. You're going to want to define the flag of the users location and then place (let's assume you've named the variable $oflag $oflag before each $oname.

The chatbox can be done via your theme's theme.php file in a similar manner, except you won't need to define the flag as a variable, you can do something like:

<img src='".e_FILES."images/flags/{EXTENDED=location.value}.png'>


------

That is probably confusing as hell as I pretty much just rattled that off as I thought about it, but it's a start if you want to attempt to tackle it yourself. On the plus side, if you start the process yourself you can always come here and post any errors/problems you're having and people will generally help you solve them.
[ Edited Jun 26 2010, 04:41PM ]
Go to top
Website
Tgtje
Jun 26 2010, 05:55PM
  • e107 Support Team
Registered Member #30653
Joined: Sep 18 2006, 01:25AM
Location: Born, The Netherlands
Posts: 1988
for what it's worth
@ nuclear: if i am not mistaken, try contacting Luceos ?
(maybe he can shed some light)
(could save a lot of work for Septor too )

I believe he (Luceos) is the man behind this plugin
[ Edited Jun 26 2010, 06:00PM ]
Go to top
Website
septor
Jun 27 2010, 06:37AM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2647
I looked up the flags from famfamfam. And it appears the filenames follow the ISO 3166-1 alpha-2 country codes. Which means 90% of them are all 2 letter filenames (eg: us.png).

Also, as seen on this webpage, my location is Michigan (which is a state, not a country), so my above suggestion probably isn't going to fully work. Your best bet is to create an extended field that is required that makes the user select their two letter country code.
Go to top
Website
BillyBoy0823
Jun 27 2010, 08:59AM
Registered Member #14644
Joined: Feb 14 2005, 04:20PM
Location: Leominster, MA USA
Posts: 504
I may be able to do something with Chatbox II, but not right away. As septor suggested, you would need to create a 'Country' extended user field. When I write it, I can look for that extended user field, have it match the flag, or if it doesn't find the right one, use a default 'e107 flag'.

If I do it for chatbox II, it would be easy to hack the chatbox and use the same code.
Go to top
septor
Jun 27 2010, 04:14PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2647
I've been thinking this over and I've come to the conclusion that it wouldn't be hard to do for either core plugin, but it's going to require a lot of preparation for it to work flawlessly.

It may not be a terrible idea to throw this idea on the feature request page, as it probably wouldn't be a bad core addition and it wouldn't be terribly hard to implement (as said above).
Go to top
Website
nuclear
Jun 27 2010, 04:18PM
Registered Member #56095
Joined: May 29 2010, 01:04PM
Posts: 10
I was thinking too of implementing it to the future e107 projects ...

I will try to contact the plugin's author or one of the owners of the sites i posted in first link.. I hope they will help me
Go to top
Kesh
Jun 28 2010, 05:48AM
Registered Member #57295
Joined: Jun 27 2010, 08:30AM
Posts: 3
i try with online extended menu to put this code who septor tell but nothing happen.
There is code of menu:
if (!defined('e107_INIT')) { exit; }

if(!defined("e_TRACKING_DISABLED") && (isset($pref['track_online']) && $pref['track_online'])) {
	$text = ONLINE_EL1.GUESTS_ONLINE.", ";
	$text .= ONLINE_EL2.MEMBERS_ONLINE." ...<br />";

	if (MEMBERS_ONLINE) {
		global $listuserson, $ADMIN_DIRECTORY;
		foreach($listuserson as $uinfo => $pinfo) {


			list($oid, $oname) = explode(".", $uinfo, 2);
			$online_location_page = substr(strrchr($pinfo, "/"), 1);
			if ($pinfo == "log.php" || $pinfo == "error.php") {
				$online_location_page = "news.php";
				$pinfo = "news.php";
			}
			if ($online_location_page == "request.php") {
				$pinfo = "download.php";
			}
			if (strstr($online_location_page, "forum")) {
				$pinfo = e_PLUGIN."forum/forum.php";
				$online_location_page = "forum.php";
			}
			if (strstr($online_location_page, "content")) {
				$pinfo = "content.php";
				$online_location_page = "content.php";
			}
			if (strstr($online_location_page, "comment")) {
				$pinfo = "comment.php";
				$online_location_page = "comment.php";
			}
			$text .= " <img src='".e_FILES."images/flags/{EXTENDED=location.value}.png' alt='' style='vertical-align:middle' /> <a href='".e_BASE."user.php?id.$oid'>$oname</a> ".ONLINE_EL7;
			(!strstr($pinfo, $ADMIN_DIRECTORY) ? $text .= " <a href='{$pinfo}'>$online_location_page</a><br />" : $text .= " $online_location_page<br />");
		}
	}

	if ((MEMBERS_ONLINE + GUESTS_ONLINE) > ($menu_pref['most_members_online'] + $menu_pref['most_guests_online'])) {
		$menu_pref['most_members_online'] = MEMBERS_ONLINE;
		$menu_pref['most_guests_online'] = GUESTS_ONLINE;
		$menu_pref['most_online_datestamp'] = time();
		$tmp = addslashes(serialize($menu_pref));
		$sql->db_Update("core", "e107_value='$tmp' WHERE e107_name='menu_pref' ");
	}
    global $gen;
	if (!is_object($gen)) {
		$gen = new convert;
	}

	$datestamp = $gen->convert_date($menu_pref['most_online_datestamp'], "short");

	//$text .= "<br />".ONLINE_EL8." ".($menu_pref['most_members_online'] + $menu_pref['most_guests_online'])."<br />(".ONLINE_EL2.$menu_pref['most_members_online'].", ".ONLINE_EL1.$menu_pref['most_guests_online'].") ".ONLINE_EL9." ".$datestamp."<br />";

 	$total_members = $sql->db_Count("user","(*)","where user_ban = 0");
	if ($total_members > 1) {
		$newest_member = $sql->db_Select("user", "user_id, user_name", "user_ban = 0 ORDER BY user_join DESC LIMIT 1");
		$row = $sql->db_Fetch();
		extract($row);
		$text .= "<br />".ONLINE_EL5.": ".$total_members."<br />".ONLINE_EL6.": <a href='".e_BASE."user.php?id.".$user_id."'>".$user_name."</a>";
	}
} elseif(ADMIN) {
	global $tp;
	$text = $tp->toHtml(ONLINE_TRACKING_MESSAGE,TRUE);
}


$ns->tablerender(ONLINE_EL4, $text, 'online_extended');

?>



                        $text .= " <img src='".e_FILES."images/flags/{EXTENDED=location.value}.png' alt='' style='vertical-align:middle' /> <a href='".e_BASE."user.php?id.$oid'>$oname</a> ".ONLINE_EL7;                         (!strstr($pinfo, $ADMIN_DIRECTORY) ? $text .= " <a href='{$pinfo}'>$online_location_page</a><br />" : $text .= " $online_location_page<br />");                 } 
[ Edited Jun 28 2010, 05:48AM ]
Go to top
septor
Jun 28 2010, 01:53PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2647
Kesh wrote ...

i try with online extended menu to put this code who septor tell but nothing happen.


Because you obviously didn't read everything I have posted. I said that is how you would go about making it work, I did not say it would work flawlessly. In another post I said that due to how the location information is handled (it's open to anything, I could change my location to "Melmac", for example) it won't work with those images (or at all). You're going to have to create an extended field that utilizes the format the images are named in (read my post with the link to the flags for more info).

You have 3 possible choices:

1) Use the plugin mentioned above.
2) Learn some PHP and do the work yourself, taking what is written in this thread as a guideline.
3) Wait for someone to do it for you.
[ Edited Jun 28 2010, 01:56PM ]
Go to top
Website
Go to page  1 2  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System