can you get more random?

I18n of sfSimpleForumPlugin

January 19th, 2009 Posted in geeky stuff | No Comments »

The sfSimpleForum plugin is a great way to quickly add a forum to a site, but it doesn’t handle multi-lingual sites, so here are my notes on how to add this feature.

1. Edit plugins/sfSimpleForumPlugin/config/schema.yml, add the culture field to the sf_simple_forum_category table :

lang:     { type: varchar, size: 7 }

My thinking is that only the categories need an added lang field, as all forums belong to a category, and all posts belong to a forum, so the language of a post is implicit in its forum and category. Note I’m using ‘lang’ and not ‘culture’ here, as culture seems to have a specific meaning in symfony, and is used when an object can exist with several cultures, so a category would exist in all languages. However in this case, the french site could have a diferent set of categories to the english site, so it’s not appropriate to use the field name ‘culture’.

2. Add culture to the test data :

sfSimpleForumCategory:
  c1:
    name:        Public Boards
    description: We talk about stuff here.
    rank:        1
    culture:     en_GB
  c2:
    name:        Miscellaneous
    description: Secret matters
    rank:        2
    culture:     en_GB
  c3:
    name:        Alleatoire
    description: Les choses alleatoires
    rank:        1
    culture:     fr_FR

3. Select by culture when getting list of all categories in plugins/sfSimpleForumPlugin/lib/model/plugin/PluginsfSimpleForumForumPeer.php:

public static function getAllOrderedByCategory()
{
  $c = new Criteria();
  $c->addJoin(self::CATEGORY_ID, sfSimpleForumCategoryPeer::ID);
  $c->add(sfSimpleForumCategoryPeer::CULTURE, sfContext::getInstance()->getUser()->getCulture());
  $c->addAscendingOrderByColumn(sfSimpleForumCategoryPeer::RANK);
  $c->addAscendingOrderByColumn(self::RANK);return self::doSelectJoinCategoryLeftJoinPost($c);
}

4. Add culture to admin interface in plugins/sfSimpleForumPlugin/modules/sfSimpleForumCategoryAdmin/config/generator.yml :

list:
  title: Category Administration
  display: [=name, description, rank, lang]
edit:
  title: Edit category "%%name%%"
  display: [name, description, rank, _lang, _forums]

5. Add set_culture partial in plugins/sfSimpleForumPlugin/modules/sfSimpleForumCategoryAdmin/templates/_lang.php :

< ?php
use_helper('Utils');
$cultures = array('en_GB' => 'English', 'fr_FR' => 'French', 'de_DE' => 'German');
echo select_culture_tag('sf_simple_forum_category[lang]', $sf_simple_forum_category->getLang(), $cultures, array('id' => 'lang'));

6. add select_culture_tag function in apps/backend/lib/helper/UtilsHelper.php :

function select_culture_tag($name, $selected = null, $cultures = array(), $options = array())
{
$c = new sfCultureInfo(sfContext::getInstance()->getUser()->getCulture());
if (! is_array($cultures)) {
$cultures = $c->getCultures();
}
if ($culture_option = _get_option($options, 'cultures'))
{
foreach ($cultures as $key => $value)
{
if (!in_array($key, $culture_option))
{
unset($cultures[$key]);
}
}
}
asort($cultures);
$option_tags = options_for_select($cultures, $selected);
return select_tag($name, $option_tags, $options);
}

Share/Save/Bookmark

Test from phone

January 19th, 2009 Posted in geeky stuff | No Comments »

Not much to say, the clue is in the title ;)

Share/Save/Bookmark

Annapurna Circuit

December 2nd, 2008 Posted in travel | No Comments »

Britta suggested doing the Annapurna trail sometime early next year. As part of my initial research, here’s some links with more information :

If you know of any more good sources of information, let me know

Share/Save/Bookmark

The world’s ugliest buildings

November 15th, 2008 Posted in General | No Comments »

Virtual Tourist have just published a press release listing (in their opinion) the worlds ugliest buildings. While you can argue with their choice (I quite like Liverpool Cathedral and I don’t find Tour Montparnasse in Paris that much of an eyesore), it’s a shame they didn’t spend ore time promoting the article on their site. the link from the article at Yahoo ! went straight to the reuters site, and I had to spend a few minutes on VirtualTourist before I found the press release. It would have been nice to have the article promoted in the virtual tourist home page, with links to photos on their site. Yet another missed opportunity I guess.

Hmm what to do today. As I’m in Barcelona, I think I’ll have lunch at Quimet & Quimet, a wonderful little tapas bar in Poble Sec. Or maybe I’ll just spend the rest of the morning looking out over Plaça Vicenç Martorell here at Chelo, with another one of their amazing fruit juices.

Back to work on monday. What joy!

Share/Save/Bookmark

Blind pilot lands plane

November 7th, 2008 Posted in General | No Comments »

A pretty incredible story from the BBC, a blind pilot landed a plane after he had a stroke whilst flying and loosing his sight.

I’ve never been very good at flying, this is the sort of thing that makes me more sure than ever that we’re better off with both feet on the ground.

Share/Save/Bookmark

Vegetarian Paris

October 30th, 2008 Posted in food and drink | No Comments »

Being a vegetarian in France isn’t easy. I have a couple of hardcore (ex-)vegetarian friends who moved to France and have moved back to the dark side. Its more understandable when you realise the almost complete lack of understanding of vegetarianism amongst the local population. Asking for a vegetable salad “sans viande” will often result in a chicken salad, as apparently chicken isn’t meat in the french sense of the word. Vegetarian salad with bacon is another common dish, and when asking for the version ’sans bacon’ the salad will return with the bacon bits (mostly) picked out by hand.

So it’s good to know that there are more and more vegetarian restaurants appearing in Paris, here are a couple of vegetarian resources I’ve found recently:

I also discovered v3ggie.com, a vegetarian search engine which gives interesting results, and has a greate recipe search feature.

Share/Save/Bookmark

Vacation in Paris

August 2nd, 2008 Posted in General, travel | No Comments »

My studio is available to rent for 4 days in August, so if you fancy a short break in Paris, staying in an apartment by Canal st Martin, let me know.

Share/Save/Bookmark

More great restaurants in Barcelona

July 25th, 2008 Posted in food and drink, travel | No Comments »

I’m back in Barcelona, and have been trying out some more restaurants. I’ve been told that catalonians don’t go in for tapas, and the tapas restaurants in Barcelona are only for tourists, but I’m still a fan. For a great tapas restaurant, try Flauta in eixample, an unpretentious, welcoming place, great for something to eat before going out for a drink in the area. Or for something a little more classy, my two discoveries this week are Botega Sepulveda and Los Caracoles

Share/Save/Bookmark

Tea

July 18th, 2008 Posted in General | No Comments »

Just heard on BBC Radio 4:

“We all know that tea is one of lifes essentials, and I for one can’t help having a deep suspicion of anyone that doesn’t like tea”

Well I’d agree with that!

Share/Save/Bookmark

Sonar 2008 Roundup

June 27th, 2008 Posted in General | No Comments »

I’m back from Sonar, and the first thing on my mind is reserving for next year. Unfurtunately I didn’t get to see as much as I would have liked, due to other commitments. In fact, I only made it to the friday night, but that alone was worth it. Madness were excellent, Richie Hawtin was incredible, Justice were amazing. And arriving back in Barcelona on the bus as the sun was rising over the port was unforgettable.

Next year I’ll be there again, and I’ll definitely be going to more of the daytime concerts.

Share/Save/Bookmark