| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- <?php
- include_once(__DIR__."/../../utils/Utils.class.php");
- include_once(__DIR__."/../../utils/error.inc.php");
- class Menu {
- public $button = null; // xxxMenu array, 即各种子菜单array
- public function __construct($xxmenuArray=null)
- {
- $this->button = $xxmenuArray;
- }
- public static function CheckMenuCreateArgs($menu) {
- }
- public static function Array2Menu($arr)
- {
- $menu = new Menu();
- foreach($arr["button"] as $item) {
- $subButton = null;
- if ( ! array_key_exists("type", $item)) {
- $subButton = SubMenu::Array2Menu($item);
- } else {
- $type = $item["type"];
- if ($type == "click") $subButton = ClickMenu::Array2Menu($item);
- if ($type == "view") $subButton = viewMenu::Array2Menu($item);
- if ($type == "scancode_push") $subButton = ScanCodePushMenu::Array2Menu($item);
- if ($type == "scancode_waitmsg") $subButton = ScanCodeWaitMsgMenu::Array2Menu($item);
- if ($type == "pic_sysphoto") $subButton = PicSysPhotoMenu::Array2Menu($item);
- if ($type == "pic_photo_or_album") $subButton = PicPhotoOrAlbumMenu::Array2Menu($item);
- if ($type == "pic_weixin") $subButton = PicWeixinMenu::Array2Menu($item);
- if ($type == "location_select") $subButton = LocationSelectMenu::Array2Menu($item);
- }
- $menu->button[] = $subButton;
- }
- return $menu;
- }
- } // class
- // ------------------------ 各种类型子菜单 ------------------------------------
- class SubMenu {
- public $name = null; // string
- public $sub_button = null; // xxxMenu array
- public function __construct($name=null, $xxmenuArray=null)
- {
- $this->name = $name;
- $this->sub_button = $xxmenuArray;
- }
- public static function Array2Menu($arr)
- {
- $menu = new SubMenu();
- $menu->name = Utils::arrayGet($arr, "name");
- foreach($arr["sub_button"] as $item) {
- $subButton = null;
- if ( ! array_key_exists("type", $item)) {
- $subButton = SubMenu::Array2Menu($item);
- } else {
- $type = $item["type"];
- if ($type == "click") $subButton = ClickMenu::Array2Menu($item);
- if ($type == "view") $subButton = viewMenu::Array2Menu($item);
- if ($type == "scancode_push") $subButton = ScanCodePushMenu::Array2Menu($item);
- if ($type == "scancode_waitmsg") $subButton = ScanCodeWaitMsgMenu::Array2Menu($item);
- if ($type == "pic_sysphoto") $subButton = PicSysPhotoMenu::Array2Menu($item);
- if ($type == "pic_photo_or_album") $subButton = PicPhotoOrAlbumMenu::Array2Menu($item);
- if ($type == "pic_weixin") $subButton = PicWeixinMenu::Array2Menu($item);
- if ($type == "location_select") $subButton = LocationSelectMenu::Array2Menu($item);
- }
- $menu->sub_button[] = $subButton;
- }
- return $menu;
- }
- }
- class ClickMenu {
- public $type = "click";
- public $name = null; // string
- public $key = null; // string
- public function __construct($name=null, $key=null, $xxmenuArray=null)
- {
- $this->name = $name;
- $this->key = $key;
- }
- public static function Array2Menu($arr)
- {
- $menu = new ClickMenu();
- $menu->type = Utils::arrayGet($arr, "type");
- $menu->name = Utils::arrayGet($arr, "name");
- $menu->key = Utils::arrayGet($arr, "key");
- return $menu;
- }
- }
- class viewMenu {
- public $type = "view";
- public $name = null; // string
- public $url = null; // string
- public function __construct($name=null, $url= null)
- {
- $this->name = $name;
- $this->url = $url;
- }
- public static function Array2Menu($arr)
- {
- $menu = new viewMenu();
- $menu->type = "view";
- $menu->name = Utils::arrayGet($arr, "name");
- $menu->url = Utils::arrayGet($arr, "url");
- return $menu;
- }
- }
- class ScanCodePushMenu {
- public $type = "scancode_push";
- public $name = null; // string
- public $key = null; // string
- public $sub_button = null; // xxxMenu array
- public function __construct($name=null, $key=null, $xxmenuArray=null)
- {
- $this->name = $name;
- $this->key = $key;
- $this->sub_button = $xxmenuArray;
- }
- public static function Array2Menu($arr)
- {
- $menu = new ScanCodePushMenu();
- $menu->type = Utils::arrayGet($arr, "type");
- $menu->name = Utils::arrayGet($arr, "name");
- $menu->key = Utils::arrayGet($arr, "key");
- foreach($arr["sub_button"] as $item) {
- $subButton = null;
- if ( ! array_key_exists("type", $item)) {
- $subButton = SubMenu::Array2Menu($item);
- } else {
- $type = $item["type"];
- if ($type == "click") $subButton = ClickMenu::Array2Menu($item);
- if ($type == "view") $subButton = viewMenu::Array2Menu($item);
- if ($type == "scancode_push") $subButton = ScanCodePushMenu::Array2Menu($item);
- if ($type == "scancode_waitmsg") $subButton = ScanCodeWaitMsgMenu::Array2Menu($item);
- if ($type == "pic_sysphoto") $subButton = PicSysPhotoMenu::Array2Menu($item);
- if ($type == "pic_photo_or_album") $subButton = PicPhotoOrAlbumMenu::Array2Menu($item);
- if ($type == "pic_weixin") $subButton = PicWeixinMenu::Array2Menu($item);
- if ($type == "location_select") $subButton = LocationSelectMenu::Array2Menu($item);
- }
- $menu->sub_button[] = $subButton;
- }
- return $menu;
- }
- }
- class ScanCodeWaitMsgMenu {
- public $type = "scancode_waitmsg";
- public $name = null; // string
- public $key = null; // string
- public $sub_button = null; // xxxMenu array
- public function __construct($name=null, $key=null, $xxmenuArray=null)
- {
- $this->name = $name;
- $this->key = $key;
- $this->sub_button = $xxmenuArray;
- }
- public static function Array2Menu($arr)
- {
- $menu = new ScanCodeWaitMsgMenu();
- $menu->type = Utils::arrayGet($arr, "type");
- $menu->name = Utils::arrayGet($arr, "name");
- $menu->key = Utils::arrayGet($arr, "key");
- foreach($arr["sub_button"] as $item) {
- $subButton = null;
- if ( ! array_key_exists("type", $item)) {
- $subButton = SubMenu::Array2Menu($item);
- } else {
- $type = $item["type"];
- if ($type == "click") $subButton = ClickMenu::Array2Menu($item);
- if ($type == "view") $subButton = viewMenu::Array2Menu($item);
- if ($type == "scancode_push") $subButton = ScanCodePushMenu::Array2Menu($item);
- if ($type == "scancode_waitmsg") $subButton = ScanCodeWaitMsgMenu::Array2Menu($item);
- if ($type == "pic_sysphoto") $subButton = PicSysPhotoMenu::Array2Menu($item);
- if ($type == "pic_photo_or_album") $subButton = PicPhotoOrAlbumMenu::Array2Menu($item);
- if ($type == "pic_weixin") $subButton = PicWeixinMenu::Array2Menu($item);
- if ($type == "location_select") $subButton = LocationSelectMenu::Array2Menu($item);
- }
- $menu->sub_button[] = $subButton;
- }
- return $menu;
- }
- }
- class PicSysPhotoMenu {
- public $type = "pic_sysphoto";
- public $name = null; // string
- public $key = null; // string
- public $sub_button = null; // xxxMenu array
- public function __construct($name=null, $key=null, $xxmenuArray=null)
- {
- $this->name = $name;
- $this->key = $key;
- $this->sub_button = $xxmenuArray;
- }
- public static function Array2Menu($arr)
- {
- $menu = new PicSysPhotoMenu();
- $menu->type = Utils::arrayGet($arr, "type");
- $menu->name = Utils::arrayGet($arr, "name");
- $menu->key = Utils::arrayGet($arr, "key");
- foreach($arr["sub_button"] as $item) {
- $subButton = null;
- if ( ! array_key_exists("type", $item)) {
- $subButton = SubMenu::Array2Menu($item);
- } else {
- $type = $item["type"];
- if ($type == "click") $subButton = ClickMenu::Array2Menu($item);
- if ($type == "view") $subButton = viewMenu::Array2Menu($item);
- if ($type == "scancode_push") $subButton = ScanCodePushMenu::Array2Menu($item);
- if ($type == "scancode_waitmsg") $subButton = ScanCodeWaitMsgMenu::Array2Menu($item);
- if ($type == "pic_sysphoto") $subButton = PicSysPhotoMenu::Array2Menu($item);
- if ($type == "pic_photo_or_album") $subButton = PicPhotoOrAlbumMenu::Array2Menu($item);
- if ($type == "pic_weixin") $subButton = PicWeixinMenu::Array2Menu($item);
- if ($type == "location_select") $subButton = LocationSelectMenu::Array2Menu($item);
- }
- $menu->sub_button[] = $subButton;
- }
- return $menu;
- }
- }
- class PicPhotoOrAlbumMenu {
- public $type = "pic_photo_or_album";
- public $name = null; // string
- public $key = null; // string
- public $sub_button = null; // xxxMenu array
- public function __construct($name=null, $key=null, $xxmenuArray=null)
- {
- $this->name = $name;
- $this->key = $key;
- $this->sub_button = $xxmenuArray;
- }
- public static function Array2Menu($arr)
- {
- $menu = new PicPhotoOrAlbumMenu();
- $menu->type = Utils::arrayGet($arr, "type");
- $menu->name = Utils::arrayGet($arr, "name");
- $menu->key = Utils::arrayGet($arr, "key");
- foreach($arr["sub_button"] as $item) {
- $subButton = null;
- if ( ! array_key_exists("type", $item)) {
- $subButton = SubMenu::Array2Menu($item);
- } else {
- $type = $item["type"];
- if ($type == "click") $subButton = ClickMenu::Array2Menu($item);
- if ($type == "view") $subButton = viewMenu::Array2Menu($item);
- if ($type == "scancode_push") $subButton = ScanCodePushMenu::Array2Menu($item);
- if ($type == "scancode_waitmsg") $subButton = ScanCodeWaitMsgMenu::Array2Menu($item);
- if ($type == "pic_sysphoto") $subButton = PicSysPhotoMenu::Array2Menu($item);
- if ($type == "pic_photo_or_album") $subButton = PicPhotoOrAlbumMenu::Array2Menu($item);
- if ($type == "pic_weixin") $subButton = PicWeixinMenu::Array2Menu($item);
- if ($type == "location_select") $subButton = LocationSelectMenu::Array2Menu($item);
- }
- $menu->sub_button[] = $subButton;
- }
- return $menu;
- }
- }
- class PicWeixinMenu {
- public $type = "pic_weixin";
- public $name = null; // string
- public $key = null; // string
- public $sub_button = null; // xxxMenu array
- public function __construct($name=null, $key=null, $xxmenuArray=null)
- {
- $this->name = $name;
- $this->key = $key;
- $this->sub_button = $xxmenuArray;
- }
- public static function Array2Menu($arr)
- {
- $menu = new PicWeixinMenu();
- $menu->type = Utils::arrayGet($arr, "type");
- $menu->name = Utils::arrayGet($arr, "name");
- $menu->key = Utils::arrayGet($arr, "key");
- foreach($arr["sub_button"] as $item) {
- $subButton = null;
- if ( ! array_key_exists("type", $item)) {
- $subButton = SubMenu::Array2Menu($item);
- } else {
- $type = $item["type"];
- if ($type == "click") $subButton = ClickMenu::Array2Menu($item);
- if ($type == "view") $subButton = viewMenu::Array2Menu($item);
- if ($type == "scancode_push") $subButton = ScanCodePushMenu::Array2Menu($item);
- if ($type == "scancode_waitmsg") $subButton = ScanCodeWaitMsgMenu::Array2Menu($item);
- if ($type == "pic_sysphoto") $subButton = PicSysPhotoMenu::Array2Menu($item);
- if ($type == "pic_photo_or_album") $subButton = PicPhotoOrAlbumMenu::Array2Menu($item);
- if ($type == "pic_weixin") $subButton = PicWeixinMenu::Array2Menu($item);
- if ($type == "location_select") $subButton = LocationSelectMenu::Array2Menu($item);
- }
- $menu->sub_button[] = $subButton;
- }
- return $menu;
- }
- }
- class LocationSelectMenu {
- public $type = "location_select";
- public $name = null; // string
- public $key = null; // string
- public function __construct($name=null, $key=null, $xxmenuArray=null)
- {
- $this->name = $name;
- $this->key = $key;
- }
- public static function Array2Menu($arr)
- {
- $menu = new LocationSelectMenu();
- $menu->type = Utils::arrayGet($arr, "type");
- $menu->name = Utils::arrayGet($arr, "name");
- $menu->key = Utils::arrayGet($arr, "key");
- return $menu;
- }
- }
|