<!--<?php
class weiboModelTemplate {
	
	var $_maxPhoto = 4;
	var $_isGM;
	var $_isTopic;
	var $_topicName;
	var $_weiboDiv; // 广场里有热门评论和热门新鲜事两个div，为了区别两个comment
	var $_showPhotoOnload; //是否载入就显示图片
	
	function weiboModelTemplate() {
		global $windid,$manager,$groupid,$SYSTEM,$do;
		$this->_isGM = ($SYSTEM['delweibo'] || CkInArray($windid, $manager));
		$this->_isTopic = $do == 'topics'? 1: 0;
		$this->_topicName = $GLOBALS['topic'];
		$this->_weiboDiv = '';
	}
	
	function setWeiboDiv($d){
		$this->_weiboDiv = $d;
	}

	function _isManager($uid) {
		global $winduid;
		return ($uid == $winduid || $this->_isGM);
	}

	function sendweibo($value){
		$this->weibo($value);
	}

	function honor($value) {
		$this->weibo($value);
	}

	function post($nextDo = '',$faceurl = '') {
print <<<EOT
-->
<div class="userInfo">
	<div class="userInfoweek">
		<div id="myFace" class="fl mr10"><p id="toModifyFace" class="tac" style="display:none;"><a href="profile.php?action=modify&info_type=face" class="s5">修改头像</a></p><img src="$faceurl" width="80" height="80" class="img"></div>
		<div class="fl" style="width:482px;">
			<form id="weibo_form" name="weibo_form" action="apps.php?q=weibo&do=post&ajax=1" method="post" onsubmit="return false">
					<input type="hidden" name="verify" value="{$GLOBALS['verifyhash']}" />
			<div class="homeSk"  onclick="getObj('popTips').style.display='none'">
				<div class="fl"><div id="submitSuccess" class="success" style="display:none;">发布成功</div></div>
				<div class="fl f14"><div id="popTips" style="position:absolute;padding:10px 13px;"></div></div>
				<textarea id="weibo_content" name="atc_content" class="homeText" autocomplete="off">{$GLOBALS['o_weibotip']}</textarea>
				<div class="c"></div>
				<div id="uploadPicDiv" class="homeSk_input" style="display:none;"></div>
			</div>
			</form>
			<div class="p5 cc" style="padding-right:0px;">
				<span id="writebutton" class="fr"><button class="button cp" id="weibo_submit"> </button></span>
				<span id="weibo_smile" class="sk_show cp">表情</span>
<!--
EOT;
$display = $GLOBALS['o_weibourl'] != '0' ? '' : 'none'; 
print <<<EOT
-->
				<span id="weibo_url" class="sk_link cp" style="display:$display">链接</span>
<!--
EOT;
$display = ($GLOBALS['o_weibophoto'] != '0' && $GLOBALS['db_phopen']) ? '' : 'none'; 
print <<<EOT
-->
				<span id="weibo_topic" class="sk_topic cp">话题</span>
				<span id="uploadPic" style="display:$display">
					<span id="uploadPicload" class="file fr" >
					<span class="sk_img cp">图片</span>
					<form id="uploadPicForm" name="uploadPicForm" method="post" action="pw_ajax.php?action=uploadwritepic" enctype="multipart/form-data">
						<input id="writePic" name="writePic" type="file" hidefocus="true" />
					</form>
					</span>
					<span id="uploadPicLoadding" class="fl" style="display:none;width:60px;position:relative;line-height:20px;">上传中...</span>
				</span>
				<img src="javascript://" id="imgPreview" style="position:absolute;display:none;left:-10000px;" />
				<div class="limit fr mr15 s6" id="weibo_contentlimit"><em>0/255</em></div>
			</div>
		</div>
	</div>
<!--
EOT;
include printEot('writesmile');
include printEot('writeurl');
print <<<EOT
-->
</div>
<script type="text/javascript" src="apps/weibo/js/post.js"></script>
<script>
var pw_weiboPost = new weibo_post({form:'weibo_form',content:'weibo_content',smile:'weibo_smile',url:'weibo_url',photo:'weibo_photo',nextdo:'{$nextDo}',weibotip:'{$GLOBALS[o_weibotip]}'});
var content = getObj('weibo_content'),
	dvalue = getObj('weibo_content').value;
	color = '#888';
	content.style.color = color;
	content.onkeydown = function(event) {
		ctrlEnter(event,getObj('weibo_form'),function(){pw_weiboPost.post();});
	}
	content.onfocus = function() {
		if(this.value === dvalue) {
			this.value = '';this.style.color='';
		}
	}
	content.onblur = function(){
		if(this.value === '') {
	//		this.value = dvalue;
			this.style.color = color;
		}
	}
/*话题功能*/	
var weibo_topic = getObj('weibo_topic');
var defaultTopic = '#请在这里输入自定义话题#';
weibo_topic.onclick = function(){
	if (content.value == dvalue) content.value = '';content.style.color = '';
	setSelection();
}
function setSelection() {
	var pos = content.value.indexOf(defaultTopic);
	var len = defaultTopic.length;
	if(pos == -1) insertContentToTextArea(content,defaultTopic);
	if(pos < 0) pos = content.value.indexOf(defaultTopic);
	var range;
	if (is_ie) {
		range = content.createTextRange();
		range.moveStart('character',-content.value.length);
		range.moveEnd('character',-content.value.length);
		range.collapse(true);
		range.moveStart('character',pos+1);
		range.moveEnd('character',len-2);
		range.select();
	} else {
		content.setSelectionRange(pos+1,pos+len-1);
	}
}
</script>
<!--
EOT;
	}

