Tsugi

PageRepository
in package

Load and persist course wiki pages and page_history. Does not emit HTTP.

Table of Contents

Constants

HREF_PREFIX  : mixed = '/pages'
Stored URL prefix; must match Controllers\Pages::ROUTE.

Methods

canonicalizeHtml()  : string
Convert current-course URLs to $IMS-CC-FILEBASE$ before storing HTML.
cartridgeDocument()  : string
HTML document for Common Cartridge wiki_content. Canvas reads the page name from the <title> tag.
clearFront()  : mixed
clearMain()  : mixed
countForContext()  : mixed
delete()  : bool|null
expandHtml()  : string
Expand canonical FILEBASE URLs for the editor or browser.
generateLogicalKey()  : string
Generate a logical key from a title.
hrefForLogicalKey()  : string|null
Path form of a course page URL (/pages/{logical_key}).
importHtml()  : array{page_id: int, logical_key: string, title: string}
Insert a wiki/HTML page from a cartridge. Returns page_id and logical_key.
insert()  : bool
listForManage()  : array<int, array<string, mixed>>
listForPicker()  : array<int, array<string, mixed>>
listForView()  : array<int, array<string, mixed>>
listHistory()  : array<int, array<string, mixed>>
load()  : array<string, mixed>|false
loadByLogicalKey()  : array<string, mixed>|false
loadForHistory()  : array<string, mixed>|false
loadMain()  : array<string, mixed>|false
pageIdsWithHistory()  : array<int, int>
readExportPayload()  : array{title: string, logical_key: string, body: string, html: string}|null
Course page for Common Cartridge export, or null if it cannot be loaded.
renderEmbeddedMedia()  : string
Turn a semantic oEmbed tag into an iframe so a saved video plays on the page.
restoreHistory()  : string|null
Restore a history row. Returns an error message or null on success.
togglePublished()  : bool
uniqueLogicalKey()  : string
Unique logical_key for add/edit (suffix -1, -2, …).
update()  : bool
hostIs()  : bool
logicalKeyRow()  : array<string, mixed>|false
mediaIframe()  : string|null
oembedUrlAttribute()  : string|null
trimHistory()  : mixed
videoIframe()  : string

Constants

HREF_PREFIX

Stored URL prefix; must match Controllers\Pages::ROUTE.

public mixed HREF_PREFIX = '/pages'

Methods

canonicalizeHtml()

Convert current-course URLs to $IMS-CC-FILEBASE$ before storing HTML.

public static canonicalizeHtml(string $html, string $fileBaseUrl, array<string|int, string> $localPrefixes, int $context_id) : string
Parameters
$html : string
$fileBaseUrl : string
$localPrefixes : array<string|int, string>
$context_id : int
Return values
string

cartridgeDocument()

HTML document for Common Cartridge wiki_content. Canvas reads the page name from the <title> tag.

public static cartridgeDocument(mixed $title, mixed $body) : string
Parameters
$title : mixed
$body : mixed

HTML fragment or full document

Return values
string

clearFront()

public static clearFront(mixed $context_id) : mixed
Parameters
$context_id : mixed

clearMain()

public static clearMain(mixed $context_id) : mixed
Parameters
$context_id : mixed

countForContext()

public static countForContext(mixed $context_id) : mixed
Parameters
$context_id : mixed

delete()

public static delete(mixed $page_id, mixed $context_id) : bool|null
Parameters
$page_id : mixed
$context_id : mixed
Return values
bool|null —

true deleted, false error, null not found

expandHtml()

Expand canonical FILEBASE URLs for the editor or browser.

public static expandHtml(string $html, string $fileBaseUrl, array<string|int, string> $localPrefixes) : string
Parameters
$html : string
$fileBaseUrl : string
$localPrefixes : array<string|int, string>
Return values
string

generateLogicalKey()

Generate a logical key from a title.

public static generateLogicalKey(string $title) : string
Parameters
$title : string
Return values
string

hrefForLogicalKey()

Path form of a course page URL (/pages/{logical_key}).

public static hrefForLogicalKey(mixed $logical_key) : string|null
Parameters
$logical_key : mixed
Return values
string|null

importHtml()

Insert a wiki/HTML page from a cartridge. Returns page_id and logical_key.

public static importHtml(mixed $title, mixed $body, mixed $logical_key, mixed $context_id, mixed $user_id) : array{page_id: int, logical_key: string, title: string}
Parameters
$title : mixed
$body : mixed
$logical_key : mixed
$context_id : mixed
$user_id : mixed
Return values
array{page_id: int, logical_key: string, title: string}

insert()

