Something
Emporium

Archived News for August 2008

Organisation!

I've been organising my recording gear, tidying up the cables etc, as well as moving the racks to under my computer desk to make more room in the spare room. I can't use the massive server rack I got from work any more, so I decided I'd get a 3 space rack case. I ordered one from Cases.com.au, and I can't recommend them enough. very good prices, super quick shipping, and the case is very good quality. So everything is a lot cleaner now, I'm happy.

I'm thinking about rewiring my SSL compressor clone to be MIDI controlled, and writing a VST plugin that sends messages to it over the MIDI. It won't be too hard, but I'm still trying to think of the best way to handle the controls that are currently potentiometers. I haven't started cutting holes in the front panel of the case it's in, so it's not too late to decide. Need to decide if it should have an LCD display or not...

Symfony 1.1 Task Options in Windows

Symfony 1.1's tasks are pretty nice. They let you centralise all the administration of your website that would usually happen through a myriad of batch scripts. When you're writing a task, you'll probably define a command line option as follows:

$this->addOption('env', null, sfCommandOption::PARAMETER_OPTIONAL, 
'Changes the environment this task is run in', 'prod');

But if you're running Windows, any attempt to use your new command line option will be met with failure:

>symfony se:build-search --env="test"

The execution of task "se:build-search" failed.
- Too many arguments ("se:build-search test" given).

symfony se:build-search [--env[="..."]] [--force[="..."]]

The gotcha is that Symfony's example syntax for using the command line argument/option won't work with Windows' cmd.exe, because it considers the "=" sign to be an argument separator. To use an option, you'll want to do this:

>symfony se:build-search "--env=test"

That is, enclose the whole option, including the option name, in speech marks. That'll escape the equals sign.

Rich Text Editor Widget in Symfony 1.1

I was pretty amazed to discover that there doesn't seem to be a rich text editor widget for the new Symfony 1.1 forms framework. The forms part of the new version is fairly controversial, and it's not intended to be anything like backward compatible with 1.0 forms/validators, but I was genuinely suprised to see there wasn't a rich text editor out-of-the-box. Here's how to get one, fairly easily:

Install TinyMCE the same way you would in Symfony 1.0. This involves downloading TinyMCE, and making it web accessible. Then you have to uncomment and edit the rich_text_js_dir directive in your app's settings.yml.

To check you have TinyMCE installed correctly, before continuing, create a template with:

<?php use_helper('Form') ?>
<?php echo textarea_tag('some', 'content',
  array('rich' => true)) ?>

Then view the template. You should see the TinyMCE editor. Now we just need to get it working with the new forms system. Introducing myWidgetFormRichTextarea:

/**
 * myWidgetFormRichTextarea represents a rich text editor.
 *
 * @author     Dominic Scheirlinck <[email protected]>
 */
class myWidgetFormRichTextarea extends sfWidgetFormTextarea
{
  
/**
   * @param array $options     An array of options
   * @param array $attributes  An array of default HTML attributes
   *
   * @see sfWidgetForm
   */
  
protected function configure($options = array(), $attributes = array())
  {
    
$this->addOption('editor''tinymce');
    
$this->addOption('tinymce_options''');
    
$this->addOption('tinymce_gzip'false);
    
$this->addOption('css'false);
    
    
parent::configure($options$attributes);
  }
  
  
/**
   * @param  string $name        The element name
   * @param  string $value       The value displayed in this widget
   * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
   * @param  array  $errors      An array of errors for the field
   *
   * @return string An HTML tag string
   *
   * @see sfWidgetForm
   */
  
public function render($name$value null$attributes = array(), $errors = array())
  {
    
$editorClass 'sfRichTextEditor' $this->toCanonicalCase($this->getOption('editor'));
    if (!
class_exists($editorClass)) {
      throw new 
sfConfigurationException(sprintf('The rich text editor "%s" does not exist.'$editorClass));
    }
    
    
$editor = new $editorClass();
    if (!
in_array('sfRichTextEditor'class_parents($editor))) {
      throw new 
sfConfigurationException(sprintf('The editor "%s" must extend sfRichTextEditor.'$editor));
    }

    
$attributes array_merge($attributes$this->getOptions());
    
$editor->initialize($name$value$attributes);
    return 
$editor->toHTML();
  }
  
  
/**
   * Converts a lower-case editor name to its canonical case
   *
   * @param string $editor
   * @return string
   */
  
private function toCanonicalCase($editor)
  {
    switch (
$editor) {
      case 
'tinymce':
        return 
'TinyMCE';
      case 
'fck':
        return 
'FCK';
    }
  }
}

If you're just using it to replace a textarea, you don't need to do anything much to use the rich widget – it'll use your existing rows and cols html attributes, and make the rich editor the right size automatically.

This might not work with future versions of Symfony, because it relies on the sfRichTextEditorTinyMCE class, which I think is only used to provide backward compatibility with 1.0.

Theft of Photons

I like this sentence, from a recent Boing Boing post:

Just another skirmish in the war against photography, as the brave security guards of the world prevent the theft of photons from our poor, helpless inanimate objects.

There isn't much that retains its magic once reductionism has had its way.

The Danish Poet

Got a spare 15 minutes? The Danish Poet won an Oscar for best animated short film in 2007. It's fantastic.

The music, the animation style and especially the story: very cool. If you click through to the Youtube detail page, you can watch it in high quality.

John Hapeta, and the accused

What's wrong with banning the publication of names from the internet, but not other forms of media? Well, if it works, nothing. It's a good step to take, for all the reasons Judge Harvey outlines, and for all the reasons outlined in other commentary.

But here's the thing: it won't work. It can't work. Perhaps it might have had a chance ten years ago, but now? Nope.

  • Anyone who isn't bound by New Zealand law can publish the names. And the internet has a large enough population of technically minded libertarians, anarchists, and anti-authoritarians to see that publication happens.
  • How do they get the names then? Well, radio steaming isn't covered by the suppression order, so it's very trivial. All it takes is one overseas internet user, listening in to Radio New Zealand during the hourly news broadcast.
  • And once they've gone and written their blog post telling the world? New Zealand commentary on the case will continue. The victim's name is enough for any jurors to pull up any discussion out there. And anybody curious enough will be able to find the dozens of international sites that do list the names of the accused.

That his idea won't work should be reason enough to condemn Judge Harvey's actions. But it's worse than that. Judge Harvey has shown that he's aware of the viral nature of the internet. Surely, then, he would have realised that a suppression order like the one he issued would draw more attention, more discussion than one that didn't relegate online expression to second-class status. It actively hurts the accused, and has the opposite effect than that stated.

Newest Posts