	function weibo($value) {//普通新鲜事
   
print <<<EOT
-->
<dl class="dl cc">
	<dt class="dt">
		<a href="apps.php?q=weibo&uid={$value['authorid']}" class="img_50"><img src="{$value['icon']}" width="44" height="44" alt="{$value['username']}" /></a>
	</dt>
	<dd class="dd">
		<div class="title">
			<span class="uname"><a href="{$GLOBALS[db_userurl]}{$value['authorid']}">{$value['username']}</a>:&nbsp;</span>{$value['content']}
		</div>
<!--
EOT;
 if($value['mid']){
if ($value['extra']['photos']) $this->_showPhotos($value['extra']['photos']);
if ($value['extra']['_hasVideo']) $this->_showVideo($value['extra']['_hasVideo']);
print <<<EOT
-->
		<div class="gray">
<!--
EOT;
$this->_operateButton($value);
print <<<EOT
-->
			<cite title="{$value['postdate_s']}"><a href="apps.php?q=weibo&do=detail&mid={$value['mid']}&uid={$value['authorid']}">{$value['lastdate']}</a> [<a href="apps.php?uid={$value['authorid']}&q=weibo">新鲜事</a>]</cite>
		</div>
		<div id="comment_{$value['mid']}{$this->_weiboDiv}"></div>
<!--
EOT;
}print <<<EOT
-->
	</dd>
</dl>
<!--
EOT;
	}

	function transmit($value) {
     if($value['mid']){//新鲜事转发
print <<<EOT
-->
<dl class="dl cc">
	<dt class="dt">
		<a href="apps.php?q=weibo&uid={$value['authorid']}" class="img_50"><img src="{$value['icon']}" width="44" height="44" alt="{$value['username']}" /></a>
	</dt>
	<dd class="dd">
		<div class="title">
			<span class="uname"><a href="{$GLOBALS[db_userurl]}{$value['authorid']}">{$value['username']}</a> </span>转发:&nbsp;{$value['content']}
		</div>
<!--
EOT;
if ($value['extra']['_hasVideo']) $this->_showVideo($value['extra']['_hasVideo']);
print <<<EOT
-->
		<div class="forward mb10">
<!--
EOT;
$this->_transmit($value['transmits']);
print <<<EOT
-->
		</div>
		<div class="gray">
<!--
EOT;
$this->_operateButton($value);
print <<<EOT
-->
			<cite title="{$value['postdate_s']}"><a href="apps.php?q=weibo&do=detail&mid={$value['mid']}&uid={$value['authorid']}">{$value['lastdate']}</a>[<a href="apps.php?uid={$value['authorid']}&q=weibo">新鲜事</a>]</cite>
		</div>
		<div id="comment_{$value['mid']}{$this->_weiboDiv}"></div>
	</dd>
</dl>
<!--
EOT;
	}}

	function _transmit($value) {
		if (empty($value)) {print <<<EOT
-->
			呀，原新鲜事已被删除了
<!--
EOT;
		} else {
			static $identify = 1;
			$id = $value['mid'] . '_' . $identify;
			if (in_array($value['type'], array(3,10, 20, 40, 42))) {
				if ($value['type'] == 10) {
					$url = "read.php?tid={$value['objectid']}";
				} elseif($value['type'] == 3) {
                	$url = "mode.php?m=cms&q=view&id={$value['objectid']}";
                }elseif ($value['type'] == 20) {
					$url = "apps.php?q=diary&a=detail&did={$value['objectid']}&uid={$value['authorid']}";
				} elseif ($value['type'] == 40) {
					$url = "apps.php?q=group&a=read&cyid={$value['extra']['cyid']}&tid={$value['objectid']}";
				} else {
					$url = "apps.php?q=group&a=active&job=view&cyid={$value['extra']['cyid']}&id={$value['objectid']}";
				}
print <<<EOT
-->
<div class="title">
	<a href="{$GLOBALS[db_userurl]}{$value['authorid']}">{$value['username']}</a>:&nbsp;<a href="$url">{$value['extra']['title']}</a>
</div>
<div class="mb10">{$value['content']}</div>
<!--
EOT;
			} else {
				($value['type'] == 30 || $value['type'] == 41) && $value['content'] = '分享照片';
print <<<EOT
-->
<div class="mb10">
	<a href="{$GLOBALS[db_userurl]}{$value['uid']}">{$value['username']}</a>:&nbsp;{$value['content']}
</div>
<!--
EOT;
			}
			if ($value['extra']['photos']) $this->_showPhotos($value['extra']['photos']);
			if ($value['extra']['_hasVideo']) $this->_showVideo($value['extra']['_hasVideo']);
print <<<EOT
-->
<div class="unForward">
	<a href="apps.php?q=weibo&do=transmit&ajax=1&mid={$value['mid']}" onclick="return ajaxurl(this)" class="s7">原文转发({$value['transmit']})</a>&nbsp;
	<a href="javascript:void(0);" class="s7"  onclick="getcomments('comment',{$value[mid]},'',{$identify});return false;">原文评论<span id="commentnum_{$id}">({$value['replies']})</span></a>
</div>
<div id="comment_{$id}{$this->_weiboDiv}"></div>
<!--
EOT;
		$identify++;
		}
	}

	function photos($value) {//相册
print <<<EOT
-->
<dl class="dl cc">
	<dt class="dt">
		<a href="apps.php?q=weibo&uid={$value['authorid']}" class="img_50"><img src="{$value['icon']}" width="44" height="44" alt="{$value['username']}" /></a>
	</dt>
	<dd class="dd">
		<div class="title">
			<span class="uname"><a href="{$GLOBALS[db_userurl]}{$value['authorid']}">{$value['username']}</a>:&nbsp;</span><!--
EOT;
if ($value['content']) {print <<<EOT
-->{$value['content']}<!--
EOT;
} else {print <<<EOT
-->分享照片<!--
EOT;
}print <<<EOT
-->
		</div>
<!--
EOT;
if ($value['extra']['photos']) $this->_showPhotos($value['extra']['photos']);
print <<<EOT
-->
		<div class="gray">
<!--
EOT;
$this->_operateButton($value);
print <<<EOT
-->
			<cite title="{$value['postdate_s']}"><a href="apps.php?q=weibo&do=detail&mid={$value['mid']}&uid={$value['authorid']}">{$value['lastdate']}</a>  [<a href="apps.php?q=photos&uid={$value['authorid']}&a=album&aid={$value['extra']['aid']}">来自相册</a>]</cite>
		</div>
		<div id="comment_{$value['mid']}{$this->_weiboDiv}"></div>
	</dd>
</dl>
<!--
EOT;
	}

	function group_photos($value) {//相册
print <<<EOT
-->
<dl class="dl cc">
	<dt class="dt">
		<a href="apps.php?q=weibo&uid={$value['authorid']}" class="img_50"><img src="{$value['icon']}" width="44" height="44" alt="{$value['username']}" /></a>
	</dt>
	<dd class="dd">
		<div class="title">
			<span class="uname"><a href="{$GLOBALS[db_userurl]}{$value['authorid']}">{$value['username']}</a>:&nbsp;</span>分享照片
		</div>
<!--
EOT;
$this->_showPhotos($value['extra']['photos']);
print <<<EOT
-->
		<div class="gray">
<!--
EOT;
$this->_operateButton($value);
print <<<EOT
-->
			<cite title="{$value['postdate_s']}"><a href="apps.php?q=weibo&do=detail&mid={$value['mid']}&uid={$value['authorid']}">{$value['lastdate']}</a>  [来自群组 - <a href="apps.php?q=galbum&cyid={$value['extra']['cyid']}&a=album&aid={$value['extra']['aid']}">{$value['extra']['cname']}</a>]</cite>
		</div>
		<div id="comment_{$value['mid']}{$this->_weiboDiv}"></div>
	</dd>
</dl>
<!--
EOT;
	}

