1
0

init commit

This commit is contained in:
2021-05-13 11:35:49 +08:00
commit a2db70af8b
18 changed files with 541 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
/vendor/
/cache/
/composer.lock
/.vscode/*

1
README.md Normal file
View File

@@ -0,0 +1 @@
# Yaf CMS

28
app/Bootstrap.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {
public function _initLoad()
{
Yaf_Loader::import(APP_PATH . '/vendor/autoload.php');
}
public function _initConfig(Yaf_Dispatcher $dispatcher) {
// 把配置保存起来
Yaf_Registry::set('config', Yaf_Application::app()->getConfig());
if (Yaf_Application::app()->environ() !== 'product') {
error_reporting(E_ALL & ~ E_NOTICE);
ini_set('display_errors', 1);
}
}
public function _initView(Yaf_Dispatcher $dispatcher) {
// 禁用yaf自带的模板引擎
Yaf_Dispatcher::getInstance()->disableView();
//设置smarty
$smarty = new Smarty_Adapter(null , Yaf_Application::app()->getConfig()->smarty);
return Yaf_Dispatcher::getInstance()->setView($smarty);
}
}

16
app/controllers/Error.php Normal file
View File

@@ -0,0 +1,16 @@
<?php
/**
* ErrorController 错误处理
*/
class ErrorController extends Yaf_Controller_Abstract {
public function errorAction($exception) {
$code = $exception->getCode();
$errMsg = $exception->getMessage();
var_dump($errMsg);
return false;
}
}

17
app/controllers/Index.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
class IndexController extends Yaf_Controller_Abstract {
protected function init() {
echo "IndexController\n";
}
/* action method may have arguments */
function indexAction() {
return false;
}
function loginAction() {
return false;
}
}

8
app/controllers/Log.php Normal file
View File

@@ -0,0 +1,8 @@
<?php
class LogController extends Yaf_Controller_Abstract {
/* action method may have arguments */
function indexAction() {
}
}

View File

@@ -0,0 +1,174 @@
<?php
/**
*
* @Author: Carl
* @Since: 2017-11-23 11:45
* Created by PhpStorm.
*/
class Smarty_Adapter implements Yaf_View_Interface
{
/**
* Smarty object
* @var Smarty
*/
public $_smarty;
/**
* Constructor
*
* @param string $tmplPath
* @param array $extraParams
* @return void
*/
public function __construct($tmplPath = null, $extraParams = array()) {
$this->_smarty = new Smarty;
if (null !== $tmplPath) {
$this->setScriptPath($tmplPath);
}
foreach ($extraParams as $key => $value) {
$this->_smarty->$key = $value;
}
}
/**
* Return the template engine object
*
* @return Smarty
*/
public function getEngine() {
return $this->_smarty;
}
/**
* Set the path to the templates
*
* @param string $path The directory to set as the path.
* @return void
*/
public function setScriptPath($path)
{
debug_print_backtrace();
if (is_readable($path)) {
$this->_smarty->template_dir = $path;
return;
}
throw new Exception("Invalid path `${path}` provided");
}
/**
* Retrieve the current template directory
*
* @return string
*/
public function getScriptPath($request = NULL)
{
return $this->_smarty->template_dir;
}
/**
* Alias for setScriptPath
*
* @param string $path
* @param string $prefix Unused
* @return void
*/
public function setBasePath($path, $prefix = 'Zend_View')
{
return $this->setScriptPath($path);
}
/**
* Alias for setScriptPath
*
* @param string $path
* @param string $prefix Unused
* @return void
*/
public function addBasePath($path, $prefix = 'Zend_View')
{
return $this->setScriptPath($path);
}
/**
* Assign a variable to the template
*
* @param string $key The variable name.
* @param mixed $val The variable value.
* @return void
*/
public function __set($key, $val)
{
$this->_smarty->assign($key, $val);
}
/**
* Allows testing with empty() and isset() to work
*
* @param string $key
* @return boolean
*/
public function __isset($key)
{
return (null !== $this->_smarty->get_template_vars($key));
}
/**
* Allows unset() on object properties to work
*
* @param string $key
* @return void
*/
public function __unset($key)
{
$this->_smarty->clear_assign($key);
}
/**
* Assign variables to the template
*
* Allows setting a specific key to the specified value, OR passing
* an array of key => value pairs to set en masse.
*
* @see __set()
* @param string|array $spec The assignment strategy to use (key or
* array of key => value pairs)
* @param mixed $value (Optional) If assigning a named variable,
* use this as the value.
* @return void
*/
public function assign($spec, $value = null) {
if (is_array($spec)) {
$this->_smarty->assign($spec);
return;
}
$this->_smarty->assign($spec, $value);
}
/**
* Clear all assigned variables
*
* Clears all variables assigned to Zend_View either via
* {@link assign()} or property overloading
* ({@link __get()}/{@link __set()}).
*
* @return void
*/
public function clearVars() {
$this->_smarty->clear_all_assign();
}
/**
* Processes a template and returns the output.
*
* @param string $name The template to process.
* @return string The output.
*/
public function render($name, $value = NULL) {
return $this->_smarty->fetch($name);
}
public function display($name, $value = NULL) {
echo $this->_smarty->fetch($name);
}
}

View File

@@ -0,0 +1,10 @@
<?php
class UserController extends Yaf_Controller_Abstract {
function listAction() {
echo json_encode(array(
));
}
}

View File

@@ -0,0 +1,197 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>仪表盘</title>
<meta content="noarchive" name="robots">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.18/css/AdminLTE.min.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.18/css/skins/_all-skins.min.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<header class="main-header">
<a href="#" class="logo">
<span class="logo-mini"><b>后</b></span>
<span class="logo-lg"><b>后台管理</b></span>
</a>
<nav class="navbar navbar-static-top">
<a href="#" class="sidebar-toggle" data-toggle="push-menu">
<span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="//cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.18/img/avatar.png" class="user-image" alt="用户头像">
<span class="hidden-xs">dragonflylee@126.com</span>
</a>
<ul class="dropdown-menu">
<li class="user-header">
<img src="//cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.18/img/avatar.png" class="img-circle" alt="用户头像">
<p>
dragonflylee@126.com
<small>超级管理员</small>
<small>上次登录 2021-05-13 16:15:45</small>
</p>
</li>
<li class="user-footer">
<div class="pull-left">
<a href="/profile" class="btn btn-default btn-flat">个人中心</a>
</div>
<div class="pull-right">
<a href="/logout" class="btn btn-default btn-flat">注销</a>
</div>
</li>
</ul>
</li>
</ul>
</div>
</nav>
</header>
<aside class="main-sidebar">
<section class="sidebar">
<div class="user-panel">
<div class="pull-left image">
<img src="//cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.18/img/avatar.png" class="img-circle" alt="用户头像">
</div>
<div class="pull-left info">
<P>超级管理员</P>
<a href="#" title="dragonflylee@126.com"><i class="fa fa-circle text-success"></i> 在线</a>
</div>
</div>
<form class="sidebar-form">
<div class="input-group">
<input type="text" name="q" class="form-control" placeholder="搜索..." value="">
<span class="input-group-btn">
<button type="submit" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i></button>
</span>
</div>
</form>
<ul class="sidebar-menu" data-widget="tree">
<li class="active">
<a href="/">
<i class="fa fa-dashboard"></i>
<span>仪表盘</span>
</a>
</li>
<li class="treeview ">
<a href="#">
<i class="fa fa-gears"></i> <span>系统管理</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<ul class="treeview-menu">
<li>
<a href="/log">
<i class="fa fa-sticky-note-o"></i>
<span>日志查看</span>
</a>
</li>
<li>
<a href="/user">
<i class="fa fa-users"></i>
<span>用户管理</span>
</a>
</li>
</ul>
</li>
<li>
<a href="/article">
<i class="fa fa-user-o"></i>
<span>文章管理</span>
</a>
</li>
</ul>
</section>
</aside>
<div class="content-wrapper">
<section class="content-header">
<h1>
仪表盘
<small></small>
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
<li class="active">仪表盘</li>
</ol>
</section>
<section class="content">
<div class="row">
<div class="col-lg-3 col-xs-6">
<div class="small-box bg-aqua">
<div class="inner">
<h3>150</h3>
<p>新订单</p>
</div>
<div class="icon">
<i class="ion ion-bag"></i>
</div>
<a href="#" class="small-box-footer">更多 <i class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<div class="col-lg-3 col-xs-6">
<div class="small-box bg-green">
<div class="inner">
<h3>53<sup style="font-size: 20px">%</sup></h3>
<p>增长率</p>
</div>
<div class="icon">
<i class="ion ion-stats-bars"></i>
</div>
<a href="#" class="small-box-footer">更多 <i class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<div class="col-lg-3 col-xs-6">
<div class="small-box bg-yellow">
<div class="inner">
<h3>44</h3>
<p>用户注册</p>
</div>
<div class="icon">
<i class="ion ion-person-add"></i>
</div>
<a href="#" class="small-box-footer">更多 <i class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
<div class="col-lg-3 col-xs-6">
<div class="small-box bg-red">
<div class="inner">
<h3>65</h3>
<p>访问量</p>
</div>
<div class="icon">
<i class="ion ion-pie-graph"></i>
</div>
<a href="#" class="small-box-footer">更多 <i class="fa fa-arrow-circle-right"></i></a>
</div>
</div>
</div>
<div class="row">
<p>{% $ref %}</p>
</div>
</section>
</div>
<footer class="main-footer">
<div class="pull-right hidden-xs">
Powered by <b>1.0.0</b>
</div>
<strong>版权所有 &copy; 2020</strong>
</footer>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.18/js/adminlte.min.js"></script>
</div>
</body>
</html>

