Skip to content

Commit

Permalink
feat: ProviderTrait listAllEnabled added
Browse files Browse the repository at this point in the history
  • Loading branch information
modstart committed Jul 1, 2024
1 parent b435653 commit c36a57c
Show file tree
Hide file tree
Showing 87 changed files with 664 additions and 232 deletions.
2 changes: 1 addition & 1 deletion app/Constant/AppConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ class AppConstant
{
const APP = 'cms';
const APP_NAME = 'ModStartCMS';
const VERSION = '8.5.0';
const VERSION = '8.6.0';
}
2 changes: 1 addition & 1 deletion module/AdminManager/View/widget/serverInfo.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="col-lg-4 col-md-6">
<div class="tw-flex ub-border-bottom tw-p-2">
<div class="tw-w-24 tw-flex-shrink-0 tw-font-bold">MSCore</div>
<div class="tw-flex-grow">V{{\ModStart\ModStart::$version}} ( With <b>{{strtoupper(\ModStart\Module\ModuleManager::getEnv())}}</b> )</div>
<div class="tw-flex-grow">V{{\ModStart\ModStart::$version}} ( With <b>{{strtoupper(ModStart\ModStart::env())}}</b> )</div>
</div>
</div>
<div class="col-lg-4 col-md-6">
Expand Down
14 changes: 9 additions & 5 deletions module/Article/Admin/Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use ModStart\Admin\Concern\HasAdminQuickCRUD;
use ModStart\Admin\Layout\AdminCRUDBuilder;
use ModStart\Field\AbstractField;
use ModStart\Field\AutoRenderedFieldValue;
use ModStart\Field\Type\FieldRenderMode;
use ModStart\Form\Form;
use ModStart\Grid\GridFilter;
Expand All @@ -33,15 +34,18 @@ protected function crud(AdminCRUDBuilder $builder)
switch ($field->renderMode()) {
case FieldRenderMode::GRID:
case FieldRenderMode::DETAIL:
return TextLink::primary(
htmlspecialchars($item->title),
ArticleUtil::url($item->toArray()),
'target="_blank"'
return AutoRenderedFieldValue::make(
TextLink::primary(
htmlspecialchars($item->title),
ArticleUtil::url($item->toArray()),
'target="_blank"'
)
);
}
});
$url = modstart_web_url('article/别名');
$builder->text('alias', '别名')
->help('默认留空,可通过链接 /article/别名 访问,不能为纯数字');
->help("默认留空,可通过链接 <code>$url</code> 访问,不能为纯数字");
$builder->richHtml('content', '内容')->listable(false);
$builder->display('created_at', L('Created At'))->listable(false);
$builder->display('updated_at', L('Updated At'))->listable(false);
Expand Down
2 changes: 1 addition & 1 deletion module/Article/Docs/release.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.5.0
## 1.5.0 链接别名不能为纯数字文案提示

- 优化:链接别名不能为纯数字文案提示

Expand Down
4 changes: 2 additions & 2 deletions module/Article/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"title": "通用文章",
"version": "1.5.0",
"author": "官方",
"modstartVersion": ">=2.6.0",
"modstartVersion": ">=3.9.0",
"description": "提供多位置、单页文章基础管理功能",
"config": {
"position": [
Expand All @@ -24,4 +24,4 @@
]
]
}
}
}
1 change: 1 addition & 0 deletions module/Member/Docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- 优化:手机快速注册登录密码设置控件不是password修复
- 优化:VIP设置赠送积分但积分设置为0时异常问题
- 修复:已登录绑定授权信息,开启自动绑定账户时,绑定账户异常问题
- 修复:用户注册弹窗异常验证码发送异常问题

---

