theme_share.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /**
  3. * Theme Share
  4. *
  5. *
  6. *********************************/
  7. defined('InShopNC') or exit('Access Invalid!');
  8. class theme_shareControl extends BaseCircleControl{
  9. protected $c_id = 0; // 圈子id
  10. protected $identity = 0; // 身份 0游客 1圈主 2管理 3成员 4申请中 5申请失败
  11. protected $circle_info = array();
  12. public function __construct(){
  13. parent::__construct();
  14. $this->c_id = intval($_GET['c_id']);
  15. if($this->c_id <= 0){
  16. echo '<script>CUR_DIALOG.close();</script>';
  17. }
  18. Tpl::output('c_id', $this->c_id);
  19. Language::read('theme_share');
  20. }
  21. /**
  22. * Share the binding
  23. */
  24. public function indexOp(){
  25. $t_id = $_GET['t_id'];
  26. if($t_id <= 0){
  27. echo '<script>CUR_DIALOG.close();</script>';
  28. }
  29. Tpl::output('t_id', $t_id);
  30. $affix_list = array();
  31. $theme_info = Model()->table('circle_theme')->find($t_id);
  32. if(!empty($theme_info)){
  33. $affix_list = Model()->table('circle_affix')->where(array('affix_type'=>1, 'circle_id'=>$this->c_id, 'theme_id'=>$t_id))->limit(1)->select();
  34. Tpl::output('theme_info', $theme_info);
  35. Tpl::output('affix_list', $affix_list);
  36. }else{
  37. echo '<script>CUR_DIALOG.close();</script>';
  38. }
  39. if(chksubmit()){
  40. $obj_validate = new Validator();
  41. $validate_arr[] = array("input"=>$_POST["content"], "validator"=>'Length',"min"=>0,"max"=>140,"message"=>Language::get('sharebind_content_not_null'));
  42. $obj_validate -> validateparam = $validate_arr;
  43. $error = $obj_validate->validate();
  44. if ($error != ''){
  45. showDialog($error,'','error');
  46. }
  47. $insert_arr = array();
  48. $insert_arr['trace_originalid'] = '0';
  49. $insert_arr['trace_originalmemberid'] = '0';
  50. $insert_arr['trace_memberid'] = $_SESSION['member_id'];
  51. $insert_arr['trace_membername'] = $_SESSION['member_name'];
  52. $insert_arr['trace_memberavatar'] = 'avatar_'.$_SESSION['member_id'].'.jpg';
  53. $insert_arr['trace_title'] = $_POST['content'];
  54. $insert_arr['trace_content'] = $this->traceContent($theme_info, $affix_list);
  55. $insert_arr['trace_addtime'] = time();
  56. $insert_arr['trace_from'] = 5;
  57. $result = Model('sns_tracelog')->tracelogAdd($insert_arr);
  58. if ($result){
  59. // Off-site sharing
  60. if (C('share_isuse') == 1){
  61. $model = Model('sns_binding');
  62. // binding information
  63. $bind_list = $model->getUsableApp($_SESSION['member_id']);
  64. // Content Sharing
  65. $params = array();
  66. $params['title'] = L('sharebind_share_theme');
  67. $params['url'] = CIRCLE_SITE_URL."/index.php?act=theme&op=theme_detail&c_id=".$this->c_id."&t_id=".$theme_info['theme_id'];
  68. $params['comment'] = $theme_info['theme_name'].$_POST['comment'];
  69. if(!empty($affix_list[0])){
  70. $params['images'] = themeImageUrl($affix_list[0]['affix_filethumb']);
  71. }
  72. // Share Tencent Weibo
  73. if (isset($_POST['checkapp_qqweibo']) && !empty($_POST['checkapp_qqweibo']) && $bind_list['qqweibo']['isbind'] == true){
  74. $model->addQQWeiboPic($bind_list['qqweibo'],$params);
  75. }
  76. // Share Sina Weibo
  77. if (isset($_POST['checkapp_sinaweibo']) && !empty($_POST['checkapp_sinaweibo']) && $bind_list['sinaweibo']['isbind'] == true){
  78. $model->addSinaWeiboUpload($bind_list['sinaweibo'],$params);
  79. }
  80. }
  81. Model()->table('circle_theme')->update(array('theme_id'=>$t_id, 'theme_sharecount'=>array('exp', 'theme_sharecount+1')));
  82. showDialog(Language::get('sharebind_share_succ'),'','succ','DialogManager.close("share");var count = $(\'em[nctype="share"]\').html(); $(\'em[nctype="share"]\').html(parseInt(count)+1);');
  83. }else {
  84. showDialog(Language::get('sharebind_share_fail'),'','error','DialogManager.close("share");');
  85. }
  86. }
  87. if (C('share_isuse') == 1){
  88. // Other web sites share interface
  89. $model = Model('sns_binding');
  90. $app_arr = $model->getUsableApp($_SESSION['member_id']);
  91. Tpl::output('app_arr',$app_arr);
  92. }
  93. Tpl::showpage('theme.share','null_layout');
  94. }
  95. /**
  96. * trace content
  97. */
  98. private function traceContent($theme_info, $affix_list){
  99. $content = "<div class='fd-media'>";
  100. $url = CIRCLE_SITE_URL."/index.php?act=theme&op=theme_detail&c_id=".$this->c_id."&t_id=".$theme_info['theme_id'];
  101. if(!empty($affix_list[0])){
  102. $content .= "<div class='goodsimg'><a target='_blank' href='".$url."'><img src='".themeImageUrl($affix_list[0]['affix_filethumb'])."' onload='javascript:DrawImage(this,120,120);'></a></div>";
  103. }
  104. $content .= "<div class=\"goodsinfo\"><p>".$_SESSION['member_name'].L('circle_at,nc_quote1').$theme_info['circle_name'].L('nc_quote2').L('circle_share,sharebind_theme').L('nc_colon').'</p><p>'.L('nc_quote1').$theme_info['theme_name'].L('nc_quote2')."&nbsp;&nbsp;<a href='".$url."'>".L('sharebind_go_and_see')."</a></p></div></div>";
  105. return $content;
  106. }
  107. }