コード例 #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
 /**
  * Create an uploadfield that can be used in a translation context.
  * Attaching, deleting, sorting will only be allowed in the master language.
  * If the page is translated, only allow editing of file title/content (eg. translate)
  * @param string $name the field name
  * @param $collection the file collection
  * @param string|null $title the field label (title)
  * @param string|null $sortField field to sort items on (in translation context). Set this
  *  parameter to null if there's no sorting
  * @return UploadField instance or null
  */
 public static function translatable_uploadfield($name, SS_List $collection, $title = null, $sortField = 'SortOrder')
 {
     $uploadField = null;
     // create two different upload fields, depending on locale
     if (Translatable::default_locale() == Translatable::get_current_locale()) {
         // for the master language, create a regular sortable upload field
         if (class_exists('SortableUploadField')) {
             $uploadField = SortableUploadField::create($name, $title, $collection);
         } else {
             $uploadField = UploadField::create($name, $title, $collection);
         }
     } else {
         // for all other languages, access the files in read-only
         if ($sortField) {
             $uploadField = UploadField::create('Translate.' . $name, $title, $collection->Sort($sortField));
         } else {
             $uploadField = UploadField::create('Translate.' . $name, $title, $collection);
         }
         // prevent uploads
         $uploadField->setConfig('canUpload', false);
         // prevent attaching
         $uploadField->setConfig('canAttachExisting', false);
         // use a custom button-template with only a edit-button
         $uploadField->setTemplateFileButtons('UploadField_TranslationButtons');
     }
     if ($uploadField) {
         $uploadField->setFileEditFields('getUploadEditorFields');
     }
     return $uploadField;
 }
コード例 #4
0
 /**
  * CMS Fields
  * @return array
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldsToTab("Root.Main", array(SortableUploadField::create('Images', 'Current Image(s)')));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
コード例 #5
0
 public function getCMSFields()
 {
     $fields = new FieldList([TextField::create('Title')]);
     if ($this->exists()) {
         $folderName = 'Documents';
         $config = $this->Page()->exists() ? $this->Page()->config()->get('page_documents') : null;
         if (is_array($config)) {
             if (isset($config['folder'])) {
                 $folderName = $config['folder'];
             }
             if (isset($config['section']) && $config['section']) {
                 $filter = new URLSegmentFilter();
                 $section = implode('-', array_map(function ($string) {
                     return ucfirst($string);
                 }, explode('-', $filter->filter($this->Title))));
                 $folderName .= '/' . $section;
             }
         }
         $fields->push(SortableUploadField::create('Documents', 'Documents')->setDescription('Drag documents by thumbnail to sort')->setFolderName($folderName));
     } else {
         $fields->push(LiteralField::create('DocumentsNotSaved', '<p>Save category to add documents</p>'));
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
コード例 #6
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('HideDescription');
     $upload_folder = Controller::join_links("gallery", $this->ID);
     $sortable_field = SortableUploadField::create('Images', 'Images to associate with this page')->setFolderName($upload_folder);
     $fields->addFieldToTab("Root.Gallery", $sortable_field);
     return $fields;
 }
 /**
  * CMS Fields
  * @return array
  */
 public function getCMSFields()
 {
     $linksGridConfig = GridFieldConfig_RelationEditor::create();
     if ($this->Links()->Count() > 0) {
         $linksGridConfig->addComponent(new GridFieldOrderableRows());
     }
     $fields = parent::getCMSFields();
     $fields->addFieldsToTab("Root.Main", array(TextareaField::create('Title')->setRows(1), HTMLEditorField::create('Content'), SortableUploadField::create('Images', 'Current Image(s)'), GridField::create('Links', 'Links', $this->Links(), $linksGridConfig)));
     return $fields;
 }
コード例 #8
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $uploadField = null;
     if (class_exists('SortableUploadField')) {
         $uploadField = SortableUploadField::create('Images', _t('ImageBlock.IMAGES', 'Images'));
     } else {
         $uploadField = UploadField::create('Images', _t('ImageBlock.IMAGES', 'Images'));
     }
     $fields->addFieldToTab('Root.Main', $uploadField);
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
コード例 #9
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;
 }
コード例 #10
0
 /**
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     //adding upload field - if item has already been saved
     //AssetsFolderID is set by the uploaddirrules module
     if ($this->owner->ID && $this->owner->AssetsFolderID != 0) {
         //this is the default, for non multi-language sites
         if (!class_exists('Translatable') || $this->owner->Locale == Translatable::default_locale()) {
             //The upload directory is expected to have been set in {@see UploadDirRules},
             //This should be handled on the object that uses this extension!
             $imageField = SortableUploadField::create('Images', '')->setAllowedFileCategories('image');
             $fields->addFieldToTab('Root.Images', $imageField);
         } else {
             //Note that images are administered in the original language
             $orig = $this->owner->getTranslation(Translatable::default_locale());
             $html = sprintf('<a href="%s">%s</a>', Controller::join_links($orig->CMSEditLink(), '?locale=' . $orig->Locale), 'Images are administered through ' . i18n::get_locale_name($orig->Locale));
             $fields->addFieldToTab('Root.Images', LiteralField::create('ImagesDesc', $html));
         }
     }
 }
コード例 #11
0
 /**
  * Add CMS Fields for Gallery
  *
  * @var FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     $fields->addFieldToTab('Root.Gallery', $GalleryImages = SortableUploadField::create('Images', 'Gallery Images'));
     $GalleryImages->setFolderName('gallery-images');
     $GalleryImages->getValidator()->setAllowedExtensions('png', 'gif', 'jpeg', 'jpg');
 }
コード例 #12
0
 public function getCMSFields()
 {
     $fields = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main', TextField::create("Title", $this->fieldLabel('Title')), TextField::create("URLSegment", $this->fieldLabel('URLSegment')), NumericField::create("Price", $this->fieldLabel('Price')), HTMLEditorField::create('Description', $this->fieldLabel('Price'))->setRows(20)->addExtraClass('stacked'), ToggleCompositeField::create('AdditionalData', 'Additional Data', array(NumericField::create("Quantity", $this->fieldLabel('Quantity')), TextField::create("SKU", $this->fieldLabel('SKU')), TextField::create("PackSize", $this->fieldLabel('PackSize')), TextField::create("Weight", $this->fieldLabel('Weight'))))->setHeadingLevel(4), ToggleCompositeField::create('Metadata', _t('CommerceAdmin.MetadataToggle', 'Metadata'), array($metaFieldDesc = TextareaField::create("MetaDescription", $this->fieldLabel('MetaDescription')), $metaFieldExtra = TextareaField::create("ExtraMeta", $this->fieldLabel('ExtraMeta'))))->setHeadingLevel(4), CheckboxField::create("Disabled", $this->fieldLabel('Disabled'))), $tabImages = new Tab('Images', SortableUploadField::create('Images', $this->fieldLabel('Images'), $this->Images()))));
     // Help text for MetaData on page content editor
     $metaFieldDesc->setRightTitle(_t('CommerceAdmin.MetaDescHelp', "Search engines use this content for displaying search results (although it will not influence their ranking)."))->addExtraClass('help');
     $metaFieldExtra->setRightTitle(_t('CommerceAdmin.MetaExtraHelp', "HTML tags for additional meta information. For example &lt;meta name=\"customName\" content=\"your custom content here\" /&gt;"))->addExtraClass('help');
     // Once product is saved, deal with more complex associations
     if ($this->ID) {
         // Deal with product features
         $add_button = new GridFieldAddNewInlineButton('toolbar-header-left');
         $add_button->setTitle('Add Attribute');
         $attributes_field = new GridField('Attributes', '', $this->Attributes(), GridFieldConfig::create()->addComponent(new GridFieldButtonRow('before'))->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldTitleHeader())->addComponent(new GridFieldEditableColumns())->addComponent(new GridFieldDeleteAction())->addComponent($add_button)->addComponent(new GridFieldOrderableRows('Sort')));
         $fields->addFieldToTab('Root.Attributes', $attributes_field);
         // Deal with customisations
         $add_button = new GridFieldAddNewButton('toolbar-header-left');
         $add_button->setButtonName('Add Customisation');
         $custom_config = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), $add_button, new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(20), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm(), new GridFieldOrderableRows('Sort'));
         $custom_field = GridField::create('Customisations', '', $this->Customisations(), $custom_config);
         $fields->addFieldToTab('Root.Customisations', $custom_field);
         $related_field = GridField::create('RelatedProducts', "", $this->RelatedProducts(), GridFieldConfig_RelationEditor::create());
         $fields->addFieldToTab('Root.Related', $related_field);
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
コード例 #13
0
 /**
  * Add the "Images" tab to the content form of the page.
  *
  * The images are linked to the page with a many-many relationship,
  * so if an image is shared among different carousels there is no
  * need to upload it multiple times.
  *
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $field = SortableUploadField::create('Images', _t('CarouselPage.db_Images'));
     $field->setFolderName($this->getClassFolder());
     $field->setFileEditFields('getCarouselEditFields');
     $root = $fields->fieldByName('Root');
     $tab = $root->fieldByName('Images');
     if (!$tab) {
         $tab = Tab::create('Images');
         $tab->setTitle(_t('CarouselPage.db_Images'));
         $root->insertAfter($tab, 'Main');
     }
     $tab->push($field);
     return $fields;
 }
コード例 #14
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;
 }
コード例 #15
0
 public function getCMSFields()
 {
     // Get a list of available product classes
     $classnames = array_values(ClassInfo::subclassesFor("Product"));
     $product_types = array();
     foreach ($classnames as $classname) {
         $instance = singleton($classname);
         $product_types[$classname] = $instance->i18n_singular_name();
     }
     // If CMS Installed, use URLSegmentField, otherwise use text
     // field for URL
     if (class_exists('SiteTreeURLSegmentField')) {
         $baseLink = Controller::join_links(Director::absoluteBaseURL());
         $url_field = SiteTreeURLSegmentField::create("URLSegment");
         $url_field->setURLPrefix($baseLink);
     } else {
         $url_field = TextField::create("URLSegment");
     }
     $fields = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main', TextField::create("Title", $this->fieldLabel('Title')), $url_field, HTMLEditorField::create('Content', $this->fieldLabel('Content'))->setRows(20)->addExtraClass('stacked'), ToggleCompositeField::create('Metadata', _t('CatalogueAdmin.MetadataToggle', 'Metadata'), array($metaFieldDesc = TextareaField::create("MetaDescription", $this->fieldLabel('MetaDescription')), $metaFieldExtra = TextareaField::create("ExtraMeta", $this->fieldLabel('ExtraMeta'))))->setHeadingLevel(4)), $tabSettings = new Tab('Settings', NumericField::create("BasePrice", _t("Catalogue.Price", "Price")), TextField::create("StockID", $this->fieldLabel('StockID'))->setRightTitle(_t("Catalogue.StockIDHelp", "For example, a product SKU")), DropdownField::create("TaxRateID", $this->fieldLabel('TaxRate'), TaxRate::get()->map())->setEmptyString(_t("Catalogue.None", "None")), TreeMultiSelectField::create("Categories", null, "CatalogueCategory"), DropdownField::create("ClassName", _t("CatalogueAdmin.ProductType", "Type of product"), $product_types))));
     // Help text for MetaData on page content editor
     $metaFieldDesc->setRightTitle(_t('CatalogueAdmin.MetaDescHelp', "Search engines use this content for displaying search results (although it will not influence their ranking)."))->addExtraClass('help');
     $metaFieldExtra->setRightTitle(_t('CatalogueAdmin.MetaExtraHelp', "HTML tags for additional meta information. For example &lt;meta name=\"customName\" content=\"your custom content here\" /&gt;"))->addExtraClass('help');
     if ($this->ID) {
         $fields->addFieldToTab('Root.Images', SortableUploadField::create('Images', $this->fieldLabel('Images'), $this->Images()));
         $fields->addFieldToTab('Root.Related', GridField::create('RelatedProducts', "", $this->RelatedProducts(), new GridFieldConfig_CatalogueRelated("Product", null, 'SortOrder')));
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 public function getCMSFields()
 {
     // Get a list of available product classes
     $classnames = ClassInfo::getValidSubClasses("CatalogueProduct");
     $product_array = array();
     foreach ($classnames as $classname) {
         if ($classname != "CatalogueProduct") {
             $description = Config::inst()->get($classname, 'description');
             if ($classname == 'Product' && !$description) {
                 $description = self::config()->description;
             }
             $description = $description ? $classname . ' - ' . $description : $classname;
             $product_array[$classname] = $description;
         }
     }
     // If we are creating a product, let us choose the product type
     if (!$this->ID) {
         $fields = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main', HiddenField::create("Title")->setValue(_t("Catalogue.NewProduct", "New Product")), ProductTypeField::create("ClassName", _t("Catalogue.SelectProductType", "Select a type of Product"), $product_array))));
     } else {
         // If CMS Installed, use URLSegmentField, otherwise use text
         // field for URL
         if (class_exists('SiteTreeURLSegmentField')) {
             $baseLink = Controller::join_links(Director::absoluteBaseURL());
             $url_field = SiteTreeURLSegmentField::create("URLSegment");
             $url_field->setURLPrefix($baseLink);
         } else {
             $url_field = TextField::create("URLSegment");
         }
         $fields = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main', TextField::create("Title", $this->fieldLabel('Title')), $url_field, HTMLEditorField::create('Content', $this->fieldLabel('Content'))->setRows(20)->addExtraClass('stacked'), ToggleCompositeField::create('Metadata', _t('CatalogueAdmin.MetadataToggle', 'Metadata'), array($metaFieldDesc = TextareaField::create("MetaDescription", $this->fieldLabel('MetaDescription')), $metaFieldExtra = TextareaField::create("ExtraMeta", $this->fieldLabel('ExtraMeta'))))->setHeadingLevel(4)), $tabSettings = new Tab('Settings', NumericField::create("BasePrice", _t("Catalogue.Price", "Price")), TextField::create("StockID", $this->fieldLabel('StockID'))->setRightTitle(_t("Catalogue.StockIDHelp", "For example, a product SKU")), DropdownField::create("TaxRateID", $this->fieldLabel('TaxRate'), TaxRate::get()->map())->setEmptyString(_t("Catalogue.None", "None")), TreeMultiSelectField::create("Categories", null, "CatalogueCategory"), CheckboxField::create("Disabled", _t("Catalogue.DisableProduct", "Disable this product (will not appear on shopfront)")), DropdownField::create("ClassName", _t("CatalogueAdmin.ProductType", "Type of product"), $product_array)), $tabImages = new Tab('Images', SortableUploadField::create('Images', $this->fieldLabel('Images'), $this->Images()))));
         // Help text for MetaData on page content editor
         $metaFieldDesc->setRightTitle(_t('CatalogueAdmin.MetaDescHelp', "Search engines use this content for displaying search results (although it will not influence their ranking)."))->addExtraClass('help');
         $metaFieldExtra->setRightTitle(_t('CatalogueAdmin.MetaExtraHelp', "HTML tags for additional meta information. For example &lt;meta name=\"customName\" content=\"your custom content here\" /&gt;"))->addExtraClass('help');
         $fields->addFieldToTab('Root.Related', GridField::create('RelatedProducts', "", $this->RelatedProducts(), GridFieldConfig_RelationEditor::create()));
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
コード例 #17
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $field = SortableUploadField::create('Images', _t('CarouselPage.db_Images'));
     $field->setFolderName($this->getClassFolder());
     // Enable HTML caption handling if captions are enabled
     if ($this->Captions) {
         $caption = CarouselCaptionField::create('Content', _t('CarouselPage.Caption'));
         $field->setFileEditFields(FieldList::create($caption));
         unset($caption);
     }
     $root = $fields->fieldByName('Root');
     $tab = $root->fieldByName('Images');
     if (!$tab) {
         $tab = Tab::create('Images');
         $tab->setTitle(_t('CarouselPage.db_Images'));
         $root->insertAfter($tab, 'Main');
     }
     $tab->push($field);
     return $fields;
 }