Expand Down
13 changes: 8 additions & 5 deletions module/Member/Util/MemberUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Module\Member\Events\MemberUserDeletedEvent;
use Module\Member\Events\MemberUserLoginAttemptEvent;
use Module\Member\Events\MemberUserLoginFailedEvent;
use Module\Member\Model\MemberUser;
use Module\Member\Type\MemberMessageStatus;
use Module\Member\Type\MemberPasswordStrength;
use Module\Member\Type\MemberStatus;
Expand Down Expand Up @@ -710,11 +711,12 @@ public static function mergeMemberUserBasics(&$records, $memberUserIdKey = 'memb
{
$keepFields = self::processBasicFields($keepFields);
if (is_array($records)) {
ModelUtil::join($records, $memberUserIdKey, $memberUserMergeKey, 'member_user', 'id');
ModelUtil::join($records, $memberUserIdKey, $memberUserMergeKey, MemberUser::class, 'id');
foreach ($records as $k => $v) {
if (empty($v[$memberUserMergeKey])) {
continue;
}
$viewName = self::viewName($v[$memberUserMergeKey]);
$memberUser = ArrayUtil::keepKeys($v[$memberUserMergeKey], $keepFields);
if (empty($memberUser['nickname'])) {
$memberUser['nickname'] = $memberUser['username'];
Expand All @@ -724,23 +726,24 @@ public static function mergeMemberUserBasics(&$records, $memberUserIdKey = 'memb
} else {
$memberUser['avatar'] = AssetsUtil::fixFull($memberUser['avatar']);
}
$memberUser['viewName'] = $viewName;
$records[$k][$memberUserMergeKey] = $memberUser;
}
} else {
ModelUtil::joinItems($records, $memberUserIdKey, $memberUserMergeKey, 'member_user', 'id');
ModelUtil::joinItems($records, $memberUserIdKey, $memberUserMergeKey, MemberUser::class, 'id');
foreach ($records as $item) {
if (empty($item->{$memberUserMergeKey})) {
continue;
}
$viewName = self::viewName($item->{$memberUserMergeKey});
$memberUser = ArrayUtil::keepKeys($item->{$memberUserMergeKey}, $keepFields);
if (empty($memberUser['nickname'])) {
$memberUser['nickname'] = $memberUser['username'];
}
$memberUser['nickname'] = $memberUser['username'];
if (empty($memberUser['avatar'])) {
$memberUser['avatar'] = AssetsUtil::fixFull('asset/image/avatar.svg');
} else {
$memberUser['avatar'] = AssetsUtil::fixFull($memberUser['avatar']);
}
$memberUser['viewName'] = $viewName;
$item->{$memberUserMergeKey} = $memberUser;
}
}
Expand Down
6 changes: 5 additions & 1 deletion module/Member/View/field/adminUserSelector.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<div class="line">
<div class="line" data-field="{{$name}}">
<div class="label">
{!! in_array('required',$rules)?'<span class="ub-text-danger ub-text-bold">*</span>':'' !!}
@if($tip)
<a class="ub-text-muted" href="javascript:;" data-tip-popover="{{$tip}}"><i class="iconfont icon-warning"></i></a>
@endif
{{$label}}
</div>
<div class="field">
Expand Down
6 changes: 1 addition & 5 deletions module/Member/View/pc/register.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
{!! \ModStart\Core\Hook\ModStartHook::fireInView('MemberRegisterPageHeadAppend'); !!}
@endsection

@section('bodyAppend')
@parent
{!! \ModStart\Core\Hook\ModStartHook::fireInView('MemberRegisterPageBodyAppend'); !!}
@endsection

@section('bodyAppend')
@parent
{{\ModStart\ModStart::js('asset/common/commonVerify.js')}}
Expand Down Expand Up @@ -47,6 +42,7 @@
},window.api.dialog);
});
</script>
{!! \ModStart\Core\Hook\ModStartHook::fireInView('MemberRegisterPageBodyAppend'); !!}
@endsection

@section('bodyContent')
Expand Down
5 changes: 1 addition & 4 deletions module/Member/View/pc/registerDialog.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
{!! \ModStart\Core\Hook\ModStartHook::fireInView('MemberRegisterPageHeadAppend'); !!}
@endsection

@section('bodyAppend')
{!! \ModStart\Core\Hook\ModStartHook::fireInView('MemberRegisterPageBodyAppend'); !!}
@endsection

@section('bodyAppend')
@parent
{{\ModStart\ModStart::js('asset/common/commonVerify.js')}}
Expand Down Expand Up @@ -45,6 +41,7 @@
},window.api.dialog);
});
</script>
{!! \ModStart\Core\Hook\ModStartHook::fireInView('MemberRegisterPageBodyAppend'); !!}
@endsection

{!! \ModStart\ModStart::style('html,body{background:var(--color-content-bg);}') !!}
Expand Down
12 changes: 5 additions & 7 deletions module/ModuleStore/Util/ModuleStoreUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,11 @@ public static function checkPackage($token, $module, $version)
if (empty($config['env'])) {
$config['env'] = ['laravel5'];
}
if (method_exists(ModuleManager::class, 'getEnv')) {
$env = ModuleManager::getEnv();
BizException::throwsIf(
L('Module %s:%s compatible with env %s, current is %s', $module, $config['version'], join(',', $config['env']), $env),
!in_array($env, $config['env'])
);
}
$env = ModStart::env();
BizException::throwsIf(
L('Module %s:%s compatible with env %s, current is %s', $module, $config['version'], join(',', $config['env']), $env),
!in_array($env, $config['env'])
);

