本文整理汇总了PHP中Sanitize::saveHTML方法的典型用法代码示例。如果您正苦于以下问题:PHP Sanitize::saveHTML方法的具体用法?PHP Sanitize::saveHTML怎么用?PHP Sanitize::saveHTML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sanitize
的用法示例。
在下文中一共展示了Sanitize::saveHTML方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public static function save($value, $type, $standard = null)
{
$var = $standard;
if ($value !== null) {
if ($type == VAR_DB || $type == VAR_ARR_DB) {
$var = Sanitize::saveDb($value);
} elseif ($type == VAR_HTML || $type == VAR_ARR_HTML) {
$var = Sanitize::saveHTML($value);
} elseif ($type == VAR_INT || $type == VAR_ARR_INT) {
$var = Sanitize::saveInt($value);
} elseif ($type == VAR_ALNUM || $type == VAR_ARR_ALNUM) {
$var = Sanitize::saveAlNum($value, true);
} elseif ($type == VAR_URI || $type == VAR_ARR_URI) {
$var = Sanitize::saveAlNum($value, false);
} else {
$var = Sanitize::removeNullByte($value);
}
} else {
if ($standard === null) {
if ($type == VAR_DB || $type == VAR_ALNUM || $type == VAR_HTML || $type == VAR_URI) {
$var = '';
} elseif ($type == VAR_INT) {
$var = 0;
} elseif ($type == VAR_ARR_INT || $type == VAR_ARR_DB || $type == VAR_ARR_ALNUM || $type == VAR_ARR_NONE || $type == VAR_ARR_HTML || $type == VAR_ARR_URI) {
$var = array();
} else {
$var = null;
}
}
}
return $var;
}
示例2: assign
public function assign($key, $value, $sanitize = true)
{
if ($sanitize) {
$value = Sanitize::saveHTML($value);
}
$this->vars[$key] = $value;
}
示例3: write
public function write($onlyCreate = false, $tpl = null)
{
$id = Request::get(1, VAR_INT);
$isSent = Request::get(2, VAR_URI) == 'send';
$data = new CustomData($this->position);
if ($id > 0 && $onlyCreate && Session::getObject()->getSetting('last_added') != $id) {
CmsPage::error('Die Bearbeitungszeit ist abgelaufen. Bitte wenden Sie sich an den Administrator.');
} else {
if ($id > 0 && !$data->load($id)) {
CmsPage::error('Der gewählte Datensatz wurde leider nicht gefunden.');
} else {
if ($id == 0) {
$data->setToDefault();
}
$fields = $data->getFields();
if ($isSent) {
$options = array();
foreach ($fields as $field) {
if ($field->canWrite()) {
if ($field->getField() instanceof CustomExternalFields) {
$options = array_merge($options, $field->getValidation());
} else {
$options[$field->getFieldName()] = $field->getValidation();
}
}
}
$result = Validator::checkRequest($options);
foreach ($fields as $field) {
if ($field->canWrite()) {
$name = $field->getFieldName();
if (isset($result['data'][$name])) {
$field->setData($result['data'][$name]);
}
}
}
if (count($result['error']) > 0) {
CmsPage::error($result['error']);
} else {
$success = false;
if ($id > 0) {
$success = $data->edit($id);
} else {
$id = $data->add();
if ($onlyCreate) {
Session::getObject()->setSetting('last_added', $id);
}
if ($id > 0) {
$success = true;
} else {
$id = 0;
$success = false;
}
}
if ($success) {
CmsPage::ok("Der Datensatz wurde erfolgreich gespeichert.");
} else {
CmsPage::error("Der Datensatz konnt leider nicht gespeichert werden.");
}
}
}
$html = array();
foreach ($fields as $field) {
if ($field->canWrite()) {
$html[] = array('field' => Sanitize::saveHTML($field->getFieldName()), 'name' => Sanitize::saveHTML($field->getName()), 'description' => Sanitize::saveHTML($field->getDescription()), 'code' => $field->getInputCode(), 'label' => !$field->noLabel());
}
}
$tpl = Response::getObject()->appendTemplate($tpl ? $tpl : '/Cms/fields/data_categories_write');
$tpl->assign('data', $data, false);
$tpl->assign('fields', $html, false);
$tpl->assign('id', $id);
$tpl->assign('baseUri', $this->baseUri);
$tpl->output();
}
}
}
示例4: echoSave
function echoSave($data)
{
echo Sanitize::saveHTML($data);
}