mirror of
https://github.com/itflow-org/itflow
synced 2026-11-26 22:37:29 +00:00
Show each starter content item as it will look under Pick which - a tag as its pill, a category as its chip, a product with its price and billing, with what each is for - and Preview the whole of a ticket, project, document, vendor or license template, canned response or product in a window, the words filled in as it is used marked; Maintenance > Starter Content gets Pick which too, its Add bringing only what is ticked and Will be added following the ticks, sharing admin/includes/starter_content_pick.php, admin/starter_content_preview.php and js/starter_content.js with Get started
This commit is contained in:
40
admin/starter_content_preview.php
Normal file
40
admin/starter_content_preview.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* A starter content item whole, for Preview under Pick which
|
||||
* (admin/includes/starter_content_pick.php) - ?pack=&item= (its
|
||||
* starterItemKey()), answered in JSON as its name and the preview's html.
|
||||
* Admins only, as the two pages that ask are.
|
||||
*/
|
||||
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/config.php';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/functions.php';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/check_login.php';
|
||||
enforceAdminPermission();
|
||||
|
||||
define('FROM_STARTER_CONTENT', true);
|
||||
require_once __DIR__ . '/post/starter_content_model.php';
|
||||
require_once __DIR__ . '/includes/starter_content_pick.php';
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Cache-Control: no-store');
|
||||
|
||||
$pack = (string) ($_GET['pack'] ?? '');
|
||||
$key = (string) ($_GET['item'] ?? '');
|
||||
$row = null;
|
||||
if (isset(starterContentPacks()[$pack]) && in_array($pack, starterPreviewPacks(), true)) {
|
||||
foreach (starterContentRows($pack) as $candidate) {
|
||||
if (starterItemKey($pack, $candidate) === $key) {
|
||||
$row = $candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$row) {
|
||||
http_response_code(404);
|
||||
echo json_encode(['error' => 'There is no such starter content.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['title' => starterItemName($pack, $row), 'pack' => starterContentPacks()[$pack]['label'], 'html' => starterItemPreview($pack, $row)]);
|
||||
Reference in New Issue
Block a user