Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class menu extends menu_ext

Hide Inherited MembersUser Interface
Description
No description.
 
Constants
constantTABLENAME ["ifc_menu"][ menu ]
 
Properties
protected_cdate[ menu_db ]
protected_cdate_dirty[ menu_db ]
protected_deleted[ menu_db ]
protected_deleted_dirty[ menu_db ]
protected_description[ menu_db ]
protected_description_dirty[ menu_db ]
protected_dirty[ obj ]
protected_id[ menu_db ]
protected_id_dirty[ menu_db ]
protected_mdate[ menu_db ]
protected_mdate_dirty[ menu_db ]
protected_name[ menu_db ]
protected_name_dirty[ menu_db ]
protected_path[ menu_db ]
protected_path_dirty[ menu_db ]
protected_popup[ menu_db ]
protected_popup_dirty[ menu_db ]
publicproperty_objects_array[ obj ]
protected_query_string[ menu_db ]
protected_query_string_dirty[ menu_db ]
 
Methods
publiccommit ( )[ menu_db ]
Parameters
No parameters for this method
Code
110  public function commit()
111  {
112      if ($this->_id > 0)
113      {
114          $this->update();
115      }
116      else
117      {
118          $this->insert();
119      }
120 
121      foreach ($this->property_objects_array as $property=>$object)
122      {
123          $this->{$property} = $object;
124      }
125 
126      return true;
127  }
public__construct ( id )[ menu_db ]
Parameters
optionalid
Code
048  public function __construct($__id=null)
049  {
050      $this->_id = 0;
051      $this->_name = "";
052      $this->_description = "";
053      $this->_path = "";
054      $this->_query_string = "";
055      $this->_popup = false;
056      $this->_mdate = null;
057      $this->_cdate = null;
058      $this->_deleted = false;
059 
060      $this->_id_dirty = false;
061      $this->_name_dirty = false;
062      $this->_description_dirty = false;
063      $this->_path_dirty = false;
064      $this->_query_string_dirty = false;
065      $this->_popup_dirty = false;
066      $this->_mdate_dirty = false;
067      $this->_cdate_dirty = false;
068      $this->_deleted_dirty = false;
069 
070      if (is_null($__id))
071      {
072          return;
073      }
074 
075      $db = menu::db();
076      $q  = " SELECT ifc_menu.id,ifc_menu.name,ifc_menu.description,ifc_menu.path,ifc_menu.query_string,ifc_menu.popup,ifc_menu.mdate,ifc_menu.cdate,ifc_menu.deleted ";
077      $q .= " FROM ifc_menu ";       
078      if (!is_null($__id))
079      {
080          $q .= " WHERE id = '$__id' ";
081      }
082 
083      $db->query($q);
084      if ($db->next_record() && $db->num_rows() == 1)
085      {
086          $this->_id = $db->f("id");
087          $this->_name = $db->f("name");
088          $this->_description = $db->f("description");
089          $this->_path = $db->f("path");
090          $this->_query_string = $db->f("query_string");
091          $this->_popup = $db->f("popup");
092          $this->_mdate = $db->f("mdate");
093          $this->_cdate = $db->f("cdate");
094          $this->_deleted = $db->f("deleted");
095      }
096  }
protected staticdb ( )[ menu_db ]
Parameters
No parameters for this method
Code
539  protected static function db()
540  {
541      return new db();
542  }
publicdelete ( )[ menu_db ]
Parameters
No parameters for this method
Code
172  public function delete()
173  {
174      $db = menu::db();
175      $q  = " UPDATE ifc_menu SET ";
176      $q .= " deleted = 1 ";
177      $q .= " WHERE id = " . $this->_id;
178      $db->query($q);
179      $this->deleted = true;
180      return true;
181  }
public staticdelete_all ( )[ menu_db ]
Parameters
No parameters for this method
Code
278  public static function delete_all()
279  {
280      $db = menu::db();
281      $q  = " UPDATE ifc_menu SET ";
282      $q .= " deleted = 1 ";
283     
284      $db->query($q);
285      return true;
286  }
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_ancestors ( )[ menu_ext ]
Parameters
No parameters for this method
Code
032  public function get_ancestors()
033  {
034      $ancestors = array();
035      $menu = $this;
036      while (!$menu->parent->is_root)
037      {
038          $ancestors[] = $menu->parent;
039          $menu = $menu->parent;
040      }
041      return $ancestors;
042  }
publicget_array ( )[ obj ]
Parameters
No parameters for this method
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicget_child_count ( )[ menu_ext ]
Parameters
No parameters for this method
Code
049  public function get_child_count()
050  {
051      return count(menu_menu::get_ids(null,$this->_id));
052  }
publicget_children ( )[ menu_ext ]
Parameters
No parameters for this method
Code
007  public function get_children()
008  {
009      $children = array();
010      foreach (menu_menu::get_ids(null,$this->_id) as $menu_menu_id)
011      {
012          $menu_menu = new menu_menu($menu_menu_id);
013          $children[] = new menu($menu_menu->child_id);
014      }
015      return $children;
016  }
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] )[ menu_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
203  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
204  {
205      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
206      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
207      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
208 
209      $db = menu::db();
210      $data = array();
211      $q  = " SELECT $colstring ";
212      $q .= " FROM ifc_menu ";
213      $q .= " WHERE ifc_menu.deleted = 0 ";
214      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
215 
216      if (is_string($__order))
217      {
218          $q .= "ORDER BY " . $__order;
219      }
220      else if (is_array($__order) and count($__order)>0)
221      {
222          $orderings = array();
223          foreach ($__order as $col=>$dir)
224          {
225              $orderings[] = " $col $dir ";
226          }
227          $q .= "ORDER BY " . implode(", ", $orderings);
228      }
229      else if (is_object($__order))
230      {
231          $q .= "";
232      }
233      else
234      {
235          // THERE IS NO `order` COLUMN ON THIS OBJECT
236      }
237 
238      if (!is_null($__limit))
239      {
240          $q .= " LIMIT $__offset , $__limit ";
241      }
242 
243      $db->query($q);
244 
245      if (count($colarray)>1 || $colstring=="*")
246      {
247          while ($db->next_record())
248          {
249              $data[] = $db->record;
250          }
251      }
252      else
253      {
254          while ($db->next_record())
255          {
256              $data[] = $db->f(0);
257          }
258      }
259 
260      return $data;
261  }
publicget_descendants ( )[ menu_ext ]
Parameters
No parameters for this method
Code
018  public function get_descendants()
019  {
020      $descendants = array();
021      foreach ($this->children as $child)
022      {
023          $descendants[] = $child;
024          if ($child->has_children)
025          {
026              $descendants = array_unique(array_merge($descendants, $child->descendants));
027          }
028      }
029      return $descendants;
030  }
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_entity ( type ["default"] )[ menu_db ]
Parameters
optionaltype ["default"]
Code
440  public function get_entity($__type="default")
441  {
442      $object = is_null(keyval($this->property_objects_array,"{$__type}_entity")) ? new entity($this->get_entity_id($__type)) : $this->property_objects_array["{$__type}_entity"];
443      $this->property_objects_array["{$__type}_entity"] = $object;
444      return $object;
445  }
publicget_entity_id ( type ["default"] )[ menu_db ]
Parameters
optionaltype ["default"]
Code
446  public function get_entity_id($__type="default")
447  {
448      $ids = $this->get_entity_ids($__type, true);
449      return (count($ids)==1 ? $ids[0] : null);
450  }
publicget_entity_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ menu_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
451  public function get_entity_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
452  {
453      $entity_ids = array();
454      $db = menu::db();
455      $q  = " SELECT cor_entity.id FROM ifc_entity_menu INNER JOIN cor_entity ON ifc_entity_menu.entity_id=cor_entity.id AND ifc_entity_menu.deleted=0 AND cor_entity.deleted=0 AND ifc_entity_menu.menu_id='$this->id' " . (is_null($__type) ? "" : " AND ifc_entity_menu.entity_menu_type_id='" . entity_menu::type_id($__type) . "'") . ($__get_primary ? " AND ifc_entity_menu.primary=1 " : "");
456      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
457      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
458      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
459      $db->query($q);
460      while ($db->next_record())
461      {
462          $entity_ids[] = $db->f("id");
463      }
464      return $entity_ids;
465  }
publicget_entity_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ menu_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
466  public function get_entity_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
467  {
468      $ids = $this->get_entity_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
469      $objects = array();
470      foreach ($ids as $index=>$id)
471      {
472          $objects[$index] = new entity($id);
473      }
474      return $objects;
475  }
publicget_has_children ( )[ menu_ext ]
Parameters
No parameters for this method
Code
044  public function get_has_children()
045  {
046      return ($this->child_count > 0);
047  }
publicget_has_visible_children ( )[ menu_ext ]
Parameters
No parameters for this method
Code
113  public function get_has_visible_children()
114  {
115      global $perm;
116      foreach ($this->descendants as $menu)
117      {
118          if ($sess->user->check_perms($menu->page->perms))
119          {
120              return true;
121          }
122      }
123      return false;
124  }
public staticget_ids ( order , lookups , where_clause , limit , offset [0] )[ menu_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
263  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
264  {
265      return menu::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
266  }
publicget_is_root ( )[ menu_ext ]
Parameters
No parameters for this method
Code
082  public function get_is_root()
083  {
084      return ($this->parent->id == 0);
085  }
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_level ( )[ menu_ext ]
Parameters
No parameters for this method
Code
054  public function get_level()
055  {
056      if ($this->is_root)
057      {
058          return 0;
059      }
060      $level = 1;
061      $parent = $this->parent;
062      while (!$parent->is_root)
063      {
064          $parent = $parent->parent;
065          $level++;
066      }
067      return $level;
068  }
public staticget_objects ( order , lookups , where_clause , limit , offset [0] )[ menu_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
268  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
269  {
270      $objects = array();
271      foreach (menu::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
272      {
273          $objects[] = new menu($id);
274      }
275      return $objects;
276  }
publicget_page ( )[ menu_ext ]
Parameters
No parameters for this method
Code
101  public function get_page()
102  {
103      $page = new page();
104      foreach (menu_page::get_ids($this->_id,null) as $menu_page_id)
105      {
106          $menu_page = new menu_page($menu_page_id);
107          $page = new page($menu_page->page_id);
108          break;
109      }
110      return $page;
111  }
publicget_page_id ( type ["default"] )[ menu_db ]
Parameters
optionaltype ["default"]
Code
347  public function get_page_id($__type="default")
348  {
349      $ids = $this->get_page_ids($__type, true);
350      return (count($ids)==1 ? $ids[0] : null);
351  }
publicget_page_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ menu_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
352  public function get_page_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
353  {
354      $page_ids = array();
355      $db = menu::db();
356      $q  = " SELECT cor_page.id FROM ifc_menu_page INNER JOIN cor_page ON ifc_menu_page.page_id=cor_page.id AND ifc_menu_page.deleted=0 AND cor_page.deleted=0 AND ifc_menu_page.menu_id='$this->id' " . (is_null($__type) ? "" : " AND ifc_menu_page.menu_page_type_id='" . menu_page::type_id($__type) . "'") . ($__get_primary ? " AND ifc_menu_page.primary=1 " : "");
357      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
358      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
359      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
360      $db->query($q);
361      while ($db->next_record())
362      {
363          $page_ids[] = $db->f("id");
364      }
365      return $page_ids;
366  }
publicget_page_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ menu_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
367  public function get_page_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
368  {
369      $ids = $this->get_page_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
370      $objects = array();
371      foreach ($ids as $index=>$id)
372      {
373          $objects[$index] = new page($id);
374      }
375      return $objects;
376  }
publicget_parent ( )[ menu_ext ]
Parameters
No parameters for this method
Code
070  public function get_parent()
071  {
072      $parent = new menu();
073      foreach (menu_menu::get_ids($this->_id,null) as $menu_menu_id)
074      {
075          $menu_menu = new menu_menu($menu_menu_id);
076          $parent = new menu($menu_menu->parent_id);
077          break;
078      }
079      return $parent;
080  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
public staticget_root_menus ( )[ menu_ext ]
Parameters
No parameters for this method
Code
087  public static function get_root_menus()
088  {
089      $root_menus = array();
090      foreach (self::get_ids() as $menu_id)
091      {
092          $menu = new menu($menu_id);
093          if ($menu->is_root)
094          {
095              $root_menus[] = $menu;
096          }
097      }
098      return $root_menus;
099  }
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 ( )[ menu_db ]
Parameters
No parameters for this method
Code
129  protected function insert()
130  {
131      $db = menu::db();
132      $q  = " INSERT INTO ifc_menu ( ";
133      $q .= $db->param_string("name") . ", ";
134      $q .= $db->param_string("description") . ", ";
135      $q .= $db->param_string("path") . ", ";
136      $q .= $db->param_string("query_string") . ", ";
137      $q .= $db->param_string("popup") . ", ";
138      $q .= $db->param_string("mdate") . ", ";
139      $q .= $db->param_string("cdate") . ", ";
140      $q .= $db->param_string("deleted");
141      $q .= " ) VALUES ( ";
142      $q .= $db->value_string($this->_name) . ", ";
143      $q .= $db->value_string($this->_description) . ", ";
144      $q .= $db->value_string($this->_path) . ", ";
145      $q .= $db->value_string($this->_query_string) . ", ";
146      $q .= ($this->_popup ? "'1'" : "'0'") . ", ";
147      $q .= $db->value_string(timestamp()) . ", ";
148      $q .= $db->value_string(timestamp()) . ", ";
149      $q .= $this->deleted ? "'1'" : "'0'";
150      $q .= " ) ";
151      $db->query($q);
152      $this->_id = $db->insert_id;
153      return true;
154  }
publicmap ( )[ menu_db ]
Parameters
No parameters for this method
Code
098  public function map()
099  {
100      $this->_name = array_key_exists("menu:name",$_REQUEST) ? reqval("menu:name") : $this->_name;
101      $this->_description = array_key_exists("menu:description",$_REQUEST) ? reqval("menu:description") : $this->_description;
102      $this->_path = array_key_exists("menu:path",$_REQUEST) ? reqval("menu:path") : $this->_path;
103      $this->_query_string = array_key_exists("menu:query_string",$_REQUEST) ? reqval("menu:query_string") : $this->_query_string;
104      $this->_popup = array_key_exists("menu:popup",$_REQUEST) ? reqval("menu:popup") : $this->_popup;
105      $this->_mdate = array_key_exists("menu:mdate",$_REQUEST) ? reqval("menu:mdate") : $this->_mdate;
106      $this->_cdate = array_key_exists("menu:cdate",$_REQUEST) ? reqval("menu:cdate") : $this->_cdate;
107      $this->_deleted = array_key_exists("menu:deleted",$_REQUEST) ? reqval("menu:deleted") : $this->_deleted;
108  }
publicpurge ( )[ menu_db ]
Parameters
No parameters for this method
Code
194  public function purge()
195  {
196      $db = menu::db();
197      $q  = " DELETE FROM ifc_menu ";
198      $q .= " WHERE id = " . $this->_id;
199      $db->query($q);
200      return true;
201  }
public staticsearch ( keyword )[ menu_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_entity ( v , type ["default"] )[ menu_db ]
Parameters
requiredv
optionaltype ["default"]
Code
477  public function set_entity($__v, $__type="default")
478  {
479      $object = is_null(keyval($this->property_objects_array,"{$__type}_entity")) ? new entity($this->get_entity_id($__type)) : $this->property_objects_array["{$__type}_entity"];
480      if (is_null($__v))
481      {
482          $rel = new entity_menu(null,$object->id,$this->id,entity_menu::type_id($__type));
483          $rel->delete();
484          if (!is_null(keyval($this->property_objects_array,"{$__type}_entity")))
485          {
486              $this->property_objects_array["{$__type}_entity"] = null;
487          }
488      }
489      else
490      {
491          $id = $object->id;
492          $object = $__v;
493          $object->id = $__v->id>0 ? $__v->id : $id;
494          $object->commit();
495          $this->set_entity_ids(array($object->id),$__type);
496      }
497  }
publicset_entity_id ( v , type ["default"] )[ menu_db ]
Parameters
requiredv
optionaltype ["default"]
Code
498  public function set_entity_id($__v, $__type="default")
499  {
500      $this->set_entity_ids(array($__v),$__type);
501  }
publicset_entity_ids ( v , type ["default"] )[ menu_db ]
Parameters
requiredv
optionaltype ["default"]
Code
502  public function set_entity_ids($__v, $__type="default")
503  {
504      if ($this->id == 0)
505      {
506          $this->commit();
507      }
508      $type_id = entity_menu::type_id($__type);
509      entity_menu::delete_all(null,$this->id,$type_id);
510      if (is_array($__v))
511      {
512          foreach ($__v as $index=>$id)
513          {
514              $object = new entity_menu(null,$id,$this->id,$type_id);
515              $object->deleted = false;
516              $object->entity_menu_type_id = $type_id;
517              $object->commit();
518              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_entity")))
519              {
520                  $this->property_objects_array["{$__type}_entity"] = new entity($object->entity_id);
521              }
522          }
523          $this->_dirty = true;
524      }
525  }
publicset_entity_list ( v , type ["default"] )[ menu_db ]
Parameters
requiredv
optionaltype ["default"]
Code
526  public function set_entity_list($__v, $__type="default")
527  {
528      if (is_array($__v))
529      {
530          $ids = array();
531          foreach ($__v as $index=>$object)
532          {
533              $ids[] = $object->id;
534          }
535          $this->set_entity_ids($ids,$__type);
536      }
537  }
publicset_page ( v , type ["default"] )[ menu_db ]
Parameters
requiredv
optionaltype ["default"]
Code
378  public function set_page($__v, $__type="default")
379  {
380      $object = is_null(keyval($this->property_objects_array,"{$__type}_page")) ? new page($this->get_page_id($__type)) : $this->property_objects_array["{$__type}_page"];
381      if (is_null($__v))
382      {
383          $rel = new menu_page(null,$this->id,$object->id,menu_page::type_id($__type));
384          $rel->delete();
385          if (!is_null(keyval($this->property_objects_array,"{$__type}_page")))
386          {
387              $this->property_objects_array["{$__type}_page"] = null;
388          }
389      }
390      else
391      {
392          $id = $object->id;
393          $object = $__v;
394          $object->id = $__v->id>0 ? $__v->id : $id;
395          $object->commit();
396          $this->set_page_ids(array($object->id),$__type);
397      }
398  }
publicset_page_id ( v , type ["default"] )[ menu_db ]
Parameters
requiredv
optionaltype ["default"]
Code
399  public function set_page_id($__v, $__type="default")
400  {
401      $this->set_page_ids(array($__v),$__type);
402  }
publicset_page_ids ( v , type ["default"] )[ menu_db ]
Parameters
requiredv
optionaltype ["default"]
Code
403  public function set_page_ids($__v, $__type="default")
404  {
405      if ($this->id == 0)
406      {
407          $this->commit();
408      }
409      $type_id = menu_page::type_id($__type);
410      menu_page::delete_all($this->id,null,$type_id);
411      if (is_array($__v))
412      {
413          foreach ($__v as $index=>$id)
414          {
415              $object = new menu_page(null,$this->id,$id,$type_id);
416              $object->deleted = false;
417              $object->menu_page_type_id = $type_id;
418              $object->commit();
419              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_page")))
420              {
421                  $this->property_objects_array["{$__type}_page"] = new page($object->page_id);
422              }
423          }
424          $this->_dirty = true;
425      }
426  }
publicset_page_list ( v , type ["default"] )[ menu_db ]
Parameters
requiredv
optionaltype ["default"]
Code
427  public function set_page_list($__v, $__type="default")
428  {
429      if (is_array($__v))
430      {
431          $ids = array();
432          foreach ($__v as $index=>$object)
433          {
434              $ids[] = $object->id;
435          }
436          $this->set_page_ids($ids,$__type);
437      }
438  }
public__toString ( )[ menu_db ]
Parameters
No parameters for this method
Code
336  public function __toString()
337  {
338      return (is_null($this->name) ? "" : $this->name);
339  }
publicundelete ( )[ menu_db ]
Parameters
No parameters for this method
Code
183  public function undelete()
184  {
185      $db = menu::db();
186      $q  = " UPDATE ifc_menu SET ";
187      $q .= " deleted = 0 ";
188      $q .= " WHERE id = " . $this->_id;
189      $db->query($q);
190      $this->deleted = false;
191      return true;
192  }
protectedupdate ( )[ menu_db ]
Parameters
No parameters for this method
Code
156  protected function update()
157  {
158      $db = menu::db();
159      $q  = " UPDATE ifc_menu SET ";
160      $q .= $db->param_string("name") . " = " . $db->value_string($this->_name) . ", ";
161      $q .= $db->param_string("description") . " = " . $db->value_string($this->_description) . ", ";
162      $q .= $db->param_string("path") . " = " . $db->value_string($this->_path) . ", ";
163      $q .= $db->param_string("query_string") . " = " . $db->value_string($this->_query_string) . ", ";
164      $q .= $db->param_string("popup") . " = " . ($this->_popup ? "'1'" : "'0'") . ", ";
165      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
166      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
167      $q .= " WHERE id = " . $this->_id;
168      $db->query($q);
169      return true;
170  }
 
Accessors
publicancestors[ menu_ext ]
Code
032  public function get_ancestors()
033  {
034      $ancestors = array();
035      $menu = $this;
036      while (!$menu->parent->is_root)
037      {
038          $ancestors[] = $menu->parent;
039          $menu = $menu->parent;
040      }
041      return $ancestors;
042  }
publicarray[ obj ]
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicchild_count[ menu_ext ]
Code
049  public function get_child_count()
050  {
051      return count(menu_menu::get_ids(null,$this->_id));
052  }
publicchildren[ menu_ext ]
Code
007  public function get_children()
008  {
009      $children = array();
010      foreach (menu_menu::get_ids(null,$this->_id) as $menu_menu_id)
011      {
012          $menu_menu = new menu_menu($menu_menu_id);
013          $children[] = new menu($menu_menu->child_id);
014      }
015      return $children;
016  }
publicclassname[ obj ]
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publiccolumns[ menu_db ]
Code
203  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
204  {
205      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
206      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
207      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
208 
209      $db = menu::db();
210      $data = array();
211      $q  = " SELECT $colstring ";
212      $q .= " FROM ifc_menu ";
213      $q .= " WHERE ifc_menu.deleted = 0 ";
214      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
215 
216      if (is_string($__order))
217      {
218          $q .= "ORDER BY " . $__order;
219      }
220      else if (is_array($__order) and count($__order)>0)
221      {
222          $orderings = array();
223          foreach ($__order as $col=>$dir)
224          {
225              $orderings[] = " $col $dir ";
226          }
227          $q .= "ORDER BY " . implode(", ", $orderings);
228      }
229      else if (is_object($__order))
230      {
231          $q .= "";
232      }
233      else
234      {
235          // THERE IS NO `order` COLUMN ON THIS OBJECT
236      }
237 
238      if (!is_null($__limit))
239      {
240          $q .= " LIMIT $__offset , $__limit ";
241      }
242 
243      $db->query($q);
244 
245      if (count($colarray)>1 || $colstring=="*")
246      {
247          while ($db->next_record())
248          {
249              $data[] = $db->record;
250          }
251      }
252      else
253      {
254          while ($db->next_record())
255          {
256              $data[] = $db->f(0);
257          }
258      }
259 
260      return $data;
261  }
publicdescendants[ menu_ext ]
Code
018  public function get_descendants()
019  {
020      $descendants = array();
021      foreach ($this->children as $child)
022      {
023          $descendants[] = $child;
024          if ($child->has_children)
025          {
026              $descendants = array_unique(array_merge($descendants, $child->descendants));
027          }
028      }
029      return $descendants;
030  }
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  }
publicentity[ menu_db ]
Code
440  public function get_entity($__type="default")
441  {
442      $object = is_null(keyval($this->property_objects_array,"{$__type}_entity")) ? new entity($this->get_entity_id($__type)) : $this->property_objects_array["{$__type}_entity"];
443      $this->property_objects_array["{$__type}_entity"] = $object;
444      return $object;
445  }
Code
477  public function set_entity($__v, $__type="default")
478  {
479      $object = is_null(keyval($this->property_objects_array,"{$__type}_entity")) ? new entity($this->get_entity_id($__type)) : $this->property_objects_array["{$__type}_entity"];
480      if (is_null($__v))
481      {
482          $rel = new entity_menu(null,$object->id,$this->id,entity_menu::type_id($__type));
483          $rel->delete();
484          if (!is_null(keyval($this->property_objects_array,"{$__type}_entity")))
485          {
486              $this->property_objects_array["{$__type}_entity"] = null;
487          }
488      }
489      else
490      {
491          $id = $object->id;
492          $object = $__v;
493          $object->id = $__v->id>0 ? $__v->id : $id;
494          $object->commit();
495          $this->set_entity_ids(array($object->id),$__type);
496      }
497  }
publicentity_id[ menu_db ]
Code
446  public function get_entity_id($__type="default")
447  {
448      $ids = $this->get_entity_ids($__type, true);
449      return (count($ids)==1 ? $ids[0] : null);
450  }
Code
498  public function set_entity_id($__v, $__type="default")
499  {
500      $this->set_entity_ids(array($__v),$__type);
501  }
publicentity_ids[ menu_db ]
Code
451  public function get_entity_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
452  {
453      $entity_ids = array();
454      $db = menu::db();
455      $q  = " SELECT cor_entity.id FROM ifc_entity_menu INNER JOIN cor_entity ON ifc_entity_menu.entity_id=cor_entity.id AND ifc_entity_menu.deleted=0 AND cor_entity.deleted=0 AND ifc_entity_menu.menu_id='$this->id' " . (is_null($__type) ? "" : " AND ifc_entity_menu.entity_menu_type_id='" . entity_menu::type_id($__type) . "'") . ($__get_primary ? " AND ifc_entity_menu.primary=1 " : "");
456      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
457      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
458      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
459      $db->query($q);
460      while ($db->next_record())
461      {
462          $entity_ids[] = $db->f("id");
463      }
464      return $entity_ids;
465  }
Code
502  public function set_entity_ids($__v, $__type="default")
503  {
504      if ($this->id == 0)
505      {
506          $this->commit();
507      }
508      $type_id = entity_menu::type_id($__type);
509      entity_menu::delete_all(null,$this->id,$type_id);
510      if (is_array($__v))
511      {
512          foreach ($__v as $index=>$id)
513          {
514              $object = new entity_menu(null,$id,$this->id,$type_id);
515              $object->deleted = false;
516              $object->entity_menu_type_id = $type_id;
517              $object->commit();
518              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_entity")))
519              {
520                  $this->property_objects_array["{$__type}_entity"] = new entity($object->entity_id);
521              }
522          }
523          $this->_dirty = true;
524      }
525  }
publicentity_list[ menu_db ]
Code
466  public function get_entity_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
467  {
468      $ids = $this->get_entity_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
469      $objects = array();
470      foreach ($ids as $index=>$id)
471      {
472          $objects[$index] = new entity($id);
473      }
474      return $objects;
475  }
Code
526  public function set_entity_list($__v, $__type="default")
527  {
528      if (is_array($__v))
529      {
530          $ids = array();
531          foreach ($__v as $index=>$object)
532          {
533              $ids[] = $object->id;
534          }
535          $this->set_entity_ids($ids,$__type);
536      }
537  }
publichas_children[ menu_ext ]
Code
044  public function get_has_children()
045  {
046      return ($this->child_count > 0);
047  }
publichas_visible_children[ menu_ext ]
Code
113  public function get_has_visible_children()
114  {
115      global $perm;
116      foreach ($this->descendants as $menu)
117      {
118          if ($sess->user->check_perms($menu->page->perms))
119          {
120              return true;
121          }
122      }
123      return false;
124  }
publicids[ menu_db ]
Code
263  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
264  {
265      return menu::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
266  }
publicis_root[ menu_ext ]
Code
082  public function get_is_root()
083  {
084      return ($this->parent->id == 0);
085  }
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  }
publiclevel[ menu_ext ]
Code
054  public function get_level()
055  {
056      if ($this->is_root)
057      {
058          return 0;
059      }
060      $level = 1;
061      $parent = $this->parent;
062      while (!$parent->is_root)
063      {
064          $parent = $parent->parent;
065          $level++;
066      }
067      return $level;
068  }
publicobjects[ menu_db ]
Code
268  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
269  {
270      $objects = array();
271      foreach (menu::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
272      {
273          $objects[] = new menu($id);
274      }
275      return $objects;
276  }
publicpage[ menu_ext ]
[ menu_db ]
Code
101  public function get_page()
102  {
103      $page = new page();
104      foreach (menu_page::get_ids($this->_id,null) as $menu_page_id)
105      {
106          $menu_page = new menu_page($menu_page_id);
107          $page = new page($menu_page->page_id);
108          break;
109      }
110      return $page;
111  }
Code
378  public function set_page($__v, $__type="default")
379  {
380      $object = is_null(keyval($this->property_objects_array,"{$__type}_page")) ? new page($this->get_page_id($__type)) : $this->property_objects_array["{$__type}_page"];
381      if (is_null($__v))
382      {
383          $rel = new menu_page(null,$this->id,$object->id,menu_page::type_id($__type));
384          $rel->delete();
385          if (!is_null(keyval($this->property_objects_array,"{$__type}_page")))
386          {
387              $this->property_objects_array["{$__type}_page"] = null;
388          }
389      }
390      else
391      {
392          $id = $object->id;
393          $object = $__v;
394          $object->id = $__v->id>0 ? $__v->id : $id;
395          $object->commit();
396          $this->set_page_ids(array($object->id),$__type);
397      }
398  }
publicpage_id[ menu_db ]
Code
347  public function get_page_id($__type="default")
348  {
349      $ids = $this->get_page_ids($__type, true);
350      return (count($ids)==1 ? $ids[0] : null);
351  }
Code
399  public function set_page_id($__v, $__type="default")
400  {
401      $this->set_page_ids(array($__v),$__type);
402  }
publicpage_ids[ menu_db ]
Code
352  public function get_page_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
353  {
354      $page_ids = array();
355      $db = menu::db();
356      $q  = " SELECT cor_page.id FROM ifc_menu_page INNER JOIN cor_page ON ifc_menu_page.page_id=cor_page.id AND ifc_menu_page.deleted=0 AND cor_page.deleted=0 AND ifc_menu_page.menu_id='$this->id' " . (is_null($__type) ? "" : " AND ifc_menu_page.menu_page_type_id='" . menu_page::type_id($__type) . "'") . ($__get_primary ? " AND ifc_menu_page.primary=1 " : "");
357      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
358      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
359      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
360      $db->query($q);
361      while ($db->next_record())
362      {
363          $page_ids[] = $db->f("id");
364      }
365      return $page_ids;
366  }
Code
403  public function set_page_ids($__v, $__type="default")
404  {
405      if ($this->id == 0)
406      {
407          $this->commit();
408      }
409      $type_id = menu_page::type_id($__type);
410      menu_page::delete_all($this->id,null,$type_id);
411      if (is_array($__v))
412      {
413          foreach ($__v as $index=>$id)
414          {
415              $object = new menu_page(null,$this->id,$id,$type_id);
416              $object->deleted = false;
417              $object->menu_page_type_id = $type_id;
418              $object->commit();
419              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_page")))
420              {
421                  $this->property_objects_array["{$__type}_page"] = new page($object->page_id);
422              }
423          }
424          $this->_dirty = true;
425      }
426  }
publicpage_list[ menu_db ]
Code
367  public function get_page_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
368  {
369      $ids = $this->get_page_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
370      $objects = array();
371      foreach ($ids as $index=>$id)
372      {
373          $objects[$index] = new page($id);
374      }
375      return $objects;
376  }
Code
427  public function set_page_list($__v, $__type="default")
428  {
429      if (is_array($__v))
430      {
431          $ids = array();
432          foreach ($__v as $index=>$object)
433          {
434              $ids[] = $object->id;
435          }
436          $this->set_page_ids($ids,$__type);
437      }
438  }
publicparent[ menu_ext ]
Code
070  public function get_parent()
071  {
072      $parent = new menu();
073      foreach (menu_menu::get_ids($this->_id,null) as $menu_menu_id)
074      {
075          $menu_menu = new menu_menu($menu_menu_id);
076          $parent = new menu($menu_menu->parent_id);
077          break;
078      }
079      return $parent;
080  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicroot_menus[ menu_ext ]
Code
087  public static function get_root_menus()
088  {
089      $root_menus = array();
090      foreach (self::get_ids() as $menu_id)
091      {
092          $menu = new menu($menu_id);
093          if ($menu->is_root)
094          {
095              $root_menus[] = $menu;
096          }
097      }
098      return $root_menus;
099  }
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