| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | class VimeoDOD extends DataExtension | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |     private static $has_one = array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |         "VimeoDataObject" => "VimeoDataObject" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     private static $exclude_vimeo_from_page_classes = array(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     private static $include_vimeo_in_page_classes = array(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     public function updateCMSFields(FieldList $fields) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |         if ($this->HasVimeo()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |             $listObject = VimeoDataObject::get(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |             if ($listObject->count()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |                 $tab = _t("VimeoDOD.TAB", "Root.Vimeo"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |                 $list = array( 0 => _t("VimeoDOD.EMPTYSTRING", "--- select vimeo video ---")) + $listObject->map($index = 'ID', $titleField = 'Title')->toArray(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |                 $fields->addFieldToTab($tab, new DropdownField("VimeoDataObjectID", _t("VimeoDOD.URLFIELD", "Video"), $list)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |                 $linkToModelAdmin = _t("VimeoDOD.LINKTOMODELADMIN", "To edit your videos, please go to <a href=\"/admin/vimeos\">Vimeo Editing Page</a>."); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |                 $fields->addFieldToTab($tab, new LiteralField("VimeoDataObjectIDEDIT", "<p>$linkToModelAdmin</p>")); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         return $fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |     public function HasVimeo() | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |         $hasVimeo = true; | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |         $includeClasses = $this->owner->Config()->get("include_vimeo_in_page_classes"); | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |         if (count($includeClasses)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |             if (!in_array($this->owner->ClassName, Config::inst()->get("VimeoDOD", "include_vimeo_in_page_classes"))) { | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |                 $hasVimeo = false; | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |         $excludeClasses = Config::inst()->get("VimeoDOD", "exclude_vimeo_from_page_classes"); | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |         if (count($excludeClasses)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |             if (in_array($this->owner->ClassName, $excludeClasses)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |                 $hasVimeo = false; | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |         return $hasVimeo; | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     public function VimeosInThisSection() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         return Page::get()->filter(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             "ParentID" => array(intval($this->owner->ParentID), intval($this->owner->ID)), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             "VimeoDataObjectID:GreaterThan" => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             "ShowInSearch" => 1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 54 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 55 |  |  |  | 
            
                        
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.