myapp.class.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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: myapp.class.php 29265 2012-03-31 06:03:26Z yexinhao $
  7. */
  8. class plugin_myapp{
  9. function plugin_myapp() {
  10. global $_G;
  11. $this->title = $_G['cache']['plugin']['myapp']['showtitle'];
  12. $this->num = intval($_G['cache']['plugin']['myapp']['shownum']);
  13. $this->myapp = intval($_G['cache']['plugin']['myapp']['showmyapp']);
  14. }
  15. }
  16. class plugin_myapp_forum extends plugin_myapp {
  17. function viewthread_sidebottom_output() {
  18. global $_G, $postlist;
  19. if(IS_ROBOT) {
  20. return array();
  21. }
  22. if(!$_G['forum_firstpid']) {
  23. return array();
  24. }
  25. loadcache('myapp');
  26. $thisApp = '';
  27. $poster = reset($postlist);
  28. $userapp = C::t('home_userapp_plying')->fetch($poster['authorid']);
  29. if(!empty($userapp['appid'])) {
  30. $applist = explode(',', $userapp['appid']);
  31. $i = 0;
  32. foreach($applist as $appid) {
  33. if(!empty($_G['cache']['myapp'][$appid])) {
  34. if($i < $this->num) {
  35. $thisApp .= '<a href="userapp.php?mod=app&id='.$appid.'&fromtid='.$_G['tid'].'"'.(isset($_G['cache']['myapp'][$appid]) ? ' title="'.$_G['cache']['myapp'][$appid]['appname'].'"' : '').' target="_blank">'.
  36. '<img class="authicn vm" src="http://appicon.manyou.com/logos/'.$appid.'" style="width:40px;height:40px;margin-left:0px;"/></a>';
  37. $i++;
  38. } else {
  39. break;
  40. }
  41. }
  42. }
  43. }
  44. $thisApp = $thisApp ? '<p>'.$this->title.'</p><p class="avt" style="margin-left:10px;">'.$thisApp.'</p>' : '';
  45. return array($thisApp);
  46. }
  47. function viewthread_postsightmlafter_output() {
  48. global $_G, $postlist;
  49. if(IS_ROBOT || !$this->myapp) {
  50. return array();
  51. }
  52. $myappdiv = $myapp = $uids = array();
  53. foreach($postlist as $post) {
  54. $uids[$post['authorid']] = $post['authorid'];
  55. }
  56. require_once libfile('function/feed');
  57. foreach(C::t('common_member')->fetch_all($uids) as $uid) {
  58. $list = array();
  59. foreach(C::t('home_feed_app')->fetch_all_by_uid_icon($uid['uid'], '', 0, 1) as $feed) {
  60. $list[$feed['icon']][] = mkfeed($feed);
  61. }
  62. $myapp[$uid['uid']] = $this->getmyapplist($list);
  63. }
  64. foreach($postlist as $post) {
  65. $myappdiv[] = $myapp[$post['authorid']];
  66. }
  67. return $myappdiv;
  68. }
  69. function getmyapplist($list) {
  70. if(!$list) {
  71. return '';
  72. }
  73. $myapp = '<div class="xld xlda mtm">';
  74. foreach($list as $appicon => $values) {
  75. $myapp .= '<dl class="bbda cl"><dd class="m avt">';
  76. $myapp .= '<a href="userapp.php?mod=app&id='.$appicon.'"><img src="http://appicon.manyou.com/logos/'.$appicon.'" alt="" /></a>';
  77. $myapp .= '</dd><dd class="cl"><ul class="el">';
  78. foreach($values as $value) {
  79. $myapp .= '<li class="cl"><a class="t" href="userapp.php?icon='.$value[icon].'" title="'.lang('home/template', 'just_look_dynamic').'">';
  80. $myapp .= '<img width="16" height="16" '.($_G[cache][myapp][$value[icon]][icon] ? 'src="'.$_G[cache][myapp][$value[icon]][icon].'" onerror="this.onerror=null;this.src=\'http://appicon.manyou.com/icons/'.$value[icon].'\'"' : 'src="http://appicon.manyou.com/icons/'.$value[icon].'"').' />';
  81. $myapp .= '</a>'.$value[title_template].'<span class="xg1">'.dgmdate($value[dateline], 'n-j H:i').'</span><div class="ec">';
  82. if($value['image_1']) {
  83. $myapp .= '<a href="'.$value[image_1_link].'"'.$value[target].'><img src="'.$value[image_1].'" class="tn" /></a>';
  84. }
  85. if($value['image_2']) {
  86. $myapp .= '<a href="'.$value[image_2_link].'"'.$value[target].'><img src="'.$value[image_2].'" class="tn" /></a>';
  87. }
  88. if($value['image_3']) {
  89. $myapp .= '<a href="'.$value[image_3_link].'"'.$value[target].'><img src="'.$value[image_3].'" class="tn" /></a>';
  90. }
  91. if($value['image_4']) {
  92. $myapp .= '<a href="'.$value[image_4_link].'"'.$value[target].'><img src="'.$value[image_4].'" class="tn" /></a>';
  93. }
  94. if($value['body_template']) {
  95. $myapp .= '<div class="detail"'.($value['image_3'] ? 'style="clear: both; zoom: 1;"' : '').'>';
  96. $myapp .= $value[body_template].'</div>';
  97. }
  98. if($value['body_general']) {
  99. $myapp .= '<div class="quote"><blockquote>'.$value[body_general].'</blockquote></div>';
  100. }
  101. $myapp .= '</div></li>';
  102. }
  103. $myapp .= '</ul></dd></dl>';
  104. }
  105. return $myapp;
  106. }
  107. }
  108. class plugin_myapp_userapp extends plugin_myapp {
  109. function userapp_update() {
  110. global $_G;
  111. if(!empty($_GET['id']) && is_numeric($_GET['id'])) {
  112. $applist = array();
  113. $userapp = C::t('home_userapp_plying')->fetch($_G['uid']);
  114. if(!empty($userapp['appid'])) {
  115. $applist = explode(',', $userapp['appid']);
  116. if(!empty($applist)) {
  117. $applist = array_diff($applist, array(''));
  118. $key = array_search($_GET['id'], $applist);
  119. if($key !== false) {
  120. unset($applist[$key]);
  121. }
  122. array_unshift($applist, $_GET['id']);
  123. while(count($applist) > $this->num) {
  124. array_pop($applist);
  125. }
  126. }
  127. }
  128. if(empty($applist)) {
  129. $applist = array($_GET['id']);
  130. }
  131. if(!empty($applist)) {
  132. $appstr = implode(',', $applist);
  133. C::t('home_userapp_plying')->insert(array('uid' => $_G['uid'], 'appid' => daddslashes($appstr)), false, true);
  134. }
  135. }
  136. }
  137. }