/**
  * @inheritDoc IFieldType::getInputHtml()
  *
  * @param string $name
  * @param mixed  $value
  *
  * @return string
  */
 public function getInputHtml($name, $value)
 {
     $configJs = $this->_getConfigJson();
     $this->_includeFieldResources($configJs);
     $id = craft()->templates->formatInputId($name);
     $localeId = isset($this->element) ? $this->element->locale : craft()->language;
     $settings = array('id' => craft()->templates->namespaceInputId($id), 'linkOptions' => $this->_getLinkOptions(), 'assetSources' => $this->_getAssetSources(), 'transforms' => $this->_getTransforms(), 'elementLocale' => $localeId, 'redactorConfig' => JsonHelper::decode(JsonHelper::removeComments($configJs)), 'redactorLang' => static::$_redactorLang);
     if (isset($this->model) && $this->model->translatable) {
         // Explicitly set the text direction
         $locale = craft()->i18n->getLocaleData($localeId);
         $settings['direction'] = $locale->getOrientation();
     }
     craft()->templates->includeJs('new Craft.RedactorIInput(' . JsonHelper::encode($settings) . ');');
     if ($value instanceof RichTextData) {
         $value = $value->getRawContent();
     }
     if (strpos($value, '{') !== false) {
         // Preserve the ref tags with hashes {type:id:url} => {type:id:url}#type:id
         $value = preg_replace_callback('/(href=|src=)([\'"])(\\{(\\w+\\:\\d+\\:' . HandleValidator::$handlePattern . ')\\})(#[^\'"#]+)?\\2/', function ($matches) {
             return $matches[1] . $matches[2] . $matches[3] . (!empty($matches[5]) ? $matches[5] : '') . '#' . $matches[4] . $matches[2];
         }, $value);
         // Now parse 'em
         $value = craft()->elements->parseRefs($value);
     }
     // Swap any <!--pagebreak-->'s with <hr>'s
     $value = str_replace('<!--pagebreak-->', '<hr class="redactor_pagebreak" style="display:none" unselectable="on" contenteditable="false" />', $value);
     return '<textarea id="' . $id . '" name="' . $name . '" style="display: none">' . htmlentities($value, ENT_NOQUOTES, 'UTF-8') . '</textarea>';
 }