Recently I had cause to report on the usage staff at work made of the corporate intranet. This would ordinarily be a simple enough task if the logs were plain standard Apache logs. However, I was dealing with Oracle9iAS, a very different beast indeed. Oracle9iAS is built on top of a customised version of Apache and incorporates a caching proxy server, the so-called Webcache; an implementation of J2EE called OC4J (Oracle Containers for Java) and various other bells and whistles, making it something of a behamoth.
As you can see from my previous post, my first attempt at writing a WordPress Plugin was a success. This plugin is very simple and allows the user to embed a YouTube video into their post. The main function calls a callback function that replaces every occurrence of the tag ["youtube" video_id] (minus quotes) with a flash video corresponding to the video_id parameter.
Just paste the code below into a file called ‘youtube.php’ in your wp-content/plugins directory. You should then be able to activate it via the Plugins admin option. Once activated, you can place a YouTube video in your post by going to code-view and inserting ["youtube" video_id] (minus the quotes). The video_id parameter is the ‘v’ parameter in a YouTube URL. In the example below, the URL is http://www.youtube.com/watch?v=lL4L4Uv5rf0. Therefore, the video_id parameter should be lL4L4Uv5rf0. In the code below, you will need to remove the quotes around the word “youtube” in the regex on line 5, I had to put these in to display the code without it interpreting the tag… it’s a work in progress!
My work has recently taken a departure from the usual web development as I’ve been “borrowed” by the other development team to help out with a Java project. Now, my Java is reasonable sound but yesterday I came across a curious situation involving passing about the current object.
In common with a lot of languages, the current object is represented by the ‘this’ keyword. I wanted to pass ‘this’ to a static method of another class. Of course, I can’t refer to the object as ‘this’ in the static method context as that would be ambiguous insofar as it could refer to the class with the static method I’m working with. This pattern is often used with callbacks where for example you might want to register a class with a particular listener objcet. To avoid confusion, I named the actual parameter in the static method
that
I assumed that I would reference the fields and methods of the object using
that.someMethod()
rather than
this.someMethod()
This is where the fun begins. Let’s call the original object
SomeObject theObject
and I want to call the static method
SomeClass.doStaticMethod(SomeObject that)
I would call that method, from within theObject, using
SomeClass.doStaticMethod(this)
When in theObject, I have access to private fields and methods since private fields and methods are within scope. I assumed the same would be true when I passed “theObject” as “this” to “SomeClass.doStaticMethod(SomeObject that)”. However, when I actually try to access private fields such as “that.privateField”, it would appear that I no longer have access. I could create appropriate accessor methods, but that would defeat the idea of encapsulation.
Does anyone have any ideas? Am I missing some fundamental (and so obvious I missed it) rule of scope or object passing?
I’ve finally found time to start investigating some other PHP frameworks, and after some brief research I decided to start off with Symfony. All is going well and so far I’m impressed with what Symfony can do compared with CakePHP… with a few exceptions.
I initially tried following the My First Project tutorial, but hit problems pretty quickly. It would seem that there was a problem with the PHP SQLite extension. The phpinfo() function verified that SQLite was indeed installed, but I couldn’t get any further on that trail. After reading a number of forum posts on the issue, it became apparent I should recompile Apache and PHP. I’m still not that confident with Linux to do that so I left it at that.
Then I followed the Askeet tutorial with more success as this tutorial uses MySQL rather than SQLite. However, I can’t get the URL rewriting to work as it should. I’ve checked my Apache configuration, the .htacces file and still no luck. If I load http://<project>/question I get a 404 error. If I load http://<project>/index.php/question or http://<project>/frontend_dev.php/question all is well. I’ll press on with this tutorial until I hit a road block, but this is really bugging me. Again, a few forum posts suggest recompiling Apache and PHP. However, the extensions that should be included in the new build are already present according to phpinfo().
I’m currently running Fedora 7 which installs Apache and PHP in its own odd way. Perhaps I should start from scratch by removing Apache and PHP with yum and compiling both from source. Although as I said I’m kind of reluctant to do that. If anyone has any ideas – let me know!
Sitepoint have another competition on the go. The winner gets a copy of the new book “Principles of Beautiful Web Design”. The competition involves using CSS to style some simple markup that serves as an advert for the book. Unfortunately the markup hooks available for use with CSS are somewhat lean. I’ve given it a shot, as have others. Why don’t you have a go – you have until the 6th of April to enter as many entries as you like. Happy coding!