Posts Tagged kohana
In a quick followup to yesterday’s building and releasing autoasset, I’ve created another module to do something simple and portable for Kohana 2.x. This module, kotidy, uses the PHP Tidy library to clean up the HTML output immediately prior to display. Even though the HTML is not seen by the end user, I find myself OCD about this kind of stuff and want to know that my source code is clean, even if most people will never see it.
Just like autoasset, kotidy uses the Event system to hook a basic function in place to use the tidy library to clean up the output. Other than adding this module to your module list in the main config file, no work is required on your part, unless you want to customize the config data being sent to Tidy::parseString(), of course.
On a similar note, modules like this are one of the main reasons why I am launching ko23.net. I think Kohana 2.x is a fantastic framework, and if a large community arose to provide modules that are just generally useful, then Kohana 2.x could really shine.
I’ve been a Kohana user for about a year now, and every major update pleases me less than the last. I’m considering starting a community dedicated to Kohana 2.3, built around maintaining documentation (since the official site already pulled the Doxygen docs, how long until they pull the documentation wiki?), creating new modules and generally working on preserving the Kohana 2.3 legacy. Would anyone be interested in being a part of this community?
I’d like to stress that I am in no way trying to insult the developers and maintainers of Kohana through this project. Their work has been absolutely amazing, but just as they forked from CodeIgnitor when they felt it was no longer serving their needs as developers, so now am I feeling that Kohana no longer serves my needs as a developer.
I’m setting the project up at ko23.net. I’ll begin adding some functionality such as forums and module hosting / rating.
It’s been a little over six months since I first began to use Kohana framework for all PHP development, and I thoroughly love the system. The only issue I’ve had with Kohana is the lack of built in, intuitive support for dynamic themes. I was unable to find an easy method to set up a theme that automatically wraps itself around all pages, while remaining dynamic enough to change certain elements on a page to page basis.
Over the past few days, I have been exploring methods to do this, with the following requirements:
- Keep all theme files separate from the application
- Require no changes to existing controllers and views to implement or change a theme
- Allow multiple applications on the same Kohana build to use the same theme
- Provide support for cascading themes
After a few failed attempts, I have found a solution that covers all four requirements and is pretty easy to implement. Of course, it is easier to implement this from the start, but if you have an existing Kohana site, it shouldn’t be too difficult to integrate this theming setup into the site. The concept of the theme is simple: create a theme as a module and then use hooks to implement the theme elements as appropriate.
In a recent Kohana project, I came across a somewhat odd PHP scenario – I had a multidimensional array that I needed to compress to a single dimensional array, but retaining all of the non array values. Basically, I need to make this change:
Array ( to => Array ( 0 => stevep 1 => bobw ) bcc => Array ( 0 => paulj ) ) Array ( 0 => stevep 1 => bobw 2 => paulj )
I looked around a bit for an existing PHP snippet to do just this, but they were all overly complex and used recursive callback functions. I had a feeling I could pull this off in a much more clean fashion. I toyed around a bit with the array functions and the ArrayObject library, and this is what I settled with:
$new_array = new ArrayObject(); array_walk_recursive($old_array, array($new_array, 'offsetSet')); $flattened_array = array_keys($new_array->getArrayCopy());
The big drawback is the way ArrayObect::offsetSet() accepts its parameters, compared to how array_walk_recursive() sends the callback parameters; they are reversed. This causes the values to become keys, which has the effect of canceling out duplicate values. If your script needs duplicate values to remain intact, then this solution won’t work for you. Otherwise, it should work out just fine.