Source of file ShortListExtension.php
Size: 1,495 Bytes - Last Modified: 2021-12-23T10:19:40+00:00
/var/www/docs.ssmods.com/process/src/code/extensions/ShortListExtension.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | <?php /* * @file ShortListExtension.php * * Extensions for Shortlist */ class ShortListExtension extends DataExtension { /** * Return the shortlist URL for this session. * */ public function getShortlistURL($full = false) { if ($full) { $shortlist = $this->getShortList(); if ($shortlist && $shortlist->exists()) { return $shortlist->Link(); } } else { return Config::inst()->get('ShortList', 'URLSegment'); } return false; } /** * Return the current session id. * */ public function getSessionID() { return Utilities::getSecurityToken(); } public function getShortList() { return DataObject::get_one('ShortList', $filter = array('SessionID' => $this->getSessionID())); } public function getShortListCount() { $shortlist = $this->getShortList(); if ($shortlist && $shortlist->exists()) { return $shortlist->ShortListItems()->Count(); } return 0; } public function AddedToShortList($ID = null, $type = null) { if (is_null($ID) || is_null($type)) { return false; } $shortlist = $this->getShortList(); if ($shortlist) { $items = $shortlist->ShortListItems()->filter(array('ItemID' => $ID, 'ItemType' => $type)); return $items->Count() > 0; } return 0; } } |