16 $this->fieldnames = array();
17 $this->attributes = array();
30 foreach ( $this->table->fields(
false,
true) as
$field ){
31 if ( @
$field[
'event.date'] ){
35 if ( @
$field[
'event.start'] ){
39 if ( @
$field[
'event.end'] ){
42 if ( @
$field[
'event.location'] ){
43 $location =
$field[
'name'];
45 if ( @
$field[
'event.category'] ){
46 $category =
$field[
'name'];
49 if ( @
$field[
'event.allday'] ){
57 $candidates = preg_grep(
'/(date)/i', array_keys($this->table->fields(
false,
true)));
58 foreach ( $candidates as $candidate ){
59 if ( $this->table->isDate($candidate) ){
66 if ( !isset($start) ){
69 $candidates = preg_grep(
'/(time|start)/i', array_keys($this->table->fields(
false,
true)));
70 foreach ( $candidates as $candidate ){
71 if ( $this->table->isDate($candidate) ){
81 $candidates = preg_grep(
'/(time|end)/i', array_keys($this->table->fields(
false,
true)));
82 foreach ( $candidates as $candidate ){
83 if ( $this->table->isDate($candidate) ){
90 if ( !isset($location) ){
93 $candidates = preg_grep(
'/(location|place|addr|venue)/i', array_keys($this->table->fields(
false,
true)));
94 foreach ( $candidates as $candidate ){
95 if ( in_array($this->table->getType($candidate), array(
'enum',
'varchar',
'char',
'int') ) ){
96 if ( $this->table->isInt($candidate) ){
97 $field =& $this->table->getField($candidate);
98 if ( @
$field[
'vocabulary'] ){
99 $location = $candidate;
103 $location = $candidate;
110 if ( !isset($location) ){
113 $candidates = preg_grep(
'/(cat|type)/i', array_keys($this->table->fields(
false,
true)));
114 foreach ( $candidates as $candidate ){
115 if ( in_array($this->table->getType($candidate), array(
'enum',
'varchar',
'char',
'int') ) ){
116 if ( $this->table->isInt($candidate) ){
117 $field =& $this->table->getField($candidate);
118 if ( @
$field[
'vocabulary'] ){
119 $category = $candidate;
123 $category = $candidate;
131 if ( !isset($allday) ){
134 $candidates = preg_grep(
'/(all|full|todo)/i', array_keys($this->table->fields(
false,
true)));
135 foreach ( $candidates as $candidate ){
136 if ( in_array($this->table->getType($candidate), array(
'tinyint',
'boolean') ) ){
137 $allday = $candidate;
145 $atts = array(
'date'=>$date,
'start'=>$start,
'end'=>$end,
'location'=>$location,
'category'=>$category,
'allday'=>$allday);
146 foreach ($atts as $key=>$val ){
148 $field =& $this->table->getField($val);
149 $this->attributes[$key] =&
$field;
151 $this->fieldnames[$key] = $val;