⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 templatecontroller.php

📁 a short sketch about linux syntex lines.
💻 PHP
字号:
<?php
class TemplateController  extends Easy_Controller_Action {
	public function Init(){
		$this->_IO = new Easy_Filesystem();
	}
	public function indexAction(){
		if ($this->_Request->getParam('path')){
			$path = base64_decode($this->_Request->getParam('path'));
		}else{
			$path = ROOT.'templates';
		}
		$filter = array('public', '.svn', 'member');
		$this->_View->files = $this->_IO->scandir($path, $filter);
	}
	public function modifyAction(){
		$this->_View->filename = base64_decode($this->_Request->getParams('file'));
		if ($this->_Request->isPost()){
			$contents =$this->_Request->getPost('textarea');
			if ($contents){
				if ($this->config['createuser'] != $this->_Request->getCookie('admin')){
					$this->_View->subject = _('保存修改失败!');
					$this->_View->message = _('保存修改成功!');
				}else{
					copy($this->_View->filename, $this->_View->filename.'.bak');
					if ($this->_IO->wfile($this->_View->filename, $contents)===false){
						$this->_View->subject = _('保存修改失败!');
						$this->_View->message = $this->_IO->error;
					}else{
						$this->_View->message = _('保存修改成功!');
					}
				}
			}else{
				$this->_View->message = _('保存修改成功失败,内容不能为空!');
			}
			exit($this->_View->render('message'));
		}
		$this->_View->contents = $this->_IO->file_get_content($this->_View->filename);
	}
	public function downAction(){
		$this->_View->filename = base64_decode($this->_Request->getParams('file'));
		$this->_IO->attachment($this->_View->filename);
	}
	public function viewAction(){
		$path = ROOT.'templates';
		$filter = array('public', '.svn', 'member');
		$data = array();
		$array = array();
		foreach($this->_IO->scandir($path, $filter) as $files){
			if (is_dir($files)){
				foreach ($this->_IO->scandir($files) as $file){
					if (basename($file) == 'demo.jpg'){
						$array['picture'] = $file;
					}elseif (basename($file) =='info.ini'){
						$array['ini'] = parse_ini_file($file);
					}elseif (basename($file) =='config.ini'){
						$array['ini'] = parse_ini_file($file);
					}
				}
				$data[basename($files)] = $array;
			}
		}
		$this->_View->template = $this->config['template'];
		$this->_View->data = $data;
	}
	public function setAction(){
		$skin = $this->_Request->getParam('name');
		if ($skin){
			$filename = ROOT.'config/config.inc.php';
			$contents = file_get_contents($filename);
			$contents = preg_replace('/\$config\[\'template\'\]+\s+\=+\s+(.+?);/is', '$config[\'template\'] = \''.$skin.'\';', $contents);
			//copy($this->_View->filename, basename($this->_View->filename).'.bak.php');
			$this->_IO->wfile($filename, $contents);
			$vodcms = new VodcmsModel();
			$vodcms->clean();
			$this->_View->message = _('风格设置成功!');
			exit($this->_View->render('message'));
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -