Tsugi

CatalogRepository
in package

Site-wide course_catalog rows. List queries never SELECT hero BLOBs.

Table of Contents

Constants

SHORT_MAX  : mixed = 512
TITLE_MAX  : mixed = 512

Properties

$purifier  : HTMLPurifier|null

Methods

clearHero()  : string|null
contextChoices()  : array<int, array{context_id: int, title: string}>
Courses an admin can attach, excluding courses already listed (except $keepCatalogId's current context).
delete()  : mixed
enrollLearner()  : mixed
Insert learner membership when missing. True when the user is a member.
hasRichDescription()  : mixed
True when the catalog long body has real content (not CKEditor blank).
heroBlob()  : array{bytes: string, mime: string, updated_at: ?string}|null
Catalog hero, or the linked course hero. Never both in one SELECT.
heroUrl()  : mixed
homeContextId()  : mixed
Google home context id for catalog rules (0 if none).
iconBlob()  : array{bytes: string, mime: string, updated_at: ?string}|null
Square icon from the linked course, if any.
iconUrl()  : mixed
isMember()  : mixed
listAdmin()  : array<int, array<string, mixed>>
listPublished()  : array<int, array<string, mixed>>
Published listings for the public catalog. No BLOBs. Description is used only to set has_detail, then dropped.
load()  : array<string, mixed>|null
One row without the hero BLOB. $publishedOnly skips unpublished.
normalizeInput()  : array{ok: true, data: array}|array{ok: false, error: string}
plainText()  : mixed
previewUrl()  : string
Lessons URL when this catalog row's course allows anonymous preview.
publishedIdForContext()  : int
Published catalog id for a course, or 0 when it is not listed.
purify()  : mixed
save()  : array{ok: true, catalog_id: int}|array{ok: false, error: string}
saveHero()  : string|null
validHttpUrl()  : mixed
withDisplayUrls()  : array<int, array<string, mixed>>
catalogOrderSql()  : mixed
Numbered rows first. 0 means unset and sorts after every other order.
purifier()  : mixed
saveError()  : array{ok: false, error: string}

Constants

Properties

Methods

clearHero()

public static clearHero(mixed $catalog_id) : string|null
Parameters
$catalog_id : mixed
Return values
string|null —

Error

contextChoices()

Courses an admin can attach, excluding courses already listed (except $keepCatalogId's current context).

public static contextChoices([mixed $keepCatalogId = 0 ]) : array<int, array{context_id: int, title: string}>

The Google site-login course is included. The public catalog sends that course to the app home instead of /courses/{id}.

Parameters
$keepCatalogId : mixed = 0
Return values
array<int, array{context_id: int, title: string}>

delete()

public static delete(mixed $catalog_id) : mixed
Parameters
$catalog_id : mixed

enrollLearner()

Insert learner membership when missing. True when the user is a member.

public static enrollLearner(mixed $context_id, mixed $user_id) : mixed
Parameters
$context_id : mixed
$user_id : mixed

hasRichDescription()

True when the catalog long body has real content (not CKEditor blank).

public static hasRichDescription(mixed $html) : mixed
Parameters
$html : mixed

heroBlob()

Catalog hero, or the linked course hero. Never both in one SELECT.

public static heroBlob(mixed $catalog_id) : array{bytes: string, mime: string, updated_at: ?string}|null
Parameters
$catalog_id : mixed
Return values
array{bytes: string, mime: string, updated_at: ?string}|null

heroUrl()

public static heroUrl(mixed $catalog_id[, mixed $updated_at = null ]) : mixed
Parameters
$catalog_id : mixed
$updated_at : mixed = null

homeContextId()

Google home context id for catalog rules (0 if none).

public static homeContextId() : mixed

iconBlob()

Square icon from the linked course, if any.

public static iconBlob(mixed $catalog_id) : array{bytes: string, mime: string, updated_at: ?string}|null
Parameters
$catalog_id : mixed
Return values
array{bytes: string, mime: string, updated_at: ?string}|null

iconUrl()

public static iconUrl(mixed $catalog_id[, mixed $updated_at = null ]) : mixed
Parameters
$catalog_id : mixed
$updated_at : mixed = null

isMember()

public static isMember(mixed $context_id, mixed $user_id) : mixed
Parameters
$context_id : mixed
$user_id : mixed

listAdmin()

public static listAdmin() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>

listPublished()

Published listings for the public catalog. No BLOBs. Description is used only to set has_detail, then dropped.

public static listPublished([mixed $user_id = 0 ]) : array<int, array<string, mixed>>
Parameters
$user_id : mixed = 0
Return values
array<int, array<string, mixed>>

load()

One row without the hero BLOB. $publishedOnly skips unpublished.

public static load(mixed $catalog_id[, mixed $publishedOnly = false ][, mixed $user_id = 0 ]) : array<string, mixed>|null
Parameters
$catalog_id : mixed
$publishedOnly : mixed = false
$user_id : mixed = 0
Return values
array<string, mixed>|null

normalizeInput()

public static normalizeInput(array<string, mixed> $post) : array{ok: true, data: array}|array{ok: false, error: string}
Parameters
$post : array<string, mixed>
Return values
array{ok: true, data: array}|array{ok: false, error: string}

plainText()

public static plainText(mixed $text, mixed $max) : mixed
Parameters
$text : mixed
$max : mixed

previewUrl()

Lessons URL when this catalog row's course allows anonymous preview.

public static previewUrl(array<string, mixed> $row) : string
Parameters
$row : array<string, mixed>
Return values
string

publishedIdForContext()

Published catalog id for a course, or 0 when it is not listed.

public static publishedIdForContext(mixed $context_id) : int
Parameters
$context_id : mixed
Return values
int

purify()

public static purify(mixed $html) : mixed
Parameters
$html : mixed

save()

public static save(mixed $catalog_id, array<string, mixed> $data[, mixed $user_id = 0 ]) : array{ok: true, catalog_id: int}|array{ok: false, error: string}
Parameters
$catalog_id : mixed
$data : array<string, mixed>

From normalizeInput()

$user_id : mixed = 0
Return values
array{ok: true, catalog_id: int}|array{ok: false, error: string}

saveHero()

public static saveHero(mixed $catalog_id, mixed $bytes) : string|null
Parameters
$catalog_id : mixed
$bytes : mixed
Return values
string|null —

Error

validHttpUrl()

public static validHttpUrl(mixed $url) : mixed
Parameters
$url : mixed

withDisplayUrls()

public static withDisplayUrls(array<int, mixed> $rows) : array<int, array<string, mixed>>
Parameters
$rows : array<int, mixed>
Return values
array<int, array<string, mixed>>

catalogOrderSql()

Numbered rows first. 0 means unset and sorts after every other order.

private static catalogOrderSql() : mixed

saveError()

private static saveError(mixed $stmt) : array{ok: false, error: string}
Parameters
$stmt : mixed
Return values
array{ok: false, error: string}

        
On this page

Search results