	function group_active($value) {//群组活动
print <<<EOT
-->
<dl class="dl cc">
	<dt class="dt">
		<a href="apps.php?q=weibo&uid={$value['authorid']}" class="img_50"><img src="{$value['icon']}" width="44" height="44" alt="{$value['username']}" /></a>
	</dt>
	<dd class="dd">
		<div class="title">
			<span class="uname"><a href="{$GLOBALS[db_userurl]}{$value['authorid']}">{$value['username']}</a>:&nbsp;</span><a href="apps.php?q=group&a=active&job=view&cyid={$value['extra']['cyid']}&id={$value['objectid']}" target="_blank">{$value['extra']['title']}</a>
		</div>
		<div class="mb10">
			{$value['content']}
		</div>
		<div class="gray">
<!--
EOT;
$this->_operateButton($value);
print <<<EOT
-->
			<cite title="{$value['postdate_s']}"><a href="apps.php?q=weibo&do=detail&mid={$value['mid']}&uid={$value['authorid']}">{$value['lastdate']}</a> [来自群组 - <a href="apps.php?q=group&a=active&cyid={$value['extra']['cyid']}">{$value['extra']['cname']}</a>]</cite>
		</div>
		<div id="comment_{$value['mid']}{$this->_weiboDiv}"></div>
	</dd>
</dl>
<!--
EOT;
	}

	function group_article($value) {//群组话题
print <<<EOT
-->
<dl class="dl cc">
	<dt class="dt">
		<a href="apps.php?q=weibo&uid={$value['authorid']}" class="img_50"><img src="{$value['icon']}" width="44" height="44" alt="{$value['username']}" /></a>
	</dt>
	<dd class="dd">
		<div class="title">
			<span class="uname"><a href="{$GLOBALS[db_userurl]}{$value['authorid']}">{$value['username']}</a>:&nbsp;</span><a href="apps.php?q=group&a=read&cyid={$value['extra']['cyid']}&tid={$value['objectid']}" target="_blank">{$value['extra']['title']}</a>
		</div>
		<div class="mb10">
			{$value['content']}
		</div>
		<div class="gray">
<!--
EOT;
$this->_operateButton($value);
print <<<EOT
-->
			<cite title="{$value['postdate_s']}"><a href="apps.php?q=weibo&do=detail&mid={$value['mid']}&uid={$value['authorid']}">{$value['lastdate']}</a> [来自群组 - <a href="apps.php?q=group&a=thread&cyid={$value['extra']['cyid']}">{$value['extra']['cname']}</a>]</cite>
		</div>
		<div id="comment_{$value['mid']}{$this->_weiboDiv}"></div>
	</dd>
</dl>
<!--
EOT;
	}

	function group_write($value) {//群组记录
print <<<EOT
-->
<dl class="dl cc">
	<dt class="dt">
		<a href="apps.php?q=weibo&uid={$value['authorid']}" class="img_50"><img src="{$value['icon']}" width="44" height="44" alt="{$value['username']}" /></a>
	</dt>
	<dd class="dd">
		<div class="title">
			<span class="uname"><a href="{$GLOBALS[db_userurl]}{$value['authorid']}">{$value['username']}</a>:&nbsp;</span>{$value['content']}
		</div>
		<div class="gray">
<!--
EOT;
$this->_operateButton($value);
print <<<EOT
-->
			<cite title="{$value['postdate_s']}"><a href="apps.php?q=weibo&do=detail&mid={$value['mid']}&uid={$value['authorid']}">{$value['lastdate']}</a> [来自群组 - <a href="apps.php?q=group&a=write&cyid={$value['extra']['cyid']}">{$value['extra']['cname']}</a>]</cite>
		</div>
		<div id="comment_{$value['mid']}{$this->_weiboDiv}"></div>
	</dd>
</dl>
<!--
EOT;
	}

	function diary($value) {//日志
print <<<EOT
-->
<dl class="dl cc">
	<dt class="dt">
		<a href="apps.php?q=weibo&uid={$value['authorid']}" class="img_50"><img src="{$value['icon']}" width="44" height="44" alt="{$value['username']}" /></a>
	</dt>
	<dd class="dd">
		<div class="title">
			<span class="uname"><a href="{$GLOBALS[db_userurl]}{$value['authorid']}">{$value['username']}</a>:&nbsp;</span><a href="apps.php?q=diary&a=detail&did={$value['objectid']}&uid={$value['authorid']}" target="_blank">{$value['extra']['title']}</a>
		</div>
		<div class="mb10">
			{$value['content']}
		</div>
		<div class="gray">
<!--
EOT;
$this->_operateButton($value);
print <<<EOT
-->
			<cite title="{$value['postdate_s']}"><a href="apps.php?q=weibo&do=detail&mid={$value['mid']}&uid={$value['authorid']}">{$value['lastdate']}</a> [<a href="apps.php?uid={$value['authorid']}&q=diary">来自日志</a>]</cite>
		</div>
		<div id="comment_{$value['mid']}{$this->_weiboDiv}"></div>
	</dd>
</dl>
<!--
EOT;
	}

	function article($value) {//帖子
print <<<EOT
-->
<dl class="dl cc">
	<dt class="dt">
		<a href="apps.php?q=weibo&uid={$value['authorid']}" class="img_50"><img src="{$value['icon']}" width="44" height="44" alt="{$value['username']}" /></a>
	</dt>
	<dd class="dd">
		<div class="title">
			<span class="uname"><a href="{$GLOBALS[db_userurl]}{$value['authorid']}">{$value['username']}</a>:&nbsp;</span><a href="read.php?tid={$value['objectid']}" target="_blank">{$value['extra']['title']}</a>
		</div>
		<div class="mb10">
			{$value['content']}
		</div>
<!--
EOT;
if ($value['extra']['_hasVideo']) $this->_showVideo($value['extra']['_hasVideo']);
print <<<EOT
-->
		<div class="gray">
<!--
EOT;
$this->_operateButton($value);
$fname = strip_tags($value['extra']['fname']);
print <<<EOT
-->
			<cite title="{$value['postdate_s']}"><a href="apps.php?q=weibo&do=detail&mid={$value['mid']}&uid={$value['authorid']}">{$value['lastdate']}</a> [来自帖子 - <a href="thread.php?fid={$value['extra']['fid']}" class="gray">{$fname}</a>]</cite>
		</div>
		<div id="comment_{$value['mid']}{$this->_weiboDiv}"></div>
	</dd>
</dl>
<!--
EOT;
	}
    
    function cms($value) {//文章
print <<<EOT
-->
<dl class="dl cc">
	<dt class="dt">
		<a href="apps.php?q=weibo&uid={$value['authorid']}" class="img_50"><img src="{$value['icon']}" width="44" height="44" alt="{$value['username']}" /></a>
	</dt>
	<dd class="dd">
		<div class="title">
			<span class="uname"><a href="{$GLOBALS[db_userurl]}{$value['authorid']}">{$value['username']}</a>:&nbsp;</span><a href="mode.php?m=cms&q=view&id={$value['objectid']}" target="_blank">{$value['extra']['title']}</a>
		</div>
		<div class="mb10">
			{$value['content']}
		</div>
<!--
EOT;
if ($value['extra']['_hasVideo']) $this->_showVideo($value['extra']['_hasVideo']);
print <<<EOT
-->
		<div class="gray">
<!--
EOT;
$this->_operateButton($value);
print <<<EOT
-->
			<cite title="{$value['postdate_s']}"><a href="apps.php?q=weibo&do=detail&mid={$value['mid']}&uid={$value['authorid']}">{$value['lastdate']}</a> [来自文章 - <a href="mode.php?m=cms&q=list&column={$value['extra']['cid']}" class="gray">{$value['extra']['cname']}</a>]</cite>
		</div>
		<div id="comment_{$value['mid']}{$this->_weiboDiv}"></div>
	</dd>
</dl>
<!--
EOT;
	}
	
	function sinaweibo($value) {
print <<<EOT
-->
<dl class="dl cc">
	<dt class="dt">
		<a href="apps.php?q=weibo&uid={$value['authorid']}" class="img_50"><img src="{$value['icon']}" width="44" height="44" alt="{$value['username']}" /></a>
	</dt>
	<dd class="dd">
		<div class="title">
			<span class="uname"><a href="{$GLOBALS[db_userurl]}{$value['authorid']}">{$value['username']}</a>:&nbsp;</span>{$value['content']}
		</div>
<!--
EOT;
if ($value['extra']['sinaPhotos']) {
	$extraPhotos = array();
	foreach ($value['extra']['sinaPhotos'] as $tmpValue) {
		$extraPhotos[] = array('path'=>$tmpValue['thumb'], 's_path'=>$tmpValue['middle']);
	}
	$this->_showPhotos($extraPhotos, false);
}
if ($value['extra']['_hasVideo']) $this->_showVideo($value['extra']['_hasVideo']);
print <<<EOT
-->
		<div class="gray">
<!--
EOT;
$this->_operateButton($value);
$sinaUserUrl = 'http://t.sina.com.cn/';
$sinaUserUrl .= isset($value['sinaWeiboUserInfo']['id']) ? $value['sinaWeiboUserInfo']['id'] : '';
print <<<EOT
-->
			<cite title="{$value['postdate_s']}"><a href="apps.php?q=weibo&do=detail&mid={$value['mid']}&uid={$value['authorid']}">{$value['lastdate']}</a> [来自 - <a target="_blank" href="$sinaUserUrl">新浪微博</a>]</cite>
		</div>
		<div id="comment_{$value['mid']}{$this->_weiboDiv}"></div>
	</dd>
</dl>
<!--
EOT;
	}

	function _operateButton($value) {
		global $do,$page,$USCR,$transmitAction;
		$do = $do ? $do : 'filterweibo';
		if(in_array($USCR,array('space_index','square_weibo'))){
			$do = 'reload';
		}
		$page = $page ? $page : 1;
		$isGM = $this->_isManager($value['authorid']);
		$id = $value['mid'];	
print <<<EOT
-->
	<div class="fr">
<!--
EOT;
if($value['mid']){
if($isGM){print <<<EOT
-->
		<a href="javascript:void(0);" class="s7" onclick="deleteweibo('{$value['mid']}','$do','$page','weiboFeed','$this->_isTopic','$this->_topicName');return false;">删除</a>&nbsp;|&nbsp;<!--
EOT;
}
if ($GLOBALS['o_weibopost'] != '0') {
print <<<EOT
--><a href="javascript:;" onclick="transmitWeibo({$value['mid']},'$do','$this->_isTopic','$this->_topicName');return false;" class="s7">转发<!--
EOT;
if ($value['transmit'] > 0) {print <<<EOT
-->({$value['transmit']})<!--
EOT;
}print <<<EOT
--></a>&nbsp;|&nbsp;<!--
EOT;
}print <<<EOT
--><a href="javascript:void(0);" class="s7" onclick="getcomments('comment','{$value['mid']}','');return false;">评论<span id="commentnum_{$id}"><!--
EOT;
if ($value['replies'] > 0) {print <<<EOT
-->({$value['replies']})<!--
EOT;
}print <<<EOT
--></span></a>&nbsp;|&nbsp;<a href="apps.php?q=collection&a=favor&type=weibo&ajax=1&id={$value['mid']}" onclick="return ajaxurl(this)" class="s7">收藏</a></div>
<!--
EOT;
	}}

