1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
<?php
/**
* TfCollection class file.
*
* @copyright Simon Wilkinson 2013+ (https://tuskfish.biz)
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html GNU General Public License (GPL) V2
* @author Simon Wilkinson <[email protected]>
* @version Release: 1.0
* @since 1.0
* @package content
*/
// Enable strict type declaration.
declare(strict_types=1);
if (!defined("TFISH_ROOT_PATH")) die("TFISH_ERROR_ROOT_PATH_NOT_DEFINED");
/**
* Represents a collection of content objects (analogous to a category). Hierarchical.
*
* For example, issues of a magazine produced at regular intervals (download content objects) can
* be bound to a collection object via the 'parent' property. Collections can contain mixed sets of
* content, for example images, videos, audio files etc.
*
* Collections can be nested by assigning another collection as a parent object. In this way,
* collections can effectively serve as categories and you can construct independent category trees.
* For example, if you wanted to create a "publications" category or section of your website you
* would just create a collection object called "Publications" and assign it as the parent of your
* publications content. Collections are also content objects in their own right, so provide them
* with a nice description and image/screenshot!
*
* @copyright Simon Wilkinson 2013+ (https://tuskfish.biz)
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html GNU General Public License (GPL) V2
* @author Simon Wilkinson <[email protected]>
* @version Release: 1.0
* @since 1.0
* @package content
* @uses trait TfLanguage to obtain a list of available translations.
* @uses trait TfMagicMethods Prevents direct setting of properties / unlisted properties.
* @uses trait TfMimetypes Access a list of known / acceptable file mimetypes.
* @properties TfValidator $validator Instance of the Tuskfish data validator class.
* @properties int $id Auto-increment, set by database.
* @properties string $type Content object type eg. TfArticle etc. [ALPHA]
* @properties string $title The name of this content.
* @properties string $teaser A short (one paragraph) summary or abstract for this content. [HTML]
* @properties string $description The full article or description of the content. [HTML]
* @properties string $media An associated download/audio/video file. [FILEPATH OR URL]
* @properties string $format Mimetype
* @properties string $fileSize Specify in bytes.
* @properties string $creator Author.
* @properties string image An associated image file, eg. a screenshot a good way to handle it. [FILEPATH OR URL]
* @properties string $caption Caption of the image file.
* @properties string $date Date of publication expressed as a string.
* @properties int $parent A source work or collection of which this content is part.
* @properties string $language Future proofing.
* @properties int $rights Intellectual property rights scheme or license under which the work is distributed.
* @properties string $publisher The entity responsible for distributing this work.
* @properties array $tags Tag IDs associated with this object; not persistent (stored as taglinks in taglinks table).
* @properties int $online Toggle object on or offline.
* @properties int $submissionTime Timestamp representing submission time.
* @properties int $counter Number of times this content was viewed or downloaded.
* @properties string $metaTitle Set a custom page title for this content.
* @properties string $metaDescription Set a custom page meta description for this content.
* @properties string $seo SEO-friendly string; it will be appended to the URL for this content.
* @properties string $handler Handler for this object (not persistent).
* @properties string $template The template that should be used to display this object (not persistent).
* @properties string $module The module that handles this content type (not persistent).
* @properties string $icon The Font Awesome icon representing this content type (not persistent).
*/
class TfCollection extends TfContentObject
{
/**
* Constructor.
*
* @param TfValidator $validator An instance of the Tuskfish data validator class.
*/
function __construct(TfValidator $validator)
{
// Must call parent constructor first.
parent::__construct($validator);
// Declare the type, template and module for this this class
$this->type = "TfCollection";
$this->template = "collection";
$this->module = "content";
$this->icon = '<i class="fas fa-folder-open"></i>';
// Object definition - unset any properties unused in this subclass.
$listOfZeroedProperties = $this->getListOfZeroedProperties();
foreach ($listOfZeroedProperties as $property) {
unset($this->$property);
}
}
/**
* Returns an array of base object properties that are not used by this subclass.
*
* This list is also used in update calls to the database to ensure that unused columns are
* cleared and reset with default values.
*
* @return array Array of properties that should be zeroed (unset).
*/
public function getListOfZeroedProperties()
{
return array();
}
/**
* Set the value of a whitelisted property.
*
* Intercepts direct calls to set the value of an object property. This method is overridden by
* child classes to impose data type restrictions and range checks on custom subclass
* properties.
*
* If you have added some custom properties to this content subclass that need to be type
* and/or range checked before permitting assignment, add a switch above the call to the parent
* method. Structure it so that any case not explicitly handled will fall through to the parent
* method, while explicit cases will be handled here.
*
* @param string $property Name of property.
* @param mixed $value Value of property.
*/
public function __set(string $property, $value)
{
parent::__set($property, $value);
}
}