• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP escape_javascript函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中escape_javascript函数的典型用法代码示例。如果您正苦于以下问题:PHP escape_javascript函数的具体用法?PHP escape_javascript怎么用?PHP escape_javascript使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了escape_javascript函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: link_to_function

/**
 * Returns a link that will trigger a javascript function using the
 * onclick handler and return false after the fact.
 *
 * Examples:
 *   <?php echo link_to_function('Greeting', "alert('Hello world!')") ?>
 *   <?php echo link_to_function(image_tag('delete'), "do_delete()", array('confirm' => 'Really?')) ?>
 */
function link_to_function($name, $function, $html_options = array())
{
    $html_options = _parse_attributes($html_options);
    $html_options['href'] = isset($html_options['href']) ? $html_options['href'] : '#';
    if (isset($html_options['confirm'])) {
        $confirm = escape_javascript($html_options['confirm']);
        unset($html_options['confirm']);
        $function = "if(window.confirm('{$confirm}')){ {$function};}";
    }
    $html_options['onclick'] = $function . '; return false;';
    return content_tag('a', $name, $html_options);
}
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:20,代码来源:JavascriptBaseHelper.php


示例2: update_key

 public function update_key()
 {
     $this->header('Content-Type: application/javascript', 200);
     $this->layout = false;
     $this->key = Pki::update($_GET['id'], $_POST['pki']);
     if ($this->key->save()) {
         echo "facebox.close();window.location.href=window.location.href;";
     } else {
         $this->key->id = $_GET['id'];
         $return = escape_javascript($this->render_partial('user/edit_key.php'));
         echo "\$('pki').replace('{$return}');";
     }
     $this->has_rendered = true;
 }
开发者ID:xetorthio,项目名称:pearfarm_channel_server,代码行数:14,代码来源:user_controller.php


示例3: ls_remote_function

/**
 * Returns the javascript needed for a remote function.
 * Takes the same arguments as 'link_to_remote()'.
 *
 * Example:
 *   <select id="options" onchange="<?php echo remote_function(array('update' => 'options', 'url' => '@update_options')) ?>">
 *     <option value="0">Hello</option>
 *     <option value="1">World</option>
 *   </select>
 */
function ls_remote_function($options)
{
    sfContext::getInstance()->getResponse()->addJavascript(sfConfig::get('sf_prototype_web_dir') . '/js/prototype');
    $javascript_options = _options_for_ajax($options);
    $update = '';
    if (isset($options['update']) && is_array($options['update'])) {
        $update = array();
        if (isset($options['update']['success'])) {
            $update[] = "success:'" . $options['update']['success'] . "'";
        }
        if (isset($options['update']['failure'])) {
            $update[] = "failure:'" . $options['update']['failure'] . "'";
        }
        $update = '{' . join(',', $update) . '}';
    } else {
        if (isset($options['update'])) {
            $update .= "'" . $options['update'] . "'";
        }
    }
    $function = !$update ? "new Ajax.Request(" : "new Ajax.Updater({$update}, ";
    $function .= '\'' . url_for($options['url']) . '\'';
    //ADDED TO ALLOW FOR APPENDING HASHES TO URLS FOR AJAX
    if (isset($options['posturl'])) {
        $function .= ' + ' . $options['posturl'];
    }
    $function .= ', ' . $javascript_options . ')';
    if (isset($options['before'])) {
        $function = $options['before'] . '; ' . $function;
    }
    if (isset($options['after'])) {
        $function = $function . '; ' . $options['after'];
    }
    if (isset($options['condition'])) {
        $function = 'if (' . $options['condition'] . ') { ' . $function . '; }';
    }
    if (isset($options['confirm'])) {
        $function = "if (confirm('" . escape_javascript($options['confirm']) . "')) { {$function}; }";
        if (isset($options['cancel'])) {
            $function = $function . ' else { ' . $options['cancel'] . ' }';
        }
    }
    return $function . ';';
}
开发者ID:silky,项目名称:littlesis,代码行数:53,代码来源:LsJavascriptHelper.php


