Welcome
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 <dominic@dubdot.com>
*/
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.
Crazy Lady Discovers Rainbow in Garden Spinkler
What is oozing out of our ground that creates this sort of effect? Not just around our sun and moon any more. Everywhere we look. This cannot be natural. We all know it wasn't something that happened 20 years ago. We, as a nation, have got to ask ourselves "what the hell is going on?"
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.
Slydial
Amazing idea: Slydial. Lets you leave answering machine messages for someone without their phone ever ringing.
Organisation!
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...
Mutton Birds and Front Lawn, Bootleg Central
areligionofakind: here, and here. Below, Don Visits Harry:
Some of the stuff on that site is pretty amazing. Witness: Andy with Neil Finn, or The Queen's English with the Auckland Chamber Orchestra.
downforeveryoneorjustme.com
A natural extension of sites like istwitterdown.com, downforeveryoneorjustme.com provides the general case. With a pretty attractive interface, and a good sense of humour*, I think I'll be using it quite often.
* — they've thought of everything!