\system\plugins\widgets\diary\widget.php
<?php
/**
* Copy Right IJH.CC
* Each engineer has a duty to keep the code elegant
* Author @shzhrui<Anhuike@gmail.com>
* $Id: widget.php 2468 2013-12-24 02:04:32Z langzhong $
*/
class Widget_Diary extends Model
{
public function newitems(&$params){
$data['cfg_status'] = K::M('home/site')->get_status();
$params['tpl'] = 'newitems.html';
return $data;
}
public function index(&$params)
{
$data['limit'] = $params['limit'] ? $params['limit'] : 5;
$filter = array('audit'=>1);
if($params['city_id']){
$filter['city_id'] = (int)$params['city_id'];
}
$diary = K::M('diary/diary')->items($filter,array('diary_id'=>'DESC') , 1,$data['limit']);
$company_ids = array();
foreach($diary as $val){
if(!empty($val['company_id'])) $company_ids[$val['company_id']] = $val['company_id'];
}
if(!empty($company_ids)) $data['diary_company_list'] = K::M('company/company')->items_by_ids($company_ids);
$data['diary'] = $diary;
$params['tpl'] = 'index.html';
return $data;
}
public function right(&$params){
$data['limit'] = $params['limit'] ? $params['limit'] : 5;
$filter = array('audit'=>1);
if($params['city_id']){
$filter['city_id'] = (int)$params['city_id'];
}
$diary = K::M('diary/diary')->items($filter,array('diary_id'=>'DESC') , 1,$data['limit']);
$company_ids = array();
foreach($diary as $val){
if(!empty($val['company_id'])) $company_ids[$val['company_id']] = $val['company_id'];
}
if(!empty($company_ids)) $data['diary_company_list'] = K::M('company/company')->items_by_ids($company_ids);
$data['diary'] = $diary;
$params['tpl'] = 'right.html';
return $data;
}
}
\system\plugins\widgets\diary\index.html
<{foreach $data.diary as $item}>
<li>
<a title="<{$data.diary_company_list[$item.company_id].name|default:'--'}>" class="f14 red" target="_blank" href="<{link ctl='company' arg0=$item.company_id city=$data.diary_company_list[$item.company_id].city_id}>">[<{$data.diary_company_list[$item.company_id].sort_name|default:'--'}>]</a>
<font class="f14"> | </font>
<a target="_blank" href="<{link ctl='content:diaryDetail' arg0=$item.diary_id city=$item.city_id}>" title="<{$item.title}>" class="f14 black8"><{$item.title}> </a>
</li>
<{/foreach}>
\system\plugins\widgets\diary\newitems.html
<p class="mt20 ml20">
<span class="lt f22">日记分享</span>
<span class="rt mt10"><a href="<{link ctl='content:diary'}>" class="f12 black">更多>></a></span>
</p>
<div class="cl"></div>
<div class="rijifenxaing_l_ul">
<ul>
<{foreach from=$data.cfg_status item=item key=key name=loop}>
<{if $smarty.foreach.loop.index < 6}>
<li> <a target="_blank" href="<{link ctl='content:diary' arg0=$key}>"><{$item}></a></li>
<{/if}>
<{/foreach}>
</ul>
</div>
<div class="cl"></div>
<div class="rijifenxiang_content hauto mt10">
<{calldata mdl="diary/diary" order="pv_num:desc" limit="3"}>
<a title="<{$item.title}>" target="_blank" style="float: left; margin-right: 10px;" href="<{link ctl='content:diaryDetail' arg0=$item.diary_id}>"><img src="<{$pager.img}>/<{$item.face_pic}>" width="140" height="85"/></a>
<{/calldata}>
<div class="cl"></div>
<p class="h10 bodr_b"></p>
<div class="rijifenxiang_content_ul hauto">
<ul>
<{calldata mdl="diary/diary" order="diary_id:desc" limit="5"}>
<li><font>[<{$data.cfg_status[$item.status]}>]</font><a target="_blank" title="<{$item.title}>" href="<{link ctl='content:diaryDetail' arg0=$item.diary_id}>"><{$item.title}></a></li>
<{/calldata}>
</ul>
</div>
</div>
<div class="cl"></div>
<div class="h10"></div>
\system\plugins\widgets\diary\right.html
<ul>
<{foreach $data.diary as $item}>
<li>
<a title="<{$data.diary_company_list[$item.company_id].name|default:'--'}>" class="red" target="_blank" href="<{link ctl='company' arg0=$item.company_id}>">[<{$data.diary_company_list[$item.company_id].sort_name|default:'--'}>]</a>
<a target="_blank" href="<{link ctl='content:diaryDetail' arg0=$item.diary_id}>" title="<{$item.title}>" class="black"><{$item.title|cutstr:24:'..'}> </a>
</li>
<{/foreach}>
</ul>
\themes\default\diary\photo.html
<dl class="diary_items_photo">
<{foreach $data.photo as $item name=foo}>
<{if $smarty.foreach.foo.index == 0}>
<dt><a target="_blank" href="<{link ctl='diary:detail' arg0=$item.diary_id}>" rel="nofollow" ><img src="<{$pager.img}><{$item}>"> <a class="total">共<{$data.count}>张</a> </a></dt>
<{else if $smarty.foreach.foo.index <=3}>
<dt><a target="_blank" href="<{link ctl='diary:detail' arg0=$item.diary_id}>" rel="nofollow" ><img src="<{$pager.img}><{$item}>"> </a></dt>
<{/if}>
<{/foreach}>
</dl>
<p class="graycl"> <{if !$data.dateline}>暂时还没有日记<{else}><{$data.dateline|format}>前被回复<{/if}> </p>
|