예제 #1
0
	public function loadFromForm($formData)
	{
		if(!isset($formData[$this->name]))
			return;

		$this->value = str_replace("\r", "", trim($formData[$this->name]));
		if($this->value)
			$this->value = "<p>".str_replace("\n\n", "</p>\n\n<p>", $this->value)."</p>";	//transform line breaks into paragraphs
		$this->value = AAHelperForm::prepareTextForDb($this->value);
		$this->value = preg_replace("~>\n(<|\w)~ui", "><br/>\n\\1", $this->value);

		$notInParagraphTags = array('ol', 'ul', 'li', 'div', 'table', 'code', 'cite', 'thead', 'tbody', 'tr', 'td', 'pre', 'h[0-9]');
		$this->value = preg_replace("~<p>(<h[0-9]>.*?</h[0-9]>)<br\s*/?>\n(\w)~usi", "\\1\n<p>\\2", $this->value);
		$this->value = preg_replace("~<p>(<h[0-9]>.*?</h[0-9]>)</p>(<br\s*/?>)?~is", "\\1", $this->value);
		$this->value = preg_replace("~<p>\n*((<".implode(')|(<', $notInParagraphTags)."))~is", "\\1", $this->value);
		$this->value = preg_replace("~((</".implode('>)|(</', $notInParagraphTags).">)|(</h[0-9]>))\n*((</p>)|(<br\s*/?>))~is", "\\1", $this->value);
		$this->value = preg_replace("~<p>((</".implode('>)|(</', $notInParagraphTags)."))~i", "\\1", $this->value);	//crutch :(
		$this->value = preg_replace("~((<".implode('[^>]*>)|(<', $notInParagraphTags)."[^>]*>))</p>~i", "\\1", $this->value);
		$this->value = preg_replace("~((<".implode('[^>]*>)|(<', $notInParagraphTags)."[^>]*>))<br\s*/?>~i", "\\1", $this->value);
		$this->value = preg_replace_callback(
				'~(<(code)|(pre)[^>]*>)(.*?)(</(code)|(pre)>)~is', 
				create_function(
						'$matches',
						'return $matches[1].preg_replace("~(</?p>)|(<br\s*/?>)~i", "", $matches[4]).$matches[5];'
				),
				$this->value
		);
	}
예제 #2
0
	public function loadFromForm($formData)
	{
		if(!isset($formData[$this->name]))
			return;
		$this->value = str_replace("\r", "", trim($formData[$this->name]));
		$this->value = str_replace("\n", "<br/>", $this->value);
		$this->value = AAHelperForm::prepareTextForDb($this->value);
	}
예제 #3
0
	public function loadFromForm($formData)
	{
		$this->value = AAHelperForm::prepareTextForDb((string)$formData[$this->name]);
	}
예제 #4
0
	public function formInput(&$controller, $tagOptions=array())
	{
		ob_start();
		$inputName = $this->formInputName();

		$inputID = "i_{$inputName}";
		echo CHtml::label($this->label, $inputID);
		echo CHtml::tag('br');
		$tagOptions['id'] = $inputID;
		if($this->isReadonly)
			$tagOptions['disabled'] = true;
		if(!$this->allowNull)
			$tagOptions['required'] = 'required';
		if(!empty($this->options['pattern']))
			$tagOptions['pattern'] = $this->options['pattern'];
		if(isset($this->options['maxlength']))
			$tagOptions['maxlength'] = $this->options['maxlength'];
		echo CHtml::textField($inputName, AAHelperForm::prepareTextForForm(((string)$this->value ? $this->value : $this->defaultValue)), $tagOptions);

		return ob_get_clean();
	}