Skip to content

Phase 14b-2: BasicTheme rewritten on iManager 2.0 stack#21

Merged
bigin merged 1 commit into
imanager-2.0from
phase-14b2-basictheme
May 3, 2026
Merged

Phase 14b-2: BasicTheme rewritten on iManager 2.0 stack#21
bigin merged 1 commit into
imanager-2.0from
phase-14b2-basictheme

Conversation

@bigin
Copy link
Copy Markdown
Owner

@bigin bigin commented May 3, 2026

The bundled basic theme now extends Frontend\Site and pulls every service from the container — no remaining call into the legacy imanager() function or editor/core/ classes survives the public render path. Pagination, theme cache, template fragments, navigation, archive, hero, contact and subscribe are all on 2.0 plumbing.

Key rewrites:

  • BasicTheme (lib/Basic.php) extends Frontend\Site and overrides init()+render(). Article list / archive use the typed PageRepository methods (findInTimeRange, findByParent, countByParent), pagination is built with iManager's Pagination value object + PaginationRenderer. Single-article rendering forces template blog-post via currentTemplate() instead of mutating the Page DTO. Contact + subscribe + loadToken endpoints preserved as a bridge with the new typed Request accessors and JSON responses; CSRF placeholders are empty until 14c-1 wires auth back.
  • BasicRouter (lib/BasicRouter.php) collapsed to a 22-line wrapper that dispatches actions and delegates routing to BasicTheme.
  • _ext.php sets up BasicTheme + checks the FilesystemCache for a SuperCache hit before invoking the router.
  • lib/subscriber/MailChimp.php: typed properties, removed dead Imanager\Util import, defensive defaults for missing config.

Frontend\Site additions for the theme surface:

  • Properties: input (Imanager\Http\Request), templateParser (TemplateRenderer), cache (FilesystemCache), msgs[]
  • currentTemplate() override hook for blog-style routing
  • getBasePath(), getPageUrl() (cycle-safe), addMsg()
  • init() empty hook for theme subclasses

Frontend\PageRepository additions:

  • findByParent(parent, orderBy, direction, activeOnly, offset, limit)
  • findInTimeRange(start, end, parent, orderBy, direction)
  • countByParent(parent, activeOnly)
  • levels(rootParent, maxDepth, activeOnly, excludeIds) with visited-set cycle detection (the migrated demo data has page id=8 pointing parent→8 to itself; would otherwise OOM the request)
  • descendants(parent) with the same cycle guard

Theme files & data:

  • resources/_tpls.php migrated from [[VAR]] to {{var}} so the iManager TemplateRenderer (Phase 11) resolves them; pagination fragments grouped under a pagination sub-array with the keys PaginationRenderer expects (wrapper/link/current/prev/...).
  • data/settings/basic-theme-config.php: dropped the static Scriptor::getConfig() / BasicTheme::VERSION references that don't autoload on the 2.0 stack — BasicTheme::init() merges the live values from $site->config.
  • template.php uses $site->currentTemplate() so the blog routing can override without mutating the Page DTO.
  • index.php delegates to the theme's _ext.php when present and bails out cleanly when _ext.php returns early on a SuperCache hit.

Manual smoke (PHP built-in server):
GET / 200, 7.3 KB
GET /scriptors-demo-page 200, 7.5 KB (home alt)
GET /articles/ 200, 7.1 KB (article list)
GET /articles/page2/ 200, 5.8 KB (paginated)
GET /articles/get-started-with-scriptor 200, 7.7 KB (single article)
GET /contact 200, 7.1 KB (form)
GET /this-does-not-exist 404

The bundled basic theme now extends Frontend\Site and pulls every
service from the container — no remaining call into the legacy
imanager() function or editor/core/ classes survives the public
render path. Pagination, theme cache, template fragments, navigation,
archive, hero, contact and subscribe are all on 2.0 plumbing.

Key rewrites:
  - BasicTheme (lib/Basic.php) extends Frontend\Site and overrides
    init()+render(). Article list / archive use the typed
    PageRepository methods (findInTimeRange, findByParent,
    countByParent), pagination is built with iManager's Pagination
    value object + PaginationRenderer. Single-article rendering
    forces template `blog-post` via currentTemplate() instead of
    mutating the Page DTO. Contact + subscribe + loadToken endpoints
    preserved as a bridge with the new typed Request accessors and
    JSON responses; CSRF placeholders are empty until 14c-1 wires
    auth back.
  - BasicRouter (lib/BasicRouter.php) collapsed to a 22-line wrapper
    that dispatches actions and delegates routing to BasicTheme.
  - _ext.php sets up BasicTheme + checks the FilesystemCache for a
    SuperCache hit before invoking the router.
  - lib/subscriber/MailChimp.php: typed properties, removed dead
    Imanager\Util import, defensive defaults for missing config.

Frontend\Site additions for the theme surface:
  - Properties: input (Imanager\Http\Request), templateParser
    (TemplateRenderer), cache (FilesystemCache), msgs[]
  - currentTemplate() override hook for blog-style routing
  - getBasePath(), getPageUrl() (cycle-safe), addMsg()
  - init() empty hook for theme subclasses

Frontend\PageRepository additions:
  - findByParent(parent, orderBy, direction, activeOnly, offset, limit)
  - findInTimeRange(start, end, parent, orderBy, direction)
  - countByParent(parent, activeOnly)
  - levels(rootParent, maxDepth, activeOnly, excludeIds) with
    visited-set cycle detection (the migrated demo data has page id=8
    pointing parent→8 to itself; would otherwise OOM the request)
  - descendants(parent) with the same cycle guard

Theme files & data:
  - resources/_tpls.php migrated from `[[VAR]]` to `{{var}}` so the
    iManager TemplateRenderer (Phase 11) resolves them; pagination
    fragments grouped under a `pagination` sub-array with the keys
    PaginationRenderer expects (wrapper/link/current/prev/...).
  - data/settings/basic-theme-config.php: dropped the static
    Scriptor::getConfig() / BasicTheme::VERSION references that
    don't autoload on the 2.0 stack — BasicTheme::init() merges the
    live values from $site->config.
  - template.php uses $site->currentTemplate() so the blog routing
    can override without mutating the Page DTO.
  - index.php delegates to the theme's _ext.php when present and
    bails out cleanly when _ext.php returns early on a SuperCache hit.

Manual smoke (PHP built-in server):
  GET /                                        200, 7.3 KB
  GET /scriptors-demo-page                     200, 7.5 KB (home alt)
  GET /articles/                               200, 7.1 KB (article list)
  GET /articles/page2/                         200, 5.8 KB (paginated)
  GET /articles/get-started-with-scriptor      200, 7.7 KB (single article)
  GET /contact                                 200, 7.1 KB (form)
  GET /this-does-not-exist                     404
@bigin bigin merged commit 9637388 into imanager-2.0 May 3, 2026
@bigin bigin deleted the phase-14b2-basictheme branch May 15, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant