\DynamicTemplate
Synopsis
class DynamicTemplate
extends Folder
{
- // members
- public static array $db = ;
- public static string $singular_name = "Dynamic Template";
- public static string $plural_name = "Dynamic Templates";
- public static string $dynamic_template_folder = "dynamic-templates/";
- // methods
- public static void set_dynamic_template_folder()
- public static void get_dynamic_template_folder()
- public static void get_dynamic_template_folder_object()
- public static void import_file()
- public static void extract_bundle()
- public static DynamicTemplate extract_file()
- public void validate()
- public void getManifest()
- public void flushManifest()
- public void sanitise()
- public void generateManifest()
- public void getFilesInDirByExt()
- public void loadManifestFile()
- public void appliesTo()
- public void getCMSFields()
- public void requireDefaultRecords()
- protected void getUploadField()
- public void addNewFile()
- protected void getUniqueName()
- public static void get_extension()
- protected void getSubdirByExtension()
- public void addUploadToFolder()
- public void addFileToManifest()
- protected static void template_exists()
- public static void create_empty_template()
- public void onBeforeWrite()
- public int constructChildInFolder()
- public void exportAs()
Hierarchy
Extends
- Folder
Tasks
Line | Task |
---|---|
63 | refactor with respect to extract_bundle |
Members
public
- $db
-
$dynamic_template_folder
This determines the base of where dynamic templates are for the site. - $plural_name
- $singular_name
Methods
protected
- getSubdirByExtension() — Given a file extension, return the subdirectory where files of that type are stored in the template. Throws an exception on unsupported file types. If $editable is true, then only .ss, .css and .js are considered supported.
- getUniqueName() — Determine a unique name for $filename within $directory. We add number suffixes to the filename (excluding extension) until we find a name that doesn't exist.
- getUploadField() — Return a field that can be used to upload a file.
- template_exists() — Determine if a template of this name already exists.
public
- addFileToManifest() — Given a file, add it to the manifest, and write a new manifest file out.
- addNewFile() — Create a new file in the template called $filename. A new empty file is added to the file system, empty, and a File record created. The file is also added to the manifest if it's a type where that's required.
- addUploadToFolder() — Take a file uploaded via a POST form, and save it inside this folder.
- appliesTo() — Determine if this template applies to an item. If the dynamic template has any class constraints, then this will return true if the class matches the constraints and returns false if it doesn't. If the template has no constraints, it always returns true.
- constructChildInFolder() — Construct a child, as Folder does, except that the child is not directly owned by the dynamic template, but the folder object $subFolder under it.
- create_empty_template()
- exportAs() — Generate the file contents for an export of this template, using the specified type. This generates a string of binary data, which can be sent in an HTTP file response. The controller that exposes the download does that, and sets file name and mine type etc. This just generates the data.
- extract_bundle()
- extract_file() — Helper to extract compressed file appropriately. If its a tarball, it uses Archive class. If it's a zip file, it uses Zip library, although this isn't always available.
- flushManifest() — Given a manifest object, flush the dynamic template with this manifest. This only has effect if the manifest has been modified.
- generateManifest() — Generate the normalised manifest array for this template. If there is a file within this folder called MANIFEST, then use that. Otherwise generate a default manifest based on what is present in this folder.
- getCMSFields() — Return the FieldSet used to edit a dynamic template in the CMS.
- getFilesInDirByExt() — Look for a subfolder called $subdir, and for every file in the folder with an extension of $ext, add it's full path to the array that is returned.
- getManifest() — Return the normalised manifest array for this template. We get it from the cache if its set, otherwise, calculate it and store it in the cache.
- get_dynamic_template_folder()
- get_dynamic_template_folder_object()
- get_extension()
- import_file() — Given a physical file (uploaded temp file typically, not in assets), treat it as a compressed template folder and extract it in place.
- loadManifestFile() — Given a file object, load and parse its contents as a manifest file.
- onBeforeWrite()
- requireDefaultRecords() — Creates the target folder
- sanitise() — Sanitise the manifest. This is called immediately prior to writing, and can check and fix certain things before write-back. One issue that is fixed is the removal of non-link file references in manifest where the physical file doesn't exist.
- set_dynamic_template_folder()
- validate()