Wordpress and phpOpenTracker problems…
Has anyone else tried to use phpOpenTracker with Wordpress? Whenever I do I get strange DB error messages. If you have used the two together, either unsuccessfully or not, please let me know.
Has anyone else tried to use phpOpenTracker with Wordpress? Whenever I do I get strange DB error messages. If you have used the two together, either unsuccessfully or not, please let me know.
Windows Media Player will only play .m3u playlists two levels deep…
You can include a playlist inside another playlist and it copes fine. If you include a playlists inside a playlist inside a playlist, the innermost one doesn’t get played.
Why do I tell you this? I decided to try and create a Pimsleur-style CD for Finnish. But to save on effort and increase modularity everything is done in bits and joined together with .m3u files. Since Windows Media Player can’t cope with the nesting though, I had to write a PHP to dump them all in one file (I’m expecting to hit a limit on the amount of songs in a playlist soon).
By the way a .m3u (playlist) is really complicated… it’s a list of URLs separated by newlines…
The PHP Code Generator now handles docblock style comments properly as well as method keywords. For static, abstract and final keywords, if one is present in any definition of a method it will in the output. For visibility keywords the method will have the “most public” specified. See my previous code generator post for more info.
I’ve completed a basic version of a class that (sort of) extends SimpleXML. When I say sort of I mean it extends a wrapper class (ExtendXML) that inlcludes all the functionality of SimpleXML.
Download the following to try it out:
The object is created the same way as ExtendXML. After creating it you must also call:
// $mf is a MicroformatXML object
$mf->mf_init();`
This adds a new property, $mfHCards, which is an array of hCards. You can access the various hCard values as properties of these objects. As an example:
$mf = MicroformatXML::create\_from\_file($xmlFile);
$mf->mf\_init();
foreach ($mf->mfHCards as $hCard) {
print $hCard->fn .' ';
}
Please note this is a very early version that is undocumented and largely untested. It also doesn’t contain every hCard property.
I posted a while ago about problems with extending SimpleXML (which I intend to do so I can add automatic microformat support). Well I think I’ve come up with a solution.
I’ve created a class called ExtendXML that is completely extendable (see the other post for an explanation of why SimpleXML isn’t extendable) that provides all of the functionality of SimpleXML.
The initial call is similar to using SimpleXML (except I made the functions static class methods instead):
ExtendXML::load_string($xmlString, [$class, [$simpleClass]]);` `ExtendXML::load_file($xmlFile, [$class, [$simpleClass]]);`
The $class argument contains the name of the class that will be returned. This should extend ExtendXML and defaults to ExtendXML.
The $simpleClass argument contains the name of the SimpleXML class that will be passed to SimpleXML functions. This should extend SimpleXMLElement and defaults to SimpleXMLElement.
The object returned can then be used the same as a SimpleXMLElement object.
I haven’t tested it much or documented it yet, but it supports child tags (returning objects are of the class ExtendXML or whatever you specified), attributes and xpath expressions.
PHP5, OOP, ArrayAccess, SPL, programming, code, tutorial, microformats, XML, SimpleXML
I wrote a post about my attempts to extend SimpleXML to support microformats. Well it’s not as it easy as it seems.
You can’t define new properties of a class extending SimpleXMLElement. Well you can define them but they don’t work - when you access them they always return a SimpleXMLElement object (or actually an object of whatever class you defined).
I’ve tried overriding __get and __set and neither work so the only thing I can think of is to create a new class that delegates most of it’s work to SimpleXMLElement.
I’m writing a PHP5 object that extends SimpleXML to automatically add various microformats. So you could do, for instance, the following:
$xml = SimpleXML\_load\_file('test.xml');
foreach ($xml->hEvent as $event) {
print $event->original();
}
This would print the original HTML of every hEvent found in the HTML document. XML, PHP, PHP5, microformats, hCard, hReview, hCalendar
I’ve started working on a class-based code generation utility for PHP (in PHP). Like the scripting engine it’s working out simpler than I expected. Quite how powerful or indeed useful it could be is yet to be seen. The way it works is by allowing you to define fragments of classes. For example the Singleton fragment is:
class !className {
static private $instance;
private function \_\_construct() {
// Code Start
// Code End
}
static public function Init() {
if (!self::$instance) {
self::$instance = new !className();
}
return self::$instance;
}
}
You create a class with some number of fragments. Each successive fragment adds specified method and properties to the class. If two (or more) fragments define the same method (probably common with constructors for instance) the the code for the second fragment get’s added in the //Code Start ... //Code End sections. Ultimately you will be able to change your model (defined in XML and it will update your code accordingly, maintaining all the code within the //Code Start ... //Code End sections.
Since I’ve been making random DOM and JavaScript posts recently I thought I’d share a clever bog post I found cleverly called DOM-foolery. It describes a relatively simple way to make images in web pages have curved corners.
That’s the name I’ve come up with for the game since it’s vaguley based on Cash Wars. Or at least will be. I’ve started adding descriptions to towns. There are a few issues still though, most notably the existence of multiple towns with the same name which I am eliminating (I’m only intending to have the largest 100 towns).