| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | class GalleryImage extends DataObject implements RenderableAsPortlet | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |     public static $db = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |         'SortOrder' => 'Int', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |         'Title' => 'Varchar', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |     // One-to-one relationship with gallery page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     public static $has_one = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |         'Image' => 'Image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |         'GalleryPage' => 'GalleryPage', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     // tidy up the CMS by not showing these fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 | 1 |  |     public function getCMSFields() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 | 1 |  |         $fields = parent::getCMSFields(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 | 1 |  |         $fields->removeFieldFromTab('Root.Main', 'GalleryPageID'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 | 1 |  |         $fields->removeFieldFromTab('Root.Main', 'ExifRead'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 | 1 |  |         $fields->removeFieldFromTab('Root.Main', 'SortOrder'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 | 1 |  |         $fields->renameField('Title', _t('GalleryImage.TITLE', 'Title')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 | 1 |  |         $fields->renameField('Image', _t('GalleryImage.IMAGE', 'Image')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 | 1 |  |         return $fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     // Tell the datagrid what fields to show in the table | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     public static $summary_fields = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         'ID' => 'ID', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         'Title' => 'Title', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         'Thumbnail' => 'Thumbnail', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     // this function creates the thumnail for the summary fields to use | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 1 |  |     public function getThumbnail() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 1 |  |         return $this->Image()->CMSThumbnail(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 1 |  |     public function getPortletTitle() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 | 1 |  |         return $this->Title; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     * An accessor method for an image for a portlet. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     * @example | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     * <code> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     *  return $this->NewsItemImage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     * </code> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 1 |  |     public function getPortletImage() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 1 |  |         return $this->Image(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     * An accessor for text associated with the portlet. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     * @example | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     * <code> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     * return $this->Summary | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     * </code> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 | 1 |  |     public function getPortletCaption() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 1 |  |         return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                        
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.