本文整理汇总了PHP中h函数的典型用法代码示例。如果您正苦于以下问题:PHP h函数的具体用法?PHP h怎么用?PHP h使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了h函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* @author Gaetan SENELLE
* @return Response
*/
public function render()
{
$response = new Response();
$exception = $this->error;
$code = $this->_code($exception);
$message = $this->_message($exception, $code);
$url = $this->controller->request->here();
$isDebug = Configure::read('debug');
$response->statusCode($code);
if (method_exists($exception, 'responseHeader')) {
$this->controller->response->header($exception->responseHeader());
}
$classname = get_class($exception);
if (preg_match('@\\\\([\\w]+)$@', $classname, $matches)) {
$classname = $matches[1];
} else {
$classname = null;
}
if (!$isDebug && !$exception instanceof ApiException && !$exception instanceof HttpException) {
$classname = null;
}
$data = ['exception' => ['type' => $classname, 'message' => $message, 'url' => h($url), 'code' => $code], 'success' => false];
$response->body(json_encode($data));
$response->type('json');
return $response;
}
示例2: ElemInit
function ElemInit()
{
$id = (int) get('id', 0);
$root_id = domainRootID();
if ($id) {
// если нет своего value, то вывести value из языка по умолчанию
# получаем данные по id
$row = sql_getRow('SELECT id,module,name,def,value FROM strings WHERE id=' . $id);
if (!$row['value'] || !$row['def']) {
# получаем данные для такого module, name
$temp_row = sql_getRow('SELECT * FROM strings WHERE module="' . $row['module'] . '" AND name="' . $row['name'] . '" AND lang="' . LANG_DEFAULT . '" AND root_id=' . getMainRootID());
if ($temp_row) {
if ($temp_row['value']) {
$row['value'] = $temp_row['value'];
}
if ($temp_row['def']) {
$row['def'] = $temp_row['def'];
}
}
}
$this->elem_fields['columns']['value']['value'] = h($row['value']);
$this->elem_fields['columns']['def'] = array('type' => 'hidden', 'value' => h($row['def']));
}
$this->elem_fields['columns']['root_id'] = array('type' => 'select', 'func' => 'getRoots');
if (!$id && $root_id) {
$this->elem_fields['columns']['root_id']['value'] = $root_id;
}
$this->elem_fields['columns']['lang'] = array('type' => 'hidden');
if (!$id) {
$this->elem_fields['columns']['lang']['value'] = '';
}
return parent::ElemInit();
}
示例3: __construct
public function __construct()
{
Language::read("common");
Language::read("microshop");
if (c("microshop_isuse") != "1") {
header("location: " . SiteUrl);
exit;
}
Tpl::setdir("default");
self::cp();
Tpl::setlayout("microshop_layout");
if ($_GET['column'] && strtoupper(CHARSET) == "GBK") {
$GLOBALS['_GET'] = Language::getgbk($_GET);
}
Tpl::output("nav_list", ($nav = f("nav")) ? $nav : h("nav", TRUE, "file"));
$search_type = array();
$search_type['goods'] = Language::get("nc_microshop_goods");
$search_type['personal'] = Language::get("nc_microshop_personal");
$search_type['store'] = Language::get("nc_microshop_store");
Tpl::output("search_type", $search_type);
if (!empty($_SESSION['member_id']) || 0 < intval($_SESSION['member_id'])) {
self::get_member_avatar($_SESSION['member_id']);
}
if (!c("site_status")) {
halt(c("closed_reason"));
}
Tpl::output("html_title", Language::get("nc_microshop") . "-" . c("site_name"));
Tpl::output("seo_keywords", c("microshop_seo_keywords"));
Tpl::output("seo_description", c("microshop_seo_description"));
$this->queryCart();
}
示例4: weibo
public function weibo()
{
// 解析参数
$_REQUEST['param'] = unserialize(urldecode($_REQUEST['param']));
$active_field = $_REQUEST['param']['active_field'] == 'title' ? 'title' : 'body';
$this->assign('has_status', $_REQUEST['param']['has_status']);
$this->assign('is_success_status', $_REQUEST['param']['is_success_status']);
$this->assign('status_title', t($_REQUEST['param']['status_title']));
// 解析模板(统一使用模板的body字段)
$_REQUEST['data'] = unserialize(urldecode($_REQUEST['data']));
$content = model('Template')->parseTemplate(t($_REQUEST['tpl_name']), array($active_field => $_REQUEST['data']));
// 设置微博发布框的权限
$type = array('at', 'image', 'video', 'file', 'contribute');
$actions = array();
foreach ($type as $value) {
$actions[$value] = false;
}
$this->assign('actions', $actions);
$this->assign('title', $content['title']);
$this->assign('initHtml', $content['body']);
$this->assign('content', h($content[$active_field]));
$this->assign('source', $_REQUEST['data']['source']);
$this->assign('sourceUrl', $_REQUEST['data']['url']);
$this->assign('type', $_REQUEST['data']['type']);
$this->assign('type_data', $_REQUEST['data']['type_data']);
$this->assign('button_title', t(urldecode($_REQUEST['button_title'])));
$this->assign('addon_info', urldecode($_REQUEST['addon_info']));
$this->display();
}
示例5: render
/**
* 实现接口
*
*/
function render()
{
//得到子菜单的标题
$menu_title = $this->_extract('menu');
//的到子菜单的属性
$sub_menu = Q::ini('appini/admin_sub_menus/' . $menu_title);
//是否存在
if (!is_array($sub_menu)) {
$sub_menu = array();
}
//得到当前的属性
$currentmenu = $this->_extract('current');
//输出子菜单 如果是当前的加上css
$out = "<ul>\n";
foreach ($sub_menu as $menu) {
//是否是当前菜单
if ($menu['title'] == $currentmenu) {
$out .= "<li class=\"current\">";
} else {
$out .= "<li>";
}
$out .= '<a href="' . url($menu['udi']) . '"> <span>';
$out .= h($menu['title']) . '</span>';
$out .= "</a></li>\n";
}
$out .= "</ul>\n";
return $out;
}
示例6: _initialize
function _initialize()
{
if (!is_numeric($_GET['uid']) && is_string($_GET['uid'])) {
$domainuser = D('User')->getUserByIdentifier(h($_GET['uid']), 'domain');
if ($domainuser) {
$this->uid = $domainuser['uid'];
$this->assign('uid', $this->uid);
} else {
$this->error(L('user_not_exist'));
}
} else {
$this->assign('uid', intval($_GET['uid']));
}
if ('detail' != ACTION_NAME) {
$user_info = D('User')->getUserByIdentifier($this->uid);
if ($user_info) {
$userinfo = array('Địa chỉ mblog' => U('home/Space/index', array('uid' => $user_info['domain'] ? $user_info['domain'] : $this->uid)), 'Giới tính' => getSex($user_info['sex']), 'Nơi sống' => $user_info['location']);
// 基本信息-钩子
Addons::hook('home_space_profile_base', array('uid' => $this->uid, 'user_info' => &$userinfo));
$this->assign('userinfo', $userinfo);
} else {
$this->error(L('user_not_exist'));
}
$this->__getSpaceCount($this->uid);
}
}
示例7: render
function render()
{
//路径
$baseDir = $this->_context->get('base_dir', $this->_context->baseDir() . 'js/fckeditor/');
$baseDir = h(rtrim($baseDir, '/\\') . '/');
$width = $this->get('width', "100%");
$height = $this->get('height', "250px");
$value = $this->get('value', '');
$class = $this->get('class', '');
//控件的id
$id = $this->id();
$config = $this->get('config');
if (!is_array($config)) {
$config = array();
}
$out = Q::control('memo', $id, array('value' => $value, 'class' => $class))->render();
$out .= <<<EOT
\t<script type="text/javascript" src="{$baseDir}fckeditor.js"></script>
<script type="text/javascript">
var oFCKeditor = new FCKeditor('{$id}');
oFCKeditor.BasePath = "{$baseDir}";
oFCKeditor.Height="{$height}";
oFCKeditor.Width="{$width}";
oFCKeditor.ReplaceTextarea();
</script>\t
EOT;
return $out;
}
示例8: output
/**
* Creates form fields and JavaScript includes to add a color picker widget.
* <code>
* $dh->output('background-color', '#f00');
* </code>
* @param string $inputName
* @param value $string
* @param array $options
*/
public function output($inputName, $value = null, $options = array())
{
$view = View::getInstance();
$view->requireAsset('core/colorpicker');
$form = Loader::helper('form');
$r = Request::getInstance();
if ($r->request->has($inputName)) {
$value = h($r->request->get($inputName));
}
$strOptions = '';
$i = 0;
$defaults = array();
$defaults['value'] = $value;
$defaults['className'] = 'ccm-widget-colorpicker';
$defaults['showInitial'] = true;
$defaults['showInput'] = true;
$defaults['allowEmpty'] = true;
$defaults['cancelText'] = t('Cancel');
$defaults['chooseText'] = t('Choose');
$defaults['preferredFormat'] = 'rgb';
$defaults['showAlpha'] = false;
$defaults['clearText'] = t('Clear Color Selection');
$defaults['appendTo'] = '.ui-dialog';
$strOptions = json_encode(array_merge($defaults, $options));
$identifier = new \Concrete\Core\Utility\Service\Identifier();
$identifier = $identifier->getString(32);
print "<input type=\"text\" data-color-picker=\"{$identifier}\" name=\"{$inputName}\" value=\"{$value}\" id=\"ccm-colorpicker-{$inputName}\" />";
print "<script type=\"text/javascript\">";
print "\$(function () { \$('[data-color-picker={$identifier}]').spectrum({$strOptions}); })";
print "</script>";
}
示例9: link
/**
* Create link containing a Font Awesome icon.
*
* @param string $icon Font Awesome icon (excluding the fa- prefix)
* @param string $title Link text
* @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://)
* @param array $options Array of options and HTML attributes.
* @param string $confirmMessage JavaScript confirmation message.
* @return string An `<a />` element.
*/
public function link($icon, $title, $url = null, $options = array(), $confirmMessage = false)
{
$escapeTitle = true;
if (isset($options['escapeTitle'])) {
$escapeTitle = $options['escapeTitle'];
unset($options['escapeTitle']);
} elseif (isset($options['escape'])) {
$escapeTitle = $options['escape'];
}
if ($escapeTitle === true) {
$title = h($title);
} elseif (is_string($escapeTitle)) {
$title = htmlentities($title, ENT_QUOTES, $escapeTitle);
}
// Determine whether to include a space between the icon and title.
$space = isset($options['space']) && $options['space'] === false ? '' : ' ';
// Append/Prepend the Font Awesome icon.
if (empty($title)) {
$title = '<i class="fa fa-' . $icon . '"></i>';
} elseif (empty($options['before'])) {
$title .= $space . '<i class="fa fa-' . $icon . '"></i>';
} else {
$title = '<i class="fa fa-' . $icon . '"></i>' . $space . $title;
}
unset($options['before']);
$options['escape'] = false;
return $this->Html->link($title, $url, $options, $confirmMessage);
}
示例10: saveArticle
/**
* 保存公告数据
* @param array $data 公告相关数据
* @return boolean|integer 若成功返回公告ID,失败返回false
*/
public function saveArticle($data)
{
// 处理数据
$add['uid'] = $save['uid'] = $GLOBALS['ts']['mid'];
$add['title'] = $save['title'] = t($data['title']);
$add['content'] = $save['content'] = h($data['content']);
$add['attach'] = $save['attach'] = trim(t($data['attach_ids']), '|');
// 附件ID
$add['mtime'] = $save['mtime'] = time();
$add['type'] = $save['type'] = intval($data['type']);
if (empty($add['title'])) {
$this->error = L('PUBLIC_COMMENT_MAIL_TITLE');
// 标题不可为空
return false;
}
if (empty($add['content'])) {
$this->error = L('PUBLIC_COMMENT_MAIL_REQUIRED');
// 内容不可为空
return false;
}
if (!empty($data['id'])) {
// 编辑操作
$map['id'] = $data['id'];
return $this->where($map)->save($save);
} else {
// 添加操作
if ($id = $this->add($add)) {
$edit['sort'] = $id;
return $this->where('id=' . $id)->save($edit);
}
}
}
示例11: pagesList
function pagesList($type)
{
global $self, $PG_DIR;
$list = array();
$dir = opendir($PG_DIR);
while ($file = readdir($dir)) {
if (preg_match("/\\.txt\$/", $file)) {
$files[] = substr($file, 0, strlen($file) - 4);
}
}
if (is_array($files)) {
sort($files);
foreach ($files as $file) {
$list[] = "<a href=\"{$self}?page=" . u($file) . "\">" . h($file) . "</a>";
}
}
if ($type == "comma") {
$ret = implode(", ", $list);
} else {
if ($type == "list") {
$ret = "<ul><li>" . implode("</li><li>", $list) . "</li></ul>";
}
}
return $ret;
}
示例12: view
public function view($page = 0) {
$list = new LogList();
$this->requireAsset('select2');
$levels = array();
foreach(Log::getLevels() as $level) {
$levels[$level] = Log::getLevelDisplayName($level);
}
$this->set('levels', $levels);
$channels = array('' => t('All Channels'));
foreach(Log::getChannels() as $channel) {
$channels[$channel] = Log::getChannelDisplayName($channel);
}
$r = Request::getInstance();
if ($r->query->has('channel') && $r->query->get('channel') != '') {
$list->filterByChannel($r->query->get('channel'));
$this->set('selectedChannel', h($r->query->get('channel')));
}
if ($r->query->has('level')) {
$selectedlevels = $r->get('level');
if (is_array($selectedlevels) && count($selectedlevels) != 8) {
$list->filterByLevels($selectedlevels);
}
}
if ($r->query->has('keywords') && $r->query->get('keywords') != '') {
$list->filterByKeywords($r->query->get('keywords'));
}
$entries = $list->getPage();
$this->set('list', $list);
$this->set('entries', $entries);
$this->set('levels', $levels);
$this->set('channels', $channels);
}
示例13: url
public function url($url, $full = false)
{
if (is_string($url) && preg_match(sprintf('/^%s.+/', preg_quote('//', '/')), $url)) {
return h($url);
}
return parent::url($url, $full);
}
示例14: auth_error
function auth_error($exception = null)
{
global $connection, $adminer, $token;
$session_name = session_name();
$error = "";
if (!$_COOKIE[$session_name] && $_GET[$session_name] && ini_bool("session.use_only_cookies")) {
$error = lang('Session support must be enabled.');
} elseif (isset($_GET["username"])) {
if (($_COOKIE[$session_name] || $_GET[$session_name]) && !$token) {
$error = lang('Session expired, please login again.');
} else {
$password =& get_session("pwds");
if (isset($password)) {
$error = h($exception ? $exception->getMessage() : (is_string($connection) ? $connection : lang('Invalid credentials.')));
$password = null;
}
}
}
page_header(lang('Login'), $error, null);
echo "<form action='' method='post' onclick='eventStop(event);'>\n";
$adminer->loginForm();
echo "<div>";
hidden_fields($_POST, array("driver", "server", "username", "password", "permanent"));
// expired session
echo "</div>\n";
echo "</form>\n";
page_footer("auth");
}
示例15: getBody
public static function getBody()
{
$result = '';
foreach (self::$data as $title => $data) {
$result .= '<table border="1" style="width:90%; background:#eee; font-size:12px; color:#222; text-align:left; border-collapse:collapse;">';
// head line
if (is_array($data['meta']) && count($data['meta'])) {
$result .= '<tr>';
foreach ($data['meta'] as $cell) {
$result .= '<th style="background:#bdb; padding:7px;">' . h($cell) . '</th>';
}
$result .= '</tr>';
}
// information lines
if (is_array($data['data']) && count($data['data'])) {
foreach ($data['data'] as $row) {
$result .= '<tr>';
foreach ($row as $cell) {
$result .= '<td style="padding:7px;">' . h($cell) . '</td>';
}
$result .= '</tr>';
}
}
$result .= '</table>';
}
return '<div style="clear:both;"></div>' . $result;
}