Source of file CollectionPage.php
Size: 3,108 Bytes - Last Modified: 2021-12-24T05:18:05+00:00
/var/www/docs.ssmods.com/process/src/src/pages/CollectionPage.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 | <?php /** * * @copyright (c) 2017 Insite Apps - http://www.insiteapps.co.za * @package insiteapps * @author Patrick Chitovoro <patrick@insiteapps.co.za> * All rights reserved. No warranty, explicit or implicit, provided. * * NOTICE: All information contained herein is, and remains the property of Insite Apps and its suppliers, if any. * The intellectual and technical concepts contained herein are proprietary to Insite Apps and its suppliers and may be * covered by South African. and Foreign Patents, patents in process, and are protected by trade secret or copyright * laws. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written * permission is obtained from Insite Apps. Proprietary and confidential. There is no freedom to use, share or change * this file. * * */ class CollectionPage extends Page { private static $empty_string = "-Select-"; private static $allowed_children = array(); private static $default_child = ""; public function canCreate( $member = null ) { return !DataObject::get_one( $this->class ); } public static function find_link( $action = false ) { if ( !$page = DataObject::get_one( get_class() ) ) { user_error( sprintf( 'No %s found. Please create one in the CMS!', get_class() ), E_USER_ERROR ); } return $page->Link( $action ); } function Children() { $aChildren = ArrayList::create(); $oCollections = ListingCollection::get()->filterByCallback( function ( $item, $list ) { return ( $item->ListingCounter() ); } ); foreach ( $oCollections as $oCollection ) { $aChildren->push( ArrayData::create( [ "Title" => $oCollection->Title, "MenuTitle" => $oCollection->Title, "Link" => $oCollection->Link(), ] ) ); } return $aChildren; } public function getCMSFields() { $fields = parent::getCMSFields(); return $fields; } } class CollectionPage_Controller extends Page_Controller { private static $allowed_actions = array( 'view', ); private static $url_handlers = array( '' => 'index', '$ID/$OtherID' => 'view', ); public function view() { $oCollection = DataObject::get_one( 'ListingCollection', sprintf( "URLSegment = '%s'", $this->urlParamsID() ) ); if ( $oCollection ) { $title = $oCollection->Title; $aData = array( 'Title' => $title, 'CustomPageTitle' => $title . ' <small>Collection</small>', 'ProductList' => $oCollection->Listings(), ); return $this->customise( $aData )->renderWith( [ 'CollectionPage_view', 'Page', ] ); } return $this->httpError( '404' ); } } |