本文整理汇总了PHP中nl函数的典型用法代码示例。如果您正苦于以下问题:PHP nl函数的具体用法?PHP nl怎么用?PHP nl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: adjustNewlines
function adjustNewlines($text)
{
$text = str_replace("\r\n", "\n", $text);
// unix mode
return str_replace("\n", nl(), $text);
// ff mode
}
示例2: welcome_render_page_late
function welcome_render_page_late($args)
{
global $page_has_object;
if (!$args['edit'] || $page_has_object) {
return false;
}
// we only display the information when there are no other pages in the
// content directory except the current one
load_modules('glue');
$pns = pagenames(array());
$pns = $pns['#data'];
if (1 < count($pns)) {
return false;
}
html_add_css(base_url() . 'modules/welcome/welcome-edit.css');
html_add_js(base_url() . 'modules/welcome/welcome.js');
body_append('<div id="welcome-msg">' . nl());
body_append(tab() . '<span id="welcome-first"><img style="float:left; margin:5px 10px 0 5px" src="' . base_url() . 'modules/welcome/gun32.gif">Welcome to HOTGLUE!</span><br>' . nl());
body_append(tab() . 'Your Content Manipulation System is ready to go!' . nl());
body_append(tab() . '<p>A short intro before you start:</p>' . nl());
body_append(tab() . '<span id="cont"><span id="text"><b>1.</b> Right now you are in <u>editing mode</u>. You can use single and double click to access the menus - they will appear next to the mouse pointer.</span>' . nl());
body_append(tab() . '<span id="text"><b>2.</b> Click on the canvas (white background of the page) to open a menu which will let you create new objects, upload files and embed YouTube and Vimeo videos! Once you made an object click on it to activate its contextual menu.</span>' . nl());
body_append(tab() . '<span id="text"><b>3.</b> Double-click on the canvas will give you a menu of options to change preferences, show a grid, make new pages, set background picture and more!</span>' . nl());
body_append(tab() . '<span id="text"><b>4.</b> Remove "' . (SHORT_URLS ? '' : '?') . 'edit" from the address of the page (the URL) to see the "view-only" version. That\'s how your page will look to everyone else!</span>' . nl());
body_append(tab() . '<span id="text"><b>5.</b> To get back to editing mode add "' . (SHORT_URLS ? '' : '?') . 'edit" to the URL of the page.<br>(for example: ' . base_url() . '<b>' . (SHORT_URLS ? '' : '?') . 'edit</b>)</span></span>' . nl());
body_append(tab() . '<p>We recommend you to use <a href="http://firefox.com" target="_blank">Mozilla Firefox</a> browser when editing in HOTGLUE. Firefox is a very reliable and modern web-browser, it is our favorite!' . nl());
body_append(tab() . '<p>You can find more information on how to work with HOTGLUE on our <a href="http://hotglue.me" target="_blank">web-site</a>. Make sure to check out "<a href="http://hotglue.me/what" target="_blank">What is HOTGLUE?</a>" and "<a href="http://hotglue.me/how" target="_blank">How to HOTGLUE?</a>" pages!' . nl());
body_append(tab() . '<p>Enjoy! <span id="welcome-light">[click this message to make it go away]</span></p>' . nl());
body_append('</div>' . nl());
return true;
}
示例3: message
function message($userID, $string)
{
global $update;
$u = new User($userID);
$update = "<strong>UPDATE:</strong><br />" . nl();
$update .= ucfirst($u->username) . "'s " . $string;
}
示例4: log_msg
/**
* log a message to file
*
* @param string $level can be error, warn, info or debug
* @param string $msg message
* @return bool true if successful, false if not
*/
function log_msg($level, $msg)
{
global $logfile;
global $loglevels;
global $request_id;
// open logfile
if ($logfile === false) {
$m = umask(0111);
// having two processes appending to the same file should
// work fine (at least on Linux)
$logfile = @fopen(LOG_FILE, 'ab');
umask($m);
}
if ($logfile === false) {
return false;
}
foreach ($loglevels as $ll) {
if ($ll == $level) {
fwrite($logfile, date('Y-m-d H:i:s') . tab() . pad($_SERVER['REMOTE_ADDR'], 15) . tab() . sprintf('%05u', $request_id) . tab() . $level . tab() . $msg . nl());
fflush($logfile);
break;
}
if ($ll == LOG_LEVEL) {
break;
}
}
return true;
}
示例5: array_to_js
/**
* convert an associative array to a javascript block
*
* @param array $container container array
* @return string
*/
function array_to_js($container)
{
$ret = '<script type="text/javascript">' . nl();
// sort container by keys
ksort($container);
$exists = array();
foreach ($container as $key => $val) {
// make sure the keys exist
$objs = expl('.', $key);
for ($i = 0; $i < count($objs) - 1; $i++) {
$obj = implode('.', array_slice($objs, 0, $i + 1));
if (!in_array($obj, $exists)) {
if ($i == 0) {
$ret .= tab() . 'var ' . $obj . ' = ' . $obj . ' || {};' . nl();
} else {
$ret .= tab() . $obj . ' = ' . $obj . ' || {};' . nl();
}
$exists[] = $obj;
}
}
$ret .= tab() . '' . $key . ' = ' . json_encode($val) . ';' . nl();
}
$ret .= '</script>' . nl();
return $ret;
}
示例6: welcome_render_page_late
function welcome_render_page_late($args)
{
global $page_has_object;
if (!$args['edit'] || $page_has_object) {
return false;
}
// we only display the information when there are no other pages in the
// content directory except the current one
load_modules('glue');
$pns = pagenames(array());
$pns = $pns['#data'];
if (1 < count($pns)) {
return false;
}
html_add_css(base_url() . 'modules/welcome/welcome-edit.css');
html_add_js(base_url() . 'modules/welcome/welcome.js');
body_append('<div id="welcome-msg">' . nl());
body_append(tab() . '<span id="welcome-first">Welcome to HOTGLUE!</span><br>' . nl());
body_append(tab() . 'Your Content Manipulation System is ready to go!' . nl());
body_append(tab() . '<p>A short intro before you start:<br>' . nl());
body_append(tab() . '¤ To get back to editing mode in the future, add "' . (SHORT_URLS ? '' : '?') . 'edit" to the address in the address bar (i.e.: ' . base_url() . '<b>' . (SHORT_URLS ? '' : '?') . 'edit</b>)<br>' . nl());
body_append(tab() . '¤ In editing mode, you can use single and double click to access the menus.<br>' . nl());
body_append(tab() . '¤ Click the page\'s background once to open a menu that lets you create new objects, upload files and embed videos (YouTube and Vimeo).<br>' . nl());
body_append(tab() . '¤ Double-click to open a menu that allows you to change preferences, show a grid, make new pages and more.<br>' . nl());
body_append(tab() . '¤ Remove "' . (SHORT_URLS ? '' : '?') . 'edit" from the address in the address bar to go to the viewing-only mode of this page.</p>' . nl());
body_append(tab() . '<p>You can find more ideas on how to use HOTGLUE at the <a href="http://hotglue.me/how_basic" target="_blank">"How-to" section of our website</a>!' . nl());
body_append(tab() . '<p>Enjoy!<br>' . nl());
body_append(tab() . '<span id="welcome-light">[This message goes away when you click it]</span></p>' . nl());
body_append('</div>' . nl());
return true;
}
示例7: controller_user_css_stylesheet
/**
* controller that shows a textarea for editing either a page's or the global
* user-defined css file
*/
function controller_user_css_stylesheet($args)
{
if ($args[0][1] == 'stylesheet') {
// changing page stylesheet
$page = $args[0][0];
page_canonical($page);
if (!page_exists($page)) {
hotglue_error(404);
}
} else {
// changing global stylesheet
$page = false;
}
default_html(true);
html_add_js_var('$.glue.page', $page);
html_add_css(base_url() . 'modules/user_css/user_css.css');
if (USE_MIN_FILES) {
html_add_js(base_url() . 'modules/user_css/user_css.min.js');
} else {
html_add_js(base_url() . 'modules/user_css/user_css.js');
}
$bdy =& body();
elem_attr($bdy, 'id', 'user_css');
if ($page === false) {
body_append('<h1>Global stylesheet</h1>' . nl());
// try to load css
$css = @file_get_contents(CONTENT_DIR . '/usercss');
if ($css === false) {
$css = '';
}
} else {
body_append('<h1>' . htmlspecialchars($page, ENT_NOQUOTES, 'UTF-8') . ' stylesheet</h1>' . nl());
load_modules('glue');
$obj = load_object(array('name' => $page . '.usercss'));
if ($obj['#error']) {
$css = '';
} else {
$css = $obj['#data']['content'];
}
}
// encoding to html must come before the replacement below
$css = htmlspecialchars($css, ENT_NOQUOTES, 'UTF-8');
// replace newline characters by an entity to prevent render_object()
// from adding some indentation
$css = str_replace("\r\n", ' ', $css);
$css = str_replace("\n", ' ', $css);
// why not replace tabs as well why we are at it
$css = str_replace("\t", '	', $css);
body_append('<textarea id="user_css_text" placeholder="enter css code here">' . $css . '</textarea>' . nl());
body_append('<br>' . nl());
body_append('<input id="user_css_save" type="button" value="save">' . nl());
echo html_finalize();
}
示例8: controller_create_page
/**
* show a site where authenticated users can create new pages
*/
function controller_create_page($args)
{
page_canonical($args[0][0]);
$page = $args[0][0];
if (page_exists($page)) {
log_msg('debug', 'controller_create_page: page ' . quot($page) . 'already exists, invoking controller_edit');
controller_edit($args);
return;
}
load_modules('glue');
default_html(true);
html_add_css(base_url() . 'css/hotglue_error.css');
if (USE_MIN_FILES) {
html_add_js(base_url() . 'js/create_page.min.js');
} else {
html_add_js(base_url() . 'js/create_page.js');
}
html_add_js_var('$.glue.page', $page);
html_add_js_var('$.glue.q', SHORT_URLS ? '' : '?');
$bdy =& body();
elem_attr($bdy, 'id', 'create_page');
body_append(tab(1) . '<div id="paper">' . nl());
body_append(tab(2) . '<div id="wrapper">' . nl());
body_append(tab(3) . '<div id="content">' . nl());
body_append(tab(4) . '<div id="left-nav">' . nl());
body_append(tab(5) . '<img src="' . htmlspecialchars(base_url(), ENT_COMPAT, 'UTF-8') . 'img/hotglue-logo.png" alt="logo">' . nl());
body_append(tab(4) . '</div>' . nl());
body_append(tab(4) . '<div id="main">' . nl());
body_append(tab(5) . '<h1 id="error-title">Page does not exist yet!</h1>' . nl());
body_append(tab(5) . '<p>' . nl());
body_append(tab(6) . 'This page does not exist yet!<br>' . nl());
body_append(tab(6) . 'Would you like to create the page?' . nl());
body_append(tab(5) . '</p>' . nl());
body_append(tab(5) . '<form><input id="create_page_btn" type="button" value="Create it!"></form>' . nl());
body_append(tab(4) . '</div>' . nl());
body_append(tab(3) . '</div>' . nl());
body_append(tab(2) . '</div>' . nl());
body_append(tab(2) . '<div style="position: absolute; left: 200px; top: -10px; z-index: 2;">' . nl());
body_append(tab(3) . '<img src="' . htmlspecialchars(base_url(), ENT_COMPAT, 'UTF-8') . 'img/hotglue-404.png" alt="404">' . nl());
body_append(tab(2) . '</div>' . nl());
body_append(tab(1) . '</div>' . nl());
echo html_finalize();
}
示例9: mkPackage
function mkPackage($option, $caller, $pkg)
{
global $ff_admpath, $ff_version, $mosConfig_fileperms;
$id = $pkg;
$name = JRequest::getVar( 'pkg_name', '');
$title = JRequest::getVar( 'pkg_title', '');
$version = JRequest::getVar( 'pkg_version', '');
$created = date('Y-m-d H:i:s');
$author = JRequest::getVar( 'pkg_author', '');
$email = JRequest::getVar( 'pkg_email', '');
$url = JRequest::getVar( 'pkg_url', '');
$description = JRequest::getVar( 'pkg_description', '');
$copyright = JRequest::getVar( 'pkg_copyright', '');
savePackage($id, $name, $title, $version, $created, $author,
$email, $url, $description, $copyright);
$xmlname = $ff_admpath.'/packages/'.$name.'.xml';
$existed = file_exists($xmlname);
if ($existed)
if (!is_writable($xmlname))
die('XML file is not writable!');
$file= fopen($xmlname, "w");
$xml = '<?xml version="1.0" encoding="utf-8" ?>'.nl().
'<FacileFormsPackage';
if ($id != '') $xml .= ' id="'.$id.'"';
if ($id == '') $xml .= ' id="'.$name.'"';
$xml .=
' type="autoincrement" version="'.$ff_version.'">'.nl().
indent(1).'<name>'.expstring($name).'</name>'.nl().
indent(1).'<title>'.expstring($title).'</title>'.nl().
indent(1).'<version>'.expstring($version).'</version>'.nl().
indent(1).'<creationDate>'.$created.'</creationDate>'.nl().
indent(1).'<author>'.expstring($author).'</author>'.nl().
indent(1).'<authorEmail>'.expstring($email).'</authorEmail>'.nl().
indent(1).'<authorUrl>'.expstring($url).'</authorUrl>'.nl().
indent(1).'<description>'.expstring($description).'</description>'.nl().
indent(1).'<copyright>'.expstring($copyright).'</copyright>'.nl();
if ($id == '')
$ids = JRequest::getVar( 'scriptsel', array());
else {
$ids = array();
$rows = _ff_select(
"select id from #__facileforms_scripts ".
"where package = '$id' ".
"order by id"
);
if (count($rows)) foreach ($rows as $row) $ids[] = $row->id;
} // if
if (count($ids) > 0) {
$ids = implode(',', $ids);
$scripts = _ff_select(
"select * from #__facileforms_scripts where id in ($ids) order by package, name, id"
);
for ($s = 0; $s < count($scripts); $s++) {
$script = $scripts[$s];
$xml .= indent(1).'<script id="'.$script->id.'">'.nl();
if ($script->published != 1)
$xml .= indent(2).'<published>'.$script->published.'</published>'.nl();
if ($script->package != '')
$xml .= indent(2).'<package>'.expstring($script->package).'</package>'.nl();
$xml .= indent(2).'<name>'.expstring($script->name).'</name>'.nl().
indent(2).'<title>'.expstring($script->title).'</title>'.nl();
if ($script->type != 'Untyped')
$xml .= indent(2).'<type>'.expstring($script->type).'</type>'.nl();
$script->description = trim($script->description);
if ($script->description != '')
$xml .= indent(2).'<description>'.expstring($script->description).'</description>'.nl();
$script->code = trim($script->code);
if ($script->code != '')
$xml .= indent(2).'<code>'.expstring($script->code).'</code>'.nl();
$xml .= indent(1).'</script>'.nl();
} // for
} // if
if ($id == '')
$ids = JRequest::getVar( 'piecesel', array());
else {
$ids = array();
$rows = _ff_select(
"select id from #__facileforms_pieces ".
"where package = '$id' ".
"order by id"
);
if (count($rows)) foreach ($rows as $row) $ids[] = $row->id;
} // if
if (count($ids) > 0) {
$ids = implode(',', $ids);
$pieces = _ff_select(
"select * from #__facileforms_pieces where id in ($ids) order by package, name, id"
);
for ($p = 0; $p < count($pieces); $p++) {
$piece = $pieces[$p];
$xml .= indent(1).'<piece id="'.$piece->id.'">'.nl();
if ($piece->published != 1)
$xml .= indent(2).'<published>'.$piece->published.'</published>'.nl();
//.........这里部分代码省略.........
示例10: html_finalize
/**
* turn the page into a html string
*
* @param bool &$cache is output cachable (will only modified if $cache is
* true before)
* @return string html
*/
function html_finalize(&$cache = false)
{
global $html;
// return html5
$ret = '<!DOCTYPE html>' . nl();
$ret .= '<html';
if (@is_array($html['header']['style'])) {
$ret .= ' style="';
ksort($html['header']['style']);
foreach ($html['header']['style'] as $key => $val) {
$ret .= htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . ': ' . htmlspecialchars($val, ENT_COMPAT, 'UTF-8') . '; ';
}
// strip the last space
$ret = substr($ret, 0, -1);
$ret .= '"';
}
$ret .= '>' . nl();
$ret .= '<head>' . nl();
$ret .= '<title>' . htmlspecialchars($html['header']['title'], ENT_NOQUOTES, 'UTF-8') . '</title>' . nl();
$ret .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . nl();
if (@is_array($html['header']['alternate'])) {
foreach ($html['header']['alternate'] as $e) {
$ret .= '<link rel="alternate" type="' . htmlspecialchars($e['type'], ENT_COMPAT, 'UTF-8') . '" href="' . htmlspecialchars($e['url'], ENT_COMPAT, 'UTF-8') . '" title="' . htmlspecialchars($e['title'], ENT_COMPAT, 'UTF-8') . '">' . nl();
}
}
if (!empty($html['header']['favicon'])) {
$ret .= '<link rel="shortcut icon" href="' . htmlspecialchars($html['header']['favicon'], ENT_COMPAT, 'UTF-8') . '">' . nl();
}
if (@is_array($html['header']['css'])) {
_array_sort_by_prio($html['header']['css']);
// removed the removal of duplicates here as two different media might point to the same url
//array_unique_element($html['header']['css'], 'url');
foreach ($html['header']['css'] as $e) {
$ret .= '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($e['url'], ENT_COMPAT, 'UTF-8') . '"';
if (!empty($e['media'])) {
$ret .= ' media="' . htmlspecialchars($e['media'], ENT_COMPAT, 'UTF-8') . '"';
}
$ret .= '>' . nl();
}
}
if (@is_array($html['header']['css_inline'])) {
_array_sort_by_prio($html['header']['css_inline']);
if (0 < count($html['header']['css_inline'])) {
$ret .= '<style type="text/css">' . nl();
}
foreach ($html['header']['css_inline'] as $c) {
$rule = $c['rule'];
// if the rule ends with a newline character, remove it
if (substr($rule, -1) == "\n") {
$rule = substr($rule, 0, -1);
}
// move rule in by one tab
$rule = str_replace("\n", "\n\t", $rule);
$ret .= tab() . $rule . nl();
}
if (0 < count($html['header']['css_inline'])) {
$ret .= '</style>' . nl();
}
}
if (@is_array($html['header']['js'])) {
_array_sort_by_prio($html['header']['js']);
array_unique_element($html['header']['js'], 'url');
foreach ($html['header']['js'] as $e) {
$ret .= '<script type="text/javascript" src="' . htmlspecialchars($e['url'], ENT_COMPAT, 'UTF-8') . '"></script>' . nl();
}
}
if (@is_array($html['header']['js_var'])) {
$ret .= array_to_js($html['header']['js_var']);
}
if (@is_array($html['header']['js_inline'])) {
_array_sort_by_prio($html['header']['js_inline']);
foreach ($html['header']['js_inline'] as $c) {
if (!empty($c['reason'])) {
$ret .= '<!-- ' . $c['reason'] . ' -->' . nl();
$ret .= '<script type="text/javascript">' . nl();
// if the code ends with a newline character, remove it
if (substr($c['code'], -1) == "\n") {
$c['code'] = substr($c['code'], 0, -1);
}
// move code in by one tab
$c = str_replace("\n", "\n\t", $c);
$ret .= tab() . $c['code'] . nl();
$ret .= '</script>' . nl();
}
}
}
$ret .= '</head>' . nl();
$ret .= elem_finalize($html['body']);
$ret .= '</html>';
// pass caching information up if requested
if ($cache) {
if (!$html['cache']) {
$cache = false;
//.........这里部分代码省略.........
示例11: expcsv
function expcsv(array $ids)
{
global $ff_config;
$csvdelimiter = stripslashes($ff_config->csvdelimiter);
$csvquote = stripslashes($ff_config->csvquote);
$cellnewline = $ff_config->cellnewline == 0 ? "\n" : "\\n";
$fields = array();
$lines = array();
$ids = implode(',', $ids);
$this->db->setQuery(
"select * from #__facileforms_records where id in ($ids) order by submitted Desc"
);
$recs = $this->db->loadObjectList();
$recsSize = count($recs);
for($r = 0; $r < $recsSize; $r++) {
$rec = $recs[$r];
$lineNum = count($lines);
$fields['ZZZ_A_ID'] = true;
$fields['ZZZ_B_SUBMITTED'] = true;
$fields['ZZZ_C_USER_ID'] = true;
$fields['ZZZ_D_USERNAME'] = true;
$fields['ZZZ_E_USER_FULL_NAME'] = true;
$fields['ZZZ_F_TITLE'] = true;
$fields['ZZZ_G_IP'] = true;
$fields['ZZZ_H_BROWSER'] = true;
$fields['ZZZ_I_OPSYS'] = true;
$fields['ZZZ_J_TRANSACTION_ID'] = true;
$fields['ZZZ_K_DATE'] = true;
$fields['ZZZ_L_TEST_ACCOUNT'] = true;
$fields['ZZZ_M_DOWNLOAD_TRIES'] = true;
$lines[$lineNum]['ZZZ_A_ID'][] = $rec->id;
$lines[$lineNum]['ZZZ_B_SUBMITTED'][] = $rec->submitted;
$lines[$lineNum]['ZZZ_C_USER_ID'][] = $rec->user_id;
$lines[$lineNum]['ZZZ_D_USERNAME'][] = $rec->username;
$lines[$lineNum]['ZZZ_E_USER_FULL_NAME'][] = $rec->user_full_name;
$lines[$lineNum]['ZZZ_F_TITLE'][] = $rec->title;
$lines[$lineNum]['ZZZ_G_IP'][] = $rec->ip;
$lines[$lineNum]['ZZZ_H_BROWSER'][] = $rec->browser;
$lines[$lineNum]['ZZZ_I_OPSYS'][] = $rec->opsys;
$lines[$lineNum]['ZZZ_J_TRANSACTION_ID'][] = $rec->paypal_tx_id;
$lines[$lineNum]['ZZZ_K_DATE'][] = $rec->paypal_payment_date;
$lines[$lineNum]['ZZZ_L_TEST_ACCOUNT'][] = $rec->paypal_testaccount;
$lines[$lineNum]['ZZZ_M_DOWNLOAD_TRIES'][] = $rec->paypal_download_tries;
$rec = $recs[$r];
$this->db->setQuery(
"select Distinct * from #__facileforms_subrecords where record = $rec->id order by id"
);
$subs = $this->db->loadObjectList();
$subsSize = count($subs);
for($s = 0; $s < $subsSize; $s++) {
$sub = $subs[$s];
if($sub->name != 'bfFakeName' && $sub->name != 'bfFakeName2' && $sub->name != 'bfFakeName3' && $sub->name != 'bfFakeName4'){
if(!isset($fields[strtoupper($sub->name)]))
{
$fields[strtoupper($sub->name)] = true;
}
$lines[$lineNum][strtoupper($sub->name)][] = $sub->value;
}
}
}
$head = '';
ksort($fields);
$lineLength = count($lines);
foreach($fields As $fieldName => $null)
{
$head .= $csvquote.$fieldName.$csvquote.$csvdelimiter;
for($i = 0; $i < $lineLength;$i++)
{
if(!isset($lines[$i][$fieldName]))
{
$lines[$i][$fieldName] = array();
}
}
}
$head = substr($head,0,strlen($head)-1) . nl();
$out = '';
for($i = 0; $i < $lineLength;$i++)
{
ksort($lines[$i]);
foreach($lines[$i] As $line){
$out .= $csvquote.str_replace($csvquote,$csvquote.$csvquote,str_replace("\n",$cellnewline,str_replace("\r","",implode('|',$line)))).$csvquote.$csvdelimiter;
}
$out = substr($out,0,strlen($out)-1);
$out .= nl();
}
$csvname = JPATH_SITE.'/components/com_breezingforms/exports/ffexport-'.date('YmdHis').'.csv';
JFile::makeSafe($csvname);
if (!JFile::write($csvname,$head.$out)) {
echo "<script> alert('".addslashes(BFText::_('COM_BREEZINGFORMS_RECORDS_XMLNORWRTBL'))."'); window.history.go(-1);</script>\n";
//.........这里部分代码省略.........
示例12: controller_user_code_stylesheet
/**
* controller that shows a textarea for editing either a page's or the global
* user-defined code files
*/
function controller_user_code_stylesheet($args)
{
if ($args[0][1] == 'code') {
// changing page code
$page = $args[0][0];
page_canonical($page);
if (!page_exists($page)) {
hotglue_error(404);
}
} else {
// changing global code
$page = false;
}
default_html(true);
html_add_js_var('$.glue.page', $page);
html_add_css(base_url() . 'modules/user_code/user_code.css');
if (USE_MIN_FILES) {
html_add_js(base_url() . 'modules/user_code/user_code.min.js');
} else {
html_add_js(base_url() . 'modules/user_code/user_code.js');
}
$bdy =& body();
// create array with names of code elements
$code = array('head' => '', 'body' => '');
elem_attr($bdy, 'id', 'user_code');
if ($page === false) {
body_append('<h1>Global code</h1>' . nl());
// try to load code
foreach ($code as $x => $v) {
$code[$x] = @file_get_contents(CONTENT_DIR . '/user' . $x);
if ($code[$x] === false) {
$code[$x] = '';
}
}
} else {
body_append('<h1>"' . htmlspecialchars(substr($page, 0, strpos($page, '.')), ENT_NOQUOTES, 'UTF-8') . '" page code</h1>' . nl());
load_modules('glue');
foreach ($code as $x => $v) {
$obj = load_object(array('name' => $page . '.user' . $x));
if ($obj['#error']) {
$code[$x] = '';
} else {
$code[$x] = $obj['#data']['content'];
}
}
}
foreach ($code as $k => $v) {
// encoding to html must come before the replacement below
$v = htmlspecialchars($v, ENT_NOQUOTES, 'UTF-8');
// replace newline characters by an entity to prevent render_object()
// from adding some indentation
$v = str_replace("\r\n", ' ', $v);
$v = str_replace("\n", ' ', $v);
// why not replace tabs as well why we are at it
$v = str_replace("\t", '	', $v);
$code[$k] = $v;
}
body_append('<div id=\'text\'>add your custom code to <head> and <body> sections of this ' . ($page ? 'page.' : 'site.') . nl());
body_append('<br>' . nl());
body_append('be cautious - errors in the code below may render the whole ' . ($page ? 'page' : 'site') . ' unusable.</div>' . nl());
body_append('<br>' . nl());
body_append('<div id=\'fake_tags\'><head></div>' . nl());
body_append('<textarea id="user_head_text" placeholder="enter code here">' . $code['head'] . '</textarea>' . nl());
body_append('<br>' . nl());
body_append('<div id=\'fake_tags\'></head><br>' . nl());
body_append('<body></div>' . nl());
body_append('<textarea id="user_body_text" placeholder="enter code here">' . $code['body'] . '</textarea>' . nl());
body_append('<div id=\'fake_tags\'></body></div><br>' . nl());
body_append('<input id="user_code_save" type="button" value="save">' . nl());
echo html_finalize();
}
示例13: camelcase2space
// Get the user specific values from the Options_users table
$val = Options::userGet($userId, $option);
$label = camelcase2space($option);
echo '<div class="control-group">' . nl();
echo ' <label class="control-label" for="' . $option . '">' . $label . '</label>' . nl();
echo ' <div class="controls">' . nl();
if ($type == 'input') {
echo '<input type="text" class="input-xlarge" id="' . $option . '" name="' . $option . '" value="' . $val . '">' . nl();
}
if ($type == 'textarea') {
echo '<textarea class="textarea input-xxlarge" id="' . $option . '" name="' . $option . '">' . $val . '</textarea>' . nl();
}
if ($type == 'bool') {
echo bool_select($val, $option);
}
if ($type == 'date') {
echo mdy($val, $option, 'd m y');
}
echo "</div></div>" . nl();
}
}
?>
<!-- Finish it off with the save button -->
<div class="controls">
<input type="submit" name='action' class="btn btn-primary btn-large" value="Save Changes">
</div>
</form>
</div>
</div>
示例14: system
system($command);
nl();
$command = $tempDir . '/phd/pear/phd -g \'phpdotnet\phd\Highlighter_GeSHi\' --xinclude -f zfpackage -d '
. $tempDir . '/manual2.full.xml -o ' . $tempDir . '/manual-html';
colorPrint('Running: ' . $command, 'green');
nl();
system($command);
nl();
colorPrint('[DONE]', 'green');
nl();
colorPrint('HTML Manual located in ' . $tempDir . '/manual-html/zf-package-chunked-xhtml/manual.html', 'green');
nl();
/** FUNCTIONS **/
function colorPrint($message, $color) {
static $isColor = null;
if ($isColor === null) {
$isColor = (function_exists('posix_isatty'));
}
list($prefix, $postfix) = array('', '');
if ($isColor) {
switch ($color) {
case 'green':
list($prefix, $postfix) = array("\033[32m", "\033[37m");
示例15: submit
//.........这里部分代码省略.........
// custom piece status and message
break;
}
// switch
// built in PayPal action
$paymentAction = false;
if ($this->formrow->template_code != '') {
require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php';
require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php';
$areas = Zend_Json::decode($this->formrow->template_areas);
if (is_array($areas)) {
jimport('joomla.version');
$version = new JVersion();
$j15 = true;
if (version_compare($version->getShortVersion(), '1.6', '>=')) {
$j15 = false;
}
$paymentAction = true;
switch (JRequest::getVar('ff_payment_method', '')) {
case 'PayPal':
foreach ($areas as $area) {
foreach ($area['elements'] as $element) {
if ($element['internalType'] == 'bfPayPal') {
$options = $element['options'];
$business = $options['business'];
$paypal = 'https://www.paypal.com';
if ($options['testaccount']) {
$paypal = 'https://www.sandbox.paypal.com';
$business = $options['testBusiness'];
}
$returnurl = htmlentities(JURI::root() . "index.php?option=com_breezingforms&confirmPayPal=true&form_id=" . $this->form . "&record_id=" . $this->record_id);
$cancelurl = htmlentities(JURI::root() . "index.php?msg=" . BFText::_('Transaction Cancelled'));
$html = '';
if (!$this->inline) {
$html .= '<html><head></head><body>';
}
JHTML::_('behavior.modal');
$ppselect = JRequest::getVar('ff_nm_bfPaymentSelect', array());
if (count($ppselect) != 0) {
$ppselected = explode('|', $ppselect[0]);
if (count($ppselected) == 4) {
$options['itemname'] = htmlentities($ppselected[0], ENT_QUOTES, 'UTF-8');
$options['itemnumber'] = htmlentities($ppselected[1], ENT_QUOTES, 'UTF-8');
$options['amount'] = htmlentities($ppselected[2], ENT_QUOTES, 'UTF-8');
$options['tax'] = htmlentities($ppselected[3], ENT_QUOTES, 'UTF-8');
}
}
// keeping this for compat reasons
$ppselect = JRequest::getVar('ff_nm_PayPalSelect', array());
if (count($ppselect) != 0) {
$ppselected = explode('|', $ppselect[0]);
if (count($ppselected) == 4) {
$options['itemname'] = htmlentities($ppselected[0], ENT_QUOTES, 'UTF-8');
$options['itemnumber'] = htmlentities($ppselected[1], ENT_QUOTES, 'UTF-8');
$options['amount'] = htmlentities($ppselected[2], ENT_QUOTES, 'UTF-8');
$options['tax'] = htmlentities($ppselected[3], ENT_QUOTES, 'UTF-8');
}
}
// compat end
$html .= "<form name=\"ff_submitform\" action=\"" . $paypal . "/cgi-bin/webscr\" method=\"post\">";
$html .= "<input type=\"hidden\" name=\"cmd\" value=\"_xclick\"/>";
$html .= "<input type=\"hidden\" name=\"business\" value=\"" . $business . "\"/>";
$html .= "<input type=\"hidden\" name=\"item_name\" value=\"" . $options['itemname'] . "\"/>";
$html .= "<input type=\"hidden\" name=\"item_number\" value=\"" . $options['itemnumber'] . "\"/>";
$html .= "<input type=\"hidden\" name=\"amount\" value=\"" . $options['amount'] . "\"/>";
$html .= "<input type=\"hidden\" name=\"tax\" value=\"" . $options['tax'] . "\"/>";