当前位置: 首页>>代码示例>>PHP>>正文


PHP GridField::setAttribute方法代码示例

本文整理汇总了PHP中GridField::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP GridField::setAttribute方法的具体用法?PHP GridField::setAttribute怎么用?PHP GridField::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GridField的用法示例。


在下文中一共展示了GridField::setAttribute方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getHTMLFragments

 /**
  * @param GridField $field
  */
 public function getHTMLFragments($field)
 {
     VersionedGridFieldExtensions::include_requirements();
     $field->addExtraClass('ss-versioned-gridfield-orderable');
     $field->setAttribute('data-url-reorder', $field->Link('reorder'));
     $field->setAttribute('data-url-movetopage', $field->Link('movetopage'));
 }
开发者ID:phil-quinn,项目名称:silverstripe-versioneddataobjects,代码行数:10,代码来源:VersionedGridFieldOrderableRows.php

示例2: getHTMLFragments

 /**
  * @param GridField $field
  */
 public function getHTMLFragments($field)
 {
     self::include_requirements();
     // set ajax urls / vars
     $field->addExtraClass('ss-gridfield-blockenhancements');
     //		$field->setAttribute('data-url-area-assignment', $field->Link('area_assignment'));
     $field->setAttribute('data-url-blocktype-assignment', $field->Link('blocktype_assignment'));
     //		$field->setAttribute('data-block-area-none-title', Config::inst()->get(get_class(), 'unassigned_area_description'));
     // add no-chozen to dropdown
     //        $field->getConfig()->getComponentByType('GridFieldAddNewMultiClass')->
     //        $field->getConfig()->getComponentByType('GridFieldDetailForm')->setAttribute('data-project-dir', project());
 }
开发者ID:micschk,项目名称:silverstripe-block_enhancements,代码行数:15,代码来源:GF_BlockEnhancements.php

