定制 micschk/silverstripe-cmstweaks 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

micschk/silverstripe-cmstweaks

Composer 安装命令:

composer require micschk/silverstripe-cmstweaks

包简介

Various admin tweaks & enhancements

关键字:

README 文档

README

This module serves as a portable set of small Silverstripe functionality & styling tweaks by Restruct.

Currently it has been partially updated to SS4+, most stuff is deactivated & will be reactivated when needed in projects.

Functionality:

  • ImagePlaceholder functionality (SVG)
  • Contact & social media fields in SiteConfig (optional/configurable)
  • Raw html head/body tag fields in SiteConfig (optional/configurable)
  • Browser-chrome colorpicker field in SiteConfig (optional/configurable)
  • Provides a global $themeDirResourceURL ($ThemeDir replacement, eg: {$themeDirResourceURL('my-theme')}/videos/vid-{$RandomNumber}.mp4)
  • SSViewer_ExtraIterators (eg "col-2-of-4"): GroupSize, PosInGroup, FirstOfGroup, LastOfGroup, FirstLastOfGroup, GroupOfGroups
  • CacheHelpers::cached_http_request(), cached_json_request() & cached_jsonLD_request()
  • GeneralHelpers::safelyGetProperty() & download_and_save_asset()
  • Various stuff added to Page by PageHelpersExtension
  • ScheduledMethodCall class to call any method on a schedule using QueuedJobs module (if installed)
  • FormFieldBootstrapExtension to simply add .form-control class to formfields (optional)
  • FormFieldTweaksExtension to add classes & attributes to form holders only (combine with ->setFieldHolderTemplate('FormFieldTweaks_holder'))
  • EnforceCMSPermission trait to have DataObjects require CMS access credentials for CRUD actions
  • GridFieldConfigs::editable_orderable()
  • SelectiveLumberjack class (fixes Lumberjack to NOT filter listview and also take hide_from_cms_tree (core functionality) into account)
  • Sets Session.cookie_secure true
  • Makes UserDefinedForm NOT save to server by default (GDPR)
  • Sets slightly higher image quality values & activates WEBP format (if webmen/silverstripe-webp-images is installed)
  • Activates MimeUploadValidator (if silverstripe/mimevalidator is installed)
  • Sets default ("cacheblock") cache to 24 hours & creates a "appcache" of 1 hour
  • Has some email config helpers (see "Email config" below)
  • Sets some image manipulation fallbacks in case methods are missing (legacy, focuspoint, cropper)
  • Sets a slightly more secure password policy
  • Activates googlesitemaps (if module installed)
  • Registers FeaturedImage & CurrentYear shortcodes (if shortcode module is installed)
  • Adds stylish pageicons for common pagetypes (font awesome icons)
  • (Bigfork:) Hides pagetypes that cannot be created & admin sections that clients rarely use
  • Hides CampaignAdmin & ReportAdmin in nav (rarely used by clients)
  • Groups RedirectedURLAdmin, ArchiveAdmin, QueuedJobsAdmin, SubsiteAdmin and SiteConfig nav-buttons under "Advanced" dropdown (if symbiote/silverstripe-grouped-cms-menu is installed)
  • Various Block (Elemental) tweaks (+ block icon/thumbnail preview route at admin/blocktypeicons)
  • Fix to make empty/unchecked checkboxes in editablegridfields submit data (eg unset)
  • Workaround checkboxes being unset by $form->loadData() when they dont have a 1:1 fieldname/relation on object (set attribute data-setactivecheckboxvalues to force a value onto checkboxsetfields)
  • DBDatetime::LegacyFormat() adds back Silverstripe 3/PHP datetime formatting support (SS4 switched to CLDR)
  • ...

Untested / dropped-in functionality

Stuff quickly copied into this module for portability but may need some tweaking/generalization before being actually usable:

  • IpAddressField formfield with IP validation (may currently be only usable in front-end, not sure)
  • DBNullableInt & MySQLSchemaManagerNullable
  • ...

Notes:

  • Legacy .margin-left & .small formfield styling -> (v4) just $field->removeExtraClass('stacked')->setRows(15)

SiteConfig ... config

Set wether to 'decorate' siteconfig or not:

# NOTE: this extension adds various extra fields & functionality to siteadmin, activate on a per-project basis
SilverStripe\SiteConfig\SiteConfig:
  extensions:
    - Restruct\Silverstripe\AdminTweaks\Extensions\SiteConfigExtension
  # move 'access' fields to main tab & remove 'access' tab
  rearrange_access_fields: false # (default true)
  enable_browser_color_theme_field: false # (default true)
  enable_subnav_activation_field: false # (default true)
  enable_contact_social_media_fields: false # (default true)
  # use in templates: {$SiteConfig.ExtraHTML_HeadStart.RAW} to include extra html
  enable_raw_head_body_fields: false # (default true)
  # deactivate container classes (or set array to override)
  theme_container_classes: false # default bootstrap container classes

Image placeholder

Include SVG directly in template:

<% include ImagePlaceholder W=180, H=50, Label='logo', AddClass='rounded' %>

Include SVG directly:

$ImagePlaceholder(180, 50, 'logo', '', 'rounded')

Include SVG as img src (base64 data-uri):

<img class="rounded" src="$ImagePlaceholder(180, 50, 'logo', true)" alt="logo" width="180" height="50">

Email config

Define email config in .env (environment) to have it auto-applied:

# EMAIL.yml
APP_SYSTEM_EMAIL_SENDER="" # eg System X/Y
APP_SYSTEM_EMAIL_ADDRESS="" # eg noreply@host.tld

# SMTP mailserver, NOTE: SwiftMail 'ssl' => SMTP over SSL/TLS / 'tls' => STARTTLS
# LIVE/Default: Mailgun servers (listen on ports 25, 465 (SSL/TLS), 587 (STARTTLS), and 2525)
APP_SMTP_HOST=""
APP_SMTP_PORT=""
APP_SMTP_ENCRYPTION=""
APP_SMTP_USERNAME=""
APP_SMTP_PASSWORD=""

# Send error logs via email
APP_LOG_MAIL_RECIPIENT=""
APP_LOG_MAIL_SUBJECT=""
APP_LOG_MAIL_SENDER=""
APP_LOG_MAIL_LEVEL=""

Show Block design/thumbnails instead of icons in admin UI (Elemental)

  1. copy & adapt below section to specific project code css to show designed block previews instead of icons
  2. set private static $icon to 'block-design block-section {block-name-offset}'
  3. add stacked blocks img to app/client (.block-name-offset sets offset if multiple stacked in one image)
i.block-section, button.block-section:before {
  background-image: url(~app/client/imgs/block-group-designs_stacked.png);
  background-position: 0 0;
}
i.block-section, button.block-section {
  &.block-name-offset {&, &:before {
    background-position: 0 -128px;
  }}
  &.block-othername-offset {&, &:before {
    background-position: 0 -28px;
  }}
}

## TODO/REACTIVEATE/UPDATE for SS4:

- JS: Add optional loading feedback overlay to buttons
- JS: Inline gridfieldeditablecolumns datepicker fixes
- JS: Advanced search toggle for modeladmins
- Check & improve

micschk/silverstripe-cmstweaks 适用场景与选型建议

micschk/silverstripe-cmstweaks 是一款 基于 SCSS 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 04 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「silverstripe」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 micschk/silverstripe-cmstweaks 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 micschk/silverstripe-cmstweaks 我们能提供哪些服务?
定制开发 / 二次开发

基于 micschk/silverstripe-cmstweaks 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 3
  • Forks: 2
  • 开发语言: SCSS

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-07