	function _showPhotos($value, $isLocalPhoto = true) {
		static $kNum = 0;
		if ($isLocalPhoto) {
			$photolist = array();
			foreach ($value as $photovalue) {
				$photovalue['s_path'] = getphotourl($photovalue['path'], false, 'imgdel.jpg');
				$photovalue['path']	= getphotourl($photovalue['path'], $photovalue['ifthumb'], 'imgdel.jpg');
				$photolist[] = $photovalue;
			}
		} else {
			$photolist = $value;
		}
		$count = count($photolist);
		$photos = pwJsonEncode($photolist);
print <<<EOT
-->
<script type="text/javascript">
weibo.push("$kNum", $photos);

</script>
<div class="ddPhoto mb10 cc">
<!--
EOT;
if ($count > $this->_maxPhoto) {print <<<EOT
-->
	<div class="pre"><a href="javascript:void(0)" onclick='weibo.prev("$kNum");return false;'>上一页</a></div>
<!--
EOT;
}$rect_width = $this->_maxPhoto*116;
$ul_width = count($photolist)*116;
print <<<EOT
-->
	<div class="fl" id="photolist_{$kNum}" count="$count" style="width:{$rect_width}px;overflow:hidden;">
		<ul class="fl" style="width:{$ul_width}px">
<!--
EOT;
$i=0;
foreach ($photolist as $photo) {
$ifDefaultShow = ($i == 0 && $this->_showPhotoOnload) ? "onload=\"weibo.showPhoto('$photo[pid]','$photo[s_path]','$kNum','$i');resizeImg(this);\"" : 'onload="resizeImg(this);"';
print <<<EOT
-->
			<li class="cp" onclick="weibo.showPhoto('{$photo[pid]}','{$photo[s_path]}','$kNum','$i')" style="cursor: url('u/images/zoomin.cur'),auto"><img src="{$photo['path']}"  $ifDefaultShow onerror="this.src='$GLOBALS[imgpath]/imgdel.jpg'" /></li>
<!--
EOT;
$i++;
}print <<<EOT
-->
		</ul>
	</div>
<!--
EOT;
if ($count > $this->_maxPhoto) {print <<<EOT
-->
	<div class="next"><a href="javascript:void(0)" onclick='weibo.next("$kNum");return false;'>下一页</a></div>
<!--
EOT;
}print <<<EOT
-->
</div>
<div id="photocontainer_{$kNum}" style="display:none;">
<!--
EOT;
$this->_photoMask($kNum);
print <<<EOT
-->	
</div>
<!--
EOT;
		$kNum++;
	}

	function _showVideo($value) {
print <<<EOT
-->
		<div class="mb10"><img src="u/images/share_v.png" class="vthumb cp" id="showVideo_{$value[0]}" onclick="mediaPlayer.showVideo('{$value[1]}','{$value[0]}')"/></div>
<!--
EOT;
	}

	function photoPop() {
print <<<EOT
-->
<div id="photo_pop_mask" onclick="weibo.hidePhoto()" class="popImgbg" style="display:none;position:absolute;background:#000;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;left:0;right:0;top:0;bottom:0;z-index:1;"></div>
<div id="photo_pop" class="popImg" style="display:none;position:absolute;z-index:2;border:3px solid #fff">
	<div class="tac pr">
		<span class="popImgdel cp" onclick="weibo.hidePhoto()">关闭</span>
		<table cellpadding="0" cellspacing="0">
			<tr>
				<td>
					<div class="fl" id="prephoto">
						<span onclick="weibo.prevPhoto()" class="aPre" title="上一张" style="zoom:1"></span>
					</div>
					<div class="fl" id="nextphoto">
						<span onclick="weibo.nextPhoto()" class="aNext" title="下一张" style="zoom:1"></span>
					</div>
					<img src="javascript://" id="photo_path" style="display: block;line-height:1;" /></td>
			</tr>
		</table>
	</div>
</div>
<!--
EOT;
	}
    
    function _photoMask($num) {
print <<<EOT
-->
<div id="photo_mask_{$num}" class="feedImgB" style="display:none;">
		<p class="mb5"><a href="javascript:;" onclick="weibo.hidePhoto($num)" class="feediImgFold">收起</a>&nbsp;|&nbsp;<a href="javascript:;" class="artWork" target="_blank" onclick="this.href=weibo.bigPhotoUrl($num)">查看大图</a></p>
	<div class="tac pr cc" style="overflow:hidden;" id="photo_small_{$num}">
			<div id="prephoto_{$num}" onclick="weibo.prevPhoto($num)" class="aPre" title="上一张" style="zoom:1;left:0;_padding-bottom:5000px;_margin-bottom:-5000px;"></div>
			<div id="nextphoto_{$num}" onclick="weibo.nextPhoto($num)" class="aNext" title="下一张" style="zoom:1;bottom:0;top:0;_padding-bottom:5000px;_margin-bottom:-5000px;"></div>
			<img src="javascript://" id="photo_path_{$num}" style="display:block;margin:0 auto;" />
	</div>
</div>
<!--
EOT;
	}
	
	function showPhotoOnload($show = false) {
		$this->_showPhotoOnload = (bool) $show;
	}
    
