LEAP™ is a content editor’s dream (CMS), a designer’s best option, and the perfect framework for site development.
LEAP™ is simpleLEAPLEAP™ is secureLEAPLEAP™ is SEO-centric

LEAP_items

This is a collection of interrelated data types. Together they describe a nested related data set of groups of items, items themselves, and properties of items.

LEAP_itemGroup

This data type is the "parent" 

public data members

id::integer
The unique ID if your chosen group.
Read + assign, not writable.

itemType::string
The data classification this group belongs to. i.e. tip, glossary, faq, quote.
Read + write.

itemName::string
The name of the group, for easy identification in select dropdowns within plugin administration.
Read + write.

itemDesc::string
A brief description for your reference.
Read + write.

status::integer
A plain boolean 0 or 1 reference for active/inactive status.
Read + write.

items::array
The ordered array of elements attached to the group object. These elements are of type LEAP_item.
Read + assign.

load(id::integer=.id)

The load method for this type. Can be called with or without an id parameter. Instantiating the object beforehand is required as the load is explicit.

local(myGroup = LEAP_itemGroup)
#myGroup->load(1)

local(myGroup = LEAP_itemGroup)
#myGroup->id = 1
#myGroup->load()

save

The save method commits any changes to the group to database. Note this does not cascade the commit to member items or their properties. Please refer to the individual save methods for these objects.

local(myGroup = LEAP_itemGroup)
#myGroup->itemType = 'test'
#myGroup->itemName = 'My test group'
#myGroup->save

delete

This delete method removes the item group, all it's member elements and their properties. It is a permanent deletion - use with care.

local(myGroup = LEAP_itemGroup)
#myGroup->id = 1
#myGroup->delete

list(itemType::string,perview::integer=10,skip::integer=0)

A list method intended to facilitate fetching all groups of type "itemType". Returns a map containing "found", "first", "last" and "rows" nodes.

The "rows" node is an ordered array, it's member nodes are of type "LEAP_item".

LEAP_itemGroup->list('faq')

-> map('found' = 2, 'first' = 1, 'last' = 2, 'rows' = array(LEAP_item, LEAP_item))

select(itemType::string,compare::integer=0)

A fetch method that returns all groups with a matching itemType. Intended for usage situations such as plugin administration modes where the choice of an item group is required. Returns only the option html elements, intended to be nested inside an html select element.

The compare parameter is an optional integer id to pre-select the "selected" property of the appropriate option.

>select name="x"< [LEAP_itemGroup->select('faq',12)] >/select<

 

 

LEAP_item

This data type contains the base information for the item, plus certain primary properties and a map of additional properties.

public data members

id::integer
The unique id of the item. Used for specific access for applicable methods.
Read + assign, not writable.

groupId::integer
The id of the parent group.
Read + write.

itemType::string
This echos the itemType of the parent group. It is primarily for quick identification of the object's intended type.
Read + write.

displayOrder::integer
A sequential integer denoting the position in the ordered array.
Read + write.

title::string
A primary object property.
Used for both identification and optionally display, in the case of an FAQ this would be used to contain the "Question" property.
In the case of a quote, this would be an identifier and not be used for display.
Read + write.

body::string
A primary object property.
Used for the main content output for the item.
For an object type "FAQ", this would be the "Answer".
Read + write.

author::string
A primary object property.
This is a text element, and as such would be used to contain the name of an author to be attributed that might be outside the LEAP™ user system.
Read + write.

authorid::integer
A primary object property.
Used to link a user that exists within the LEAP™ user system, or in another id-based user management system as appropriate.
Read + write.

dateCreated::date
The date the item was first saved.
Read only.

dateUpdated::date
The date the item was last updated.
Read only.

status::integer
A plain boolean 0 or 1 reference for active/inactive status.
Read + write.

props::map
The map of properties attached to the item.
These property elements are a name/value pair with the name being the property name reference and the value being the complete property object of type LEAP_itemProp.
Read + assign.