示例4: sql

 $cache_attribs_string = '';
 $rsAttrGroup = sql("SELECT `attribute_groups`.`id`, IFNULL(`sys_trans_text`.`text`, `attribute_groups`.`name`) AS `name`, `attribute_categories`.`color` \n\t\t\t                      FROM `attribute_groups` \n\t\t\t                INNER JOIN `attribute_categories` ON `attribute_groups`.`category_id`=`attribute_categories`.`id` \n\t\t\t                 LEFT JOIN `sys_trans` ON `attribute_groups`.`trans_id`=`sys_trans`.`id`\n\t\t\t                 LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'\n\t\t\t                  ORDER BY `attribute_groups`.`category_id` ASC, `attribute_groups`.`id` ASC", $locale);
 while ($rAttrGroup = sql_fetch_assoc($rsAttrGroup)) {
     $group_line = '';
     $rs = sql("SELECT `cache_attrib`.`id`, IFNULL(`ttname`.`text`, `cache_attrib`.`name`) AS `name`, `cache_attrib`.`icon_undef`, `cache_attrib`.`icon_large`, IFNULL(`ttdesc`.`text`, `cache_attrib`.`html_desc`) AS `html_desc` \n\t\t\t\t             FROM `cache_attrib` \n\t\t            LEFT JOIN `sys_trans` AS `tname` ON `cache_attrib`.`trans_id`=`tname`.`id` AND `cache_attrib`.`name`=`tname`.`text`\n\t\t            LEFT JOIN `sys_trans_text` AS `ttname` ON `tname`.`id`=`ttname`.`trans_id` AND `ttname`.`lang`='&1'\n\t\t            LEFT JOIN `sys_trans` AS `tdesc` ON `cache_attrib`.`html_desc_trans_id`=`tdesc`.`id` AND `cache_attrib`.`html_desc`=`tdesc`.`text`\n\t\t            LEFT JOIN `sys_trans_text` AS `ttdesc` ON `tdesc`.`id`=`ttdesc`.`trans_id` AND `ttdesc`.`lang`='&1'\n\t\t\t\t            WHERE `cache_attrib`.`group_id`=" . ($rAttrGroup['id'] + 0) . " AND\n\t\t\t\t\t\t\tNOT IFNULL(`cache_attrib`.`hidden`, 0)=1 AND \n\t\t\t\t\t\t\t `cache_attrib`.`selectable`!=0 ORDER BY `cache_attrib`.`group_id`, `cache_attrib`.`id`", $locale);
     while ($record = sql_fetch_array($rs)) {
         $line = $cache_attrib_pic;
         $line = mb_ereg_replace('{attrib_id}', $record['id'], $line);
         $line = mb_ereg_replace('{attrib_text}', escape_javascript($record['name']), $line);
         if (in_array($record['id'], $cache_attribs)) {
             $line = mb_ereg_replace('{attrib_pic}', $record['icon_large'], $line);
         } else {
             $line = mb_ereg_replace('{attrib_pic}', $record['icon_undef'], $line);
         }
         $line = mb_ereg_replace('{html_desc}', escape_javascript($record['html_desc']), $line);
         $line = mb_ereg_replace('{name}', escape_javascript($record['name']), $line);
         $line = mb_ereg_replace('{color}', $rAttrGroup['color'], $line);
         $group_line .= $line;
         $nLineAttrCount++;
         $line = $cache_attrib_js;
         $line = mb_ereg_replace('{id}', $record['id'], $line);
         if (in_array($record['id'], $cache_attribs)) {
             $line = mb_ereg_replace('{selected}', 1, $line);
         } else {
             $line = mb_ereg_replace('{selected}', 0, $line);
         }
         $line = mb_ereg_replace('{img_undef}', $record['icon_undef'], $line);
         $line = mb_ereg_replace('{img_large}', $record['icon_large'], $line);
         if ($cache_attrib_array != '') {
             $cache_attrib_array .= ',';
         }
开发者ID:PaulinaKowalczuk,项目名称:oc-server3,代码行数:31,代码来源:newcache.php


示例5: _lwButtonJs

function _lwButtonJs($options = array())
{
    $js_options = array();
    foreach ($options as $k => $v) {
        $js_options[] = "{$k}: '" . escape_javascript($v) . "'";
    }
    $js = 'myLightWindow.activateWindow({' . implode(', ', $js_options) . '}); return false;';
    return $js;
}
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:9,代码来源:LightWindowHelper.php


示例6: jq_remote_function


//.........这里部分代码省略.........
    // Defining elements to update
    if (isset($options['update']) && is_array($options['update'])) {
        // On success, update the element with returned data
        if (isset($options['update']['success'])) {
            $update_success = "#" . $options['update']['success'];
        }
        // On failure, execute a client-side function
        if (isset($options['update']['failure'])) {
            $update_failure = $options['update']['failure'];
        }
    } else {
        if (isset($options['update'])) {
            $update_success = "#" . $options['update'];
        }
    }
    // Update method
    $updateMethod = _update_method(isset($options['position']) ? $options['position'] : '');
    // Callbacks
    if (isset($options['loading'])) {
        $callback_loading = $options['loading'];
    }
    if (isset($options['complete'])) {
        $callback_complete = $options['complete'];
    }
    if (isset($options['success'])) {
        $callback_success = $options['success'];
    }
    $execute = 'false';
    if (isset($options['script']) && $options['script'] == '1') {
        $execute = 'true';
    }
    // Data Type
    if (isset($options['dataType'])) {
        $dataType = $options['dataType'];
    } elseif ($execute) {
        $dataType = 'html';
    } else {
        $dataType = 'text';
    }
    // POST or GET ?
    $method = 'POST';
    if (isset($options['method']) && strtoupper($options['method']) == 'GET') {
        $method = $options['method'];
    }
    // async or sync, async is default
    if (isset($options['type']) && $options['type'] == 'synchronous') {
        $type = 'false';
    }
    // Is it a form submitting
    if (isset($options['form'])) {
        $formData = 'jQuery(this).serialize()';
    } elseif (isset($options['submit'])) {
        $formData = '{\'#' . $options['submit'] . '\'}.serialize()';
    } elseif (isset($options['with'])) {
        $formData = $options['with'];
    }
    // build the function
    $function = "jQuery.ajax({";
    $function .= 'type:\'' . $method . '\'';
    $function .= ',dataType:\'' . $dataType . '\'';
    if (isset($type)) {
        $function .= ',async:' . $type;
    }
    if (isset($formData)) {
        $function .= ',data:' . $formData;
    }
    if (isset($update_success) and !isset($callback_success)) {
        $function .= ',success:function(i){jQuery(\'' . $update_success . '\').' . $updateMethod . '(i);}';
    }
    if (isset($update_failure)) {
        $function .= ',error:function(){' . $update_failure . '}';
    }
    if (isset($callback_loading)) {
        $function .= ',beforeSend:function(){' . $callback_loading . '}';
    }
    if (isset($callback_complete)) {
        $function .= ',complete:function(request){' . $callback_complete . '}';
    }
    if (isset($callback_success)) {
        $function .= ',success:function(request){' . $callback_success . '}';
    }
    $function .= ',url:\'' . url_for($options['url']) . '\'';
    $function .= '})';
    if (isset($options['before'])) {
        $function = $options['before'] . '; ' . $function;
    }
    if (isset($options['after'])) {
        $function = $function . '; ' . $options['after'];
    }
    if (isset($options['condition'])) {
        $function = 'if (' . $options['condition'] . ') { ' . $function . '; }';
    }
    if (isset($options['confirm'])) {
        $function = "if (confirm('" . escape_javascript($options['confirm']) . "')) { {$function}; }";
        if (isset($options['cancel'])) {
            $function = $function . ' else { ' . $options['cancel'] . ' }';
        }
    }
    return $function;
}
开发者ID:anvaya,项目名称:nckids,代码行数:101,代码来源:jQueryHelper.php


示例7: _confirm_javascript_function

function _confirm_javascript_function($confirm)
{
    return "confirm('" . escape_javascript($confirm) . "')";
}
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:4,代码来源:UrlHelper.php


示例8: array

$t->is(tag('br', 'class=foo', false), '<br class="foo" />', 'tag() takes a string of options as its second parameters');
$t->is(tag('p', array('class' => 'foo', 'id' => 'bar'), true), '<p class="foo" id="bar">', 'tag() takes a boolean parameter as its third parameter');
//$t->is(tag('br', array('class' => '"foo"')), '<br class="&quot;foo&quot;" />');
// content_tag()
$t->diag('content_tag()');
$t->is(content_tag(''), '', 'content_tag() returns an empty string with empty input');
$t->is(content_tag('', ''), '', 'content_tag() returns an empty string with empty input');
$t->is(content_tag('p', 'Toto'), '<p>Toto</p>', 'content_tag() takes a content as its second parameter');
$t->is(content_tag('p', ''), '<p></p>', 'content_tag() takes a tag as its first parameter');
// cdata_section()
$t->diag('cdata_section()');
$t->is(cdata_section(''), '<![CDATA[]]>', 'cdata_section() returns a string wrapped into a CDATA section');
$t->is(cdata_section('foobar'), '<![CDATA[foobar]]>', 'cdata_section() returns a string wrapped into a CDATA section');
// escape_javascript()
$t->diag('escape_javascript()');
$t->is(escape_javascript("alert('foo');\nalert(\"bar\");"), 'alert(\\\'foo\\\');\\nalert(\\"bar\\");', 'escape_javascript() escapes JavaScript scripts');
// _get_option()
$t->diag('_get_option()');
$options = array('foo' => 'bar', 'bar' => 'foo');
$t->is(_get_option($options, 'foo'), 'bar', '_get_option() returns the value for the given key');
$t->ok(!isset($options['foo']), '_get_option() removes the key from the original array');
$t->is(_get_option($options, 'nofoo', 'nobar'), 'nobar', '_get_option() returns the default value if the key does not exist');
// escape_once()
$t->diag('escape_once()');
$t->is(escape_once('This a > text to "escape"'), 'This a &gt; text to &quot;escape&quot;', 'escape_once() escapes an HTML strings');
$t->is(escape_once(escape_once('This a > text to "escape"')), 'This a &gt; text to &quot;escape&quot;', 'escape_once() does not escape an already escaped string');
$t->is(escape_once('This a &gt; text to "escape"'), 'This a &gt; text to &quot;escape&quot;', 'escape_once() does not escape an already escaped string');
$t->is(escape_once("This a &gt; \"text\" to 'escape'"), "This a &gt; &quot;text&quot; to 'escape'", 'escape_once() does not escape simple quotes but escape double quotes');
// fix_double_escape()
$t->diag('fix_double_escape()');
$t->is(fix_double_escape(htmlspecialchars(htmlspecialchars('This a > text to "escape"'), ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8'), 'This a &gt; text to &quot;escape&quot;', 'fix_double_escape() fixes double escaped strings');
开发者ID:hunde,项目名称:bsc,代码行数:31,代码来源:TagHelperTest.php


示例9: outputSearchForm


//.........这里部分代码省略.........
        $logtypes = array();
    }
    $rs = sql("\n\t\tSELECT `id`,\n\t\tIFNULL(`sys_trans_text`.`text`, `log_types`.`name`) AS `name`,\n\t\t`id`='&2' as `selected`\n\t\tFROM (\n\t\t\tSELECT `id`,`name`,`trans_id` FROM `log_types`\n\t\t\tUNION\n\t\t\tSELECT 0,'all',(SELECT id FROM sys_trans WHERE `text`='all')\n\t\t) `log_types`\n\t\tLEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`log_types`.`trans_id` AND `sys_trans_text`.`lang`='&1'\n\t  ORDER BY `log_types`.`id` ASC", $opt['template']['locale'], $logtypes ? $logtypes[0] : 0);
    $tpl->assign_rs('logtype_options', $rs);
    sql_free_result($rs);
    // cache-attributes
    $attributes_jsarray = '';
    $bBeginLine2 = true;
    $nPrevLineAttrCount2 = 0;
    $nLineAttrCount2 = 0;
    $attributes_img2 = '';
    /* perpare 'all attributes' */
    $rsAttrGroup = sql("SELECT `attribute_groups`.`id`, IFNULL(`sys_trans_text`.`text`, `attribute_groups`.`name`) AS `name`, `attribute_categories`.`color` FROM `attribute_groups` INNER JOIN `attribute_categories` ON `attribute_groups`.`category_id`=`attribute_categories`.`id` LEFT JOIN `sys_trans` ON `attribute_groups`.`trans_id`=`sys_trans`.`id` AND `sys_trans`.`text`=`attribute_groups`.`name` LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1' ORDER BY `attribute_groups`.`category_id` ASC, `attribute_groups`.`id` ASC", $opt['template']['locale']);
    while ($rAttrGroup = sql_fetch_assoc($rsAttrGroup)) {
        $group_line = '';
        $rs = sql("SELECT `cache_attrib`.`id`, IFNULL(`ttname`.`text`, `cache_attrib`.`name`) AS `name`, `cache_attrib`.`icon_large`, `cache_attrib`.`icon_no`, `cache_attrib`.`icon_undef`, `cache_attrib`.`search_default`, IFNULL(`ttdesc`.`text`, `cache_attrib`.`html_desc`) AS `html_desc`\n\t\t             FROM `cache_attrib`\n\t\t        LEFT JOIN `sys_trans` AS `tname` ON `cache_attrib`.`trans_id`=`tname`.`id` AND `cache_attrib`.`name`=`tname`.`text`\n\t\t        LEFT JOIN `sys_trans_text` AS `ttname` ON `tname`.`id`=`ttname`.`trans_id` AND `ttname`.`lang`='&1'\n\t\t        LEFT JOIN `sys_trans` AS `tdesc` ON `cache_attrib`.`html_desc_trans_id`=`tdesc`.`id` AND `cache_attrib`.`html_desc`=`tdesc`.`text`\n\t\t        LEFT JOIN `sys_trans_text` AS `ttdesc` ON `tdesc`.`id`=`ttdesc`.`trans_id` AND `ttdesc`.`lang`='&1'\n\t\t            WHERE `cache_attrib`.`group_id`='&2' AND `selectable`\n\t\t\t\t\t  AND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1\n\t\t         ORDER BY `cache_attrib`.`id`", $opt['template']['locale'], $rAttrGroup['id']);
        while ($record = sql_fetch_array($rs)) {
            // icon specified
            $line = $cache_attrib_jsarray_line;
            $line = mb_ereg_replace('{id}', $record['id'], $line);
            if (!isset($options['cache_attribs'])) {
                $line = mb_ereg_replace('{state}', 0, $line);
            } else {
                if (array_search($record['id'], $options['cache_attribs']) === false) {
                    if (array_search($record['id'], $options['cache_attribs_not']) === false) {
                        $line = mb_ereg_replace('{state}', 0, $line);
                    } else {
                        $line = mb_ereg_replace('{state}', 2, $line);
                    }
                } else {
                    $line = mb_ereg_replace('{state}', 1, $line);
                }
            }
            $line = mb_ereg_replace('{text_long}', escape_javascript($record['name']), $line);
            $line = mb_ereg_replace('{icon}', $record['icon_large'], $line);
            $line = mb_ereg_replace('{icon_no}', $record['icon_no'], $line);
            $line = mb_ereg_replace('{icon_undef}', $record['icon_undef'], $line);
            $line = mb_ereg_replace('{search_default}', $record['search_default'], $line);
            if ($attributes_jsarray != '') {
                $attributes_jsarray .= ",\n";
            }
            $attributes_jsarray .= $line;
            $line = $cache_attrib_img_line1;
            $line = mb_ereg_replace('{id}', $record['id'], $line);
            $line = mb_ereg_replace('{text_long}', escape_javascript($record['name']), $line);
            if (!isset($options['cache_attribs'])) {
                $line = mb_ereg_replace('{icon}', $record['icon_undef'], $line);
            } else {
                if (array_search($record['id'], $options['cache_attribs']) === false) {
                    if (array_search($record['id'], $options['cache_attribs_not']) === false) {
                        $line = mb_ereg_replace('{icon}', $record['icon_undef'], $line);
                    } else {
                        $line = mb_ereg_replace('{icon}', $record['icon_no'], $line);
                    }
                } else {
                    $line = mb_ereg_replace('{icon}', $record['icon_large'], $line);
                }
            }
            $line = mb_ereg_replace('{html_desc}', escape_javascript($record['html_desc']), $line);
            $line = mb_ereg_replace('{name}', escape_javascript($record['name']), $line);
            $line = mb_ereg_replace('{color}', $rAttrGroup['color'], $line);
            $group_line .= $line;
            $nLineAttrCount2++;
        }
        sql_free_result($rs);
        if ($group_line != '') {
开发者ID:kirstenko,项目名称:oc-server3,代码行数:67,代码来源:search.php


示例10: foreach

  <tbody>
    <?php 
foreach ($permission_list as $permission) {
    ?>
    <tr>
      <td><?php 
    echo $permission->getTitle();
    ?>
</td>
      <td><?php 
    echo $permission->getCode();
    ?>
</td>
      <td>
        <?php 
    echo jq_link_to_function('edit', "fillForm(" . $permission->getId() . ", '" . escape_javascript($permission->getTitle()) . "', '" . $permission->getCode() . "')", array('class' => 'link-edit'));
    ?>
        <?php 
    echo link_to('remove', 'permission/delete?id=' . $permission->getId(), array('class' => 'link-de-activate', 'method' => 'delete', 'confirm' => 'Are you sure to delete \'' . $permission->choiceText() . '\'?'));
    ?>
      </td>
    </tr>
    <?php 
}
?>
  </tbody>
</table>



Items per page:
开发者ID:yasirgit,项目名称:afids,代码行数:31,代码来源:_list.php


示例11: javascript_tag

echo javascript_tag("\nfunction insertGadget(type, id, caption)\n{\n  var parentIframe = parent.document.getElementsByTagName('iframe')[0];\n\n  var typeId = 'plot' + type.charAt(0).toUpperCase() + type.substr(1, type.length - 1);\n  var target = parentIframe.contentWindow.document.getElementById(typeId).getElementsByClassName('emptyGadget')[0];\n  var contents = parentIframe.contentWindow.document.createElement('div');\n  contents.setAttribute('class', 'gadget');\n  contents.innerHTML = caption+'(<a href=\\'#\\' onclick=\\'dropNewGadget(\"'+type+'\", \"'+id+'\", this.parentNode); return false;\\'>" . __('削除') . "</a>)';\n  new Insertion.Before(target, contents);\n\n  var form = parent.document.getElementById('gadgetForm');\n  var hidden = parent.document.createElement('input');\n  hidden.setAttribute('class', type + 'New');\n  hidden.setAttribute('type', 'hidden');\n  hidden.setAttribute('name', 'new[' + type + '][]');\n  hidden.setAttribute('value', id);\n  new Insertion.Bottom(form, hidden);\n\n  parentIframe.contentWindow.parent.adjustByIframeContens(parentIframe);\n}\n");
?>


<dl>
<?php 
if ($config) {
    foreach ($config as $key => $value) {
        ?>
<dt>
<?php 
        echo __($value['caption']['ja_JP']);
        ?>
<br />
<?php 
        echo link_to_function(__('このガジェットを追加する'), 'insertGadget(\'' . $type . '\', \'' . escape_javascript($key) . '\', \'' . escape_javascript(__($value['caption']['ja_JP'])) . '\')');
        ?>
</dt>
<dd><?php 
        echo __($value['description']['ja_JP']);
        ?>
</dd>
<?php 
    }
} else {
    ?>
<dt><?php 
    echo __('ガジェットがありません');
    ?>
</dt>
<dd><?php 
开发者ID:kawahara,项目名称:OpenPNE3,代码行数:31,代码来源:addGadgetSuccess.php


示例12: outputSearchForm


//.........这里部分代码省略.........
            $logtype_options .= '<option value="' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($record['name'], ENT_COMPAT, 'UTF-8') . '</option>';
        }
        $logtype_options .= "\n";
    }
    tpl_set_var('logtype_options', $logtype_options);
    // cache-attributes
    $attributes_jsarray = '';
    $bBeginLine2 = true;
    $nPrevLineAttrCount2 = 0;
    $nLineAttrCount2 = 0;
    $attributes_img2 = '';
    /* perpare 'all attributes' */
    $rsAttrGroup = sql("SELECT `attribute_groups`.`id`, IFNULL(`sys_trans_text`.`text`, `attribute_groups`.`name`) AS `name`, `attribute_categories`.`color` FROM `attribute_groups` INNER JOIN `attribute_categories` ON `attribute_groups`.`category_id`=`attribute_categories`.`id` LEFT JOIN `sys_trans` ON `attribute_groups`.`trans_id`=`sys_trans`.`id` AND `sys_trans`.`text`=`attribute_groups`.`name` LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1' ORDER BY `attribute_groups`.`category_id` ASC, `attribute_groups`.`id` ASC", $locale);
    while ($rAttrGroup = sql_fetch_assoc($rsAttrGroup)) {
        $group_line = '';
        $rs = sql("SELECT `cache_attrib`.`id`, IFNULL(`ttname`.`text`, `cache_attrib`.`name`) AS `name`, `cache_attrib`.`icon_large`, `cache_attrib`.`icon_no`, `cache_attrib`.`icon_undef`, `cache_attrib`.`search_default`, IFNULL(`ttdesc`.`text`, `cache_attrib`.`html_desc`) AS `html_desc`\n\t\t             FROM `cache_attrib` \n\t\t        LEFT JOIN `sys_trans` AS `tname` ON `cache_attrib`.`trans_id`=`tname`.`id` AND `cache_attrib`.`name`=`tname`.`text`\n\t\t        LEFT JOIN `sys_trans_text` AS `ttname` ON `tname`.`id`=`ttname`.`trans_id` AND `ttname`.`lang`='&1'\n\t\t        LEFT JOIN `sys_trans` AS `tdesc` ON `cache_attrib`.`html_desc_trans_id`=`tdesc`.`id` AND `cache_attrib`.`html_desc`=`tdesc`.`text`\n\t\t        LEFT JOIN `sys_trans_text` AS `ttdesc` ON `tdesc`.`id`=`ttdesc`.`trans_id` AND `ttdesc`.`lang`='&1'\n\t\t            WHERE `cache_attrib`.`group_id`='&2'\n\t\t\t\t\t  AND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1\n\t\t         ORDER BY `cache_attrib`.`id`", $locale, $rAttrGroup['id']);
        while ($record = sql_fetch_array($rs)) {
            // icon specified
            $line = $cache_attrib_jsarray_line;
            $line = mb_ereg_replace('{id}', $record['id'], $line);
            if (!isset($options['cache_attribs'])) {
                $line = mb_ereg_replace('{state}', 0, $line);
            } else {
                if (array_search($record['id'], $options['cache_attribs']) === false) {
                    if (array_search($record['id'], $options['cache_attribs_not']) === false) {
                        $line = mb_ereg_replace('{state}', 0, $line);
                    } else {
                        $line = mb_ereg_replace('{state}', 2, $line);
                    }
                } else {
                    $line = mb_ereg_replace('{state}', 1, $line);
                }
            }
            $line = mb_ereg_replace('{text_long}', escape_javascript($record['name']), $line);
            $line = mb_ereg_replace('{icon}', $record['icon_large'], $line);
            $line = mb_ereg_replace('{icon_no}', $record['icon_no'], $line);
            $line = mb_ereg_replace('{icon_undef}', $record['icon_undef'], $line);
            $line = mb_ereg_replace('{search_default}', $record['search_default'], $line);
            if ($attributes_jsarray != '') {
                $attributes_jsarray .= ",\n";
            }
            $attributes_jsarray .= $line;
            $line = $cache_attrib_img_line1;
            $line = mb_ereg_replace('{id}', $record['id'], $line);
            $line = mb_ereg_replace('{text_long}', escape_javascript($record['name']), $line);
            if (!isset($options['cache_attribs'])) {
                $line = mb_ereg_replace('{icon}', $record['icon_undef'], $line);
            } else {
                if (array_search($record['id'], $options['cache_attribs']) === false) {
                    if (array_search($record['id'], $options['cache_attribs_not']) === false) {
                        $line = mb_ereg_replace('{icon}', $record['icon_undef'], $line);
                    } else {
                        $line = mb_ereg_replace('{icon}', $record['icon_no'], $line);
                    }
                } else {
                    $line = mb_ereg_replace('{icon}', $record['icon_large'], $line);
                }
            }
            $line = mb_ereg_replace('{html_desc}', escape_javascript($record['html_desc']), $line);
            $line = mb_ereg_replace('{name}', escape_javascript($record['name']), $line);
            $line = mb_ereg_replace('{color}', $rAttrGroup['color'], $line);
            $group_line .= $line;
            $nLineAttrCount2++;
        }
        sql_free_result($rs);
        if ($group_line != '') {
开发者ID:RH-Code,项目名称:opencaching,代码行数:67,代码来源:search.php


示例13: pagination_limit_select

 /**
  * Paging html functions
  *  @todo Document this API
  */
 function pagination_limit_select($object_name_or_object, $options = array())
 {
     $html = "";
     if (is_object($object_name_or_object)) {
         $object = $object_name_or_object;
     } else {
         $object = $this->object($object_name_or_object);
     }
     if (!is_object($object)) {
         return null;
     }
     if ($object->pages > 0) {
         $base_url = isset($options['base_url']) ? $options['base_url'] : '';
         $update = isset($options['update']) ? $options['update'] : '';
         $extra_params = isset($options['extra_params']) ? "&" . $options['extra_params'] : ($object->paging_extra_params ? "&" . $object->paging_extra_params : '');
         $default_text = isset($options['default_text']) ? $options['default_text'] : "per page:";
         if ($update && $base_url) {
             $on_change = remote_function(array("update" => $update, "url" => "{$base_url}?per_page=' + this.options[this.selectedIndex].value + '" . escape_javascript($extra_params) . "'"));
         } else {
             $on_change = "document.location = '{$base_url}?per_page=' + this.options[this.selectedIndex].value + '" . escape_javascript($extra_params) . "'";
         }
         $html .= "\n                <select name=\"per_page\" onChange=\"{$on_change}\">\n                    <option value=\"{$object->rows_per_page}\" selected>{$default_text}</option>\n                    <option value=10>10</option>\n                    <option value=20>20</option>\n                    <option value=50>50</option>\n                    <option value=100>100</option>\n                    <option value=200>200</option>\n                    <option value=999999999>ALL</option>\n                </select>\n            ";
     }
     return $html;
 }
开发者ID:phpontrax,项目名称:trax,代码行数:29,代码来源:active_record_helper.php


示例14: _escape_body

function _escape_body()
{
    $result = ob_get_contents();
    ob_end_clean();
    $htmlEscape = _tag_get_attribute('escape_body', 'htmlEscape');
    $jsEscape = _tag_get_attribute('escape_body', 'jsEscape');
    if (is_null($jsEscape) || !is_bool($jsEscape)) {
        $jsEscape = false;
    }
    if ($jsEscape == true) {
        $result = escape_javascript($result);
    }
    if ($htmlEscape == true) {
        $result = specialchars($result);
    }
    return $result;
}
开发者ID:qlixes,项目名称:springphp,代码行数:17,代码来源:bind_tags.php


示例15: remote_function

function remote_function($options)
{
    $obj =& get_instance();
    $obj->response->enqueue_js('prototype');
    $javascript_options = _options_for_ajax($options);
    $update = '';
    if (isset($options['update']) && is_array($options['update'])) {
        $update = array();
        if (isset($options['update']['success'])) {
            $update[] = "success:'" . $options['update']['success'] . "'";
        }
        if (isset($options['update']['failure'])) {
            $update[] = "failure:'" . $options['update']['failure'] . "'";
        }
        $update = '{' . join(',', $update) . '}';
    } else {
        if (isset($options['update'])) {
            $update .= "'" . $options['update'] . "'";
        }
    }
    $function = !$update ? "new Ajax.Request(" : "new Ajax.Updater({$update}, ";
    $function .= '\'' . system_url($options['url']) . '\'';
    $function .= ', ' . $javascript_options . ')';
    if (isset($options['before'])) {
        $function = $options['before'] . '; ' . $function;
    }
    if (isset($options['after'])) {
        $function = $function . '; ' . $options['after'];
    }
    if (isset($options['condition'])) {
        $function = 'if (' . $options['condition'] . ') { ' . $function . '; }';
    }
    if (isset($options['confirm'])) {
        $function = "if (confirm('" . escape_javascript($options['confirm']) . "')) { {$function}; }";
        if (isset($options['cancel'])) {
            $function = $function . ' else { ' . $options['cancel'] . ' }';
        }
    }
    return $function;
}
开发者ID:qlixes,项目名称:springphp,代码行数:40,代码来源:prototype_helper.php


示例16: jq_link_to_function

function jq_link_to_function($name, $function, $html_options = array())
{
    $html_options = _parse_attributes($html_options);
    $html_options['href'] = isset($html_options['href']) ? $html_options['href'] : '#';
    if (isset($html_options['confirm'])) {
        $confirm = escape_javascript($html_options['confirm']);
        $html_options['onclick'] = "if(confirm('{$confirm}')){ {$function};}; return false;";
        // [email protected]: without this we get a confirm attribute, which breaks confirm() in IE
        // (we could call window.confirm, but there is no reason to have the
        // nonstandard confirm attribute)
        unset($html_options['confirm']);
    } else {
        $html_options['onclick'] = $function . '; return false;';
    }
    return content_tag('a', $name, $html_options);
}
开发者ID:slemoigne,项目名称:sympal,代码行数:16,代码来源:jQueryHelper.php


示例17: ob_get_contents

                }
            }
        }
        if ($ob_active) {
            $user_fields[$icu] = ob_get_contents();
            ob_end_clean();
        }
        foreach ($user_cats as $category) {
            if (array_key_exists($category['field_cat'], $user_fields) && $user_fields[$category['field_cat']]) {
                echo "<tr>\n";
                echo "<td colspan='2' class='tbl2'><strong>" . $category['field_cat_name'] . "</strong></td>\n";
                echo "</tr>\n" . $user_fields[$category['field_cat']];
            }
        }
    }
    if ($settings['enable_terms'] == 1) {
        echo "<tr>\n<td class='tbl'>" . $locale['508'] . "<span style='color:#ff0000'>*</span></td>\n";
        echo "<td class='tbl'><input type='checkbox' id='agreement' name='agreement' value='1' onclick='checkagreement()' /> <span class='small'><label for='agreement'>" . $locale['509'] . "</label></span></td>\n";
        echo "</tr>\n";
    }
    echo "<tr>\n<td align='center' colspan='2'><br />\n";
    echo "<input type='submit' name='register' value='" . $locale['506'] . "' class='button'" . ($settings['enable_terms'] == 1 ? " disabled='disabled'" : "") . " />\n";
    echo "</td>\n</tr>\n</table>\n</form>\n";
    closetable();
    echo "<script type='text/javascript'>\r\nfunction ValidateForm(frm) {\r\n\tif (frm.username.value==\"\") {\r\n\t\talert(" . escape_javascript($locale['550']) . ");\r\n\t\treturn false;\r\n\t}\r\n\tif (frm.password1.value==\"\") {\r\n\t\talert(" . escape_javascript($locale['551']) . ");\r\n\t\treturn false;\r\n\t}\r\n\tif (frm.email.value==\"\") {\r\n\t\talert(" . escape_javascript($locale['552']) . ");\r\n\t\treturn false;\r\n\t}\r\n}\r\n</script>\n";
    // Pimped: JavaScript
    if ($settings['enable_terms'] == 1) {
        echo "<script language='JavaScript' type='text/javascript'>\r\n\t\t\tfunction checkagreement() {\r\n\t\t\t\tif(document.inputform.agreement.checked) {\r\n\t\t\t\t\tdocument.inputform.register.disabled=false;\r\n\t\t\t\t} else {\r\n\t\t\t\t\tdocument.inputform.register.disabled=true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t</script>";
    }
}
require_once TEMPLATES . "footer.php";
开发者ID:MichaelFichtner,项目名称:RadioLaFamilia,代码行数:31,代码来源:register.php


示例18: render

    /**
     * @param  string $name        The element name
     * @param  string $value       The date displayed in this widget
     * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
     * @param  array  $errors      An array of errors for the field
     *
     * @return string An HTML tag string
     *
     * @see sfWidgetForm
     */
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {
        $visible_value = escape_javascript($this->getOption('value_callback') ? call_user_func($this->getOption('value_callback'), $value) : $value);

        sfContext::getInstance()->getConfiguration()->loadHelpers('Url');

        $id = $this->generateId($name);

        $return = $this->renderTag('input', array(
            'type'  => 'hidden',
            'name'  => $name,
            'value' => $value
        ));

        $return .= sprintf(<<<EOF
<script type="text/javascript">
function defaultFormatResult(item)
{
    return item.text;
}

function defaultFormatNoMatches(term)
{
    return 'Keine Ergebnisse gefunden.';
}

function defaultFormatInputTooShort(term, minLength)
{
    return 'Bitte geben Sie mind. ' + minLength + ' Zeichen ein.';
}

jQuery("#%s").select2(
{
    width:                  '%s',
    minimumInputLength:     %s,
    placeholder:            '%s',
    allowClear:             %s,
    formatSelection:        %s,
    formatResult:           %s,
    formatNoMatches:        %s,
    formatInputTooShort:    %s,
    containerCss:           '%s',
    containerCssClass:      '%s',
    dropdownCss:            '%s',
    dropdownCssClass:       '%s',
    ajax: {
        url:        '%s',
        dataType:   'json',
        quietMillis: 100,
        data:       function (term, page)
        {
            return {
                q:     term,
                limit: 10,
                page:  page
            };
        },
        results: function (data, page)
        {
            var more = (page * 10) < data.total;

            return {results: data.items, more: more};
        }
    }
});

jQuery('#%s').select2('data', { id: '%s', text: '%s' });
</script>
EOF
            ,
            $id,
            $this->getOption('width'),
            $this->getOption('minimumInputLength'),
            $this->getOption('placeholder', ''),
            $this->getOption('allowClear') == true ? 'true' : 'false',
            $this->getOption('formatSelection'),
            $this->getOption('formatResult'),
            $this->getOption('formatNoMatches'),
            $this->getOption('formatInputTooShort'),
            $this->getOption('containerCss'),
            $this->getOption('containerCssClass'),
            $this->getOption('dropdownCss'),
            $this->getOption('dropdownCssClass'),
            url_for($this->getOption('url')),
            $id,
            $value,
            $visible_value ? $visible_value : $this->getOption('placeholder', '')
        );

        return $return;
//.........这里部分代码省略.........
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:101,代码来源:sfWidgetFormSelect2Autocompleter.class.php



注:本文中的escape_javascript函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP escape_js函数代码示例发布时间:2022-05-15
下一篇:
PHP escape_html_whitespace函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap