Source of file GalleryImage.php
Size: 6,731 Bytes - Last Modified: 2021-12-23T10:36:50+00:00
/var/www/docs.ssmods.com/process/src/src/Pages/GalleryImage.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 | <?php /** * This file is part of SilverWare. * * PHP version >=5.6.0 * * For full copyright and license information, please view the * LICENSE.md file that was distributed with this source code. * * @package SilverWare\Gallery\Pages * @author Colin Tucker <colin@praxis.net.au> * @copyright 2017 Praxis Interactive * @license https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause * @link https://github.com/praxisnetau/silverware-gallery */ namespace SilverWare\Gallery\Pages; use SilverWare\Extensions\Model\DetailFieldsExtension; use Page; /** * An extension of the page class for a gallery image. * * @package SilverWare\Gallery\Pages * @author Colin Tucker <colin@praxis.net.au> * @copyright 2017 Praxis Interactive * @license https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause * @link https://github.com/praxisnetau/silverware-gallery */ class GalleryImage extends Page { /** * Human-readable singular name. * * @var string * @config */ private static $singular_name = 'Gallery Image'; /** * Human-readable plural name. * * @var string * @config */ private static $plural_name = 'Gallery Images'; /** * Description of this object. * * @var string * @config */ private static $description = 'An individual image within a gallery album'; /** * Icon file for this object. * * @var string * @config */ private static $icon = 'silverware/gallery: admin/client/dist/images/icons/GalleryImage.png'; /** * Defines the table name to use for this object. * * @var string * @config */ private static $table_name = 'SilverWare_GalleryImage'; /** * Determines whether this object can exist at the root level. * * @var boolean * @config */ private static $can_be_root = false; /** * Defines the allowed children for this object. * * @var array|string * @config */ private static $allowed_children = 'none'; /** * Defines the default values for the fields of this object. * * @var array * @config */ private static $defaults = [ 'ShowInMenus' => 0 ]; /** * Maps field and method names to the class names of casting objects. * * @var array * @config */ private static $casting = [ 'AlbumLink' => 'HTMLFragment' ]; /** * Defines the extension classes to apply to this object. * * @var array * @config */ private static $extensions = [ DetailFieldsExtension::class ]; /** * Defines the meta field configuration for this object. * * @var array * @config */ private static $meta_fields = [ 'Image' => 'Root.Main', 'Summary' => false ]; /** * Defines the detail fields to show for the object. * * @var array * @config */ private static $detail_fields = [ 'date' => [ 'name' => 'Date', 'icon' => 'calendar', 'text' => '$MetaDateFormatted', 'show' => 'DateShown' ], 'album' => [ 'name' => 'Album', 'icon' => 'folder-o', 'text' => '$AlbumLink' ] ]; /** * Defines the format for the meta date field. * * @var string * @config */ private static $meta_date_format = 'd MMMM Y'; /** * Defines the setting for showing the detail fields inline. * * @var boolean * @config */ private static $detail_fields_inline = true; /** * Defines the setting for hiding the detail fields header. * * @var boolean * @config */ private static $detail_fields_hide_header = true; /** * Defines the setting for hiding the detail field names. * * @var boolean * @config */ private static $detail_fields_hide_names = true; /** * Answers a list of field objects for the CMS interface. * * @return FieldList */ public function getCMSFields() { // Obtain Field Objects (from parent): $fields = parent::getCMSFields(); // Remove Field Objects: $fields->removeFieldFromTab('Root.Main', 'Content'); // Answer Field Objects: return $fields; } /** * Answers the name of the asset folder used for uploading images. * * @return string */ public function getMetaImageFolder() { if ($album = $this->getAlbum()) { return $album->getMetaImageFolder(); } } /** * Answers the summary for the object. * * @return DBHTMLText */ public function getMetaSummary() { return $this->dbObject('ImageMetaCaption'); } /** * Answers the parent album of the receiver. * * @return GalleryAlbum */ public function getAlbum() { return $this->getParent(); } /** * Answers a string of HTML containing a link to the parent album. * * @return string */ public function getAlbumLink() { return sprintf( '<a href="%s">%s</a>', $this->getAlbum()->Link(), $this->getAlbum()->Title ); } /** * Answers a link for the previous image in the album. * * @return string */ public function getPrevLink() { return $this->getAlbum()->getPrevLink($this); } /** * Answers a link for the next image in the album. * * @return string */ public function getNextLink() { return $this->getAlbum()->getNextLink($this); } /** * Answers the text for the previous image button. * * @return string */ public function getPrevText() { return _t(__CLASS__ . '.PREVIOUS', 'Previous'); } /** * Answers the text for the next image button. * * @return string */ public function getNextText() { return _t(__CLASS__ . '.NEXT', 'Next'); } /** * Answers true if the date is to be shown. * * @return boolean */ public function getDateShown() { return !$this->getAlbum()->HideImageDate; } /** * Answers true if the footer is to be shown. * * @return boolean */ public function getFooterShown() { return ($this->getAlbum()->getImageCount() > 1); } } |