<?php
// 发送短信验证码
require_once ("../user_include.inc");

$ta = new TemplateAction();
if(!$ta->isLogin()) {
	print json_encode(array("count"=>0, "html"=>""));
	exit;
}

//检索用户收录的单词
$sql = "select a.* from article_dat a, user_favorite_dat u where a.delete_flg=false and u.delete_flg=false and u.data_type='article' and u.user_id='{$ta->user->id}' and u.data_id=a.id order by u.id desc";
error_log("Koala...ajax_get_my_articles.php...sql=" . $sql, 0);
$db = &KoalaDBManager::getInstance();
$article_data_list = $db->executeQuery($sql);

$article_count = count($article_data_list);
$index = 0;
ob_start();
foreach($article_data_list as $tmp) {
	$index++;
	$article_dat = new ArticleDat($tmp);
?>
		<div class="article_item">
			<div class="article_row">
				<div class="index"><?=$index?>/<?=$article_count?></div>
				<div class="title"><?=$article_dat->title?></div>
				<?
					if(!empty($article_dat->video_url) || !empty($article_dat->mp3)) {
				?>
				<img src="images/video.png" class="link" onClick="articleDetailMy('<?=$article_dat->id?>');">
				<?} else {?>
				<img src="images/picture.png" class="link" onClick="articleDetailMy('<?=$article_dat->id?>');">
				<?
					}
				?>
			</div>
			<div class="love_row">
				<img src="images/love2.png" onClick="deleteFavorite('article', '<?=$article_dat->id?>');">
			</div>
		</div>
<?
}
$html = ob_get_contents();
ob_end_clean();
print json_encode(array("word_count"=>$article_count, "html"=>$html));
?>