ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilADTTest Class Reference

This is a ADT-based example object. More...

+ Inheritance diagram for ilADTTest:
+ Collaboration diagram for ilADTTest:

Data Fields

const INTERESTS_NONE = 0
const INTERESTS_LANGUAGES = 1
const INTERESTS_IT = 2

Protected Member Functions

 initProperties ()
 Init properties (aka set ADT definition)
 initDBBridge (ilADTGroupDBBridge $a_adt_db)
 Init (properties) DB bridge.
 parsePrimary (array $a_args)
 Parse incoming primary key.
 hasPrimary ()
 Check if currently has primary.
 createPrimaryKey ()
 Create new primary key, e.g.
- Protected Member Functions inherited from ilADTBasedObject
 initActiveRecordInstance ()
 Init active record helper for current table, primary and properties.

Protected Attributes

 $id
 $properties
- Protected Attributes inherited from ilADTBasedObject
 $properties = array()
 $db_errors = array()

Additional Inherited Members

- Public Member Functions inherited from ilADTBasedObject
 __construct ()
 Constructor.
 getProperties ()
 Get all properties.
 isValid ()
 Validate.
 __call ($a_method, $a_value)
 Get property magic method ("get<PropertyName>()")
 read ()
 Read record.
 create ()
 Create record (only if valid)
 update ()
 Update record (only if valid)
 delete ()
 Delete record.
 getDBErrors ()
 Get DB errors.
 translateDBErrorCodes (array $a_codes)
 Translate DB error codes.
 getAllTranslatedErrors ($delimiter="\n")
 Get translated error codes (DB, Validation)

Detailed Description

This is a ADT-based example object.

It has all supported ADTs and shows DB sequence-handling

Definition at line 10 of file class.ilADTTest.php.

Member Function Documentation

ilADTTest::createPrimaryKey ( )
protected

Create new primary key, e.g.

sequence

Returns
bool

Reimplemented from ilADTBasedObject.

Definition at line 114 of file class.ilADTTest.php.

References $ilDB.

{
global $ilDB;
$this->id = $ilDB->nextId("adt_test");
// INSERT is only done if createPrimaryKey() returns TRUE!
return true;
}
ilADTTest::hasPrimary ( )
protected

Check if currently has primary.

Returns
bool

Reimplemented from ilADTBasedObject.

Definition at line 109 of file class.ilADTTest.php.

References $id.

{
return (bool)$this->id;
}
ilADTTest::initDBBridge ( ilADTGroupDBBridge  $a_adt_db)
protected

Init (properties) DB bridge.

Parameters
ilADTGroupDBBridge$a_adt_db

Reimplemented from ilADTBasedObject.

Definition at line 98 of file class.ilADTTest.php.

References ilADTGroupDBBridge\setPrimary(), and ilADTGroupDBBridge\setTable().

{
$a_adt_db->setTable("adt_test");
$a_adt_db->setPrimary(array("id"=>array("integer", $this->id)));
}

+ Here is the call graph for this function:

ilADTTest::initProperties ( )
protected

Init properties (aka set ADT definition)

Returns
ilADT

Reimplemented from ilADTBasedObject.

Definition at line 22 of file class.ilADTTest.php.

References $lang, $lng, $options, and ilADTFactory\getInstance().

{
global $lng;
// this could be generated from XML or code comments or whatever
include_once "Services/ADT/classes/class.ilADTFactory.php";
$properties_def = $factory->getDefinitionInstanceByType("Group");
$name = $factory->getDefinitionInstanceByType("Text");
$name->setMaxLength(255);
$properties_def->addElement("name", $name);
$status = $factory->getDefinitionInstanceByType("Boolean");
$properties_def->addElement("active", $status);
// example options from ilLanguage
$lng->loadLanguageModule("meta");
$options = array();
foreach($lng->getInstalledLanguages() as $lang)
{
$options[$lang] = $lng->txt("meta_l_".$lang);
}
$lang = $factory->getDefinitionInstanceByType("Enum");
$lang->setNumeric(false);
$lang->setOptions($options);
$properties_def->addElement("lang", $lang);
$age = $factory->getDefinitionInstanceByType("Integer");
$age->setMin(0);
$age->setMax(120);
$properties_def->addElement("age", $age);
$weight = $factory->getDefinitionInstanceByType("Float");
$weight->setMin(0);
$weight->setMax(500);
$properties_def->addElement("weight", $weight);
// null?
$home = $factory->getDefinitionInstanceByType("Location");
$properties_def->addElement("home", $home);
$tags = $factory->getDefinitionInstanceByType("MultiText");
$tags->setMaxLength(255);
$tags->setMaxSize(5);
$properties_def->addElement("tags", $tags);
$options = array(
self::INTERESTS_NONE => $lng->txt("test_interests_none"),
self::INTERESTS_LANGUAGES => $lng->txt("test_interests_languages"),
self::INTERESTS_IT => $lng->txt("test_interests_it")
);
$intr = $factory->getDefinitionInstanceByType("MultiEnum");
$intr->setOptions($options);
$properties_def->addElement("interests", $intr);
$date = $factory->getDefinitionInstanceByType("Date");
$properties_def->addElement("entry_date", $date);
$dt = $factory->getDefinitionInstanceByType("DateTime");
$properties_def->addElement("last_login", $dt);
// convert ADT definitions to proper ADTs
return $factory->getInstanceByDefinition($properties_def);
}

+ Here is the call graph for this function:

ilADTTest::parsePrimary ( array  $a_args)
protected

Parse incoming primary key.

See Also
__construct()
Parameters
array$a_args

Reimplemented from ilADTBasedObject.

Definition at line 104 of file class.ilADTTest.php.

{
$this->id = (int)$a_args[0];
}

Field Documentation

ilADTTest::$id
protected

Definition at line 12 of file class.ilADTTest.php.

Referenced by hasPrimary().

ilADTTest::$properties
protected

Definition at line 13 of file class.ilADTTest.php.

const ilADTTest::INTERESTS_IT = 2

Definition at line 17 of file class.ilADTTest.php.

const ilADTTest::INTERESTS_LANGUAGES = 1

Definition at line 16 of file class.ilADTTest.php.

const ilADTTest::INTERESTS_NONE = 0

Definition at line 15 of file class.ilADTTest.php.


The documentation for this class was generated from the following file: