本文整理匯總了PHP中JsonHelper::removeComments方法的典型用法代碼示例。如果您正苦於以下問題:PHP JsonHelper::removeComments方法的具體用法?PHP JsonHelper::removeComments怎麽用?PHP JsonHelper::removeComments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JsonHelper
的用法示例。
在下文中一共展示了JsonHelper::removeComments方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getInputHtml
/**
* @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>';
}