XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
Data.class.php
Go to the documentation of this file.
1<?php
7
8if (!defined('XOOPS_ROOT_PATH')) {
9 exit();
10}
11
12class Profile_DataObject extends XoopsSimpleObject
13{
14 public $mDef = null;
15
16 public function Profile_DataObject()
17 {
18 self::__construct();
19 }
20
24 public function __construct()
25 {
26 $handler = Legacy_Utils::getModuleHandler('definitions', 'profile');
27 $this->mDef = $handler->getDefinitions(false);
28
29 $this->initVar('uid', XOBJ_DTYPE_INT, '', false);
30 foreach (array_keys($this->mDef) as $key) {
31 $this->mDef[$key]->mFieldType->setInitVar($this, $this->mDef[$key]->getShow('field_name'), $this->mDef[$key]->getDefault());
32 }
33 }
34
43 public function showField(/*** string ***/ $key, /*** Enum ***/ $option=2)
44 {
45 return $this->mDef[$key]->mFieldType->showField($this, $key, $option);
46 }
47
56 public function setField(/*** string ***/ $key, /*** mixed ***/ $value)
57 {
58 $type = $this->mDef[$key]->get('type');
59 switch ($type) {
60 case Profile_FormType::TEXT:
61 if ('html' == $this->mDef[$key]->get('options')) {
62 $value = XCube_Root::getSingleton()->mTextFilter->purifyHtml($value);
63 }
64 $this->set($key, $value);
65 break;
66 case Profile_FormType::DATE:
67 $dateArr = explode('-', $value);
68 $date = mktime(0, 0, 0, $dateArr[1], $dateArr[2], $dateArr[0]);
69 $this->set($key, $date);
70 break;
71 default:
72 $this->set($key, $value);
73 break;
74 }
75
76 return $value;
77 }
78}
79
81{
82 public $mTable = 'profile_data';
83 public $mPrimary = 'uid';
84 public $mClass = 'Profile_DataObject';
85
86 public function insert(&$obj, $force = false)
87 {
88 if (0 === (is_countable($obj->mDef) ? count($obj->mDef) : 0)) {
89 return true;
90 }
91 return parent::insert($obj, $force = false);
92 }
93}
static getModuleHandler( $name, $dirname)
showField( $key, $option=2)
setField( $key, $value)