更新部分注释

This commit is contained in:
TOP糯米 2019-06-21 11:36:49 +08:00
parent 8ef1bae0e0
commit a0dd742016
26 changed files with 90 additions and 93 deletions

View File

@ -6,7 +6,7 @@ return [
// 'Top' => top\library\template\Top::class,
],
'decorator' => [
app\home\decorator\Log::class
\app\home\decorator\Log::class
],
'session' => [
'open' => true,
@ -18,7 +18,7 @@ return [
'user' => 'root',
'passwd' => '',
'dbname' => '',
'prefix' => 'cms_',
'prefix' => 't_',
'charset' => 'utf8'
],
'view' => [

View File

@ -4,22 +4,22 @@ namespace app\home\controller;
use app\home\model\Job;
class Index extends Common {
class Index extends Common
{
public function _init() {
echo 1;
}
public function index() {
public function index()
{
$model = model(Job::class);
return [
'title' => '测试',
'lists' => $model->select(),
'title' => 'test',
'lists' => $model->order('id desc')->select(),
'query' => $model->sql
];
}
public function testPage() {
public function testPage()
{
return $this->fetch('', [
'a' => '测试页面',
]);

View File

@ -5,18 +5,19 @@ namespace app\home\decorator;
use top\decorator\ifs\DecoratorIfs;
use top\library\Register;
class Log implements DecoratorIfs {
class Log implements DecoratorIfs
{
public function before() {
// TODO: Implement before() method.
public function before()
{
}
/**
* @param array $data
* @throws \Exception
*/
public function after($data) {
// TODO: Implement after() method.
public function after($data)
{
$router = Register::get('Router');
$message = '当前访问:';
$message .= $router->module . '.';

View File

@ -6,10 +6,10 @@ use top\library\Model;
/**
* 模型示例
* Class Example
* @package app\home\model
*/
class Example extends Model {
class Example extends Model
{
protected $table = 'users';
protected $pk = 'id';
@ -44,11 +44,11 @@ class Example extends Model {
/**
* 将字符串时间格式化为unix时间戳
*
* @param $param
* @return false|int
*/
public function getIntTime($param) {
public function getIntTime($param)
{
return strtotime($param);
}

View File

@ -4,6 +4,7 @@ namespace app\home\model;
use top\library\Model;
class Job extends Model {
class Job extends Model
{
}

View File

@ -1 +1 @@
{$a}
{{ a }}

View File

@ -5,10 +5,6 @@ return [
null,
'home/auth/login'
],
'users-edit' => [
'[id]',
'home/users/edit'
],
'intention-detail' => [
'[id]',
'home/intention/detail'
@ -17,12 +13,4 @@ return [
'[:type]',
'home/permission/index'
],
'permission-add' => [
'[:id]',
'home/permission/add'
],
'permission-update' => [
'[id]',
'home/permission/update'
],
];

View File

@ -21,6 +21,7 @@ class ReturnDecorator implements DecoratorIfs
/**
* 布尔或数组则显示视图
* @param array $data
* @throws \Exception
*/
public function after($data)
{

View File

@ -6,14 +6,13 @@ use top\library\Loader;
/**
* 文件上传类
* @author TOP糯米
* @author topnuomi
*/
class Upload
{
private static $instance;
private static $fileType;
private static $dirName;
private $image;
private $error;
private function __construct()

View File

@ -4,7 +4,7 @@ namespace top\extend;
/**
* 水印处理类
* @author TOP糯米
* @author topnuomi
*/
class Water
{

View File

@ -9,7 +9,7 @@ class App
{
/**
* 执行
* start
* @param int $type
* @param string $defaultModule
*/

View File

@ -23,7 +23,6 @@ class Config
private function __clone()
{
// TODO: Implement __clone() method.
}
public static function instance()
@ -36,7 +35,6 @@ class Config
/**
* 添加配置
*
* @param string $name
* @param string $value
*/

View File

@ -70,7 +70,6 @@ class Database
private function __clone()
{
// TODO: Implement __clone() method.
}
/**

View File

@ -19,7 +19,6 @@ class Register
private function __clone()
{
// TODO: Implement __clone() method.
}
/**

View File

@ -20,7 +20,6 @@ class Template
private $param = [];
/**
*
* @param TemplateIfs $template
*/
private function __construct(TemplateIfs $template)
@ -30,7 +29,6 @@ class Template
private function __clone()
{
// TODO: Implement __clone() method.
}
/**

View File

@ -43,7 +43,6 @@ class View
private function __clone()
{
// TODO: Implement __clone() method.
}
/**

View File

@ -27,8 +27,9 @@ class File implements CacheIfs
/**
* 设置缓存
* {@inheritdoc}
* @see \top\library\cache\CacheIfs::set()
* @param string $name
* @param string $value
* @return bool
*/
public function set($name = '', $value = '')
{
@ -47,22 +48,18 @@ class File implements CacheIfs
/**
* 获取缓存
* {@inheritdoc}
* @see \top\library\cache\CacheIfs::get()
* @param string $name
*/
public function get($name = '')
{
// TODO Auto-generated method stub
}
/**
* 删除缓存
* {@inheritdoc}
* @see \top\library\cache\CacheIfs::_unset()
* @param string $name
*/
public function _unset($name = '')
{
// TODO Auto-generated method stub
}
/**

View File

@ -30,6 +30,10 @@ class MySQLi implements DatabaseIfs
{
}
private function __clone()
{
}
/**
* 连接数据库
* @param array $config
@ -43,6 +47,7 @@ class MySQLi implements DatabaseIfs
throw new DatabaseException(mysqli_connect_error());
}
mysqli_query($link, 'set names ' . $config['charset']);
return $this;
}
@ -67,7 +72,6 @@ class MySQLi implements DatabaseIfs
foreach ($data as $key => $value) {
$query = 'insert into ' . $table;
$allField = ' (' . implode(',', array_keys($value)) . ')';
$allValue = array_values($value);
$allValue = '(' . implode(',', $this->checkNull($value)) . ')';
$this->sql = $query .= $allField . ' values ' . $allValue . ';';
$this->query($query);
@ -272,8 +276,9 @@ class MySQLi implements DatabaseIfs
public function query($query)
{
$result = mysqli_query($this->link, $query);
if (!$result)
if (!$result) {
throw new DatabaseException(mysqli_error($this->link));
}
// $this->writeLogs($result, $query);
return $result;
}
@ -463,7 +468,7 @@ class MySQLi implements DatabaseIfs
$content = <<<EOF
[{$nowTime}] SQL: {$query} {$error}\n
EOF;
file_put_contents(BASEDIR . '/framework/logs/db_logs.txt', $content, FILE_APPEND);
file_put_contents(FRAMEWORK_PATH . '/db_logs.txt', $content, FILE_APPEND);
}
}
@ -481,8 +486,6 @@ EOF;
return true;
}
/**
*/
public function __destruct()
{
$this->close();

View File

@ -36,24 +36,28 @@ interface DatabaseIfs
/**
* 查找一条记录
* @param string $table
* @param string|array $field
* @param array $join
* @param string|array $on
* @param string|array $where
* @param string $order
* @param $table
* @param $distinct
* @param $field
* @param $join
* @param $on
* @param $where
* @param $order
* @return mixed
*/
public function find($table, $distinct, $field, $join, $on, $where, $order);
/**
* 查找全部
* @param string $table
* @param string|array $field
* @param array $join
* @param string|array $on
* @param string|array $where
* @param string $order
* @param string $limit
* @param $table
* @param $distinct
* @param $field
* @param $join
* @param $on
* @param $where
* @param $order
* @param $limit
* @return mixed
*/
public function select($table, $distinct, $field, $join, $on, $where, $order, $limit);

View File

@ -9,6 +9,11 @@ function request()
return $request;
}
/**
* 调用模型
* @param $class
* @return mixed
*/
function model($class)
{
static $model = [];

View File

@ -26,6 +26,10 @@ class Request
$this->server = (!empty($_SERVER)) ? $_SERVER : [];
}
private function __clone()
{
}
public function method()
{
return (isset($this->server['REQUEST_METHOD']) && $this->server['REQUEST_METHOD'] != '') ? $this->server['REQUEST_METHOD'] : '';

View File

@ -86,9 +86,7 @@ class Pathinfo implements RouteIfs
*/
public function param()
{
unset($this->uriArray[0]);
unset($this->uriArray[1]);
unset($this->uriArray[2]);
unset($this->uriArray[0], $this->uriArray[1], $this->uriArray[2]);
$this->uriArray = array_merge($this->uriArray, []);
if (!empty($this->uriArray) && class_exists($this->class)) {
$paramName = (new \ReflectionMethod($this->class, $this->action))->getParameters();
@ -105,8 +103,7 @@ class Pathinfo implements RouteIfs
}
}
}
unset($paramName);
unset($paramNameArray);
unset($paramName, $paramNameArray);
return $param;
}
return [];
@ -152,9 +149,7 @@ class Pathinfo implements RouteIfs
}
}
$this->uri = $uri;
// unset($uri);
unset($paramArray);
unset($name);
unset($paramArray, $name);
return $uri;
}
@ -168,7 +163,7 @@ class Pathinfo implements RouteIfs
}
/**
* 返回解析出的数据 home/controller/index
* 赋值解析出的数据
* @throws \ReflectionException
*/
public function processing()

View File

@ -5,7 +5,8 @@ namespace top\library\template\driver;
use top\library\Register;
use top\library\template\ifs\TemplateIfs;
class Smarty implements TemplateIfs {
class Smarty implements TemplateIfs
{
private static $instance;
@ -13,20 +14,24 @@ class Smarty implements TemplateIfs {
private $smarty;
private function __construct() {
private function __construct()
{
}
private function __clone() {
private function __clone()
{
}
public static function instance() {
public static function instance()
{
if (!self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
public function run() {
public function run()
{
$this->config = Register::get('Config')->get('view');
$this->smarty = new \Smarty();
(isset($this->config['cacheDir'])) && $this->smarty->setCacheDir($this->config['cacheDir']);
@ -34,15 +39,18 @@ class Smarty implements TemplateIfs {
return $this;
}
public function cache($status) {
public function cache($status)
{
$time = (isset($this->config['cacheTime'])) ? $this->config['cacheTime'] : \Smarty::CACHING_LIFETIME_CURRENT;
$this->smarty->setCaching($time);
return true;
}
public function fetch($file, $param, $cache) {
foreach ($param as $k => $v)
public function fetch($file, $param, $cache)
{
foreach ($param as $k => $v) {
$this->smarty->assign($k, $v);
}
$templateFile = $this->config['dir'] . $file . '.' . $this->config['ext'];
return $this->smarty->fetch($templateFile);
}

View File

@ -21,6 +21,7 @@ class Top implements TemplateIfs
// 视图配置
private $config;
// 缓存状态
private $cacheStatus = false;
public static function instance()

View File

@ -20,7 +20,6 @@ class Twig implements TemplateIfs
private function __clone()
{
// TODO: Implement __clone() method.
}
public static function instance()
@ -33,14 +32,12 @@ class Twig implements TemplateIfs
public function run()
{
// TODO: Implement run() method.
$this->config = Register::get('Config')->get('view');
return $this;
}
public function cache($status)
{
// TODO: Implement cache() method.
return true;
}

View File

@ -122,7 +122,7 @@ class Tags
private function processingViewTag($filename)
{
$tags = [
'view:name' => '$___view__config = \\framework\\library\\Register::get(\'Config\')->get(\'view\'); require BASEDIR . \'/\' . $___view__config[\'dir\'] . \'name\' . \'.\' . $___view__config[\'ext\'];'
'view:name' => '$__view__config = \\framework\\library\\Register::get(\'Config\')->get(\'view\'); require BASEDIR . \'/\' . $__view__config[\'dir\'] . \'name\' . \'.\' . $__view__config[\'ext\'];'
];
$this->setTags($tags);
$content = file_get_contents($filename);
@ -168,7 +168,7 @@ class Tags
// 最终过滤内容中?\>与<?php中间的内容
$result = preg_replace('#\?>([\r|\n|\s]*?)<\?php#', '', $result);
$filename = $this->compileDir . md5($filename) . '.php';
file_put_contents($filename, "<?php /* TOP糯米 */ (!defined('BASEDIR')) && exit(0); ?>" . $result);
file_put_contents($filename, "<?php /* topnuomi */ (!defined('BASEDIR')) && exit(0); ?>" . $result);
return $filename;
}
}