2012-05-25 09:48:56 +00:00
< ? php
2012-06-25 13:03:14 +00:00
class AchMenu extends Parentum {
2012-06-24 10:44:24 +00:00
/*---------------------------
This class is the dispatcher for actual MenuNodes .
Since every MenuNode will only keep a list of it ' s children ,
we have to handle the main nodes which have no parent this way .
---------------------------*/
protected $open ;
2012-05-27 19:08:28 +00:00
2012-05-31 13:15:36 +00:00
function AchMenu ( $open = false ) {
global $DBc , $_USER ;
2012-05-25 09:48:56 +00:00
2012-07-08 16:11:25 +00:00
parent :: __construct ();
2012-05-27 19:08:28 +00:00
$this -> open = $open ;
2012-05-28 19:09:44 +00:00
2012-06-24 10:44:24 +00:00
// the summary page is autogenerated and has no database entry. We add it manually here.
2012-07-01 18:04:01 +00:00
/* $tmp = array ();
2012-05-28 19:09:44 +00:00
$tmp [ 'ac_id' ] = 0 ;
$tmp [ 'ac_parent' ] = null ;
2012-05-31 13:15:36 +00:00
$tmp [ 'acl_name' ] = get_translation ( 'ach_summary' , $_USER -> getLang ());
2012-06-21 18:55:52 +00:00
$tmp [ 'ac_image' ] = " test.png " ;
2012-05-28 19:09:44 +00:00
$tmp [ 'ac_order' ] = - 1 ;
2012-06-24 10:44:24 +00:00
$tmp [ 'open' ] = $open ;
2012-07-01 18:04:01 +00:00
$this -> addChild ( new AchMenuNode ( $tmp , $this )); */
2012-05-27 19:08:28 +00:00
2012-05-31 13:15:36 +00:00
$res = $DBc -> sqlQuery ( " SELECT * FROM ach_category LEFT JOIN (ach_category_lang) ON (acl_lang=' " . $_USER -> getLang () . " ' AND acl_category=ac_id) WHERE ac_parent IS NULL ORDER by ac_order ASC, acl_name ASC " );
2012-05-27 19:08:28 +00:00
2012-05-25 09:48:56 +00:00
$sz = sizeof ( $res );
for ( $i = 0 ; $i < $sz ; $i ++ ) {
2012-06-21 20:45:27 +00:00
$res [ $i ][ 'open' ] = $open ;
2012-07-01 18:04:01 +00:00
$this -> addChild ( $this -> makeChild ( $res [ $i ]));
2012-05-25 09:48:56 +00:00
}
2012-07-08 16:11:25 +00:00
#echo var_export($this->nodes->findNode(1),true);
2012-05-25 09:48:56 +00:00
}
2012-05-27 19:08:28 +00:00
2012-06-24 10:44:24 +00:00
function getOpen () { // just returns the previously set ID of the currently open MenuNode
2012-05-27 19:08:28 +00:00
return $this -> open ;
}
2012-05-28 19:09:44 +00:00
2012-06-24 10:44:24 +00:00
function getOpenCat () { // finds the currently open MenuNode and returns it's ID. If not found the result will be 0 instead.
2012-07-08 16:11:25 +00:00
$iter = $this -> getIterator ();
while ( $iter -> hasNext ()) {
$curr = $iter -> getNext ();
$res = $curr -> hasOpenCat ();
2012-05-28 19:09:44 +00:00
if ( $res != 0 ) {
return $res ;
}
}
return 0 ;
}
2012-06-21 18:55:52 +00:00
2012-07-08 16:11:25 +00:00
#@override Parentum::makeChild()
2012-06-25 13:03:14 +00:00
protected function makeChild ( $a ) {
return new AchMenuNode ( $a , $this );
2012-06-21 18:55:52 +00:00
}
2012-05-25 09:48:56 +00:00
}
?>