Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/mobileapp/lib/data/ |
Upload File : |
<?php namespace Bitrix\MobileApp\Data; use Bitrix\Main\Text\Encoding; class Lists { private $categoryCodes = array(); private $categoryNames = array(); private $sections = array(); private $items = array(); public function addItem($categoryCode = "", $item = array()) { $this->createCategory($categoryCode); $this->items[$categoryCode][] = $item; } public function addItems($categoryCode = "", $items = array()) { $this->createCategory($categoryCode); foreach ($items as $item) { $this->items[$categoryCode][] = $item; } } public function addSection($categoryCode = "", $sectionCode, $sectionName) { $this->createCategory($categoryCode); $this->sections[$categoryCode][] = array( "ID"=> $sectionCode, "NAME"=>$sectionName ); } public function setCategoryName($categoryCode = "", $name = "") { $this->categoryNames[$categoryCode] = $name; } private function createCategory($categoryCode) { if(!array_key_exists($categoryCode,$this->categoryCodes)) { $this->categoryCodes[$categoryCode] = array(); $this->sections[$categoryCode] = array(); $this->categoryNames[$categoryCode] = ""; } } public function showJSON() { $listData = array( "data" => $this->items, "sections" => $this->sections, "names" => $this->categoryNames, ); header("Content-Type: application/x-javascript"); echo json_encode($listData); } }