Advertisement
Guest User

Page Class

a guest
May 5th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.17 KB | None | 0 0
  1. class Page extends SiteTree {
  2.  
  3.     private static $db = array(
  4.         'showGallery' => 'Boolean',
  5.         'bgColor' => 'VarChar(7)'
  6.     );
  7.  
  8.     private static $has_one = array(
  9.         'Background' => 'Image'
  10.     );
  11.  
  12.      public static $has_many = array(
  13.     'GalleryImages' => 'GalleryImage'
  14.     );
  15.  
  16.  
  17.     // Create Grid Field
  18.     public function getCMSFields() {
  19.         $fields = parent::getCMSFields();
  20.  
  21.         $gridFieldConfig = GridFieldConfig::create()->addComponents(
  22.           new GridFieldToolbarHeader(),
  23.           new GridFieldAddNewButton('toolbar-header-right'),
  24.           new GridFieldSortableHeader(),
  25.           new GridFieldDataColumns(),
  26.           new GridFieldPaginator(10),
  27.           new GridFieldEditButton(),
  28.           new GridFieldDeleteAction(),
  29.           new GridFieldDetailForm()
  30.         );
  31.  
  32.         $gridField = new GridField("GalleryImages", "Image Gallery", $this->GalleryImages(), $gridFieldConfig);
  33.         $fields->addFieldToTab("Root.Gallery", $gridField);
  34.         $fields->addFieldToTab("Root.Main", new UploadField('Background'));
  35.         $fields->addFieldToTab('Root.Main', new TextField('bgColor', 'Background Color'));
  36.         $fields->addFieldToTab('Root.Main', new CheckboxField('showGallery', 'Auto display gallery'));
  37.  
  38.         return $fields;
  39.     }
  40.  
  41.     static $api_access = true;
  42. }
  43.  
  44. class Page_Controller extends ContentController {
  45.  
  46.     /**
  47.      * An array of actions that can be accessed via a request. Each array element should be an action name, and the
  48.      * permissions or conditions required to allow the user to access it.
  49.      *
  50.      * <code>
  51.      * array (
  52.      *     'action', // anyone can access this action
  53.      *     'action' => true, // same as above
  54.      *     'action' => 'ADMIN', // you must have ADMIN permissions to access this action
  55.      *     'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
  56.      * );
  57.      * </code>
  58.      *
  59.      * @var array
  60.      */
  61.     private static $allowed_actions = array ();
  62.  
  63.     public function init() {
  64.         parent::init();
  65.         // You can include any CSS or JS required by your project here.
  66.         // See: http://doc.silverstripe.org/framework/en/reference/requirements
  67.         // Ejemplo: Requirements::javascript("cms/javascript/LeftAndMain.js");
  68.         // Ejemplo: Requirements::css("cms/css/TreeSelector.css");
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement