PageRenderTime 91ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/b2b/core/model/system/mdl.template.php

http://phpfor.googlecode.com/
PHP | 687 lines | 657 code | 27 blank | 3 comment | 20 complexity | b6d74c88f620be6e143ca6cea4017c9a MD5 | raw file
  1. <?php
  2. class mdl_template extends modelFactory{
  3. function getList(){
  4. $handle = opendir(THEME_DIR);
  5. while(false!==($item=readdir($handle))){
  6. if(substr($item,0,1)!='.' && is_dir(THEME_DIR.'/'.$item)){
  7. $t[$item]=1;
  8. }
  9. }
  10. closedir($handle);
  11. foreach($this->db->select('select * from sdb_themes where theme in("'.implode('","',array_keys($t)).'")') as $theme){
  12. $themes[$theme['theme']] = $theme;
  13. unset($t[$theme['theme']]);
  14. }
  15. $objWg = $this->system->loadModel('content/widgets');
  16. foreach($objWg->getLibs() as $w){
  17. $widgets[$w['name']] = $w;
  18. $widgets[$w['name']]['installed'] = true;
  19. }
  20. //???
  21. foreach(array_keys($t) as $item){
  22. if(file_exists(THEME_DIR.'/'.$item.'/theme.xml')){
  23. $themes[$item] = $this->initTheme($item);
  24. }
  25. }
  26. foreach($this->db->select('SELECT base_file,widgets_type FROM sdb_widgets_set s') as $widset){
  27. $tname = substr($widset['base_file'],($p=strpos($widset['base_file'],':')+1),strpos($widset['base_file'],'/')-$p);
  28. if($themes[$tname]){
  29. $themes[$tname]['widgets'][$widset['widgets_type']] = $widgets[$widset['widgets_type']]?$widgets[$widset['widgets_type']]:array('label'=>$widset['widgets_type'],'name'=>$widset['widgets_type'],'installed'=>false);
  30. }
  31. }
  32. ksort($themes);
  33. return $themes;
  34. }
  35. function remove($theme){
  36. return $this->__removeDir(THEME_DIR.'/'.$theme);
  37. }
  38. function remove_directory($dir){
  39. if(substr($dir, -1, 1)=="/"){
  40. $dir=substr($dir, 0, strlen($dir)-1);
  41. }
  42. if ($handle=opendir("$dir")){
  43. while(false!==($item=readdir($handle))){
  44. if($item!="." && $item!=".."){
  45. if (is_dir("$dir/$item")){
  46. remove_directory("$dir/$item");
  47. }else{
  48. unlink("$dir/$item");
  49. }
  50. }
  51. }
  52. closedir($handle);
  53. rmdir($dir);
  54. }
  55. }
  56. function backTemplate($p1,$p2){
  57. echo '????';
  58. }
  59. function previewImg($theme){
  60. $this->system->sfile(THEME_DIR.'/'.$theme.'/preview.jpg','images/theme_dft.jpg',true);
  61. }
  62. function allowUpload(&$message){
  63. if(!function_exists("gzinflate")){
  64. $message = 'gzip';
  65. return $message;
  66. }
  67. if(!is_writable(THEME_DIR)){
  68. $message = 'writeable';
  69. return $message;
  70. }
  71. return true;
  72. }
  73. function makeXml($theme,$name){
  74. //THEME_DIR.'/'.$theme
  75. if(file_put_contents(THEME_DIR.'/'.$theme.'/'.$name.'.xml',$this->__makeConfigFile($theme))){
  76. return true;
  77. }else{
  78. return false;
  79. }
  80. }
  81. function getThemes($theme){
  82. $list=array("theme.xml","theme-bak.xml");
  83. $views = array();
  84. foreach($list as $v){
  85. if(is_file(THEME_DIR.'/'.$theme.'/'.$v)){
  86. $views[]=$v;
  87. }
  88. }
  89. return $views;
  90. }
  91. function getViews($theme){
  92. if ($handle=opendir(THEME_DIR.'/'.$theme)){
  93. $views = array();
  94. while(false!==($file=readdir($handle))){
  95. if ($file{0}!=='.' && $file{0}!=='_' && is_file(THEME_DIR.'/'.$theme.'/'.$file) && (($t=strtolower(strstr($file,'.')))=='.html' || $t=='.htm')){
  96. $views[] = $file;
  97. }
  98. }
  99. closedir($handle);
  100. return $views;
  101. }else{
  102. return false;
  103. }
  104. }
  105. function upload($file,&$msg){
  106. if(!$this->allowUpload($msg)) return false;
  107. $tar = $this->system->loadModel('utility/tar');
  108. //$file_name=split(".tgz",$file['name']);
  109. $sDir=$this->__buildDir(str_replace('\\','/',THEME_DIR.'/'.time()));
  110. if($tar->openTAR($file['tmp_name'])){
  111. if($tar->containsFile('theme.xml')) {
  112. foreach($tar->files as $id => $file) {
  113. $fpath = $sDir.$file['name'];
  114. $path_parts = pathinfo($file['name']);
  115. if (strtolower($path_parts["extension"]) == "php") continue;
  116. if(!is_dir(dirname($fpath))){
  117. if(mkdir_p(dirname($fpath))){
  118. $file_ext = explode(".",$file['name']);
  119. if($file_ext[1]!='php'){
  120. file_put_contents($fpath,$tar->getContents($file));
  121. }
  122. }else{
  123. $msg = '?????';
  124. return false;
  125. }
  126. }else{
  127. file_put_contents($fpath,$tar->getContents($file));
  128. }
  129. }
  130. $tar->closeTAR();
  131. if(!$config=$this->initTheme(basename($sDir),'','upload')){
  132. $this->__removeDir($sDir);
  133. $msg='shopEx???????';
  134. return false;
  135. }
  136. return $config;
  137. }else{
  138. $msg = '?????shopEx???';
  139. return false;
  140. }
  141. }else{
  142. $msg = '????????????shopEx???'.$file['tmp_name'];
  143. return false;
  144. }
  145. }
  146. function getBorderFromThemes($file){
  147. /*
  148. $wights_border=Array();
  149. $path=THEME_DIR.'/'.substr($file,5,strpos($file,'/')-5).'/borders/';
  150. $handle = opendir($path);
  151. while (false !== ($file = readdir($handle))) {
  152. if(substr($file,0,1)!='.'){
  153. $wights_border['borders/'.$file]=file_get_contents($path.$file);
  154. }
  155. }
  156. */
  157. //closedir($handle);
  158. $wights_border=Array();
  159. $path=THEME_DIR.'/'.$file;
  160. $workdir = getcwd();
  161. chdir($path);
  162. $xml = $this->system->loadModel('utility/xml');
  163. $content=file_get_contents('info.xml');
  164. $config = $xml->xml2arrayValues($content);
  165. foreach($config['theme']['borders']['set'] as $k=>$v){
  166. $wights_border[$v['attr']['tpl']]=file_get_contents($v['attr']['tpl']);
  167. }
  168. chdir($workdir);
  169. return $wights_border;
  170. }
  171. function resetTheme($theme){
  172. $path=THEME_DIR.'/'.$theme;
  173. $workdir = getcwd();
  174. chdir($path);
  175. if(is_file('info.xml')){
  176. $xml = $this->system->loadModel('utility/xml');
  177. $config = $xml->xml2arrayValues(file_get_contents('info.xml'));
  178. $aTheme=array(
  179. 'theme'=>$theme,
  180. 'name'=>$config['theme']['name']['value'],
  181. 'id'=>$config['theme']['id']['value'],
  182. 'version'=>$config['theme']['version']['value'],
  183. 'info'=>$config['theme']['info']['value'],
  184. 'author'=>$config['theme']['author']['value'],
  185. 'site'=>$config['theme']['site']['value'],
  186. 'update_url'=>$config['theme']['update_url']['value'],
  187. 'config'=>array(
  188. 'config'=>$this->__changeXMLArray($config['theme']['config']['set']),
  189. 'borders'=>$this->__changeXMLArray($config['theme']['borders']['set']),
  190. 'views'=>$this->__changeXMLArray($config['theme']['views']['view'])
  191. )
  192. );
  193. /*
  194. $update=array(
  195. 'config'=>$this->__changeXMLArray($config['theme']['config']['set']),
  196. 'borders'=>$this->__changeXMLArray($config['theme']['borders']['set']),
  197. 'views'=>$this->__changeXMLArray($config['theme']['views']['view'])
  198. );
  199. */
  200. chdir($workdir);
  201. if(!$this->updateThemes($aTheme)){
  202. return false;
  203. }else{
  204. return true;
  205. }
  206. }
  207. }
  208. function initTheme($theme,$replaceWg=false,$upload='',$loadxml=''){
  209. if(empty($loadxml)){
  210. $loadxml='theme.xml';
  211. }
  212. $configxml='info.xml';
  213. $this->separatXml($theme);
  214. $sDir=THEME_DIR.'/'.$theme.'/';
  215. $xml = $this->system->loadModel('utility/xml');
  216. $wightes_info = $xml->xml2arrayValues(file_get_contents($sDir.$loadxml));
  217. if(is_file($sDir.$configxml)){
  218. $config = $xml->xml2arrayValues(file_get_contents($sDir.$configxml));
  219. }else{
  220. $config=$wightes_info;
  221. }
  222. if($upload=="upload" && $config['theme']['id']['value']){
  223. $config['theme']['id']['value']=preg_replace('@[^a-zA-Z0-9]@','_',$config['theme']['id']['value']);
  224. if(rename(THEME_DIR.'/'.$theme,THEME_DIR.'/'.$config['theme']['id']['value'])){
  225. $sDir=THEME_DIR.'/'.$config['theme']['id']['value'];
  226. $theme=$config['theme']['id']['value'];
  227. $replaceWg=false;
  228. }
  229. }
  230. $aTheme=array(
  231. 'name'=>$config['theme']['name']['value'],
  232. 'id'=>$config['theme']['id']['value'],
  233. 'version'=>$config['theme']['version']['value'],
  234. 'info'=>$config['theme']['info']['value'],
  235. 'author'=>$config['theme']['author']['value'],
  236. 'site'=>$config['theme']['site']['value'],
  237. 'update_url'=>$config['theme']['update_url']['value'],
  238. 'config'=>array(
  239. 'config'=>$this->__changeXMLArray($config['theme']['config']['set']),
  240. 'borders'=>$this->__changeXMLArray($config['theme']['borders']['set']),
  241. 'views'=>$this->__changeXMLArray($config['theme']['views']['view'])
  242. )
  243. );
  244. $aWidgets=$wightes_info['theme']['widgets']['widget'];
  245. $aTheme['theme']=$theme;
  246. $aTheme['stime']=time();
  247. if(is_array($aTheme['config']['views']) && count($aTheme['config']['views'])>0){
  248. foreach($aTheme['config']['views'] as $v){
  249. $tmp[]=$v['tpl'];
  250. }
  251. $aTheme['template']=implode(',',$tmp);
  252. }else{
  253. $aTheme['template']='';
  254. }
  255. for($i=0;$i<count($aWidgets);$i++){
  256. $aTmp[$i]['base_file']='user:'.$aTheme['theme'].'/'.$aWidgets[$i]['attr']['file'];
  257. $aTmp[$i]['base_slot']=$aWidgets[$i]['attr']['slot'];
  258. $aTmp[$i]['widgets_type']=$aWidgets[$i]['attr']['type'];
  259. $aTmp[$i]['widgets_order']=$aWidgets[$i]['attr']['order'];
  260. $aTmp[$i]['title']=$aWidgets[$i]['attr']['title'];
  261. $aTmp[$i]['domid']=$aWidgets[$i]['attr']['domid'];
  262. $aTmp[$i]['border']=$aWidgets[$i]['attr']['border'];
  263. $aTmp[$i]['classname']=$aWidgets[$i]['attr']['classname'];
  264. $aTmp[$i]['tpl']=$aWidgets[$i]['attr']['tpl'];
  265. $aTmp[$i]['base_id']=$aWidgets[$i]['attr']['baseid'];
  266. /*$set=$aWidgets[$i]['set'];
  267. $aSet = array();
  268. for($y=0;$y<count($set);$y++){
  269. $aSet[$set[$y]['attr']['key']]=$set[$y]['attr']['value'];
  270. }*/
  271. $aTmp[$i]['params']=strtr($aWidgets[$i]['value'], array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
  272. }
  273. $aWidgets=$aTmp;
  274. $aNumber=$this->countWidgetsByTheme($theme);
  275. $nNumber=intval($aNumber['num']);
  276. $insertWidgets=false;
  277. if($replaceWg){
  278. if($nNumber){
  279. $this->deleteWidgetsByTheme($theme);
  280. }
  281. $insertWidgets=true;
  282. }else{
  283. if($nNumber==0){
  284. $insertWidgets=true;
  285. }
  286. }
  287. if($insertWidgets && count($aWidgets)>0){
  288. foreach($aWidgets as $k=>$wg){
  289. $this->insertWidgets($wg);
  290. }
  291. }
  292. if(!$this->updateThemes($aTheme)){
  293. return false;
  294. }else{
  295. return $aTheme;
  296. }
  297. }
  298. function countWidgetsByTheme($sTheme){
  299. return $this->db->selectrow('select count("widgets_id") as num from sdb_widgets_set where base_file like "user:'.$sTheme.'%"');
  300. }
  301. function deleteWidgetsByTheme($sTheme){
  302. return $this->db->query('delete from sdb_widgets_set where base_file like "user:'.$sTheme.'%"');
  303. }
  304. function insertWidgets($aData){
  305. $rs=$this->db->query('select * from sdb_widgets_set where 1');
  306. $aData['params']=str_replace('\'','\\\'',$aData['params']);
  307. $sSQL= $this->db->GetInsertSQL($rs,$aData);
  308. if(!$sSQL || $this->db->query($sSQL)){
  309. return true;
  310. }else{
  311. return false;
  312. }
  313. }
  314. function __buildDir($sDir){
  315. if(file_exists($sDir)){
  316. $aTmp=explode('/',$sDir);
  317. $sTmp=end($aTmp);
  318. if(strpos($sTmp,'(')){
  319. $i=substr($sTmp,strpos($sTmp,'(')+1,-1);
  320. $i++;
  321. $sDir=str_replace('('.($i-1).')','('.$i.')',$sDir);
  322. }else{
  323. $sDir.='(1)';
  324. }
  325. return $this->__buildDir($sDir);
  326. }else{
  327. return $sDir.'/';
  328. }
  329. }
  330. function __removeDir($sDir) {
  331. if($rHandle=opendir($sDir)){
  332. while(false!==($sItem=readdir($rHandle))){
  333. if ($sItem!='.' && $sItem!='..'){
  334. if(is_dir($sDir.'/'.$sItem)){
  335. $this->__removeDir($sDir.'/'.$sItem);
  336. }else{
  337. if(!unlink($sDir.'/'.$sItem)){
  338. trigger_error('??????????'.$sDir.'/'.$sItem.'????',E_USER_NOTICE);
  339. }
  340. }
  341. }
  342. }
  343. closedir($rHandle);
  344. rmdir($sDir);
  345. return true;
  346. }else{
  347. return false;
  348. }
  349. }
  350. function updateThemes($aData){//?? sdb_themes
  351. $rs=$this->db->query('select * from sdb_themes where theme="'.$aData['theme'].'"');
  352. $sql= $this->db->GetUpdateSQL($rs,$aData,true);
  353. return (!$sql || $this->db->exec($sql));
  354. }
  355. function setDefault($theme){
  356. return $this->system->setConf('system.ui.current_theme',$theme);
  357. //exit();
  358. }
  359. function reset($theme,$xml=''){
  360. return $this->initTheme($theme,true,'',$xml);
  361. }
  362. function getDefault(){
  363. $defaultTheme=$this->system->getConf('system.ui.current_theme');
  364. $this->separatXml($defaultTheme);
  365. return $defaultTheme;
  366. }
  367. function separatXml($theme){
  368. $workdir = getcwd();
  369. chdir(THEME_DIR.'/'.$theme);
  370. if(!is_file('info.xml')){
  371. $content=file_get_contents('theme.xml');
  372. $rContent=substr($content,0,strpos($content,'<widgets>'));
  373. /*
  374. $xml = $this->system->loadModel('utility/xml');
  375. $content=file_get_contents('theme.xml');
  376. $config = $xml->xml2arrayValues($content);
  377. $info=array();
  378. foreach($config['theme'] as $k=>$v){
  379. if($k!='widgets'){
  380. $info[$k]=$v;
  381. }
  382. }
  383. */
  384. file_put_contents('info.xml',$rContent.'</theme>');
  385. }
  386. chdir($workdir);
  387. }
  388. function outputPkg($theme){
  389. $tar = $this->system->loadModel('utility/tar');
  390. $workdir = getcwd();
  391. if(chdir(THEME_DIR.'/'.$theme)){
  392. $this->__getAllFiles('.',$aFile);
  393. for($i=0;$i<count($aFile);$i++){
  394. if($f = substr($aFile[$i],2)){
  395. if($f!='theme.xml'){
  396. $tar->addFile($f);
  397. }
  398. }
  399. }
  400. if(is_file('info.xml')){
  401. $tar->addFile('info.xml',file_get_contents('info.xml'));
  402. }
  403. $tar->addFile('theme.xml',$this->__makeConfigFile($theme));
  404. //$tar->addFile('info.xml',$this->__makeConfigFile($theme));
  405. $aTheme=$this->getThemeInfo($theme);
  406. $this->system->session->close();
  407. $charset = $this->system->loadModel('utility/charset');
  408. //$name = $charset->utf2local(preg_replace('/\s/','-',$aTheme['name'].'-'.$aTheme['version']),'zh');
  409. $name = $charset->utf2local(preg_replace('/\s/','-',$aTheme['name'].'-'.$aTheme['version']),'zh');
  410. @set_time_limit(0);
  411. //header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  412. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  413. header('Content-type: application/octet-stream');
  414. header('Content-type: application/force-download');
  415. header('Content-Disposition: attachment; filename="'.$name.'.tgz"');
  416. $tar->getTar('output');
  417. chdir($workdir);
  418. }else{
  419. chdir($workdir);
  420. return false;
  421. }
  422. }
  423. function __getAllFiles($sDir,&$aFile){
  424. if($rHandle=opendir($sDir)){
  425. while(false!==($sItem=readdir($rHandle))){
  426. if ($sItem!='.' && $sItem!='..' && $sItem!=''){
  427. if(is_dir($sDir.'/'.$sItem)){
  428. $this->__getAllFiles($sDir.'/'.$sItem,$aFile);
  429. }else{
  430. $aFile[]=$sDir.'/'.$sItem;
  431. }
  432. }
  433. }
  434. closedir($rHandle);
  435. }
  436. }
  437. function __makeConfigFile($sTheme){
  438. $aTheme=$this->getThemeInfo($sTheme);
  439. $aWidget['widgets']=$this->getWidgetsInfo($sTheme);
  440. foreach($aWidget['widgets'] as $i=>$widget){
  441. $aWidget['widgets'][$i]['params']=$aWidget['widgets'][$i]['params'];
  442. $aWidget['widgets'][$i]['base_file']=str_replace('user:'.$sTheme.'/','',$aWidget['widgets'][$i]['base_file']);
  443. }
  444. $aTheme['config']['config']=$aTheme['config']['config'];
  445. $aTheme['config']['views']=$aTheme['views'];
  446. $aTheme['id']=$aTheme['theme'];
  447. $smarty = &$this->system->loadModel('system/frontend');
  448. $aTheme=array_merge($aTheme,$aWidget);
  449. foreach($aTheme as $k=>$v){
  450. $smarty->assign($k,$v);
  451. }
  452. $sXML=$smarty->fetch('admin:system/template/theme.xml');
  453. return $sXML;
  454. }
  455. function __changeXMLArray($aArray){
  456. for($i=0;$i<count($aArray);$i++){
  457. $aData[$i]=$aArray[$i]['attr'];
  458. }
  459. return $aData;
  460. }
  461. function getThemeInfo($sTheme){
  462. $info = $this->db->selectrow('select * from sdb_themes where theme="'.$sTheme.'"');
  463. if(isset($info['config'])){
  464. $info['config'] = unserialize($info['config']);
  465. }
  466. return $info;
  467. }
  468. function getWidgetsInfo($sName){
  469. return $this->db->select('select * from sdb_widgets_set where base_file like "user:'.$sName.'/%"');
  470. }
  471. //todo page?????
  472. function htmEdit($src){
  473. return $this->db->selectrow('select * from sdb_pages where page_title="'.$src.'"');
  474. }
  475. function editHtml($title,$data){
  476. $dat=$this->db->selectrow('select * from sdb_pages where page_title="'.$title.'"');
  477. if($dat['page_title']){
  478. $rs=$this->db->query('select * from sdb_pages where page_title="'.$title.'"');
  479. $sql=$this->db->GetUpdateSQL($rs,$data);
  480. }else{
  481. $rs=$this->db->query('select * from sdb_pages where 1');
  482. $sql= $this->db->GetInsertSQL($rs,array_merge($data,array('page_title'=>$title)));
  483. }
  484. return (!$sql || $this->db->exec($sql));
  485. }
  486. function templateConfig($sTemplate){
  487. $aData=$this->db->selectrow('select config from sdb_themes where theme="'.$sTemplate.'"');
  488. $aData=unserialize($aData['config']);
  489. if(count($aData)>0){
  490. foreach($aData as $k=>$v){
  491. $tmp[]=array('key'=>$k,'value'=>$v);
  492. }
  493. }
  494. return array('total'=>count($aData),'main'=>$tmp);
  495. }
  496. function templateConfigEdit($sTemplate,$sKey,$sValue){
  497. $aData=$this->db->selectrow('select config from sdb_themes where name="'.$sTemplate.'"');
  498. $aConfig=unserialize($aData['config']);
  499. $aConfig[$sKey]=$sValue;
  500. $aTmp=array('config'=>serialize($aConfig));
  501. $rs=$this->db->query('select config from sdb_themes where name="'.$sTemplate.'"');
  502. $sql=$this->db->GetUpdateSQL($rs,$aTmp);
  503. if(!$sql || $this->db->query($sql)){
  504. return true;
  505. }else{
  506. return false;
  507. }
  508. }
  509. function applyTheme($theme=null){
  510. if($_COOKIE['PREVIEW_THEME']){
  511. return $this->getThemeInfo($_COOKIE['PREVIEW_THEME']);
  512. }
  513. if(!$theme){
  514. $theme = $this->system->getConf('system.ui.current_theme');
  515. define('TPL_ID',$theme);
  516. }
  517. return $this->getThemeInfo($theme);
  518. }
  519. function getContent($theme,$file){
  520. return file_get_contents(THEME_DIR.'/'.$theme.'/'.$file);
  521. }
  522. function delFile($theme,$file){
  523. return unlink(THEME_DIR.'/'.$theme.'/'.$file);
  524. }
  525. function saveTemplate($file,$theme,$content){
  526. $aData['template_source']=$content;
  527. $aData['theme']=$theme;
  528. $aData['template_name']=$file;
  529. if($rs=$this->db->query('select sdb_template_id from sdb_template where theme="'.$theme.'" and "template_name='.$file.'"')){
  530. if(!$this->db->GetUpdateSQL($rs,$aData)){
  531. return false;
  532. }
  533. }else{
  534. if(!$this->db->GetInsertSQL($rs,$aData)){
  535. return false;
  536. }
  537. }
  538. return true;
  539. }
  540. function setContent($theme,$file,$content){
  541. if($content){
  542. return file_put_contents(THEME_DIR.'/'.$theme.'/'.$file,stripslashes($content));
  543. }else{
  544. return false;
  545. }
  546. }
  547. function getListName($name){
  548. $ctl = array(
  549. 'default.html'=>'????',
  550. 'index.html'=>'??',
  551. 'article.html'=>'???',
  552. 'product.html'=>'?????',
  553. 'comment.html'=>'????/???',
  554. 'gallery.html'=>'?????',
  555. 'cart.html'=>'????',
  556. 'gift.html'=>'???',
  557. 'member.html'=>'?????',
  558. 'page.html'=>'???????',
  559. 'passport.html'=>'??/???',
  560. 'search.html'=>'?????'
  561. );
  562. return $ctl[$name];
  563. }
  564. function templateList($theme){//??????
  565. include('shopctls.php');
  566. $ctl = array(
  567. 'gallery'=>'?????',
  568. 'product'=>'?????',
  569. 'page'=>'???????',
  570. 'article'=>'???',
  571. 'cart'=>'????',
  572. 'comment'=>'????/???',
  573. 'member'=>'?????',
  574. 'passport'=>'??/???',
  575. 'search'=>'?????'
  576. );
  577. $data = array(
  578. array('name'=>'??','file'=>'index.html','available'=>file_exists(THEME_DIR.'/'.$theme.'/index.html')),
  579. );
  580. foreach($controllers as $c=>$a){
  581. if($ctl[$c]){
  582. $item = array('name'=>$ctl[$c],'items'=>array(),'file'=>($file=$c.'.html'),'available'=>file_exists(THEME_DIR.'/'.$theme.'/'.$file));
  583. foreach($a as $act=>$i){
  584. $item['items'][] = array_merge(array(
  585. 'act'=>$act,
  586. 'file'=>($file = $c.'-'.$act.'.html'),
  587. 'available'=>file_exists(THEME_DIR.'/'.$theme.'/'.$file),
  588. ),$i);
  589. }
  590. $data[]=$item;
  591. }
  592. }
  593. $data[]=array('name'=>'????','file'=>'default.html','available'=>file_exists(THEME_DIR.'/'.$theme.'/default.html'));
  594. return $data;
  595. }
  596. }
  597. ?>