mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-04 17:24:47 +00:00
7d140cb037
--HG-- branch : gsoc2012-achievements
120 lines
No EOL
2.6 KiB
PHP
120 lines
No EOL
2.6 KiB
PHP
<?php
|
|
class AchMenu extends RenderNodeIterator {
|
|
var $open;
|
|
|
|
function AchMenu($open = false) {
|
|
global $DBc,$_USER;
|
|
|
|
$this->open = $open;
|
|
|
|
$tmp = array();
|
|
$tmp['ac_id'] = 0;
|
|
$tmp['ac_parent'] = null;
|
|
$tmp['acl_name'] = get_translation('ach_summary',$_USER->getLang());
|
|
$tmp['ac_image'] = "test.png";
|
|
$tmp['ac_order'] = -1;
|
|
$this->nodes[] = new AchMenuNode($tmp,$open);
|
|
|
|
$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");
|
|
|
|
$sz = sizeof($res);
|
|
for($i=0;$i<$sz;$i++) {
|
|
$res[$i]['open'] = $open;
|
|
$this->nodes[] = $this->makeChild($res[$i]);
|
|
}
|
|
}
|
|
|
|
function getOpen() {
|
|
return $this->open;
|
|
}
|
|
|
|
function getOpenCat() {
|
|
foreach($this->nodes as $elem) {
|
|
$res = $elem->hasOpenCat();
|
|
if($res != 0) {
|
|
return $res;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
function makeChild(&$a) {
|
|
return new AchMenuNode($a);
|
|
}
|
|
}
|
|
|
|
class AchMenuNode extends RenderNodeIterator {
|
|
private $id;
|
|
private $parent;
|
|
private $name;
|
|
private $open;
|
|
private $image;
|
|
private $order;
|
|
|
|
function AchMenuNode(&$data) {
|
|
global $DBc,$_USER;
|
|
|
|
$this->id = $data['ac_id'];
|
|
$this->parent = $data['ac_parent'];
|
|
$this->name = $data['acl_name'];
|
|
$this->image = $data['ac_image'];
|
|
$this->order = $data['ac_order'];
|
|
$this->open = ($this->id == $data['open']);
|
|
$this->dev = $data['ac_dev'];
|
|
|
|
$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='".$this->id."' ORDER by ac_order ASC, acl_name ASC");
|
|
|
|
$sz = sizeof($res);
|
|
for($i=0;$i<$sz;$i++) {
|
|
$res[$i]['open'] = $open;
|
|
$this->nodes[] = $this->makeChild($res[$i]);
|
|
}
|
|
}
|
|
|
|
function makeChild(&$a) {
|
|
return new AchMenuNode($a);
|
|
}
|
|
|
|
function getID() {
|
|
return $this->id;
|
|
}
|
|
|
|
function getName() {
|
|
return $this->name;
|
|
}
|
|
|
|
function getParent() {
|
|
return $this->parent;
|
|
}
|
|
|
|
function hasOpenCat() {
|
|
if($this->open) {
|
|
return $this->id;
|
|
}
|
|
|
|
foreach($this->nodes as $elem) {
|
|
$res = $elem->hasOpenCat();
|
|
if($res != 0) {
|
|
return $res;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
function isOpen() {
|
|
return $this->open;
|
|
}
|
|
|
|
function getImage() {
|
|
return $this->image;
|
|
}
|
|
|
|
function getOrder() {
|
|
return $this->order;
|
|
}
|
|
|
|
function inDev() {
|
|
return ($this->dev == 1);
|
|
}
|
|
}
|
|
?>
|