Login   Register  
PHP Classes
elePHPant
Icontem

File: readme.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Tom Schaefer  >  Flex Lorem  >  readme.txt  >  Download  
File: readme.txt
Role: Documentation
Content type: text/plain
Description: read me
Class: Flex Lorem
Generate bogus content to test page layouts
Author: By
Last change: replace doc
Date: 1 year ago
Size: 5,162 bytes
 

Contents

Class file image Download
FLEXIBLE LOREM

Class Lorem generates html elements containing lorem ipsum snippets.
It has an easy to use plugin interface. So you can write your own sets of snippets.
Class Lorem comes along with an element builder class which is able to create every 
html element and element attribute you need. The element builder is able to setup well-formed
html. It is fully object-oriented.

Class Lorem has a build-in lorem plugin creator, which converts html source intto a lorem plugin class. Look at the example script how it works.
Once you created a plugin, it will automatically recognized and loaded by class Lorem.


e.g. echo lorem::element("div")
	->add(lorem::element("h1")->add("headline"))
	->add(lorem::element("p")->add("paragraph"))
	->addAttribute("class", "article");

output:
  <div class="article">
  	<h1>headline</h1>
  	<p>paragraph</p>
  </div>

For a quick impression look at the test script. It shows how to handle {lorem.placeholders} 
with html source snippets.

If you want to see it in action I provided an online show case at http://www.query4u.de/showcase/tests/lorem/.
Within the site's form you can manipulate css styles and html elements. You can change the values of the 
layout section. Once you click the loremify button you immediately will see the output results at the bottom of the
web page.


e.g. echo lorem::layout('{Lorem.teaser}')

output:
	<div><div style="width:100%;height:80px;vertical-align:middle;line-height:80px;text-align:center;background:#ccc;position:relative;"><img width="100%" height="100%" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAMAAABFaP0WAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMAUExURQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALMw9IgAAAEAdFJOU////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wBT9wclAAAACXBIWXMAAAsSAAALEgHS3X78AAAAGnRFWHRTb2Z0d2FyZQBQYWludC5ORVQgdjMuNS4xMDD0cqEAAAAOSURBVBhXY/j/n+H/fwAL+gP9ltYOJgAAAABJRU5ErkJggg=="></img><div style="width:100%;height:80px;vertical-align:middle;line-height:80px;text-align:center;background:#ccc;position:absolute;top:0px;">IMAGE</div></div></div><p>nullam mattis faucibus sem, non odio fringilla class, aliquam metus. </p></div


## provided placeholders
{Lorem.teaser}
{Lorem.navigation}
{Lorem.image}
{Lorem.listing}
{Lorem.headline}
{Lorem.para}
{Lorem.separator}

## customization examples
Most of the placeholders are customizable. You can change the output result by adding commaseparated values.

e.g. {Lorem.image, 100, 90} => 90px height image (100 always means 100%)

{Lorem.teaser, 1}
{Lorem.teaser, 2}    => different teaser types
{Lorem.teaser, 3}


{Lorem.headline, 1} > h1
{Lorem.headline, 2} > h2
{Lorem.headline, 3} > h3
{Lorem.headline, 4} > h4

{Lorem.para, 1} > p with only a single word
{Lorem.para, 100} > p with 100 words



## creating a plugin

The first parameter of lorem::createPlugin has to be unique plugin name.
When you define a new placeholder you have to choose a unique name for it.
Otherwise the creator will throw an exception.
The placeholder consists of to parts:
- Lorem (Namespace)
- Placeholder (Method)
e.g. Lorem.choco

The second parameter  of lorem::createPlugin expects an array of the form:
array("name" => array("parameter" => array(), "source" => "your html source");

e.g.
echo lorem::createPlugin("test", array(
	"sugar" => array(
		"parameters" => array(),
		"source" => '<div class="test">
				<span>{Lorem.text,3}</span>
				<h1>{Lorem.text,5}</h1>
				{lorem.para}
				{lorem.separator}
				</div>
				'
	),
	"choco" => array(
		"parameters" => array(),
		"source" => '<div class="test">
				<span>{Lorem.text,4}</span>
				<h2>{Lorem.text,5}</h2>
				{lorem.para}
				{lorem.separator}
				</div>
				'
	)
));




I hope you see how easy lorem can be used.

Best regards
Tom Schaefer