本文整理汇总了PHP中ReadonlyField::addExtraClass方法的典型用法代码示例。如果您正苦于以下问题:PHP ReadonlyField::addExtraClass方法的具体用法?PHP ReadonlyField::addExtraClass怎么用?PHP ReadonlyField::addExtraClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadonlyField
的用法示例。
在下文中一共展示了ReadonlyField::addExtraClass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCMSFields
/**
* Adds group select fields to CMS
*
* @param FieldSet $fields
* @return void
*/
public function updateCMSFields(FieldSet &$fields)
{
// Only modify folder objects with parent nodes
if (!$this->owner instanceof Folder || !$this->owner->ID) {
return;
}
// Only allow ADMIN and SECURE_FILE_SETTINGS members to edit these options
if (!Permission::checkMember(Member::currentUser(), array('ADMIN', 'SECURE_FILE_SETTINGS'))) {
return;
}
// Update Security Tab
$secureFilesTab = $fields->findOrMakeTab('Root.' . _t('SecureFiles.SECUREFILETABNAME', 'Security'));
$secureFilesTab->push(new HeaderField(_t('SecureFiles.GROUPACCESSTITLE', 'Group Access')));
$secureFilesTab->push(new TreeMultiselectField('GroupPermissions', _t('SecureFiles.GROUPACCESSFIELD', 'Group Access Permissions')));
if ($this->owner->InheritSecured()) {
$permissionGroups = $this->owner->InheritedGroupPermissions();
if ($permissionGroups->Count()) {
$fieldText = implode(", ", $permissionGroups->map());
} else {
$fieldText = _t('SecureFiles.NONE', "(None)");
}
$InheritedGroupsField = new ReadonlyField("InheritedGroupPermissionsText", _t('SecureFiles.GROUPINHERITEDPERMS', 'Inherited Group Permissions'), $fieldText);
$InheritedGroupsField->addExtraClass('prependUnlock');
$secureFilesTab->push($InheritedGroupsField);
}
}
开发者ID:hamishcampbell,项目名称:silverstripe-securefiles,代码行数:32,代码来源:SecureFileGroupPermissionDecorator.php
示例2: performReadonlyTransformation
/**
* Returns a readonly version of this field
*/
function performReadonlyTransformation()
{
$field = new ReadonlyField($this->name, $this->title, $this->value);
$field->addExtraClass($this->extraClass());
$field->setForm($this->form);
return $field;
}
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-dynamiclists,代码行数:10,代码来源:DependentDynamicListDropdownField.php
示例3: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
// Add the preview fields here, including rules used
$t = new StaticSitePageTransformer();
$urlField = new ReadonlyField("PreviewSourceURL", "Imported from", "<a href=\"{$this->AbsoluteURL}\">" . Convert::raw2xml($this->AbsoluteURL) . "</a>");
$urlField->dontEscape = true;
$fields->addFieldToTab("Root.Preview", $urlField);
$content = $t->getContentFieldsAndSelectors($this);
if (count($content) === 0) {
return $fields;
}
foreach ($content as $k => $v) {
$readonlyField = new ReadonlyField("Preview{$k}", "{$k}<br>\n<em>" . $v['selector'] . "</em>", $v['content']);
$readonlyField->addExtraClass('readonly-click-toggle');
$fields->addFieldToTab("Root.Preview", $readonlyField);
}
Requirements::javascript('staticsiteconnector/js/StaticSiteContentItem.js');
Requirements::css('staticsiteconnector/css/StaticSiteContentItem.css');
return $fields;
}
示例4: updateCMSFields
/**
* Security tab for folders
*/
public function updateCMSFields(FieldSet &$fields)
{
// Only modify folder objects with parent nodes
if (!$this->owner instanceof Folder || !$this->owner->ID) {
return;
}
// Only allow ADMIN and SECURE_FILE_SETTINGS members to edit these options
if (!Permission::checkMember(Member::currentUser(), array('ADMIN', 'SECURE_FILE_SETTINGS'))) {
return;
}
$secureFilesTab = $fields->findOrMakeTab('Root.' . _t('SecureFiles.SECUREFILETABNAME', 'Security'));
$EnableSecurityHolder = new FieldGroup();
$EnableSecurityHolder->addExtraClass('securityFieldHolder');
if ($this->InheritSecured()) {
$EnableSecurityField = new ReadonlyField('InheritSecurity', '', _t('SecureFiles.INHERITED', 'This folder is inheriting security settings from a parent folder.'));
$EnableSecurityField->addExtraClass('prependLock');
} else {
$EnableSecurityField = new CheckboxField('Secured', _t('SecureFiles.SECUREFOLDER', 'Folder is secure.'));
}
$secureFilesTab->push(new HeaderField(_t('SecureFiles.FOLDERSECURITY', 'Folder Security')));
$EnableSecurityHolder->push($EnableSecurityField);
$secureFilesTab->push($EnableSecurityHolder);
}
示例5: getFields
/**
* Gets the field list for a record.
*
* @param GridField $grid
* @param DataObjectInterface $record
* @return FieldList
*/
public function getFields(GridField $grid, DataObjectInterface $record)
{
$cols = $this->getDisplayFields($grid);
$fields = new FieldList();
$list = $grid->getList();
$class = $list ? $list->dataClass() : null;
foreach ($cols as $col => $info) {
$field = null;
if ($info instanceof Closure) {
$field = call_user_func($info, $record, $col, $grid);
} elseif (is_array($info)) {
if (isset($info['callback'])) {
$field = call_user_func($info['callback'], $record, $col, $grid);
} elseif (isset($info['field'])) {
if ($info['field'] == 'LiteralField') {
$field = new $info['field']($col, null);
} else {
$field = new $info['field']($col);
}
}
if (!$field instanceof FormField) {
throw new Exception(sprintf('The field for column "%s" is not a valid form field', $col));
}
}
if (!$field && $list instanceof ManyManyList) {
$extra = $list->getExtraFields();
if ($extra && array_key_exists($col, $extra)) {
$field = Object::create_from_string($extra[$col], $col)->scaffoldFormField();
}
}
if (!$field) {
if (!$this->displayFields) {
// If setDisplayFields() not used, utilize $summary_fields
// in a way similar to base class
//
// Allows use of 'MyBool.Nice' and 'MyHTML.NoHTML' so that
// GridFields not using inline editing still look good or
// revert to looking good in cases where the field isn't
// available or is readonly
//
$colRelation = explode('.', $col);
if ($class && ($obj = singleton($class)->dbObject($colRelation[0]))) {
$field = $obj->scaffoldFormField();
} else {
$field = new ReadonlyField($colRelation[0]);
}
} else {
if ($class && ($obj = singleton($class)->dbObject($col))) {
$field = $obj->scaffoldFormField();
} else {
$field = new ReadonlyField($col);
}
}
}
if (!$field instanceof FormField) {
throw new Exception(sprintf('Invalid form field instance for column "%s"', $col));
}
// Add CSS class for interactive fields
if (!($field->isReadOnly() || $field instanceof LiteralField)) {
$field->addExtraClass('editable-column-field');
}
$fields->push($field);
}
return $fields;
}
示例6: getFieldsForOembed
/**
* @return FieldList
*/
protected function getFieldsForOembed($url, $file)
{
if (isset($file->Oembed->thumbnail_url)) {
$thumbnailURL = $file->Oembed->thumbnail_url;
} elseif ($file->Type == 'photo') {
$thumbnailURL = $file->Oembed->url;
} else {
$thumbnailURL = FRAMEWORK_DIR . '/images/default_media.png';
}
$previewField = new LiteralField("ImageFull", "<img id='thumbnailImage' class='thumbnail-preview' src='{$thumbnailURL}?r=" . rand(1, 100000) . "' alt='{$file->Name}' />\n");
if ($file->Width != null) {
$dimensionsField = new FieldGroup(_t('HtmlEditorField.IMAGEDIMENSIONS', 'Dimensions'), $widthField = new TextField('Width', _t('HtmlEditorField.IMAGEWIDTHPX', 'Width'), $file->Width), $heightField = new TextField('Height', _t('HtmlEditorField.IMAGEHEIGHTPX', 'Height'), $file->Height));
}
$fields = new FieldList($filePreview = CompositeField::create(CompositeField::create($previewField)->setName("FilePreviewImage")->addExtraClass('cms-file-info-preview'), CompositeField::create(CompositeField::create(new ReadonlyField("FileType", _t('AssetTableField.TYPE', 'File type') . ':', $file->Type), $urlField = new ReadonlyField('ClickableURL', _t('AssetTableField.URL', 'URL'), sprintf('<a href="%s" target="_blank" class="file">%s</a>', $url, $url))))->setName("FilePreviewData")->addExtraClass('cms-file-info-data'))->setName("FilePreview")->addExtraClass('cms-file-info'), new TextField('CaptionText', _t('HtmlEditorField.CAPTIONTEXT', 'Caption text')), $alignment = new DropdownField('CSSClass', _t('HtmlEditorField.CSSCLASS', 'Alignment / style'), array('left' => _t('HtmlEditorField.CSSCLASSLEFT', 'On the left, with text wrapping around.'), 'leftAlone' => _t('HtmlEditorField.CSSCLASSLEFTALONE', 'On the left, on its own.'), 'right' => _t('HtmlEditorField.CSSCLASSRIGHT', 'On the right, with text wrapping around.'), 'center' => _t('HtmlEditorField.CSSCLASSCENTER', 'Centered, on its own.'))), $dimensionsField);
$urlField->addExtraClass('text-wrap');
$urlField->dontEscape = true;
if ($dimensionsField) {
$dimensionsField->addExtraClass('dimensions last');
$widthField->setMaxLength(5);
$heightField->setMaxLength(5);
} else {
$alignment->addExtraClass('last');
}
if ($file->Type == 'photo') {
$filePreview->FieldList()->insertBefore(new TextField('AltText', _t('HtmlEditorField.IMAGEALTTEXT', 'Alternative text (alt) - shown if image cannot be displayed'), $file->Title, 80), 'CaptionText');
$filePreview->FieldList()->insertBefore(new TextField('Title', _t('HtmlEditorField.IMAGETITLE', 'Title text (tooltip) - for additional information about the image')), 'CaptionText');
}
$this->extend('updateFieldsForImage', $fields, $url, $file);
return $fields;
}