What is Information Set?

The information set is a technique to work with a database table with a ready-to-use user interface.

In the real world, information is always preserved as a record and categorized in many ways. Computer systems commonly follow the below-phased method to manage entries, called crud data management.

  1. Create record
  2. Modify and update the record.
  3. View entry
  4. Delete entry

A few more techniques are required to process the data in the system, like

  1. Do data validation.
  2. Arrange the proper input fields.
  3. Apply data access control.
  4. Define the data types.
  5. Develop a user interface to manage data.

To defend the first line of support, Apprain provides the below two features:

  • Information Set
  • Category Set

Notes:
* Information Set: accept other information sets or category sets as input fields.
* Number of library functions available to fetch and manage data from both of them.

Information sets are created through XML files containing all necessary fields and basic information. Below are the methods to create an information set.

Method 1: Work in base framework

All the files are typically saved in the below location:

development/definition/information_set

Here are some important points to be followed:

  • Each XML file in this folder is considered a database table and is loaded automatically by the system.
  • The name of the XML file considered the table name.
  • The file name must follow the convention of the database table name.
  • A separate file name can be assigned when a callback function is used in a component.

There are two steps to creating any information set:

Step 1: Create the XML file
The XML has two main parts which are enclosed by the tag see below example:

<?xml version="1.0" encoding="utf-8"?> <InformationSet> <base></base> <fields></fields> </InformationSet>


The base part contains all the basic information in the information set. Here is an example.

<base mode="db"> <version>3.0.1</version> <lastupdate>2013-04-08</lastupdate> <title>Email Template</title> <admin_tab>developer</admin_tab> <addons/> <parameters /> <max_entry> <limit></limit> <message><![CDATA[]]></message> </max_entry> </base>

At this stage, two fields are very important. The first is <title>, which carries the name of the information set, and the second is , which contains the control panel tab defined in Interface Builder. Because the information set creates the user interface that must be rendered somewhere in the admin panel, refer to the documentation of Interface Builder to understand more about it.

After completing the base part the Interface Builder request the database fields name in the tag of fields. Here is an example:

<fields> <field name="message"> <title>Message</title> <type>textareaTag</type> <validation> <rule> <type>notEmpty</type> <err-message>Please enter value</err-message> </rule> </validation> <parameters> <parameter name="richtexteditor">No</parameter> </parameters> <db-attribute> <attribute name="type">text</attribute> <attribute name="length"></attribute> <attribute name="null"></attribute> <attribute name="default"></attribute> </db-attribute> <tag-attributes> <attribute name="id">description</attribute> <attribute name="class">app_input</attribute> <attribute name="rows">20</attribute> </tag-attributes> </field> </fields>

Field/AttributeDescriptionExample
NameDefine as tag attribute<field name="message">
TitleTitle of the fiend display in the interface <title>Message</title>
TypeHTML input type<type>textareaTag</type>
Validation typeType of the data validation in <rule> <type>notEmpty</type>
Error MessageDisplay message if failed <err-message>Please enter value</err-message>
ParametersAdditional attribute<parameter name="richtexteditor">Yes</parameter>
DB-attributeDatabase filed attributes <attribute name="type">text</attribute>
<attribute name="length"></attribute>
<attribute name="null"></attribute>
<attribute name="default"></attribute>
Tag-attributesHTML Tag attributes <attribute name="id">description</attribute>
<attribute name="class">app_input</attribute>
<attribute name="rows">20</attribute>

Click here to check out more details on field specifications. Below are the common fields for an information set:

InputTag TextareaTag FileTag
SelectTag RadioTag CheckboxTag
dateTag InformationSetTag CategorySetTag

Two major tasks here are to create the XML file and arrange all the necessary fields as needed. A complete file is given below, for example.

