本文整理汇总了PHP中CMbString::htmlSpecialChars方法的典型用法代码示例。如果您正苦于以下问题:PHP CMbString::htmlSpecialChars方法的具体用法?PHP CMbString::htmlSpecialChars怎么用?PHP CMbString::htmlSpecialChars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMbString
的用法示例。
在下文中一共展示了CMbString::htmlSpecialChars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHtmlValue
/**
* @see parent::getHtmlValue()
*/
function getHtmlValue($object, $smarty = null, $params = array())
{
$value = $object->{$this->fieldName};
// Empty value: no paragraph
if (!$value) {
return "";
}
// Truncate case: no breakers but inline bullets instead
if ($truncate = CValue::read($params, "truncate")) {
$value = CMbString::truncate($value, $truncate === true ? null : $truncate);
$value = CMbString::nl2bull($value);
return CMbString::htmlSpecialChars($value);
}
// Markdown case: full delegation
if ($this->markdown) {
// In order to prevent from double escaping
$content = CMbString::markdown(html_entity_decode($value));
return "<div class='markdown'>{$content}</div>";
}
// Standard case: breakers and paragraph enhancers
$text = "";
$value = str_replace(array("\r\n", "\r"), "\n", $value);
$paragraphs = preg_split("/\n{2,}/", $value);
foreach ($paragraphs as $_paragraph) {
if (!empty($_paragraph)) {
$_paragraph = nl2br(CMbString::htmlSpecialChars($_paragraph));
$text .= "<p>{$_paragraph}</p>";
}
}
return $text;
}
示例2: getValue
/**
* @see parent::getValue()
*/
function getValue($object, $smarty = null, $params = array())
{
if ($this->class) {
return CMbString::htmlSpecialChars(CAppUI::tr($object->{$this->fieldName}));
}
return parent::getValue($object, $smarty, $params);
}
示例3: getFormHtmlElement
/**
* @see parent::getFormHtmlElement()
*/
function getFormHtmlElement($object, $params, $value, $className)
{
$field = CMbString::htmlSpecialChars($this->fieldName);
$value = CMbString::htmlSpecialChars($value);
$class = CMbString::htmlSpecialChars("{$className} {$this->prop}");
$form = CMbArray::extract($params, "form");
$extra = CMbArray::makeXmlAttributes($params);
return "<input type=\"tel\" name=\"{$field}\" value=\"{$value}\" class=\"{$class} styled-element\" {$extra} />";
}
示例4: processLog
/**
* Process the exported data
*
* @param string $export Data
* @param string $label Add an optionnal label
* @param bool $log Log to file or echo data
*
* @return int The size of the data written in the log file
**/
function processLog($export, $label = null, $log = false)
{
$export = CMbString::htmlSpecialChars($export);
$time = date("Y-m-d H:i:s");
$msg = "\n<pre>[{$time}] {$label}: {$export}</pre>";
if ($log) {
return file_put_contents(LOG_PATH, $msg, FILE_APPEND);
}
echo $msg;
return null;
}
示例5: log
/**
* Process the exported data
*
* @param string $export Data
* @param string $label Add an optionnal label
* @param bool $onlyPlainField Only get DB fields and there values if export is object
*
* @return int The size of the data written in the log file
**/
static function log($export, $label = null, $onlyPlainField = false)
{
if (!CAppUI::conf("debug")) {
return null;
}
if ($export instanceof CMbObject && $onlyPlainField) {
$export = $export->getPlainFields();
}
$export = print_r($export, true);
$export = CMbString::htmlSpecialChars($export);
$time = date("Y-m-d H:i:s");
$msg = "\n<pre>[{$time}] {$label}: {$export}</pre>";
return file_put_contents(DEBUG_PATH, $msg, FILE_APPEND);
}
示例6: getFormHtmlElement
/**
* @see parent::getFormHtmlElement()
*/
function getFormHtmlElement($object, $params, $value, $className)
{
$field = CMbString::htmlSpecialChars($this->fieldName);
$form = CMbArray::extract($params, "form");
$extra = CMbArray::makeXmlAttributes($params);
$readonly = CMbArray::extract($params, "readonly");
$default_color = $this->default ? $this->default : "ffffff";
$reset_value = $this->notNull ? $default_color : "";
$bg_reset = $reset_value ? "#{$reset_value}" : "transparent";
$value = !$value && ($this->notNull || $this->default) ? $default_color : $value;
$sHtml = "\n <input type=\"text\" class=\"color_picker\" name=\"{$field}\" value=\"{$value}\" {$extra} />\n <button type=\"button\" onclick=\"var elem = \$(this).previous('input'); \$V(elem, '{$reset_value}', true); elem.setStyle({backgroundColor: '{$bg_reset}'});\" class='cancel notext'></button>\n ";
if ($form && !$readonly) {
$js_params = "{}";
if (!$this->notNull) {
$js_params = "{required:false}";
}
$sHtml .= "<script type=\"text/javascript\">\n Main.add(function(){\n var _e = getForm('" . $form . "').elements['" . $field . "'];\n new jscolor.color(_e, {$js_params});\n })\n </script>";
}
return $sHtml;
}
示例7: addProperty
/**
* Ajoute un champ
*
* @param string $field nom du champ
* @param string $value [optional]
* @param array $options [optional]
* @param boolean $htmlescape [optional]
*
* @return void
*/
function addProperty($field, $value = null, $options = array(), $htmlescape = true)
{
if ($htmlescape) {
$value = CMbString::htmlSpecialChars($value);
}
$sec = explode(' - ', $field, 3);
switch (count($sec)) {
case 3:
$section = $sec[0];
$item = $sec[1];
$sub_item = $sec[2];
break;
case 2:
$section = $sec[0];
$item = $sec[1];
$sub_item = '';
break;
default:
trigger_error("Error while exploding the string", E_USER_ERROR);
return;
}
if (!array_key_exists($section, $this->sections)) {
$this->sections[$section] = array();
}
if ($sub_item != '' && !array_key_exists($item, $this->sections[$section])) {
$this->sections[$section][$item] = array();
}
if ($sub_item == '') {
$this->sections[$section][$field] = array("view" => CMbString::htmlEntities($item), "field" => $field, "value" => $value, "fieldHTML" => CMbString::htmlEntities("[{$field}]", ENT_QUOTES), "valueHTML" => $value, "shortview" => $section . " - " . $item, "options" => $options);
} else {
$this->sections[$section][$item][$sub_item] = array("view" => CMbString::htmlEntities($sub_item), "field" => $field, "value" => $value, "fieldHTML" => CMbString::htmlEntities("[{$field}]", ENT_QUOTES), "valueHTML" => $value, "shortview" => $section . " - " . $item . " - " . $sub_item, "options" => $options);
}
// Barcode
if (isset($options["barcode"])) {
if ($sub_item) {
$_field =& $this->sections[$section][$item][$sub_item];
} else {
$_field =& $this->sections[$section][$field];
}
if ($this->valueMode) {
$src = $this->getBarcodeDataUri($_field['value'], $options["barcode"]);
} else {
$src = $_field['fieldHTML'];
}
$_field["field"] = "";
if ($options["barcode"]["title"]) {
$_field["field"] .= $options["barcode"]["title"] . "<br />";
}
$_field["field"] .= "<img alt=\"{$field}\" src=\"{$src}\" ";
foreach ($options["barcode"] as $name => $attribute) {
$_field["field"] .= " {$name}=\"{$attribute}\"";
}
$_field["field"] .= "/>";
}
// Custom data
if (isset($options["data"])) {
$_field =& $this->sections[$section][$item][$sub_item];
$data = $options["data"];
$view = $_field['field'];
$_field["field"] = "[<span data-data=\"{$data}\">{$view}</span>]";
}
// Image (from a CFile object)
if (isset($options["image"])) {
$_field =& $this->sections[$section][$field];
$data = "";
if ($this->valueMode) {
$file = new CFile();
$file->load($_field['value']);
if ($file->_id) {
// Resize the image
CAppUI::requireLibraryFile("phpThumb/phpthumb.class");
include_once "lib/phpThumb/phpThumb.config.php";
$thumbs = new phpthumb();
$thumbs->setSourceFilename($file->_file_path);
$thumbs->w = 640;
$thumbs->f = "png";
$thumbs->GenerateThumbnail();
$data = "data:" . $file->file_type . ";base64," . urlencode(base64_encode($thumbs->IMresizedData));
}
}
$src = $this->valueMode ? $data : $_field['fieldHTML'];
$_field["field"] = "<img src=\"" . $src . "\" />";
}
}
示例8: getFormHtmlElement
/**
* @see parent::getFormHtmlElement()
*/
function getFormHtmlElement($object, $params, $value, $className)
{
$form = CMbArray::extract($params, "form");
// needs to be extracted
$field = CMbString::htmlSpecialChars($this->fieldName);
$extra = CMbArray::makeXmlAttributes($params);
$sHtml = '<input type="password" name="' . $field . '" class="' . CMbString::htmlSpecialChars(trim($className . ' ' . $this->prop)) . ' styled-element" ';
if ($this->revealable) {
$sHtml .= ' value="' . CMbString::htmlSpecialChars($value) . '" ';
}
$sHtml .= $extra . ' />';
if ($this->revealable) {
$sHtml .= '<button class="lookup notext" type="button" onclick="var i=$(this).previous(\'input\');i.type=(i.type==\'password\')?\'text\':\'password\'"></button>';
}
if ($this->randomizable) {
$random_call = "getRandomPassword('{$object->_class}', '{$field}');";
$title = CAppUI::tr("common-action-Get random password");
$sHtml .= '<button class="change notext" type="button" onclick="' . $random_call . '" title="' . $title . '"></button>';
}
$sHtml .= '<span id="' . $field . '_message"></span>';
return $sHtml;
}
示例9: makeXmlAttributes
/**
* Return a string of XML attributes based on given array key-value pairs
*
* @param array $array The source array
*
* @return string String attributes like 'key1="value1" ... keyN="valueN"'
*/
static function makeXmlAttributes($array)
{
$return = '';
foreach ($array as $key => $value) {
if ($value !== null) {
$value = trim(CMbString::htmlSpecialChars($value));
$return .= "{$key}=\"{$value}\" ";
}
}
return $return;
}
示例10: getFormHtmlElement
/**
* @see parent::getFormHtmlElement()
*/
function getFormHtmlElement($object, $params, $value, $className)
{
$sHtml = "";
$field = CMbString::htmlSpecialChars($this->fieldName);
$typeEnum = CMbArray::extract($params, "typeEnum", $this->typeEnum ? $this->typeEnum : "radio");
$separator = CMbArray::extract($params, "separator");
$disabled = CMbArray::extract($params, "disabled");
$readonly = CMbArray::extract($params, "readonly");
$default = CMbArray::extract($params, "default", $this->default);
$form = CMbArray::extract($params, "form");
// needs to be extracted
$className = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}"));
$extra = CMbArray::makeXmlAttributes($params);
// Empty label
if ($emptyLabel = CMbArray::extract($params, "emptyLabel")) {
$emptyLabel = "— " . CAppUI::tr($emptyLabel);
}
switch ($typeEnum) {
case "radio":
// Attributes for all inputs
$attributes = array("type" => "radio", "name" => $field);
if (null === $value) {
$value = "{$default}";
}
for ($i = 1; $i >= 0; $i--) {
$attributes["value"] = "{$i}";
$attributes["checked"] = $value === "{$i}" ? "checked" : null;
$attributes["disabled"] = $disabled === "{$i}" || $readonly ? "disabled" : null;
$attributes["class"] = $className;
$xmlAttributes = CMbArray::makeXmlAttributes($attributes);
$sHtml .= "\n<input {$xmlAttributes} {$extra} />";
$sTr = CAppUI::tr("bool.{$i}");
$sHtml .= "\n<label for=\"{$field}_{$i}\">{$sTr}</label> ";
if ($separator && $i != 0) {
$sHtml .= "\n{$separator}";
}
}
return $sHtml;
case "checkbox":
$disabled = $readonly ? "disabled=\"1\"" : $disabled;
if (null === $value) {
$value = "{$default}";
}
if ($value !== null && $value == 1) {
$checked = " checked=\"checked\"";
} else {
$checked = "";
$value = "0";
}
$sHtml = '<input type="checkbox" name="__' . $field . '"
onclick="$V(this.form.' . $field . ', $V(this)?1:0);" ' . $checked . ' ' . $disabled . ' />';
$sHtml .= '<input type="hidden" name="' . $field . '" ' . $extra . ' value="' . $value . '" />';
return $sHtml;
case "select":
$disabled = $readonly ? "disabled=\"1\"" : $disabled;
$sHtml = "<select name=\"{$field}\" class=\"{$className}\" {$disabled} {$extra}>";
if ($emptyLabel) {
if ($value === null) {
$sHtml .= "\n<option value=\"\" selected=\"selected\">{$emptyLabel}</option>";
} else {
$sHtml .= "\n<option value=\"\">{$emptyLabel}</option>";
}
}
foreach ($this->_locales as $key => $item) {
if ($value !== null && $value === "{$key}" || $value === null && "{$key}" === "{$this->default}" && !$emptyLabel) {
$selected = " selected=\"selected\"";
} else {
$selected = "";
}
$sHtml .= "\n<option value=\"{$key}\" {$selected}>{$item}</option>";
}
$sHtml .= "\n</select>";
return $sHtml;
}
}
示例11: getFormElementDateTime
/**
* Get an HTML form datetime input corresponding to the bound object value
*
* @param object $object Object holding the field
* @param array $params Extra parameters
* @param string $value The actual value
* @param string $className Extra CSS class name
* @param string $format Optional datetime format
*
* @return string HTML form datetime string
*/
function getFormElementDateTime($object, $params, $value, $className, $format = "%d/%m/%Y %H:%M")
{
if ($object->_locked) {
$params["readonly"] = "readonly";
}
$class = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}"));
$field = CMbString::htmlSpecialChars($this->fieldName);
// Format the date
$date = "";
if ($value && $value != '0000-00-00' && $value != '00:00:00' && $value != '0000-00-00 00:00:00') {
$date = $this instanceof CDateSpec && $this->progressive ? $this->getValue($object, null, $params) : CMbDT::format($value, $format);
}
$form = CMbArray::extract($params, "form");
$register = CMbArray::extract($params, "register");
$style = CMbArray::extract($params, "style");
$tabindex = CMbArray::extract($params, "tabindex");
$readonly = CMbArray::get($params, "readonly");
$extra = CMbArray::makeXmlAttributes($params);
$html = array();
$html[] = '<input name="' . $field . '_da" type="text" value="' . $date . '" class="' . $class . ' styled-element"
readonly="readonly" ' . (isset($tabindex) ? 'tabindex="' . $tabindex . '" ' : '') . ' style="' . $style . '" />';
$html[] = '<input name="' . $field . '" type="hidden" value="' . $value . '" class="' . $class . '" ' . $extra . ' data-visual-element="' . $field . '_da" />';
if ($form && !$readonly && ($register || $this instanceof CTimeSpec)) {
$register = $this instanceof CDateSpec && $this->progressive ? 'regProgressiveField' : 'regField';
$html[] = '<script type="text/javascript">
Main.add(function(){Calendar.' . $register . '(getForm("' . $form . '").elements["' . $field . '"])})
</script>';
}
return implode("\n", $html);
}
示例12: cleanField
/**
* The default Smarty escape
*
* @param string $string The string to escape
*
* @return string Escaped string
*/
function cleanField($string)
{
if (!is_scalar($string)) {
return $string;
}
return CMbString::htmlSpecialChars($string, ENT_QUOTES);
}
示例13:
case "text/medistory-form":
if (class_exists("CMedistoryImprime")) {
$includeInfosFile = CMedistoryImprime::toHTML($raw_content);
$show_editor = false;
$display_as_is = true;
break;
}
case "text/ami-patient-text":
if (class_exists("CAMIDocument")) {
$includeInfosFile = CAMIDocument::toHTML($raw_content);
$show_editor = false;
$display_as_is = true;
break;
}
case "text/plain":
$includeInfosFile = "<pre>" . CMbString::htmlSpecialChars($raw_content) . "</pre>";
break;
case "text/html":
$includeInfosFile = CMbString::purifyHTML($raw_content);
$show_editor = false;
$display_as_is = true;
break;
}
}
if ($fileSel->isPDFconvertible()) {
$isConverted = true;
$fileconvert = $fileSel->loadPDFconverted();
$success = 1;
if (!$fileconvert->_id) {
$success = $fileSel->convertToPDF();
}
示例14: getFormHtmlElement
/**
* @see parent::getFormHtmlElement()
*/
function getFormHtmlElement($object, $params, $value, $className)
{
$field = CMbString::htmlSpecialChars($this->fieldName);
$locales = $this->_locales;
$typeEnum = CMbArray::extract($params, "typeEnum", $this->typeEnum ? $this->typeEnum : "checkbox");
$separator = CMbArray::extract($params, "separator", $this->vertical ? "<br />" : null);
$cycle = CMbArray::extract($params, "cycle", 1);
$alphabet = CMbArray::extract($params, "alphabet", false);
$size = CMbArray::extract($params, "size", 0);
$onchange = CMbArray::get($params, "onchange");
$form = CMbArray::extract($params, "form");
// needs to be extracted
$readonly = CMbArray::extract($params, "readonly") == 1;
$extra = CMbArray::makeXmlAttributes($params);
$className = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}"));
if ($alphabet) {
asort($locales);
}
$uid = uniqid();
$value_array = $this->getListValues($value);
switch ($typeEnum) {
case "select":
if ($readonly) {
$readonly = "readonly";
}
$sHtml = "<script type=\"text/javascript\">\n Main.add(function(){\n var select = \$\$('select[data-select_set={$uid}]')[0],\n element = select.previous(),\n tokenField = new TokenField(element, {" . ($onchange ? "onChange: function(){ {$onchange} }.bind(element)" : "") . "});\n\n select.observe('change', function(event){\n tokenField.setValues(\$A(select.options).filter(function(o){return o.selected}).pluck('value'));\n\n element.fire('ui:change');\n });\n });\n </script>";
$sHtml .= "<input type=\"hidden\" name=\"{$field}\" value=\"{$value}\" class=\"{$className}\" {$extra} />\n";
$sHtml .= "<select class=\"{$className}\" multiple=\"multiple\" size=\"{$size}\" data-select_set=\"{$uid}\" {$extra} {$readonly}>";
foreach ($locales as $key => $item) {
if (!empty($value_array) && in_array($key, $value_array)) {
$selected = " selected=\"selected\"";
} else {
$selected = "";
}
$sHtml .= "\n<option value=\"{$key}\" {$selected}>{$item}</option>";
}
$sHtml .= "\n</select>";
break;
default:
case "checkbox":
$sHtml = "<span id=\"set-container-{$uid}\">\n";
$sHtml .= "<input type=\"hidden\" name=\"{$field}\" value=\"{$value}\" class=\"{$className}\" {$extra} />\n";
$sHtml .= "<script type=\"text/javascript\">\n Main.add(function(){\n var cont = \$('set-container-{$uid}'),\n element = cont.down('input[type=hidden]'),\n tokenField = new TokenField(element, {" . ($onchange ? "onChange: function(){ {$onchange} }.bind(element)" : "") . "});\n\n cont.select('input[type=checkbox]').invoke('observe', 'click', function(event){\n var elt = Event.element(event);\n tokenField.toggle(elt.value, elt.checked);\n\n element.fire('ui:change');\n });\n });\n </script>";
$compteur = 0;
if ($readonly) {
$readonly = "disabled";
}
foreach ($locales as $key => $item) {
$selected = "";
if (!empty($value_array) && in_array($key, $value_array)) {
$selected = " checked=\"checked\"";
}
$sHtml .= "\n<label>\n <input type=\"checkbox\" name=\"_{$field}_{$key}\" value=\"{$key}\" class=\"set-checkbox token{$uid}\" {$selected} {$readonly} />\n {$item}\n </label> ";
$compteur++;
$modulo = $compteur % $cycle;
if ($separator != null && $modulo == 0 && $compteur < count($locales)) {
$sHtml .= $separator;
}
}
$sHtml .= "</span>\n";
}
return $sHtml;
}
示例15: getFormHtmlElement
/**
* @see parent::getFormHtmlElement()
*/
function getFormHtmlElement($object, $params, $value, $className)
{
$field = CMbString::htmlSpecialChars($this->fieldName);
$typeEnum = CMbArray::extract($params, "typeEnum", $this->typeEnum ? $this->typeEnum : "select");
$columns = CMbArray::extract($params, "columns", $this->columns ? $this->columns : 1);
$separator = CMbArray::extract($params, "separator");
$cycle = CMbArray::extract($params, "cycle", 1);
$alphabet = CMbArray::extract($params, "alphabet", false);
$form = CMbArray::extract($params, "form");
// needs to be extracted
// Empty label
if ($emptyLabel = CMbArray::extract($params, "emptyLabel")) {
$emptyLabel = CAppUI::tr($emptyLabel);
}
// Extra info por HTML generation
$extra = CMbArray::makeXmlAttributes($params);
$locales = $this->_locales;
$className = CMbString::htmlSpecialChars(trim("{$className} {$this->prop}"));
$html = "";
// Alpha sorting
if ($alphabet) {
asort($locales);
}
// Turn readonly to disabled
$readonly = CMbArray::extract($params, "readonly");
$disabled = $readonly ? "disabled=\"1\"" : "";
switch ($typeEnum) {
default:
case "select":
$html .= "<select name=\"{$field}\" class=\"{$className}\" {$disabled} {$extra}>";
// Empty option label
if ($emptyLabel) {
$emptyLabel = "— {$emptyLabel}";
if ($value === null) {
$html .= "\n<option value=\"\" selected=\"selected\">{$emptyLabel}</option>";
} else {
$html .= "\n<option value=\"\">{$emptyLabel}</option>";
}
}
// All other options
foreach ($locales as $key => $item) {
$selected = "";
if ($value !== null && $value === "{$key}" || $value === null && "{$key}" === "{$this->default}" && !$emptyLabel) {
$selected = " selected=\"selected\"";
}
$html .= "\n<option value=\"{$key}\" {$selected}>{$item}</option>";
}
$html .= "\n</select>";
return $html;
case "radio":
$compteur = 0;
// Empty radio label
if ($emptyLabel) {
if ($value === null) {
$html .= "\n<input type=\"radio\" name=\"{$field}\" value=\"\" checked=\"checked\" />";
} else {
$html .= "\n<input type=\"radio\" name=\"{$field}\" value=\"\" />";
}
$html .= "<label for=\"{$field}_\">{$emptyLabel}</label> ";
}
// All other radios
foreach ($locales as $key => $item) {
$selected = "";
if ($value !== null && $value === "{$key}" || $value === null && "{$key}" === "{$this->default}") {
$selected = " checked=\"checked\"";
}
$html .= "\n<input type=\"radio\" name=\"{$field}\" value=\"{$key}\" {$selected} class=\"{$className}\" {$disabled} {$extra} />\n <label for=\"{$field}_{$key}\">{$item}</label> ";
$compteur++;
$modulo = $compteur % $cycle;
if ($separator != null && $modulo == 0 && $compteur < count($locales)) {
$html .= $separator;
}
if ($this->vertical) {
$html .= "<br />\n";
}
}
return $html;
}
}