Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class topic extends topic_ext

Hide Inherited MembersForum
Description
No description.
 
Constants
constantTABLENAME ["forum_topic"][ topic ]
 
Properties
protected_cdate[ topic_db ]
protected_cdate_dirty[ topic_db ]
protected_deleted[ topic_db ]
protected_deleted_dirty[ topic_db ]
protected_description[ topic_db ]
protected_description_dirty[ topic_db ]
protected_dirty[ obj ]
protected_id[ topic_db ]
protected_id_dirty[ topic_db ]
protected_mdate[ topic_db ]
protected_mdate_dirty[ topic_db ]
protected_name[ topic_db ]
protected_name_dirty[ topic_db ]
publicproperty_objects_array[ obj ]
protected_views[ topic_db ]
protected_views_dirty[ topic_db ]
 
Methods
publiccommit ( )[ topic_db ]
Parameters
No parameters for this method
Code
102  public function commit()
103  {
104      if ($this->_id > 0)
105      {
106          $this->update();
107      }
108      else
109      {
110          $this->insert();
111      }
112 
113      foreach ($this->property_objects_array as $property=>$object)
114      {
115          $this->{$property} = $object;
116      }
117 
118      return true;
119  }
public__construct ( id , name )[ topic_db ]
Parameters
optionalid
optionalname
Code
044  public function __construct($__id=null, $__name=null)
045  {
046      $this->_id = 0;
047      $this->_name = $__name;
048      $this->_description = "";
049      $this->_views = 0;
050      $this->_mdate = null;
051      $this->_cdate = null;
052      $this->_deleted = false;
053 
054      $this->_id_dirty = false;
055      $this->_name_dirty = false;
056      $this->_description_dirty = false;
057      $this->_views_dirty = false;
058      $this->_mdate_dirty = false;
059      $this->_cdate_dirty = false;
060      $this->_deleted_dirty = false;
061 
062      if (is_null($__id) && is_null($__name))
063      {
064          return;
065      }
066 
067      $db = topic::db();
068      $q  = " SELECT forum_topic.id,forum_topic.name,forum_topic.description,forum_topic.views,forum_topic.mdate,forum_topic.cdate,forum_topic.deleted ";
069      $q .= " FROM forum_topic ";       
070      if (!is_null($__id))
071      {
072          $q .= " WHERE id = '$__id' ";
073      }
074      else if (!is_null($__name))
075      {
076          $q .= " WHERE name = '$__name' ";
077      }
078 
079      $db->query($q);
080      if ($db->next_record() && $db->num_rows() == 1)
081      {
082          $this->_id = $db->f("id");
083          $this->_name = $db->f("name");
084          $this->_description = $db->f("description");
085          $this->_views = $db->f("views");
086          $this->_mdate = $db->f("mdate");
087          $this->_cdate = $db->f("cdate");
088          $this->_deleted = $db->f("deleted");
089      }
090  }
protected staticdb ( )[ topic_db ]
Parameters
No parameters for this method
Code
525  protected static function db()
526  {
527      return new db();
528  }
publicdelete ( )[ topic_db ]
Parameters
No parameters for this method
Code
158  public function delete()
159  {
160      $db = topic::db();
161      $q  = " UPDATE forum_topic SET ";
162      $q .= " deleted = 1 ";
163      $q .= " WHERE id = " . $this->_id;
164      $db->query($q);
165      $this->deleted = true;
166      return true;
167  }
public staticdelete_all ( )[ topic_db ]
Parameters
No parameters for this method
Code
264  public static function delete_all()
265  {
266      $db = topic::db();
267      $q  = " UPDATE forum_topic SET ";
268      $q .= " deleted = 1 ";
269     
270      $db->query($q);
271      return true;
272  }
public__get ( p )[ obj ]
Parameters
requiredp
Code
007  public function __get($p)
008  {
009      $methods = get_class_methods($this);
010      $properties = get_object_vars($this);
011      if (in_array("get_$p",$methods))
012      {
013          return $this->{"get_$p"}();
014      }
015      else if (array_key_exists("_$p",$properties))
016      {
017          return $this->{"_$p"};
018      }
019      else if (in_array("get_" . substr($p,strpos($p,"_")+1), $methods))
020      {
021          return $this->{"get_" . substr($p,strpos($p,"_")+1)}(substr($p,0,strpos($p,"_")));
022      }
023      else
024      {
025          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
026          return null;
027      }
028  }
publicget_array ( )[ obj ]
Parameters
No parameters for this method
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicget_board ( type ["default"] )[ topic_db ]
Parameters
optionaltype ["default"]
Code
426  public function get_board($__type="default")
427  {
428      $object = is_null(keyval($this->property_objects_array,"{$__type}_board")) ? new board($this->get_board_id($__type)) : $this->property_objects_array["{$__type}_board"];
429      $this->property_objects_array["{$__type}_board"] = $object;
430      return $object;
431  }
publicget_board_id ( type ["default"] )[ topic_db ]
Parameters
optionaltype ["default"]
Code
432  public function get_board_id($__type="default")
433  {
434      $ids = $this->get_board_ids($__type, true);
435      return (count($ids)==1 ? $ids[0] : null);
436  }
publicget_board_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ topic_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
437  public function get_board_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
438  {
439      $board_ids = array();
440      $db = topic::db();
441      $q  = " SELECT forum_board.id FROM forum_board_topic INNER JOIN forum_board ON forum_board_topic.board_id=forum_board.id AND forum_board_topic.deleted=0 AND forum_board.deleted=0 AND forum_board_topic.topic_id='$this->id' " . (is_null($__type) ? "" : " AND forum_board_topic.board_topic_type_id='" . board_topic::type_id($__type) . "'") . ($__get_primary ? " AND forum_board_topic.primary=1 " : "");
442      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
443      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
444      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
445      $db->query($q);
446      while ($db->next_record())
447      {
448          $board_ids[] = $db->f("id");
449      }
450      return $board_ids;
451  }
publicget_board_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ topic_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
452  public function get_board_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
453  {
454      $ids = $this->get_board_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
455      $objects = array();
456      foreach ($ids as $index=>$id)
457      {
458          $objects[$index] = new board($id);
459      }
460      return $objects;
461  }
publicget_classname ( )[ obj ]
Parameters
No parameters for this method
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
public staticget_columns ( columns , order , lookups , where_clause , limit , offset [0] )[ topic_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
189  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
190  {
191      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
192      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
193      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
194 
195      $db = topic::db();
196      $data = array();
197      $q  = " SELECT $colstring ";
198      $q .= " FROM forum_topic ";
199      $q .= " WHERE forum_topic.deleted = 0 ";
200      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
201 
202      if (is_string($__order))
203      {
204          $q .= "ORDER BY " . $__order;
205      }
206      else if (is_array($__order) and count($__order)>0)
207      {
208          $orderings = array();
209          foreach ($__order as $col=>$dir)
210          {
211              $orderings[] = " $col $dir ";
212          }
213          $q .= "ORDER BY " . implode(", ", $orderings);
214      }
215      else if (is_object($__order))
216      {
217          $q .= "";
218      }
219      else
220      {
221          // THERE IS NO `order` COLUMN ON THIS OBJECT
222      }
223 
224      if (!is_null($__limit))
225      {
226          $q .= " LIMIT $__offset , $__limit ";
227      }
228 
229      $db->query($q);
230 
231      if (count($colarray)>1 || $colstring=="*")
232      {
233          while ($db->next_record())
234          {
235              $data[] = $db->record;
236          }
237      }
238      else
239      {
240          while ($db->next_record())
241          {
242              $data[] = $db->f(0);
243          }
244      }
245 
246      return $data;
247  }
publicget_dirty ( )[ obj ]
Parameters
No parameters for this method
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicget_first_post ( )[ topic_ext ]
Parameters
No parameters for this method
Code
035  public function get_first_post()
036  {
037      $posts = array();
038      $posts = $this->post_list;
039      if(count($posts)>0)
040      {
041          return $posts[0];
042      }
043      else
044      {
045          return new post();
046      }
047  }
public staticget_ids ( order , lookups , where_clause , limit , offset [0] )[ topic_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
249  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
250  {
251      return topic::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
252  }
publicget_json ( )[ obj ]
Parameters
No parameters for this method
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicget_last_post ( )[ topic_ext ]
Parameters
No parameters for this method
Code
049  public function get_last_post()
050  {
051      $posts = array();
052      $posts = $this->post_list;
053      if(count($posts)>0)
054      {
055          return $posts[count($posts)-1];
056      }
057      else
058      {
059          return new post();
060      }
061  }
public staticget_objects ( order , lookups , where_clause , limit , offset [0] )[ topic_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
254  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
255  {
256      $objects = array();
257      foreach (topic::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
258      {
259          $objects[] = new topic($id);
260      }
261      return $objects;
262  }
publicget_post ( type ["default"] )[ topic_db ]
Parameters
optionaltype ["default"]
Code
327  public function get_post($__type="default")
328  {
329      $object = is_null(keyval($this->property_objects_array,"{$__type}_post")) ? new post($this->get_post_id($__type)) : $this->property_objects_array["{$__type}_post"];
330      $this->property_objects_array["{$__type}_post"] = $object;
331      return $object;
332  }
publicget_post_id ( type ["default"] )[ topic_db ]
Parameters
optionaltype ["default"]
Code
333  public function get_post_id($__type="default")
334  {
335      $ids = $this->get_post_ids($__type, true);
336      return (count($ids)==1 ? $ids[0] : null);
337  }
publicget_post_ids ( type , get_primary [false] )[ topic_ext ]
Parameters
optionaltype
optionalget_primary [false]
Code
008  public function get_post_ids($__type=null, $__get_primary=false)
009  {
010      //get posts from newest to oldest
011      $post_ids = array();
012      $ids = post_topic::get_ids(null,$this->id,is_null($__type) ? null : post_topic::type_id($__type),"cdate");
013      if (!is_null($__type) && count($ids)>1 && $__get_primary)
014      {
015          foreach ($ids as $id)
016          {
017              $object = new post_topic($id);
018              if ($object->primary)
019              {
020                  return array($object->post_id);
021              }
022          }
023      }
024      else
025      {
026          foreach ($ids as $id)
027          {
028              $object = new post_topic($id);
029              $post_ids[] = $object->post_id;
030          }
031      }
032      return $post_ids;
033  }
publicget_post_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ topic_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
353  public function get_post_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
354  {
355      $ids = $this->get_post_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
356      $objects = array();
357      foreach ($ids as $index=>$id)
358      {
359          $objects[$index] = new post($id);
360      }
361      return $objects;
362  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
protectedget_string ( )[ obj ]
Parameters
No parameters for this method
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
protectedinsert ( )[ topic_db ]
Parameters
No parameters for this method
Code
121  protected function insert()
122  {
123      $db = topic::db();
124      $q  = " INSERT INTO forum_topic ( ";
125      $q .= $db->param_string("name") . ", ";
126      $q .= $db->param_string("description") . ", ";
127      $q .= $db->param_string("views") . ", ";
128      $q .= $db->param_string("mdate") . ", ";
129      $q .= $db->param_string("cdate") . ", ";
130      $q .= $db->param_string("deleted");
131      $q .= " ) VALUES ( ";
132      $q .= $db->value_string($this->_name) . ", ";
133      $q .= $db->value_string($this->_description) . ", ";
134      $q .= $db->value_string($this->_views) . ", ";
135      $q .= $db->value_string(timestamp()) . ", ";
136      $q .= $db->value_string(timestamp()) . ", ";
137      $q .= $this->deleted ? "'1'" : "'0'";
138      $q .= " ) ";
139      $db->query($q);
140      $this->_id = $db->insert_id;
141      return true;
142  }
publicmap ( )[ topic_db ]
Parameters
No parameters for this method
Code
092  public function map()
093  {
094      $this->_name = array_key_exists("topic:name",$_REQUEST) ? reqval("topic:name") : $this->_name;
095      $this->_description = array_key_exists("topic:description",$_REQUEST) ? reqval("topic:description") : $this->_description;
096      $this->_views = array_key_exists("topic:views",$_REQUEST) ? reqval("topic:views") : $this->_views;
097      $this->_mdate = array_key_exists("topic:mdate",$_REQUEST) ? reqval("topic:mdate") : $this->_mdate;
098      $this->_cdate = array_key_exists("topic:cdate",$_REQUEST) ? reqval("topic:cdate") : $this->_cdate;
099      $this->_deleted = array_key_exists("topic:deleted",$_REQUEST) ? reqval("topic:deleted") : $this->_deleted;
100  }
publicpurge ( )[ topic_db ]
Parameters
No parameters for this method
Code
180  public function purge()
181  {
182      $db = topic::db();
183      $q  = " DELETE FROM forum_topic ";
184      $q .= " WHERE id = " . $this->_id;
185      $db->query($q);
186      return true;
187  }
public staticsearch ( keyword )[ topic_db ]
public__set ( p , v )[ obj ]
Parameters
requiredp
requiredv
Code
030  public function __set($p,$v)
031  {
032      $methods = get_class_methods($this);
033      $properties = get_object_vars($this);
034      if (in_array("set_$p",$methods))
035      {
036          $this->{"set_$p"}($v);
037      }
038      else if (array_key_exists("_$p",$properties))
039      {
040          if (!preg_match('/_dirty$/',$p) && property_exists($this,"_{$p}_dirty"))
041          {
042              if (is_object($this->{"_$p"}))
043              {
044                  $this->{"_$p"}->dirty = true;
045              }
046              else
047              {
048                  $this->{"_{$p}_dirty"} = $this->{$p}==$v ? false : true;
049              }
050          }
051          $this->{"_$p"} = $v;
052      }
053      else if (in_array("set_" . substr($p,strpos($p,"_")+1), $methods))
054      {
055          $this->{"set_" . substr($p,strpos($p,"_")+1)}($v,substr($p,0,strpos($p,"_")));
056      }
057      else
058      {
059          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
060      }
061  }
publicset_board ( v , type ["default"] )[ topic_db ]
Parameters
requiredv
optionaltype ["default"]
Code
463  public function set_board($__v, $__type="default")
464  {
465      $object = is_null(keyval($this->property_objects_array,"{$__type}_board")) ? new board($this->get_board_id($__type)) : $this->property_objects_array["{$__type}_board"];
466      if (is_null($__v))
467      {
468          $rel = new board_topic(null,$object->id,$this->id,board_topic::type_id($__type));
469          $rel->delete();
470          if (!is_null(keyval($this->property_objects_array,"{$__type}_board")))
471          {
472              $this->property_objects_array["{$__type}_board"] = null;
473          }
474      }
475      else
476      {
477          $id = $object->id;
478          $object = $__v;
479          $object->id = $__v->id>0 ? $__v->id : $id;
480          $object->commit();
481          $this->set_board_ids(array($object->id),$__type);
482      }
483  }
publicset_board_id ( v , type ["default"] )[ topic_db ]
Parameters
requiredv
optionaltype ["default"]
Code
484  public function set_board_id($__v, $__type="default")
485  {
486      $this->set_board_ids(array($__v),$__type);
487  }
publicset_board_ids ( v , type ["default"] )[ topic_db ]
Parameters
requiredv
optionaltype ["default"]
Code
488  public function set_board_ids($__v, $__type="default")
489  {
490      if ($this->id == 0)
491      {
492          $this->commit();
493      }
494      $type_id = board_topic::type_id($__type);
495      board_topic::delete_all(null,$this->id,$type_id);
496      if (is_array($__v))
497      {
498          foreach ($__v as $index=>$id)
499          {
500              $object = new board_topic(null,$id,$this->id,$type_id);
501              $object->deleted = false;
502              $object->board_topic_type_id = $type_id;
503              $object->commit();
504              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_board")))
505              {
506                  $this->property_objects_array["{$__type}_board"] = new board($object->board_id);
507              }
508          }
509          $this->_dirty = true;
510      }
511  }
publicset_board_list ( v , type ["default"] )[ topic_db ]
Parameters
requiredv
optionaltype ["default"]
Code
512  public function set_board_list($__v, $__type="default")
513  {
514      if (is_array($__v))
515      {
516          $ids = array();
517          foreach ($__v as $index=>$object)
518          {
519              $ids[] = $object->id;
520          }
521          $this->set_board_ids($ids,$__type);
522      }
523  }
publicset_post ( v , type ["default"] )[ topic_db ]
Parameters
requiredv
optionaltype ["default"]
Code
364  public function set_post($__v, $__type="default")
365  {
366      $object = is_null(keyval($this->property_objects_array,"{$__type}_post")) ? new post($this->get_post_id($__type)) : $this->property_objects_array["{$__type}_post"];
367      if (is_null($__v))
368      {
369          $rel = new post_topic(null,$object->id,$this->id,post_topic::type_id($__type));
370          $rel->delete();
371          if (!is_null(keyval($this->property_objects_array,"{$__type}_post")))
372          {
373              $this->property_objects_array["{$__type}_post"] = null;
374          }
375      }
376      else
377      {
378          $id = $object->id;
379          $object = $__v;
380          $object->id = $__v->id>0 ? $__v->id : $id;
381          $object->commit();
382          $this->set_post_ids(array($object->id),$__type);
383      }
384  }
publicset_post_id ( v , type ["default"] )[ topic_db ]
Parameters
requiredv
optionaltype ["default"]
Code
385  public function set_post_id($__v, $__type="default")
386  {
387      $this->set_post_ids(array($__v),$__type);
388  }
publicset_post_ids ( v , type ["default"] )[ topic_db ]
Parameters
requiredv
optionaltype ["default"]
Code
389  public function set_post_ids($__v, $__type="default")
390  {
391      if ($this->id == 0)
392      {
393          $this->commit();
394      }
395      $type_id = post_topic::type_id($__type);
396      post_topic::delete_all(null,$this->id,$type_id);
397      if (is_array($__v))
398      {
399          foreach ($__v as $index=>$id)
400          {
401              $object = new post_topic(null,$id,$this->id,$type_id);
402              $object->deleted = false;
403              $object->post_topic_type_id = $type_id;
404              $object->commit();
405              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_post")))
406              {
407                  $this->property_objects_array["{$__type}_post"] = new post($object->post_id);
408              }
409          }
410          $this->_dirty = true;
411      }
412  }
publicset_post_list ( v , type ["default"] )[ topic_db ]
Parameters
requiredv
optionaltype ["default"]
Code
413  public function set_post_list($__v, $__type="default")
414  {
415      if (is_array($__v))
416      {
417          $ids = array();
418          foreach ($__v as $index=>$object)
419          {
420              $ids[] = $object->id;
421          }
422          $this->set_post_ids($ids,$__type);
423      }
424  }
public__toString ( )[ topic_db ]
Parameters
No parameters for this method
Code
322  public function __toString()
323  {
324      return (is_null($this->name) ? "" : $this->name);
325  }
publicundelete ( )[ topic_db ]
Parameters
No parameters for this method
Code
169  public function undelete()
170  {
171      $db = topic::db();
172      $q  = " UPDATE forum_topic SET ";
173      $q .= " deleted = 0 ";
174      $q .= " WHERE id = " . $this->_id;
175      $db->query($q);
176      $this->deleted = false;
177      return true;
178  }
protectedupdate ( )[ topic_db ]
Parameters
No parameters for this method
Code
144  protected function update()
145  {
146      $db = topic::db();
147      $q  = " UPDATE forum_topic SET ";
148      $q .= $db->param_string("name") . " = " . $db->value_string($this->_name) . ", ";
149      $q .= $db->param_string("description") . " = " . $db->value_string($this->_description) . ", ";
150      $q .= $db->param_string("views") . " = " . $db->value_string($this->_views) . ", ";
151      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
152      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
153      $q .= " WHERE id = " . $this->_id;
154      $db->query($q);
155      return true;
156  }
 
Accessors
publicarray[ obj ]
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicboard[ topic_db ]
Code
426  public function get_board($__type="default")
427  {
428      $object = is_null(keyval($this->property_objects_array,"{$__type}_board")) ? new board($this->get_board_id($__type)) : $this->property_objects_array["{$__type}_board"];
429      $this->property_objects_array["{$__type}_board"] = $object;
430      return $object;
431  }
Code
463  public function set_board($__v, $__type="default")
464  {
465      $object = is_null(keyval($this->property_objects_array,"{$__type}_board")) ? new board($this->get_board_id($__type)) : $this->property_objects_array["{$__type}_board"];
466      if (is_null($__v))
467      {
468          $rel = new board_topic(null,$object->id,$this->id,board_topic::type_id($__type));
469          $rel->delete();
470          if (!is_null(keyval($this->property_objects_array,"{$__type}_board")))
471          {
472              $this->property_objects_array["{$__type}_board"] = null;
473          }
474      }
475      else
476      {
477          $id = $object->id;
478          $object = $__v;
479          $object->id = $__v->id>0 ? $__v->id : $id;
480          $object->commit();
481          $this->set_board_ids(array($object->id),$__type);
482      }
483  }
publicboard_id[ topic_db ]
Code
432  public function get_board_id($__type="default")
433  {
434      $ids = $this->get_board_ids($__type, true);
435      return (count($ids)==1 ? $ids[0] : null);
436  }
Code
484  public function set_board_id($__v, $__type="default")
485  {
486      $this->set_board_ids(array($__v),$__type);
487  }
publicboard_ids[ topic_db ]
Code
437  public function get_board_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
438  {
439      $board_ids = array();
440      $db = topic::db();
441      $q  = " SELECT forum_board.id FROM forum_board_topic INNER JOIN forum_board ON forum_board_topic.board_id=forum_board.id AND forum_board_topic.deleted=0 AND forum_board.deleted=0 AND forum_board_topic.topic_id='$this->id' " . (is_null($__type) ? "" : " AND forum_board_topic.board_topic_type_id='" . board_topic::type_id($__type) . "'") . ($__get_primary ? " AND forum_board_topic.primary=1 " : "");
442      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
443      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
444      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
445      $db->query($q);
446      while ($db->next_record())
447      {
448          $board_ids[] = $db->f("id");
449      }
450      return $board_ids;
451  }
Code
488  public function set_board_ids($__v, $__type="default")
489  {
490      if ($this->id == 0)
491      {
492          $this->commit();
493      }
494      $type_id = board_topic::type_id($__type);
495      board_topic::delete_all(null,$this->id,$type_id);
496      if (is_array($__v))
497      {
498          foreach ($__v as $index=>$id)
499          {
500              $object = new board_topic(null,$id,$this->id,$type_id);
501              $object->deleted = false;
502              $object->board_topic_type_id = $type_id;
503              $object->commit();
504              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_board")))
505              {
506                  $this->property_objects_array["{$__type}_board"] = new board($object->board_id);
507              }
508          }
509          $this->_dirty = true;
510      }
511  }
publicboard_list[ topic_db ]
Code
452  public function get_board_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
453  {
454      $ids = $this->get_board_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
455      $objects = array();
456      foreach ($ids as $index=>$id)
457      {
458          $objects[$index] = new board($id);
459      }
460      return $objects;
461  }
Code
512  public function set_board_list($__v, $__type="default")
513  {
514      if (is_array($__v))
515      {
516          $ids = array();
517          foreach ($__v as $index=>$object)
518          {
519              $ids[] = $object->id;
520          }
521          $this->set_board_ids($ids,$__type);
522      }
523  }
publicclassname[ obj ]
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publiccolumns[ topic_db ]
Code
189  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
190  {
191      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
192      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
193      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
194 
195      $db = topic::db();
196      $data = array();
197      $q  = " SELECT $colstring ";
198      $q .= " FROM forum_topic ";
199      $q .= " WHERE forum_topic.deleted = 0 ";
200      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
201 
202      if (is_string($__order))
203      {
204          $q .= "ORDER BY " . $__order;
205      }
206      else if (is_array($__order) and count($__order)>0)
207      {
208          $orderings = array();
209          foreach ($__order as $col=>$dir)
210          {
211              $orderings[] = " $col $dir ";
212          }
213          $q .= "ORDER BY " . implode(", ", $orderings);
214      }
215      else if (is_object($__order))
216      {
217          $q .= "";
218      }
219      else
220      {
221          // THERE IS NO `order` COLUMN ON THIS OBJECT
222      }
223 
224      if (!is_null($__limit))
225      {
226          $q .= " LIMIT $__offset , $__limit ";
227      }
228 
229      $db->query($q);
230 
231      if (count($colarray)>1 || $colstring=="*")
232      {
233          while ($db->next_record())
234          {
235              $data[] = $db->record;
236          }
237      }
238      else
239      {
240          while ($db->next_record())
241          {
242              $data[] = $db->f(0);
243          }
244      }
245 
246      return $data;
247  }
publicdirty[ obj ]
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicfirst_post[ topic_ext ]
Code
035  public function get_first_post()
036  {
037      $posts = array();
038      $posts = $this->post_list;
039      if(count($posts)>0)
040      {
041          return $posts[0];
042      }
043      else
044      {
045          return new post();
046      }
047  }
publicids[ topic_db ]
Code
249  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
250  {
251      return topic::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
252  }
publicjson[ obj ]
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publiclast_post[ topic_ext ]
Code
049  public function get_last_post()
050  {
051      $posts = array();
052      $posts = $this->post_list;
053      if(count($posts)>0)
054      {
055          return $posts[count($posts)-1];
056      }
057      else
058      {
059          return new post();
060      }
061  }
publicobjects[ topic_db ]
Code
254  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
255  {
256      $objects = array();
257      foreach (topic::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
258      {
259          $objects[] = new topic($id);
260      }
261      return $objects;
262  }
publicpost[ topic_db ]
Code
327  public function get_post($__type="default")
328  {
329      $object = is_null(keyval($this->property_objects_array,"{$__type}_post")) ? new post($this->get_post_id($__type)) : $this->property_objects_array["{$__type}_post"];
330      $this->property_objects_array["{$__type}_post"] = $object;
331      return $object;
332  }
Code
364  public function set_post($__v, $__type="default")
365  {
366      $object = is_null(keyval($this->property_objects_array,"{$__type}_post")) ? new post($this->get_post_id($__type)) : $this->property_objects_array["{$__type}_post"];
367      if (is_null($__v))
368      {
369          $rel = new post_topic(null,$object->id,$this->id,post_topic::type_id($__type));
370          $rel->delete();
371          if (!is_null(keyval($this->property_objects_array,"{$__type}_post")))
372          {
373              $this->property_objects_array["{$__type}_post"] = null;
374          }
375      }
376      else
377      {
378          $id = $object->id;
379          $object = $__v;
380          $object->id = $__v->id>0 ? $__v->id : $id;
381          $object->commit();
382          $this->set_post_ids(array($object->id),$__type);
383      }
384  }
publicpost_id[ topic_db ]
Code
333  public function get_post_id($__type="default")
334  {
335      $ids = $this->get_post_ids($__type, true);
336      return (count($ids)==1 ? $ids[0] : null);
337  }
Code
385  public function set_post_id($__v, $__type="default")
386  {
387      $this->set_post_ids(array($__v),$__type);
388  }
publicpost_ids[ topic_ext ]
[ topic_db ]
Code
008  public function get_post_ids($__type=null, $__get_primary=false)
009  {
010      //get posts from newest to oldest
011      $post_ids = array();
012      $ids = post_topic::get_ids(null,$this->id,is_null($__type) ? null : post_topic::type_id($__type),"cdate");
013      if (!is_null($__type) && count($ids)>1 && $__get_primary)
014      {
015          foreach ($ids as $id)
016          {
017              $object = new post_topic($id);
018              if ($object->primary)
019              {
020                  return array($object->post_id);
021              }
022          }
023      }
024      else
025      {
026          foreach ($ids as $id)
027          {
028              $object = new post_topic($id);
029              $post_ids[] = $object->post_id;
030          }
031      }
032      return $post_ids;
033  }
Code
389  public function set_post_ids($__v, $__type="default")
390  {
391      if ($this->id == 0)
392      {
393          $this->commit();
394      }
395      $type_id = post_topic::type_id($__type);
396      post_topic::delete_all(null,$this->id,$type_id);
397      if (is_array($__v))
398      {
399          foreach ($__v as $index=>$id)
400          {
401              $object = new post_topic(null,$id,$this->id,$type_id);
402              $object->deleted = false;
403              $object->post_topic_type_id = $type_id;
404              $object->commit();
405              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_post")))
406              {
407                  $this->property_objects_array["{$__type}_post"] = new post($object->post_id);
408              }
409          }
410          $this->_dirty = true;
411      }
412  }
publicpost_list[ topic_db ]
Code
353  public function get_post_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
354  {
355      $ids = $this->get_post_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
356      $objects = array();
357      foreach ($ids as $index=>$id)
358      {
359          $objects[$index] = new post($id);
360      }
361      return $objects;
362  }
Code
413  public function set_post_list($__v, $__type="default")
414  {
415      if (is_array($__v))
416      {
417          $ids = array();
418          foreach ($__v as $index=>$object)
419          {
420              $ids[] = $object->id;
421          }
422          $this->set_post_ids($ids,$__type);
423      }
424  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads