* Resolve confilict.

This commit is contained in:
liuchenglong
2023-05-06 01:51:00 +00:00
204 changed files with 5528 additions and 4160 deletions
+2 -1
View File
@@ -950,7 +950,8 @@ class baseControl
if(empty($moduleName)) $moduleName = $this->moduleName;
if(empty($methodName)) $methodName = $this->methodName;
include $this->app->getBasePath() . 'zin' . DS . 'zin.php';
/* Load zin lib */
$this->app->loadClass('zin', true);
/**
* 设置视图文件。(PHP7有一个bug,不能直接$viewFile = $this->setViewFile())。
+3 -3
View File
@@ -1381,8 +1381,8 @@ class baseRouter
}
else
{
$value = @getenv('PATH_INFO');
if(empty($value)) $value = @getenv('ORIG_PATH_INFO');
$value = getenv('PATH_INFO');
if(empty($value)) $value = getenv('ORIG_PATH_INFO');
}
if(str_contains((string) $value, (string) $_SERVER['SCRIPT_NAME'])) $value = str_replace($_SERVER['SCRIPT_NAME'], '', (string) $value);
@@ -2002,7 +2002,7 @@ class baseRouter
/* 生成一个临时的target扩展文件,并加载,用于后续的hook文件加载使用。Create a tmp merged target file and import it for merge hook codes using. */
$tmpTargetFile = $mergedTargetDir . "tmp$moduleName.php";
if(@file_put_contents($tmpTargetFile, $targetLines))
if(file_put_contents($tmpTargetFile, $targetLines))
{
if(!class_exists($tmpTargetClass)) include $tmpTargetFile;
return $targetLines;
+20
View File
@@ -21,6 +21,12 @@ use ZenTao\Cache\SimpleCache\InvalidArgumentException;
class cache
{
const DRIVER_APCU = 'Apcu';
const DRIVER_FILE = 'File';
const DRIVER_YAC = 'Yac';
/**
* @var ZenTao\Cache\SimpleCache\CacheInterface
*/
@@ -50,6 +56,20 @@ class cache
$this->client = new $className($namespace, $defaultLifetime, $app->getCacheRoot());
}
/**
* Create a cache instance.
*
* @param string $driver
* @param string $namespace
* @param int $defaultLifetime
* @access public
* @return object
*/
public static function create($driver = 'File', $namespace = '', $defaultLifetime = 0)
{
return new self($driver, $namespace, $defaultLifetime);
}
public function __call($name, $arguments)
{
if(!method_exists($this->client, $name)) throw new InvalidArgumentException("Method {$name} does not exist.");
+2 -13
View File
@@ -26,7 +26,7 @@ class form extends baseFixer
* 错误信息列表。
* Error list.
*
* @var object
* @var array
*/
public $errors;
@@ -114,7 +114,7 @@ class form extends baseFixer
{
if(!isset($this->errors[$field])) $this->errors[$field] = array();
$fieldName = isset($app->lang->{$app->rawModule}->$field) ? $app->lang->{$app->rawModule}->$field : $field;
$this->errors[$field][] = sprintf($lang->error->notempty, $fieldName);
$this->errors[$field][] = sprintf($app->lang->error->notempty, $fieldName);
}
}
@@ -138,17 +138,6 @@ class form extends baseFixer
$this->data->$field = $data;
}
/**
* 打印表单数据。
* Print the form data.
*
* @return void
*/
public function a()
{
a($this->data);
}
/**
* 过滤表单字段数据。
* Filter the form field data.
View File
@@ -13,7 +13,7 @@ namespace zin;
require_once dirname(__DIR__) . DS . 'utils' . DS . 'dataset.class.php';
require_once dirname(__DIR__) . DS . 'utils' . DS . 'flat.func.php';
require_once 'portal.class.php';
require_once __DIR__ . DS . 'portal.class.php';
class context extends \zin\utils\dataset
{
@@ -11,7 +11,7 @@
namespace zin;
require_once 'context.class.php';
require_once __DIR__ . DS . 'context.class.php';
function portal(/* string $name, mixed ...$children */)
{
@@ -11,7 +11,7 @@
namespace zin;
require_once 'zin.class.php';
require_once __DIR__ . DS . 'zin.class.php';
class directive
{
@@ -12,7 +12,7 @@
namespace zin;
require_once dirname(__DIR__) . DS . 'utils' . DS . 'deep.func.php';
require_once 'selector.func.php';
require_once __DIR__ . DS . 'selector.func.php';
class dom
{
@@ -12,8 +12,8 @@
namespace zin;
require_once dirname(__DIR__) . DS . 'utils' . DS . 'flat.func.php';
require_once 'wg.class.php';
require_once 'wg.func.php';
require_once __DIR__ . DS . 'wg.class.php';
require_once __DIR__ . DS . 'wg.func.php';
class h extends wg
{
@@ -11,13 +11,13 @@
namespace zin;
require_once 'h.class.php';
require_once 'item.class.php';
require_once 'wg.func.php';
require_once 'set.class.php';
require_once 'to.class.php';
require_once 'data.func.php';
require_once 'on.class.php';
require_once __DIR__ . DS . 'h.class.php';
require_once __DIR__ . DS . 'item.class.php';
require_once __DIR__ . DS . 'wg.func.php';
require_once __DIR__ . DS . 'set.class.php';
require_once __DIR__ . DS . 'to.class.php';
require_once __DIR__ . DS . 'data.func.php';
require_once __DIR__ . DS . 'on.class.php';
function h() {return call_user_func_array('\zin\h::create', func_get_args());}
@@ -11,8 +11,8 @@
namespace zin;
require_once 'wg.class.php';
require_once 'wg.func.php';
require_once __DIR__ . DS . 'wg.class.php';
require_once __DIR__ . DS . 'wg.func.php';
class item extends wg
{
@@ -11,7 +11,7 @@
namespace zin;
require_once 'wg.func.php';
require_once __DIR__ . DS . 'wg.func.php';
class on
{
@@ -11,7 +11,7 @@
namespace zin;
require_once 'wg.class.php';
require_once __DIR__ . DS . 'wg.class.php';
class portal extends wg
{
View File
@@ -11,7 +11,7 @@
namespace zin;
require_once 'zin.class.php';
require_once __DIR__ . DS . 'zin.class.php';
/**
* Render page content with a widget to HTML.
@@ -11,7 +11,7 @@
namespace zin;
require_once 'directive.class.php';
require_once __DIR__ . DS . 'directive.class.php';
class set
{
@@ -11,7 +11,7 @@
namespace zin;
require_once 'directive.class.php';
require_once __DIR__ . DS . 'directive.class.php';
class to
{
@@ -11,12 +11,12 @@
namespace zin;
require_once 'props.class.php';
require_once 'directive.class.php';
require_once 'zin.class.php';
require_once 'context.class.php';
require_once 'selector.func.php';
require_once 'dom.class.php';
require_once __DIR__ . DS . 'props.class.php';
require_once __DIR__ . DS . 'directive.class.php';
require_once __DIR__ . DS . 'zin.class.php';
require_once __DIR__ . DS . 'context.class.php';
require_once __DIR__ . DS . 'selector.func.php';
require_once __DIR__ . DS . 'dom.class.php';
class wg
{
@@ -11,10 +11,10 @@
namespace zin;
require_once dirname(__DIR__) . DS . 'utils' . DS . 'flat.func.php';
require_once 'props.class.php';
require_once 'directive.class.php';
require_once 'wg.class.php';
require_once 'context.func.php';
require_once __DIR__ . DS . 'props.class.php';
require_once __DIR__ . DS . 'directive.class.php';
require_once __DIR__ . DS . 'wg.class.php';
require_once __DIR__ . DS . 'context.func.php';
function set($name, $value = NULL)
{
+9
View File
@@ -843,6 +843,15 @@ function tabs()
return createWg('tabs', func_get_args());
}
/**
* tab pane widget.
* bool isActive?
*/
function tabPane()
{
return createWg('tabPane', func_get_args());
}
/**
* panel widget.
*
+2 -2
View File
@@ -11,7 +11,7 @@
namespace zin;
require_once 'config.php';
require_once __DIR__ . DS . 'config.php';
function setWgVer($ver, $names = NULL)
{
@@ -44,7 +44,7 @@ function createWg($name, $args)
$name = strtolower($name);
$wgVer = getWgVer($name);
include_once $app->getBasePath() . 'zin' . DS . 'wg' . DS . $name . DS . "v$wgVer.php";
include_once __DIR__ . DS . 'wg' . DS . $name . DS . "v$wgVer.php";
$wgName = "\\zin\\$name";
View File
@@ -11,7 +11,7 @@
namespace zin\utils;
require_once 'dataset.class.php';
require_once __DIR__ . DS . 'dataset.class.php';
/**
* Manage data for html element and widgets
View File
+1 -1
View File
@@ -11,7 +11,7 @@
namespace zin\utils;
require_once 'dataset.class.php';
require_once __DIR__ . DS . 'dataset.class.php';
/**
* Manage hx for html element and widgets
+1 -1
View File
@@ -11,7 +11,7 @@
namespace zin\utils;
require_once 'dataset.class.php';
require_once __DIR__ . DS . 'dataset.class.php';
/**
* Manage style for html element and widgets
View File
+75
View File
@@ -0,0 +1,75 @@
<?php
namespace zin;
require_once dirname(__DIR__) . DS . 'formgroup' . DS . 'v1.php';
require_once dirname(__DIR__) . DS . 'formrow' . DS . 'v1.php';
require_once dirname(__DIR__) . DS . 'formbase' . DS . 'v1.php';
/**
* 通用表单(form)部件类,支持 Ajax 提交
* The common form widget class
*/
class form extends formBase
{
protected static $defineProps = array
(
'items?: array',
'grid?: bool',
'labelWidth?: int'
);
protected static $defaultProps = array
(
'grid' => true,
'actionsClass' => 'form-group gap-4 no-label'
);
public function onBuildItem(item|array $item): wg
{
if(!($item instanceof item))
{
if($item instanceof wg) return $item;
$item = item(set($item));
}
if($this->prop('grid')) return new formRow(inherit($item));
return new formGroup(inherit($item));
}
protected function buildActions(): wg
{
$actions = parent::buildActions();
if($this->prop('grid') && !empty($actions)) $actions = div(setClass('form-row'), $actions);
return $actions;
}
protected function buildProps(): array
{
list($grid, $labelWidth) = $this->prop(array('grid', 'labelWidth'));
$props = parent::buildProps();
if($grid) $props[] = set::class('form-grid');
if(!empty($labelWidth)) $props[] = setCssVar('form-label-width', $labelWidth);
return $props;
}
protected function buildContent(): array
{
list($items, $grid) = $this->prop(['items', 'grid']);
$list = is_array($items) ? array_map(array($this, 'onBuildItem'), $items) : [];
$children = $this->children();
if(!empty($children)) $list = array_merge($list, $children);
if($grid)
{
foreach($list as $key => $item)
{
if($item instanceof formGroup) $list[$key] = new formRow($item);
}
}
return $list;
}
}
+91
View File
@@ -0,0 +1,91 @@
<?php
declare(strict_types=1);
/**
* The formBase widget class file of zin module of ZenTaoPMS.
*
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author sunhao<sunhao@easycorp.ltd>
* @package zin
* @link http://www.zentao.net
*/
namespace zin;
/**
* 基础表单(formBase)部件类,支持 Ajax 提交
* The formBase widget class
*/
class formBase extends wg
{
protected static $defineProps = array
(
'method?: string',
'url?: string',
'actions?: array',
'actionsClass?: string',
'target?: string',
'submitBtnText?: string',
'cancelBtnText?: string',
);
protected static $defaultProps = array
(
'method' => 'post',
'target' => 'ajax',
'actions' => ['submit', 'cancel'],
);
protected function buildActions(): wg
{
$actions = $this->prop('actions');
if(empty($actions)) return NULL;
global $lang;
foreach($actions as $key => $action)
{
if($action === 'submit') $actions[$key] = ['text' => $this->prop('submitBtnText') ?? $lang->save, 'btnType' => 'submit', 'type' => 'primary'];
elseif($action === 'cancel') $actions[$key] = ['text' => $this->prop('cancelBtnText') ?? $lang->goback, 'url' => html::getGobackLink()];
elseif(is_string($action)) $actions[$key] = ['text' => $action];
}
return toolbar
(
set::class('form-actions', $this->prop('actionsClass')),
set::items($actions)
);
}
protected function buildContent(): array|wg
{
return $this->children();
}
protected function buildProps(): array
{
return array();
}
protected function build(): wg
{
list($url, $target, $method, $id) = $this->prop(['url', 'target', 'method', 'id']);
$isAjax = $target === 'ajax';
if($isAjax)
{
$target = NULL;
if(empty($id)) $id = $this->gid;
}
if(empty($url)) $url = $_SERVER['REQUEST_URI'];
return h::form
(
set::class('form load-indicator', $isAjax ? 'form-ajax' : ''),
set(['id' => $id, 'action' => $url, 'target' => $target, 'method' => $method]),
set($this->getRestProps()),
$this->buildProps(),
$this->buildContent(),
$this->buildActions(),
$isAjax ? zui::ajaxForm(set::_to("#$id")) : NULL
);
}
}
View File
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace zin;
class tabPane extends wg
{
protected static $defineProps = array(
'isActive?:bool=false',
);
protected function build()
{
$isActive = $this->prop('isActive');
$className = $isActive ? 'tab-pane active' : 'tab-pane';
return div
(
set($this->props->skip(array_keys(static::getDefinedProps()))),
setClass($className),
$this->children()
);
}
}
+2
View File
@@ -0,0 +1,2 @@
.nav-tabs>.nav-item.active>a {color: var(--color-primary-500);}
.nav-tabs>.nav-item.active>a:after {border-bottom-color: var(--color-primary-500) !important; border-bottom-width: 2px;}

Some files were not shown because too many files have changed in this diff Show More