HTML [examples]

Display object as HTML
PRINT_HTML
open database southwind
select * from shippers into object shipobj
print_html(shipobj)
1 Speedy Express (503) 555-9831
2 United Package (503) 555-3199 3 Federal Shipping (503) 555-9931

https://www.lianja.com/doc/index.php/PRINT_HTML()


Return a string from a character string or memo field where html markup has been removed
HTML_TOPLAINTEXT
open database southwind
use employees
? html_toplaintext(notes,.T.)

https://www.lianja.com/doc/index.php/HTML_TOPLAINTEXT()


Return a string from a character string or memo field where qualifying characters have been replaced with their html entity equivalents
HTML_ENTITIES

<!-- dispmemo.rsp -->
<html>
<body>
<%
open database southwind
use example
goto 1
 ? "<pre>" + html_entities(notes) + "</pre>"
close databases
%>
</body>
</html>

https://www.lianja.com/doc/index.php/HTML_ENTITIES()


Return a string from a character string or memo field where numeric html entities have been replaced with their display character equivalents
HTML_ENTITY_DECODE
? html_entity_decode("{")
{

https://www.lianja.com/doc/index.php/HTML_ENTITY_DECODE()


Return a string from a character string or memo field where numeric html entities have been replaced with their display character equivalents
DECODE
? decode("{")
{

https://www.lianja.com/doc/index.php/DECODE()


Return a string from a character string or memo field where qualifying characters have been replaced with their html entity equivalents
ENCODE

<!-- dispmemo.rsp -->
<html>
<body>
<%
open database southwind
use example
goto 1
 ? "<pre>" + encode(notes) + "</pre>"
close databases
%>
</body>
</html>

https://www.lianja.com/doc/index.php/ENCODE()


Generate the base64 encoded contents of a file and output it into the HTML5
BASE64_ENCODE_FILE

<%@ Language=VFP %>
<html>
<head>
<style>
.pics
  {
  opacity:0.4;
  }
.pics:hover
  {
  opacity:1.0;
  }
</style>
</head>
<body>
<%
? "<table width='80%' align=center cellpadding=12>"
? "<tr>"
? "<td align=center>"
? "<h1>Lianja example</h1>"
? '<p>Customize this to suit your own needs. This is a just an example.<p>'
? '<hr size="1px" color="lightgray"/>'
? "</td>"
? "</tr>"
? "<tr>"
? "<td>"
? "<h3>Image</h3>"
? "</td>"
? "</tr>"
? "<tr>"
? "<td  align=center>"
base64_encode_file("babyray.jpg","jpg","472px","284px","class='pics'")
? "</td>"
? "</tr>"
 ? "<tr>"
? "<td align=center>"
? "<p>Copyright © 2013 Lianja Inc. All rights reserved worldwide.</p>"
? "<h3><a href 'http://www.lianja.com'> www.lianja.com</a></h3>"
? "</td>"
? "</tr>"
? "</table>"
%>
</body>
</html>


Generate the base64 encoded contents of an object field image as an IMG tag and output it into the HTML5
BASE64_ENCODE_IMAGE

<%@ Language=VFP %>
<html>
<head>
<style>
.pics
  {
  opacity:0.4;
  }
.pics:hover
  {
  opacity:1.0;
  }
</style>
</head>
<body>
<%
? "<table width='80%' align=center cellpadding=12>"
? "<tr>"
? "<td align=center colspan=2>"
? "<h1>Lianja example - image queries</h1>"
? '<p>Customize this to suit your own needs. This is a just an example.<p>'
? '<hr size="1px" color="lightgray"/>'
? "</td>"
? "</tr>"
? "<tr>"
? "<td colspan=2>"
? "<h3>Employees</h3>"
? "</td>"
? "</tr>"
 
// scan through the employees table
open database southwind
use employees
scan
	? "<tr>"
	? "<td>"
    ? "<a target='_blank' href='../odata/southwind/orders(" ;
        + etos(employeeid) ;
        + ",employeeid)'>"
    base64_encode_image(photo,"180px","200px","class='pics'")
	? '</a>'	
	? "</td>"
	? "<td>"
	? mtos(notes)
	? "</td>"
	? "<tr>"
	? '<td colspan="2">'
	? '<hr size="1px" color="lightgray"/>'
	? "</td>"
	? "</tr>"
	? "</tr>"
endscan
close data
 
? "<tr>"
? "<td align=center colspan=2>"
? "<p>Copyright © 2013 Lianja Inc. All rights reserved worldwide.</p>"
? "<h3><a href 'http://www.lianja.com'> www.lianja.com</a></h3>"
? "</td>"
? "</tr>"
? "</table>"
%>
</body>
</html>

https://www.lianja.com/doc/index.php/BASE64_ENCODE_IMAGE()


HTML style color

For color attributes that do not have an associated Select Color dialog, just a text field to enter the value, the color can be specified in the following ways:

Color name

An HTML color name, e.g.

Coral
LightCyan
DarkGreen

Hexadecimal color value

A hexadecimal color value, with or without the # prefix, e.g.

#FF7F50
FF7F50

RGB color value

An RGB color value: rgb(red,green,blue), e.g.

rgb(255, 127, 80)

Export

select employeeid, lastname, firstname;
  from employees into html emp

https://www.lianja.com/doc/index.php/Importing_and_Exporting_Data


The data URI scheme is a URI scheme (Uniform Resource Identifier scheme) that provides a way to include data in-line in web pages as if they were external resources. This technique allows normally separate elements such as images and style sheets to be fetched in a single HTTP request rather than multiple HTTP requests, which can be more efficient.

To make it easier to use these in Lianja .rsp pages for WebViews and HTML5 generated reports, Lianja includes a function:

base64_encode_file( )

This function will read a file, generate the base64 encoded contents of the file (optionally enclosed in an IMG tag) and output it into the WebView or HTML5 sent to a browser.

This makes it easy to have images stored in a Lianja database (e.g. photos) and have them displayed in a WebView with only a few lines of code.

Let’s assume we have an .rsp page written in the Visual FoxPro compatible scripting language embedded in Lianja called generatepage.rsp. The code required to display an image stored in a table would look like this.

<% // open a table the NoSQL way use attachments order tag empname    // Look up an employee seek "Smith"    // Create a unique temporary name (guaranteed uniqueness across concurrent users in a network)  m_tmpnam = tmpnam()    // Extract the photo from the database and write it to the temporary file objectWrite(m_tmpnam,photo)    // Generate the base64 encoded contents as an IMG tag and output into the HTML5   base64_encode_file(m_tmpnam, objectType(photo), "100px", "100px")    // Don't forget to remove the temporary file erase &m_tmpnam %>

Because we specified the (optional) type of the data, an IMG tag will be formatted and sent. If we specify only the filename then only the base64 encoded contents of the file will be sent. This allows you to embed base64 encoded data wrapped by other HTML5 tags.

The output looks something like this:


The parameters to base64_encode_file( ) are as follows:

nSize = base64_encode_file(cFilename [, cType [, cWidth [, cHeight [, cOptional]]]] )

cFilename is the path to the file on the local filesystem (make sure you have the access permissions correct when using this with the Lianja Cloud)

cType is the (optional) type of data e.g. “gif”, “png”, “jpg”

cWidth is the (optional) width to be specified on the IMG tag e.g. “10%” or “100px”

cHeight is the (optional) height to be specified on the IMG tag e.g. “10%” or “100px”

cOptional allows you to specify such things as ‘style=”background-color: green;’ which will be included in the IMG tag

It is worth pointing out that Lianja .rsp pages are cross-platform. They require no third party software to be installed, just Lianja. They can be used to generate reports or output any other HTML5 content — all written in a Visual FoxPro compatible scripting language that comes embedded within Lianja.

https://www.lianja.com/doc/index.php/Generating_HTML_Inline_Images


Advertisements