View File

@@ -0,0 +1,17 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>管理</title>
<meta content="noarchive" name="robots">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.4/css/bootstrap3/bootstrap-switch.min.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/iCheck/1.0.3/skins/square/blue.min.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker3.min.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.18/css/AdminLTE.min.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.18/css/skins/_all-skins.min.css" rel="stylesheet">
<!--[if lt IE 9]>"}}
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
{{html "<![endif]-->

View File

@@ -0,0 +1,11 @@
<?php
class IndexController extends Yaf_Controller_Abstract {
/* action method may have arguments */
function indexAction() {
echo json_encode(array(
));
}
}

0
cache/.gitkeep vendored Executable file
View File

8
composer.json Normal file
View File

@@ -0,0 +1,8 @@
{
"name": "dragonflylee/yafcms",
"description": "cms framework powerby yaf",
"require": {
"symfony/yaml": "^3.4",
"smarty/smarty": "^3"
}
}

17
conf/app.ini Normal file
View File

@@ -0,0 +1,17 @@
[common]
application.directory = APP_PATH "/app"
application.modules = "Admin"
application.dispatcher.throwException = True
application.dispatcher.catchException = True
application.view.ext = "tpl"
[smarty]
smarty.left_delimiter = "{% "
smarty.right_delimiter = " %}"
smarty.template_dir = APP_PATH "/view/"
smarty.compile_dir = APP_PATH "/cache/compile"
smarty.cache_dir = APP_PATH "/cache/"
[product : common : smarty]
[development : common : smarty]

22
conf/nginx.conf Normal file
View File

@@ -0,0 +1,22 @@
server {
listen 80;
server_name yaf.lvh.me;
access_log /var/log/nginx/yafcms.access.log;
error_log /var/log/nginx/yafcms.error.log;
root /var/www/yaf_cms/public;
index index.php;
charset utf-8;
location ~ .*\.php(\/.*)*$ {
include snippets/fastcgi-php.conf;
# 设置监听端口
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
if (!-e $request_filename) {
rewrite ^/(.*) /index.php/$1 last;
}
}

1
public/assets/css/ace.min.css vendored Normal file

File diff suppressed because one or more lines are too long

5
public/assets/js/ace.min.js vendored Normal file

File diff suppressed because one or more lines are too long

5
public/index.php Normal file
View File

@@ -0,0 +1,5 @@
<?php
define('APP_PATH', dirname(__DIR__)); //应用路径
$app = new Yaf_Application(APP_PATH . '/conf/app.ini');
$app->bootstrap()->run();