<?php
/**
* 侧边栏组件、页面模块
*/
if(!defined('EMLOG_ROOT')) {exit('error!');}
?>
<?php
//底部友情链接
function links(){
global $CACHE;
$link_cache = $CACHE->readCache('link');
?>
<ol>
<h2>友情链接</h2>
<?php foreach($link_cache as $value): ?>
<li style="width:135px;display: block;overflow: hidden;float:left;height:20px;"><a target="_blank" href="<?php echo $value['url']; ?>"><?php echo $value['link']; ?></a></li>
<?php endforeach; ?>
</ol>
<?php }?>
<?php
//9篇栏目文章列表
function get_list($sort){
$db = MySql::getInstance();
?>
<?php
$sql1 = "SELECT sortname FROM ".DB_PREFIX."sort WHERE sid=".$sort;
$s = $db->query($sql1);
$sortname = $db->fetch_array($s);
?>
<?php
$sql2 = "SELECT gid,title,date FROM ".DB_PREFIX."blog WHERE sortid=".$sort." AND hide='n' ORDER BY `date` DESC LIMIT 9";
$list = $db->query($sql2);
while($row = $db->fetch_array($list)){
?>
<li><span><strong><?php echo $row['gid'];?></strong></span><a href="<?php echo Url::log($row['gid']);?>"><?php echo subString($row['title'],0,23);?></a></li>
<?php }?>
<?php } ?>
<?php
//10篇底部最新文章列表
function newlog(){
$db = MySql::getInstance();
?>
<?php
$sql = "SELECT gid,title,date FROM ".DB_PREFIX."blog ORDER BY `date` DESC LIMIT 5";
$list = $db->query($sql);
while($row = $db->fetch_array($list)){
?>
<dl>
<dd><a href="<?php echo Url::log($row['gid']);?>"><?php echo subString($row['title'],0,35);?></a></dd>
</dl>
<?php }?>
<?php } ?>
<?php
//10底部随机文章
function randlog(){
$db = MySql::getInstance();
?>
<?php
$sql = "SELECT gid,title,date FROM ".DB_PREFIX."blog ORDER BY RAND() LIMIT 6";
$list = $db->query($sql);
while($row = $db->fetch_array($list)){
?>
<li><a href="<?php echo Url::log($row['gid']);?>"><?php echo subString($row['title'],0,15);?></a></li>
<?php }?>
<?php } ?>
<?php
//widget:blogger
function widget_blogger($title){
global $CACHE;
$user_cache = $CACHE->readCache('user');
$name = $user_cache[1]['mail'] != '' ? "<a href=\"mailto:".$user_cache[1]['mail']."\">".$user_cache[1]['name']."</a>" : $user_cache[1]['name'];?>
<li>
<h3><span><?php echo $title; ?></span></h3>
<ul id="bloggerinfo">
<div id="bloggerinfoimg">
<?php if (!empty($user_cache[1]['photo']['src'])): ?>
<img src="<?php echo BLOG_URL.$user_cache[1]['photo']['src']; ?>" width="<?php echo $user_cache[1]['photo']['width']; ?>" height="<?php echo $user_cache[1]['photo']['height']; ?>" alt="blogger" />
<?php endif;?>
</div>
<p><b><?php echo $name; ?></b>
<?php echo $user_cache[1]['des']; ?></p>
</ul>
</li>
<?php }?>
<?php
//widget:日历
function widget_calendar($title){ ?>
<li>
<h3><span><?php echo $title; ?></span></h3>
<div id="calendar">
</div>
<script>sendinfo('<?php echo Calendar::url(); ?>','calendar');</script>
</li>
<?php }?>
<?php
//widget:标签
function widget_tag($title){
global $CACHE;
$tag_cache = $CACHE->readCache('tags');?>
<li>
<h3><span><?php echo $title; ?></span></h3>
<ul id="blogtags">
<?php foreach($tag_cache as $value): ?>
<span style="font-size:<?php echo $value['fontsize']; ?>pt; line-height:30px;">
<a href="<?php echo Url::tag($value['tagurl']); ?>" title="<?php echo $value['usenum']; ?> 篇文章"><?php echo $value['tagname']; ?></a></span>
<?php endforeach; ?>
</ul>
</li>
<?php }?>
<?php
//widget:分类
function widget_sort($title){
global $CACHE;
$sort_cache = $CACHE->readCache('sort'); ?>
<div class="sunnav">
<ul>
<?php foreach($sort_cache as $value): ?>
<li>
<a href="<?php echo Url::sort($value['sid']); ?>"><?php echo $value['sortname']; ?>(<?php echo $value['lognum'] ?>)</a>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php }?>
<?php
//widget:最新微语
function widget_twitter($title){
global $CACHE;
$newtws_cache = $CACHE->readCache('newtw');
$istwitter = Option::get('istwitter');
?>
<li>
<h3 style="color:#CCC"><span><?php echo $title; ?></span></h3>
<ul id="twitter">
<?php foreach($newtws_cache as $value): ?>
<?php $img = empty($value['img']) ? "" : '<a title="查看图片" class="t_img" href="'.BLOG_URL.str_replace('thum-', '', $value['img']).'" target="_blank"> </a>';?>
<li style="color:#999"><?php echo $value['t']; ?><?php echo $img;?><p style="color:#666"><?php echo smartDate($value['date']); ?></p></li>
<?php endforeach; ?>
<?php if ($istwitter == 'y') :?>
<p><a href="<?php echo BLOG_URL . 't/'; ?>">更多»</a></p>
<?php endif;?>
</ul>
</li>
<?php }?>
<?php
//widget:最新评论
function widget_newcomm($title){
global $CACHE;
$com_cache = $CACHE->readCache('comment');
?>
<li>
<h3 style="color:#CCC"><span><?php echo $title; ?></span></h3>
<ul id="newcomment">
<?php
foreach($com_cache as $value):
$url = Url::comment($value['gid'], $value['page'], $value['cid']);
?>
<li id="comment"><?php echo $value['name']; ?>
<br /><a href="<?php echo $url; ?>"><?php echo $value['content']; ?></a></li>
<?php endforeach; ?>
</ul>
</li>
<?php }?>
<?php
//widget:最新文章
function widget_newlog($title){
global $CACHE;
$newLogs_cache = $CACHE->readCache('newlog');
?>
<li>
<h3><span><?php echo $title; ?></span></h3>
<ul id="newlog">
<?php foreach($newLogs_cache as $value): ?>
<li><a href="<?php echo Url::log($value['gid']); ?>"><?php echo $value['title']; ?></a></li>
<?php endforeach; ?>
</ul>
</li>
<?php }?>
<?php
//widget:热门文章
function widget_hotlog($title){
$index_hotlognum = Option::get('index_hotlognum');
$Log_Model = new Log_Model();
$randLogs = $Log_Model->getHotLog($index_hotlognum);?>
<ol>
<h2><?php echo $title; ?></h2>
<?php foreach($randLogs as $value): ?>
<li><a href="<?php echo Url::log($value['gid']); ?>"><?php echo $value['title']; ?></a></li>
<?php endforeach; ?>
</ol>
<?php }?>
<?php
//widget:随机文章
function widget_random_log($title){
$index_randlognum = Option::get('index_randlognum');
$Log_Model = new Log_Model();
$randLogs = $Log_Model->getRandLog($index_randlognum);?>
<li>
<h3><span><?php echo $title; ?></span></h3>
<ul id="randlog">
<?php foreach($randLogs as $value): ?>
<li><a href="<?php echo Url::log($value['gid']); ?>"><?php echo $value['title']; ?></a></li>
<?php endforeach; ?>
</ul>
</li>
<?php }?>
<?php
//widget:搜索
function widget_search($title){ ?>
<li>
<h3><span><?php echo $title; ?></span></h3>
<ul id="logsearch">
<form name="keyform" method="get" action="<?php echo BLOG_URL; ?>index.php">
<input name="keyword" class="search" type="text" />
</form>
</ul>
</li>
<?php } ?>
<?php
//widget:归档
function widget_archive($title){
global $CACHE;
$record_cache = $CACHE->readCache('record');
?>
<li>
<h3><span><?php echo $title; ?></span></h3>
<ul id="record">
<?php foreach($record_cache as $value): ?>
<li><a href="<?php echo Url::record($value['date']); ?>"><?php echo $value['record']; ?>(<?php echo $value['lognum']; ?>)</a></li>
<?php endforeach; ?>
</ul>
</li>
<?php } ?>
<?php
//widget:自定义组件
function widget_custom_text($title, $content){ ?>
<li>
<h3><span><?php echo $title; ?></span></h3>
<ul>
<?php echo $content; ?>
</ul>
</li>
<?php } ?>
<?php
//widget:友情链接
function widget_link($title){
global $CACHE;
$link_cache = $CACHE->readCache('link');
?>
<li>
<h3><span><?php echo $title; ?></span></h3>
<ul id="link">
<?php foreach($link_cache as $value): ?>
<li style="width:115px;display: block;overflow: hidden;float:left;height:20px;"><a href="<?php echo $value['url']; ?>" title="<?php echo $value['des']; ?>" target="_blank"><?php echo $value['link']; ?></a></li>
<?php endforeach; ?>
</ul>
</li>
<?php }?>
<?php
//blog:导航
function blog_navi(){
global $CACHE;
$navi_cache = $