PHP Classes
elePHPant
Icontem

Flex Lorem: Generate bogus content to test page layouts

Recommend this page to a friend!
  Info   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2012-08-18 (4 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 254 All time: 7,361 This week: 958Up
Version License PHP version Categories
flex-lorem 0.1GNU General Publi...5HTML, PHP 5, Text processing
Description Author

This class can generate bogus content to test page layouts.

It takes an HTML template and replaces marked sections it with bogus content, tipically with Latin text with words like lorem, ipsum, etc..

The class supports some pre-defined template elements that allow determining the way the template text should be replaced, like text, paragraphs, headlines, images, etc..

Additional plugin classes can be used to customize the way the text is generated.

Innovation Award
PHP Programming Innovation award nominee
August 2012
Number 6


Prize: One copy of VS.PHP
One common way to test page layouts is to fill the content areas with random content.

Often Latin text is used fill in layout spaces so you can see how it looks.

This class can generate random Latin text and fill marked templates with the generated text that will be used to preview the layout to be tested.

Manuel Lemos
Picture of Tom Schaefer
  Performance   Level  
Name: Tom Schaefer <contact>
Classes: 39 packages by
Country: Germany Germany
Innovation award
Innovation award
Nominee: 9x

Winner: 1x

Details
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


  Files folder image Files  
File Role Description
Files folder imageplugins (2 files)
Plain text file element.php Class html element creator used by lorem and its plugins
Plain text file lorem.php Class main class
Accessible without login Plain text file readme.txt Doc. read me
Accessible without login Plain text file test.php Example test script and showcase
Accessible without login Plain text file testplugin.php Example example for plugin creator

  Files folder image Files  /  plugins  
File Role Description
  Plain text file image.php Class image plugin
  Plain text file text.php Class text plugin

 Version Control Unique User Downloads Download Rankings  
 0%
Total:254
This week:0
All time:7,361
This week:958Up