/** * 根据app_id获取相关信息 */ public function config() { $app_id = intval($this->input['id']); if (!$app_id) { $this->errorOutput(NO_APP_ID); } //获取APP信息 $app_info = $this->api->detail('app_info', array('id' => $app_id, 'del' => 0)); if (!$app_info) { $this->errorOutput(APP_NOT_EXISTS); } //分享平台数据 if (isset($app_info['share_plant']) && $app_info['share_plant']) { $app_info['share_plant'] = @unserialize($app_info['share_plant']); } else { $app_info['share_plant'] = array(); } if ($app_info['icon'] && unserialize($app_info['icon'])) { $app_info['icon'] = unserialize($app_info['icon']); if (IS_REPLACE && REPLACE_IMG_DOMAIN) { $app_info['icon']['host'] = REPLACE_IMG_DOMAIN; } $app_icon = array('web' => $app_info['icon']); if ($this->settings['icon_size']) { $path = $app_info['icon']['host'] . $app_info['icon']['dir']; $file = $app_info['icon']['filepath'] . $app_info['icon']['filename']; if ($this->settings['icon_size']['android']) { foreach ($this->settings['icon_size']['android'] as $android) { $size = $android['width'] . 'x' . $android['height']; $url = $path . $size . '/' . $file; switch ($android['width']) { case '36': $key = 'drawable-ldpi'; break; case '48': $key = 'drawable-mdpi'; break; case '72': $key = 'drawable-hdpi'; break; case '96': $key = 'drawable-xhdpi'; break; case '144': $key = 'drawable-xxhdpi'; break; } if ($key) { $app_icon['android'][$key] = $url; } } } if ($this->settings['icon_size']['ios']) { foreach ($this->settings['icon_size']['ios'] as $ios) { $size = $ios['width'] . 'x' . $ios['height']; $url = $path . $size . '/' . $file; switch ($ios['width']) { case '57': $key = 'Icon'; break; case '114': $key = 'Icon@2x'; break; case '120': $key = 'Icon-60@2x'; break; } if ($key) { $app_icon['ios'][$key] = $url; } } } } if ($app_icon) { $app_info['icon'] = $app_icon; } } if ($app_info['startup_pic'] && unserialize($app_info['startup_pic'])) { $app_info['startup_pic'] = unserialize($app_info['startup_pic']); if (IS_REPLACE && REPLACE_IMG_DOMAIN) { $app_info['startup_pic']['host'] = REPLACE_IMG_DOMAIN; } $startup_pic = array('web' => $app_info['startup_pic']); if ($this->settings['startup_size']) { $path = $app_info['startup_pic']['host'] . $app_info['startup_pic']['dir']; $file = $app_info['startup_pic']['filepath'] . $app_info['startup_pic']['filename']; if ($this->settings['startup_size']['android']) { foreach ($this->settings['startup_size']['android'] as $android) { $size = $android['width'] . 'x' . $android['height']; $url = $path . $size . '/' . $file; $startup_pic['android'] = $url; } } if ($this->settings['startup_size']['ios']) { foreach ($this->settings['startup_size']['ios'] as $ios) { $size = $ios['width'] . 'x' . $ios['height']; $url = $path . $size . '/' . $file; switch ($size) { case '640x960': $key = 'Default@2x'; break; case '640x1136': $key = 'Default-568h@2x'; break; } if ($key) { $startup_pic['ios'][$key] = $url; } } } //iOS有上传图片则覆盖 if ($app_info['startup_pic2'] && unserialize($app_info['startup_pic2'])) { $startup_pic2 = unserialize($app_info['startup_pic2']); $path = $startup_pic2['host'] . $startup_pic2['dir']; $file = $startup_pic2['filepath'] . $startup_pic2['filename']; $startup_pic['ios']['Default-568h@2x'] = $path . '640x1136/' . $file; } if ($app_info['startup_pic3'] && unserialize($app_info['startup_pic3'])) { $startup_pic3 = unserialize($app_info['startup_pic3']); $path = $startup_pic3['host'] . $startup_pic3['dir']; $file = $startup_pic3['filepath'] . $startup_pic3['filename']; $startup_pic['ios']['Default@2x'] = $path . '640x960/' . $file; } } if ($startup_pic) { $app_info['startup_pic'] = $startup_pic; } } if ($app_info['is_show_guide']) { //获取APP引导图 $guideCondition = array('app_id' => $app_id, 'effect' => $app_info['guide_effect']); $guide_pic = $this->api->app_pic($guideCondition); if ($guide_pic) { $guide_pic_arr = array(); foreach ($guide_pic as $k => $guide) { if ($guide['type'] == 1) { $guide_type = 'fg'; } elseif ($guide['type'] == 2) { $guide_type = 'bg'; } if (IS_REPLACE && REPLACE_IMG_DOMAIN) { $guide['info']['host'] = REPLACE_IMG_DOMAIN; } $guide_pic_arr[$guide_type][$k]['web'] = $guide['info']; if ($this->settings['guide_size']) { $path = $guide['info']['host'] . $guide['info']['dir']; $file = $guide['info']['filepath'] . $guide['info']['filename']; if ($this->settings['guide_size']['android']) { foreach ($this->settings['guide_size']['android'] as $android) { if ($guide['type'] == 2 && $app_info['guide_effect'] == 'effect2') { $size = 'x800'; } else { $size = $android['width'] . 'x' . $android['height']; } $url = $path . $size . '/' . $file; $guide_pic_arr[$guide_type][$k]['android'] = $url; } } if ($this->settings['guide_size']['ios']) { foreach ($this->settings['guide_size']['ios'] as $ios) { if ($guide['type'] == 2 && $app_info['guide_effect'] == 'effect2') { $size = 'x1136'; } else { $size = $ios['width'] . 'x' . $ios['height']; } $url = $path . $size . '/' . $file; $guide_pic_arr[$guide_type][$k]['ios'] = $url; } } } } if (!$guide_pic_arr) { $guide_pic_arr = $guide_pic; } $app_info['guide_pic'] = $guide_pic_arr; } } if ($this->settings['data_url']) { $app_info['base_url'] = trim($this->settings['data_url']['path'], '/') . '/' . $app_info['user_id'] . '/'; } //天气接口 if (WEATHER_API) { $app_info['weather_api'] = WEATHER_API; } //统计接口 if (STATISTICS_API) { $app_info['statistics_api'] = STATISTICS_API; } //会员接口 if (MEMBER_API) { $app_info['member_api'] = MEMBER_API; } //互助接口 if (SEEKHELP_API) { $app_info['seekhelp_api'] = SEEKHELP_API; } //获取推送id和key include_once ROOT_PATH . 'lib/class/company.class.php'; $companyApi = new company(); $push_api = $companyApi->getPushApi($this->user['user_id']); if ($push_api) { $app_info['push_api'] = $push_api; $app_info['prov_id'] = $push_api['prov_id']; } //获取APP打包程序数据 $app_info['client'] = $this->api->get_version_info($app_id); //获取APP模板信息 $temp_info = $this->api->detail('app_template', array('id' => $app_info['temp_id'])); if ($temp_info) { if (unserialize($temp_info['pic'])) { $temp_info['pic'] = unserialize($temp_info['pic']); if (IS_REPLACE && REPLACE_IMG_DOMAIN) { $temp_info['pic']['host'] = REPLACE_IMG_DOMAIN; } } $app_info['template'] = $temp_info; //获取APP模板的属性 include_once CUR_CONF_PATH . 'lib/appTemplate.class.php'; $tempApi = new appTemplate(); $temp_attr = $tempApi->get_attribute($app_info['temp_id'], $app_id, true); if ($temp_attr) { $temp_attr = $temp_attr[$app_info['temp_id']]; foreach ($temp_attr as $k => $attr) { if ($attr['mark'] == 'homeBackground') { unset($temp_attr[$k]); continue; } if (is_string($attr['attr_value']) && strpos($attr['attr_value'], '|')) { $arr = explode('|', $attr['attr_value']); $arr_list = array(); foreach ($arr as $value) { $vv = explode(':', $value); $arr_list[$vv[0]] = $vv[1]; } $temp_attr[$k]['attr_value'] = $arr_list; } } $app_info['template']['attrs'] = $temp_attr; } } //获取APP模块信息 include_once CUR_CONF_PATH . 'lib/appModule.class.php'; $moduleApi = new appModule(); include_once CUR_CONF_PATH . 'lib/appInterface.class.php'; $ui_api = new appInterface(); $condition = array('app_id' => $app_id); if ($this->user['user_id']) { $condition['uid'] = $this->user['user_id']; } $module_info = $moduleApi->show(array('count' => -1, 'condition' => $condition)); if ($module_info) { $ui_id = array(); foreach ($module_info as $k => $module) { if ($module['pic'] && is_array($module['pic']) && $this->settings['module_size']) { if (IS_REPLACE && REPLACE_IMG_DOMAIN) { $module['pic']['host'] = REPLACE_IMG_DOMAIN; } $module_icon = array('web' => $module['pic']); if ($this->settings['module_size']) { $path = $module['pic']['host'] . $module['pic']['dir']; $file = $module['pic']['filepath'] . $module['pic']['filename']; if ($this->settings['module_size']['android']) { foreach ($this->settings['module_size']['android'] as $android) { $size = $android['width'] . 'x' . $android['height']; $url = $path . $size . '/' . $file; $module_icon['android'] = $url; } } if ($this->settings['module_size']['ios']) { foreach ($this->settings['module_size']['ios'] as $ios) { $size = $ios['width'] . 'x' . $ios['height']; $url = $path . $size . '/' . $file; $module_icon['ios'] = $url; } } } if ($module_icon) { $module_info[$k]['pic'] = $module_icon; } } if ($module['press_pic'] && is_array($module['press_pic']) && $this->settings['module_size']) { if (IS_REPLACE && REPLACE_IMG_DOMAIN) { $module['press_pic']['host'] = REPLACE_IMG_DOMAIN; } $module_icon = array('web' => $module['press_pic']); if ($this->settings['module_size']) { $path = $module['press_pic']['host'] . $module['press_pic']['dir']; $file = $module['press_pic']['filepath'] . $module['press_pic']['filename']; if ($this->settings['module_size']['android']) { foreach ($this->settings['module_size']['android'] as $android) { $size = $android['width'] . 'x' . $android['height']; $url = $path . $size . '/' . $file; $module_icon['android'] = $url; } } if ($this->settings['module_size']['ios']) { foreach ($this->settings['module_size']['ios'] as $ios) { $size = $ios['width'] . 'x' . $ios['height']; $url = $path . $size . '/' . $file; $module_icon['ios'] = $url; } } } if ($module_icon) { $module_info[$k]['press_pic'] = $module_icon; } } if ($module['ui_id']) { $ui_id[$module['ui_id']] = $module['ui_id']; } } if ($ui_id) { $ui_id = implode(',', $ui_id); $ui_info = $ui_api->show(array('count' => -1, 'condition' => array('id' => $ui_id))); if ($ui_info) { foreach ($module_info as $k => $v) { //获取界面对应的属性 $ui_attr = $ui_api->get_attribute($v['ui_id'], $v['id'], true); if ($ui_attr && $ui_attr[$v['ui_id']]) { $ui_info[$v['ui_id']]['attr'] = $ui_attr[$v['ui_id']]; } if ($ui_info[$v['ui_id']]) { $module_info[$k]['ui'] = $ui_info[$v['ui_id']]; } } } } $app_info['module'] = $module_info; } if ($this->input['flag']) { $app_cache = $this->api->detail('app_cache', array('app_id' => $app_id)); if (!$app_cache) { $insertData = array('app_id' => $app_id, 'data' => serialize($app_info)); $this->api->create('app_cache', $insertData); $app_info['unpack'] = 1; } else { if ($app_cache && unserialize($app_cache['data'])) { $app_cache_data = unserialize($app_cache['data']); //暂时去除验证设置是否改动 //if ($this->compare_data($app_info, $app_cache_data)) //{ // $app_info['unpack'] = 0; //} //else //{ $this->api->update('app_cache', array('data' => serialize($app_info)), array('app_id' => $app_id)); if ($app_info['client']) { /* $updateData = array( 'file_url' => '', 'download_url' => '', 'file_size' => 0, 'state' => 0, 'publish_time' => 0, 'push' => 0 ); foreach ($app_info['client'] as $k => $client) { $updateData['version_name'] = $client['version_name'] + 1; $updateData['version_code'] = $client['version_code'] + 1; $updateCondition = array( 'app_id' => $app_id, 'client_id' => $client['client_id'] ); if ($this->api->update('client_relation', $updateData, $updateCondition)) { $app_info['client'][$k]['version_name'] = $updateData['version_name']; $app_info['client'][$k]['version_code'] = $updateData['version_code']; } } */ } $app_info['unpack'] = 2; //} } else { $app_info['unpack'] = 0; } } } $this->addItem($app_info); $this->output(); }
/** * 根据app_id获取相关信息 */ public function config() { $app_id = intval($this->input['id']); if ($app_id <= 0) { $this->errorOutput(PARAM_WRONG); } //获取APP信息 $app_info = $this->api->detail('app_info', array('id' => $app_id, 'del' => 0)); if (!$app_info) { $this->errorOutput(NO_APPID); } if ($app_info['icon'] && unserialize($app_info['icon'])) { $app_info['icon'] = unserialize($app_info['icon']); if (IS_REPLACE && REPLACE_IMG_DOMAIN) { //XXX $app_info['icon']['host'] = REPLACE_IMG_DOMAIN; } $app_icon = array('web' => $app_info['icon']); if ($this->settings['icon_size']) { $path = $app_info['icon']['host'] . $app_info['icon']['dir']; $file = $app_info['icon']['filepath'] . $app_info['icon']['filename']; if ($this->settings['icon_size']['android']) { foreach ($this->settings['icon_size']['android'] as $android) { $size = $android['width'] . 'x' . $android['height']; $url = $path . $size . '/' . $file; switch ($android['width']) { case '36': $key = 'drawable-ldpi'; break; case '48': $key = 'drawable-mdpi'; break; case '72': $key = 'drawable-hdpi'; break; case '96': $key = 'drawable-xhdpi'; break; case '144': $key = 'drawable-xxhdpi'; break; } if ($key) { $app_icon['android'][$key] = $url; } } } if ($this->settings['icon_size']['ios']) { foreach ($this->settings['icon_size']['ios'] as $ios) { $size = $ios['width'] . 'x' . $ios['height']; $url = $path . $size . '/' . $file; switch ($ios['width']) { case '57': $key = 'Icon'; break; case '114': $key = 'Icon@2x'; break; case '120': $key = 'Icon-60@2x'; break; } if ($key) { $app_icon['ios'][$key] = $url; } } } } if ($app_icon) { $app_info['icon'] = $app_icon; } } if ($app_info['startup_pic'] && unserialize($app_info['startup_pic'])) { $app_info['startup_pic'] = unserialize($app_info['startup_pic']); if (IS_REPLACE && REPLACE_IMG_DOMAIN) { //XXX $app_info['startup_pic']['host'] = REPLACE_IMG_DOMAIN; } $startup_pic = array('web' => $app_info['startup_pic']); if ($this->settings['startup_size']) { $path = $app_info['startup_pic']['host'] . $app_info['startup_pic']['dir']; $file = $app_info['startup_pic']['filepath'] . $app_info['startup_pic']['filename']; if ($this->settings['startup_size']['android']) { foreach ($this->settings['startup_size']['android'] as $android) { $size = $android['width'] . 'x' . $android['height']; $url = $path . $size . '/' . $file; $startup_pic['android'] = $url; } } if ($this->settings['startup_size']['ios']) { foreach ($this->settings['startup_size']['ios'] as $ios) { $size = $ios['width'] . 'x' . $ios['height']; $url = $path . $size . '/' . $file; switch ($size) { case '320x480': $key = 'Default'; break; case '640x960': $key = 'Default@2x'; break; case '640x1136': $key = 'Default-568h@2x'; break; } if ($key) { $startup_pic['ios'][$key] = $url; } } } } if ($startup_pic) { $app_info['startup_pic'] = $startup_pic; } } if (!USE_EFFECT) { unset($app_info['transition_effects']); } //获取APP引导图 $guide_pic = $this->api->app_pic(array('app_id' => $app_id)); if ($guide_pic) { $guide_pic_arr = array(); foreach ($guide_pic as $k => $guide) { if (IS_REPLACE && REPLACE_IMG_DOMAIN) { //XXX $guide['info']['host'] = REPLACE_IMG_DOMAIN; } $guide_pic_arr[$k]['web'] = $guide['info']; if ($this->settings['guide_size']) { $path = $guide['info']['host'] . $guide['info']['dir']; $file = $guide['info']['filepath'] . $guide['info']['filename']; if ($this->settings['guide_size']['android']) { foreach ($this->settings['guide_size']['android'] as $android) { $size = $android['width'] . 'x' . $android['height']; $url = $path . $size . '/' . $file; $guide_pic_arr[$k]['android'][] = $url; } } if ($this->settings['guide_size']['ios']) { foreach ($this->settings['guide_size']['ios'] as $ios) { $size = $ios['width'] . 'x' . $ios['height']; $url = $path . $size . '/' . $file; switch ($size) { case '640x1136': $key = 'guide'; break; case '640x960': $key = 'guide_960'; break; } if ($key) { $guide_pic_arr[$k]['ios'][$key] = $url; } } } } } if (!$guide_pic_arr) { $guide_pic_arr = $guide_pic; } $app_info['guide_pic'] = $guide_pic_arr; } if ($this->settings['data_url']) { $app_info['base_url'] = trim($this->settings['data_url']['path'], '/') . '/' . $app_info['user_id'] . '/'; } if (WEATHER_API) { $app_info['weather_api'] = WEATHER_API; } //获取APP打包程序数据 $app_info['client'] = $this->api->get_client($app_id, false, true); //获取APP模板信息 $temp_info = $this->api->detail('app_template', array('id' => $app_info['temp_id'])); if ($temp_info) { if (unserialize($temp_info['pic'])) { $temp_info['pic'] = unserialize($temp_info['pic']); if (IS_REPLACE && REPLACE_IMG_DOMAIN) { //XXX $temp_info['pic']['host'] = REPLACE_IMG_DOMAIN; } } $app_info['template'] = $temp_info; //获取APP模板的属性 include_once CUR_CONF_PATH . 'lib/appTemplate.class.php'; $tempApi = new appTemplate(); $temp_attr = $tempApi->get_attribute($app_info['temp_id'], $app_id, true); if ($temp_attr) { $temp_attr = $temp_attr[$app_info['temp_id']]; foreach ($temp_attr as $k => $attr) { if ($attr['mark'] == 'homeBackground') { unset($temp_attr[$k]); continue; } if (is_string($attr['attr_value']) && strpos($attr['attr_value'], '|')) { $arr = explode('|', $attr['attr_value']); $arr_list = array(); foreach ($arr as $value) { $vv = explode(':', $value); $arr_list[$vv[0]] = $vv[1]; } $temp_attr[$k]['attr_value'] = $arr_list; } } $app_info['template']['attrs'] = $temp_attr; } } //获取APP模块信息 include_once CUR_CONF_PATH . 'lib/appModule.class.php'; $moduleApi = new appModule(); include_once CUR_CONF_PATH . 'lib/appInterface.class.php'; $ui_api = new appInterface(); $condition = array('app_id' => $app_id); if ($this->user['user_id']) { $condition['uid'] = $this->user['user_id']; } $module_info = $moduleApi->show(array('count' => -1, 'condition' => $condition)); if ($module_info) { $ui_id = array(); foreach ($module_info as $k => $module) { if ($module['pic'] && is_array($module['pic']) && $this->settings['module_size']) { if (IS_REPLACE && REPLACE_IMG_DOMAIN) { //XXX $module['pic']['host'] = REPLACE_IMG_DOMAIN; } $module_icon = array('web' => $module['pic']); if ($this->settings['module_size']) { $path = $module['pic']['host'] . $module['pic']['dir']; $file = $module['pic']['filepath'] . $module['pic']['filename']; if ($this->settings['module_size']['android']) { foreach ($this->settings['module_size']['android'] as $android) { $size = $android['width'] . 'x' . $android['height']; $url = $path . $size . '/' . $file; $module_icon['android'] = $url; } } if ($this->settings['module_size']['ios']) { foreach ($this->settings['module_size']['ios'] as $ios) { $size = $ios['width'] . 'x' . $ios['height']; $url = $path . $size . '/' . $file; $module_icon['ios'] = $url; } } } if ($module_icon) { $module_info[$k]['pic'] = $module_icon; } } if ($this->settings['data_url']) { $data_url = trim($this->settings['data_url']['path'], '/') . '/' . $app_info['user_id'] . '/'; if ($module['type'] == 'vote') { $data_url .= trim($this->settings['data_url']['file']['vote']['url'], '/'); } else { $data_url .= trim($this->settings['data_url']['file']['content']['url'], '/'); if ($module['type']) { $type = implode(',', $module['type']); $data_url .= '&app=' . $type; } } $module_info[$k]['url'] = $data_url; } if ($module['ui_id']) { $ui_id[$module['ui_id']] = $module['ui_id']; } } if ($ui_id) { $ui_id = implode(',', $ui_id); $ui_info = $ui_api->show(array('count' => -1, 'condition' => array('id' => $ui_id))); if ($ui_info) { foreach ($module_info as $k => $v) { //获取界面对应的属性 $ui_attr = $ui_api->get_attribute($v['ui_id'], $v['id'], true); if ($ui_attr) { $ui_info[$v['ui_id']]['attr'] = $ui_attr[$v['ui_id']]; } $module_info[$k]['ui'] = $ui_info[$v['ui_id']]; } } } $app_info['module'] = $module_info; } if ($this->input['flag']) { $app_cache = $this->api->detail('app_cache', array('app_id' => $app_id)); if (!$app_cache) { $insertData = array('app_id' => $app_id, 'data' => serialize($app_info)); $this->api->create('app_cache', $insertData); $app_info['unpack'] = 1; } else { if ($app_cache && unserialize($app_cache['data'])) { $app_cache_data = unserialize($app_cache['data']); if ($this->compare_data($app_info, $app_cache_data)) { $app_info['unpack'] = 0; } else { $this->api->update('app_cache', array('data' => serialize($app_info)), array('app_id' => $app_id)); if ($app_info['client']) { $updateData = array('file_url' => '', 'download_url' => '', 'file_size' => 0, 'state' => 0, 'publish_time' => 0); foreach ($app_info['client'] as $k => $client) { if ($client['state'] > 0) { $updateData['version_name'] = $client['version_name'] + 1; $updateData['version_code'] = $client['version_code'] + 1; } $updateCondition = array('app_id' => $app_id, 'client_id' => $client['client_id']); if ($this->api->update('client_relation', $updateData, $updateCondition)) { if ($client['state'] > 0) { $app_info['client'][$k]['version_name'] = $updateData['version_name']; $app_info['client'][$k]['version_code'] = $updateData['version_code']; } } } } $app_info['unpack'] = 2; } } else { $app_info['unpack'] = 0; } } } $this->addItem($app_info); $this->output(); }