<?xml version="1.0" encoding="utf-8"?> <InformationSet> <base mode="db"> <version>3.1.0</version> <lastupdate>2013-12-23</lastupdate> <title>Blog Post</title> <admin_tab>blog</admin_tab> <addons /> <parameters /> <max_entry> <limit></limit> <message><![CDATA[]]></message> </max_entry> </base> <fields> <field name="title"> <title>Title</title> <type>inputTag</type> <searchable>Yes</searchable> <validation> <rule> <type>notEmpty</type> <err-message>Please enter a blog title</err-message> </rule> </validation> <parameters /> <tag-attributes> <attribute name="id">title</attribute> <attribute name="class">app_input</attribute> </tag-attributes> </field> <field name="category"> <title>Category</title> <type>categoryTag</type> <validation> <rule> <type>notEmpty</type> <err-message>Please select a category</err-message> </rule> </validation> <category_type>blog-cat</category_type> <parameters> <parameter name="parent_start">0</parameter> <parameter name="inputType">selectTag</parameter> <parameter name="auto_link">Yes</parameter> </parameters> <tag-attributes> <attribute name="id">category</attribute> </tag-attributes> </field> <field name="description"> <title>Description</title> <type>textareaTag</type> <searchable>Yes</searchable> <db-attribute> <attribute name="type ">text</attribute> <attribute name="length"></attribute> <attribute name="null"></attribute> <attribute name="default"></attribute> </db-attribute> <validation> <rule> <type>notEmpty</type> <err-message>Please enter post</err-message> </rule> </validation> <parameters /> <tag-attributes> <attribute name="id">description</attribute> <attribute name="class">app_input</attribute> <attribute name="rows">20</attribute> </tag-attributes> </field> <field name="status"> <title>Status</title> <type>radioTag</type> <db-attribute> <attribute name="type ">enum</attribute> <attribute name="length"></attribute> <attribute name="null"></attribute> <attribute name="default"></attribute> </db-attribute> <validation> <rule> <type>inList</type> <err-message>Please select a status</err-message> <list><val>Public</val><val>Private</val></list> </rule> </validation> <options> <option value="Public">Public</option> <option value="Private">Private</option> </options> <selected>Public</selected> <tag-attributes> <attribute name="id">status</attribute> <attribute name="class">app_input</attribute> </tag-attributes> </field> </fields> </InformationSet>

Step 2: Add the access links in the Interface Builder to create and manage data
Once the information set in XML is ready, it needs to be accessed from the interface to perform the crud operation. Below are the access links for an information set.

TypeConvention Example
Add Entry/information/manage/[name]/add/information/manage/blogpost/add
Manage Entries/information/manage/[name]/information/manage/blogpost

* [name] is the information set name; generally, it is the name of the XML file. More about the access link here.

Finally, this access link is used to add the Interface Builder in the admin panel to create interface; see the below example.

<menu> <title>Blog Posts</title> <items> <item> <title>Add Post</title> <link>/information/manage/blogpost/add</link> </item> <item> <title>Manage Post</title> <link>/information/manage/blogpost</link> </item> </items> <adminicon> <type /> <location /> </adminicon> </menu>

Method 2: Work Component

This is a continuation of Method 1. Components always keep resources isolated, so the XML file should be placed inside the working component directory. See the path below:

component/[component name]/information_set

For example, if the component name is “appbog” and the information set name is "blogpost", then create the file in the below location:

component/appblog/information_set/blogpost.xml

After file creation is done, the information set file needs to be registered in the component through the below callback method.

In init() method

<?php class Component_Homepress_Register extends appRain_Base_Component { public function init() { App::Module("Hook") ->setHookName("InformationSet") ->setAction("register_definition") ->Register(get_class($this),"register_informationset_defination"); } }


Method body considering above example

<?php class Component_Homepress_Register extends appRain_Base_Component { public function register_informationset_defination() { $srcpaths = Array(); $srcpaths[] = array( "type"=>"homepress", "path"=>$this->attachMyPath("information_set/homepress.xml") ); return $srcpaths; } }


Function Reference

InformationSet gives facilities to manage data; however, it is always expected that Framework can access data and use it. Below are the methods that help to work with information set through programming.

Find FindByField findAll
findAllByField Paging idToName
oneDArray countEntry Save
Delete DeleteByField Tag


Summary

As a CMS tool it helps to manage data in database tables through an auto-generated interface. Let's recap.

  • First, create the XML file with all the required fields.
  • Second, if it’s a component, create the file inside the component directory; otherwise, in the development area.
  • Finally, set the menu in the admin panel to access the user interface and manage data.

Important: An information set acts like a database model, so use the list of functions to manage data inside your code and save time.