<?php
/*
 * Copyright (c) 2013, webvariants GbR, http://www.webvariants.de
 *
 * This file is released under the terms of the MIT license. You can find the
 * complete text in the attached LICENSE file or online at:
 *
 * http://www.opensource.org/licenses/mit-license.php
 */

/**
 * @ingroup form
 */
class sly_Form_Wymeditor extends sly_Form_Textarea {
	protected $fullWidth = false;
	protected $editor;

	public function __construct($name, $label, $value, $id = null) {
		parent::__construct($name, $label, $value, $id);
		$this->editor = WV14_WYMEditor::getSimpleEditor();
		$this->addClass('wymeditor');
		$this->addOuterClass('wymeditor-row');
	}

	public function useFullWidth($switch = true) {
		$this->fullWidth = (boolean) $switch;
		$this->fullWidth ? $this->addOuterClass('full-width') : $this->removeOuterClass('full-width');

		return $this;
	}

	/**
	 * return the editor instance of this form element
	 *
	 * @return WV14_WYMEditor
	 */
	public function getEditor() {
		return $this->editor;
	}

	public function render() {
		$this->editor->embed();
		return parent::render();
	}
}
