Mobile.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: Mobile.php 34063 2013-09-26 05:37:52Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. Cloud::loadFile('Service_Server_Restful');
  12. class Cloud_Service_Server_Mobile extends Cloud_Service_Server_Restful {
  13. protected static $_instance;
  14. public static function getInstance() {
  15. if (!(self::$_instance instanceof self)) {
  16. self::$_instance = new self();
  17. }
  18. return self::$_instance;
  19. }
  20. public function onMobileLoginToken($deviceToken, $uid) {
  21. return C::t("#mobile#common_devicetoken")->loginToken($deviceToken, $uid);
  22. }
  23. public function onMobileLogoutToken($deviceToken, $uid) {
  24. return C::t("#mobile#common_devicetoken")->logoutToken($deviceToken);
  25. }
  26. public function onMobileClearToken($deviceToken) {
  27. return C::t("#mobile#common_devicetoken")->clearToken($deviceToken);
  28. }
  29. public function onMobileModule() {
  30. global $_G;
  31. if(!$_G['setting']['plugins']['available']) {
  32. return '';
  33. }
  34. require_once libfile('function/admincp');
  35. loadcache('pluginlanguage_script', 1);
  36. $return = array();
  37. foreach($_G['setting']['plugins']['available'] as $pluginid) {
  38. $row = array();
  39. $modulefile = DISCUZ_ROOT.'./source/plugin/'.$pluginid.'/discuz_mobile_'.$pluginid.'.xml';
  40. if(file_exists($modulefile)) {
  41. $_GET['importtxt'] = @implode('', file($modulefile));
  42. $pluginarray = getimportdata('Discuz! Mobile', 0, 1);
  43. if($pluginarray) {
  44. foreach($pluginarray as $name => $value) {
  45. $row[] = array(
  46. 'name' => isset($_G['cache']['pluginlanguage_script'][$pluginid][$name]) ? $_G['cache']['pluginlanguage_script'][$pluginid][$name] : $name,
  47. 'logo' => $value['logo'],
  48. 'url' => preg_match('/^http:\/\//', $value['url']) ? $value['url'] : $_G['siteurl'].$value['url'],
  49. );
  50. }
  51. }
  52. }
  53. $return[$pluginid] = $row;
  54. }
  55. return $return;
  56. }
  57. }