create_html.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <?php
  2. defined('IN_PHPCMS') or exit('No permission resources.');
  3. pc_base::load_app_class('admin','admin',0);
  4. pc_base::load_sys_class('form','',0);
  5. class create_html extends admin {
  6. private $db;
  7. public $siteid,$categorys;
  8. public function __construct() {
  9. parent::__construct();
  10. $this->db = pc_base::load_model('content_model');
  11. $this->siteid = $this->get_siteid();
  12. $this->categorys = getcache('category_content_'.$this->siteid,'commons');
  13. foreach($_GET as $k=>$v) {
  14. $_POST[$k] = $v;
  15. }
  16. }
  17. public function update_urls() {
  18. if(isset($_POST['dosubmit'])) {
  19. extract($_POST,EXTR_SKIP);
  20. $this->url = pc_base::load_app_class('url');
  21. $modelid = intval($_POST['modelid']);
  22. if($modelid) {
  23. //设置模型数据表名
  24. $this->db->set_model($modelid);
  25. $table_name = $this->db->table_name;
  26. if($type == 'lastinput') {
  27. $offset = 0;
  28. } else {
  29. $page = max(intval($page), 1);
  30. $offset = $pagesize*($page-1);
  31. }
  32. $where = ' WHERE status=99 ';
  33. $order = 'ASC';
  34. if(!isset($first) && is_array($catids) && $catids[0] > 0) {
  35. setcache('url_show_'.$_SESSION['userid'], $catids,'content');
  36. $catids = implode(',',$catids);
  37. $where .= " AND catid IN($catids) ";
  38. $first = 1;
  39. } elseif($first) {
  40. $catids = getcache('url_show_'.$_SESSION['userid'],'content');
  41. $catids = implode(',',$catids);
  42. $where .= " AND catid IN($catids) ";
  43. } else {
  44. $first = 0;
  45. }
  46. if($type == 'lastinput' && $number) {
  47. $offset = 0;
  48. $pagesize = $number;
  49. $order = 'DESC';
  50. } elseif($type == 'date') {
  51. if($fromdate) {
  52. $fromtime = strtotime($fromdate.' 00:00:00');
  53. $where .= " AND `inputtime`>=$fromtime ";
  54. }
  55. if($todate) {
  56. $totime = strtotime($todate.' 23:59:59');
  57. $where .= " AND `inputtime`<=$totime ";
  58. }
  59. } elseif($type == 'id') {
  60. $fromid = intval($fromid);
  61. $toid = intval($toid);
  62. if($fromid) $where .= " AND `id`>=$fromid ";
  63. if($toid) $where .= " AND `id`<=$toid ";
  64. }
  65. if(!isset($total) && $type != 'lastinput') {
  66. $rs = $this->db->query("SELECT COUNT(*) AS `count` FROM `$table_name` $where");
  67. $result = $this->db->fetch_array($rs);
  68. $total = $result[0]['count'];
  69. $pages = ceil($total/$pagesize);
  70. $start = 1;
  71. }
  72. $rs = $this->db->query("SELECT * FROM `$table_name` $where ORDER BY `id` $order LIMIT $offset,$pagesize");
  73. $data = $this->db->fetch_array($rs);
  74. foreach($data as $r) {
  75. if($r['islink'] || $r['upgrade']) continue;
  76. //更新URL链接
  77. $this->urls($r['id'], $r['catid'], $r['inputtime'], $r['prefix']);
  78. }
  79. if($pages > $page) {
  80. $page++;
  81. $http_url = get_url();
  82. $creatednum = $offset + count($data);
  83. $percent = round($creatednum/$total, 2)*100;
  84. $message = L('need_update_items',array('total'=>$total,'creatednum'=>$creatednum,'percent'=>$percent));
  85. $forward = $start ? "?m=content&c=create_html&a=update_urls&type=$type&dosubmit=1&first=$first&fromid=$fromid&toid=$toid&fromdate=$fromdate&todate=$todate&pagesize=$pagesize&page=$page&pages=$pages&total=$total&modelid=$modelid" : preg_replace("/&page=([0-9]+)&pages=([0-9]+)&total=([0-9]+)/", "&page=$page&pages=$pages&total=$total", $http_url);
  86. } else {
  87. delcache('url_show_'.$_SESSION['userid'],'content');
  88. $message = L('create_update_success');
  89. $forward = '?m=content&c=create_html&a=update_urls';
  90. }
  91. showmessage($message,$forward,200);
  92. } else {
  93. //当没有选择模型时,需要按照栏目来更新
  94. if(!isset($set_catid)) {
  95. if($catids[0] != 0) {
  96. $update_url_catids = $catids;
  97. } else {
  98. foreach($this->categorys as $catid=>$cat) {
  99. if($cat['child'] || $cat['siteid'] != $this->siteid || $cat['type']!=0) continue;
  100. $update_url_catids[] = $catid;
  101. }
  102. }
  103. setcache('update_url_catid'.'-'.$this->siteid.'-'.$_SESSION['userid'],$update_url_catids,'content');
  104. $message = L('start_update_urls');
  105. $forward = "?m=content&c=create_html&a=update_urls&set_catid=1&pagesize=$pagesize&dosubmit=1";
  106. showmessage($message,$forward,200);
  107. }
  108. $catid_arr = getcache('update_url_catid'.'-'.$this->siteid.'-'.$_SESSION['userid'],'content');
  109. $autoid = $autoid ? intval($autoid) : 0;
  110. if(!isset($catid_arr[$autoid])) showmessage(L('create_update_success'),'?m=content&c=create_html&a=update_urls',200);
  111. $catid = $catid_arr[$autoid];
  112. $modelid = $this->categorys[$catid]['modelid'];
  113. //设置模型数据表名
  114. $this->db->set_model($modelid);
  115. $table_name = $this->db->table_name;
  116. $page = max(intval($page), 1);
  117. $offset = $pagesize*($page-1);
  118. $where = " WHERE status=99 AND catid='$catid'";
  119. $order = 'ASC';
  120. if(!isset($total)) {
  121. $rs = $this->db->query("SELECT COUNT(*) AS `count` FROM `$table_name` $where");
  122. $result = $this->db->fetch_array($rs);
  123. $total = $result[0]['count'];
  124. $pages = ceil($total/$pagesize);
  125. $start = 1;
  126. }
  127. $rs = $this->db->query("SELECT * FROM `$table_name` $where ORDER BY `id` $order LIMIT $offset,$pagesize");
  128. $data = $this->db->fetch_array($rs);
  129. foreach($data as $r) {
  130. if($r['islink'] || $r['upgrade']) continue;
  131. //更新URL链接
  132. $this->urls($r['id'], $r['catid'], $r['inputtime'], $r['prefix']);
  133. }
  134. if($pages > $page) {
  135. $page++;
  136. $http_url = get_url();
  137. $creatednum = $offset + count($data);
  138. $percent = round($creatednum/$total, 2)*100;
  139. $message = '【'.$this->categorys[$catid]['catname'].'】 '.L('have_update_items',array('total'=>$total,'creatednum'=>$creatednum,'percent'=>$percent));
  140. $forward = $start ? "?m=content&c=create_html&a=update_urls&type=$type&dosubmit=1&first=$first&fromid=$fromid&toid=$toid&fromdate=$fromdate&todate=$todate&pagesize=$pagesize&page=$page&pages=$pages&total=$total&autoid=$autoid&set_catid=1" : preg_replace("/&page=([0-9]+)&pages=([0-9]+)&total=([0-9]+)/", "&page=$page&pages=$pages&total=$total", $http_url);
  141. } else {
  142. $autoid++;
  143. $message = L('updating').$this->categorys[$catid]['catname']." ...";
  144. $forward = "?m=content&c=create_html&a=update_urls&set_catid=1&pagesize=$pagesize&dosubmit=1&autoid=$autoid";
  145. }
  146. showmessage($message,$forward,200);
  147. }
  148. } else {
  149. $show_header = $show_dialog = '';
  150. $admin_username = param::get_cookie('admin_username');
  151. $modelid = isset($_GET['modelid']) ? intval($_GET['modelid']) : 0;
  152. $tree = pc_base::load_sys_class('tree');
  153. $tree->icon = array('&nbsp;&nbsp;&nbsp;│ ','&nbsp;&nbsp;&nbsp;├─ ','&nbsp;&nbsp;&nbsp;└─ ');
  154. $tree->nbsp = '&nbsp;&nbsp;&nbsp;';
  155. $categorys = array();
  156. if(!empty($this->categorys)) {
  157. foreach($this->categorys as $catid=>$r) {
  158. if($this->siteid != $r['siteid'] || ($r['type']!=0 && $r['child']==0)) continue;
  159. if($modelid && $modelid != $r['modelid']) continue;
  160. $r['disabled'] = $r['child'] ? 'disabled' : '';
  161. $categorys[$catid] = $r;
  162. }
  163. }
  164. $str = "<option value='\$catid' \$selected \$disabled>\$spacer \$catname</option>";
  165. $tree->init($categorys);
  166. $string .= $tree->get_tree(0, $str);
  167. include $this->admin_tpl('update_urls');
  168. }
  169. }
  170. private function urls($id, $catid= 0, $inputtime = 0, $prefix = ''){
  171. $urls = $this->url->show($id, 0, $catid, $inputtime, $prefix,'','edit');
  172. //更新到数据库
  173. $url = $urls[0];
  174. $this->db->update(array('url'=>$url),array('id'=>$id));
  175. //echo $id; echo "|";
  176. return $urls;
  177. }
  178. /**
  179. * 生成内容页
  180. */
  181. public function show() {
  182. if(isset($_POST['dosubmit'])) {
  183. extract($_POST,EXTR_SKIP);
  184. $this->html = pc_base::load_app_class('html');
  185. $modelid = intval($_POST['modelid']);
  186. if($modelid) {
  187. //设置模型数据表名
  188. $this->db->set_model($modelid);
  189. $table_name = $this->db->table_name;
  190. if($type == 'lastinput') {
  191. $offset = 0;
  192. } else {
  193. $page = max(intval($page), 1);
  194. $offset = $pagesize*($page-1);
  195. }
  196. $where = ' WHERE status=99 ';
  197. $order = 'ASC';
  198. if(!isset($first) && is_array($catids) && $catids[0] > 0) {
  199. setcache('html_show_'.$_SESSION['userid'], $catids,'content');
  200. $catids = implode(',',$catids);
  201. $where .= " AND catid IN($catids) ";
  202. $first = 1;
  203. } elseif(count($catids)==1 && $catids[0] == 0) {
  204. $catids = array();
  205. foreach($this->categorys as $catid=>$cat) {
  206. if($cat['child'] || $cat['siteid'] != $this->siteid || $cat['type']!=0) continue;
  207. $setting = string2array($cat['setting']);
  208. if(!$setting['content_ishtml']) continue;
  209. $catids[] = $catid;
  210. }
  211. setcache('html_show_'.$_SESSION['userid'], $catids,'content');
  212. $catids = implode(',',$catids);
  213. $where .= " AND catid IN($catids) ";
  214. $first = 1;
  215. } elseif($first) {
  216. $catids = getcache('html_show_'.$_SESSION['userid'],'content');
  217. $catids = implode(',',$catids);
  218. $where .= " AND catid IN($catids) ";
  219. } else {
  220. $first = 0;
  221. }
  222. if(count($catids)==1 && $catids[0]==0) {
  223. $message = L('create_update_success');
  224. $forward = '?m=content&c=create_html&a=show';
  225. showmessage($message,$forward);
  226. }
  227. if($type == 'lastinput' && $number) {
  228. $offset = 0;
  229. $pagesize = $number;
  230. $order = 'DESC';
  231. } elseif($type == 'date') {
  232. if($fromdate) {
  233. $fromtime = strtotime($fromdate.' 00:00:00');
  234. $where .= " AND `inputtime`>=$fromtime ";
  235. }
  236. if($todate) {
  237. $totime = strtotime($todate.' 23:59:59');
  238. $where .= " AND `inputtime`<=$totime ";
  239. }
  240. } elseif($type == 'id') {
  241. $fromid = intval($fromid);
  242. $toid = intval($toid);
  243. if($fromid) $where .= " AND `id`>=$fromid ";
  244. if($toid) $where .= " AND `id`<=$toid ";
  245. }
  246. if(!isset($total) && $type != 'lastinput') {
  247. $rs = $this->db->query("SELECT COUNT(*) AS `count` FROM `$table_name` $where");
  248. $result = $this->db->fetch_array($rs);
  249. $total = $result[0]['count'];
  250. $pages = ceil($total/$pagesize);
  251. $start = 1;
  252. }
  253. $rs = $this->db->query("SELECT * FROM `$table_name` $where ORDER BY `id` $order LIMIT $offset,$pagesize");
  254. $data = $this->db->fetch_array($rs);
  255. $tablename = $this->db->table_name.'_data';
  256. $this->url = pc_base::load_app_class('url');
  257. foreach($data as $r) {
  258. if($r['islink']) continue;
  259. $this->db->table_name = $tablename;
  260. $r2 = $this->db->get_one(array('id'=>$r['id']));
  261. if($r) $r = array_merge($r,$r2);
  262. if($r['upgrade']) {
  263. $urls[1] = $r['url'];
  264. } else {
  265. $urls = $this->url->show($r['id'], '', $r['catid'],$r['inputtime']);
  266. }
  267. $this->html->show($urls[1],$r,0,'edit',$r['upgrade']);
  268. }
  269. if($pages > $page) {
  270. $page++;
  271. $http_url = get_url();
  272. $creatednum = $offset + count($data);
  273. $percent = round($creatednum/$total, 2)*100;
  274. $message = L('need_update_items',array('total'=>$total,'creatednum'=>$creatednum,'percent'=>$percent));
  275. $forward = $start ? "?m=content&c=create_html&a=show&type=$type&dosubmit=1&first=$first&fromid=$fromid&toid=$toid&fromdate=$fromdate&todate=$todate&pagesize=$pagesize&page=$page&pages=$pages&total=$total&modelid=$modelid" : preg_replace("/&page=([0-9]+)&pages=([0-9]+)&total=([0-9]+)/", "&page=$page&pages=$pages&total=$total", $http_url);
  276. } else {
  277. delcache('html_show_'.$_SESSION['userid'],'content');
  278. $message = L('create_update_success');
  279. $forward = '?m=content&c=create_html&a=show';
  280. }
  281. showmessage($message,$forward,200);
  282. } else {
  283. //当没有选择模型时,需要按照栏目来更新
  284. if(!isset($set_catid)) {
  285. if($catids[0] != 0) {
  286. $update_url_catids = $catids;
  287. } else {
  288. foreach($this->categorys as $catid=>$cat) {
  289. if($cat['child'] || $cat['siteid'] != $this->siteid || $cat['type']!=0) continue;
  290. $setting = string2array($cat['setting']);
  291. if(!$setting['content_ishtml']) continue;
  292. $update_url_catids[] = $catid;
  293. }
  294. }
  295. setcache('update_html_catid'.'-'.$this->siteid.'-'.$_SESSION['userid'],$update_url_catids,'content');
  296. $message = L('start_update');
  297. $forward = "?m=content&c=create_html&a=show&set_catid=1&pagesize=$pagesize&dosubmit=1";
  298. showmessage($message,$forward,200);
  299. }
  300. if(count($catids)==1 && $catids[0]==0) {
  301. $message = L('create_update_success');
  302. $forward = '?m=content&c=create_html&a=show';
  303. showmessage($message,$forward,200);
  304. }
  305. $catid_arr = getcache('update_html_catid'.'-'.$this->siteid.'-'.$_SESSION['userid'],'content');
  306. $autoid = $autoid ? intval($autoid) : 0;
  307. if(!isset($catid_arr[$autoid])) showmessage(L('create_update_success'),'?m=content&c=create_html&a=show',200);
  308. $catid = $catid_arr[$autoid];
  309. $modelid = $this->categorys[$catid]['modelid'];
  310. //设置模型数据表名
  311. $this->db->set_model($modelid);
  312. $table_name = $this->db->table_name;
  313. $page = max(intval($page), 1);
  314. $offset = $pagesize*($page-1);
  315. $where = " WHERE status=99 AND catid='$catid'";
  316. $order = 'ASC';
  317. if(!isset($total)) {
  318. $rs = $this->db->query("SELECT COUNT(*) AS `count` FROM `$table_name` $where");
  319. $result = $this->db->fetch_array($rs);
  320. $total = $result[0]['count'];
  321. $pages = ceil($total/$pagesize);
  322. $start = 1;
  323. }
  324. $rs = $this->db->query("SELECT * FROM `$table_name` $where ORDER BY `id` $order LIMIT $offset,$pagesize");
  325. $data = $this->db->fetch_array($rs);
  326. $tablename = $this->db->table_name.'_data';
  327. $this->url = pc_base::load_app_class('url');
  328. foreach($data as $r) {
  329. if($r['islink']) continue;
  330. //写入文件
  331. $this->db->table_name = $tablename;
  332. $r2 = $this->db->get_one(array('id'=>$r['id']));
  333. if($r2) $r = array_merge($r,$r2);
  334. if($r['upgrade']) {
  335. $urls[1] = $r['url'];
  336. } else {
  337. $urls = $this->url->show($r['id'], '', $r['catid'],$r['inputtime']);
  338. }
  339. $this->html->show($urls[1],$r,0,'edit',$r['upgrade']);
  340. }
  341. if($pages > $page) {
  342. $page++;
  343. $http_url = get_url();
  344. $creatednum = $offset + count($data);
  345. $percent = round($creatednum/$total, 2)*100;
  346. $message = '【'.$this->categorys[$catid]['catname'].'】 '.L('have_update_items',array('total'=>$total,'creatednum'=>$creatednum,'percent'=>$percent));
  347. $forward = $start ? "?m=content&c=create_html&a=show&type=$type&dosubmit=1&first=$first&fromid=$fromid&toid=$toid&fromdate=$fromdate&todate=$todate&pagesize=$pagesize&page=$page&pages=$pages&total=$total&autoid=$autoid&set_catid=1" : preg_replace("/&page=([0-9]+)&pages=([0-9]+)&total=([0-9]+)/", "&page=$page&pages=$pages&total=$total", $http_url);
  348. } else {
  349. $autoid++;
  350. $message = L('start_update').$this->categorys[$catid]['catname']." ...";
  351. $forward = "?m=content&c=create_html&a=show&set_catid=1&pagesize=$pagesize&dosubmit=1&autoid=$autoid";
  352. }
  353. showmessage($message,$forward,200);
  354. }
  355. } else {
  356. $show_header = $show_dialog = '';
  357. $admin_username = param::get_cookie('admin_username');
  358. $modelid = isset($_GET['modelid']) ? intval($_GET['modelid']) : 0;
  359. $tree = pc_base::load_sys_class('tree');
  360. $tree->icon = array('&nbsp;&nbsp;&nbsp;│ ','&nbsp;&nbsp;&nbsp;├─ ','&nbsp;&nbsp;&nbsp;└─ ');
  361. $tree->nbsp = '&nbsp;&nbsp;&nbsp;';
  362. $categorys = array();
  363. if(!empty($this->categorys)) {
  364. foreach($this->categorys as $catid=>$r) {
  365. if($this->siteid != $r['siteid'] || ($r['type']!=0 && $r['child']==0)) continue;
  366. if($modelid && $modelid != $r['modelid']) continue;
  367. if($r['child']==0) {
  368. $setting = string2array($r['setting']);
  369. if(!$setting['content_ishtml']) continue;
  370. }
  371. $r['disabled'] = $r['child'] ? 'disabled' : '';
  372. $categorys[$catid] = $r;
  373. }
  374. }
  375. $str = "<option value='\$catid' \$selected \$disabled>\$spacer \$catname</option>";
  376. $tree->init($categorys);
  377. $string .= $tree->get_tree(0, $str);
  378. include $this->admin_tpl('create_html_show');
  379. }
  380. }
  381. /**
  382. * 生成栏目页
  383. */
  384. public function category() {
  385. if(isset($_POST['dosubmit'])) {
  386. extract($_POST,EXTR_SKIP);
  387. $this->html = pc_base::load_app_class('html');
  388. $referer = isset($referer) ? urlencode($referer) : '';
  389. $modelid = intval($_POST['modelid']);
  390. if(!isset($set_catid)) {
  391. if($catids[0] != 0) {
  392. $update_url_catids = $catids;
  393. } else {
  394. foreach($this->categorys as $catid=>$cat) {
  395. if($cat['siteid'] != $this->siteid || $cat['type']==2 || !$cat['ishtml']) continue;
  396. if($modelid && ($modelid != $cat['modelid'])) continue;
  397. $update_url_catids[] = $catid;
  398. }
  399. }
  400. setcache('update_html_catid'.'-'.$this->siteid.'-'.$_SESSION['userid'],$update_url_catids,'content');
  401. $message = L('start_update_category');
  402. $forward = "?m=content&c=create_html&a=category&set_catid=1&pagesize=$pagesize&dosubmit=1&modelid=$modelid&referer=$referer";
  403. showmessage($message,$forward);
  404. }
  405. $catid_arr = getcache('update_html_catid'.'-'.$this->siteid.'-'.$_SESSION['userid'],'content');
  406. $autoid = $autoid ? intval($autoid) : 0;
  407. if(!isset($catid_arr[$autoid])) {
  408. if(!empty($referer) && $this->categorys[$catid_arr[0]]['type']!=1) {
  409. showmessage(L('create_update_success'),'?m=content&c=content&a=init&catid='.$catid_arr[0],200);
  410. } else {
  411. showmessage(L('create_update_success'),'?m=content&c=create_html&a=category',200);
  412. }
  413. }
  414. $catid = $catid_arr[$autoid];
  415. $page = $page ? $page : 1;
  416. $j = 1;
  417. do {
  418. $this->html->category($catid,$page);
  419. $page++;
  420. $j++;
  421. $total_number = isset($total_number) ? $total_number : PAGES;
  422. } while ($j <= $total_number && $j < $pagesize);
  423. if($page <= $total_number) {
  424. $endpage = intval($page+$pagesize);
  425. $message = L('updating').$this->categorys[$catid]['catname'].L('start_to_end_id',array('page'=>$page,'endpage'=>$endpage));
  426. $forward = "?m=content&c=create_html&a=category&set_catid=1&pagesize=$pagesize&dosubmit=1&autoid=$autoid&page=$page&total_number=$total_number&modelid=$modelid&referer=$referer";
  427. } else {
  428. $autoid++;
  429. $message = $this->categorys[$catid]['catname'].L('create_update_success');
  430. $forward = "?m=content&c=create_html&a=category&set_catid=1&pagesize=$pagesize&dosubmit=1&autoid=$autoid&modelid=$modelid&referer=$referer";
  431. }
  432. showmessage($message,$forward,200);
  433. } else {
  434. $show_header = $show_dialog = '';
  435. $admin_username = param::get_cookie('admin_username');
  436. $modelid = isset($_GET['modelid']) ? intval($_GET['modelid']) : 0;
  437. $tree = pc_base::load_sys_class('tree');
  438. $tree->icon = array('&nbsp;&nbsp;&nbsp;│ ','&nbsp;&nbsp;&nbsp;├─ ','&nbsp;&nbsp;&nbsp;└─ ');
  439. $tree->nbsp = '&nbsp;&nbsp;&nbsp;';
  440. $categorys = array();
  441. if(!empty($this->categorys)) {
  442. foreach($this->categorys as $catid=>$r) {
  443. if($this->siteid != $r['siteid'] || ($r['type']==2 && $r['child']==0)) continue;
  444. if($modelid && $modelid != $r['modelid']) continue;
  445. if($r['child']==0) {
  446. if(!$r['ishtml']) continue;
  447. }
  448. $categorys[$catid] = $r;
  449. }
  450. }
  451. $str = "<option value='\$catid' \$selected>\$spacer \$catname</option>";
  452. $tree->init($categorys);
  453. $string .= $tree->get_tree(0, $str);
  454. include $this->admin_tpl('create_html_category');
  455. }
  456. }
  457. //生成首页
  458. public function public_index() {
  459. $this->html = pc_base::load_app_class('html');
  460. $size = $this->html->index();
  461. showmessage(L('index_create_finish',array('size'=>sizecount($size))));
  462. }
  463. /**
  464. * 批量生成内容页
  465. */
  466. public function batch_show() {
  467. if(isset($_POST['dosubmit'])) {
  468. $catid = intval($_GET['catid']);
  469. if(!$catid) showmessage(L('missing_part_parameters'));
  470. $modelid = $this->categorys[$catid]['modelid'];
  471. $setting = string2array($this->categorys[$catid]['setting']);
  472. $content_ishtml = $setting['content_ishtml'];
  473. if($content_ishtml) {
  474. $this->url = pc_base::load_app_class('url');
  475. $this->db->set_model($modelid);
  476. if(empty($_POST['ids'])) showmessage(L('you_do_not_check'));
  477. $this->html = pc_base::load_app_class('html');
  478. $ids = implode(',', $_POST['ids']);
  479. $rs = $this->db->select("catid='$catid' AND id IN ($ids)");
  480. $tablename = $this->db->table_name.'_data';
  481. foreach($rs as $r) {
  482. if($r['islink']) continue;
  483. $this->db->table_name = $tablename;
  484. $r2 = $this->db->get_one(array('id'=>$r['id']));
  485. if($r2) $r = array_merge($r,$r2);
  486. //判断是否为升级或转换过来的数据
  487. if(!$r['upgrade']) {
  488. $urls = $this->url->show($r['id'], '', $r['catid'],$r['inputtime']);
  489. } else {
  490. $urls[1] = $r['url'];
  491. }
  492. $this->html->show($urls[1],$r,0,'edit',$r['upgrade']);
  493. }
  494. showmessage(L('operation_success'),HTTP_REFERER);
  495. }
  496. }
  497. }
  498. }
  499. ?>