Example #1
0
/**
 * 对字段数据处理
 * a) 规范链接
 * b) 图片地址等
 * @param $field 文章数据
 * @return array
 */
function content_field($field)
{
    $cache = S('field' . $field['mid']);
    foreach ($field as $name => $value) {
        if (!isset($cache[$name])) {
            continue;
        }
        switch ($cache[$name]['field_type']) {
            case 'thumb':
                $field[$name] = $field[$name] ? __ROOT__ . '/' . $field[$name] : __ROOT__ . '/HDCMS/Static/image/thumb.jpg';
                break;
            case 'image':
                $field[$name] = $field[$name] ? __ROOT__ . '/' . $field[$name] : '';
                break;
            case 'images':
                $images = unserialize($field[$name]);
                if (is_array($images)) {
                    foreach ($images as $id => $data) {
                        $images[$id]['url'] = __ROOT__ . '/' . $data['path'];
                    }
                }
                $field[$name] = $images;
                break;
            case 'files':
                $files = unserialize($field[$name]);
                if (is_array($files)) {
                    foreach ($files as $id => $data) {
                        if (!empty($data['path'])) {
                            $pathinfo = pathinfo(basename($data['path']));
                            $files[$id]['url'] = U("Index/Download/download", array('cid' => $field['cid'], 'filename' => $pathinfo['filename']));
                        }
                    }
                }
                $field[$name] = $files;
                break;
        }
    }
    //头像
    if (empty($field['icon'])) {
        $field['icon'] = __STATIC__ . "/image/user.png";
    }
    //URL地址
    $field['url'] = Url::content($field);
    //栏目图片
    if (empty($field['catimage'])) {
        $field['catimage'] = __ROOT__ . '/' . $field['catimage'];
    }
    //栏目url
    $field['caturl'] = Url::category($field);
    //发表时间
    $field['time'] = date("Y-m-d", $field['addtime']);
    //多久前发表
    $field['date_before'] = date_before($field['addtime']);
    return $field;
}
Example #2
0
 public function content()
 {
     $mid = Q('mid', 0, 'intval');
     $cid = Q('cid', 0, 'intval');
     $aid = Q('aid', 0, 'intval');
     if (!$mid || !$cid || !$aid) {
         $this->error('参数错误', __ROOT__);
     }
     $ContentModel = new Content($mid);
     $field = $ContentModel->find($aid);
     if ($field) {
         $field['time'] = date("Y/m/d", $field['addtime']);
         $field['date_before'] = date_before($field['addtime']);
         $field['commentnum'] = M("comment")->where("cid=" . $cid . " AND aid=" . $aid)->count();
         $this->assign('hdcms', $field);
         $this->display($field['template']);
     }
 }
Example #3
0
                      	</a>
                      	<a href="http://localhost/v5/cmsweb/hdcms/index.php?<?php 
            echo $d['domain'];
            ?>
">
                      		<?php 
            echo $d['username'];
            ?>
                      	</a>
                      <?php 
            echo $d['content'];
            ?>
                    </div>
                    <div class="right-action">
                        <span class="time"> <?php 
            echo date_before($d['addtime']);
            ?>
</span>
                    </div>
                </li>
            <?php 
            $hd["list"]["d"]["first"] = false;
        }
    }
} else {
    echo "";
}
?>
        </ul>
    </section>
    <div class="page1 h30">
Example #4
0
$where[] = $table . '.content_state=1';
//------------------关联content_flag表后有重复数据,去掉重复的文章---------------------
$db->group = $table . '.aid';
//---------------------------------指定显示条数--------------------------------------
$db->limit(5);
//-----------------------------------获取数据----------------------------------------
$result = $db->where($where)->all();
if ($result) {
    foreach ($result as $index => $field) {
        $field['index'] = $index + 1;
        $field['title'] = mb_substr($field['title'], 0, 22, 'utf8');
        $field['title'] = $field['color'] ? "<span style='color:" . $field['color'] . "'>" . $field['title'] . "</span>" : $field['title'];
        $field['description'] = mb_substr($field['description'], 0, 80, 'utf-8');
        $field['time'] = date("Y-m-d", $field['updatetime']);
        $field['icon'] = empty($field['icon']) ? "http://localhost/v5/cmsweb/hdcms/data/image/user/150.png" : 'http://localhost/v5/cmsweb/hdcms/' . $field['icon'];
        $field['date_before'] = date_before($field['addtime']);
        $field['thumb'] = 'http://localhost/v5/cmsweb/hdcms' . '/' . $field['thumb'];
        $field['caturl'] = Url::getCategoryUrl($field);
        $field['url'] = Url::getContentUrl($field);
        if ($field['new_window'] || $field['redirecturl']) {
            $field['link'] = '<a href="' . $field['url'] . '" target="_blank">' . $field['title'] . '</a>';
        } else {
            $field['link'] = '<a href="' . $field['url'] . '">' . $field['title'] . '</a>';
        }
        ?>
							<section>
								<a href="<?php 
        echo $field['url'];
        ?>
">
									<h3><?php 
Example #5
0
                                                ?>
                                                            <div class="hd-author-info">
                                                            <span class="hd-comment-author">
                                                                <a href="http://localhost/v5/cmsweb/hdcms/index.php?<?php 
                                                echo $d['domain'];
                                                ?>
"><?php 
                                                echo $d['nickname'];
                                                ?>
</a>&nbsp;&nbsp;
                                                            </span>
                                                                <?php 
                                                echo date('Y-m-d H:i', $d['pubtime']);
                                                ?>
                                                                (<?php 
                                                echo date_before($d['pubtime']);
                                                ?>
)
                                                            </div>
                                                        </div>
                                                    </li>
                                                <?php 
                                                $hd["list"]["a"]["first"] = false;
                                            }
                                        }
                                    } else {
                                        echo "";
                                    }
                                    ?>
                                            </ul>
                                        </li>