cache_diytemplatename.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: cache_diytemplatename.php 24927 2011-10-17 03:13:33Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. function build_cache_diytemplatename() {
  12. $data = array();
  13. $apps = array('portal', 'forum', 'group', 'home');
  14. $nullname = lang('portalcp', 'diytemplate_name_null');
  15. $scriptarr = $lostname = array();
  16. foreach(C::t('common_diy_data')->range() as $datarow) {
  17. $datarow['name'] = $datarow['name'] ? $datarow['name'] : lang('portalcp', $datarow['targettplname'], '', '');
  18. if(empty($datarow['name'])) {
  19. $lostname[$datarow['targettplname']] = $datarow['targettplname'];
  20. $datarow['name'] = $nullname;
  21. }
  22. $data[$datarow['targettplname']] = dhtmlspecialchars($datarow['name']);
  23. $curscript = substr($datarow['targettplname'], 0, strpos($datarow['targettplname'], '/'));
  24. if(in_array($curscript, $apps)) {
  25. $scriptarr[$curscript][$datarow['targettplname']] = true;
  26. }
  27. }
  28. if($lostname) {
  29. require_once libfile('function/portalcp');
  30. foreach(getdiytplnames($lostname) as $pre => $datas) {
  31. foreach($datas as $id => $name) {
  32. $data[$pre.$id] = $name;
  33. }
  34. }
  35. }
  36. savecache('diytemplatename', $data);
  37. foreach($scriptarr as $curscript => $value) {
  38. savecache('diytemplatename'.$curscript, $value);
  39. }
  40. }
  41. ?>