本文整理汇总了PHP中to_sqls函数的典型用法代码示例。如果您正苦于以下问题:PHP to_sqls函数的具体用法?PHP to_sqls怎么用?PHP to_sqls使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了to_sqls函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* 删除队列信息
*/
public function delete() {
$idarr = isset($_POST['id']) ? $_POST['id'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
$where = to_sqls($idarr, '', 'id');
if ($this->db->delete($where)) {
showmessage(L('operation_success'), HTTP_REFERER);
} else {
showmessage(L('operation_failure'), HTTP_REFERER);
}
}
示例2: listinfo
/**
* 查询多条数据并分页
* @param $where
* @param $order
* @param $page
* @param $pagesize
* @return unknown_type
*/
public final function listinfo($where = '', $order = '', $page = 1, $pagesize = 20, $key = '', $setpages = 10, $urlrule = '', $array = array())
{
$where = to_sqls($where);
$this->number = $this->count($where);
$page = max(intval($page), 1);
$offset = $pagesize * ($page - 1);
$this->pages = pages($this->number, $page, $pagesize, $urlrule, $array, $setpages);
$array = array();
return $this->select($where, '*', "{$offset}, {$pagesize}", $order, '', $key);
}
示例3: listinfo
/**
* 查询多条数据并分页
* @param $where
* @param $order
* @param $page
* @param $pagesize
* @return unknown_type
*/
final public function listinfo($where = '', $order = '', $page = 1, $pagesize = 20, $key='', $setpages = 10,$urlrule = '',$array = array(), $data = '*') {
$where = to_sqls($where);
$this->number = $this->count($where);
$page = max(intval($page), 1);
$offset = $pagesize*($page-1);
$this->pages = pages($this->number, $page, $pagesize, $urlrule, $array, $setpages);
$array = array();
if ($this->number > 0) {
return $this->select($where, $data, "$offset, $pagesize", $order, '', $key);
} else {
return array();
}
}
示例4: init
/**
* 首页
*/
public function init()
{
if (isset($_POST['dosubmit'])) {
$denyusername = isset($_POST['denyusername']) ? new_stripslashes(trim($_POST['denyusername'])) : '';
$denyemail = isset($_POST['denyemail']) ? new_stripslashes(trim($_POST['denyemail'])) : '';
$denyemaildata = array2string(explode("\r\n", $denyemail));
$denyusernamedata = array2string(explode("\r\n", $denyusername));
$this->db->insert(array('name' => 'denyemail', 'data' => $denyemaildata), 1, 1);
$this->db->insert(array('name' => 'denyusername', 'data' => $denyusernamedata), 1, 1);
/*写入缓存*/
setcache('settings', array('denyemail' => explode("\r\n", $denyemail), 'denyusername' => explode("\r\n", $denyusername)));
showmessage(L('operation_success'), HTTP_REFERER);
}
$where = to_sqls(array('denyemail', 'denyusername'), '', 'name');
$settingarr = $this->db->listinfo($where);
foreach ($settingarr as $v) {
$setting[$v['name']] = string2array($v['data']);
}
include $this->admin_tpl('system');
}
示例5: get_all
public final function get_all($data = '*', $from = '', $where = '', $order = '', $limit = '')
{
if (!$from) {
$from = $this->table_name;
}
$sql = 'SELECT ' . $data . ' FROM ' . $from;
if ($where) {
$where = to_sqls($where);
$sql .= ' WHERE ' . $where;
}
if ($order) {
$sql .= ' ORDER BY ' . $order;
}
if ($limit) {
$limitNums = explode(',', $limit);
$sql .= ' LIMIT ' . intval($limitNums[0]) . ',' . $limitNums[1];
}
$arr = $this->selectBySql($sql);
return $arr;
}
示例6: my_listinfo
public final function my_listinfo($where = '', $order = '', $page = 1, $pagesize = 20, $key = '', $setpages = 10, $urlrule = '', $array = array())
{
if (is_array($where)) {
$number = $this->query('select count(*) as num ' . substr($where['sql'], strpos($where['sql'], 'from')));
$num = $this->fetch_array($number);
$this->number = $num[0]['num'];
} else {
$where = to_sqls($where);
$this->number = $this->count($where);
}
$page = max(intval($page), 1);
$offset = $pagesize * ($page - 1);
$this->pages = my_pages($this->number, $page, $pagesize, $urlrule, $array, $setpages);
$array = array();
if ($this->number > 0) {
if (is_array($where)) {
return $this->queryAll($where['sql'] . " order by {$order} limit {$offset}, {$pagesize}");
} else {
return $this->select($where, '*', "{$offset}, {$pagesize}", $order, '', $key);
}
} else {
return array();
}
}
示例7: getSql
function getSql($avs, $siteID)
{
//properties
$num = intval($avs['totalNum']);
$start = $avs['startNum'] == null ? 0 : intval($avs['startNum']) - 1;
$channelSql = '';
if ($avs['channelIndex']) {
$channelObj = bpBase::loadAppClass('channelObj', 'channel', 1);
$thisChannel = $channelObj->getChannelByIndex($avs['channelIndex'], 1);
$channelids = array();
if (intval($thisChannel->id)) {
$channelSql = ' AND A.channel_id=' . $thisChannel->id;
array_push($channelids, $thisChannel->id);
if ($avs['scope'] && $avs['scope'] == 'children') {
$channels = $channelObj->getChannelsByParentID($thisChannel->id);
if ($channels) {
foreach ($channels as $c) {
array_push($channelids, $c->id);
}
}
}
$channelSql = ' AND ' . to_sqls($channelids, '', 'A.channel_id');
}
//
}
if (!intval($avs['city'])) {
return 'SELECT A.autoid,A.id,A.site,A.link,A.externallink,A.thumb,CC.title,CC.title AS subtitle,A.title AS atitle,A.subtitle AS asubtitle,A.intro,A.source,A.author,A.time,A.keywords,A.pagecount FROM ' . TABLE_PREFIX . 'contentgroup_content CC,' . TABLE_PREFIX . 'article A WHERE groupid=' . $avs['id'] . ' AND A.id=CC.contentid' . $channelSql . ' AND A.time<{sysTime} ORDER BY CC.taxis DESC LIMIT ' . $start . ',' . $num;
} else {
return 'SELECT A.autoid,A.id,A.site,A.link,A.externallink,A.thumb,CC.title,CC.title AS subtitle,A.title AS atitle,A.subtitle AS asubtitle,A.intro,A.source,A.author,A.time,A.keywords,A.pagecount FROM ' . TABLE_PREFIX . 'contentgroup_content CC,' . TABLE_PREFIX . 'article A WHERE groupid=' . $avs['id'] . ' AND CC.geoid=' . intval($avs['city']) . ' AND A.id=CC.contentid' . $channelSql . ' AND A.time<{sysTime} ORDER BY CC.taxis DESC LIMIT ' . $start . ',' . $num;
}
}
示例8: init
//.........这里部分代码省略.........
$result = $this->db->listinfo($sql, 'searchid DESC', $page, 10);
}
//如果开启相关搜索功能
if ($setting['relationenble']) {
//如果关键词长度在8-16之间,保存关键词作为relation search
$this->keyword_db = pc_base::load_model('search_keyword_model');
if (strlen($q) < 17 && strlen($q) > 5 && !empty($segment_q)) {
$res = $this->keyword_db->get_one(array('keyword' => $q));
if ($res) {
//关键词搜索数+1
//$this->keyword_db->update(array('searchnums'=>'+=1'), array('keyword'=>$q));
} else {
//关键词转换为拼音
pc_base::load_sys_func('iconv');
$pinyin = gbk_to_pinyin($q);
if (is_array($pinyin)) {
$pinyin = implode('', $pinyin);
}
$this->keyword_db->insert(array('keyword' => $q, 'searchnums' => 1, 'data' => $segment_q, 'pinyin' => $pinyin));
}
}
//相关搜索
if (!empty($segment_q)) {
$relation_q = str_replace(' ', '%', $segment_q);
} else {
$relation_q = $q;
}
$relation = $this->keyword_db->select("MATCH (`data`) AGAINST ('%{$relation_q}%' IN BOOLEAN MODE)", '*', 10, 'searchnums DESC');
}
//如果结果不为空
if (!empty($result) || !empty($commend['id'])) {
//开启sphinx后文章id取法不同
if ($setting['sphinxenable']) {
foreach ($result as $_v) {
$sids[] = $_v['attrs']['id'];
}
} else {
foreach ($result as $_v) {
$sids[] = $_v['id'];
}
}
if (!empty($commend['id'])) {
$sids[] = $commend['id'];
}
$sids = array_unique($sids);
$where = to_sqls($sids, '', 'id');
//获取模型id
$model_type_cache = getcache('type_model_' . $siteid, 'search');
$model_type_cache = array_flip($model_type_cache);
$modelid = $model_type_cache[$typeid];
//是否读取其他模块接口
if ($modelid) {
$this->content_db->set_model($modelid);
/**
* 如果表名为空,则为黄页模型
*/
if (empty($this->content_db->model_tablename)) {
$this->content_db = pc_base::load_model('yp_content_model');
$this->content_db->set_model($modelid);
}
if ($setting['sphinxenable']) {
$data = $this->content_db->listinfo($where, 'id DESC', 1, $pagesize);
$pages = pages($totalnums, $page, $pagesize);
} else {
$data = $this->content_db->select($where, '*');
$pages = $this->db->pages;
$totalnums = $this->db->number;
}
//如果分词结果为空
if (!empty($segment_q)) {
$replace = explode(' ', $segment_q);
foreach ($replace as $replace_arr_v) {
$replace_arr[] = '<font color=red>' . $replace_arr_v . '</font>';
}
foreach ($data as $_k => $_v) {
$data[$_k]['title'] = str_replace($replace, $replace_arr, $_v['title']);
$data[$_k]['description'] = str_replace($replace, $replace_arr, $_v['description']);
}
} else {
foreach ($data as $_k => $_v) {
$data[$_k]['title'] = str_replace($q, '<font color=red>' . $q . '</font>', $_v['title']);
$data[$_k]['description'] = str_replace($q, '<font color=red>' . $q . '</font>', $_v['description']);
}
}
} else {
//读取专辑搜索接口
$special_api = pc_base::load_app_class('search_api', 'special');
$data = $special_api->get_search_data($sids);
$totalnums = count($data);
}
}
$execute_time = execute_time();
$pages = isset($pages) ? $pages : '';
$totalnums = isset($totalnums) ? $totalnums : 0;
$data = isset($data) ? $data : '';
include template('search', 'list');
} else {
include template('search', 'index');
}
}
示例9: getChannelTotalPage
/**
* 根据模板中的pageContents标签获取每页的数量值,仅生成静态页时有效
*
* @param unknown_type $channelID
* @return unknown
*/
public function getChannelTotalPage($channelID)
{
$tpl = bpBase::loadAppClass('template', 'template', 1);
//channel
$channelID = intval($channelID);
$thisChannel = $this->getChannelByID($channelID);
//分析模板
$template = $tpl->get($thisChannel->channeltemplate);
if (!file_exists(ABS_PATH . 'templatesCache' . DIRECTORY_SEPARATOR . $template->id . '.parsed.tpl.php')) {
$tpl->createChannelPageR($channelid);
}
//只有生成静态页的情况下,下面的代码才有效
$totalPage = 1;
if (file_exists(ABS_PATH . '/templatesCache/' . $template->id . '.tags.tpl.php')) {
@(require ABS_PATH . '/templatesCache/' . $template->id . '.tags.tpl.php');
$pageSize = 20;
//判断是否有分页标签
$isPagination = false;
if ($tagsArr) {
foreach ($tagsArr as $t) {
if ($t['name'] == 'pageContents') {
//
$isPagination = true;
$pageSize = $t['avs']['pageNum'];
}
}
}
if ($isPagination) {
$childChannels = $this->getChannelsByParentID($channelID);
$channelidArr = array($channelID);
if ($childChannels) {
foreach ($childChannels as $c) {
array_push($channelidArr, $c->id);
}
}
$article_db = bpBase::loadModel('article_model');
$where = to_sqls($channelidArr, '', 'channel_id');
$totalCount = $article_db->get_var($where, 'COUNT(id)', '', '');
$totalPage = $totalCount % $pageSize > 0 ? intval($totalCount / $pageSize) + 1 : $totalCount / $pageSize;
$totalPage = $totalPage < 1 ? 1 : $totalPage;
} else {
$totalPage = 1;
}
}
return $totalPage;
}
示例10: deleteExRelateArticle20130416
public function deleteExRelateArticle20130416()
{
$taskName = 'deleteExRelateArticle20130416';
$thisTask = $this->update_log_db->get_one(array('file' => $taskName));
$this->_executedCheck($taskName, $thisTask);
//
$content_db = bpBase::loadModel('content_model');
$article_db = bpBase::loadModel('article_model');
$articles = $article_db->select(array('ex' => 1), 'id');
$articleids = array();
if ($articles) {
foreach ($articles as $a) {
array_push($articleids, $a['id']);
}
}
$content_db->delete(to_sqls($articleids, '', 'contentid'));
//
$this->_finishTask($taskName, $thisTask);
}
示例11: init
/**
* 关键词搜索
*/
public function init()
{
//获取siteid
$siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;
$SEO = seo($siteid);
//搜索配置
$search_setting = getcache('search');
$setting = $search_setting[$siteid];
$search_model = getcache('search_model_' . $siteid);
$type_module = getcache('type_module_' . $siteid);
if (isset($_POST['q'])) {
if (trim($_POST['q']) == '') {
header('Location: ' . APP_PATH . 'index.php?m=search');
exit;
}
$typeid = empty($_POST['typeid']) ? 0 : intval($_POST['typeid']);
$time = empty($_POST['time']) || !in_array($_POST['time'], array('all', 'day', 'month', 'year', 'week')) ? 'all' : trim($_POST['time']);
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$pagesize = 10;
$q = safe_replace(trim($_POST['q']));
$q = new_html_special_chars(strip_tags($q));
$q = str_replace('%', '', $q);
//过滤'%',用户全文搜索
$search_q = $q;
//搜索原内容
$sql_time = $sql_tid = '';
if ($typeid) {
$sql_tid = ' AND typeid = ' . $typeid;
}
//按时间搜索
if ($time == 'day') {
$search_time = SYS_TIME - 86400;
$sql_time = ' AND adddate > ' . $search_time;
} elseif ($time == 'week') {
$search_time = SYS_TIME - 604800;
$sql_time = ' AND adddate > ' . $search_time;
} elseif ($time == 'month') {
$search_time = SYS_TIME - 2592000;
$sql_time = ' AND adddate > ' . $search_time;
} elseif ($time == 'year') {
$search_time = SYS_TIME - 31536000;
$sql_time = ' AND adddate > ' . $search_time;
} else {
$search_time = 0;
$sql_time = '';
}
if ($page == 1 && !$setting['sphinxenable']) {
//精确搜索
$commend = $this->db->get_one("`siteid`= '{$siteid}' {$sql_tid} {$sql_time} AND `data` like '%{$q}%'");
} else {
$commend = '';
}
//如果开启sphinx
if ($setting['sphinxenable']) {
$sphinx = pc_base::load_app_class('search_interface', '', 0);
$sphinx = new search_interface();
$offset = $pagesize * ($page - 1);
$res = $sphinx->search($q, array($siteid), array($typeid), array($search_time, SYS_TIME), $offset, $pagesize, '@weight desc');
$totalnums = $res['total'];
//如果结果不为空
if (!empty($res['matches'])) {
$result = $res['matches'];
}
} else {
$sql = "`siteid`= '{$siteid}' {$sql_tid} {$sql_time} AND `data` like '%{$q}%'";
$result = $this->db->listinfo($sql, 'searchid DESC', $page, 10);
//$result = $this->db->listinfo($sql, 'adddate ASC', $page, 10);
}
//如果结果不为空
if (!empty($result) || !empty($commend['id'])) {
foreach ($result as $_v) {
if ($_v['typeid']) {
$sids[$_v['typeid']][] = $_v['id'];
}
}
if (!empty($commend['id'])) {
if ($commend['typeid']) {
$sids[$commend['typeid']][] = $commend['id'];
}
}
$model_type_cache = getcache('type_model_' . $siteid, 'search');
$model_type_cache = array_flip($model_type_cache);
$data = array();
foreach ($sids as $_k => $_val) {
$tid = $_k;
$ids = array_unique($_val);
$where = to_sqls($ids, '', 'id');
//获取模型id
$modelid = $model_type_cache[$tid];
//是否读取其他模块接口
if ($modelid) {
$this->content_db->set_model($modelid);
/**
* 如果表名为空,则为黄页模型
*/
if (empty($this->content_db->model_tablename)) {
$this->content_db = pc_base::load_model('yp_content_model');
//.........这里部分代码省略.........
示例12: createChannelPageSelect
function createChannelPageSelect()
{
$channel_db = bpBase::loadModel('channel_model');
$channel = bpBase::loadAppClass('channelObj', 'channel', 1);
if (isset($_POST['doSubmit'])) {
//选定栏目
if ($_GET['type'] == 'channel') {
$channelIDStr = '';
if ($_POST['channels']) {
$comma = '';
foreach ($_POST['channels'] as $c) {
//$channelTotalPage=$channel->getChannelTotalPage($c);
$channelTotalPage = 1;
for ($t = 1; $t < $channelTotalPage + 1; $t++) {
$channelIDStr .= $comma . $c . '.' . $t;
//,channelid.pageNum
$comma = ',';
}
//清除缓存
$content = bpBase::loadAppClass('articleObj', 'article', 1);
$content->clearContentsCache($c);
$channel->clearCrumbCache($c);
}
}
file_put_contents(ABS_PATH . 'templatesCache' . DIRECTORY_SEPARATOR . 'channels.txt', $channelIDStr);
echo '<script>window.location.href=\'?m=template&c=createHtml&a=createChannelPage&siteid=' . $_GET['siteid'] . '&type=channel\';</script>';
} elseif ($_GET['type'] == 'content') {
$article_db = bpBase::loadModel('article_model');
$contentIDStr = '';
if ($_POST['channels']) {
$where = to_sqls($_POST['channels'], '', 'channel_id');
$contents = $article_db->get_results('id', '', $where, 'time DESC');
$comma = '';
if ($contents) {
foreach ($contents as $cc) {
$contentIDStr .= $comma . $cc->id;
$comma = ',';
}
}
}
file_put_contents(ABS_PATH . 'templatesCache' . DIRECTORY_SEPARATOR . 'contents.txt', $contentIDStr);
echo '<script>window.location.href=\'?m=template&c=createHtml&a=createChannelPage&siteid=' . $_GET['siteid'] . '&type=content\';</script>';
}
} else {
/*
$channels=$channel_db->select('');
$channelsByID=array();//用栏目id作为数组id来组织栏目数组
if ($channels){
foreach ($channels as $c){
$channelsByID[$c['id']]=$c;
}
}
$rights=$this->rights($user->uid);//根据用户id获取用户的权限数组
$accessChannels=$this->accessChannels($rights);
//*******************向上查找哪些父栏目需要在栏目树中显示********************
$showChannels=array();//向上查找哪些父栏目需要在栏目树中显示
foreach ($accessChannels as $channelid){
$pid=$channelid;
do {
$pid=$channelsByID[$channelid]['parentid'];
array_push($showChannels,$pid);
array_push($showChannels,$channelid);
$channelid=$channelsByID[$pid]['id'];
}while ($pid!=0&&!in_array($pid,$showChannels));
}
*/
/////////////////////////////////////////////////
$selectOptionStr = $channel->channelCreatePageTree($channel->tree(0, $_GET['siteid']), 0, $accessChannels, $showChannels);
include $this->showManageTpl('createChannelPageSelect');
}
}
示例13: get_search_data
/**
* 获取专题下内容数据
* @param string/intval $ids 多个id用“,”分开
*/
public function get_search_data($ids)
{
$where = to_sqls($ids, '', 'id');
$data = $this->db->select($where, '`id`, `title`, `thumb`, `description`, `url`, `inputtime`', '', '', '', 'id');
return $data;
}
示例14: exportmobile
public function exportmobile()
{
$start_time = isset($_POST['start_time']) ? $_POST['start_time'] : '';
$end_time = isset($_POST['end_time']) ? $_POST['end_time'] : date('Y-m-d', SYS_TIME);
$where_start_time = strtotime($start_time) ? strtotime($start_time) : 0;
$where_end_time = strtotime($end_time) + 86400;
$groupid = isset($_POST['groupid']) && !empty($_POST['groupid']) ? $_POST['groupid'] : '';
$modelid = isset($_POST['modelid']) && !empty($_POST['modelid']) ? $_POST['modelid'] : 10;
//开始时间大于结束时间,置换变量
if ($where_start_time > $where_end_time) {
$tmp = $where_start_time;
$where_start_time = $where_end_time;
$where_end_time = $tmp;
$tmptime = $start_time;
$start_time = $end_time;
$end_time = $tmptime;
unset($tmp, $tmptime);
}
$where = '';
if ($groupid) {
$where .= "`groupid` = '{$groupid}' AND ";
}
if ($modelid) {
$where .= "`modelid` = '{$modelid}' AND ";
}
$where .= "`regdate` BETWEEN '{$where_start_time}' AND '{$where_end_time}'";
//根据条件读取会员主表
$total = $this->member_db->count($where);
$str = '';
$perpage = 10;
for ($i = 0; $i <= floor($total / $perpage); $i++) {
$start = $i * $perpage;
$data = $this->member_db->select($where, 'userid', "{$start}, {$perpage}");
$userid_arr = array();
foreach ($data as $v) {
$userid_arr[] = $v['userid'];
}
$uids = to_sqls($userid_arr, '', 'userid');
//读取模型表中手机号码字段
$this->member_db->set_model($modelid);
$data = $this->member_db->select($uids);
foreach ($data as $v) {
if (!empty($v['mobile'])) {
$str .= $v['mobile'] . "\r\n";
}
}
$this->member_db->set_model();
}
header("Content-type:application/octet-stream");
header("Content-Disposition: attachment; filename=mobile.txt");
echo $str;
}
示例15: export
public function export()
{
if (isset($_POST['doSubmit'])) {
//1 创建保存路径
$modelPath = ABS_PATH . 'templates' . DIRECTORY_SEPARATOR . 'specialModel';
if (!file_exists($modelPath) || !is_dir($modelPath)) {
mkdir($modelPath, 777);
}
$saveFolder = $modelPath . DIRECTORY_SEPARATOR . $_POST['enname'];
if (!file_exists($saveFolder) || !is_dir($saveFolder)) {
mkdir($saveFolder, 777);
}
//2 拷贝专题文件到模型路径
recurse_copy(ABS_PATH . 'templates' . DIRECTORY_SEPARATOR . 'special' . DIRECTORY_SEPARATOR . $_POST['enname'] . DIRECTORY_SEPARATOR, $saveFolder . DIRECTORY_SEPARATOR);
//3 保存模型信息:名称、简介等
$modelInfo = array();
$modelInfo['name'] = $_POST['name'];
$modelInfo['enname'] = $_POST['enname'];
$modelInfo['intro'] = $_POST['intro'];
file_put_contents($saveFolder . DIRECTORY_SEPARATOR . 'modelInfo.txt', base64_encode(serialize($modelInfo)));
//4 创建logo
$logoPath = str_replace(array(MAIN_URL_ROOT . '/', '/'), array(ABS_PATH, DIRECTORY_SEPARATOR), $_POST['thumb']);
@unlink($saveFolder . DIRECTORY_SEPARATOR . 'logo.jpg');
@rename($logoPath, $saveFolder . DIRECTORY_SEPARATOR . 'logo.jpg');
//5 导出专题首页模板信息
$thisSpecial = $this->special_db->get($_POST['specialid']);
$tpl_db = bpBase::loadModel('template_model');
$thisTemplate = $tpl_db->get_one(array('id' => intval($thisSpecial['templateid'])));
//保存专题首页模板
$tplFile = ABS_PATH . substr($thisTemplate['path'], 1);
$thisTemplate['code'] = file_get_contents($tplFile);
file_put_contents($saveFolder . DIRECTORY_SEPARATOR . 'index.template.info.txt', base64_encode(serialize($thisTemplate)));
file_put_contents($saveFolder . DIRECTORY_SEPARATOR . 'index.template.txt', $thisTemplate['code']);
//6 导出专题使用的栏目
$channel_db = bpBase::loadModel('channel_model');
$channels = $channel_db->select(array('site' => intval($_POST['specialid'])));
file_put_contents($saveFolder . DIRECTORY_SEPARATOR . 'channels.data.txt', base64_encode(serialize($channels)));
//保存栏目信息
//7 处理栏目及内容用的模板
if ($channels) {
//查询出所有用到的栏目和内容templateid
$templateids = array();
foreach ($channels as $channel) {
array_push($templateids, $channel['channeltemplate']);
array_push($templateids, $channel['contenttemplate']);
}
$templates = $tpl_db->select(to_sqls($templateids, '', 'id'));
$templates = arrToArrByKey($templates);
file_put_contents($saveFolder . DIRECTORY_SEPARATOR . 'templates.data.txt', base64_encode(serialize($templates)));
foreach ($channels as $channel) {
if ($channel['channeltype'] == 1) {
//只处理普通栏目的模板
//只处理非默认模板
$thisChannelTemplate = $templates[$channel['channeltemplate']];
$thisContentTemplate = $templates[$channel['contenttemplate']];
if (!$thisChannelTemplate['isdefault']) {
//栏目模板
$tplFile = ABS_PATH . substr($thisChannelTemplate['path'], 1);
$code = file_get_contents($tplFile);
file_put_contents($saveFolder . DIRECTORY_SEPARATOR . $channel['cindex'] . '.' . $thisChannelTemplate['id'] . '.channel.template.txt', $code);
}
if (!$thisContentTemplate['isdefault']) {
//内容模板
$tplFile = ABS_PATH . substr($thisContentTemplate['path'], 1);
$code = file_get_contents($tplFile);
file_put_contents($saveFolder . DIRECTORY_SEPARATOR . $channel['cindex'] . '.' . $thisContentTemplate['id'] . '.content.template.txt', $code);
}
}
}
}
showMessage('导出完成', '?m=special&c=m_special&a=specials');
} else {
$adus = bpBase::loadAppClass('adus', 'manage');
$adus->title = '导出专题为模型';
$adus->formAction = '?m=special&c=m_special&a=export';
$adus->tip = '导出条件:专题所用的图片、js和css均在“/templates/special/当前专题/”文件夹下';
/********************输入项*************************/
//获取专题模板文件夹列表
$specialPathSub = ABS_PATH . 'templates' . DIRECTORY_SEPARATOR . 'special';
$files = scandir($specialPathSub);
$folderArr = array();
if ($files) {
foreach ($files as $f) {
if ($f != '.' && $f != '..' && is_dir($specialPathSub . DIRECTORY_SEPARATOR . $f)) {
array_push($folderArr, array('itemValue' => $f, 'itemText' => $f, 'selected' => false));
}
}
}
//
$inputs = array();
array_push($inputs, array('name' => '名称', 'type' => 'text', 'validate' => "'required'", 'style' => 'width:180px;', 'field' => 'name', 'value' => ''));
array_push($inputs, array('name' => '', 'type' => 'hidden', 'validate' => "'required'", 'field' => 'specialid', 'value' => $_GET['specialid']));
array_push($inputs, array('type' => 'select', 'field' => 'enname', 'name' => '选择文件夹', 'data' => $folderArr, 'complement' => '本专题的css、图片等文件存放文件夹'));
array_push($inputs, array('name' => '缩略图', 'type' => 'thumb', 'validate' => "'required'", 'style' => 'width:180px;', 'field' => 'thumb', 'value' => '', 'width' => 800, 'height' => 800));
array_push($inputs, array('name' => '简介', 'type' => 'textarea', 'style' => 'width:80%;font-size:12px;height:60px;', 'field' => 'intro', 'value' => ''));
$adus->inputs = $inputs;
$adus->outputPage();
}
}