load(id::integer=.id)

The load method for this type. Can be called with or without an id parameter. Instantiating the object beforehand is required as the load is explicit.

local(myItem = LEAP_item)
#myItem->load(1)

local(myItem = LEAP_item)
#myItem->id = 1
#myItem->load()

save

The save method commits any changes to the item to database. Note this does not cascade the commit to member properties.

local(myItem = LEAP_item)
#myItem->itemType = 'test'
$myItem->groupid = 12
#myItem->title = 'My test item'
#myItem->body = 'Hello world'
#myItem->save

delete

This delete method removes the item and all it's properties. It is a permanent deletion - use with care.

local(myItem = LEAP_item)
#myItem->id = 1
#myItem->delete

capture(groupid::integer)

Returns an ordered array of items attached to the specified group. Array elements are of type LEAP_item.

list(groupid::integer,perview::integer=10,skip::integer=0)

A fetch method that returns all items with the specified group id. Intended for usage situations such as plugin administration modes where the choice of an item is required. Returns only the option html elements, intended to be nested inside an html select element.

The compare parameter is an optional integer id to pre-select the "selected" property of the appropriate option.

 

 

LEAP_itemProp

public data members

elementid::integer
The id of the parent item.
Readable and writable, although changing the assignment after initial creation is not recommended.

version::integer
The id of the item. Used for specific access for applicable methods.
Read + assign, not writable.
Note the key on this table is a compound key bound over elementid and version, therefore version is NOT unique but the combination is.

propName::string
The name of the property as referred to in your code.
Read + Write.

propType::string
The destination datatype, used for casting and efficient storage to the correct database column.
Possible values: int, dec, text. Any other value will cause the property value to be cast as a string and stored as a varchar 255.

prop::any
The primary reference member object you would access.
.prop is cast to the intended datatype via the setprop method
Read + Write.

load(el::integer=.elementid,v::integer=.id)
load(el::integer=.elementid,propName::string='')

The load methods use Lasso 9's multiple dispatch to assign data to self whether you know it's version (id) or it's property name.

Both the following "load" calls are valid:

local(property = LEAP_itemProp)
#property->load(123,3)
#property->load(123,'width')

save

Saves the current object.

#property->prop
> Something witty

#property->prop = 'Hello World'
#property->save

#property->prop
> Hello World

capture(elementid::integer)

This method returns a map of properties belonging to the parent element signified by the integer id of "elementid".
The pair is "property name" & property object of type LEAP_itemProp.

This method can be invoked without being instantiated to a variable:

local(properties = LEAP_itemProp->capture(123))

 

Common usage examples

Listing available groups

local(data = LEAP_itemGroup->list('Quote',10,0))
with i in #data->find('rows') do => {^
     #i->itemname
^}

List items in a group

local(obj = LEAP_itemGroup)
#obj->load($id)
with i in #obj->items
	do => {^
		#i->title
		#i->props->find('CompanyName')->prop
	^}

Save a group (with optional insert)

local(thisobj = LEAP_itemGroup)
if($id > 0) => {
	#thisobj->load($id)
else
	#thisobj->status = 0
}
#thisobj->itemType = 'quote'
#thisobj->itemName = string(client_param('LEAPEDIT_itemName')) 
#thisobj->itemDesc = string(client_param('LEAPEDIT_itemDesc')) 
#thisObj->save 

Save a property

local(thiscompany = LEAP_itemProp)
#thiscompany->elementid		= #thisObj->id
#thiscompany->load(#thisObj->id,'companyName')
#thiscompany->propName 		= 'companyName'
#thiscompany->propType 		= 'string'
#thiscompany->prop			= string(client_param('LEAPEDIT_companyName'))
#thiscompany->save

© Copyright LEAP™ 2017 | Privacy Policy | Design by Treefrog Inc.