public static insert(mixed $context_id, mixed $user_id, mixed $title, mixed $logical_key, mixed $body, mixed $published, mixed $is_main, mixed $is_front_page) : bool
Parameters
$context_id : mixed
$user_id : mixed
$title : mixed
$logical_key : mixed
$body : mixed
$published : mixed
$is_main : mixed
$is_front_page : mixed
Return values
bool

listForManage()

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

listForPicker()

public static listForPicker(int $context_id[, bool $published_only = false ]) : array<int, array<string, mixed>>
Parameters
$context_id : int
$published_only : bool = false
Return values
array<int, array<string, mixed>>

listForView()

public static listForView(int $context_id[, bool $published_only = false ]) : array<int, array<string, mixed>>
Parameters
$context_id : int
$published_only : bool = false
Return values
array<int, array<string, mixed>>

listHistory()

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

load()

public static load(int $page_id, int $context_id) : array<string, mixed>|false
Parameters
$page_id : int
$context_id : int
Return values
array<string, mixed>|false

loadByLogicalKey()

public static loadByLogicalKey(int $context_id, string $logical_key[, bool $published_only = false ]) : array<string, mixed>|false
Parameters
$context_id : int
$logical_key : string
$published_only : bool = false
Return values
array<string, mixed>|false

loadForHistory()

public static loadForHistory(int $page_id, int $context_id) : array<string, mixed>|false
Parameters
$page_id : int
$context_id : int
Return values
array<string, mixed>|false

loadMain()

public static loadMain(int $context_id[, bool $published_only = false ]) : array<string, mixed>|false
Parameters
$context_id : int
$published_only : bool = false
Return values
array<string, mixed>|false

pageIdsWithHistory()

public static pageIdsWithHistory(mixed $context_id) : array<int, int>
Parameters
$context_id : mixed
Return values
array<int, int>

readExportPayload()

Course page for Common Cartridge export, or null if it cannot be loaded.

public static readExportPayload(mixed $page_id, mixed $logical_key, int $context_id) : array{title: string, logical_key: string, body: string, html: string}|null
Parameters
$page_id : mixed
$logical_key : mixed
$context_id : int
Return values
array{title: string, logical_key: string, body: string, html: string}|null

renderEmbeddedMedia()

Turn a semantic oEmbed tag into an iframe so a saved video plays on the page.

public static renderEmbeddedMedia(string $html) : string

The editor stores , which a browser does not render.

Parameters
$html : string
Return values
string

restoreHistory()

Restore a history row. Returns an error message or null on success.

public static restoreHistory(int $page_id, int $history_id, int $context_id, string $fileBaseUrl, array<string|int, string> $localPrefixes) : string|null
Parameters
$page_id : int
$history_id : int
$context_id : int
$fileBaseUrl : string
$localPrefixes : array<string|int, string>
Return values
string|null

togglePublished()

public static togglePublished(mixed $page_id, mixed $context_id) : bool
Parameters
$page_id : mixed
$context_id : mixed
Return values
bool

uniqueLogicalKey()

Unique logical_key for add/edit (suffix -1, -2, …).

public static uniqueLogicalKey(int $context_id, string $logical_key[, int $exclude_page_id = 0 ]) : string
Parameters
$context_id : int
$logical_key : string
$exclude_page_id : int = 0
Return values
string

update()

public static update(mixed $page_id, mixed $context_id, mixed $title, mixed $logical_key, mixed $body, mixed $published, mixed $is_main, mixed $is_front_page) : bool
Parameters
$page_id : mixed
$context_id : mixed
$title : mixed
$logical_key : mixed
$body : mixed
$published : mixed
$is_main : mixed
$is_front_page : mixed
Return values
bool

hostIs()

private static hostIs(string $host, string $name) : bool
Parameters
$host : string
$name : string
Return values
bool

logicalKeyRow()

private static logicalKeyRow(mixed $context_id, mixed $logical_key[, mixed $exclude_page_id = 0 ]) : array<string, mixed>|false
Parameters
$context_id : mixed
$logical_key : mixed
$exclude_page_id : mixed = 0
Return values
array<string, mixed>|false

mediaIframe()

private static mediaIframe(string $url) : string|null
Parameters
$url : string
Return values
string|null

oembedUrlAttribute()

private static oembedUrlAttribute(string $attrs) : string|null
Parameters
$attrs : string
Return values
string|null

trimHistory()

private static trimHistory(mixed $page_id) : mixed
Parameters
$page_id : mixed

videoIframe()

private static videoIframe(string $src) : string
Parameters
$src : string
Return values
string

        
On this page

Search results