コード例 #1
0
 function updateCMSFields(FieldList $fields)
 {
     $fields->insertBefore($uploadField = new SortableUploadField("FeaturedImages", _t("FeaturedImage.FeaturedImages", "Page Image(s)")), "Content");
     $uploadField->setFolderName(Config::inst()->get($this->owner->class, 'upload_folder'));
     //$uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
     $uploadField->setAllowedFileCategories('image');
     $uploadField->setAllowedMaxFileNumber(Config::inst()->get($this->owner->class, 'max_featured_images'));
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->makeFieldReadonly('Author');
     $attachments = new SortableUploadField('Attachments');
     //SortableUploadField class in in the "sortablefile" module
     $attachments->setFolderName('Uploads/BlogAttachments');
     $attachments->setAllowedExtensions(array('pdf', 'doc', 'docx', 'csv', 'ppt', 'pptx', 'xls', 'xlsx', 'odt', 'ods'));
     $fields->addFieldToTab("Root.Main", $attachments, "Content");
     return $fields;
 }
コード例 #3
0
ファイル: Page.php プロジェクト: neilcreagh/FuelCMS
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $gridFieldConfig = GridFieldConfig_RecordEditor::create();
     $gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
     $gridfield = new GridField("Pictures", "Pictures", $this->Pictures()->sort("SortOrder"), $gridFieldConfig);
     $fields->addFieldToTab('Root.Pictures', $gridfield);
     $fields->addFieldToTab('Root.Pictures', new DropdownField('Align', 'Align (relative to text)', singleton('Page')->dbObject('Align')->enumValues()), '');
     $gridFieldConfig2 = GridFieldConfig_RecordEditor::create();
     $gridFieldConfig2->addComponent(new GridFieldSortableRows('SortOrder'));
     $gridfield2 = new GridField("Videos", "Videos", $this->Videos()->sort("SortOrder"), $gridFieldConfig2);
     $fields->addFieldToTab('Root.Videos', $gridfield2);
     $fields->addFieldToTab('Root.Videos', new CheckboxField('Videobottom', 'Show all videos below'), '');
     $gridFieldConfig3 = GridFieldConfig_RecordEditor::create();
     $gridFieldConfig3->addComponent(new GridFieldSortableRows('SortOrder'));
     $gridfield3 = new GridField("ExtraContentBlocks", "ExtraContentBlocks", $this->ExtraContentBlocks()->sort("SortOrder"), $gridFieldConfig3);
     $fields->addFieldToTab('Root.Main', new LiteralField('Note1', '<br /><br />'), 'Metadata');
     // Spacer
     $fields->addFieldToTab('Root.Main', $gridfield3, 'Metadata');
     $fields->addFieldToTab('Root.Main', new LiteralField('Note2', '<br /><br />'), 'Metadata');
     // Spacer
     $fields->addFieldToTab('Root.Gallery', $uploadField = new SortableUploadField($name = 'GalleryImages', $title = 'Upload images (max 100 in total)'));
     $uploadField->setAllowedMaxFileNumber(100);
     $uploadField->setFolderName('GalleryImages');
     $uploadField->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
     $metatitle = new TextField('MetaTitle', 'Alternative Page Title');
     $metatitle->setRightTitle('Used in the browser window, search listings, bookmarks etc');
     $fields->addFieldToTab('Root.Main', $metatitle, 'MetaDescription');
     $CustomPreviewText = new TextAreaField('CustomPreviewText', 'Custom Preview Text');
     $CustomPreviewText->setRightTitle('Replaces the content summary for this page when shown on listing pages or search engines');
     $fields->addFieldToTab('Root.Main', $CustomPreviewText, 'MetaDescription');
     $fields->removeByName("Dependent");
     $fields->removeByName("MetaDescription");
     $fields->removeByName("ExtraMeta");
     return $fields;
 }
コード例 #4
0
ファイル: Product.php プロジェクト: vinstah/body
 /**
  * Set some CMS fields for managing Products
  * 
  * @see Page::getCMSFields()
  * @return FieldList
  */
 public function getCMSFields()
 {
     $shopConfig = ShopConfig::current_shop_config();
     $fields = parent::getCMSFields();
     //Main Product Image
     $fields->addFieldToTab("Root.Main", $uploadField = new UploadField("MainProductImage", "Main Product Image"));
     $uploadField->setFolderName('Store');
     $uploadField->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
     // Use SortableUploadField instead of UploadField!
     $imageField = new SortableUploadField('OtherImages', 'Other Product Images');
     $imageField->setFolderName('Store');
     $imageField->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
     $fields->addFieldToTab('Root.Main', $imageField);
     //Product fields
     $fields->addFieldToTab('Root.Main', new PriceField('Price'), 'Content');
     //Replace URL Segment field
     if ($this->ParentID == -1) {
         $urlsegment = new SiteTreeURLSegmentField("URLSegment", 'URLSegment');
         $baseLink = Controller::join_links(Director::absoluteBaseURL(), 'product/');
         $url = strlen($baseLink) > 36 ? "..." . substr($baseLink, -32) : $baseLink;
         $urlsegment->setURLPrefix($url);
         $fields->replaceField('URLSegment', $urlsegment);
     }
     if ($this->isInDB()) {
         //Product attributes
         $listField = new GridField('Attributes', 'Attributes', $this->Attributes(), GridFieldConfig_BasicSortable::create());
         $fields->addFieldToTab('Root.Attributes', $listField);
         //Product variations
         $attributes = $this->Attributes();
         if ($attributes && $attributes->exists()) {
             //Remove the stock level field if there are variations, each variation has a stock field
             $fields->removeByName('Stock');
             $variationFieldList = array();
             foreach ($attributes as $attribute) {
                 $variationFieldList['AttributeValue_' . $attribute->ID] = $attribute->Title;
             }
             $variationFieldList = array_merge($variationFieldList, singleton('Variation')->summaryFields());
             $config = GridFieldConfig_HasManyRelationEditor::create();
             $dataColumns = $config->getComponentByType('GridFieldDataColumns');
             $dataColumns->setDisplayFields($variationFieldList);
             $listField = new GridField('Variations', 'Variations', $this->Variations(), $config);
             $fields->addFieldToTab('Root.Variations', $listField);
         }
     }
     //Ability to edit fields added to CMS here
     $this->extend('updateProductCMSFields', $fields);
     if ($warning = ShopConfig::base_currency_warning()) {
         $fields->addFieldToTab('Root.Main', new LiteralField('BaseCurrencyWarning', '<p class="message warning">' . $warning . '</p>'), 'Title');
     }
     return $fields;
 }