Blame view

mobile/source/modules/users/blocks/users_top.php 2.87 KB
a1684257   Administrator   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
  <?php
  	//	òîï ïîëüçîâàòåëåé
  	
  function users_top($options){
  global $MAIN_USER,$MAIN_DB;
   	if ( $options=='week' ){
  		$time = (time()-(60*60*24*7));
   	}else{
   		$time = (time()-(60*60*24*31));
   	}
  
  		
  	$sql = "SELECT
  			 	SUM(points) AS points,
  			 	u.u_interests,
  			 	u.u_login 	AS profile_url,
  			 	u.u_avatar 	AS avatar_url,
  			 	u.u_points  AS rank_img,
  			 	u.u_login,u.u_name,u.u_points 
  			FROM 
  		  	".$MAIN_DB -> prefix("users_points_log")." l
  		  	LEFT JOIN
  		  	".$MAIN_DB -> prefix("users")." u
  		  	USING(u_id)
  		 	WHERE u_active='1' AND g_id=2 AND l.time>$time AND points>0 GROUP BY u_id ORDER BY SUM(points) DESC LIMIT 0,3";
  	$u = new u_query('u');
  	$u -> set_sql($sql);
  	$u -> get(false,false);
    	$rows = array();
   	while( $row =  $u -> row() ){
  		if ( $row['points']<=0 ){
  			continue;
  		}
  		$row['u_interests']= sys_in_html($row['u_interests'] );
  		$rows[]= arr_to_obj($row);
    	}
    	
    	
     	$t = new PHPTAL( false );
    	if ( $options=='week' ){
     		$t -> setSource(TMPL_USER_TOP_WEEK);
    	}else{
    		$t -> setSource(TMPL_USER_TOP_MONTH);
    	}
    	$t -> rows = $rows;
    	
    	 		
    	return  $t -> execute();
  }
  
  define("TMPL_USER_TOP_WEEK",
  <<<TMPL_USER_TOP_WEEK
  <h2>Íóæíî äîïèñàòü øàáëîí</h2>
  <h2><a class="h_link" href="/users/top.html"><span></span></a></h2>
  <ul class="top_users">
  <tal:block tal:condition="exists:rows" tal:repeat="r rows" >
  	<li>
  		<div class="tu_content_wrap">
  			<a href="/show-user/{r users.u_login}">
  				<img src="{r users.u_avatar}" title="{r users.u_login}" width="88" height="88" alt="{r users.u_login}">
  			</a>
  			<div class="tu_content">
  				<a class="b_link" href="/show-user/{r users.u_login}">{r users.u_name}</a>
  				{if exists_u_interests}<p>	{u_interests}</p>{endif}
  			</div>
  			<div class="stars_rate">
  				<img src="/source/modules/ajax/tmp/{r users.u_rank_img}"  width="86" height="15">
  				<strong tal:content="row/points">+123</strong>
  			</div>
  		</div>
  	</li>
  </tal:block>
  </ul>
  TMPL_USER_TOP_WEEK
  );
  
  define("TMPL_USER_TOP_MONTH",
  <<<TMPL_USER_TOP_MONTH
  <div class="top_users_wrap">
  	<h2><a class="h_link" href="/users/top.html"><span></span></a></h2>
  	<table class="top_users" cellpadding="0" cellspacing="0">
  	<tr>
  		<tal:block tal:condition="exists:rows" tal:repeat="r rows" >
  		<th width="32%">
  			<div class="tu_content_wrap">
  				<a tal:attributes="href r/profile_url" >
  					<img 
  						tal:attributes="title r/u_login;src r/avatar_url;alt r/u_login"  
  						
  						
  						width="88" height="88"
  					 />
  				</a>
  				<div class="tu_content">
  					<a class="b_link" tal:attributes="href r/profile_url" tal:content="r/u_name"></a>
  					<p tal:condition="r/u_interests" tal:content="r/u_interests"></p>
  				</div>
  				<div class="stars_rate">
  					<img tal:attributes="src r/rank_img"  width="86" height="15" />
  					<strong tal:content="r/u_points">+10</strong>
  				</div>
  			</div>
  		</th>
  		<td>&nbsp;</td>
  	</tal:block>
  </tr>
  </table>
  </div>
  TMPL_USER_TOP_MONTH
  );
  ?>