本文整理汇总了PHP中BaseAction::html_init方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseAction::html_init方法的具体用法?PHP BaseAction::html_init怎么用?PHP BaseAction::html_init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseAction
的用法示例。
在下文中一共展示了BaseAction::html_init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
ob_start();
//用于生成静态HTML
$is_build = C('IS_BUILD_HTML');
$static_file = './Html/' . cookie('think_template') . '/index.html';
$path = './IndexAction.class.php';
$php_file = basename($path);
parent::html_init($static_file, $php_file, $is_build);
$this->assign('cur_menu', 0);
//网站头部
R('Public/head');
R('Public/py_link');
//查询数据库,读取缓存
$config = F('basic', '', './Web/Conf/');
//------------企业网站的东东----------------
//最新公告
parent::lists(20, 0, 5, 'list_gao');
//最新新闻
parent::lists(18, 0, 9, 'list_new');
//菜单目录
parent::children_dir(22);
//------------文章系统的东东-------------
if (cookie('think_template') == 'xinwen') {
$type = M('type');
$article = M('article');
//网站公告
$notice = $article->where('status=1 AND typeid=' . $config['noticeid'])->field('aid,title')->order('addtime desc')->limit($config['noticenum'])->select();
$this->assign('notice', $notice);
unset($notice);
//首页幻灯内容
//先模式判断
if ($config['flashmode'] == 0) {
$hd = M('flash');
$hd = $hd->where('status=1')->order('rank asc')->limit($config['ishomeimg'])->select();
foreach ($hd as $k => $v) {
$hd[$k]['imgurl'] = __PUBLIC__ . "/Uploads/hd/" . $v['pic'];
if (empty($v['pic'])) {
$hd[$k]['imgurl'] = TMPL_PATH . cookie('think_template') . "/images/nopic.png";
}
}
} else {
$hd = $article->where('isflash=1')->field('title,aid,imgurl')->order('addtime desc')->limit($config['ishomeimg'])->select();
//判断处理图片地址
foreach ($hd as $k => $v) {
$hd[$k]['url'] = U("articles/" . $v['aid']);
if (empty($v['imgurl'])) {
$hd[$k]['imgurl'] = TMPL_PATH . cookie('think_template') . "/images/nopic.png";
}
}
}
$this->assign('flash', $hd);
unset($flash);
//首页top 2
$map['istop'] = 1;
$map['ishot'] = 1;
$map['status'] = 1;
$top = $article->where($map)->field('aid,title,note')->order('addtime desc')->limit(2)->select();
$top[0]['title'] = msubstr($top[0]['title'], 0, 18, 'utf-8');
$top[0]['note'] = msubstr($top[0]['note'], 0, 50, 'utf-8');
$top[1]['title'] = msubstr($top[1]['title'], 0, 18, 'utf-8');
$top[1]['note'] = msubstr($top[1]['note'], 0, 50, 'utf-8');
$this->assign('top', $top);
unset($top, $map);
//首页栏目内容
$list = $type->where('isindex=1')->order('irank asc')->field('typeid,typename,indexnum')->select();
foreach ($list as $k => $v) {
$data['status'] = 1;
$data['typeid'] = $v['typeid'];
$k % 2 == 0 ? $list[$k]['i'] = 0 : ($list[$k]['i'] = 1);
//方便定位广告,引入p
$list[$k]['p'] = $k;
$list[$k]['article'] = $article->where($data)->order('addtime desc')->field('title,aid,titlecolor')->limit($v['indexnum'])->select();
}
$this->assign('list', $list);
unset($list);
//首页投票
$this->vote($config['indexvote']);
//释放内存
unset($type, $article);
}
//------------文章系统的东东结束-------------
//友情链接
$link = M('link');
$map['islogo'] = 0;
$map['status'] = 1;
$lk = $link->where($map)->field('url,title')->order('rank')->select();
$map['islogo'] = 1;
$logolk = $link->where($map)->field('url,title,logo')->order('rank')->select();
$this->assign('link', $lk);
$this->assign('logolink', $logolk);
unset($link, $logolk, $map);
//输出模板
$this->display(TMPL_PATH . cookie('think_template') . '/index.html');
if ($is_build == 1) {
$c = ob_get_contents();
if (!file_exists(dirname($static_file))) {
@mkdir(dirname($static_file));
}
file_put_contents($static_file, $c);
//.........这里部分代码省略.........
示例2: index
public function index()
{
if (!isset($_GET['aid'])) {
$this->error('非法操作');
}
inject_check($_GET['aid']);
inject_check($_GET['p']);
$aid = intval($_GET['aid']);
//读取数据库和缓存
ob_start();
//用于生成静态HTML
$is_build = C('IS_BUILD_HTML');
//允许参数
$allow_param = array('p', 'keyword');
$static_file = './Html/' . cookie('think_template') . '/articles/' . $aid;
$mid_str = '';
if (count($_REQUEST) > 1) {
foreach ($_REQUEST as $k => $v) {
if ($k != 'aid' && in_array($k, $allow_param)) {
$mid_str .= '/' . $k . '/' . md5($v);
}
}
}
$static_file .= $mid_str . '.html';
$path = './ArticleAction.class.php';
$php_file = basename($path);
parent::html_init($static_file, $php_file, $is_build);
//以下是动态代码
$article = M('article');
$config = F('basic', '', './Web/Conf/');
$page_model = 'page/page_default.html';
//相关判断
$alist = $article->where('aid=' . $aid)->find();
if (!$alist) {
alert('文章不存在或已删除!', __APP__);
}
if ($alist['islink'] == 1) {
Header('Location:' . $alist['linkurl']);
}
if ($alist['status'] == 0) {
alert('文章未审核!', __APP__);
}
//阅读权限
if ($config['isread'] == 1) {
$uvail = explode(',', $_SESSION['dami_uservail']);
if (!in_array($alist['typeid'], $uvail)) {
alert('对不起您没有阅读改文章的权限!', __APP__);
}
}
$this->assign('title', $alist['title']);
parent::tree_dir($alist['typeid'], 'tree_list');
$type = M('type');
$list = $type->where('typeid=' . intval($alist['typeid']))->find();
if ($list) {
$pid = get_first_father($list['typeid']);
$cur_menu = get_field('type', 'typeid=' . $pid, 'drank');
$this->assign('cur_menu', $cur_menu);
$this->assign('type', $list);
}
$a = M('type')->where('typeid=' . $alist['typeid'])->getField('page_path');
if ($a != '' && file_exists(TMPL_PATH . cookie('think_template') . '/' . $a)) {
$page_model = $a;
}
//网站头部
R('Public/head');
R('Public/py_link');
//统计处理
if ($alist['status'] == 1) {
$map['hits'] = $alist['hits'] + 1;
$article->where('aid=' . $aid)->save($map);
}
//注销map
unset($map);
$alist['hits'] += 1;
//关键字替换
$alist['content'] = $this->key($alist['content']);
//鼠标轮滚图片
if ($config['mouseimg'] == 1) {
$alist['content'] = $this->mouseimg($alist['content']);
}
//文章内分页处理
if ($alist['pagenum'] == 0) {
//手动分页
$alist['content'] = $this->diypage($alist['content']);
} else {
//自动分页
$alist['content'] = $this->autopage($alist['pagenum'], $alist['content']);
}
//文章内投票
$this->vote($alist['voteid']);
//心情投票
$url = __ROOT__;
//用于心情js的根路径变量
$this->assign('url', $url);
//文章上下篇
$map['status'] = 1;
$map['typeid'] = $alist['typeid'];
$map['aid'] = array('lt', $alist['aid']);
$up = $article->where($map)->field('aid,title')->order('addtime desc')->limit(1)->find();
//dump($article->getLastsql());
//.........这里部分代码省略.........
示例3: index
public function index()
{
inject_check($_GET['typeid']);
inject_check($_GET['p']);
//读取数据库&判断
$typeid = (int) $_GET['typeid'];
$list_model = 'list/list_default.html';
$type = M('type');
$list = $type->where('typeid=' . intval($_GET['typeid']))->find();
if (!$list) {
$this->error('栏目不存在!');
} else {
//当前选中菜单
$pid = get_first_father($list['typeid']);
$cur_menu = get_field('type', 'typeid=' . $pid, 'drank');
$this->assign('cur_menu', $cur_menu);
if ($list['list_path'] != '' && file_exists(TMPL_PATH . cookie('think_template') . '/' . $list['list_path'])) {
$list_model = $list['list_path'];
}
}
ob_start();
//用于生成静态HTML
$is_build = C('IS_BUILD_HTML');
//允许参数
$allow_param = array('p', 'author_id');
$static_file = './Html/' . cookie('think_template') . '/lists/' . $typeid;
$mid_str = '';
if (count($_REQUEST) > 1) {
foreach ($_REQUEST as $k => $v) {
if ($k != 'typeid' && in_array($k, $allow_param)) {
$mid_str .= '/' . $k . '/' . md5($v);
}
}
}
$static_file .= $mid_str . '.html';
$path = './ListAction.class.php';
$php_file = basename($path);
parent::html_init($static_file, $php_file, $is_build);
//以下是动态代码
//家族树与子孙树
parent::tree_dir($typeid, 'tree_list');
parent::children_dir($typeid, 'child_list');
//栏目基本信息封装
$this->assign('title', $list['typename']);
$this->assign('type', $list);
//栏目导航
$config = F('basic', '', './Web/Conf/');
if ($config['listshowmode'] == 1) {
$map['fid'] = $list['fid'];
} else {
$map['fid'] = intval($_GET['typeid']);
}
$map['islink'] = 0;
$nav = $type->where($map)->field('typeid,typename')->select();
$this->assign('dh', $nav);
//第一次释放内存
$pernum = isset($list['pernum']) && intval($list['pernum']) > 0 ? intval($list['pernum']) : $config['artlistnum'];
unset($list, $nav, $map);
$list_server = M('admin')->where('is_client=1')->select();
$this->assign('list_server', $list_server);
$vip_sn = M('vip_mess')->order('id desc')->getField('vip_sn');
$this->assign('vip_sn', $vip_sn);
//网站头部与友情链接
R('Public/head');
R('Public/py_link');
//查询数据库和缓存
$article = D('ArticleView');
//封装条件
$map['status'] = 1;
//导入分页类
import('ORG.Util.Page');
//准备工作
$arr = get_children($typeid);
$map['article.typeid'] = array('in', $arr);
//用户阅读权限
if ($config['isread'] == 1) {
$map['_string'] = 'article.typeid in(' . $_SESSION['dami_uservail'] . ')';
}
//分页处理
$count = $article->where($map)->count();
$p = new Page($count, $pernum);
$p->setConfig('prev', '上一页');
$p->setConfig('header', '篇文章');
$p->setConfig('first', '首 页');
$p->setConfig('last', '末 页');
$p->setConfig('next', '下一页');
if (check_wap()) {
$temp_str = "%first%%upPage%%downPage%%end%";
} else {
$temp_str = "%first%%upPage%%prePage%%linkPage%%nextPage%%downPage%%end%\n\t\t<select name='select' onChange='javascript:window.location.href=(this.options[this.selectedIndex].value);'>%allPage%</select>共<font color='#CD4F07'><b>%totalRow%</b></font>篇 " . $config['artlistnum'] . "篇/每页";
}
$p->setConfig('theme', $temp_str);
//数据查询
$alist = $article->where($map)->order('istop desc,addtime desc')->limit($p->firstRow . ',' . $p->listRows)->select();
//echo $article->getLastSql();
//封装变量
$this->assign('page', $p->show());
$this->assign('list', $alist);
//释放内存
unset($article, $type, $p, $tlist, $alist);
//.........这里部分代码省略.........