$form = new Ansel_Form_Ecard($vars, $title);
$renderer = new Horde_Form_Renderer();
-$editor = $injector->getInstance('Horde_Editor')->getEditor('ckeditor', array('id' => 'ecard_comments'));
+$editor = $injector->getInstance('Horde_Editor')->initialize(array('id' => 'ecard_comments'));
if ($editor->supportedByBrowser()) {
$vars->set('rtemode', 1);
$form->addHidden('', 'rtemode', 'text', false);
+++ /dev/null
-<?php
-/**
- * @category Horde
- * @package Core
- */
-class Horde_Core_Binder_Editor implements Horde_Injector_Binder
-{
- public function create(Horde_Injector $injector)
- {
- return new Horde_Core_Factory_Editor($injector);
- }
-
- public function equals(Horde_Injector_Binder $binder)
- {
- return false;
- }
-}
* @return Horde_Editor The singleton editor instance.
* @throws Horde_Editor_Exception
*/
- public function getEditor($driver, $params = array())
+ public function create()
{
- $browser = $this->_injector->getInstance('Horde_Browser');
- if (!$browser->hasFeature('rte')) {
- return Horde_Editor::factory();
- }
-
- $params = array_merge(
- Horde::getDriverConfig('editor', $driver),
- $params,
- array(
- 'browser' => $browser
- )
- );
-
- return Horde_Editor::factory($driver, $params);
+ return $this->_injector->getInstance('Horde_Editor_Ckeditor');
}
-
}
@htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset));
if ($var->type->hasHelper('rte')) {
- $GLOBALS['injector']->getInstance('Horde_Editor')->getEditor('ckeditor', array('id' => $varname, 'relativelinks' => $var->type->hasHelper('relativelinks')));
+ $GLOBALS['injector']->getInstance('Horde_Editor')->initialize(array('id' => $varname, 'relativelinks' => $var->type->hasHelper('relativelinks')));
}
if ($var->type->hasHelper() && $browser->hasFeature('javascript')) {
'Horde_Core_Controller_RequestMapper',
'getRequestConfiguration',
),
+ 'Horde_Editor' => array(
+ 'Horde_Core_Factor_Editor',
+ 'create',
+ ),
'Horde_Kolab_Server_Composite' => array(
'Horde_Core_Factory_KolabServer',
'getComposite',
<file name="DbBase.php" role="php" />
<file name="DbPear.php" role="php" />
<file name="Dns.php" role="php" />
- <file name="Editor.php" role="php" />
<file name="Facebook.php" role="php" />
<file name="Group.php" role="php" />
<file name="History.php" role="php" />
<install as="Horde/Core/Binder/DbBase.php" name="lib/Horde/Core/Binder/DbBase.php" />
<install as="Horde/Core/Binder/DbPear.php" name="lib/Horde/Core/Binder/DbPear.php" />
<install as="Horde/Core/Binder/Dns.php" name="lib/Horde/Core/Binder/Dns.php" />
- <install as="Horde/Core/Binder/Editor.php" name="lib/Horde/Core/Binder/Editor.php" />
<install as="Horde/Core/Binder/Facebook.php" name="lib/Horde/Core/Binder/Facebook.php" />
<install as="Horde/Core/Binder/Group.php" name="lib/Horde/Core/Binder/Group.php" />
<install as="Horde/Core/Binder/History.php" name="lib/Horde/Core/Binder/History.php" />
protected $_js = '';
/**
- * Attempts to return a concrete instance based on $driver.
- *
- * @param string $driver The type of concrete subclass to return.
- * @param array $params A hash containing any additional configuration
- * or connection parameters a subclass might need.
- *
- * @return Horde_Editor The newly created concrete instance.
- * @throws Horde_Editor_Exception.
- */
- static public function factory($driver = null, $params = null)
- {
- $driver = ucfirst(basename($driver));
- if (empty($driver) || (strcmp($driver, 'None') == 0)) {
- return new Horde_Editor();
- }
-
- $class = __CLASS__ . '_' . $driver;
- if (class_exists($class)) {
- return new $class($params);
- }
-
- throw new Horde_Editor_Exception('Driver ' . $driver . ' not found');
- }
-
- /**
* Constructor.
*
* @param array $params The following configuration parameters:
* 'browser' - (Horde_Browser) A browser object.
* </pre>
*/
- public function __construct($params = array())
+ public function __construct(Horde_Browser $browser)
+ {
+ $this->_browser = $params['browser'];
+ }
+
+ public function initialize(array $params = array())
{
- if (isset($params['browser'])) {
- $this->_browser = $params['browser'];
- }
}
/**
{
return false;
}
-
- /**
- * List the available editors.
- *
- * @return array List of available editors.
- */
- static public function availableEditors()
- {
- $eds = array();
-
- foreach (glob(dirname(__FILE__) . '/Editor/*.php') as $val) {
- $eds[] = basename($val, '.php');
- }
-
- return $eds;
- }
-
}
class Horde_Editor_Ckeditor extends Horde_Editor
{
/**
- * Constructor.
- *
* @param array $params The following configuration parameters:
* <pre>
* 'basic' - (boolean) Load "basic" editor (a small javascript stub that
* instead be stored for access via getJS().
* </pre>
*/
- public function __construct(array $params = array())
+ public function initialize(array $params = array())
{
- $params = array_merge(array(
- 'config' => array()
- ), $params);
-
- parent::__construct($params);
-
if (!$this->supportedByBrowser()) {
return;
}
+ $params = array_merge(array(
+ 'config' => array()
+ ), $params);
+
$ck_file = empty($params['basic'])
? 'ckeditor.js'
: 'ckeditor_basic.js';
return false;
}
}
-
}
htmlspecialchars($var->getValue($vars)));
if ($var->type->hasHelper('rte')) {
- $GLOBALS['injector']->getInstance('Horde_Editor')->getEditor('ckeditor', array('id' => $var->getVarName()));
+ $GLOBALS['injector']->getInstance('Horde_Editor')->initialize(array('id' => $var->getVarName()));
}
if ($var->type->hasHelper() && $browser->hasFeature('javascript')) {
--- /dev/null
+form tweaks:
+Thanks for moving this to a public port, Lowell. Based on Chuck's request,
+I do have a couple suggestions for making the form more easily
+customizable. While it may seem like overkill, I find the best bet is to
+follow this pattern:
+<div>
+<div><label></label></div>
+<div><input /></div>
+</div>
+
+The reason I prefer to do this is that it negates the need for <br> tags
+since divs are block-level elements (using the br tag is technically
+considered a non-semantic tag, and therefore bad practice). It also allows
+you, through a stylesheet, to control whether or not the labels are above
+the fields or to the side, just by adding classnames to the containing
+divs.
+
+A couple of other suggestions: the label tags should have a "for"
+attribute that matches the id value of the input they're referring to. This
+is for accessibility reasons, and helps aid in tab indexing for
+keyboard-oriented users. While we're talking about labels, it might be a
+good idea to remove the colon after each label. It's better to group
+related fields with white-space, and actually makes the form look less
+complicated, believe it or not.
+
+Also, since the HTML 4.01 and XHTML 1.0 spec, the "name" attribute has
+been replaced by the "id" attribute. You can safely remove the "name"
+attribute from your form inputs and use "id" instead, which will allow for
+compatibility with either doctype in any A-Grade browsers.
}
if ($mime_type == 'text/html') {
- $injector->getInstance('Horde_Editor')->getEditor('ckeditor', array('id' => 'content'));
+ $injector->getInstance('Horde_Editor')->initialize(array('id' => 'content'));
}
require GOLLEM_TEMPLATES . '/common-header.inc';
Gollem::status();
/* Is the HTML editor available? */
$imp_ui = new IMP_Ui_Compose();
- $editor = $GLOBALS['injector']->getInstance('Horde_Editor')->getEditor('Ckeditor', array('no_notify' => true));
- $sess['rteavail'] = $editor->supportedByBrowser();
+ $sess['rteavail'] = $GLOBALS['injector']->getInstance('Horde_Editor')->supportedByBrowser();
/* Determine view. */
$setcookie = false;
$ui->suppress[] = 'signature_html_select';
} else {
Horde::addScriptFile('signaturehtml.js', 'imp');
- $GLOBALS['injector']->getInstance('Horde_Editor')->getEditor('Ckeditor', array('id' => 'signature_html'));
+ $GLOBALS['injector']->getInstance('Horde_Editor')->initialize(array('id' => 'signature_html'));
}
break;
$stationery = $GLOBALS['injector']->getInstance('IMP_Compose_Stationery');
if ($ob->type == 'html') {
- $GLOBALS['injector']->getInstance('Horde_Editor')->getEditor('Ckeditor', array('id' => 'content'));
+ $GLOBALS['injector']->getInstance('Horde_Editor')->initialize(array('id' => 'content'));
}
$t = $GLOBALS['injector']->createInstance('Horde_Template');
*/
public function initRTE($basic = false)
{
- $GLOBALS['injector']->getInstance('Horde_Editor')->getEditor('Ckeditor', array('basic' => $basic));
+ $GLOBALS['injector']->getInstance('Horde_Editor')->initialize(array('basic' => $basic));
$font_family = $GLOBALS['prefs']->getValue('compose_html_font_family');
if (!$font_family) {
// Add editor now to avoud JS error notifications no redirect
foreach ($conf['attributes']['languages'] as $key) {
- $injector->getInstance('Horde_Editor')->getEditor('Ckeditor', array('id' => 'content_' . $key));
+ $injector->getInstance('Horde_Editor')->initialize(array('id' => 'content_' . $key));
}
require_once NEWS_TEMPLATES . '/common-header.inc';