码桶

发现社区成员的开源项目

飞扬 / LB_Down 公开
main
LB_Down/newest.php
newest.php1.7 KB
<?php
/**
 * 今日更新
 *
 * 
 *
 * @package custom
 */

if (!defined('__TYPECHO_ROOT_DIR__')) exit;

$db = \Typecho\Db::get();
$prefix = $db->getPrefix();
$adapter = $db->getAdapterName();
$isMysql = (strpos($adapter, 'Mysql') !== false || strpos($adapter, 'Pdo_Mysql') !== false);
$q = $isMysql ? '`' : '"';
$recentRows = $db->fetchAll($db->select()->from('table.contents')
    ->where('type = ?', 'post')
    ->where('status = ?', 'publish')
    ->where('created >= ?', strtotime('today'))
    ->order('created', \Typecho\Db::SORT_DESC)
    ->limit(40));
$recentWidget = \Widget\Contents\Post\Recent::alloc();

$this->need('header.php');
?>

<div class="content-area">
    <article class="page-content">
        <h1 class="page-title"><?php $this->title(); ?></h1>
        <div class="page-body fmt">
            <?php $this->content(); ?>
        </div>

        
        <div class="newest-page-list">
            <?php if ($recentRows): ?>
            <div class="resource-list" style="margin-top:20px;">
                <?php $idx = 0; foreach ($recentRows as $row): ?>
                    <?php $recentWidget->push($row); ?>
                    <?php lb_resource_card($recentWidget, $idx++); ?>
                <?php endforeach; ?>
            </div>
            <?php else: ?>
                <div class="no-results">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                        <circle cx="11" cy="11" r="8"/>
                        <line x1="21" y1="21" x2="16.65" y2="16.65"/>
                    </svg>
                    <p>暂无更新内容</p>
                </div>
            <?php endif; ?>
        </div>
    </article>
</div>

<?php $this->need('footer.php'); ?>