示例3: MediaForm

 /**
  * Return a {@link Form} instance allowing a user to
  * add images and flash objects to the TinyMCE content editor.
  *  
  * @return Form
  */
 public function MediaForm()
 {
     // TODO Handle through GridState within field - currently this state set too late to be useful here (during
     // request handling)
     $parentID = $this->getAttachParentID();
     $fileFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldFilterHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(5), new GridFieldDeleteAction(), new GridFieldDetailForm());
     $fileField = new GridField('Files', false, null, $fileFieldConfig);
     $fileField->setList($this->getFiles($parentID));
     $fileField->setAttribute('data-selectable', true);
     $fileField->setAttribute('data-multiselect', true);
     $columns = $fileField->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('CMSThumbnail' => false, 'Name' => _t('File.Name')));
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span>' . '<strong class="title">%s</strong></span>';
     $fromCMS = new CompositeField(new LiteralField('headerSelect', '<h4>' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.FindInFolder', 'Find in Folder')) . '</h4>'), $select = TreeDropdownField::create('ParentID', "", 'Folder')->addExtraClass('noborder')->setValue($parentID), $fileField);
     $fromCMS->addExtraClass('content ss-uploadfield');
     $select->addExtraClass('content-select');
     $fromWeb = new CompositeField(new LiteralField('headerURL', '<h4>' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.ADDURL', 'Add URL')) . '</h4>'), $remoteURL = new TextField('RemoteURL', 'http://'), new LiteralField('addURLImage', '<button class="action ui-action-constructive ui-button field add-url" data-icon="addMedia">' . _t('HtmlEditorField.BUTTONADDURL', 'Add url') . '</button>'));
     $remoteURL->addExtraClass('remoteurl');
     $fromWeb->addExtraClass('content ss-uploadfield');
     Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
     $computerUploadField = Object::create('UploadField', 'AssetUploadField', '');
     $computerUploadField->setConfig('previewMaxWidth', 40);
     $computerUploadField->setConfig('previewMaxHeight', 30);
     $computerUploadField->addExtraClass('ss-assetuploadfield');
     $computerUploadField->removeExtraClass('ss-uploadfield');
     $computerUploadField->setTemplate('HtmlEditorField_UploadField');
     $computerUploadField->setFolderName(Config::inst()->get('Upload', 'uploads_folder'));
     $tabSet = new TabSet("MediaFormInsertMediaTabs", Tab::create('FromComputer', _t('HtmlEditorField.FROMCOMPUTER', 'From your computer'), $computerUploadField)->addExtraClass('htmleditorfield-from-computer'), Tab::create('FromWeb', _t('HtmlEditorField.FROMWEB', 'From the web'), $fromWeb)->addExtraClass('htmleditorfield-from-web'), Tab::create('FromCms', _t('HtmlEditorField.FROMCMS', 'From the CMS'), $fromCMS)->addExtraClass('htmleditorfield-from-cms'));
     $tabSet->addExtraClass('cms-tabset-primary');
     $allFields = new CompositeField($tabSet, new LiteralField('headerEdit', '<h4 class="field noborder header-edit">' . sprintf($numericLabelTmpl, '2', _t('HtmlEditorField.ADJUSTDETAILSDIMENSIONS', 'Details &amp; dimensions')) . '</h4>'), $editComposite = new CompositeField(new LiteralField('contentEdit', '<div class="content-edit ss-uploadfield-files files"></div>')));
     $allFields->addExtraClass('ss-insert-media');
     $headings = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.INSERTMEDIA', 'Insert Media')) . sprintf('<h3 class="htmleditorfield-mediaform-heading update">%s</h3>', _t('HtmlEditorField.UpdateMEDIA', 'Update Media'))));
     $headings->addExtraClass('cms-content-header');
     $editComposite->addExtraClass('ss-assetuploadfield');
     $fields = new FieldList($headings, $allFields);
     $actions = new FieldList(FormAction::create('insertmedia', _t('HtmlEditorField.BUTTONINSERT', 'Insert'))->addExtraClass('ss-ui-action-constructive media-insert')->setAttribute('data-icon', 'accept')->setUseButtonTag(true), FormAction::create('insertmedia', _t('HtmlEditorField.BUTTONUpdate', 'Update'))->addExtraClass('ss-ui-action-constructive media-update')->setAttribute('data-icon', 'accept')->setUseButtonTag(true));
     $form = new Form($this->controller, "{$this->name}/MediaForm", $fields, $actions);
     $form->unsetValidator();
     $form->disableSecurityToken();
     $form->loadDataFrom($this);
     $form->addExtraClass('htmleditorfield-form htmleditorfield-mediaform cms-dialog-content');
     // TODO Re-enable once we remove $.metadata dependency which currently breaks the JS due to $.ui.widget
     // $form->setAttribute('data-urlViewfile', $this->controller->Link($this->name));
     // Allow other people to extend the fields being added to the imageform
     $this->extend('updateMediaForm', $form);
     return $form;
 }
开发者ID:hemant-chakka,项目名称:awss,代码行数:53,代码来源:HtmlEditorField.php

示例4: getListField

 /**
  * @param $folderID The ID of the folder to display.
  * @return FormField
  */
 protected function getListField($folderID)
 {
     // Generate the folder selection field.
     $folderField = new TreeDropdownField('ParentID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder');
     $folderField->setValue($folderID);
     // Generate the file list field.
     $config = GridFieldConfig::create();
     $config->addComponent(new GridFieldSortableHeader());
     $config->addComponent(new GridFieldFilterHeader());
     $config->addComponent($columns = new GridFieldDataColumns());
     $columns->setDisplayFields(array('StripThumbnail' => '', 'Name' => 'Name', 'Title' => 'Title'));
     $config->addComponent(new GridFieldPaginator(8));
     // If relation is to be autoset, we need to make sure we only list compatible objects.
     $baseClass = $this->parent->getRelationAutosetClass();
     // Create the data source for the list of files within the current directory.
     $files = DataList::create($baseClass)->filter('ParentID', $folderID);
     $fileField = new GridField('Files', false, $files, $config);
     $fileField->setAttribute('data-selectable', true);
     if ($this->parent->getAllowedMaxFileNumber() !== 1) {
         $fileField->setAttribute('data-multiselect', true);
     }
     $selectComposite = new CompositeField($folderField, $fileField);
     return $selectComposite;
 }
开发者ID:hemant-chakka,项目名称:awss,代码行数:28,代码来源:UploadField.php

示例5: MediaForm

	/**
	 * Return a {@link Form} instance allowing a user to
	 * add images and flash objects to the TinyMCE content editor.
	 *  
	 * @return Form
	 */
	function MediaForm() {
		// TODO Handle through GridState within field - currently this state set too late to be useful here (during request handling)
		$parentID = $this->controller->getRequest()->requestVar('ParentID');

		$fileFieldConfig = GridFieldConfig::create();
		$fileFieldConfig->addComponent(new GridFieldSortableHeader());
		$fileFieldConfig->addComponent(new GridFieldFilterHeader());
		$fileFieldConfig->addComponent(new GridFieldDataColumns());
		$fileFieldConfig->addComponent(new GridFieldPaginator(5));
		$fileField = new GridField('Files', false, null, $fileFieldConfig);
		$fileField->setList($this->getFiles($parentID));
		$fileField->setAttribute('data-selectable', true);
		$fileField->setAttribute('data-multiselect', true);
		$columns = $fileField->getConfig()->getComponentByType('GridFieldDataColumns');
		$columns->setDisplayFields(array(
			'CMSThumbnail' => false,
			'Name' => _t('File.Name'),
		));
		
		$numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span><strong class="title">%s</strong></span>';

		$fromCMS = new CompositeField(
			new LiteralField('headerSelect', '<h4 class="field header-select">' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.Find', 'Find')) . '</h4>'),
				$selectComposite = new CompositeField(
					new TreeDropdownField('ParentID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder'),
					$fileField
				)
		);

		$fromCMS->addExtraClass('content');
		$selectComposite->addExtraClass('content-select');

		Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
		$computerUploadField = Object::create('UploadField', 'AssetUploadField', '');
		$computerUploadField->setConfig('previewMaxWidth', 40);
		$computerUploadField->setConfig('previewMaxHeight', 30);
		$computerUploadField->addExtraClass('ss-assetuploadfield');
		$computerUploadField->removeExtraClass('ss-uploadfield');
		$computerUploadField->setTemplate('HtmlEditorField_UploadField');
		$computerUploadField->setFolderName(Upload::$uploads_folder);

		$tabSet = new TabSet(
			"MediaFormInsertImageTabs",
			new Tab(
				_t('HtmlEditorField.FROMCOMPUTER','From your computer'),
				$computerUploadField
			),
			new Tab(
				_t('HtmlEditorField.FROMCMS','From the CMS'),
				$fromCMS
			)
		);

		$allFields = new CompositeField(
			$tabSet,
			new LiteralField('headerEdit', '<h4 class="field header-edit">' . sprintf($numericLabelTmpl, '2', _t('HtmlEditorField.EditDetails', 'Edit details')) . '</h4>'),
			$editComposite = new CompositeField(
				new LiteralField('contentEdit', '<div class="content-edit"></div>')
			)
		);

		$fields = new FieldList(
			new LiteralField(
				'Heading',
				sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.INSERTIMAGE', 'Insert Image')).
				sprintf('<h3 class="htmleditorfield-mediaform-heading update">%s</h3>', _t('HtmlEditorField.UpdateIMAGE', 'Update Image'))
			),
			$allFields
		);
		
		$actions = new FieldList(
			FormAction::create('insertimage', _t('HtmlEditorField.BUTTONINSERT', 'Insert'))
				->addExtraClass('ss-ui-action-constructive image-insert')
				->setAttribute('data-icon', 'accept')
				->setUseButtonTag(true),
			FormAction::create('insertimage', _t('HtmlEditorField.BUTTONUpdate', 'Update'))
				->addExtraClass('ss-ui-action-constructive image-update')
				->setAttribute('data-icon', 'accept')
				->setUseButtonTag(true)
		);

		$form = new Form(
			$this->controller,
			"{$this->name}/MediaForm",
			$fields,
			$actions
		);
		

		$form->unsetValidator();
		$form->disableSecurityToken();
		$form->loadDataFrom($this);
		$form->addExtraClass('htmleditorfield-form htmleditorfield-mediaform cms-dialog-content');
		// TODO Re-enable once we remove $.metadata dependency which currently breaks the JS due to $.ui.widget
//.........这里部分代码省略.........
开发者ID:redema,项目名称:sapphire,代码行数:101,代码来源:HtmlEditorField.php

示例6: getEditForm

 public function getEditForm($id = null, $fields = null)
 {
     $form = parent::getEditForm($id, $fields);
     $folder = $id && is_numeric($id) ? DataObject::get_by_id('Folder', $id, false) : $this->currentPage();
     $fields = $form->Fields();
     $title = $folder && $folder->exists() ? $folder->Title : _t('AssetAdmin.FILES', 'Files');
     $fields->push(new HiddenField('ID', false, $folder->ID));
     // File listing
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldFilterHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(15), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm());
     $gridField = new GridField('File', $title, $this->getList(), $gridFieldConfig);
     $columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('StripThumbnail' => '', 'Title' => _t('File.Name'), 'Created' => _t('AssetAdmin.CREATED', 'Date'), 'Size' => _t('AssetAdmin.SIZE', 'Size')));
     $columns->setFieldCasting(array('Created' => 'Date->Nice'));
     $gridField->setAttribute('data-url-folder-template', Controller::join_links($this->Link('show'), '%s'));
     if ($folder->canCreate()) {
         $uploadBtn = new LiteralField('UploadButton', sprintf('<a class="ss-ui-button ss-ui-action-constructive cms-panel-link" data-pjax-target="Content" data-icon="drive-upload" href="%s">%s</a>', Controller::join_links(singleton('CMSFileAddController')->Link(), '?ID=' . $folder->ID), _t('Folder.UploadFilesButton', 'Upload')));
     } else {
         $uploadBtn = null;
     }
     if (!$folder->hasMethod('canAddChildren') || $folder->hasMethod('canAddChildren') && $folder->canAddChildren()) {
         // TODO Will most likely be replaced by GridField logic
         $addFolderBtn = new LiteralField('AddFolderButton', sprintf('<a class="ss-ui-button ss-ui-action-constructive cms-add-folder-link" data-icon="add" data-url="%s" href="%s">%s</a>', Controller::join_links($this->Link('AddForm'), '?' . http_build_query(array('action_doAdd' => 1, 'ParentID' => $folder->ID, 'SecurityID' => $form->getSecurityToken()->getValue()))), Controller::join_links($this->Link('addfolder'), '?ParentID=' . $folder->ID), _t('Folder.AddFolderButton', 'Add folder')));
     } else {
         $addFolderBtn = '';
     }
     if ($folder->canEdit()) {
         $syncButton = new LiteralField('SyncButton', sprintf('<a class="ss-ui-button ss-ui-action ui-button-text-icon-primary ss-ui-button-ajax" data-icon="arrow-circle-double" title="%s" href="%s">%s</a>', _t('AssetAdmin.FILESYSTEMSYNCTITLE', 'Update the CMS database entries of files on the filesystem. Useful when new files have been uploaded outside of the CMS, e.g. through FTP.'), $this->Link('doSync'), _t('FILESYSTEMSYNC', 'Sync files')));
     } else {
         $syncButton = null;
     }
     // Move existing fields to a "details" tab, unless they've already been tabbed out through extensions.
     // Required to keep Folder->getCMSFields() simple and reuseable,
     // without any dependencies into AssetAdmin (e.g. useful for "add folder" views).
     if (!$fields->hasTabset()) {
         $tabs = new TabSet('Root', $tabList = new Tab('ListView', _t('AssetAdmin.ListView', 'List View')), $tabTree = new Tab('TreeView', _t('AssetAdmin.TreeView', 'Tree View')));
         $tabList->addExtraClass("content-listview");
         $tabTree->addExtraClass("content-treeview");
         if ($fields->Count() && $folder->exists()) {
             $tabs->push($tabDetails = new Tab('DetailsView', _t('AssetAdmin.DetailsView', 'Details')));
             $tabDetails->addExtraClass("content-galleryview");
             foreach ($fields as $field) {
                 $fields->removeByName($field->getName());
                 $tabDetails->push($field);
             }
         }
         $fields->push($tabs);
     }
     // List view
     $fields->addFieldsToTab('Root.ListView', array($actionsComposite = CompositeField::create(CompositeField::create($uploadBtn, $addFolderBtn, $syncButton)->addExtraClass('cms-actions-row'))->addExtraClass('cms-content-toolbar field'), $gridField));
     $treeField = new LiteralField('Tree', '');
     // Tree view
     $fields->addFieldsToTab('Root.TreeView', array(clone $actionsComposite, new LiteralField('Tree', $treeField->createTag('div', array('class' => 'cms-tree', 'data-url-tree' => $this->Link('getsubtree'), 'data-url-savetreenode' => $this->Link('savetreenode')), $this->SiteTreeAsUL()))));
     // Move actions to "details" tab (they don't make sense on list/tree view)
     $actions = $form->Actions();
     $saveBtn = $actions->fieldByName('action_save');
     $deleteBtn = $actions->fieldByName('action_delete');
     if (($saveBtn || $deleteBtn) && $fields->fieldByName('Root.DetailsView')) {
         $actions->removeByName('action_save');
         $actions->removeByName('action_delete');
         $fields->addFieldToTab('Root.DetailsView', CompositeField::create($saveBtn, $deleteBtn)->addExtraClass('Actions'));
     }
     $fields->setForm($form);
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // TODO Can't merge $FormAttributes in template at the moment
     $form->addExtraClass('cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:nzjoel,项目名称:silverstripe-cms,代码行数:70,代码来源:AssetAdmin.php

示例7: getListField

 /**
  * @param $folderID The ID of the folder to display.
  * @return FormField
  */
 protected function getListField($folderID)
 {
     // Generate the folder selection field.
     $folderField = new TreeDropdownField('ParentID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder');
     $folderField->setValue($folderID);
     // Generate the file list field.
     $config = GridFieldConfig::create();
     $config->addComponent(new GridFieldSortableHeader());
     $config->addComponent(new GridFieldFilterHeader());
     $config->addComponent(new GridFieldDataColumns());
     $config->addComponent(new GridFieldPaginator(10));
     // If relation is to be autoset, we need to make sure we only list compatible objects.
     $baseClass = null;
     if ($this->parent->relationAutoSetting) {
         $baseClass = $this->parent->getRelationAutosetClass();
     }
     // By default we can attach anything that is a file, or derives from file.
     if (!$baseClass) {
         $baseClass = 'File';
     }
     // Create the data source for the list of files within the current directory.
     $files = DataList::create($baseClass)->filter('ParentID', $folderID);
     $fileField = new GridField('Files', false, $files, $config);
     $fileField->setAttribute('data-selectable', true);
     if ($this->parent->getConfig('allowedMaxFileNumber') > 1) {
         $fileField->setAttribute('data-multiselect', true);
     }
     $selectComposite = new CompositeField($folderField, $fileField);
     return $selectComposite;
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:34,代码来源:UploadField.php

示例8: getListField

	/**
	 * @param $folderID The ID of the folder to display.
	 * @return FormField
	 */
	protected function getListField($folderID) {
		// Generate the folder selection field.
		$folderField = new TreeDropdownField('ParentID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder');
		$folderField->setValue($folderID);

		// Generate the file list field.
		$config = GridFieldConfig::create();
		$config->addComponent(new GridFieldSortableHeader());
		$config->addComponent(new GridFieldFilterHeader());
		$config->addComponent(new GridFieldDataColumns());
		$config->addComponent(new GridFieldPaginator(10));

		// Create the data source for the list of files within the current directory.
		$files = DataList::create('File')->filter('ParentID', $folderID);

		// If relation is to be autoset, make sure only objects from related class are listed.
		if ($this->parent->relationAutoSetting) {
			if ($relationClass = $this->parent->getRelationAutosetClass()) {
				$files->filter('ClassName', $relationClass);
			}
		}

		$fileField = new GridField('Files', false, $files, $config);
		$fileField->setAttribute('data-selectable', true);
		if($this->parent->getConfig('allowedMaxFileNumber') > 1) $fileField->setAttribute('data-multiselect', true);

		$selectComposite = new CompositeField(
			$folderField,
			$fileField
		);

		return $selectComposite;
	}
开发者ID:redema,项目名称:sapphire,代码行数:37,代码来源:UploadField.php

示例9: getHTMLFragments

 /**
  * @param GridField $field
  */
 public function getHTMLFragments($field)
 {
     if (!$field->getConfig()->getComponentByType('GridFieldOrderableRows')) {
         user_error("GridFieldGroupable requires a GridFieldOrderableRows component", E_USER_WARNING);
     }
     self::include_requirements();
     // set ajax urls / vars
     $field->addExtraClass('ss-gridfield-groupable');
     $field->setAttribute('data-url-group-assignment', $field->Link('group_assignment'));
     // setoptions [groupUnassignedName, groupFieldLabel, groupField, groupsAvailable]
     $field->setAttribute('data-groupable-unassigned', $this->getOption('groupUnassignedName'));
     $field->setAttribute('data-groupable-role', $this->getOption('groupFieldLabel'));
     $field->setAttribute('data-groupable-itemfield', $this->getOption('groupField'));
     $field->setAttribute('data-groupable-groups', json_encode($this->getOption('groupsAvailable')));
 }
开发者ID:micschk,项目名称:silverstripe-groupable-gridfield,代码行数:18,代码来源:GridFieldGroupable.php

示例10: getListField

 /**
  * @param int $folderID The ID of the folder to display.
  * @return FormField
  */
 protected function getListField($folderID)
 {
     // Generate the folder selection field.
     $folderField = new TreeDropdownField('ParentID', _t('HTMLEditorField.FOLDER', 'Folder'), 'Folder');
     $folderField->setValue($folderID);
     // Generate the file list field.
     $config = GridFieldConfig::create();
     $config->addComponent(new GridFieldSortableHeader());
     $config->addComponent(new GridFieldFilterHeader());
     $config->addComponent($colsComponent = new GridFieldDataColumns());
     $colsComponent->setDisplayFields(array('StripThumbnail' => '', 'Title' => singleton('File')->fieldLabel('Title'), 'Created' => singleton('File')->fieldLabel('Created'), 'Size' => singleton('File')->fieldLabel('Size')));
     $colsComponent->setFieldCasting(array('Created' => 'DBDatetime->Nice'));
     // Set configurable pagination for file list field
     $pageSize = Config::inst()->get(get_class($this), 'page_size');
     $config->addComponent(new GridFieldPaginator($pageSize));
     // If relation is to be autoset, we need to make sure we only list compatible objects.
     $baseClass = $this->parent->getRelationAutosetClass();
     // Create the data source for the list of files within the current directory.
     $files = DataList::create($baseClass)->exclude('ClassName', 'Folder');
     if ($folderID) {
         $files = $files->filter('ParentID', $folderID);
     }
     $fileField = new GridField('Files', false, $files, $config);
     $fileField->setAttribute('data-selectable', true);
     if ($this->parent->getAllowedMaxFileNumber() !== 1) {
         $fileField->setAttribute('data-multiselect', true);
     }
     $selectComposite = new CompositeField($folderField, $fileField);
     return $selectComposite;
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:34,代码来源:UploadField.php

示例11: getListField

 /**
  * @param $folderID
  * @return CompositeField|FormField
  */
 protected function getListField($folderID)
 {
     // Generate the file list field.
     $config = GridFieldConfig::create();
     $config->addComponent(new GridFieldSortableHeader());
     $config->addComponent(new GridFieldFilterHeader());
     $config->addComponent(new GridFieldPaginator(20));
     $config->addComponent($colsComponent = new GridFieldDataColumns());
     $colsComponent->setDisplayFields(array('StripThumbnail' => 'Thumbnail', 'Title' => 'Title', 'Size' => singleton('CloudinaryFile')->fieldLabel('Size')));
     // If relation is to be autoset, we need to make sure we only list compatible objects.
     $baseClass = $this->parent->getRelationAutosetClass();
     // Create the data source for the list of files within the current directory.
     $files = DataList::create($baseClass);
     if ($this->parent->hasMethod('addFilterForFiles')) {
         $files = $this->parent->addFilterForFiles($files);
     }
     $fileField = new GridField('Files', false, $files, $config);
     $fileField->setAttribute('data-selectable', true);
     if ($this->parent->getAllowedMaxFileNumber() !== 1) {
         $fileField->setAttribute('data-multiselect', true);
     }
     $selectComposite = new CompositeField($fileField);
     return $selectComposite;
 }
开发者ID:helpfulrobot,项目名称:mademedia-silverstripe-cloudinary,代码行数:28,代码来源:CloudinaryUploadField.php

示例12: getHTMLFragments

 /**
  * @param GridField $field
  */
 public function getHTMLFragments($field)
 {
     GridFieldExtensions::include_requirements();
     $field->addExtraClass('ss-gridfield-orderable');
     $field->setAttribute('data-immediate-update', (string) (int) $this->immediateUpdate);
     $field->setAttribute('data-url-reorder', $field->Link('reorder'));
     $field->setAttribute('data-url-movetopage', $field->Link('movetopage'));
 }
开发者ID:ajshort,项目名称:silverstripe-gridfieldextensions,代码行数:11,代码来源:GridFieldOrderableRows.php


注:本文中的GridField::setAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。