return Response::generateSuccessData([
'requires' => $requires,
Expand Down
49 changes: 26 additions & 23 deletions module/Vendor/Docs/module/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,37 @@

「ModStart基础包」提供公共的基础服务,几乎所有的模块都需要依赖该模块的方法和类。

## 提供者和使用者 Provider 和 Biz
## 提供者 Provider

提供者(Provider)提供了抽象的服务,可以在模块中实现具体的业务支持。一个简单的例子,系统提供一周抽象的人机验证方式,如果你提供了一个具体的人机验证方式,那么你就可以实现一个人机验证提供者。

使用者(Biz)提供了具体的应用服务,不同的使用者可以注册完成应用服务的使用。 一个简单的例子,系统提供了一个评论使用者,如果你需要评论功能,那么你就可以使用评论使用者。
- `CaptchaProvider` 人机验证
- `CensorImageProvider` 图片智能审核
- `CensorTextProvider` 文字智能审核
- `ContentVerifyProvider` 内容审核
- `DataRefProvider` 上传文件引用引用
- `HomePageProvider` 首页
- `IDManagerProvider` ID管理
- `LBSProvider` 地理位置服务
- `LiveStreamProvider` 直播流
- `MailSenderProvider` 邮件发送
- `NotifierProvider` 通知
- `RandomImageProvider` 随机图片
- `RichContentProvider` 富文本内容
- `SearchBoxProvider` 多搜
- `SiteTemplateProvider` 网站模板
- `SiteUrlProvider` 网站链接
- `SmsSenderProvider` 短信发送
- `SmsTemplateProvider` 短信模板
- `SuperSearchProvider` 超级搜索
- `VideoStreamProvider` 视频点播
- `OcrProvider` 图片文字识别

## 使用者 Biz

- Captcha 人机验证提供者
- CensorImage 图片智能审核提供者
- CensorText 文字智能审核提供者
- ContentVerify 内容审核提供者
- DataRef 上传文件引用引用提供者
- HomePage 首页提供者
- IDManager ID管理提供者
- LBS 地理位置服务提供者
- LiveStream 直播流提供者
- MailSender 邮件发送提供者
- Notifier 通知提供者
- RandomImage 随机图片提供者
- RichContent 富文本内容提供者
- SearchBox 多搜提供者
- SiteTemplate 网站模板提供者
- SiteUrl 网站链接提供者
- SmsSender 短信发送提供者
- SmsTemplate 短信模板提供者
- SuperSearch 超级搜索
- VideoStream 视频点播提供者
- OCR 图片文字识别
使用者(Biz)提供了具体的应用服务,不同的使用者可以注册完成应用服务的使用。 一个简单的例子,系统提供了一个评论使用者,如果你需要评论功能,那么你就可以使用评论使用者。

- `ScheduleBiz` 计划任务

{ADMIN_MENUS}

2 changes: 1 addition & 1 deletion module/Vendor/Docs/release.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 4.4.0
## 4.4.0 优化后台操作工具类,新增分类操作工具类

- 新增:订单快捷操作工具类 OrderUtil
- 新增:分类快捷操作工具类 CategoryUtil
Expand Down
12 changes: 12 additions & 0 deletions module/Vendor/Provider/BizTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ public static function listAll()
return self::$list;
}

public static function listAllEnabled()
{
$records = [];
foreach (static::listAll() as $bizer) {
if (!$bizer->enable()) {
continue;
}
$records[] = $bizer;
}
return $records;
}

public static function getByName($name)
{
foreach (self::listAll() as $item) {
Expand Down
24 changes: 24 additions & 0 deletions module/Vendor/Provider/ProviderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ public static function listAll()
return self::$list;
}

public static function listAllEnabled()
{
$records = [];
foreach (static::listAll() as $provider) {
if (!$provider->enable()) {
continue;
}
$records[] = $provider;
}
return $records;
}

/**
* 列出全部Map name->title
* @return array
Expand Down Expand Up @@ -102,11 +114,23 @@ public static function getByName($name)
return null;
}

public static function getEnabledByName($name)
{
$item = self::getByName($name);
return $item && $item->enable() ? $item : null;
}

public static function first()
{
foreach (self::listAll() as $item) {
return $item;
}
return null;
}

public static function titleByName($name)
{
$item = self::getByName($name);
return $item ? $item->title() : $name;
}
}
Loading

0 comments on commit c36a57c

Please sign in to comment.