本文整理汇总了PHP中ContentModel::Get_Content方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentModel::Get_Content方法的具体用法?PHP ContentModel::Get_Content怎么用?PHP ContentModel::Get_Content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentModel
的用法示例。
在下文中一共展示了ContentModel::Get_Content方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Action
public function Action()
{
global $templates;
switch ($_GET['action']) {
case 'show':
$templates->assgin('title', '文档列表');
$templates->assgin('show', true);
$nav = new NavModel();
$id = $nav->Get_All_Childid();
foreach ($id as $value) {
$arr[] = $value->id;
}
$nav_id = implode(',', $arr);
$content = new ContentModel();
$content->nav = $nav_id;
$templates->assgin('Show_Content', $content->Get_Content());
//显示所有的content
$this->Nav();
//显示所有的导航,select标签
if (isset($_GET['nav']) && $_GET['send'] == '刷选') {
//开始刷选
if ($_GET['nav'] != 0) {
//不为零
$content->nav = $_GET['nav'];
} else {
$content->nav = $nav_id;
//为零的话,默认全部
}
$templates->assgin('Show_Content', $content->Get_Content());
//显示所有的content
}
break;
case 'update':
if ($_POST['send'] == '修改文档') {
$this->model->id = $_POST['id'];
$this->Get_Post();
$this->model->Update_Content() ? Tool::alertLocation('文档修改成功', 'content.php?action=show') : Tool::alertBack('文档修改失败');
}
$templates->assgin('title', '修改文档');
$templates->assgin('update', true);
if (isset($_GET['id'])) {
$content = new ContentModel();
$content->id = $_GET['id'];
$object = $content->Get_One_Content();
if (!$object) {
Tool::alertBack('文档不存在');
}
$templates->assgin('titlec', $object->title);
$this->attr($object->attr);
$this->Nav($object->nav);
$this->readlimit($object->read_limit);
$this->color($object->color);
$this->sort($object->sort);
$this->commend($object->commend);
$templates->assgin('id', $object->id);
$templates->assgin('tag', $object->tag);
$templates->assgin('keyword', $object->keyword);
$templates->assgin('thumbnail', $object->thumbnail);
$templates->assgin('source', $object->source);
$templates->assgin('author', $object->author);
$templates->assgin('info', $object->info);
$templates->assgin('content', $object->content);
$templates->assgin('read_count', $object->read_count);
$templates->assgin('gold', $object->gold);
$templates->assgin('color', $object->color);
} else {
Tool::alertBack('非法操作');
}
break;
case 'add':
if (isset($_POST['send'])) {
$this->Get_Post();
$affect = $this->model->Add_Content();
if ($affect == 1) {
Tool::alertLocation('添加文档成功', '?action=show');
} else {
Tool::alertBack('警告:文档添加失败');
}
}
$templates->assgin('title', '新增文档');
$templates->assgin('add', true);
$this->Nav();
break;
case 'delete':
if (isset($_GET['id'])) {
$this->model->id = $_GET['id'];
$this->model->Delete_Content() ? Tool::alertLocation('文档删除成功', 'content.php?action=show') : Tool::alertBack('文档删除失败');
}
break;
default:
echo '非法操作';
break;
}
}
示例2: Get_Contentlist
private function Get_Contentlist()
{
global $templates;
$content = new ContentModel();
$nav = new NavModel();
$nav->id = $_GET['id'];
$object_child = $nav->selectchildNav_nolimit();
//根据父导航ld找到子导航
foreach ($object_child as $value_child) {
$id[] = $value_child->id;
}
if ($object_child) {
$in = implode(',', $id);
$content->nav = $in;
//sQL语句中IN关键字
} else {
$content->nav = $_GET['id'];
}
$countArr = $content->Get_Contentlist();
$count = $countArr->c;
//得到记录数
$page = new Page($count, PAGE_SIZE);
$content->limit = $page->limit;
//注入limit值
$templates->assgin('page', $page->Show_Page_Num());
//显示分页
$object = $content->Get_Content();
//获取所有的content
foreach ($object as $value) {
$value->title = Tool::Sub_Str($value->title, 15);
//对title进行截取
$value->info = Tool::Sub_Str($value->info, 120);
//对info进行截取
if (empty($value->thumbnail)) {
$value->thumbnail = 'images/none.jpg';
}
}
$templates->assgin('AllContent', $object);
//注入模板,显示content
//列出本月推荐
$object_rec = $content->Month_Rec();
if ($object_rec) {
foreach ($object_rec as $value) {
$value->title = Tool::Sub_Str($value->title, 15);
$value->date = date('m-d', strtotime($value->date));
//将时间格式转换一下
}
}
$templates->assgin('Month_Rec', $object_rec);
//注入模板,显示本月推荐
//列出本月热点
$object_hot = $content->Month_Hot();
if ($object_hot) {
foreach ($object_hot as $value) {
$value->title = Tool::Sub_Str($value->title, 15);
$value->date = date('m-d', strtotime($value->date));
//将时间格式转换一下
}
}
$templates->assgin('Month_Hot', $object_hot);
//注入模板,显示本月热点
//列出本月图文(含有图片的wenzha)
$object_pic = $content->Month_Pic();
if ($object_pic) {
foreach ($object_pic as $value) {
$value->title = Tool::Sub_Str($value->title, 15);
$value->date = date('m-d', strtotime($value->date));
//将时间格式转换一下
}
}
$templates->assgin('Month_pic', $object_pic);
//注入模板,显示本月热点
}