    function live($list) {
print <<<EOT
-->
	<a href="javascript:;" class="fl preLive">上一页</a>
	<a href="javascript:;" class="fr nextLive">下一页</a>
	<div class="ulLive" style="height:56px;overflow:hidden;width:535px;">
	<ul class="cc">
<!--
EOT;
if (!$list || !is_array($list)) return false;
foreach ($list as $value) {
print <<<EOT
-->
		<li style="height:52px;overflow:hidden;">
			<a href="apps.php?q=weibo&uid={$value['authorid']}" class="img_50 mr10"><img src="{$value['icon']}" alt="{$value['username']}" /></a>
			<p style="width:105px;overflow:hidden;"><span><a href="{$GLOBALS[db_userurl]}{$value['authorid']}">{$value['username']}:</a></span><!--
EOT;
if ($value['type'] == 10) {
$url = "read.php?tid={$value['objectid']}";
}elseif($value['type'] == 3) {
$url = "mode.php?m=cms&q=view&id={$value['objectid']}";
}elseif ($value['type'] == 20) {
$url = "apps.php?q=diary&a=detail&did={$value['objectid']}&uid={$value['authorid']}";
} elseif ($value['type'] == 40) {
$url = "apps.php?q=group&a=read&cyid={$value['extra']['cyid']}&tid={$value['objectid']}";
} elseif ($value['type'] == 42) {
$url = "apps.php?q=group&a=active&job=view&cyid={$value['extra']['cyid']}&id={$value['objectid']}";
}
if($url) {print <<<EOT
-->
			<a href="$url" target="_blank">{$value['extra']['title']}</a>
<!--
EOT;
}print <<<EOT
-->     
       {$value['content']}</p>
		</li>
<!--
EOT;
}print <<<EOT
-->
	</ul>
    
<script type="text/javascript">

(function(){
	var interval;
	function moveElement(elem, final_x, final_y, interval){
		/*if (!elem.style.left) elem.style.left = "0px";
		if (!elem.style.top) elem.style.top = "0px";
		var xpos = parseInt(elem.style.left);
		var ypos = parseInt(elem.style.top);
		if (xpos == final_x && ypos == final_y){ if (elem.movement) clearTimeout(elem.movement);return true;}
		if (xpos < final_x) {var dist = Math.ceil((final_x - xpos) / 1.2);xpos = xpos + dist;}
		if (xpos > final_x) {var dist = Math.ceil((xpos - final_x) / 1.2);xpos = xpos - dist;}
		elem.style.left = xpos + "px";elem.style.top = ypos + "px";*/
		elem.style.left = final_x+'px';
		//elem.movement = setTimeout(function(){moveElement(elem, final_x, final_y, interval)}, interval);
	}

	var moveElem = getElementsByClassName("cc","J_feedLive")[0];
	var prevElem = getElementsByClassName("preLive","J_feedLive")[0];
	var nextElem = getElementsByClassName("nextLive","J_feedLive")[0];
	var lis = moveElem.getElementsByTagName("li");
	if(lis.length%3!=0){
		for(var i=0;i<lis.length%2;i++)
		{
			moveElem.removeChild(lis[0]);
		}
	}
	var width = lis[0].offsetWidth;
	var currentNum = 0;moveElem.style.left = 0;
	moveElem.style.width = width*lis.length+"px";
	prevElem.onclick = function(){
		clearInterval(interval);
		if(currentNum==0){
			var oFragment = document.createDocumentFragment();
			while(lis.length!=3){
				var node = lis[lis.length-1];
				oFragment.insertBefore(node.cloneNode(true),oFragment.childNodes[0]);
				moveElem.removeChild(node);
			}
			moveElem.insertBefore(oFragment,lis[0]);
			moveElem.style.left = -width*(lis.length-3)+"px";
			currentNum = 6;
			}
			moveElement(moveElem,parseInt(moveElem.style.left)+width*3,0,10);
			currentNum-=3;
			interval = setInterval(function(){
				nextElem.onclick();
			},6000);
	};
	nextElem.onclick = function(){
		clearInterval(interval);
		if(currentNum==lis.length-3){
			var oFragment = document.createDocumentFragment();
			while(lis.length!=3){
				var node = lis[0];
				oFragment.appendChild(lis[0].cloneNode(true));
				moveElem.removeChild(lis[0]);
			}
			moveElem.appendChild(oFragment);
			moveElem.style.left = 0;
			currentNum = 0;
			}
		moveElement(moveElem,parseInt(moveElem.style.left)-width*3,0,10);
		currentNum+=3;
		interval = setInterval(function(){
			nextElem.onclick();
		},6000);
	};
	interval = setInterval(function(){
		nextElem.onclick();
	},6000);
})();
</script>
	</div>
<!--
EOT;
	}
}
$weiboModelTemplate = new weiboModelTemplate();
?>