CommonKML
Contents
Why commonKML ?
This project was developed from my (ODBC3) coding of a KML website using the PHP language. I wanted a way to improve my webpages with the following needs:
- re-use code where possible for common routines
- simplify the code so it was shorter and more readable
- reduce errors made in coding
- extend the KML with new features made from existing ones
- improve debugging
- Provide International Language support
After coding various dynamic KML pages including a game, I devised a library of routines that I could include into any webpage. Here is the worst part of it:
- Extra level of coding to learn
- hides the real KML code
- needs to load an external library to work
- attribute names are not obvious
That last listed trade off I have made is that the purpose of attributes in a tag is nolonger obvious as the attribute name is not shown. Consider:
<TEXT coords='10,20' font='0' pen='65'>hello</TEXT> It is clear that 65 belongs to pen, and the 0 is a font attribute.
This becomes: text(10,20,0,65,'hello');
This is shorter, but it is not obvious that the 3rd paramter is for the font, and 4th is pen. I found out nothing shows up when I have a font of 65, and the colour is 0 (transparent).
The answer is to use meaingful contants: text(10,20,FONT0,RED,'hello');
So with this format there is a great benefit of using the library. You do not have to keep swapping between KML and PHP so much, and my colour coded editor displays the PHP much better than the KML (unless I define all the syntax of KML).
Debugging I built a feature into the library that will make the KML visible when viewed on a normal computer browser such as Netscape or IE. The trick was to make the output text/plain. However to overcome a bug in IE, I also have to hide the <?xml /> tag. The code will work as normal on a Kiss player and in a KML browser program, as these both have the URL parameter of PlayerBrand.
If you need to review the contents of the commonkml.php that is on your web browser, then just put the url to it in your PC browser.
Future The current function list does not cover all the existing KML functions. For example, there is no support for the background gradients. I shall extend these as I find time or the need arises. Some future inclusions may be:
- Placement of background images (align left, right, sizing etc)
- Word wrap (done, but more options)
- Multiple pages of text
- Text formating and flow around images
- Handle the new KML version 2
- Simple menu generation
- grouping of functions, then call the group like a new function call.
- Get label of bottom left key (either Clear or Del depending on model)
- Convert http://somewhere.com to http://somewhere.com/ in abs_url().
- Filled rectangle or rectangle around some text. Good for menu highlight.
Version
1.0
http://mpcclub.com/modules.php?name=Downloads&d_op=getit&lid=323#dl
- Allow @ to skip error reporting
- img() to add images
- flowtext() now works around images
- global $commonkmlroot is system file location of the commonkml.php
- use fontfile from $commonkmlroot.'/verdana.ttf' so it works on non windows
- major tidy up of layout and tabbing
- <hr/ support in htmlparse
- Colour support for name=eg.'RED' or number eg. 65 or RED constant (later allow #FF0000)
- <line> removed as it is not valid KML
- $ScreenWidth,$ScreenHeight defined global and removed all 720x480
0.9
- querystring() to merge and preserve parameters
- keyclick() now has comment option
- correct passing of + in a url
- Keyboard.php sample script
- Can display << char and >> char
- ontimer() tag() rewritten
- maxmenuitems() Determine maximum possible menuitems
- Added thickness to rect($x,$y,$w,$h,$pen,$thick=1)
- background('#19a819') is <BACKGROUND vgradient='25,168,25-25,168,25' />
- $PlayerModel set and defaults to DP-500
- Display euro for KMLBrowser and DP558. Fallback to 'e' on other models
0.8d
http://mpcclub.com/modules.php?name=Downloads&d_op=getit&lid=259#dl
- Even more menu styles
- Removed an incorect echo from OXO game script.
0.8c
- Changed error reporting text. Added line number
- More options for menus including command bar for 5xx and 558 with page numbers
0.8b 7th Feb 2005
- Fixed magic quotes in showurl.php
- keysinc.php for key labelling etc.
- Show all warnings and errors if passing ?debug in PC browser
- menuinc.php for predefined menus
0.8 1st Feb 2005
- Trap warning and errors and show as KML
- Display extra accent,currency and graphic characters.
- Add textbold()
- Preliminary version of HTML parsing with parsehtml()
0.7 23rd Jan 2005
- Fixed OXO player pick
- More tweaks to underline and strikeout
- Add aligntextleft() aligntextcenter() aligntextright()
- Default fip speed=4
- Allow for text offset bug in KMLBrowser shown with aligntext.php
- Allow '?arg=value' as short hand for url to goto current script
0.6 14th Jan 2005 (ATTENTION: Enable GD for PHP)
- URL encode all query strings and allow uppercase chars.
- Eg. gotoself('name=Albert Zeal who said "who's here?"&age=52');
- text() uses special version of htmlentities() table
- header('Content-type: text/html; charset=utf-8');
- textshadow uses bigger shadow for bigger font
- Use ScreenWidth, ScreenHeight in clearpage()
- Align text over images/bar-3.gif and images/bar-7.gif in samples
- fontwidth($font) gives average font width in pixels
- tempimagename() gets a cache temp JPEG name
0.5 10th Jan 2005
- Request the commonkml.php directly, will show it as text
- Updated this readme file with latest work.
- Samples use new colour and FONT constants, and clearpage().
- Fix undefined variable warning when using single argument to fip('text');
- Removed need to echo functions and removed echo from samples.
- URL encode all query strings and allow uppercase chars.
- Eg. gotoself('name=Albert Zeal who said "who's here?"&age=52');
0.4 9th Jan 2005
http://mpcclub.com/modules.php?name=Downloads&d_op=getit&lid=235#dl
- Added colour defines eg. BLACK (not all examples use this yet)
0.3 5th Jan 2005
- Fixed BUTTON_0
- Added new BUTTON codes
- Fixed PL and NL language codes.
- Added clearpage()
- Cleaned up global variables to use $_GET[] instead eg. $_GET['ScreenHeight']
- Added FONT0-FONT4
0.2 16th Dec 2004
- Allow relative or absolute urls or keep $$PREVIOUSDOCUMENT$$.
- Added textshadow
- wraptext improved and truncates text that would appear below bottom of screen.
- htmlspecialchars() performed on all displayed text.
- fip can have default speed and intensity
0.1 12th Nov 2004
- Initial release