8 private $categoryCodes = array();
9 private $categoryNames = array();
10 private $sections = array();
11 private $items = array();
14 public function addItem($categoryCode =
"", $item = array())
16 $this->createCategory($categoryCode);
17 $this->items[$categoryCode][] = $item;
19 public function addItems($categoryCode =
"", $items = array())
21 $this->createCategory($categoryCode);
22 foreach ($items as $item)
24 $this->items[$categoryCode][] = $item;
28 public function addSection($categoryCode =
"", $sectionCode, $sectionName)
30 $this->createCategory($categoryCode);
32 $this->sections[$categoryCode][] = array(
41 $this->categoryNames[$categoryCode] = $name;
44 private function createCategory($categoryCode)
46 if(!array_key_exists($categoryCode,$this->categoryCodes))
48 $this->categoryCodes[$categoryCode] = array();
49 $this->sections[$categoryCode] = array();
50 $this->categoryNames[$categoryCode] =
"";
56 public function showJSON()
64 "data" => $this->items,
65 "sections" => $this->sections,
66 "names" => $this->categoryNames,
69 if(SITE_CHARSET !=
"UTF8")
71 $listData = Encoding::convertEncodingArray($listData, SITE_CHARSET,
"UTF8");
73 header(
"Content-Type: application/x-javascript");
74 echo json_encode($listData);