Page 1 of 2
PHP function to handle nickname colors/formatting?
Posted: 02 Dec 2012, 08:16
by slugish
I am working on a script to display players in my servers on my site. I want to display players by nickname, but am stuck with converting names. I would prefer to display nicks using the same color and formatting rules as maniaplanet, but I would settle for a function to strip away formatting and display standard text. I am by no means a php pro, so I would love to avoid coding this from scratch if someone else has already done so. Does anyone have this already?
Re: PHP function to handle nickname colors/formatting?
Posted: 02 Dec 2012, 09:55
by RamCUP2000
Re: PHP function to handle nickname colors/formatting?
Posted: 02 Dec 2012, 10:47
by The_Big_Boo
You can also check out our ManiaLib classes which we're using in all our projects.
-
Formatting: to strip colors, links and other formatting from the string
-
StyleParser: a full rework of class given in previous post, which handles formatting as closest to the game as possible and correct a few bugs. You can see the result on the player page for instance.
-
Color: mandatory for these classes to work, used to contrast colors.
Re: PHP function to handle nickname colors/formatting?
Posted: 02 Dec 2012, 11:44
by slugish
Sweet... that should be able to handle what I need. Thanks!
Now, this actually confuses me somewhat... What is the difference between Manialib and Maniaplanet Web Services?
Re: PHP function to handle nickname colors/formatting?
Posted: 02 Dec 2012, 17:50
by The_Big_Boo
ManiaLib is a lightweight framework to create Manialinks (and web pages) following MVC paradigm, like Zend or Symfony (to take PHP examples).
Maniaplanet Web Services are, well, web services ^^ So they are only useful to request data about players, rankings, ... to send notifications, to make transactions and this kind of thing but it won't handle any UI at all.
Re: PHP function to handle nickname colors/formatting?
Posted: 03 Dec 2012, 09:58
by magnetik
You can also use JavaScript to parse maniaplanet style.
Take a look at
http://magnetik.github.com/maniaplanet-style-js-parser/
it's far from being perfect but still quite usable.
I'll publish a jQuery plugin to make the use easier during the week.
Re: PHP function to handle nickname colors/formatting?
Posted: 08 Dec 2012, 19:05
by slugish
Edit: Okay, so the below was after I had tested the script as simply a php file. If I open that file, the below is what shows up. However, if I embed that file in an iframe on my wordpress site, the unicode displays correctly. I have no idea how or why that works, but apparently I have it working now...
I have this working and it handles the colors/formatting great, but it appears to have some trouble with alt code/unicode. Is this an issue with the script, or is this perhaps related to the server I have it running on? Here is an example, I am using the script to parse both the server name and player names. The bottom right corner is an overlay of the page that I have the script running on.

Re: PHP function to handle nickname colors/formatting?
Posted: 10 Dec 2012, 18:45
by steppie
Your output page need to encode UTF-8 to show special characters
This should do the trick.
Code: Select all
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
Re: PHP function to handle nickname colors/formatting?
Posted: 13 Dec 2012, 13:58
by niarfman
Don't forget to write your file with utf8 character encoding, in case you want to display some special chars too.
This is possible with an editor like notepad++ (Menu: "Encoding"=>Convert to UTF-8).
Player list is already in UTF8 and will be displayed well with the line given by steppie.
Also I have a question in relation with this topic : Does Manialive include specifics fonts used in the game or should we use TAHOMA as usual with Tm ?
Re: PHP function to handle nickname colors/formatting?
Posted: 10 Jan 2013, 10:23
by magnetik
There are no font included.