@@ -12,61 +12,61 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class DefaultSlideTypeTask extends BuildTask |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @var string |
|
| 17 | - */ |
|
| 18 | - private static $segment = 'default-slide-type-task'; |
|
| 15 | + /** |
|
| 16 | + * @var string |
|
| 17 | + */ |
|
| 18 | + private static $segment = 'default-slide-type-task'; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - protected $title = 'Flexslider - Default Slide Type Task'; |
|
| 20 | + /** |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + protected $title = 'Flexslider - Default Slide Type Task'; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @param \SilverStripe\Control\HTTPRequest $request |
|
| 27 | - */ |
|
| 28 | - public function run($request) |
|
| 29 | - { |
|
| 30 | - $this->setDefaults(); |
|
| 31 | - } |
|
| 25 | + /** |
|
| 26 | + * @param \SilverStripe\Control\HTTPRequest $request |
|
| 27 | + */ |
|
| 28 | + public function run($request) |
|
| 29 | + { |
|
| 30 | + $this->setDefaults(); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * |
|
| 35 | - */ |
|
| 36 | - protected function setDefaults() |
|
| 37 | - { |
|
| 38 | - $default = SlideImage::singleton()->config()->get('defaults'); |
|
| 33 | + /** |
|
| 34 | + * |
|
| 35 | + */ |
|
| 36 | + protected function setDefaults() |
|
| 37 | + { |
|
| 38 | + $default = SlideImage::singleton()->config()->get('defaults'); |
|
| 39 | 39 | |
| 40 | - if (isset($default['SlideType'])) { |
|
| 41 | - $baseTable = SlideImage::singleton()->baseTable(); |
|
| 40 | + if (isset($default['SlideType'])) { |
|
| 41 | + $baseTable = SlideImage::singleton()->baseTable(); |
|
| 42 | 42 | |
| 43 | - $tables = [ |
|
| 44 | - $baseTable, |
|
| 45 | - "{$baseTable}_Versions", |
|
| 46 | - "{$baseTable}_Live", |
|
| 47 | - ]; |
|
| 43 | + $tables = [ |
|
| 44 | + $baseTable, |
|
| 45 | + "{$baseTable}_Versions", |
|
| 46 | + "{$baseTable}_Live", |
|
| 47 | + ]; |
|
| 48 | 48 | |
| 49 | - foreach ($tables as $table) { |
|
| 50 | - $query = DB::query("SELECT * FROM \"{$table}\" WHERE \"SlideType\" IS NULL"); |
|
| 49 | + foreach ($tables as $table) { |
|
| 50 | + $query = DB::query("SELECT * FROM \"{$table}\" WHERE \"SlideType\" IS NULL"); |
|
| 51 | 51 | |
| 52 | - foreach ($this->yieldSingle($query) as $record) { |
|
| 53 | - DB::prepared_query( |
|
| 54 | - "UPDATE \"{$table}\" SET \"SlideType\" = ? WHERE \"ID\" = ?", |
|
| 55 | - [$default['SlideType'], $record['ID']] |
|
| 56 | - ); |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - } |
|
| 52 | + foreach ($this->yieldSingle($query) as $record) { |
|
| 53 | + DB::prepared_query( |
|
| 54 | + "UPDATE \"{$table}\" SET \"SlideType\" = ? WHERE \"ID\" = ?", |
|
| 55 | + [$default['SlideType'], $record['ID']] |
|
| 56 | + ); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @param $list |
|
| 64 | - * @return \Generator |
|
| 65 | - */ |
|
| 66 | - protected function yieldSingle($list) |
|
| 67 | - { |
|
| 68 | - foreach ($list as $item) { |
|
| 69 | - yield $item; |
|
| 70 | - } |
|
| 71 | - } |
|
| 62 | + /** |
|
| 63 | + * @param $list |
|
| 64 | + * @return \Generator |
|
| 65 | + */ |
|
| 66 | + protected function yieldSingle($list) |
|
| 67 | + { |
|
| 68 | + foreach ($list as $item) { |
|
| 69 | + yield $item; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -14,122 +14,122 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class SlideLinkTask extends BuildTask |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 20 | - protected $title = 'Flexslider - Slide Link Migration Task'; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - private static $segment = 'slide-link-migration-task'; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @var array |
|
| 29 | - */ |
|
| 30 | - private $known_links = []; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @param \SilverStripe\Control\HTTPRequest $request |
|
| 34 | - * @throws \SilverStripe\ORM\ValidationException |
|
| 35 | - */ |
|
| 36 | - public function run($request) |
|
| 37 | - { |
|
| 38 | - $this->migrateLinks(); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @throws \SilverStripe\ORM\ValidationException |
|
| 43 | - */ |
|
| 44 | - protected function migrateLinks() |
|
| 45 | - { |
|
| 46 | - $baseTable = SlideImage::singleton()->baseTable(); |
|
| 47 | - |
|
| 48 | - $tables = [ |
|
| 49 | - $baseTable, |
|
| 50 | - "{$baseTable}_Versions", |
|
| 51 | - "{$baseTable}_Live", |
|
| 52 | - ]; |
|
| 53 | - |
|
| 54 | - foreach ($tables as $table) { |
|
| 55 | - foreach ($this->yieldSingle(DB::query("SELECT * FROM \"{$table}\"")) as $record) { |
|
| 56 | - $linkID = $record['PageLinkID']; |
|
| 57 | - $linkLabel = isset($record['LinkLabel']) ? $record['LinkLabel'] : null; |
|
| 58 | - |
|
| 59 | - $slideLink = $this->findOrMakeLink($linkID, $linkLabel); |
|
| 60 | - |
|
| 61 | - if ($slideLink !== false && $slideLink instanceof Link) { |
|
| 62 | - DB::prepared_query( |
|
| 63 | - "UPDATE \"{$table}\" SET \"SlideLinkID\" = ? WHERE \"ID\" = ?", |
|
| 64 | - [$slideLink->ID, $record['ID']] |
|
| 65 | - ); |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @param $list |
|
| 73 | - * @return \Generator |
|
| 74 | - */ |
|
| 75 | - private function yieldSingle($list) |
|
| 76 | - { |
|
| 77 | - foreach ($list as $item) { |
|
| 78 | - yield $item; |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * @param int $linkID |
|
| 84 | - * @param string $linkLabel |
|
| 85 | - * @return bool|mixed|Link |
|
| 86 | - * @throws \SilverStripe\ORM\ValidationException |
|
| 87 | - */ |
|
| 88 | - private function findOrMakeLink($linkID = 0, $linkLabel = '') |
|
| 89 | - { |
|
| 90 | - if (!$linkID || !($page = SiteTree::get()->byID($linkID))) { |
|
| 91 | - return false; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - if (isset($this->getKnownLinks()[$linkID])) { |
|
| 95 | - return $this->getKnownLinks()[$linkID]; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - $link = Link::create(); |
|
| 99 | - $link->Type = 'SiteTree'; |
|
| 100 | - $link->SiteTreeID = $linkID; |
|
| 101 | - $link->Template = 'button'; |
|
| 102 | - |
|
| 103 | - if ($linkLabel !== null && $linkLabel !== '') { |
|
| 104 | - $link->Title = $linkLabel; |
|
| 105 | - } else { |
|
| 106 | - $link->Title = $page->Title; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - $link->write(); |
|
| 110 | - |
|
| 111 | - $this->addKnownLink($linkID, $link); |
|
| 112 | - |
|
| 113 | - return $link; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * @param $linkID |
|
| 118 | - * @param $linkableLinkID |
|
| 119 | - * @return $this |
|
| 120 | - */ |
|
| 121 | - private function addKnownLink($linkID, $linkableLinkID) |
|
| 122 | - { |
|
| 123 | - $this->known_links[$linkID] = $linkableLinkID; |
|
| 124 | - |
|
| 125 | - return $this; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @return array |
|
| 130 | - */ |
|
| 131 | - private function getKnownLinks() |
|
| 132 | - { |
|
| 133 | - return $this->known_links; |
|
| 134 | - } |
|
| 17 | + /** |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | + protected $title = 'Flexslider - Slide Link Migration Task'; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + private static $segment = 'slide-link-migration-task'; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @var array |
|
| 29 | + */ |
|
| 30 | + private $known_links = []; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @param \SilverStripe\Control\HTTPRequest $request |
|
| 34 | + * @throws \SilverStripe\ORM\ValidationException |
|
| 35 | + */ |
|
| 36 | + public function run($request) |
|
| 37 | + { |
|
| 38 | + $this->migrateLinks(); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @throws \SilverStripe\ORM\ValidationException |
|
| 43 | + */ |
|
| 44 | + protected function migrateLinks() |
|
| 45 | + { |
|
| 46 | + $baseTable = SlideImage::singleton()->baseTable(); |
|
| 47 | + |
|
| 48 | + $tables = [ |
|
| 49 | + $baseTable, |
|
| 50 | + "{$baseTable}_Versions", |
|
| 51 | + "{$baseTable}_Live", |
|
| 52 | + ]; |
|
| 53 | + |
|
| 54 | + foreach ($tables as $table) { |
|
| 55 | + foreach ($this->yieldSingle(DB::query("SELECT * FROM \"{$table}\"")) as $record) { |
|
| 56 | + $linkID = $record['PageLinkID']; |
|
| 57 | + $linkLabel = isset($record['LinkLabel']) ? $record['LinkLabel'] : null; |
|
| 58 | + |
|
| 59 | + $slideLink = $this->findOrMakeLink($linkID, $linkLabel); |
|
| 60 | + |
|
| 61 | + if ($slideLink !== false && $slideLink instanceof Link) { |
|
| 62 | + DB::prepared_query( |
|
| 63 | + "UPDATE \"{$table}\" SET \"SlideLinkID\" = ? WHERE \"ID\" = ?", |
|
| 64 | + [$slideLink->ID, $record['ID']] |
|
| 65 | + ); |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @param $list |
|
| 73 | + * @return \Generator |
|
| 74 | + */ |
|
| 75 | + private function yieldSingle($list) |
|
| 76 | + { |
|
| 77 | + foreach ($list as $item) { |
|
| 78 | + yield $item; |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * @param int $linkID |
|
| 84 | + * @param string $linkLabel |
|
| 85 | + * @return bool|mixed|Link |
|
| 86 | + * @throws \SilverStripe\ORM\ValidationException |
|
| 87 | + */ |
|
| 88 | + private function findOrMakeLink($linkID = 0, $linkLabel = '') |
|
| 89 | + { |
|
| 90 | + if (!$linkID || !($page = SiteTree::get()->byID($linkID))) { |
|
| 91 | + return false; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + if (isset($this->getKnownLinks()[$linkID])) { |
|
| 95 | + return $this->getKnownLinks()[$linkID]; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + $link = Link::create(); |
|
| 99 | + $link->Type = 'SiteTree'; |
|
| 100 | + $link->SiteTreeID = $linkID; |
|
| 101 | + $link->Template = 'button'; |
|
| 102 | + |
|
| 103 | + if ($linkLabel !== null && $linkLabel !== '') { |
|
| 104 | + $link->Title = $linkLabel; |
|
| 105 | + } else { |
|
| 106 | + $link->Title = $page->Title; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + $link->write(); |
|
| 110 | + |
|
| 111 | + $this->addKnownLink($linkID, $link); |
|
| 112 | + |
|
| 113 | + return $link; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * @param $linkID |
|
| 118 | + * @param $linkableLinkID |
|
| 119 | + * @return $this |
|
| 120 | + */ |
|
| 121 | + private function addKnownLink($linkID, $linkableLinkID) |
|
| 122 | + { |
|
| 123 | + $this->known_links[$linkID] = $linkableLinkID; |
|
| 124 | + |
|
| 125 | + return $this; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * @return array |
|
| 130 | + */ |
|
| 131 | + private function getKnownLinks() |
|
| 132 | + { |
|
| 133 | + return $this->known_links; |
|
| 134 | + } |
|
| 135 | 135 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | $slideLink = $this->findOrMakeLink($linkID, $linkLabel); |
| 60 | 60 | |
| 61 | - if ($slideLink !== false && $slideLink instanceof Link) { |
|
| 61 | + if ($slideLink!==false && $slideLink instanceof Link) { |
|
| 62 | 62 | DB::prepared_query( |
| 63 | 63 | "UPDATE \"{$table}\" SET \"SlideLinkID\" = ? WHERE \"ID\" = ?", |
| 64 | 64 | [$slideLink->ID, $record['ID']] |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $link->SiteTreeID = $linkID; |
| 101 | 101 | $link->Template = 'button'; |
| 102 | 102 | |
| 103 | - if ($linkLabel !== null && $linkLabel !== '') { |
|
| 103 | + if ($linkLabel!==null && $linkLabel!=='') { |
|
| 104 | 104 | $link->Title = $linkLabel; |
| 105 | 105 | } else { |
| 106 | 106 | $link->Title = $page->Title; |
@@ -16,91 +16,91 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class SlideThumbnailNavMigrationTask extends BuildTask |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @var string |
|
| 21 | - */ |
|
| 22 | - protected $title = 'FlexSlider - Default Values'; |
|
| 19 | + /** |
|
| 20 | + * @var string |
|
| 21 | + */ |
|
| 22 | + protected $title = 'FlexSlider - Default Values'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - protected $description = 'Set default values for slider after the thumbnail nav update'; |
|
| 24 | + /** |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + protected $description = 'Set default values for slider after the thumbnail nav update'; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 32 | - private static $segment = 'slide-thumbnail-nav-migration-task'; |
|
| 29 | + /** |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | + private static $segment = 'slide-thumbnail-nav-migration-task'; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @var bool |
|
| 36 | - */ |
|
| 37 | - protected $enabled = true; |
|
| 34 | + /** |
|
| 35 | + * @var bool |
|
| 36 | + */ |
|
| 37 | + protected $enabled = true; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param $request |
|
| 41 | - */ |
|
| 42 | - public function run($request) |
|
| 43 | - { |
|
| 44 | - $this->defaultSliderSettings(); |
|
| 45 | - } |
|
| 39 | + /** |
|
| 40 | + * @param $request |
|
| 41 | + */ |
|
| 42 | + public function run($request) |
|
| 43 | + { |
|
| 44 | + $this->defaultSliderSettings(); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @param $class |
|
| 49 | - * @return \Generator |
|
| 50 | - */ |
|
| 51 | - protected function getObjectSet($class) |
|
| 52 | - { |
|
| 53 | - foreach ($class::get() as $object) { |
|
| 54 | - yield $object; |
|
| 55 | - } |
|
| 56 | - } |
|
| 47 | + /** |
|
| 48 | + * @param $class |
|
| 49 | + * @return \Generator |
|
| 50 | + */ |
|
| 51 | + protected function getObjectSet($class) |
|
| 52 | + { |
|
| 53 | + foreach ($class::get() as $object) { |
|
| 54 | + yield $object; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * |
|
| 60 | - */ |
|
| 61 | - public function defaultSliderSettings() |
|
| 62 | - { |
|
| 63 | - $ct = 0; |
|
| 58 | + /** |
|
| 59 | + * |
|
| 60 | + */ |
|
| 61 | + public function defaultSliderSettings() |
|
| 62 | + { |
|
| 63 | + $ct = 0; |
|
| 64 | 64 | |
| 65 | - $objects = ClassInfo::subclassesFor(DataObject::class); |
|
| 65 | + $objects = ClassInfo::subclassesFor(DataObject::class); |
|
| 66 | 66 | |
| 67 | - if ($objects) { |
|
| 68 | - unset($objects[DataObject::class]); |
|
| 69 | - foreach ($objects as $object) { |
|
| 70 | - if ($object::singleton()->hasExtension(FlexSlider::class)) { |
|
| 71 | - foreach ($this->getObjectSet($object) as $result) { |
|
| 72 | - $result->Loop = 1; |
|
| 73 | - $result->Animate = 1; |
|
| 74 | - $result->SliderControlNav = 0; |
|
| 75 | - $result->SliderDirectionNav = 1; |
|
| 76 | - $result->CarouselControlNav = 0; |
|
| 77 | - $result->CarouselDirectionNav = 1; |
|
| 78 | - $result->CarouselThumbnailCt = 6; |
|
| 79 | - if ($result instanceof SiteTree || $object::singleton()->hasExtension(Versioned::class)) { |
|
| 80 | - $result->writeToStage('Stage'); |
|
| 81 | - if ($result->isPublished()) { |
|
| 82 | - $result->publishRecursive(); |
|
| 83 | - } |
|
| 84 | - } else { |
|
| 85 | - $result->write(); |
|
| 86 | - } |
|
| 87 | - $ct++; |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - static::write_message($ct . " Sliders updated"); |
|
| 93 | - } |
|
| 67 | + if ($objects) { |
|
| 68 | + unset($objects[DataObject::class]); |
|
| 69 | + foreach ($objects as $object) { |
|
| 70 | + if ($object::singleton()->hasExtension(FlexSlider::class)) { |
|
| 71 | + foreach ($this->getObjectSet($object) as $result) { |
|
| 72 | + $result->Loop = 1; |
|
| 73 | + $result->Animate = 1; |
|
| 74 | + $result->SliderControlNav = 0; |
|
| 75 | + $result->SliderDirectionNav = 1; |
|
| 76 | + $result->CarouselControlNav = 0; |
|
| 77 | + $result->CarouselDirectionNav = 1; |
|
| 78 | + $result->CarouselThumbnailCt = 6; |
|
| 79 | + if ($result instanceof SiteTree || $object::singleton()->hasExtension(Versioned::class)) { |
|
| 80 | + $result->writeToStage('Stage'); |
|
| 81 | + if ($result->isPublished()) { |
|
| 82 | + $result->publishRecursive(); |
|
| 83 | + } |
|
| 84 | + } else { |
|
| 85 | + $result->write(); |
|
| 86 | + } |
|
| 87 | + $ct++; |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + static::write_message($ct . " Sliders updated"); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * @param $message |
|
| 97 | - */ |
|
| 98 | - protected static function write_message($message) |
|
| 99 | - { |
|
| 100 | - if (Director::is_cli()) { |
|
| 101 | - echo "{$message}\n"; |
|
| 102 | - } else { |
|
| 103 | - echo "{$message}<br><br>"; |
|
| 104 | - } |
|
| 105 | - } |
|
| 95 | + /** |
|
| 96 | + * @param $message |
|
| 97 | + */ |
|
| 98 | + protected static function write_message($message) |
|
| 99 | + { |
|
| 100 | + if (Director::is_cli()) { |
|
| 101 | + echo "{$message}\n"; |
|
| 102 | + } else { |
|
| 103 | + echo "{$message}<br><br>"; |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | 106 | } |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | - static::write_message($ct . " Sliders updated"); |
|
| 92 | + static::write_message($ct." Sliders updated"); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -36,312 +36,312 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class SlideImage extends DataObject implements PermissionProvider |
| 38 | 38 | { |
| 39 | - /** |
|
| 40 | - * @var string |
|
| 41 | - */ |
|
| 42 | - private static $singular_name = 'Slide'; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 47 | - private static $plural_name = 'Slides'; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @var array |
|
| 51 | - */ |
|
| 52 | - private static $db = [ |
|
| 53 | - 'Name' => 'Varchar(255)', |
|
| 54 | - 'Headline' => 'Varchar(255)', |
|
| 55 | - 'Description' => 'Text', |
|
| 56 | - 'SortOrder' => 'Int', |
|
| 57 | - 'SlideType' => 'Varchar', |
|
| 58 | - ]; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * @var array |
|
| 62 | - */ |
|
| 63 | - private static $has_one = [ |
|
| 64 | - 'Image' => Image::class, |
|
| 65 | - 'Video' => EmbeddedObject::class, |
|
| 66 | - 'Page' => \Page::class, |
|
| 67 | - 'PageLink' => SiteTree::class, |
|
| 68 | - 'SlideLink' => Link::class, |
|
| 69 | - ]; |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @var array |
|
| 73 | - */ |
|
| 74 | - private static $owns = [ |
|
| 75 | - 'Image', |
|
| 76 | - ]; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @var string |
|
| 80 | - */ |
|
| 81 | - private static $table_name = 'SlideImage'; |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @var string |
|
| 85 | - */ |
|
| 86 | - private static $default_sort = 'SortOrder'; |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Adds Publish button to SlideImage record |
|
| 90 | - * |
|
| 91 | - * @var bool |
|
| 92 | - */ |
|
| 93 | - private static $versioned_gridfield_extensions = true; |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * @var array |
|
| 97 | - */ |
|
| 98 | - private static $defaults = [ |
|
| 99 | - 'SlideType' => 'Image', |
|
| 100 | - ]; |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @var array |
|
| 104 | - */ |
|
| 105 | - private static $summary_fields = [ |
|
| 106 | - 'Image.CMSThumbnail' => 'Image', |
|
| 107 | - 'Name' => 'Name', |
|
| 108 | - ]; |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * @var array |
|
| 112 | - */ |
|
| 113 | - private static $searchable_fields = [ |
|
| 114 | - 'Name', |
|
| 115 | - 'Headline', |
|
| 116 | - 'Description', |
|
| 117 | - ]; |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @var int |
|
| 121 | - */ |
|
| 122 | - private static $image_size_limit = 512000; |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * @var array |
|
| 126 | - */ |
|
| 127 | - private static $slide_types = [ |
|
| 128 | - 'Image', |
|
| 129 | - 'Video', |
|
| 130 | - 'Text', |
|
| 131 | - ]; |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * @param bool $includerelations |
|
| 135 | - * @return array |
|
| 136 | - */ |
|
| 137 | - public function fieldLabels($includerelations = true) |
|
| 138 | - { |
|
| 139 | - $labels = parent::fieldLabels($includerelations); |
|
| 140 | - |
|
| 141 | - $labels['Name'] = _t(__CLASS__ . '.NAME', 'Name'); |
|
| 142 | - $labels['Headline'] = _t(__CLASS__ . '.HEADLINE', 'Headline'); |
|
| 143 | - $labels['Description'] = _t(__CLASS__ . '.DESCRIPTION', 'Description'); |
|
| 144 | - $labels['SlideLinkID'] = _t(__CLASS__ . '.PAGE_LINK', "Call to action link"); |
|
| 145 | - $labels['Image'] = _t(__CLASS__ . '.IMAGE', 'Image'); |
|
| 146 | - $labels['SlideType'] = _t(__CLASS__ . '.SlideType', 'Image or Video'); |
|
| 147 | - $labels['Video'] = _t(__CLASS__ . '.VideoLabel', 'Video URL'); |
|
| 148 | - |
|
| 149 | - return $labels; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * @return \SilverStripe\Forms\FieldList |
|
| 154 | - */ |
|
| 155 | - public function getCMSFields() |
|
| 156 | - { |
|
| 157 | - $this->beforeUpdateCMSFields(function ($fields) { |
|
| 158 | - $fields->removeByName([ |
|
| 159 | - 'ShowSlide', |
|
| 160 | - 'SortOrder', |
|
| 161 | - 'PageID', |
|
| 162 | - 'Image', |
|
| 163 | - 'SlideType', |
|
| 164 | - 'Video', |
|
| 165 | - 'VideoID', |
|
| 166 | - 'SlideLinkID', |
|
| 167 | - ]); |
|
| 168 | - |
|
| 169 | - // Name |
|
| 170 | - $fields->dataFieldByName('Name') |
|
| 171 | - ->setDescription( |
|
| 172 | - _t(__CLASS__ . '.INTERNAL_USE', 'for internal reference only') |
|
| 173 | - ); |
|
| 174 | - |
|
| 175 | - // Headline |
|
| 176 | - $fields->dataFieldByName('Headline') |
|
| 177 | - ->setDescription( |
|
| 178 | - _t(__CLASS__ . '.USED_IN_TEMPLATE', 'optional, used in template') |
|
| 179 | - ); |
|
| 180 | - |
|
| 181 | - // Description |
|
| 182 | - $fields->dataFieldByName('Description') |
|
| 183 | - ->setDescription( |
|
| 184 | - _t(__CLASS__ . '.USED_IN_TEMPLATE', 'optional, used in template') |
|
| 185 | - ); |
|
| 186 | - |
|
| 187 | - // Page link |
|
| 188 | - $fields->replaceField( |
|
| 189 | - 'PageLinkID', |
|
| 190 | - LinkField::create('SlideLinkID', $this->fieldLabel('SlideLinkID')) |
|
| 191 | - ); |
|
| 192 | - |
|
| 193 | - // Image |
|
| 194 | - $image = UploadField::create('Image', $this->fieldLabel('Image')) |
|
| 195 | - ->setFolderName('Uploads/SlideImages'); |
|
| 196 | - |
|
| 197 | - $image->getValidator()->setAllowedExtensions(['jpg', 'jpeg', 'png', 'gif']); |
|
| 198 | - |
|
| 199 | - $fields->addFieldToTab( |
|
| 200 | - 'Root.Main', |
|
| 201 | - CompositeField::create(FieldList::create( |
|
| 202 | - DropdownField::create('SlideType', $this->fieldLabel('SlideType')) |
|
| 203 | - ->setSource($this->getTypeSource()), |
|
| 204 | - Wrapper::create( |
|
| 205 | - $image |
|
| 206 | - )->displayIf('SlideType')->isEqualTo('Image')->orIf('SlideType')->isEqualTo('Video')->end(), |
|
| 207 | - Wrapper::create( |
|
| 208 | - $videoField = EmbeddedObjectField::create('Video', $this->fieldLabel('Video')) |
|
| 209 | - ->setDescription(_t(__CLASS__ . '.VideoDescription', 'Supported links: YouTube, Vimeo')) |
|
| 210 | - )->displayIf('SlideType')->isEqualTo('Video')->end() |
|
| 211 | - ))->setName('MediaFields'), |
|
| 212 | - 'Description' |
|
| 213 | - ); |
|
| 214 | - }); |
|
| 215 | - |
|
| 216 | - $fields = parent::getCMSFields(); |
|
| 217 | - |
|
| 218 | - $this->extend('updateSlideImageFields', $fields); |
|
| 219 | - |
|
| 220 | - return $fields; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * @return \SilverStripe\ORM\ValidationResult |
|
| 225 | - */ |
|
| 226 | - public function validate() |
|
| 227 | - { |
|
| 228 | - $result = parent::validate(); |
|
| 229 | - |
|
| 230 | - if (!$this->Name) { |
|
| 231 | - $result->addError( |
|
| 232 | - _t(__CLASS__ . '.NAME_REQUIRED', 'A Name is required before you can save') |
|
| 233 | - ); |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - $types = $this->getTypeSource(); |
|
| 237 | - |
|
| 238 | - if (isset($types['Video']) && $this->SlideType == 'Video' && !$this->VideoID) { |
|
| 239 | - $result->addError( |
|
| 240 | - _t(__CLASS__ . '.VIDEO_REQUIRED', 'An Video Link is required before you can save') |
|
| 241 | - ); |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - if (isset($types['Image']) && $this->SlideType == 'Image' && !$this->ImageID) { |
|
| 245 | - $result->addError( |
|
| 246 | - _t(__CLASS__ . '.IMAGE_REQUIRED', 'An Image is required before you can save') |
|
| 247 | - ); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - if (isset($types['Text']) && $this->SlideType == 'Text' && !$this->Description) { |
|
| 251 | - $result->addError( |
|
| 252 | - _t(__CLASS__ . '.DESCRIPTION_REQUIRED', 'A Description is required before you can save') |
|
| 253 | - ); |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - return $result; |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * @return array |
|
| 261 | - */ |
|
| 262 | - public function providePermissions() |
|
| 263 | - { |
|
| 264 | - return [ |
|
| 265 | - 'Slide_EDIT' => 'Slide Edit', |
|
| 266 | - 'Slide_DELETE' => 'Slide Delete', |
|
| 267 | - 'Slide_CREATE' => 'Slide Create', |
|
| 268 | - ]; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * @param null $member |
|
| 273 | - * @param array $context |
|
| 274 | - * |
|
| 275 | - * @return bool|int |
|
| 276 | - */ |
|
| 277 | - public function canCreate($member = null, $context = []) |
|
| 278 | - { |
|
| 279 | - return Permission::check('Slide_CREATE', 'any', $member); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - /** |
|
| 283 | - * @param null $member |
|
| 284 | - * @param array $context |
|
| 285 | - * |
|
| 286 | - * @return bool|int |
|
| 287 | - */ |
|
| 288 | - public function canEdit($member = null, $context = []) |
|
| 289 | - { |
|
| 290 | - return Permission::check('Slide_EDIT', 'any', $member); |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * @param null $member |
|
| 295 | - * @param array $context |
|
| 296 | - * |
|
| 297 | - * @return bool|int |
|
| 298 | - */ |
|
| 299 | - public function canDelete($member = null, $context = []) |
|
| 300 | - { |
|
| 301 | - return Permission::check('Slide_DELETE', 'any', $member); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * @param null $member |
|
| 306 | - * @param array $context |
|
| 307 | - * |
|
| 308 | - * @return bool |
|
| 309 | - */ |
|
| 310 | - public function canView($member = null, $context = []) |
|
| 311 | - { |
|
| 312 | - return true; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * @return array |
|
| 317 | - */ |
|
| 318 | - public function getTypeSource() |
|
| 319 | - { |
|
| 320 | - $types = $this->config()->get('slide_types'); |
|
| 321 | - asort($types); |
|
| 322 | - return array_combine($types, $types); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * @param null $template |
|
| 327 | - * @param null $customFields |
|
| 328 | - * @return \SilverStripe\ORM\FieldType\DBHTMLText |
|
| 329 | - */ |
|
| 330 | - public function renderWith($template = null, $customFields = null) |
|
| 331 | - { |
|
| 332 | - if ($template === null) { |
|
| 333 | - $template = static::class; |
|
| 334 | - $template = ($this->SlideType) ? $template . "_{$this->SlideType}" : ''; |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - return parent::renderWith($template); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * @return \SilverStripe\ORM\FieldType\DBHTMLText |
|
| 342 | - */ |
|
| 343 | - public function forTemplate() |
|
| 344 | - { |
|
| 345 | - return $this->renderWith(); |
|
| 346 | - } |
|
| 39 | + /** |
|
| 40 | + * @var string |
|
| 41 | + */ |
|
| 42 | + private static $singular_name = 'Slide'; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | + private static $plural_name = 'Slides'; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @var array |
|
| 51 | + */ |
|
| 52 | + private static $db = [ |
|
| 53 | + 'Name' => 'Varchar(255)', |
|
| 54 | + 'Headline' => 'Varchar(255)', |
|
| 55 | + 'Description' => 'Text', |
|
| 56 | + 'SortOrder' => 'Int', |
|
| 57 | + 'SlideType' => 'Varchar', |
|
| 58 | + ]; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @var array |
|
| 62 | + */ |
|
| 63 | + private static $has_one = [ |
|
| 64 | + 'Image' => Image::class, |
|
| 65 | + 'Video' => EmbeddedObject::class, |
|
| 66 | + 'Page' => \Page::class, |
|
| 67 | + 'PageLink' => SiteTree::class, |
|
| 68 | + 'SlideLink' => Link::class, |
|
| 69 | + ]; |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @var array |
|
| 73 | + */ |
|
| 74 | + private static $owns = [ |
|
| 75 | + 'Image', |
|
| 76 | + ]; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @var string |
|
| 80 | + */ |
|
| 81 | + private static $table_name = 'SlideImage'; |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @var string |
|
| 85 | + */ |
|
| 86 | + private static $default_sort = 'SortOrder'; |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Adds Publish button to SlideImage record |
|
| 90 | + * |
|
| 91 | + * @var bool |
|
| 92 | + */ |
|
| 93 | + private static $versioned_gridfield_extensions = true; |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * @var array |
|
| 97 | + */ |
|
| 98 | + private static $defaults = [ |
|
| 99 | + 'SlideType' => 'Image', |
|
| 100 | + ]; |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @var array |
|
| 104 | + */ |
|
| 105 | + private static $summary_fields = [ |
|
| 106 | + 'Image.CMSThumbnail' => 'Image', |
|
| 107 | + 'Name' => 'Name', |
|
| 108 | + ]; |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * @var array |
|
| 112 | + */ |
|
| 113 | + private static $searchable_fields = [ |
|
| 114 | + 'Name', |
|
| 115 | + 'Headline', |
|
| 116 | + 'Description', |
|
| 117 | + ]; |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @var int |
|
| 121 | + */ |
|
| 122 | + private static $image_size_limit = 512000; |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * @var array |
|
| 126 | + */ |
|
| 127 | + private static $slide_types = [ |
|
| 128 | + 'Image', |
|
| 129 | + 'Video', |
|
| 130 | + 'Text', |
|
| 131 | + ]; |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * @param bool $includerelations |
|
| 135 | + * @return array |
|
| 136 | + */ |
|
| 137 | + public function fieldLabels($includerelations = true) |
|
| 138 | + { |
|
| 139 | + $labels = parent::fieldLabels($includerelations); |
|
| 140 | + |
|
| 141 | + $labels['Name'] = _t(__CLASS__ . '.NAME', 'Name'); |
|
| 142 | + $labels['Headline'] = _t(__CLASS__ . '.HEADLINE', 'Headline'); |
|
| 143 | + $labels['Description'] = _t(__CLASS__ . '.DESCRIPTION', 'Description'); |
|
| 144 | + $labels['SlideLinkID'] = _t(__CLASS__ . '.PAGE_LINK', "Call to action link"); |
|
| 145 | + $labels['Image'] = _t(__CLASS__ . '.IMAGE', 'Image'); |
|
| 146 | + $labels['SlideType'] = _t(__CLASS__ . '.SlideType', 'Image or Video'); |
|
| 147 | + $labels['Video'] = _t(__CLASS__ . '.VideoLabel', 'Video URL'); |
|
| 148 | + |
|
| 149 | + return $labels; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * @return \SilverStripe\Forms\FieldList |
|
| 154 | + */ |
|
| 155 | + public function getCMSFields() |
|
| 156 | + { |
|
| 157 | + $this->beforeUpdateCMSFields(function ($fields) { |
|
| 158 | + $fields->removeByName([ |
|
| 159 | + 'ShowSlide', |
|
| 160 | + 'SortOrder', |
|
| 161 | + 'PageID', |
|
| 162 | + 'Image', |
|
| 163 | + 'SlideType', |
|
| 164 | + 'Video', |
|
| 165 | + 'VideoID', |
|
| 166 | + 'SlideLinkID', |
|
| 167 | + ]); |
|
| 168 | + |
|
| 169 | + // Name |
|
| 170 | + $fields->dataFieldByName('Name') |
|
| 171 | + ->setDescription( |
|
| 172 | + _t(__CLASS__ . '.INTERNAL_USE', 'for internal reference only') |
|
| 173 | + ); |
|
| 174 | + |
|
| 175 | + // Headline |
|
| 176 | + $fields->dataFieldByName('Headline') |
|
| 177 | + ->setDescription( |
|
| 178 | + _t(__CLASS__ . '.USED_IN_TEMPLATE', 'optional, used in template') |
|
| 179 | + ); |
|
| 180 | + |
|
| 181 | + // Description |
|
| 182 | + $fields->dataFieldByName('Description') |
|
| 183 | + ->setDescription( |
|
| 184 | + _t(__CLASS__ . '.USED_IN_TEMPLATE', 'optional, used in template') |
|
| 185 | + ); |
|
| 186 | + |
|
| 187 | + // Page link |
|
| 188 | + $fields->replaceField( |
|
| 189 | + 'PageLinkID', |
|
| 190 | + LinkField::create('SlideLinkID', $this->fieldLabel('SlideLinkID')) |
|
| 191 | + ); |
|
| 192 | + |
|
| 193 | + // Image |
|
| 194 | + $image = UploadField::create('Image', $this->fieldLabel('Image')) |
|
| 195 | + ->setFolderName('Uploads/SlideImages'); |
|
| 196 | + |
|
| 197 | + $image->getValidator()->setAllowedExtensions(['jpg', 'jpeg', 'png', 'gif']); |
|
| 198 | + |
|
| 199 | + $fields->addFieldToTab( |
|
| 200 | + 'Root.Main', |
|
| 201 | + CompositeField::create(FieldList::create( |
|
| 202 | + DropdownField::create('SlideType', $this->fieldLabel('SlideType')) |
|
| 203 | + ->setSource($this->getTypeSource()), |
|
| 204 | + Wrapper::create( |
|
| 205 | + $image |
|
| 206 | + )->displayIf('SlideType')->isEqualTo('Image')->orIf('SlideType')->isEqualTo('Video')->end(), |
|
| 207 | + Wrapper::create( |
|
| 208 | + $videoField = EmbeddedObjectField::create('Video', $this->fieldLabel('Video')) |
|
| 209 | + ->setDescription(_t(__CLASS__ . '.VideoDescription', 'Supported links: YouTube, Vimeo')) |
|
| 210 | + )->displayIf('SlideType')->isEqualTo('Video')->end() |
|
| 211 | + ))->setName('MediaFields'), |
|
| 212 | + 'Description' |
|
| 213 | + ); |
|
| 214 | + }); |
|
| 215 | + |
|
| 216 | + $fields = parent::getCMSFields(); |
|
| 217 | + |
|
| 218 | + $this->extend('updateSlideImageFields', $fields); |
|
| 219 | + |
|
| 220 | + return $fields; |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * @return \SilverStripe\ORM\ValidationResult |
|
| 225 | + */ |
|
| 226 | + public function validate() |
|
| 227 | + { |
|
| 228 | + $result = parent::validate(); |
|
| 229 | + |
|
| 230 | + if (!$this->Name) { |
|
| 231 | + $result->addError( |
|
| 232 | + _t(__CLASS__ . '.NAME_REQUIRED', 'A Name is required before you can save') |
|
| 233 | + ); |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + $types = $this->getTypeSource(); |
|
| 237 | + |
|
| 238 | + if (isset($types['Video']) && $this->SlideType == 'Video' && !$this->VideoID) { |
|
| 239 | + $result->addError( |
|
| 240 | + _t(__CLASS__ . '.VIDEO_REQUIRED', 'An Video Link is required before you can save') |
|
| 241 | + ); |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + if (isset($types['Image']) && $this->SlideType == 'Image' && !$this->ImageID) { |
|
| 245 | + $result->addError( |
|
| 246 | + _t(__CLASS__ . '.IMAGE_REQUIRED', 'An Image is required before you can save') |
|
| 247 | + ); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + if (isset($types['Text']) && $this->SlideType == 'Text' && !$this->Description) { |
|
| 251 | + $result->addError( |
|
| 252 | + _t(__CLASS__ . '.DESCRIPTION_REQUIRED', 'A Description is required before you can save') |
|
| 253 | + ); |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + return $result; |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * @return array |
|
| 261 | + */ |
|
| 262 | + public function providePermissions() |
|
| 263 | + { |
|
| 264 | + return [ |
|
| 265 | + 'Slide_EDIT' => 'Slide Edit', |
|
| 266 | + 'Slide_DELETE' => 'Slide Delete', |
|
| 267 | + 'Slide_CREATE' => 'Slide Create', |
|
| 268 | + ]; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * @param null $member |
|
| 273 | + * @param array $context |
|
| 274 | + * |
|
| 275 | + * @return bool|int |
|
| 276 | + */ |
|
| 277 | + public function canCreate($member = null, $context = []) |
|
| 278 | + { |
|
| 279 | + return Permission::check('Slide_CREATE', 'any', $member); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * @param null $member |
|
| 284 | + * @param array $context |
|
| 285 | + * |
|
| 286 | + * @return bool|int |
|
| 287 | + */ |
|
| 288 | + public function canEdit($member = null, $context = []) |
|
| 289 | + { |
|
| 290 | + return Permission::check('Slide_EDIT', 'any', $member); |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * @param null $member |
|
| 295 | + * @param array $context |
|
| 296 | + * |
|
| 297 | + * @return bool|int |
|
| 298 | + */ |
|
| 299 | + public function canDelete($member = null, $context = []) |
|
| 300 | + { |
|
| 301 | + return Permission::check('Slide_DELETE', 'any', $member); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * @param null $member |
|
| 306 | + * @param array $context |
|
| 307 | + * |
|
| 308 | + * @return bool |
|
| 309 | + */ |
|
| 310 | + public function canView($member = null, $context = []) |
|
| 311 | + { |
|
| 312 | + return true; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * @return array |
|
| 317 | + */ |
|
| 318 | + public function getTypeSource() |
|
| 319 | + { |
|
| 320 | + $types = $this->config()->get('slide_types'); |
|
| 321 | + asort($types); |
|
| 322 | + return array_combine($types, $types); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * @param null $template |
|
| 327 | + * @param null $customFields |
|
| 328 | + * @return \SilverStripe\ORM\FieldType\DBHTMLText |
|
| 329 | + */ |
|
| 330 | + public function renderWith($template = null, $customFields = null) |
|
| 331 | + { |
|
| 332 | + if ($template === null) { |
|
| 333 | + $template = static::class; |
|
| 334 | + $template = ($this->SlideType) ? $template . "_{$this->SlideType}" : ''; |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + return parent::renderWith($template); |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * @return \SilverStripe\ORM\FieldType\DBHTMLText |
|
| 342 | + */ |
|
| 343 | + public function forTemplate() |
|
| 344 | + { |
|
| 345 | + return $this->renderWith(); |
|
| 346 | + } |
|
| 347 | 347 | } |
@@ -138,13 +138,13 @@ discard block |
||
| 138 | 138 | { |
| 139 | 139 | $labels = parent::fieldLabels($includerelations); |
| 140 | 140 | |
| 141 | - $labels['Name'] = _t(__CLASS__ . '.NAME', 'Name'); |
|
| 142 | - $labels['Headline'] = _t(__CLASS__ . '.HEADLINE', 'Headline'); |
|
| 143 | - $labels['Description'] = _t(__CLASS__ . '.DESCRIPTION', 'Description'); |
|
| 144 | - $labels['SlideLinkID'] = _t(__CLASS__ . '.PAGE_LINK', "Call to action link"); |
|
| 145 | - $labels['Image'] = _t(__CLASS__ . '.IMAGE', 'Image'); |
|
| 146 | - $labels['SlideType'] = _t(__CLASS__ . '.SlideType', 'Image or Video'); |
|
| 147 | - $labels['Video'] = _t(__CLASS__ . '.VideoLabel', 'Video URL'); |
|
| 141 | + $labels['Name'] = _t(__CLASS__.'.NAME', 'Name'); |
|
| 142 | + $labels['Headline'] = _t(__CLASS__.'.HEADLINE', 'Headline'); |
|
| 143 | + $labels['Description'] = _t(__CLASS__.'.DESCRIPTION', 'Description'); |
|
| 144 | + $labels['SlideLinkID'] = _t(__CLASS__.'.PAGE_LINK', "Call to action link"); |
|
| 145 | + $labels['Image'] = _t(__CLASS__.'.IMAGE', 'Image'); |
|
| 146 | + $labels['SlideType'] = _t(__CLASS__.'.SlideType', 'Image or Video'); |
|
| 147 | + $labels['Video'] = _t(__CLASS__.'.VideoLabel', 'Video URL'); |
|
| 148 | 148 | |
| 149 | 149 | return $labels; |
| 150 | 150 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public function getCMSFields() |
| 156 | 156 | { |
| 157 | - $this->beforeUpdateCMSFields(function ($fields) { |
|
| 157 | + $this->beforeUpdateCMSFields(function($fields) { |
|
| 158 | 158 | $fields->removeByName([ |
| 159 | 159 | 'ShowSlide', |
| 160 | 160 | 'SortOrder', |
@@ -169,19 +169,19 @@ discard block |
||
| 169 | 169 | // Name |
| 170 | 170 | $fields->dataFieldByName('Name') |
| 171 | 171 | ->setDescription( |
| 172 | - _t(__CLASS__ . '.INTERNAL_USE', 'for internal reference only') |
|
| 172 | + _t(__CLASS__.'.INTERNAL_USE', 'for internal reference only') |
|
| 173 | 173 | ); |
| 174 | 174 | |
| 175 | 175 | // Headline |
| 176 | 176 | $fields->dataFieldByName('Headline') |
| 177 | 177 | ->setDescription( |
| 178 | - _t(__CLASS__ . '.USED_IN_TEMPLATE', 'optional, used in template') |
|
| 178 | + _t(__CLASS__.'.USED_IN_TEMPLATE', 'optional, used in template') |
|
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | 181 | // Description |
| 182 | 182 | $fields->dataFieldByName('Description') |
| 183 | 183 | ->setDescription( |
| 184 | - _t(__CLASS__ . '.USED_IN_TEMPLATE', 'optional, used in template') |
|
| 184 | + _t(__CLASS__.'.USED_IN_TEMPLATE', 'optional, used in template') |
|
| 185 | 185 | ); |
| 186 | 186 | |
| 187 | 187 | // Page link |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | )->displayIf('SlideType')->isEqualTo('Image')->orIf('SlideType')->isEqualTo('Video')->end(), |
| 207 | 207 | Wrapper::create( |
| 208 | 208 | $videoField = EmbeddedObjectField::create('Video', $this->fieldLabel('Video')) |
| 209 | - ->setDescription(_t(__CLASS__ . '.VideoDescription', 'Supported links: YouTube, Vimeo')) |
|
| 209 | + ->setDescription(_t(__CLASS__.'.VideoDescription', 'Supported links: YouTube, Vimeo')) |
|
| 210 | 210 | )->displayIf('SlideType')->isEqualTo('Video')->end() |
| 211 | 211 | ))->setName('MediaFields'), |
| 212 | 212 | 'Description' |
@@ -229,27 +229,27 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | if (!$this->Name) { |
| 231 | 231 | $result->addError( |
| 232 | - _t(__CLASS__ . '.NAME_REQUIRED', 'A Name is required before you can save') |
|
| 232 | + _t(__CLASS__.'.NAME_REQUIRED', 'A Name is required before you can save') |
|
| 233 | 233 | ); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | $types = $this->getTypeSource(); |
| 237 | 237 | |
| 238 | - if (isset($types['Video']) && $this->SlideType == 'Video' && !$this->VideoID) { |
|
| 238 | + if (isset($types['Video']) && $this->SlideType=='Video' && !$this->VideoID) { |
|
| 239 | 239 | $result->addError( |
| 240 | - _t(__CLASS__ . '.VIDEO_REQUIRED', 'An Video Link is required before you can save') |
|
| 240 | + _t(__CLASS__.'.VIDEO_REQUIRED', 'An Video Link is required before you can save') |
|
| 241 | 241 | ); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - if (isset($types['Image']) && $this->SlideType == 'Image' && !$this->ImageID) { |
|
| 244 | + if (isset($types['Image']) && $this->SlideType=='Image' && !$this->ImageID) { |
|
| 245 | 245 | $result->addError( |
| 246 | - _t(__CLASS__ . '.IMAGE_REQUIRED', 'An Image is required before you can save') |
|
| 246 | + _t(__CLASS__.'.IMAGE_REQUIRED', 'An Image is required before you can save') |
|
| 247 | 247 | ); |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - if (isset($types['Text']) && $this->SlideType == 'Text' && !$this->Description) { |
|
| 250 | + if (isset($types['Text']) && $this->SlideType=='Text' && !$this->Description) { |
|
| 251 | 251 | $result->addError( |
| 252 | - _t(__CLASS__ . '.DESCRIPTION_REQUIRED', 'A Description is required before you can save') |
|
| 252 | + _t(__CLASS__.'.DESCRIPTION_REQUIRED', 'A Description is required before you can save') |
|
| 253 | 253 | ); |
| 254 | 254 | } |
| 255 | 255 | |
@@ -329,9 +329,9 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | public function renderWith($template = null, $customFields = null) |
| 331 | 331 | { |
| 332 | - if ($template === null) { |
|
| 332 | + if ($template===null) { |
|
| 333 | 333 | $template = static::class; |
| 334 | - $template = ($this->SlideType) ? $template . "_{$this->SlideType}" : ''; |
|
| 334 | + $template = ($this->SlideType) ? $template."_{$this->SlideType}" : ''; |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | return parent::renderWith($template); |
@@ -12,124 +12,124 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class SlideTest extends SapphireTest |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @var string |
|
| 17 | - */ |
|
| 18 | - protected static $fixture_file = '../fixtures.yml'; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * |
|
| 22 | - */ |
|
| 23 | - public function testCanCreate() |
|
| 24 | - { |
|
| 25 | - /** @var Member $canCreate */ |
|
| 26 | - $canCreate = $this->objFromFixture(Member::class, 'slide_author'); |
|
| 27 | - /** @var Member $canAdminister */ |
|
| 28 | - $canAdminister = $this->objFromFixture(Member::class, 'slide_admin'); |
|
| 29 | - /** @var Member $noPermission */ |
|
| 30 | - $noPermission = $this->objFromFixture(Member::class, 'slide_no_permission'); |
|
| 31 | - |
|
| 32 | - $this->logInAs($canCreate); |
|
| 33 | - $slide = Slide::singleton(); |
|
| 34 | - |
|
| 35 | - $this->assertTrue($slide->canCreate()); |
|
| 36 | - |
|
| 37 | - $this->logOut(); |
|
| 38 | - $this->logInAs($canAdminister); |
|
| 39 | - |
|
| 40 | - $this->assertTrue($slide->canCreate()); |
|
| 41 | - |
|
| 42 | - $this->logOut(); |
|
| 43 | - $this->logInAs($noPermission); |
|
| 44 | - |
|
| 45 | - $this->assertFalse($slide->canCreate()); |
|
| 46 | - $this->logOut(); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * |
|
| 51 | - */ |
|
| 52 | - public function testCanEdit() |
|
| 53 | - { |
|
| 54 | - /** @var Slide $slide */ |
|
| 55 | - $slide = $this->objFromFixture(Slide::class, 'base_slide'); |
|
| 56 | - /** @var Member $canCreate */ |
|
| 57 | - $canEdit = $this->objFromFixture(Member::class, 'slide_author'); |
|
| 58 | - /** @var Member $canAdminister */ |
|
| 59 | - $canAdminister = $this->objFromFixture(Member::class, 'slide_admin'); |
|
| 60 | - /** @var Member $noPermission */ |
|
| 61 | - $noPermission = $this->objFromFixture(Member::class, 'slide_no_permission'); |
|
| 62 | - |
|
| 63 | - $this->logInAs($canEdit); |
|
| 64 | - |
|
| 65 | - $this->assertTrue($slide->canEdit()); |
|
| 66 | - |
|
| 67 | - $this->logOut(); |
|
| 68 | - $this->logInAs($canAdminister); |
|
| 69 | - |
|
| 70 | - $this->assertTrue($slide->canEdit()); |
|
| 71 | - |
|
| 72 | - $this->logOut(); |
|
| 73 | - $this->logInAs($noPermission); |
|
| 74 | - |
|
| 75 | - $this->assertFalse($slide->canEdit()); |
|
| 76 | - $this->logOut(); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * |
|
| 81 | - */ |
|
| 82 | - public function testCanDelete() |
|
| 83 | - { |
|
| 84 | - /** @var Slide $slide */ |
|
| 85 | - $slide = $this->objFromFixture(Slide::class, 'base_slide'); |
|
| 86 | - /** @var Member $canCreate */ |
|
| 87 | - $noDelete = $this->objFromFixture(Member::class, 'slide_author'); |
|
| 88 | - /** @var Member $canAdminister */ |
|
| 89 | - $canAdminister = $this->objFromFixture(Member::class, 'slide_admin'); |
|
| 90 | - /** @var Member $noPermission */ |
|
| 91 | - $noPermission = $this->objFromFixture(Member::class, 'slide_no_permission'); |
|
| 92 | - |
|
| 93 | - $this->logInAs($noDelete); |
|
| 94 | - |
|
| 95 | - $this->assertFalse($slide->canDelete()); |
|
| 96 | - |
|
| 97 | - $this->logOut(); |
|
| 98 | - $this->logInAs($canAdminister); |
|
| 99 | - |
|
| 100 | - $this->assertTrue($slide->canDelete()); |
|
| 101 | - |
|
| 102 | - $this->logOut(); |
|
| 103 | - $this->logInAs($noPermission); |
|
| 104 | - |
|
| 105 | - $this->assertFalse($slide->canDelete()); |
|
| 106 | - $this->logOut(); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - public function testCanPublish() |
|
| 110 | - { |
|
| 111 | - /** @var Slide $slide */ |
|
| 112 | - $slide = $this->objFromFixture(Slide::class, 'base_slide'); |
|
| 113 | - /** @var Member $canCreate */ |
|
| 114 | - $noPublish = $this->objFromFixture(Member::class, 'slide_author'); |
|
| 115 | - /** @var Member $canAdminister */ |
|
| 116 | - $canAdminister = $this->objFromFixture(Member::class, 'slide_admin'); |
|
| 117 | - /** @var Member $noPermission */ |
|
| 118 | - $noPermission = $this->objFromFixture(Member::class, 'slide_no_permission'); |
|
| 119 | - |
|
| 120 | - $this->logInAs($noPublish); |
|
| 121 | - |
|
| 122 | - $this->assertFalse($slide->canPublish()); |
|
| 123 | - |
|
| 124 | - $this->logOut(); |
|
| 125 | - $this->logInAs($canAdminister); |
|
| 15 | + /** |
|
| 16 | + * @var string |
|
| 17 | + */ |
|
| 18 | + protected static $fixture_file = '../fixtures.yml'; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * |
|
| 22 | + */ |
|
| 23 | + public function testCanCreate() |
|
| 24 | + { |
|
| 25 | + /** @var Member $canCreate */ |
|
| 26 | + $canCreate = $this->objFromFixture(Member::class, 'slide_author'); |
|
| 27 | + /** @var Member $canAdminister */ |
|
| 28 | + $canAdminister = $this->objFromFixture(Member::class, 'slide_admin'); |
|
| 29 | + /** @var Member $noPermission */ |
|
| 30 | + $noPermission = $this->objFromFixture(Member::class, 'slide_no_permission'); |
|
| 31 | + |
|
| 32 | + $this->logInAs($canCreate); |
|
| 33 | + $slide = Slide::singleton(); |
|
| 34 | + |
|
| 35 | + $this->assertTrue($slide->canCreate()); |
|
| 36 | + |
|
| 37 | + $this->logOut(); |
|
| 38 | + $this->logInAs($canAdminister); |
|
| 39 | + |
|
| 40 | + $this->assertTrue($slide->canCreate()); |
|
| 41 | + |
|
| 42 | + $this->logOut(); |
|
| 43 | + $this->logInAs($noPermission); |
|
| 44 | + |
|
| 45 | + $this->assertFalse($slide->canCreate()); |
|
| 46 | + $this->logOut(); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * |
|
| 51 | + */ |
|
| 52 | + public function testCanEdit() |
|
| 53 | + { |
|
| 54 | + /** @var Slide $slide */ |
|
| 55 | + $slide = $this->objFromFixture(Slide::class, 'base_slide'); |
|
| 56 | + /** @var Member $canCreate */ |
|
| 57 | + $canEdit = $this->objFromFixture(Member::class, 'slide_author'); |
|
| 58 | + /** @var Member $canAdminister */ |
|
| 59 | + $canAdminister = $this->objFromFixture(Member::class, 'slide_admin'); |
|
| 60 | + /** @var Member $noPermission */ |
|
| 61 | + $noPermission = $this->objFromFixture(Member::class, 'slide_no_permission'); |
|
| 62 | + |
|
| 63 | + $this->logInAs($canEdit); |
|
| 64 | + |
|
| 65 | + $this->assertTrue($slide->canEdit()); |
|
| 66 | + |
|
| 67 | + $this->logOut(); |
|
| 68 | + $this->logInAs($canAdminister); |
|
| 69 | + |
|
| 70 | + $this->assertTrue($slide->canEdit()); |
|
| 71 | + |
|
| 72 | + $this->logOut(); |
|
| 73 | + $this->logInAs($noPermission); |
|
| 74 | + |
|
| 75 | + $this->assertFalse($slide->canEdit()); |
|
| 76 | + $this->logOut(); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * |
|
| 81 | + */ |
|
| 82 | + public function testCanDelete() |
|
| 83 | + { |
|
| 84 | + /** @var Slide $slide */ |
|
| 85 | + $slide = $this->objFromFixture(Slide::class, 'base_slide'); |
|
| 86 | + /** @var Member $canCreate */ |
|
| 87 | + $noDelete = $this->objFromFixture(Member::class, 'slide_author'); |
|
| 88 | + /** @var Member $canAdminister */ |
|
| 89 | + $canAdminister = $this->objFromFixture(Member::class, 'slide_admin'); |
|
| 90 | + /** @var Member $noPermission */ |
|
| 91 | + $noPermission = $this->objFromFixture(Member::class, 'slide_no_permission'); |
|
| 92 | + |
|
| 93 | + $this->logInAs($noDelete); |
|
| 94 | + |
|
| 95 | + $this->assertFalse($slide->canDelete()); |
|
| 96 | + |
|
| 97 | + $this->logOut(); |
|
| 98 | + $this->logInAs($canAdminister); |
|
| 99 | + |
|
| 100 | + $this->assertTrue($slide->canDelete()); |
|
| 101 | + |
|
| 102 | + $this->logOut(); |
|
| 103 | + $this->logInAs($noPermission); |
|
| 104 | + |
|
| 105 | + $this->assertFalse($slide->canDelete()); |
|
| 106 | + $this->logOut(); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + public function testCanPublish() |
|
| 110 | + { |
|
| 111 | + /** @var Slide $slide */ |
|
| 112 | + $slide = $this->objFromFixture(Slide::class, 'base_slide'); |
|
| 113 | + /** @var Member $canCreate */ |
|
| 114 | + $noPublish = $this->objFromFixture(Member::class, 'slide_author'); |
|
| 115 | + /** @var Member $canAdminister */ |
|
| 116 | + $canAdminister = $this->objFromFixture(Member::class, 'slide_admin'); |
|
| 117 | + /** @var Member $noPermission */ |
|
| 118 | + $noPermission = $this->objFromFixture(Member::class, 'slide_no_permission'); |
|
| 119 | + |
|
| 120 | + $this->logInAs($noPublish); |
|
| 121 | + |
|
| 122 | + $this->assertFalse($slide->canPublish()); |
|
| 123 | + |
|
| 124 | + $this->logOut(); |
|
| 125 | + $this->logInAs($canAdminister); |
|
| 126 | 126 | |
| 127 | - $this->assertTrue($slide->canPublish()); |
|
| 127 | + $this->assertTrue($slide->canPublish()); |
|
| 128 | 128 | |
| 129 | - $this->logOut(); |
|
| 130 | - $this->logInAs($noPermission); |
|
| 129 | + $this->logOut(); |
|
| 130 | + $this->logInAs($noPermission); |
|
| 131 | 131 | |
| 132 | - $this->assertFalse($slide->canPublish()); |
|
| 133 | - $this->logOut(); |
|
| 134 | - } |
|
| 132 | + $this->assertFalse($slide->canPublish()); |
|
| 133 | + $this->logOut(); |
|
| 134 | + } |
|
| 135 | 135 | } |
@@ -43,199 +43,199 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | class FlexSlider extends DataExtension |
| 45 | 45 | { |
| 46 | - use Configurable; |
|
| 46 | + use Configurable; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var array |
|
| 50 | - */ |
|
| 51 | - private static $db = [ |
|
| 52 | - 'Animation' => "Enum('slide, fade', 'slide')", |
|
| 53 | - 'Loop' => 'Boolean', |
|
| 54 | - 'Animate' => 'Boolean', |
|
| 55 | - 'ThumbnailNav' => 'Boolean', |
|
| 56 | - 'SliderControlNav' => 'Boolean', |
|
| 57 | - 'SliderDirectionNav' => 'Boolean', |
|
| 58 | - 'CarouselControlNav' => 'Boolean', |
|
| 59 | - 'CarouselDirectionNav' => 'Boolean', |
|
| 60 | - 'CarouselThumbnailCt' => 'Int', |
|
| 61 | - 'FlexSliderSpeed' => 'Double', |
|
| 62 | - ]; |
|
| 48 | + /** |
|
| 49 | + * @var array |
|
| 50 | + */ |
|
| 51 | + private static $db = [ |
|
| 52 | + 'Animation' => "Enum('slide, fade', 'slide')", |
|
| 53 | + 'Loop' => 'Boolean', |
|
| 54 | + 'Animate' => 'Boolean', |
|
| 55 | + 'ThumbnailNav' => 'Boolean', |
|
| 56 | + 'SliderControlNav' => 'Boolean', |
|
| 57 | + 'SliderDirectionNav' => 'Boolean', |
|
| 58 | + 'CarouselControlNav' => 'Boolean', |
|
| 59 | + 'CarouselDirectionNav' => 'Boolean', |
|
| 60 | + 'CarouselThumbnailCt' => 'Int', |
|
| 61 | + 'FlexSliderSpeed' => 'Double', |
|
| 62 | + ]; |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @var array |
|
| 66 | - */ |
|
| 67 | - private static $has_many = [ |
|
| 68 | - 'Slides' => Slide::class, |
|
| 69 | - ]; |
|
| 64 | + /** |
|
| 65 | + * @var array |
|
| 66 | + */ |
|
| 67 | + private static $has_many = [ |
|
| 68 | + 'Slides' => Slide::class, |
|
| 69 | + ]; |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * |
|
| 73 | - */ |
|
| 74 | - public function populateDefaults() |
|
| 75 | - { |
|
| 76 | - $this->owner->Loop = 1; |
|
| 77 | - $this->owner->Animate = 1; |
|
| 78 | - $this->owner->SliderControlNav = 0; |
|
| 79 | - $this->owner->SliderDirectionNav = 1; |
|
| 80 | - $this->owner->CarouselControlNav = 0; |
|
| 81 | - $this->owner->CarouselDirectionNav = 1; |
|
| 82 | - $this->owner->CarouselThumbnailCt = 6; |
|
| 83 | - $this->owner->FlexSliderSpeed = $this->getDefaultSpeed(); |
|
| 71 | + /** |
|
| 72 | + * |
|
| 73 | + */ |
|
| 74 | + public function populateDefaults() |
|
| 75 | + { |
|
| 76 | + $this->owner->Loop = 1; |
|
| 77 | + $this->owner->Animate = 1; |
|
| 78 | + $this->owner->SliderControlNav = 0; |
|
| 79 | + $this->owner->SliderDirectionNav = 1; |
|
| 80 | + $this->owner->CarouselControlNav = 0; |
|
| 81 | + $this->owner->CarouselDirectionNav = 1; |
|
| 82 | + $this->owner->CarouselThumbnailCt = 6; |
|
| 83 | + $this->owner->FlexSliderSpeed = $this->getDefaultSpeed(); |
|
| 84 | 84 | |
| 85 | - return parent::populateDefaults(); |
|
| 86 | - } |
|
| 85 | + return parent::populateDefaults(); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * @param FieldList $fields |
|
| 90 | - * @throws \ReflectionException |
|
| 91 | - */ |
|
| 92 | - public function updateCMSFields(FieldList $fields) |
|
| 93 | - { |
|
| 94 | - $fields->removeByName([ |
|
| 95 | - 'Animation', |
|
| 96 | - 'Loop', |
|
| 97 | - 'Animate', |
|
| 98 | - 'ThumbnailNav', |
|
| 99 | - 'SliderControlNav', |
|
| 100 | - 'SliderDirectionNav', |
|
| 101 | - 'CarouselControlNav', |
|
| 102 | - 'CarouselDirectionNav', |
|
| 103 | - 'CarouselThumbnailCt', |
|
| 104 | - 'FlexSliderSpeed', |
|
| 105 | - 'Slides', |
|
| 106 | - ]); |
|
| 88 | + /** |
|
| 89 | + * @param FieldList $fields |
|
| 90 | + * @throws \ReflectionException |
|
| 91 | + */ |
|
| 92 | + public function updateCMSFields(FieldList $fields) |
|
| 93 | + { |
|
| 94 | + $fields->removeByName([ |
|
| 95 | + 'Animation', |
|
| 96 | + 'Loop', |
|
| 97 | + 'Animate', |
|
| 98 | + 'ThumbnailNav', |
|
| 99 | + 'SliderControlNav', |
|
| 100 | + 'SliderDirectionNav', |
|
| 101 | + 'CarouselControlNav', |
|
| 102 | + 'CarouselDirectionNav', |
|
| 103 | + 'CarouselThumbnailCt', |
|
| 104 | + 'FlexSliderSpeed', |
|
| 105 | + 'Slides', |
|
| 106 | + ]); |
|
| 107 | 107 | |
| 108 | - // Slides |
|
| 109 | - if ($this->owner->ID) { |
|
| 110 | - $availableSlides = []; |
|
| 111 | - foreach (ClassInfo::subclassesFor(Slide::class, false) as $class) { |
|
| 112 | - $availableSlides[$class] = $class::singleton()->i18n_singular_name(); |
|
| 113 | - }; |
|
| 108 | + // Slides |
|
| 109 | + if ($this->owner->ID) { |
|
| 110 | + $availableSlides = []; |
|
| 111 | + foreach (ClassInfo::subclassesFor(Slide::class, false) as $class) { |
|
| 112 | + $availableSlides[$class] = $class::singleton()->i18n_singular_name(); |
|
| 113 | + }; |
|
| 114 | 114 | |
| 115 | - $config = GridFieldConfig_RecordEditor::create(); |
|
| 116 | - $config->addComponent(new GridFieldOrderableRows('SortOrder')); |
|
| 117 | - $config->removeComponentsByType([ |
|
| 118 | - GridFieldAddExistingAutocompleter::class, |
|
| 119 | - GridFieldDeleteAction::class, |
|
| 120 | - GridFieldAddNewButton::class, |
|
| 121 | - ])->addComponent($multiClass = new GridFieldAddNewMultiClass()); |
|
| 115 | + $config = GridFieldConfig_RecordEditor::create(); |
|
| 116 | + $config->addComponent(new GridFieldOrderableRows('SortOrder')); |
|
| 117 | + $config->removeComponentsByType([ |
|
| 118 | + GridFieldAddExistingAutocompleter::class, |
|
| 119 | + GridFieldDeleteAction::class, |
|
| 120 | + GridFieldAddNewButton::class, |
|
| 121 | + ])->addComponent($multiClass = new GridFieldAddNewMultiClass()); |
|
| 122 | 122 | |
| 123 | - $multiClass->setClasses($availableSlides); |
|
| 123 | + $multiClass->setClasses($availableSlides); |
|
| 124 | 124 | |
| 125 | - $SlidesField = GridField::create( |
|
| 126 | - 'Slides', |
|
| 127 | - _t(__CLASS__ . '.SLIDES', 'Slides'), |
|
| 128 | - $this->owner->Slides()->sort('SortOrder'), |
|
| 129 | - $config |
|
| 130 | - ); |
|
| 125 | + $SlidesField = GridField::create( |
|
| 126 | + 'Slides', |
|
| 127 | + _t(__CLASS__ . '.SLIDES', 'Slides'), |
|
| 128 | + $this->owner->Slides()->sort('SortOrder'), |
|
| 129 | + $config |
|
| 130 | + ); |
|
| 131 | 131 | |
| 132 | - $slideTitle = $this->owner->stat('slide_tab_title') ?: _t(__CLASS__ . '.SLIDES', 'Slides'); |
|
| 132 | + $slideTitle = $this->owner->stat('slide_tab_title') ?: _t(__CLASS__ . '.SLIDES', 'Slides'); |
|
| 133 | 133 | |
| 134 | - $animations = []; |
|
| 135 | - $animationOptions = $this->owner->dbObject('Animation')->getEnum(); |
|
| 136 | - foreach ($animationOptions as $value) { |
|
| 137 | - $animations[$value] = _t(__CLASS__ . ".$value", $value); |
|
| 138 | - } |
|
| 134 | + $animations = []; |
|
| 135 | + $animationOptions = $this->owner->dbObject('Animation')->getEnum(); |
|
| 136 | + foreach ($animationOptions as $value) { |
|
| 137 | + $animations[$value] = _t(__CLASS__ . ".$value", $value); |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - $fields->addFieldsToTab("Root.{$slideTitle}", [ |
|
| 141 | - $SlidesField, |
|
| 142 | - ToggleCompositeField::create('ConfigHD', _t(__CLASS__ . '.SettingsLabel', 'Slider Settings'), [ |
|
| 143 | - DropdownField::create( |
|
| 144 | - 'Animation', |
|
| 145 | - _t(__CLASS__ . '.ANIMATION_OPTION', 'Animation option'), |
|
| 146 | - $animations |
|
| 147 | - ), |
|
| 148 | - CheckboxField::create( |
|
| 149 | - 'Animate', |
|
| 150 | - _t(__CLASS__ . '.ANIMATE', 'Animate automatically') |
|
| 151 | - ), |
|
| 152 | - CheckboxField::create( |
|
| 153 | - 'Loop', |
|
| 154 | - _t(__CLASS__ . '.LOOP', 'Loop the carousel') |
|
| 155 | - ), |
|
| 156 | - CheckboxField::create( |
|
| 157 | - 'SliderControlNav', |
|
| 158 | - _t(__CLASS__ . '.CONTROL_NAV', 'Show ControlNav') |
|
| 159 | - ), |
|
| 160 | - CheckboxField::create( |
|
| 161 | - 'SliderDirectionNav', |
|
| 162 | - _t(__CLASS__ . '.DIRECTION_NAV', 'Show DirectionNav') |
|
| 163 | - ), |
|
| 164 | - CheckboxField::create( |
|
| 165 | - 'ThumbnailNav', |
|
| 166 | - _t(__CLASS__ . '.THUMBNAIL_NAV', 'Thumbnail Navigation') |
|
| 167 | - ), |
|
| 168 | - //DisplayLogicWrapper::create( |
|
| 169 | - CheckboxField::create( |
|
| 170 | - 'CarouselControlNav', |
|
| 171 | - _t(__CLASS__ . '.CAROUSEL_CONTROL_NAV', 'Show Carousel ControlNav') |
|
| 172 | - ), |
|
| 173 | - CheckboxField::create( |
|
| 174 | - 'CarouselDirectionNav', |
|
| 175 | - _t(__CLASS__ . '.CAROUSEL_DIRECTION_NAV', 'Show Carousel DirectionNav') |
|
| 176 | - ), |
|
| 177 | - NumericField::create( |
|
| 178 | - 'CarouselThumbnailCt', |
|
| 179 | - _t(__CLASS__ . '.CAROUSEL_THUMBNAIL_COUNT', 'Number of thumbnails') |
|
| 180 | - ), |
|
| 181 | - NumericField::create( |
|
| 182 | - 'FlexSliderSpeed', |
|
| 183 | - _t(__CLASS__ . '.SLIDER_SPEED', 'Slider Speed') |
|
| 184 | - ) |
|
| 185 | - ->setDescription('In Seconds') |
|
| 186 | - ->setScale(2), |
|
| 187 | - ]), |
|
| 188 | - ]); |
|
| 189 | - } |
|
| 190 | - } |
|
| 140 | + $fields->addFieldsToTab("Root.{$slideTitle}", [ |
|
| 141 | + $SlidesField, |
|
| 142 | + ToggleCompositeField::create('ConfigHD', _t(__CLASS__ . '.SettingsLabel', 'Slider Settings'), [ |
|
| 143 | + DropdownField::create( |
|
| 144 | + 'Animation', |
|
| 145 | + _t(__CLASS__ . '.ANIMATION_OPTION', 'Animation option'), |
|
| 146 | + $animations |
|
| 147 | + ), |
|
| 148 | + CheckboxField::create( |
|
| 149 | + 'Animate', |
|
| 150 | + _t(__CLASS__ . '.ANIMATE', 'Animate automatically') |
|
| 151 | + ), |
|
| 152 | + CheckboxField::create( |
|
| 153 | + 'Loop', |
|
| 154 | + _t(__CLASS__ . '.LOOP', 'Loop the carousel') |
|
| 155 | + ), |
|
| 156 | + CheckboxField::create( |
|
| 157 | + 'SliderControlNav', |
|
| 158 | + _t(__CLASS__ . '.CONTROL_NAV', 'Show ControlNav') |
|
| 159 | + ), |
|
| 160 | + CheckboxField::create( |
|
| 161 | + 'SliderDirectionNav', |
|
| 162 | + _t(__CLASS__ . '.DIRECTION_NAV', 'Show DirectionNav') |
|
| 163 | + ), |
|
| 164 | + CheckboxField::create( |
|
| 165 | + 'ThumbnailNav', |
|
| 166 | + _t(__CLASS__ . '.THUMBNAIL_NAV', 'Thumbnail Navigation') |
|
| 167 | + ), |
|
| 168 | + //DisplayLogicWrapper::create( |
|
| 169 | + CheckboxField::create( |
|
| 170 | + 'CarouselControlNav', |
|
| 171 | + _t(__CLASS__ . '.CAROUSEL_CONTROL_NAV', 'Show Carousel ControlNav') |
|
| 172 | + ), |
|
| 173 | + CheckboxField::create( |
|
| 174 | + 'CarouselDirectionNav', |
|
| 175 | + _t(__CLASS__ . '.CAROUSEL_DIRECTION_NAV', 'Show Carousel DirectionNav') |
|
| 176 | + ), |
|
| 177 | + NumericField::create( |
|
| 178 | + 'CarouselThumbnailCt', |
|
| 179 | + _t(__CLASS__ . '.CAROUSEL_THUMBNAIL_COUNT', 'Number of thumbnails') |
|
| 180 | + ), |
|
| 181 | + NumericField::create( |
|
| 182 | + 'FlexSliderSpeed', |
|
| 183 | + _t(__CLASS__ . '.SLIDER_SPEED', 'Slider Speed') |
|
| 184 | + ) |
|
| 185 | + ->setDescription('In Seconds') |
|
| 186 | + ->setScale(2), |
|
| 187 | + ]), |
|
| 188 | + ]); |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * @return mixed |
|
| 194 | - */ |
|
| 195 | - public function getSlideShow() |
|
| 196 | - { |
|
| 197 | - $owner = $this->owner; |
|
| 192 | + /** |
|
| 193 | + * @return mixed |
|
| 194 | + */ |
|
| 195 | + public function getSlideShow() |
|
| 196 | + { |
|
| 197 | + $owner = $this->owner; |
|
| 198 | 198 | |
| 199 | - if (!($owner instanceof SiteTree)) { |
|
| 200 | - $this->getCustomScript(); |
|
| 201 | - } |
|
| 199 | + if (!($owner instanceof SiteTree)) { |
|
| 200 | + $this->getCustomScript(); |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - return $this->owner->Slides()->sort('SortOrder'); |
|
| 204 | - } |
|
| 203 | + return $this->owner->Slides()->sort('SortOrder'); |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - /** |
|
| 207 | - * add requirements to PageController init() |
|
| 208 | - */ |
|
| 209 | - public function contentcontrollerInit() |
|
| 210 | - { |
|
| 211 | - // only call custom script if page has Slides and DataExtension |
|
| 212 | - if (DataObject::has_extension($this->owner->Classname, FlexSlider::class)) { |
|
| 213 | - if ($this->owner->getSlideShow()->exists()) { |
|
| 214 | - $this->getCustomScript(); |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - } |
|
| 206 | + /** |
|
| 207 | + * add requirements to PageController init() |
|
| 208 | + */ |
|
| 209 | + public function contentcontrollerInit() |
|
| 210 | + { |
|
| 211 | + // only call custom script if page has Slides and DataExtension |
|
| 212 | + if (DataObject::has_extension($this->owner->Classname, FlexSlider::class)) { |
|
| 213 | + if ($this->owner->getSlideShow()->exists()) { |
|
| 214 | + $this->getCustomScript(); |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - /** |
|
| 220 | - * |
|
| 221 | - */ |
|
| 222 | - public function getCustomScript() |
|
| 223 | - { |
|
| 224 | - // Flexslider options |
|
| 225 | - $sync = ($this->owner->ThumbnailNav == true) ? "sync: '.fs-carousel:eq('+index+')'," : ''; |
|
| 219 | + /** |
|
| 220 | + * |
|
| 221 | + */ |
|
| 222 | + public function getCustomScript() |
|
| 223 | + { |
|
| 224 | + // Flexslider options |
|
| 225 | + $sync = ($this->owner->ThumbnailNav == true) ? "sync: '.fs-carousel:eq('+index+')'," : ''; |
|
| 226 | 226 | |
| 227 | - $before = $this->owner->hasMethod('flexSliderBeforeAction') |
|
| 228 | - ? $this->owner->flexSliderBeforeAction() |
|
| 229 | - : 'function(){}'; |
|
| 227 | + $before = $this->owner->hasMethod('flexSliderBeforeAction') |
|
| 228 | + ? $this->owner->flexSliderBeforeAction() |
|
| 229 | + : 'function(){}'; |
|
| 230 | 230 | |
| 231 | - $after = $this->owner->hasMethod('flexSliderAfterAction') |
|
| 232 | - ? $this->owner->flexSliderAfterAction() |
|
| 233 | - : 'function(){}'; |
|
| 231 | + $after = $this->owner->hasMethod('flexSliderAfterAction') |
|
| 232 | + ? $this->owner->flexSliderAfterAction() |
|
| 233 | + : 'function(){}'; |
|
| 234 | 234 | |
| 235 | - $speed = $this->getSlideshowSpeed(); |
|
| 235 | + $speed = $this->getSlideshowSpeed(); |
|
| 236 | 236 | |
| 237 | - Requirements::customScript( |
|
| 238 | - "(function($) { |
|
| 237 | + Requirements::customScript( |
|
| 238 | + "(function($) { |
|
| 239 | 239 | $(document).ready(function(){ |
| 240 | 240 | jQuery('.flexslider').each(function(index){ |
| 241 | 241 | |
@@ -281,39 +281,39 @@ discard block |
||
| 281 | 281 | }) |
| 282 | 282 | }); |
| 283 | 283 | }(jQuery));' |
| 284 | - ); |
|
| 285 | - } |
|
| 284 | + ); |
|
| 285 | + } |
|
| 286 | 286 | |
| 287 | - /** |
|
| 288 | - * @return int |
|
| 289 | - */ |
|
| 290 | - public function getSlideshowSpeed() |
|
| 291 | - { |
|
| 292 | - $speed = $this->owner->FlexSliderSpeed > 0 |
|
| 293 | - ? $this->owner->FlexSliderSpeed |
|
| 294 | - : $this->getDefaultSpeed(); |
|
| 287 | + /** |
|
| 288 | + * @return int |
|
| 289 | + */ |
|
| 290 | + public function getSlideshowSpeed() |
|
| 291 | + { |
|
| 292 | + $speed = $this->owner->FlexSliderSpeed > 0 |
|
| 293 | + ? $this->owner->FlexSliderSpeed |
|
| 294 | + : $this->getDefaultSpeed(); |
|
| 295 | 295 | |
| 296 | - return $speed * 1000; |
|
| 297 | - } |
|
| 296 | + return $speed * 1000; |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | - /** |
|
| 300 | - * @return mixed |
|
| 301 | - */ |
|
| 302 | - protected function getDefaultSpeed() |
|
| 303 | - { |
|
| 304 | - return $this->owner->config()->get('flex_slider_speed') |
|
| 305 | - ?: Config::inst()->get(FlexSlider::class, 'flex_slider_speed'); |
|
| 306 | - } |
|
| 299 | + /** |
|
| 300 | + * @return mixed |
|
| 301 | + */ |
|
| 302 | + protected function getDefaultSpeed() |
|
| 303 | + { |
|
| 304 | + return $this->owner->config()->get('flex_slider_speed') |
|
| 305 | + ?: Config::inst()->get(FlexSlider::class, 'flex_slider_speed'); |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - /** |
|
| 309 | - * |
|
| 310 | - */ |
|
| 311 | - public function onBeforeWrite() |
|
| 312 | - { |
|
| 313 | - parent::onBeforeWrite(); |
|
| 308 | + /** |
|
| 309 | + * |
|
| 310 | + */ |
|
| 311 | + public function onBeforeWrite() |
|
| 312 | + { |
|
| 313 | + parent::onBeforeWrite(); |
|
| 314 | 314 | |
| 315 | - if (!$this->owner->CarouselThumbnailCt) { |
|
| 316 | - $this->owner->CarouselThumbnailCt = 6; |
|
| 317 | - } |
|
| 318 | - } |
|
| 315 | + if (!$this->owner->CarouselThumbnailCt) { |
|
| 316 | + $this->owner->CarouselThumbnailCt = 6; |
|
| 317 | + } |
|
| 318 | + } |
|
| 319 | 319 | } |
@@ -124,63 +124,63 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $SlidesField = GridField::create( |
| 126 | 126 | 'Slides', |
| 127 | - _t(__CLASS__ . '.SLIDES', 'Slides'), |
|
| 127 | + _t(__CLASS__.'.SLIDES', 'Slides'), |
|
| 128 | 128 | $this->owner->Slides()->sort('SortOrder'), |
| 129 | 129 | $config |
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | - $slideTitle = $this->owner->stat('slide_tab_title') ?: _t(__CLASS__ . '.SLIDES', 'Slides'); |
|
| 132 | + $slideTitle = $this->owner->stat('slide_tab_title') ?: _t(__CLASS__.'.SLIDES', 'Slides'); |
|
| 133 | 133 | |
| 134 | 134 | $animations = []; |
| 135 | 135 | $animationOptions = $this->owner->dbObject('Animation')->getEnum(); |
| 136 | 136 | foreach ($animationOptions as $value) { |
| 137 | - $animations[$value] = _t(__CLASS__ . ".$value", $value); |
|
| 137 | + $animations[$value] = _t(__CLASS__.".$value", $value); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | $fields->addFieldsToTab("Root.{$slideTitle}", [ |
| 141 | 141 | $SlidesField, |
| 142 | - ToggleCompositeField::create('ConfigHD', _t(__CLASS__ . '.SettingsLabel', 'Slider Settings'), [ |
|
| 142 | + ToggleCompositeField::create('ConfigHD', _t(__CLASS__.'.SettingsLabel', 'Slider Settings'), [ |
|
| 143 | 143 | DropdownField::create( |
| 144 | 144 | 'Animation', |
| 145 | - _t(__CLASS__ . '.ANIMATION_OPTION', 'Animation option'), |
|
| 145 | + _t(__CLASS__.'.ANIMATION_OPTION', 'Animation option'), |
|
| 146 | 146 | $animations |
| 147 | 147 | ), |
| 148 | 148 | CheckboxField::create( |
| 149 | 149 | 'Animate', |
| 150 | - _t(__CLASS__ . '.ANIMATE', 'Animate automatically') |
|
| 150 | + _t(__CLASS__.'.ANIMATE', 'Animate automatically') |
|
| 151 | 151 | ), |
| 152 | 152 | CheckboxField::create( |
| 153 | 153 | 'Loop', |
| 154 | - _t(__CLASS__ . '.LOOP', 'Loop the carousel') |
|
| 154 | + _t(__CLASS__.'.LOOP', 'Loop the carousel') |
|
| 155 | 155 | ), |
| 156 | 156 | CheckboxField::create( |
| 157 | 157 | 'SliderControlNav', |
| 158 | - _t(__CLASS__ . '.CONTROL_NAV', 'Show ControlNav') |
|
| 158 | + _t(__CLASS__.'.CONTROL_NAV', 'Show ControlNav') |
|
| 159 | 159 | ), |
| 160 | 160 | CheckboxField::create( |
| 161 | 161 | 'SliderDirectionNav', |
| 162 | - _t(__CLASS__ . '.DIRECTION_NAV', 'Show DirectionNav') |
|
| 162 | + _t(__CLASS__.'.DIRECTION_NAV', 'Show DirectionNav') |
|
| 163 | 163 | ), |
| 164 | 164 | CheckboxField::create( |
| 165 | 165 | 'ThumbnailNav', |
| 166 | - _t(__CLASS__ . '.THUMBNAIL_NAV', 'Thumbnail Navigation') |
|
| 166 | + _t(__CLASS__.'.THUMBNAIL_NAV', 'Thumbnail Navigation') |
|
| 167 | 167 | ), |
| 168 | 168 | //DisplayLogicWrapper::create( |
| 169 | 169 | CheckboxField::create( |
| 170 | 170 | 'CarouselControlNav', |
| 171 | - _t(__CLASS__ . '.CAROUSEL_CONTROL_NAV', 'Show Carousel ControlNav') |
|
| 171 | + _t(__CLASS__.'.CAROUSEL_CONTROL_NAV', 'Show Carousel ControlNav') |
|
| 172 | 172 | ), |
| 173 | 173 | CheckboxField::create( |
| 174 | 174 | 'CarouselDirectionNav', |
| 175 | - _t(__CLASS__ . '.CAROUSEL_DIRECTION_NAV', 'Show Carousel DirectionNav') |
|
| 175 | + _t(__CLASS__.'.CAROUSEL_DIRECTION_NAV', 'Show Carousel DirectionNav') |
|
| 176 | 176 | ), |
| 177 | 177 | NumericField::create( |
| 178 | 178 | 'CarouselThumbnailCt', |
| 179 | - _t(__CLASS__ . '.CAROUSEL_THUMBNAIL_COUNT', 'Number of thumbnails') |
|
| 179 | + _t(__CLASS__.'.CAROUSEL_THUMBNAIL_COUNT', 'Number of thumbnails') |
|
| 180 | 180 | ), |
| 181 | 181 | NumericField::create( |
| 182 | 182 | 'FlexSliderSpeed', |
| 183 | - _t(__CLASS__ . '.SLIDER_SPEED', 'Slider Speed') |
|
| 183 | + _t(__CLASS__.'.SLIDER_SPEED', 'Slider Speed') |
|
| 184 | 184 | ) |
| 185 | 185 | ->setDescription('In Seconds') |
| 186 | 186 | ->setScale(2), |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | public function getCustomScript() |
| 223 | 223 | { |
| 224 | 224 | // Flexslider options |
| 225 | - $sync = ($this->owner->ThumbnailNav == true) ? "sync: '.fs-carousel:eq('+index+')'," : ''; |
|
| 225 | + $sync = ($this->owner->ThumbnailNav==true) ? "sync: '.fs-carousel:eq('+index+')'," : ''; |
|
| 226 | 226 | |
| 227 | 227 | $before = $this->owner->hasMethod('flexSliderBeforeAction') |
| 228 | 228 | ? $this->owner->flexSliderBeforeAction() |
@@ -241,18 +241,18 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | if(jQuery('.fs-carousel').eq(index).length) { |
| 243 | 243 | jQuery('.fs-carousel').eq(index).flexslider({ |
| 244 | - slideshow: " . $this->owner->obj('Animate')->NiceAsBoolean() . ", |
|
| 244 | + slideshow: " . $this->owner->obj('Animate')->NiceAsBoolean().", |
|
| 245 | 245 | animation: 'slide', |
| 246 | - animationLoop: " . $this->owner->obj('Loop')->NiceAsBoolean() . ", |
|
| 247 | - controlNav: " . $this->owner->obj('CarouselControlNav')->NiceAsBoolean() . ", |
|
| 248 | - directionNav: " . $this->owner->obj('CarouselDirectionNav')->NiceAsBoolean() . ", |
|
| 246 | + animationLoop: " . $this->owner->obj('Loop')->NiceAsBoolean().", |
|
| 247 | + controlNav: " . $this->owner->obj('CarouselControlNav')->NiceAsBoolean().", |
|
| 248 | + directionNav: " . $this->owner->obj('CarouselDirectionNav')->NiceAsBoolean().", |
|
| 249 | 249 | prevText: '', |
| 250 | 250 | nextText: '', |
| 251 | 251 | pausePlay: false, |
| 252 | 252 | asNavFor: '.flexslider:eq('+index+')', |
| 253 | - minItems: " . $this->owner->obj('CarouselThumbnailCt') . ", |
|
| 254 | - maxItems: " . $this->owner->obj('CarouselThumbnailCt') . ", |
|
| 255 | - move: " . $this->owner->obj('CarouselThumbnailCt') . ", |
|
| 253 | + minItems: " . $this->owner->obj('CarouselThumbnailCt').", |
|
| 254 | + maxItems: " . $this->owner->obj('CarouselThumbnailCt').", |
|
| 255 | + move: " . $this->owner->obj('CarouselThumbnailCt').", |
|
| 256 | 256 | itemWidth: 100, |
| 257 | 257 | itemMargin: 10 |
| 258 | 258 | }); |
@@ -260,22 +260,22 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | if(jQuery('.flexslider').eq(index).length){ |
| 262 | 262 | jQuery('.flexslider').eq(index).flexslider({ |
| 263 | - slideshow: " . $this->owner->obj('Animate')->NiceAsBoolean() . ", |
|
| 264 | - animation: '" . $this->owner->Animation . "', |
|
| 265 | - animationLoop: " . $this->owner->obj('Loop')->NiceAsBoolean() . ", |
|
| 266 | - controlNav: " . $this->owner->obj('SliderControlNav')->NiceAsBoolean() . ", |
|
| 267 | - directionNav: " . $this->owner->obj('SliderDirectionNav')->NiceAsBoolean() . ", |
|
| 263 | + slideshow: " . $this->owner->obj('Animate')->NiceAsBoolean().", |
|
| 264 | + animation: '" . $this->owner->Animation."', |
|
| 265 | + animationLoop: " . $this->owner->obj('Loop')->NiceAsBoolean().", |
|
| 266 | + controlNav: " . $this->owner->obj('SliderControlNav')->NiceAsBoolean().", |
|
| 267 | + directionNav: " . $this->owner->obj('SliderDirectionNav')->NiceAsBoolean().", |
|
| 268 | 268 | prevText: '', |
| 269 | 269 | nextText: '', |
| 270 | 270 | pauseOnAction: true, |
| 271 | 271 | pauseOnHover: true, |
| 272 | - " . $sync . " |
|
| 272 | + " . $sync." |
|
| 273 | 273 | start: function(slider){ |
| 274 | 274 | $('body').removeClass('loading'); |
| 275 | 275 | }, |
| 276 | - before: " . $before . ', |
|
| 277 | - after: ' . $after . ', |
|
| 278 | - slideshowSpeed: ' . $speed . ' |
|
| 276 | + before: " . $before.', |
|
| 277 | + after: ' . $after.', |
|
| 278 | + slideshowSpeed: ' . $speed.' |
|
| 279 | 279 | }); |
| 280 | 280 | } |
| 281 | 281 | }) |
@@ -14,42 +14,42 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class VideoEmbedSlide extends Slide |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 20 | - private static $singular_name = 'Video Embed Slide'; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - private static $plural_name = 'Video Embed Slides'; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @var string |
|
| 29 | - */ |
|
| 30 | - private static $table_name = 'VideoEmbedSlide'; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @var array |
|
| 34 | - */ |
|
| 35 | - private static $has_one = [ |
|
| 36 | - 'Video' => EmbeddedObject::class, |
|
| 37 | - ]; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @return FieldList |
|
| 41 | - */ |
|
| 42 | - public function getCMSFields() |
|
| 43 | - { |
|
| 44 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 45 | - $fields->removeByName(['VideoID']); |
|
| 46 | - $fields->addFieldToTab( |
|
| 47 | - 'Root.Main', |
|
| 48 | - EmbeddedObjectField::create('Video', 'Video', $this->Video()), |
|
| 49 | - 'Content' |
|
| 50 | - ); |
|
| 51 | - }); |
|
| 52 | - |
|
| 53 | - return parent::getCMSFields(); |
|
| 54 | - } |
|
| 17 | + /** |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | + private static $singular_name = 'Video Embed Slide'; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + private static $plural_name = 'Video Embed Slides'; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @var string |
|
| 29 | + */ |
|
| 30 | + private static $table_name = 'VideoEmbedSlide'; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @var array |
|
| 34 | + */ |
|
| 35 | + private static $has_one = [ |
|
| 36 | + 'Video' => EmbeddedObject::class, |
|
| 37 | + ]; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @return FieldList |
|
| 41 | + */ |
|
| 42 | + public function getCMSFields() |
|
| 43 | + { |
|
| 44 | + $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 45 | + $fields->removeByName(['VideoID']); |
|
| 46 | + $fields->addFieldToTab( |
|
| 47 | + 'Root.Main', |
|
| 48 | + EmbeddedObjectField::create('Video', 'Video', $this->Video()), |
|
| 49 | + 'Content' |
|
| 50 | + ); |
|
| 51 | + }); |
|
| 52 | + |
|
| 53 | + return parent::getCMSFields(); |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | public function getCMSFields() |
| 43 | 43 | { |
| 44 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 44 | + $this->beforeUpdateCMSFields(function(FieldList $fields) { |
|
| 45 | 45 | $fields->removeByName(['VideoID']); |
| 46 | 46 | $fields->addFieldToTab( |
| 47 | 47 | 'Root.Main', |
@@ -12,51 +12,51 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class VideoSlide extends Slide |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @var string |
|
| 17 | - */ |
|
| 18 | - private static $singular_name = 'Video Slide'; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - private static $plural_name = 'Video Slides'; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - private static $table_name = 'VideoSlide'; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var array |
|
| 32 | - */ |
|
| 33 | - private static $has_one = [ |
|
| 34 | - 'Video' => File::class, |
|
| 35 | - ]; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @var array |
|
| 39 | - */ |
|
| 40 | - private static $owns = [ |
|
| 41 | - 'Video', |
|
| 42 | - ]; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @return FieldList |
|
| 46 | - */ |
|
| 47 | - public function getCMSFields() |
|
| 48 | - { |
|
| 49 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 50 | - $fields->addFieldToTab( |
|
| 51 | - 'Root.Main', |
|
| 52 | - UploadField::create('Video') |
|
| 53 | - ->setTitle('Video') |
|
| 54 | - ->setDescription('mp4 format') |
|
| 55 | - ->setAllowedExtensions(['mp4']), |
|
| 56 | - 'Content' |
|
| 57 | - ); |
|
| 58 | - }); |
|
| 59 | - |
|
| 60 | - return parent::getCMSFields(); |
|
| 61 | - } |
|
| 15 | + /** |
|
| 16 | + * @var string |
|
| 17 | + */ |
|
| 18 | + private static $singular_name = 'Video Slide'; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + private static $plural_name = 'Video Slides'; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + private static $table_name = 'VideoSlide'; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var array |
|
| 32 | + */ |
|
| 33 | + private static $has_one = [ |
|
| 34 | + 'Video' => File::class, |
|
| 35 | + ]; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @var array |
|
| 39 | + */ |
|
| 40 | + private static $owns = [ |
|
| 41 | + 'Video', |
|
| 42 | + ]; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @return FieldList |
|
| 46 | + */ |
|
| 47 | + public function getCMSFields() |
|
| 48 | + { |
|
| 49 | + $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 50 | + $fields->addFieldToTab( |
|
| 51 | + 'Root.Main', |
|
| 52 | + UploadField::create('Video') |
|
| 53 | + ->setTitle('Video') |
|
| 54 | + ->setDescription('mp4 format') |
|
| 55 | + ->setAllowedExtensions(['mp4']), |
|
| 56 | + 'Content' |
|
| 57 | + ); |
|
| 58 | + }); |
|
| 59 | + |
|
| 60 | + return parent::getCMSFields(); |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | public function getCMSFields() |
| 48 | 48 | { |
| 49 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 49 | + $this->beforeUpdateCMSFields(function(FieldList $fields) { |
|
| 50 | 50 | $fields->addFieldToTab( |
| 51 | 51 | 'Root.Main', |
| 52 | 52 | UploadField::create('Video') |
@@ -23,344 +23,344 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class Slide extends DataObject implements PermissionProvider, SlideInterface |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * The Create permission |
|
| 28 | - */ |
|
| 29 | - const SLIDE_CREATE = 'SLIDE_CREATE'; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * The Publish permission |
|
| 33 | - */ |
|
| 34 | - const SLIDE_PUBLISH = 'SLIDE_PUBLISH'; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * The Edit permission |
|
| 38 | - */ |
|
| 39 | - const SLIDE_EDIT = 'SLIDE_EDIT'; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * The Delete permission |
|
| 43 | - */ |
|
| 44 | - const SLIDE_DELETE = 'SLIDE_DELETE'; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @var string |
|
| 48 | - */ |
|
| 49 | - private static $singular_name = 'Slide'; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @var string |
|
| 53 | - */ |
|
| 54 | - private static $plural_name = 'Slides'; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @var string |
|
| 58 | - */ |
|
| 59 | - private static $table_name = 'Slide'; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @var array |
|
| 63 | - */ |
|
| 64 | - private static $db = [ |
|
| 65 | - 'Title' => 'Varchar(255)', |
|
| 66 | - 'ShowTitle' => 'Boolean', |
|
| 67 | - 'Content' => 'HTMLText', |
|
| 68 | - 'SortOrder' => 'Int', |
|
| 69 | - ]; |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @var array |
|
| 73 | - */ |
|
| 74 | - private static $has_one = [ |
|
| 75 | - 'Page' => \Page::class, |
|
| 76 | - ]; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @var array |
|
| 80 | - */ |
|
| 81 | - private static $extensions = [ |
|
| 82 | - Versioned::class, |
|
| 83 | - InheritedPermissionsExtension::class, |
|
| 84 | - ]; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * @var array |
|
| 88 | - */ |
|
| 89 | - private static $versioning = [ |
|
| 90 | - "Stage", "Live", |
|
| 91 | - ]; |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * @var string |
|
| 96 | - */ |
|
| 97 | - private static $default_sort = 'SortOrder'; |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Adds Publish button to SlideImage record |
|
| 101 | - * |
|
| 102 | - * @var bool |
|
| 103 | - */ |
|
| 104 | - private static $versioned_gridfield_extensions = true; |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * @var array |
|
| 108 | - */ |
|
| 109 | - private static $searchable_fields = [ |
|
| 110 | - 'Title', |
|
| 111 | - 'Content', |
|
| 112 | - ]; |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * @var array |
|
| 116 | - */ |
|
| 117 | - private static $summary_fields = [ |
|
| 118 | - 'SlideType', |
|
| 119 | - 'Title', |
|
| 120 | - ]; |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * @return FieldList |
|
| 124 | - */ |
|
| 125 | - public function getCMSFields() |
|
| 126 | - { |
|
| 127 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 128 | - $viewInherit = $fields->dataFieldByName('CanViewType'); |
|
| 129 | - $editInherit = $fields->dataFieldByName('CanEditType'); |
|
| 130 | - |
|
| 131 | - $fields->removeByName([ |
|
| 132 | - 'Title', |
|
| 133 | - 'ShowTitle', |
|
| 134 | - 'SortOrder', |
|
| 135 | - 'CanViewType', |
|
| 136 | - 'CanEditType', |
|
| 137 | - 'PageID', |
|
| 138 | - ]); |
|
| 139 | - |
|
| 140 | - $fields->addFieldToTab( |
|
| 141 | - 'Root.Main', |
|
| 142 | - TextCheckboxGroupField::create(), |
|
| 143 | - 'Content' |
|
| 144 | - ); |
|
| 145 | - |
|
| 146 | - $fields->addFieldsToTab( |
|
| 147 | - 'Root.Permissions', |
|
| 148 | - [ |
|
| 149 | - $viewInherit, |
|
| 150 | - $editInherit, |
|
| 151 | - ] |
|
| 152 | - ); |
|
| 153 | - }); |
|
| 154 | - |
|
| 155 | - return parent::getCMSFields(); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * @return array |
|
| 160 | - */ |
|
| 161 | - public function providePermissions() |
|
| 162 | - { |
|
| 163 | - return [ |
|
| 164 | - static::SLIDE_CREATE => [ |
|
| 165 | - 'name' => _t(__CLASS__ . '.PERMISSION_CREATE_DESCRIPTION', 'Create Slides'), |
|
| 166 | - 'help' => _t(__CLASS__ . '.PERMISSION_CREATE_HELP', 'Allow creating slides'), |
|
| 167 | - 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 168 | - 'sort' => 100, |
|
| 169 | - ], |
|
| 170 | - static::SLIDE_PUBLISH => [ |
|
| 171 | - 'name' => _t(__CLASS__ . '.PERMISSION_PUBLISH_DESCRIPTION', 'Publish Slides'), |
|
| 172 | - 'help' => _t(__CLASS__ . '.PERMISSION_PUBLISH_HELP', 'Allow publishing slides'), |
|
| 173 | - 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 174 | - 'sort' => 100, |
|
| 175 | - ], |
|
| 176 | - static::SLIDE_EDIT => [ |
|
| 177 | - 'name' => _t(__CLASS__ . '.PERMISSION_EDIT_DESCRIPTION', 'Edit Slides'), |
|
| 178 | - 'help' => _t(__CLASS__ . '.PERMISSION_EDIT_HELP', 'Allow editing slides'), |
|
| 179 | - 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 180 | - 'sort' => 100, |
|
| 181 | - ], |
|
| 182 | - static::SLIDE_DELETE => [ |
|
| 183 | - 'name' => _t(__CLASS__ . '.PERMISSION_DELETE_DESCRIPTION', 'Delete Slides'), |
|
| 184 | - 'help' => _t(__CLASS__ . '.PERMISSION_DELETE_HELP', 'Allow deleting slides'), |
|
| 185 | - 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 186 | - 'sort' => 100, |
|
| 187 | - ], |
|
| 188 | - ]; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * @param null $member |
|
| 193 | - * @param array $context |
|
| 194 | - * @return bool|int |
|
| 195 | - */ |
|
| 196 | - public function canCreate($member = null, $context = []) |
|
| 197 | - { |
|
| 198 | - if (!$member) { |
|
| 199 | - $member = Security::getCurrentUser(); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - // Standard mechanism for accepting permission changes from extensions |
|
| 203 | - $extended = $this->extendedCan(__FUNCTION__, $member, $context); |
|
| 204 | - if ($extended !== null) { |
|
| 205 | - return $extended; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - // Check permission |
|
| 209 | - if ($member && Permission::checkMember($member, "ADMIN") || Permission::checkMember($member, static::SLIDE_CREATE)) { |
|
| 210 | - return true; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - // This doesn't necessarily mean we are creating a root page, but that |
|
| 214 | - // we don't know if there is a parent, so default to this permission |
|
| 215 | - return SiteConfig::current_site_config()->canCreateTopLevel($member); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * @param null $member |
|
| 220 | - * @return bool|int |
|
| 221 | - */ |
|
| 222 | - public function canPublish($member = null) |
|
| 223 | - { |
|
| 224 | - if (!$member) { |
|
| 225 | - $member = Security::getCurrentUser(); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // Check extension |
|
| 229 | - $extended = $this->extendedCan('canPublish', $member); |
|
| 230 | - if ($extended !== null) { |
|
| 231 | - return $extended; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - if (Permission::checkMember($member, "ADMIN") || Permission::checkMember($member, static::SLIDE_PUBLISH)) { |
|
| 235 | - return true; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - return false; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * @param null $member |
|
| 243 | - * @return bool|int |
|
| 244 | - */ |
|
| 245 | - public function canEdit($member = null) |
|
| 246 | - { |
|
| 247 | - if (!$member) { |
|
| 248 | - $member = Security::getCurrentUser(); |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - // Standard mechanism for accepting permission changes from extensions |
|
| 252 | - $extended = $this->extendedCan('canEdit', $member); |
|
| 253 | - if ($extended !== null) { |
|
| 254 | - return $extended; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - // Default permissions |
|
| 258 | - if (Permission::checkMember($member, "ADMIN") || Permission::checkMember($member, static::SLIDE_EDIT)) { |
|
| 259 | - return true; |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - |
|
| 263 | - return false; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * @param null $member |
|
| 268 | - * @return bool|null |
|
| 269 | - */ |
|
| 270 | - public function canView($member = null) |
|
| 271 | - { |
|
| 272 | - if (!$member) { |
|
| 273 | - $member = Security::getCurrentUser(); |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - // Standard mechanism for accepting permission changes from extensions |
|
| 277 | - $extended = $this->extendedCan('canView', $member); |
|
| 278 | - if ($extended !== null) { |
|
| 279 | - return $extended; |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - // admin override |
|
| 283 | - if ($member && Permission::checkMember($member, ["ADMIN", "SITETREE_VIEW_ALL"])) { |
|
| 284 | - return true; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - // Note: getInheritedPermissions() is disused in this instance |
|
| 288 | - // to allow parent canView extensions to influence subpage canView() |
|
| 289 | - |
|
| 290 | - // check for empty spec |
|
| 291 | - if (!$this->CanViewType || $this->CanViewType === InheritedPermissions::ANYONE) { |
|
| 292 | - return true; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - // check for inherit |
|
| 296 | - if ($this->CanViewType === InheritedPermissions::INHERIT) { |
|
| 297 | - return $this->getSiteConfig()->canViewPages($member); |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - // check for any logged-in users |
|
| 301 | - if ($this->CanViewType === InheritedPermissions::LOGGED_IN_USERS && $member && $member->ID) { |
|
| 302 | - return true; |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - // check for specific groups |
|
| 306 | - if ($this->CanViewType === InheritedPermissions::ONLY_THESE_USERS |
|
| 307 | - && $member |
|
| 308 | - && $member->inGroups($this->ViewerGroups()) |
|
| 309 | - ) { |
|
| 310 | - return true; |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - return false; |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - /** |
|
| 317 | - * @param null $member |
|
| 318 | - * @return bool|int |
|
| 319 | - */ |
|
| 320 | - public function canDelete($member = null) |
|
| 321 | - { |
|
| 322 | - if (!$member) { |
|
| 323 | - $member = Security::getCurrentUser(); |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - // Standard mechanism for accepting permission changes from extensions |
|
| 327 | - $extended = $this->extendedCan('canDelete', $member); |
|
| 328 | - if ($extended !== null) { |
|
| 329 | - return $extended; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - if (!$member) { |
|
| 333 | - return false; |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - // Default permission check |
|
| 337 | - if (Permission::checkMember($member, ["ADMIN", static::SLIDE_DELETE])) { |
|
| 338 | - return true; |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - return false; |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * Stub method to get the site config, unless the current class can provide an alternate. |
|
| 346 | - * |
|
| 347 | - * @return SiteConfig |
|
| 348 | - */ |
|
| 349 | - public function getSiteConfig() |
|
| 350 | - { |
|
| 351 | - $configs = $this->invokeWithExtensions('alternateSiteConfig'); |
|
| 352 | - foreach (array_filter($configs) as $config) { |
|
| 353 | - return $config; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - return SiteConfig::current_site_config(); |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * @return string |
|
| 361 | - */ |
|
| 362 | - public function getSlideType() |
|
| 363 | - { |
|
| 364 | - return static::i18n_singular_name(); |
|
| 365 | - } |
|
| 26 | + /** |
|
| 27 | + * The Create permission |
|
| 28 | + */ |
|
| 29 | + const SLIDE_CREATE = 'SLIDE_CREATE'; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * The Publish permission |
|
| 33 | + */ |
|
| 34 | + const SLIDE_PUBLISH = 'SLIDE_PUBLISH'; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * The Edit permission |
|
| 38 | + */ |
|
| 39 | + const SLIDE_EDIT = 'SLIDE_EDIT'; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * The Delete permission |
|
| 43 | + */ |
|
| 44 | + const SLIDE_DELETE = 'SLIDE_DELETE'; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @var string |
|
| 48 | + */ |
|
| 49 | + private static $singular_name = 'Slide'; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @var string |
|
| 53 | + */ |
|
| 54 | + private static $plural_name = 'Slides'; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @var string |
|
| 58 | + */ |
|
| 59 | + private static $table_name = 'Slide'; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @var array |
|
| 63 | + */ |
|
| 64 | + private static $db = [ |
|
| 65 | + 'Title' => 'Varchar(255)', |
|
| 66 | + 'ShowTitle' => 'Boolean', |
|
| 67 | + 'Content' => 'HTMLText', |
|
| 68 | + 'SortOrder' => 'Int', |
|
| 69 | + ]; |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @var array |
|
| 73 | + */ |
|
| 74 | + private static $has_one = [ |
|
| 75 | + 'Page' => \Page::class, |
|
| 76 | + ]; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @var array |
|
| 80 | + */ |
|
| 81 | + private static $extensions = [ |
|
| 82 | + Versioned::class, |
|
| 83 | + InheritedPermissionsExtension::class, |
|
| 84 | + ]; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * @var array |
|
| 88 | + */ |
|
| 89 | + private static $versioning = [ |
|
| 90 | + "Stage", "Live", |
|
| 91 | + ]; |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * @var string |
|
| 96 | + */ |
|
| 97 | + private static $default_sort = 'SortOrder'; |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Adds Publish button to SlideImage record |
|
| 101 | + * |
|
| 102 | + * @var bool |
|
| 103 | + */ |
|
| 104 | + private static $versioned_gridfield_extensions = true; |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * @var array |
|
| 108 | + */ |
|
| 109 | + private static $searchable_fields = [ |
|
| 110 | + 'Title', |
|
| 111 | + 'Content', |
|
| 112 | + ]; |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * @var array |
|
| 116 | + */ |
|
| 117 | + private static $summary_fields = [ |
|
| 118 | + 'SlideType', |
|
| 119 | + 'Title', |
|
| 120 | + ]; |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * @return FieldList |
|
| 124 | + */ |
|
| 125 | + public function getCMSFields() |
|
| 126 | + { |
|
| 127 | + $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 128 | + $viewInherit = $fields->dataFieldByName('CanViewType'); |
|
| 129 | + $editInherit = $fields->dataFieldByName('CanEditType'); |
|
| 130 | + |
|
| 131 | + $fields->removeByName([ |
|
| 132 | + 'Title', |
|
| 133 | + 'ShowTitle', |
|
| 134 | + 'SortOrder', |
|
| 135 | + 'CanViewType', |
|
| 136 | + 'CanEditType', |
|
| 137 | + 'PageID', |
|
| 138 | + ]); |
|
| 139 | + |
|
| 140 | + $fields->addFieldToTab( |
|
| 141 | + 'Root.Main', |
|
| 142 | + TextCheckboxGroupField::create(), |
|
| 143 | + 'Content' |
|
| 144 | + ); |
|
| 145 | + |
|
| 146 | + $fields->addFieldsToTab( |
|
| 147 | + 'Root.Permissions', |
|
| 148 | + [ |
|
| 149 | + $viewInherit, |
|
| 150 | + $editInherit, |
|
| 151 | + ] |
|
| 152 | + ); |
|
| 153 | + }); |
|
| 154 | + |
|
| 155 | + return parent::getCMSFields(); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * @return array |
|
| 160 | + */ |
|
| 161 | + public function providePermissions() |
|
| 162 | + { |
|
| 163 | + return [ |
|
| 164 | + static::SLIDE_CREATE => [ |
|
| 165 | + 'name' => _t(__CLASS__ . '.PERMISSION_CREATE_DESCRIPTION', 'Create Slides'), |
|
| 166 | + 'help' => _t(__CLASS__ . '.PERMISSION_CREATE_HELP', 'Allow creating slides'), |
|
| 167 | + 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 168 | + 'sort' => 100, |
|
| 169 | + ], |
|
| 170 | + static::SLIDE_PUBLISH => [ |
|
| 171 | + 'name' => _t(__CLASS__ . '.PERMISSION_PUBLISH_DESCRIPTION', 'Publish Slides'), |
|
| 172 | + 'help' => _t(__CLASS__ . '.PERMISSION_PUBLISH_HELP', 'Allow publishing slides'), |
|
| 173 | + 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 174 | + 'sort' => 100, |
|
| 175 | + ], |
|
| 176 | + static::SLIDE_EDIT => [ |
|
| 177 | + 'name' => _t(__CLASS__ . '.PERMISSION_EDIT_DESCRIPTION', 'Edit Slides'), |
|
| 178 | + 'help' => _t(__CLASS__ . '.PERMISSION_EDIT_HELP', 'Allow editing slides'), |
|
| 179 | + 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 180 | + 'sort' => 100, |
|
| 181 | + ], |
|
| 182 | + static::SLIDE_DELETE => [ |
|
| 183 | + 'name' => _t(__CLASS__ . '.PERMISSION_DELETE_DESCRIPTION', 'Delete Slides'), |
|
| 184 | + 'help' => _t(__CLASS__ . '.PERMISSION_DELETE_HELP', 'Allow deleting slides'), |
|
| 185 | + 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 186 | + 'sort' => 100, |
|
| 187 | + ], |
|
| 188 | + ]; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * @param null $member |
|
| 193 | + * @param array $context |
|
| 194 | + * @return bool|int |
|
| 195 | + */ |
|
| 196 | + public function canCreate($member = null, $context = []) |
|
| 197 | + { |
|
| 198 | + if (!$member) { |
|
| 199 | + $member = Security::getCurrentUser(); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + // Standard mechanism for accepting permission changes from extensions |
|
| 203 | + $extended = $this->extendedCan(__FUNCTION__, $member, $context); |
|
| 204 | + if ($extended !== null) { |
|
| 205 | + return $extended; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + // Check permission |
|
| 209 | + if ($member && Permission::checkMember($member, "ADMIN") || Permission::checkMember($member, static::SLIDE_CREATE)) { |
|
| 210 | + return true; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + // This doesn't necessarily mean we are creating a root page, but that |
|
| 214 | + // we don't know if there is a parent, so default to this permission |
|
| 215 | + return SiteConfig::current_site_config()->canCreateTopLevel($member); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * @param null $member |
|
| 220 | + * @return bool|int |
|
| 221 | + */ |
|
| 222 | + public function canPublish($member = null) |
|
| 223 | + { |
|
| 224 | + if (!$member) { |
|
| 225 | + $member = Security::getCurrentUser(); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // Check extension |
|
| 229 | + $extended = $this->extendedCan('canPublish', $member); |
|
| 230 | + if ($extended !== null) { |
|
| 231 | + return $extended; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + if (Permission::checkMember($member, "ADMIN") || Permission::checkMember($member, static::SLIDE_PUBLISH)) { |
|
| 235 | + return true; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + return false; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * @param null $member |
|
| 243 | + * @return bool|int |
|
| 244 | + */ |
|
| 245 | + public function canEdit($member = null) |
|
| 246 | + { |
|
| 247 | + if (!$member) { |
|
| 248 | + $member = Security::getCurrentUser(); |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + // Standard mechanism for accepting permission changes from extensions |
|
| 252 | + $extended = $this->extendedCan('canEdit', $member); |
|
| 253 | + if ($extended !== null) { |
|
| 254 | + return $extended; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + // Default permissions |
|
| 258 | + if (Permission::checkMember($member, "ADMIN") || Permission::checkMember($member, static::SLIDE_EDIT)) { |
|
| 259 | + return true; |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + |
|
| 263 | + return false; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * @param null $member |
|
| 268 | + * @return bool|null |
|
| 269 | + */ |
|
| 270 | + public function canView($member = null) |
|
| 271 | + { |
|
| 272 | + if (!$member) { |
|
| 273 | + $member = Security::getCurrentUser(); |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + // Standard mechanism for accepting permission changes from extensions |
|
| 277 | + $extended = $this->extendedCan('canView', $member); |
|
| 278 | + if ($extended !== null) { |
|
| 279 | + return $extended; |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + // admin override |
|
| 283 | + if ($member && Permission::checkMember($member, ["ADMIN", "SITETREE_VIEW_ALL"])) { |
|
| 284 | + return true; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + // Note: getInheritedPermissions() is disused in this instance |
|
| 288 | + // to allow parent canView extensions to influence subpage canView() |
|
| 289 | + |
|
| 290 | + // check for empty spec |
|
| 291 | + if (!$this->CanViewType || $this->CanViewType === InheritedPermissions::ANYONE) { |
|
| 292 | + return true; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + // check for inherit |
|
| 296 | + if ($this->CanViewType === InheritedPermissions::INHERIT) { |
|
| 297 | + return $this->getSiteConfig()->canViewPages($member); |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + // check for any logged-in users |
|
| 301 | + if ($this->CanViewType === InheritedPermissions::LOGGED_IN_USERS && $member && $member->ID) { |
|
| 302 | + return true; |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + // check for specific groups |
|
| 306 | + if ($this->CanViewType === InheritedPermissions::ONLY_THESE_USERS |
|
| 307 | + && $member |
|
| 308 | + && $member->inGroups($this->ViewerGroups()) |
|
| 309 | + ) { |
|
| 310 | + return true; |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + return false; |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + /** |
|
| 317 | + * @param null $member |
|
| 318 | + * @return bool|int |
|
| 319 | + */ |
|
| 320 | + public function canDelete($member = null) |
|
| 321 | + { |
|
| 322 | + if (!$member) { |
|
| 323 | + $member = Security::getCurrentUser(); |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + // Standard mechanism for accepting permission changes from extensions |
|
| 327 | + $extended = $this->extendedCan('canDelete', $member); |
|
| 328 | + if ($extended !== null) { |
|
| 329 | + return $extended; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + if (!$member) { |
|
| 333 | + return false; |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + // Default permission check |
|
| 337 | + if (Permission::checkMember($member, ["ADMIN", static::SLIDE_DELETE])) { |
|
| 338 | + return true; |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + return false; |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * Stub method to get the site config, unless the current class can provide an alternate. |
|
| 346 | + * |
|
| 347 | + * @return SiteConfig |
|
| 348 | + */ |
|
| 349 | + public function getSiteConfig() |
|
| 350 | + { |
|
| 351 | + $configs = $this->invokeWithExtensions('alternateSiteConfig'); |
|
| 352 | + foreach (array_filter($configs) as $config) { |
|
| 353 | + return $config; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + return SiteConfig::current_site_config(); |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * @return string |
|
| 361 | + */ |
|
| 362 | + public function getSlideType() |
|
| 363 | + { |
|
| 364 | + return static::i18n_singular_name(); |
|
| 365 | + } |
|
| 366 | 366 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function getCMSFields() |
| 126 | 126 | { |
| 127 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
| 127 | + $this->beforeUpdateCMSFields(function(FieldList $fields) { |
|
| 128 | 128 | $viewInherit = $fields->dataFieldByName('CanViewType'); |
| 129 | 129 | $editInherit = $fields->dataFieldByName('CanEditType'); |
| 130 | 130 | |
@@ -162,27 +162,27 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | return [ |
| 164 | 164 | static::SLIDE_CREATE => [ |
| 165 | - 'name' => _t(__CLASS__ . '.PERMISSION_CREATE_DESCRIPTION', 'Create Slides'), |
|
| 166 | - 'help' => _t(__CLASS__ . '.PERMISSION_CREATE_HELP', 'Allow creating slides'), |
|
| 167 | - 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 165 | + 'name' => _t(__CLASS__.'.PERMISSION_CREATE_DESCRIPTION', 'Create Slides'), |
|
| 166 | + 'help' => _t(__CLASS__.'.PERMISSION_CREATE_HELP', 'Allow creating slides'), |
|
| 167 | + 'category' => _t(__CLASS__.'.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 168 | 168 | 'sort' => 100, |
| 169 | 169 | ], |
| 170 | 170 | static::SLIDE_PUBLISH => [ |
| 171 | - 'name' => _t(__CLASS__ . '.PERMISSION_PUBLISH_DESCRIPTION', 'Publish Slides'), |
|
| 172 | - 'help' => _t(__CLASS__ . '.PERMISSION_PUBLISH_HELP', 'Allow publishing slides'), |
|
| 173 | - 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 171 | + 'name' => _t(__CLASS__.'.PERMISSION_PUBLISH_DESCRIPTION', 'Publish Slides'), |
|
| 172 | + 'help' => _t(__CLASS__.'.PERMISSION_PUBLISH_HELP', 'Allow publishing slides'), |
|
| 173 | + 'category' => _t(__CLASS__.'.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 174 | 174 | 'sort' => 100, |
| 175 | 175 | ], |
| 176 | 176 | static::SLIDE_EDIT => [ |
| 177 | - 'name' => _t(__CLASS__ . '.PERMISSION_EDIT_DESCRIPTION', 'Edit Slides'), |
|
| 178 | - 'help' => _t(__CLASS__ . '.PERMISSION_EDIT_HELP', 'Allow editing slides'), |
|
| 179 | - 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 177 | + 'name' => _t(__CLASS__.'.PERMISSION_EDIT_DESCRIPTION', 'Edit Slides'), |
|
| 178 | + 'help' => _t(__CLASS__.'.PERMISSION_EDIT_HELP', 'Allow editing slides'), |
|
| 179 | + 'category' => _t(__CLASS__.'.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 180 | 180 | 'sort' => 100, |
| 181 | 181 | ], |
| 182 | 182 | static::SLIDE_DELETE => [ |
| 183 | - 'name' => _t(__CLASS__ . '.PERMISSION_DELETE_DESCRIPTION', 'Delete Slides'), |
|
| 184 | - 'help' => _t(__CLASS__ . '.PERMISSION_DELETE_HELP', 'Allow deleting slides'), |
|
| 185 | - 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 183 | + 'name' => _t(__CLASS__.'.PERMISSION_DELETE_DESCRIPTION', 'Delete Slides'), |
|
| 184 | + 'help' => _t(__CLASS__.'.PERMISSION_DELETE_HELP', 'Allow deleting slides'), |
|
| 185 | + 'category' => _t(__CLASS__.'.PERMISSIONS_CATEGORY', 'FlexSlider Permissions'), |
|
| 186 | 186 | 'sort' => 100, |
| 187 | 187 | ], |
| 188 | 188 | ]; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | // Standard mechanism for accepting permission changes from extensions |
| 203 | 203 | $extended = $this->extendedCan(__FUNCTION__, $member, $context); |
| 204 | - if ($extended !== null) { |
|
| 204 | + if ($extended!==null) { |
|
| 205 | 205 | return $extended; |
| 206 | 206 | } |
| 207 | 207 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | // Check extension |
| 229 | 229 | $extended = $this->extendedCan('canPublish', $member); |
| 230 | - if ($extended !== null) { |
|
| 230 | + if ($extended!==null) { |
|
| 231 | 231 | return $extended; |
| 232 | 232 | } |
| 233 | 233 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | // Standard mechanism for accepting permission changes from extensions |
| 252 | 252 | $extended = $this->extendedCan('canEdit', $member); |
| 253 | - if ($extended !== null) { |
|
| 253 | + if ($extended!==null) { |
|
| 254 | 254 | return $extended; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | |
| 276 | 276 | // Standard mechanism for accepting permission changes from extensions |
| 277 | 277 | $extended = $this->extendedCan('canView', $member); |
| 278 | - if ($extended !== null) { |
|
| 278 | + if ($extended!==null) { |
|
| 279 | 279 | return $extended; |
| 280 | 280 | } |
| 281 | 281 | |
@@ -288,22 +288,22 @@ discard block |
||
| 288 | 288 | // to allow parent canView extensions to influence subpage canView() |
| 289 | 289 | |
| 290 | 290 | // check for empty spec |
| 291 | - if (!$this->CanViewType || $this->CanViewType === InheritedPermissions::ANYONE) { |
|
| 291 | + if (!$this->CanViewType || $this->CanViewType===InheritedPermissions::ANYONE) { |
|
| 292 | 292 | return true; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // check for inherit |
| 296 | - if ($this->CanViewType === InheritedPermissions::INHERIT) { |
|
| 296 | + if ($this->CanViewType===InheritedPermissions::INHERIT) { |
|
| 297 | 297 | return $this->getSiteConfig()->canViewPages($member); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | // check for any logged-in users |
| 301 | - if ($this->CanViewType === InheritedPermissions::LOGGED_IN_USERS && $member && $member->ID) { |
|
| 301 | + if ($this->CanViewType===InheritedPermissions::LOGGED_IN_USERS && $member && $member->ID) { |
|
| 302 | 302 | return true; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | // check for specific groups |
| 306 | - if ($this->CanViewType === InheritedPermissions::ONLY_THESE_USERS |
|
| 306 | + if ($this->CanViewType===InheritedPermissions::ONLY_THESE_USERS |
|
| 307 | 307 | && $member |
| 308 | 308 | && $member->inGroups($this->ViewerGroups()) |
| 309 | 309 | ) { |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | // Standard mechanism for accepting permission changes from extensions |
| 327 | 327 | $extended = $this->extendedCan('canDelete', $member); |
| 328 | - if ($extended !== null) { |
|
| 328 | + if ($extended!==null) { |
|
| 329 | 329 | return $extended; |
| 330 | 330 | } |
| 331 | 331 | |