本文整理汇总了PHP中df_escape函数的典型用法代码示例。如果您正苦于以下问题:PHP df_escape函数的具体用法?PHP df_escape怎么用?PHP df_escape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了df_escape函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: textEncode
/**
* Method to render text
*
* @access public
* @param string $text the text to render
* @return rendered text
*
*/
function textEncode($text)
{
// attempt to translate HTML entities in the source.
// get the config options.
$type = $this->getConf('translate', HTML_ENTITIES);
$quotes = $this->getConf('quotes', ENT_COMPAT);
$charset = $this->getConf('charset', 'ISO-8859-1');
// have to check null and false because HTML_ENTITIES is a zero
if ($type === HTML_ENTITIES) {
// keep a copy of the translated version of the delimiter
// so we can convert it back.
$new_delim = htmlentities($this->wiki->delim, $quotes, $charset);
// convert the entities. we silence the call here so that
// errors about charsets don't pop up, per counsel from
// Jan at Horde. (http://pear.php.net/bugs/bug.php?id=4474)
$text = @htmlentities($text, $quotes, $charset);
// re-convert the delimiter
$text = str_replace($new_delim, $this->wiki->delim, $text);
} elseif ($type === HTML_SPECIALCHARS) {
// keep a copy of the translated version of the delimiter
// so we can convert it back.
$new_delim = df_escape($this->wiki->delim, $quotes, $charset);
// convert the entities. we silence the call here so that
// errors about charsets don't pop up, per counsel from
// Jan at Horde. (http://pear.php.net/bugs/bug.php?id=4474)
$text = @df_escape($text, $quotes, $charset);
// re-convert the delimiter
$text = str_replace($new_delim, $this->wiki->delim, $text);
}
return $text;
}
示例2: smarty_function_escape_special_chars
/**
* escape_special_chars common function
*
* Function: smarty_function_escape_special_chars<br>
* Purpose: used by other smarty functions to escape
* special chars except for already escaped ones
* @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @return string
*/
function smarty_function_escape_special_chars($string)
{
if (!is_array($string)) {
$string = preg_replace('!&(#?\\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
$string = df_escape($string);
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
}
return $string;
}
示例3: smarty_modifier_escape
/**
* Smarty escape modifier plugin
*
* Type: modifier<br>
* Name: escape<br>
* Purpose: Escape the string according to escapement type
* @link http://smarty.php.net/manual/en/language.modifier.escape.php
* escape (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param html|htmlall|url|quotes|hex|hexentity|javascript
* @return string
*/
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'ISO-8859-1')
{
switch ($esc_type) {
case 'html':
return df_escape($string, ENT_QUOTES, $char_set);
case 'htmlall':
return htmlentities($string, ENT_QUOTES, $char_set);
case 'url':
return rawurlencode($string);
case 'urlpathinfo':
return str_replace('%2F', '/', rawurlencode($string));
case 'quotes':
// escape unescaped single quotes
return preg_replace("%(?<!\\\\)'%", "\\'", $string);
case 'hex':
// escape every character into hex
$return = '';
for ($x = 0; $x < strlen($string); $x++) {
$return .= '%' . bin2hex($string[$x]);
}
return $return;
case 'hexentity':
$return = '';
for ($x = 0; $x < strlen($string); $x++) {
$return .= '&#x' . bin2hex($string[$x]) . ';';
}
return $return;
case 'decentity':
$return = '';
for ($x = 0; $x < strlen($string); $x++) {
$return .= '&#' . ord($string[$x]) . ';';
}
return $return;
case 'javascript':
// escape quotes and backslashes, newlines, etc.
return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\\/'));
case 'mail':
// safe way to display e-mail address on a web page
return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
case 'nonstd':
// escape non-standard chars, such as ms document quotes
$_res = '';
for ($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) {
$_ord = ord(substr($string, $_i, 1));
// non-standard char, escape it
if ($_ord >= 126) {
$_res .= '&#' . $_ord . ';';
} else {
$_res .= substr($string, $_i, 1);
}
}
return $_res;
default:
return $string;
}
}
示例4: smarty_modifier_debug_print_var
/**
* Smarty debug_print_var modifier plugin
*
* Type: modifier<br>
* Name: debug_print_var<br>
* Purpose: formats variable contents for display in the console
* @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php
* debug_print_var (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param array|object
* @param integer
* @param integer
* @return string
*/
function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
{
$_replace = array("\n" => '<i>\\n</i>', "\r" => '<i>\\r</i>', "\t" => '<i>\\t</i>');
switch (gettype($var)) {
case 'array':
$results = '<b>Array (' . count($var) . ')</b>';
foreach ($var as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat(' ', $depth * 2) . '<b>' . strtr($curr_key, $_replace) . '</b> => ' . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
$depth--;
}
break;
case 'object':
$object_vars = get_object_vars($var);
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
foreach ($object_vars as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat(' ', $depth * 2) . '<b> ->' . strtr($curr_key, $_replace) . '</b> = ' . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
$depth--;
}
break;
case 'boolean':
case 'NULL':
case 'resource':
if (true === $var) {
$results = 'true';
} elseif (false === $var) {
$results = 'false';
} elseif (null === $var) {
$results = 'null';
} else {
$results = df_escape((string) $var);
}
$results = '<i>' . $results . '</i>';
break;
case 'integer':
case 'float':
$results = df_escape((string) $var);
break;
case 'string':
$results = strtr($var, $_replace);
if (strlen($var) > $length) {
$results = substr($var, 0, $length - 3) . '...';
}
$results = df_escape('"' . $results . '"');
break;
case 'unknown type':
default:
$results = strtr((string) $var, $_replace);
if (strlen($results) > $length) {
$results = substr($results, 0, $length - 3) . '...';
}
$results = df_escape($results);
}
return $results;
}
示例5: oneLineDescription
function oneLineDescription(&$record)
{
$del =& $record->_table->getDelegate();
$origRecord = $this->origRecords[$record->getId()];
if (!$origRecord) {
$origRecord = $record;
}
if (is_a($origRecord, 'Dataface_RelatedRecord')) {
$origDel = $origRecord->_record->table()->getDelegate();
$method = 'rel_' . $origRecord->_relationshipName . '__' . oneLineDescription;
if (isset($origDel) and method_exists($origDel, $method)) {
return $del->{$method}($origRecord);
}
}
if (isset($del) and method_exists($del, 'oneLineDescription')) {
return $del->oneLineDescription($record);
}
$app =& Dataface_Application::getInstance();
$adel =& $app->getDelegate();
if (isset($adel) and method_exists($adel, 'oneLineDescription')) {
return $adel->oneLineDescription($record);
}
$out = '<span class="Dataface_GlanceList-oneLineDescription">
<span class="Dataface_GlanceList-oneLineDescription-title"><a href="' . df_escape($record->getURL('-action=view')) . '" title="View this record">' . df_escape($origRecord->getTitle()) . '</a></span> ';
if ($creator = $record->getCreator()) {
$show = true;
if (isset($app->prefs['hide_posted_by']) and $app->prefs['hide_posted_by']) {
$show = false;
}
if (isset($record->_table->_atts['__prefs__']['hide_posted_by']) and $record->_table->_atts['__prefs__']['hide_posted_by']) {
$show = false;
}
if ($show) {
$out .= '<span class="Dataface_GlanceList-oneLineDescription-posted-by">Posted by ' . df_escape($creator) . '.</span> ';
}
}
if ($modified = $record->getLastModified()) {
$show = true;
if (isset($app->prefs['hide_updated']) and $app->prefs['hide_updated']) {
$show = false;
}
if (isset($record->_table->_atts['__prefs__']['hide_updated']) and $record->_table->_atts['__prefs__']['hide_updated']) {
$show = false;
}
if ($show) {
$out .= '<span class="Dataface_GlanceList-oneLineDescription-updated">Updated ' . df_escape(df_offset(date('Y-m-d H:i:s', $modified))) . '</span>';
}
}
$out .= '
</span>';
return $out;
}
示例6: ConvertToXmlAttribute
function ConvertToXmlAttribute($value)
{
if (defined('PHP_OS')) {
$os = PHP_OS;
} else {
$os = php_uname();
}
if (strtoupper(substr($os, 0, 3)) === 'WIN') {
return utf8_encode(df_escape($value));
} else {
return df_escape($value);
}
}
示例7: process
/**
*
* Generates a replacement for the matched text. Token options are:
*
* 'type' => ['start'|'end'] The starting or ending point of the
* heading text. The text itself is left in the source.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return string A pair of delimited tokens to be used as a
* placeholder in the source text surrounding the heading text.
*
*/
function process(&$matches)
{
// keep a running count for header IDs. we use this later
// when constructing TOC entries, etc.
static $id;
if (!isset($id)) {
$id = 0;
}
$prefix = df_escape($this->getConf('id_prefix'));
$start = $this->wiki->addToken($this->rule, array('type' => 'start', 'level' => strlen($matches[1]), 'text' => $matches[2], 'id' => $prefix . $id++));
$end = $this->wiki->addToken($this->rule, array('type' => 'end', 'level' => strlen($matches[1])));
return $start . $matches[2] . $end . "\n";
}
示例8: showSummary
function showSummary(&$record)
{
$del =& $record->_table->getDelegate();
if (isset($del) and method_exists($del, 'showSummary')) {
return $del->showSummary($record);
}
$app =& Dataface_Application::getInstance();
$adel =& $app->getDelegate();
if (isset($adel) and method_exists($adel, 'showSummary')) {
return $adel->showSummary($record);
}
// No custom summary defined. We build our own.
// See if there is an image of sorts.
$logoField = $this->getLogoField($record);
$out = '<div class="Dataface_SummaryList-record-summary">';
if ($logoField) {
if (isset($app->prefs['SummaryList_logo_width'])) {
$width = $apps->prefs['SummaryList_logo_width'];
} else {
$width = '60';
}
$out .= '<div class="Dataface_SummaryList-record-logo"><a href="' . $record->getURL('-action=view') . '" title="Record details">
<img src="' . $record->display($logoField) . '" width="' . df_escape($width) . '"/>
</a>
</div>';
}
$out .= '<table class="record-view-table">
<tbody>';
foreach ($this->getSummaryColumns($record) as $fieldname) {
$field =& $record->_table->getField($fieldname);
$out .= '
<tr><th class="record-view-label">' . df_escape($field['widget']['label']) . '</th><td class="record-view-value">' . $record->htmlValue($fieldname) . '</td></tr>
';
}
$out .= ' </tbody></table>';
//$out .= '<h5 class="Dataface_SummaryList-record-title"><a href="'.$record->getURL('-action=view').'">'.df_escape($record->callDelegateFunction('summaryTitle',$record->getTitle())).'</a></h5>';
//$out .= '<div class="Dataface_SummaryList-record-description">'.$record->callDelegateFunction('summaryDescription',$record->getDescription()).'</div>';
//$out .= ( $record->getLastModified() + $record->getCreated() > 0 ? '<div class="Dataface_SummaryLIst-record-status">'.
// ( $record->getLastModified() > 0 ? '<span class="Dataface_SummaryList-record-last-modified">
// '.df_translate('scripts.GLOBAL.LABEL_LAST_MODIFIED', 'Last updated '.df_offset(date('Y-m-d H:i:s',intval($record->getLastModified()))), array('last_mod'=>df_offset(date('Y-m-d H:i:s',intval($record->getLastModified()))))).'
// </span>' : '').
// ( $record->getCreated() > 0 ?
// '<span class="Dataface_SummaryList-record-created">'.df_translate('scripts.GLOBAL.LABEL_DATE_CREATED','Created '.df_offset(date('Y-m-d H:i:s',intval($record->getCreated()))), array('created'=>df_offset(date('Y-m-d H:i:s',intval($record->getCreated()))))).'</span>':''
// ).'
// </div>': '').'
$out .= ' </div>';
return $out;
}
示例9: Dataface_Record__htmlValue
public function Dataface_Record__htmlValue($event)
{
$fieldname = $event->fieldname;
$record = $event->record;
$field =& $record->table()->getField($fieldname);
if ($field['widget']['type'] === 'geopicker') {
$this->registerPaths();
Dataface_JavascriptTool::getInstance()->import('xataface/modules/geopicker/widgets/geopicker.js');
$val = $record->val($fieldname);
if (!trim($val)) {
$event->out = '';
} else {
$event->out = '<input type="hidden" value="' . df_escape($val) . '" class="xf-geopicker" data-geopicker-read-only="1"/>';
//out geopicker data in a hidden file (js code will substitute the textbox with the map)
}
}
}
示例10: handle
function handle($params)
{
$js = Dataface_JavascriptTool::getInstance();
$js->import('xatacard/layout/tests/RecordSetTest.js');
$js->setMinify(false);
$js->setUseCache(false);
df_register_skin('xatajax', XATAJAX_PATH . DIRECTORY_SEPARATOR . 'templates');
try {
df_display(array(), 'tests/xatacard/layout/RecordSet/RecordSetTest.html');
} catch (Exception $ex) {
//echo "here";exit;
while ($ex) {
echo '<h3>' . $ex->getMessage() . '</h3>';
echo nl2br(df_escape($ex->getTraceAsString()));
$ex = $ex->getPrevious();
}
}
}
示例11: CreateHtml
function CreateHtml()
{
$HtmlValue = df_escape($this->Value);
$Html = '<div>';
if (!isset($_GET)) {
global $HTTP_GET_VARS;
$_GET = $HTTP_GET_VARS;
}
if ($this->IsCompatible()) {
if (isset($_GET['fcksource']) && $_GET['fcksource'] == "true") {
$File = 'fckeditor.original.html';
} else {
$File = 'fckeditor.html';
}
$Link = "{$this->BasePath}editor/{$File}?InstanceName={$this->InstanceName}";
if ($this->ToolbarSet != '') {
$Link .= "&Toolbar={$this->ToolbarSet}";
}
// Render the linked hidden field.
$Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}\" name=\"{$this->InstanceName}\" value=\"{$HtmlValue}\" style=\"display:none\" />";
// Render the configurations hidden field.
$Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}___Config\" value=\"" . $this->GetConfigFieldString() . "\" style=\"display:none\" />";
// Render the editor IFRAME.
$Html .= "<iframe id=\"{$this->InstanceName}___Frame\" src=\"{$Link}\" width=\"{$this->Width}\" height=\"{$this->Height}\" frameborder=\"0\" scrolling=\"no\"></iframe>";
} else {
if (strpos($this->Width, '%') === false) {
$WidthCSS = $this->Width . 'px';
} else {
$WidthCSS = $this->Width;
}
if (strpos($this->Height, '%') === false) {
$HeightCSS = $this->Height . 'px';
} else {
$HeightCSS = $this->Height;
}
$Html .= "<textarea name=\"{$this->InstanceName}\" rows=\"4\" cols=\"40\" style=\"width: {$WidthCSS}; height: {$HeightCSS}\">{$HtmlValue}</textarea>";
}
$Html .= '</div>';
return $Html;
}
示例12: _toString_Array
/**
* Returns the string representation of a multiple variable
*
* @return string The string representation of a multiple variable.
* @access private
*/
function _toString_Array()
{
$txt = '';
$stack = array(0);
$counter = count($this->family);
for ($c = 0; $c < $counter; $c++) {
switch ($this->family[$c]) {
case VAR_DUMP_START_GROUP:
array_push($stack, 0);
if ($this->depth[$c] > 0) {
$txt .= $this->options['start_td_colspan'];
}
$txt .= $this->options['start_table'];
if ($this->options['show_caption']) {
$txt .= $this->options['start_caption'] . df_escape($this->value[$c]) . $this->options['end_caption'];
}
break;
case VAR_DUMP_FINISH_GROUP:
array_pop($stack);
$txt .= $this->options['end_table'];
if ($this->depth[$c] > 0) {
$txt .= $this->options['end_td_colspan'] . $this->options['end_tr'];
}
break;
case VAR_DUMP_START_ELEMENT_NUM:
case VAR_DUMP_START_ELEMENT_STR:
array_push($stack, 1 - array_pop($stack));
$tr = end($stack) == 1 ? 'start_tr' : 'start_tr_alt';
$comp = $this->family[$c] == VAR_DUMP_START_ELEMENT_NUM ? 'num' : 'str';
$txt .= $this->options[$tr] . $this->options['start_td_key'] . $this->options['before_' . $comp . '_key'] . df_escape($this->value[$c]) . $this->options['after_' . $comp . '_key'] . $this->options['end_td_key'];
break;
case VAR_DUMP_FINISH_ELEMENT:
case VAR_DUMP_FINISH_STRING:
$etr = end($stack) == 1 ? 'end_tr' : 'end_tr_alt';
if (!is_null($this->value[$c])) {
$string = df_escape($this->value[$c]);
if ($this->options['show_eol'] !== FALSE) {
$string = str_replace("\n", $this->options['show_eol'] . "\n", $string);
}
$txt .= $this->options['start_td_type'] . $this->options['before_type'] . df_escape($this->type[$c]) . $this->options['after_type'] . $this->options['end_td_type'] . $this->options['start_td_value'] . $this->options['before_value'] . nl2br($string) . $this->options['after_value'] . $this->options['end_td_value'] . $this->options[$etr];
} else {
$txt .= $this->options['start_td_colspan'] . $this->options['before_type'] . df_escape($this->type[$c]) . $this->options['after_type'] . $this->options['end_td_colspan'] . $this->options[$etr];
}
break;
}
}
return $txt;
}
示例13: array
function &buildWidget(&$record, &$field, &$form, $formFieldName, $new = false)
{
$table =& $record->_table;
$widget =& $field['widget'];
$factory = Dataface_FormTool::factory();
$attributes = array('class' => $widget['class'], 'id' => $field['name']);
if ($field['repeat']) {
$attributes['multiple'] = true;
$attributes['size'] = 5;
}
$options = $record->_table->getValuelist($field['vocabulary']);
//Dataface_FormTool::getVocabulary($record, $field);
if (!isset($options)) {
$options = array();
}
$emptyOpt = array('' => df_translate('scripts.GLOBAL.FORMS.OPTION_PLEASE_SELECT', "Please Select..."));
$opts = $emptyOpt;
if ($record and $record->val($field['name'])) {
if (!@$field['repeat'] and !isset($options[$record->strval($field['name'])])) {
$opts[$record->strval($field['name'])] = $record->strval($field['name']);
} else {
if (@$field['repeat']) {
$vals = $record->val($field['name']);
if (is_array($vals)) {
foreach ($vals as $thisval) {
if (!isset($options[$thisval])) {
$opts[$thisval] = $thisval;
}
}
}
}
}
}
foreach ($options as $kopt => $opt) {
$opts[$kopt] = $opt;
}
$el = $factory->addElement('select', $formFieldName, $widget['label'], $opts, $attributes);
// Now to make it editable
if (@$field['vocabulary']) {
try {
$rel =& Dataface_ValuelistTool::getInstance()->asRelationship($table, $field['vocabulary']);
if ($rel and !PEAR::isError($rel)) {
if (!is_a($rel, 'Dataface_Relationship')) {
throw new Exception("The relationship object for the vocabulary " . $field['vocabulary'] . " could not be loaded.");
}
if (!$rel->getDomainTable()) {
throw new Exception("The relationship object for the vocabulary " . $field['vocabulary'] . " could not be loaded or the domain table could not be found");
}
$dtable = Dataface_Table::loadTable($rel->getDomainTable());
if ($dtable and !PEAR::isError($dtable)) {
$perms = $dtable->getPermissions();
if (@$perms['new']) {
$fields =& $rel->fields();
if (count($fields) > 1) {
$valfield = $fields[1];
$keyfield = $fields[0];
} else {
$valfield = $fields[0];
$keyfield = $fields[0];
}
if (strpos($valfield, '.') !== false) {
list($tmp, $valfield) = explode('.', $valfield);
}
if (strpos($keyfield, '.') !== false) {
list($tmp, $keyfield) = explode('.', $keyfield);
}
$jt = Dataface_JavascriptTool::getInstance();
$jt->import('RecordDialog/RecordDialog.js');
//$suffix = '<script type="text/javascript" src="'.DATAFACE_URL.'/js/jquery-ui-1.7.2.custom.min.js"></script>';
//$suffix .= '<script type="text/javascript" src="'.DATAFACE_URL.'/js/RecordDialog/RecordDialog.js"></script>';
$suffix = '<a href="#" onclick="return false" id="' . df_escape($field['name']) . '-other">Other..</a>';
$suffix .= '<script>
jQuery(document).ready(function($){
$("#' . $field['name'] . '-other").each(function(){
var tablename = "' . addslashes($dtable->tablename) . '";
var valfld = ' . json_encode($valfield) . ';
var keyfld = ' . json_encode($keyfield) . ';
var fieldname = ' . json_encode($field['name']) . ';
var btn = this;
$(this).RecordDialog({
table: tablename,
callback: function(data){
var key = data[keyfld];
var val = data[valfld];
var $option = $(\'<option value="\'+key+\'">\'+val+\'</option>\');
$("#"+fieldname).append($option);
$("#"+fieldname).val(key);
if ( !val || val === key ){
var q = {
"-action" : "field_vocab_value",
"-key" : key,
"-table" : ' . json_encode($field['tablename']) . ',
"-field" : ' . json_encode($field['name']) . '
};
$.get(DATAFACE_SITE_HREF, q, function(res){
if ( res && res.code === 200 ){
$option.text(res.value);
}
});
//.........这里部分代码省略.........
示例14: getFrozenHtml
/**
* Returns the value of field without HTML tags (in this case, value is changed to a mask)
*
* @since 1.0
* @access public
* @return string
*/
function getFrozenHtml()
{
$value = df_escape($this->getValue());
if ($this->getAttribute('wrap') == 'off') {
$html = $this->_getTabs() . '<pre>' . $value . "</pre>\n";
} else {
$html = nl2br($value) . "\n";
}
return $html . $this->_getPersistantData();
}
示例15: getFrozenHtml
/**
* Returns the value of field without HTML tags
*
* @since 1.0
* @access public
* @return string
*/
function getFrozenHtml()
{
$value = $this->getValue();
return ('' != $value ? df_escape($value) : ' ') . $this->_getPersistantData();
}