| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | class PageRow extends DataObject | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     private static $bg_image_prefix = ''; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     private static $bg_image_postfix = ''; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     private static $background_image_options = []; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     private static $background_style_options = []; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * @var int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     private static $max_number_of_pages_for_tree_selector = 500; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     ### Names Section | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     private static $singular_name = 'Content Block'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     public function i18n_singular_name() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         return _t('PageRows.SINGULAR_NAME', 'Content Block'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     private static $plural_name = 'PageRows'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     public function i18n_plural_name() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         return _t('PageRows.PLURAL_NAME', 'Content Blocks'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     ### Model Section | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     private static $db = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         'ReadyForPublication' => 'Boolean', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         'Code' => 'Varchar(7)', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         'Title' => 'Varchar(255)', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         'BackgroundImage' => 'Varchar(255)', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         'BackgroundStyle' => 'Varchar(100)' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     private static $belongs_many_many = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         'Pages' => 'Page' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     ### Further DB Field Details | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     private static $indexes = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         'Created' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         'Code' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         'ReadyForPublication' => true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     private static $default_sort = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         'ReadyForPublication' => 'DESC', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         'Created' => 'DESC' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     private static $required_fields = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         'Title' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     private static $searchable_fields = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         'ClassName' => 'ExactMatchFilter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         'ReadyForPublication' => 'ExactMatchFilter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         'Code' => 'PartialMatchFilter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         'Title' => 'PartialMatchFilter' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     public function scaffoldSearchFields($_params = null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         $list = ClassInfo::subclassesFor('PageRow'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $newList = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         foreach($list as $key => $entry) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             $newList[$entry] = Injector::inst()->get($entry)->i18n_singular_name(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         $fields = parent::scaffoldSearchFields($_params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         $fields->replaceField( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             'ClassName', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             DropdownField::create( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |                 'ClassName', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |                 'Type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |                 ['' => '--- ANY ---'] + $newList | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         return $fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     ### Field Names and Presentation Section | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     private static $summary_fields = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         'CodeNice' => 'Code', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         'Type' => 'Type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         'TitleStrong' => 'Title', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         'UsedOn' => 'Used On', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         'ReadyForPublicationStrong' => 'Published' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     private static $field_labels = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         'ReadyForPublication' => 'Ready' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     private static $field_labels_right = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         'Code' => 'This is auto-generated (unique) code to keep track of content blocks', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |         'ReadyForPublication' => 'Is this Content Block ready for publication?' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     ### Casting Section | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     private static $casting = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         'CodeNice' => 'HTMLText', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         'Type' => 'Varchar', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         'UsedOn' => 'Varchar', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |         'ChildPageRowHTML' => 'HTMLText', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         'TitleStrong' => 'HTMLText', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         'ReadyForPublicationStrong' => 'HTMLText' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     public function getType() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         return $this->singular_name(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     public function getCodeNice() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         $v = '<span style="font-family: monospace;">'.substr($this->Code, 0, 3).'-'.substr($this->Code, -4).'</span>'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         return DBField::create_field('HTMLText', $v); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |     public function getUsedOn() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |         $v = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         $pages = $this->Pages(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |         foreach($pages as $page) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |             $v[] = $page->MenuTitle; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |         return DBField::create_field('Varchar', implode(', ', $v)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |     public function getTitleStrong() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         $v = '<strong style="color: blue">'.$this->Title.'</strong>'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         return DBField::create_field('HTMLText', $v); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |     public function getReadyForPublicationStrong() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         if($this->ReadyForPublication) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |             $v = '<span style="color: green">Published</span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |             $v = '<span style="color: red">NOT published</span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         return DBField::create_field('HTMLText', $v); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |     ### can Section | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |      * only children can be created | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     public function canDelete($member = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         return $this->Pages()->count() ? false : true; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |     ### write Section | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |     public function requireDefaultRecords() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |         parent::requireDefaultRecords(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         //make template | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         $theme = SSViewer::current_theme(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |         if($theme) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |             if ($this->ClassName !== 'PageRow') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |                 $folder = Director::baseFolder(). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |                 '/themes/'. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |                 $theme.'_mysite/templates/Includes/page-row/types/'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |                 if(! file_exists($folder)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |                     DB::alteration_message('✓ Creating '.$folder, 'created'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |                     mkdir($folder, 0755, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |                 if(file_exists($folder)){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |                     $fileName = | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |                         $folder . $this->templateForHTMLOutput($this->ClassName).'.ss'; | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 236 |  | View Code Duplication |                     if (! file_exists($fileName)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |                         DB::alteration_message('✓ Creating ...' . $fileName, 'created'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |                         file_put_contents( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |                             $fileName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |         '<% include PageRowHeader %> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |         <% include PageRowFooter %>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |                         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |                         DB::alteration_message('✓ Checked ...' . $fileName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |             //scss files ... | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |             $folder = | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |                 Director::baseFolder().'/themes/'. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |                 $theme.'_mysite/src/sass/page-rows/'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |             $fileName = $folder . $this->ClassName.'.scss'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |             if(! file_exists($folder)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |                 mkdir($folder, 0755, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |             } | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 258 |  | View Code Duplication |             if (! file_exists($fileName)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |                 DB::alteration_message('✓ Creating ...' . $fileName, 'created'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |                 file_put_contents( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |                     $fileName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |     '.'.strtolower($this->ClassName).'.row { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |     }' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |                 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |                 DB::alteration_message('✓ Checked ...' . $fileName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |     public function validate() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |         $result = parent::validate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |         if ($this->ReadyForPublication) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |             $fieldLabels = $this->FieldLabels(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |             $indexes = $this->Config()->get('indexes'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |             foreach ($this->Config()->get('required_fields') as $field) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |                 $value = $this->$field; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |                 if (! $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |                     $fieldWithoutID = $field; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |                     if (substr($fieldWithoutID, -2) === 'ID') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |                         $fieldWithoutID = substr($fieldWithoutID, 0, -2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |                     $myName = isset($fieldLabels[$fieldWithoutID]) ? $fieldLabels[$fieldWithoutID] : $fieldWithoutID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |                     $result->error( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |                         _t( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |                             'PageRows.'.$field.'_REQUIRED', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |                             $myName.' is required' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |                         ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |                         'REQUIRED_PageRows_'.$field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |                     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |                 if (isset($indexes[$field]) && isset($indexes[$field]['type']) && $indexes[$field]['type'] === 'unique') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |                     $id = (empty($this->ID) ? 0 : $this->ID); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |                     $count = PageRows::get() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |                         ->filter(array($field => $value)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |                         ->exclude(array('ID' => $id)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |                         ->count(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |                     if ($count > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |                         $myName = $fieldLabels['$field']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |                         $result->error( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |                             _t( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |                                 'PageRows.'.$field.'_UNIQUE', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |                                 $myName.' needs to be unique' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |                             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |                             'UNIQUE_PageRows_'.$field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |                         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |         return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |     public function onBeforeWrite() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |         parent::onBeforeWrite(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |         if (!$this->Code) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |             $this->Code = hash('md5', rand()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |         //... | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |     public function onAfterWrite() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |         parent::onAfterWrite(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |         if (!$this->Code) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |             $this->Code = hash('md5', rand()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |         if(class_exists('DynamicCache')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |             DynamicCache::inst()->clear(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |     ### Import / Export Section | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |     ### CMS Edit Section | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |     ####################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |     protected $runCMSFieldFixups = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |     public function getCMSFields() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |         $fields = parent::getCMSFields(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |         $fields->removeByName('BackgroundImage'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |         $fields->removeByName('BackgroundStyle'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |         $fields->removeByName('Pages'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |         if ($this->exists() && $this->Code) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |             //too late now! | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |             $list = ClassInfo::subclassesFor('PageRow'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |             $arrayOfTypes = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |             foreach ($list as $className) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |                 if ($className === 'PageRow') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |                     continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |                 $arrayOfTypes[$className] = Injector::inst()->get($className)->singular_name(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |             $fields->addFieldToTab( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |                 'Root.Main', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |                 DropdownField::create( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |                     'ClassName', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |                     'Type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |                     $arrayOfTypes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |                 'Title' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |         $fieldLabels = $this->FieldLabels(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |         $fields->insertAfter( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |             'ReadyForPublication', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |             ReadonlyField::create( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |                 'ClassNameNice', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |                 'Type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |                 $this->singular_name() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |         $fields->replaceField( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |             'Code', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |             ReadonlyField::create( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |                 'Code', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |                 'Code' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |         $fieldGroups = $this->myCMSFieldGroups(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |         foreach ($fieldGroups as $tabTitle => $fieldGroup) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |             if(is_array($fieldGroup) && count($fieldGroup)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |                 foreach ($fieldGroup as $fieldNameOrFormField) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |                     if($fieldNameOrFormField instanceof FormField) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |                         $fields->addFieldToTab( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |                             'Root.'.$tabTitle, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |                             $fieldNameOrFormField | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |                         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |                         $fieldObject = $fields->dataFieldByName($fieldNameOrFormField); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |                         if ($fieldObject) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |                             $fields->addFieldToTab( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |                                 'Root.'.$tabTitle, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |                                 $fieldObject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |                             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |         //... | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |         if ($this->exists()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |             $fields->addFieldsToTab( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |                 'Root.Preview', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |                 [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |                     LiteralField::create( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |                         'PreviewClassName', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |                         '<h2><a href="'.$this->MyPreviewLink(strtolower($this->ClassName)).'">View All '.$this->singular_name().' Page Blocks</a></h2>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |                     LiteralField::create( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |                         'PreviewIframe', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |                         '<iframe src="'.$this->MyPreviewLink($this->ID).'" style="width: calc(100% - 2px); height: 600px; border: 1px solid #000;"></iframe>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |                     LiteralField::create( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |                         'PreviewAll', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |                         '<h2><a href="'.$this->MyPreviewLink('all').'">View All Page Blocks</a></h2>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |                     LiteralField::create( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |                         'PreviewOneOfEach', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |                         '<h2><a href="'.$this->MyPreviewLink('oneofeach').'">View One Of Each Page Block Type</a></h2>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |                 ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |             if(Page::get()->count() > $this->Config()->get('max_number_of_pages_for_tree_selector')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |                 $fields->addFieldToTab( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |                     'Root.Pages', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |                     GridField::create( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |                         'Pages', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |                         'Shown On ...', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |                         $this->Pages(), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |                         GridFieldConfig_RecordViewer::create() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |                 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |                 $fields->addFieldToTab( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |                     'Root.Pages', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |                     TreeMultiselectField::create( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |                         'Pages', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |                         'Shown On ...', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |                         'SiteTree' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |                         ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |                     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |             $usedInArray = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |             $pageClasses = ClassInfo::subclassesFor('SiteTree'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |             foreach ($pageClasses as $pageClass) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |                 $pageClassObject = Injector::inst()->get($pageClass); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |                 if ($pageClassObject instanceof Page) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |                     $classesUsed = $pageClassObject->DefaultPageRows(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |                     foreach ($classesUsed as $individualItems) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |                         if ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |                             ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |                                 is_array($individualItems) && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |                                 ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |                                     $individualItems['Parent'] === $this->ClassName || | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |                                     $individualItems['Child']=== $this->ClassName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |                                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |                             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |                             || | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |                             (is_string($individualItems) && $individualItems=== $this->ClassName) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |                         ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |                             $usedInArray[$pageClassObject->ClassName] = $pageClassObject->singular_name(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |             if (count($usedInArray)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |                 $fields->addFieldToTab( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |                     'Root.Pages', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |                     LiteralField::create( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |                         'UsedInInfo', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |                         '<h2>'.$this->plural_name().' ('.$this->ClassName.') are used in the following pages ...</h2><p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |                         - '.implode('<br />- ', $usedInArray).' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |                         </p>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |                 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |         if ($this->runCMSFieldFixups) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |             $this->decorateCMSFields($fields); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |         return $fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |     protected function myCMSFieldGroups() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |             'Image' => $this->getImageCMSFields(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |             'Layout' => $this->getLayoutCMSFields(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |             'Background' => $this->getBackgroundFields(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |             'Publish' => $this->getPublishCMSFields() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |     ############################################# | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |     ### TEMPLATE STUFF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |     ############################################# | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |     public function HTMLClassNamesAsString() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |         $str = $this->makeIntoHTMLClasses($this->baseClassesForHTMLAsArray()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |         $str .= ' '.$this->makeIntoHTMLClasses($this->AdditionalHTMLClassNamesAsArray()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |         return $str; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |     public function ChildInheritedClassNamesAsString() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |         return ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |     protected function baseClassesForHTMLAsArray() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |          * we avoid the use of Advertisement as this will be blocked by adblockers ... | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |         $array = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |             ($this->HasChildPageRowHTML() ? 'has-child-row' : 'no-child-row'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |             $this->ClassName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |         foreach($this->hasOne() as $method => $item) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |             $field = $method.'ID'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |             if($this->$field) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |                 $array [] = 'has-'.strtolower($method); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |         return $array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  |     protected function makeIntoHTMLClasses($array) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |         $str = implode(' ', $array); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |         $str = str_replace('  ', ' ', $str); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  |         $str = str_replace('  ', ' ', $str); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |         $str = strtolower($str); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |         return $str; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |     public function UserCanEditMe() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |         return $this->canEdit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |     private static $_current_owner_page_object_overridden = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |     public static function set_current_page_object($page) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |         self::$_current_owner_page_object_overridden = $page; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |     public function CurrentOwnerPageObject() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |         if (self::$_current_owner_page_object_overridden) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |             return self::$_current_owner_page_object_overridden; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |         $controller = $this->CurrentOwnerController(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |         if ($controller) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |             return $controller->data(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |     public function CurrentOwnerController() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |         $controller = Controller::curr(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |         if ($controller instanceof Page_Controller) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |             return $controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |     public function AdditionalHTMLClassNamesAsArray() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |         return []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |     public function HTMLOutputAlwaysOutput($includeJS = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |         return $this->HTMLOutput($includeJS, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |     public function HTMLOutput($includeJS = true, $alwaysShow = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |         if ($this->ReadyForPublication || $alwaysShow) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |             $scripts = $this->customScripts(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |             if ($includeJS) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  |                 foreach ($scripts as $key => $script) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  |                     Requirements::customScript( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  |                         $script, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  |                         $key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  |                     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  |             return $this->renderWith($this->templateForHTMLOutput()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  |      * custom scripts required to run this show | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  |     protected function customScripts() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  |         return []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  |     protected function templateForHTMLOutput($className = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  |         if (! $className) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  |             $className = $this->ClassName; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  |         return 'PageRow-'.$className; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 643 |  | View Code Duplication |     public function MyPreviewLink($id = 0) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  |         if (! $id) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  |             $id = $this->ID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  |         $controller = Injector::inst()->get('PreviewPageRow'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  |         return $controller->Link('preview/'.$id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 653 |  | View Code Duplication |     public function MyPublicViewLink() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  |         if (! $id) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  |             $id = $this->ID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  |         $controller = Injector::inst()->get('PreviewPageRow'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  |         return $controller->Link('preview/'.$id); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  |     public function MoreDetailsRowChildLinkingID() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  |         return 'PageRow-'.$this->ID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  |     public function UserCanEditBlock($member = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  |         return $this->canEdit($member); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  |     public function ContextRelevantCMSEditLink() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  |         $ownerPage = $this->CurrentOwnerPageObject(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  |         if ($ownerPage && $ownerPage instanceof SiteTree) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  |             return '/admin/pages/edit/EditForm/'.$ownerPage->ID.'/field/PageRows/item/'.$this->ID.'/edit/'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  |             return $this->CMSEditLink(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  |     public function ChildClassMethodName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  |         return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  |     private $_childPageRowHTML = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  |      * @alias for HasChildPageRowHTML | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  |     public function HasChild() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  |         return $this->CalculatedHasMoreDetailsRow(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  |     public function AsChildOpenByDefault() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  |     public function MoreDetailsRowParentLinkingID() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  |         if($this->CalculatedHasMoreDetailsRow()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  |             return 'PageRow'.$this->MoreDetailsRowID; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  |         return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  |     public function CalculatedHasMoreDetailsRow() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  |         if(!empty($this->HasMoreDetailsSection)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  |             if(!empty($this->MoreDetailsRowID)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  |                 if($object = $this->MoreDetailsRow()){ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  |                     if($object->exists() && $object->ReadyForPublication) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  |                         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 |  |  |     public function HasChildPageRowHTML() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  |         return $this->CalculatedHasMoreDetailsRow(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 741 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 742 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 743 |  |  |      * @return null / string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 |  |  |     public function ChildPageRowHTML() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 |  |  |         return $this->getChildPageRowHTML(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 |  |  |      * @return null / string | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 752 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 753 |  |  |     public function getChildPageRowHTML() | 
            
                                                                        
                            
            
                                    
            
            
                | 754 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 755 |  |  |         if ($this->_childPageRowHTML === null) { | 
            
                                                                        
                            
            
                                    
            
            
                | 756 |  |  |             $this->_childPageRowHTML = false; | 
            
                                                                        
                            
            
                                    
            
            
                | 757 |  |  |             $method = $this->ChildClassMethodName(); | 
            
                                                                        
                            
            
                                    
            
            
                | 758 |  |  |             if ($method) { | 
            
                                                                        
                            
            
                                    
            
            
                | 759 |  |  |                 $object = $this->$method(); | 
            
                                                                        
                            
            
                                    
            
            
                | 760 |  |  |                 if ($object && $object->exists()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 761 |  |  |                     $this->_childPageRowHTML = $object->HTMLOutput(); | 
            
                                                                        
                            
            
                                    
            
            
                | 762 |  |  |                 } | 
            
                                                                        
                            
            
                                    
            
            
                | 763 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 764 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 765 |  |  |         return $this->_childPageRowHTML; | 
            
                                                                        
                            
            
                                    
            
            
                | 766 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  |     ############################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 769 |  |  |     # COPIED AND PATCHED FROM: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  |     # https://github.com/jonom/silverstripe-version-history/blob/master/code/VersionHistoryExtension.php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  |     ############################### | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 |  |  |     protected function getImageCMSFields() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  |         return []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 777 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 778 |  |  |     protected function getLayoutCMSFields() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  |         return []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 |  |  |     protected function getBackgroundFields() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  |         $a = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 |  |  |         if($this->IsPageRowWithBackgroundStyle()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 787 |  |  |             $a[] = DropdownField::create( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 788 |  |  |                 'BackgroundStyle', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 789 |  |  |                 'Background Style', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 790 |  |  |                 $this->BackgroundStyleOptionsWithBasics() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 791 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 |  |  |         if($this->IsPageRowWithBackgroundImage()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  |             $a[] = DropdownField::create( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  |                 'BackgroundImage', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 |  |  |                 'Background Image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  |                 $this->BackgroundImageOptionsWithBasics() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 |  |  |         return $a; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 |  |  |     protected function getPublishCMSFields() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 |  |  |             'ReadyForPublication', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 |  |  |             'Code' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 |  |  |     private $_bgImage = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 813 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  |     protected $_theSameBackgroundImageForAllOfThisTypeToDo = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 |  |  |     public function IsPageRowWithBackgroundImage() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  |         $prefix = $this->Config()->get('bg_image_prefix'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  |         $postfix = $this->Config()->get('bg_image_postfix'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  |         if($prefix || $postfix) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  |             $options = $this->BackgroundImageOptions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  |             if(count($options)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 823 |  |  |                 return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 826 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 |  |  |     public function HasBackgroundImage() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 |  |  |         return $this->BackgroundImage ? true : false; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 832 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  |     public function CalculatedBackgroundImage() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  |         if($this->_bgImage === null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 |  |  |             $this->_bgImage = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 |  |  |             if($this->BackgroundImage) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 |  |  |                 $prefix = $this->Config()->get('bg_image_prefix'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  |                 $postfix = $this->Config()->get('bg_image_postfix'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  |                 if($this->BackgroundImage == 'random') { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 |  |  |                     $a = $this->BackgroundImageOptions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 842 |  |  |                     if(count($a)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 |  |  |                         $this->_bgImage = $prefix.$a[array_rand($a)].$postfix; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 845 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 |  |  |                     $this->_bgImage = $prefix.$this->BackgroundImage.$postfix; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 848 |  |  |                 if($this->HasSameBackgroundImageForAllOfThisType() && $this->_theSameBackgroundImageForAllOfThisTypeToDo) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  |                     $this->_theSameBackgroundImageForAllOfThisTypeToDo = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  |                     Requirements::customCSS(' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  |                         section.row.'.strtolower($this->ClassName).' { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  |                             background-image: url('.$this->_bgImage.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  |                     '); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 |  |  |         return $this->_bgImage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 859 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  |     protected function HasSameBackgroundImageForAllOfThisType() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 |  |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  |     protected function BackgroundImageOptions() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  |         return $this->Config()->get('background_image_options'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 869 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 871 |  | View Code Duplication |     protected function BackgroundImageOptionsWithBasics() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  |         $a = ['' => '--- no background image selected ---'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  |             + $this->BackgroundImageOptions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 875 |  |  |         if(count($a) > 2) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 876 |  |  |             $a['random'] = 'Random Background Image'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 877 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 878 |  |  |         return $a; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 879 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 880 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  |     protected $_bgStyle = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  |     public function IsPageRowWithBackgroundStyle() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  |         $options = $this->BackgroundStyleOptions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  |         if(count($options)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  |             return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 890 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  |     public function CalculatedBackgroundStyle() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  |         if($this->_bgStyle === null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  |             $this->_bgStyle = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  |             if($this->BackgroundStyle) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  |                 if($this->BackgroundStyle == 'random') { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 898 |  |  |                     $a = $this->BackgroundStyleOptions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  |                     if(count($a)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 900 |  |  |                         $this->_bgStyle = $a[array_rand($a)]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  |                     $this->_bgStyle = $this->BackgroundStyle; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  |         return $this->_bgStyle; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 911 |  | View Code Duplication |     protected function BackgroundStyleOptionsWithBasics() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 912 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  |         $a = ['' => '--- default style ---'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  |             + $this->BackgroundstyleOptions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 |  |  |         if(count($a) > 2) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 |  |  |             $a['random'] = 'Random Background Style'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 |  |  |         return $a; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 |  |  |     protected function BackgroundStyleOptions() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 924 |  |  |         return $this->Config()->get('background_style_options'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 925 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 926 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 927 |  |  |  | 
            
                        
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.