本文整理汇总了PHP中GridField_FormAction::create方法的典型用法代码示例。如果您正苦于以下问题:PHP GridField_FormAction::create方法的具体用法?PHP GridField_FormAction::create怎么用?PHP GridField_FormAction::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridField_FormAction
的用法示例。
在下文中一共展示了GridField_FormAction::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getColumnContent
/**
*
* @param \GridField $gridField
* @param \DataObject $record
* @param string $columnName
* @return string|null - the HTML for the column
*/
public function getColumnContent($gridField, $record, $columnName)
{
if (!$record instanceof \Payment) {
return null;
}
if (!$record->canRefund()) {
return null;
}
\Requirements::css('omnipay-ui/css/omnipay-ui-cms.css');
\Requirements::javascript('omnipay-ui/javascript/omnipay-ui-cms.js');
\Requirements::add_i18n_javascript('omnipay-ui/javascript/lang');
$infoText = '';
switch (GatewayInfo::refundMode($record->Gateway)) {
case GatewayInfo::MULTIPLE:
$infoText = 'MultiRefundInfo';
break;
case GatewayInfo::PARTIAL:
$infoText = 'SingleRefundInfo';
break;
case GatewayInfo::FULL:
$infoText = 'FullRefundInfo';
break;
}
/** @var \Money $money */
$money = $record->dbObject('Money');
/** @var \GridField_FormAction $field */
$field = \GridField_FormAction::create($gridField, 'RefundPayment' . $record->ID, false, 'refundpayment', array('RecordID' => $record->ID))->addExtraClass('gridfield-button-refund payment-dialog-button')->setAttribute('title', _t('GridFieldRefundAction.Title', 'Refund Payment'))->setAttribute('data-icon', 'button-refund')->setAttribute('data-dialog', json_encode(array('maxAmount' => $money->Nice(), 'maxAmountNum' => $money->getAmount(), 'hasAmountField' => $record->canRefund(null, true), 'infoTextKey' => $infoText, 'buttonTextKey' => 'RefundAmount')))->setDescription(_t('GridFieldRefundAction.Description', 'Refund a captured payment'));
return $field->Field();
}
示例2: getColumnContent
public function getColumnContent($gridField, $record, $columnName)
{
$link = $gridField->getForm()->getController()->Link("edit");
$target = $gridField->getForm()->getRecord();
$field = GridField_FormAction::create($gridField, 'Select' . $record->ID, 'Select', "doselect", array("RecordClassName" => $record->ClassName, "RecordID" => $record->ID, "TargetClassName" => $target->ClassName, "TargetID" => $target->ID, "Redirect" => $link))->addExtraClass("ss-ui-action-constructive");
return $field->Field();
}
示例3: getHTMLFragments
/**
* Returns a map where the keys are fragment names and the values are pieces of HTML to add to these fragments.
* @param GridField $gridField Grid Field Reference
* @return Array Map where the keys are fragment names and the values are pieces of HTML to add to these fragments.
*/
public function getHTMLFragments($gridField)
{
$dataList = $gridField->getList();
if (class_exists('UnsavedRelationList') && $dataList instanceof UnsavedRelationList) {
return array();
}
$state = $gridField->State->GridFieldSortableRows;
if (!is_bool($state->sortableToggle)) {
$state->sortableToggle = false;
}
//Ensure user can edit
if (!singleton($gridField->getModelClass())->canEdit()) {
return array();
}
//Sort order toggle
$sortOrderToggle = GridField_FormAction::create($gridField, 'sortablerows-toggle', 'sorttoggle', 'sortableRowsToggle', null)->addExtraClass('sortablerows-toggle');
$sortOrderSave = GridField_FormAction::create($gridField, 'sortablerows-savesort', 'savesort', 'saveGridRowSort', null)->addExtraClass('sortablerows-savesort');
//Sort to Page Action
$sortToPage = GridField_FormAction::create($gridField, 'sortablerows-sorttopage', 'sorttopage', 'sortToPage', null)->addExtraClass('sortablerows-sorttopage');
$data = array('SortableToggle' => $sortOrderToggle, 'SortOrderSave' => $sortOrderSave, 'SortToPage' => $sortToPage, 'Checked' => $state->sortableToggle == true ? ' checked = "checked"' : '', 'List' => $dataList);
$forTemplate = new ArrayData($data);
//Inject Requirements
$custom = Config::inst()->get('GridFieldSortableRows', 'Base');
$base = $custom ?: SORTABLE_GRIDFIELD_BASE;
Requirements::css($base . '/css/GridFieldSortableRows.css');
Requirements::javascript($base . '/javascript/GridFieldSortableRows.js');
$args = array('Colspan' => count($gridField->getColumns()), 'ID' => $gridField->ID(), 'DisableSelection' => $this->disable_selection);
$fragments = array('header' => $forTemplate->renderWith('GridFieldSortableRows', $args));
if ($gridField->getConfig()->getComponentByType('GridFieldPaginator')) {
$fragments['after'] = $forTemplate->renderWith('GridFieldSortableRows_paginator');
}
return $fragments;
}
示例4: getColumnContent
/**
*
* @param GridField $gridField
* @param DataObject $record
* @param string $columnName
* @return string - the HTML for the column
*/
public function getColumnContent($gridField, $record, $columnName)
{
if ($this->removeRelation) {
$field = GridField_FormAction::create($gridField, 'UnlinkRelation' . $record->ID, false, "unlinkrelation", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-unlink')->setAttribute('title', _t('GridAction.UnlinkRelation', "Unlink"))->setAttribute('data-icon', 'chain--minus');
} else {
if (!$record->canDelete()) {
return;
}
$field = GridField_FormAction::create($gridField, 'DeleteRecord' . $record->ID, false, "deleterecord", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-delete')->setAttribute('title', _t('GridAction.Delete', "Delete"))->setAttribute('data-icon', 'cross-circle')->setDescription(_t('GridAction.DELETE_DESCRIPTION', 'Delete'));
}
//add a class to the field to if it is the last gridfield in the list
$numberOfRelations = $record->Pages()->Count();
$field->addExtraClass('dms-delete')->setAttribute('data-pages-count', $numberOfRelations)->removeExtraClass('gridfield-button-delete');
//remove the base gridfield behaviour
//set a class telling JS what kind of warning to display when clicking the delete button
if ($numberOfRelations > 1) {
$field->addExtraClass('dms-delete-link-only');
} else {
$field->addExtraClass('dms-delete-last-warning');
}
//set a class to show if the document is hidden
if ($record->isHidden()) {
$field->addExtraClass('dms-document-hidden');
}
return $field->Field();
}
示例5: getColumnContent
public function getColumnContent($gridField, $record, $columnName)
{
Requirements::javascript(POSTMARK_RELATIVE_PATH . '/javascript/Messages.js');
Requirements::css(POSTMARK_RELATIVE_PATH . '/css/GridFieldPostmarkMessageButton.css');
$field = GridField_FormAction::create($gridField, 'MessageCustomer' . $record->ID, false, "message", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-pencil gird-field-message')->setAttribute('title', 'Message')->setAttribute('data-icon', 'envelope')->setDescription('Send Message');
return $field->Field();
}
开发者ID:helpfulrobot,项目名称:silverstripers-silverstripe-postmarked,代码行数:7,代码来源:GridFieldPostmarkMessageButton.php
示例6: getColumnContent
public function getColumnContent($gridField, $record, $columnName)
{
$template = $gridField->getList()->byID($record->ID);
$title = 'Clone Template';
$icon = 'drive-upload';
$field = GridField_FormAction::create($gridField, GridFieldCloneSurveyTemplateAction::ACTION_NAME . $record->ID, false, GridFieldCloneSurveyTemplateAction::ACTION_NAME, array('RecordID' => $record->ID))->setAttribute('title', $title)->setAttribute('data-icon', $icon)->setDescription($title);
return $field->Field();
}
示例7: getColumnContent
/**
* @param GridField $gridField
* @param DataObject $record
* @param string $columnName
* @return string - the HTML for the column
*/
public function getColumnContent($gridField, $record, $columnName)
{
if (!$record->canDelete()) {
return;
}
$field = GridField_FormAction::create($gridField, 'SoftDeleteRecord' . $record->ID, false, "softdeleterecord", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-delete')->setAttribute('title', _t('GridAction.Delete', "Delete"))->setAttribute('data-icon', 'cross-circle')->setDescription(_t('GridAction.DELETE_DESCRIPTION', 'Delete'));
return $field->Field();
}
示例8: getColumnContent
/**
*
* @param GridField $gridField
* @param DataObject $record
* @param string $columnName
* @return string - the HTML for the column
*/
public function getColumnContent($gridField, $record, $columnName)
{
if (!$record->IsDeletedFromStage && $record->canDelete() && !$record->isPublished()) {
$field = GridField_FormAction::create($gridField, 'DeleteFromStage' . $record->ID, false, "deletefromstage", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-deletedraft')->setAttribute('title', _t('PublishableGridFieldAction.DELETE', 'Delete draft'))->setAttribute('data-icon', 'decline')->setDescription(_t('PublishableGridFieldAction.DELETE_DESC', 'Remove this item from the draft site'));
return $field->Field();
}
return;
}
开发者ID:helpfulrobot,项目名称:studiobonito-silverstripe-publishable,代码行数:15,代码来源:PublishableGridFieldDeleteAction.php
示例9: getColumnContent
public function getColumnContent($gridField, $record, $columnName)
{
if (!$record->canCreate()) {
return;
}
$field = GridField_FormAction::create($gridField, 'CopyRecord' . $record->ID, false, "copyrecord", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-copy')->setAttribute('title', _t('GridAction.Copy', "Copy"))->setDescription(_t('GridAction.COPY_DESCRIPTION', 'Copy'));
return $field->Field();
}
示例10: getColumnContent
public function getColumnContent($gridField, $record, $columnName)
{
if (!$record->canEdit()) {
return;
}
$summit_event = $gridField->getList()->byID($record->ID);
$title = $summit_event->Published ? "Unpublish Event" : "Publish Event";
$icon = $summit_event->Published ? 'accept' : 'accept_disabled';
$field = GridField_FormAction::create($gridField, 'publishsummitevent' . $record->ID, false, "publishsummitevent", array('RecordID' => $record->ID))->setAttribute('title', $title)->setAttribute('data-icon', $icon)->setDescription($title);
return $field->Field();
}
示例11: getColumnContent
public function getColumnContent($gridField, $record, $columnName)
{
if (!$record->canEdit()) {
return;
}
$member = $gridField->getList()->byID($record->ID);
$title = $member->Active ? "Deactivate Member" : "Activate Member";
$icon = $member->Active ? 'accept' : 'accept_disabled';
$field = GridField_FormAction::create($gridField, 'activatemember' . $record->ID, false, "activatemember", array('RecordID' => $record->ID))->setAttribute('title', $title)->setAttribute('data-icon', $icon)->setDescription($title);
return $field->Field();
}
示例12: getHTMLFragments
public function getHTMLFragments($gridField)
{
$singleton = singleton($gridField->getModelClass());
if (!$singleton->canCreate() || !singleton('SiteTree')->canCreate()) {
return [];
}
if (!$this->buttonName) {
// provide a default button name, can be changed by calling {@link setButtonName()} on this component
$this->buttonName = _t('Link.COPY_CHILDREN_FROM_ROOT', 'Copy children from root');
}
return [$this->targetFragment => \GridField_FormAction::create($gridField, 'CopyChildrenFromRoot-' . \Convert::raw2att($this->urlSegment), $this->buttonName, $this->urlSegment, [])->addExtraClass('gridfield-button-copyChildrenFromRoot')->setAttribute('title', $this->buttonName)->setDescription($this->buttonName)->Field()];
}
示例13: getColumnContent
/**
* {@inheritDoc}
*/
public function getColumnContent($gridField, $record, $columnName)
{
if (!$record->canEdit()) {
return;
}
if ($record->isPublished()) {
$field = GridField_FormAction::create($gridField, 'UnPublish' . $record->ID, false, "unpublish", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-unpublish')->setAttribute('title', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'))->setAttribute('data-icon', 'unpublish')->setDescription(_t('News.BUTTONUNPUBLISHDESC', 'Unpublish news item'));
} else {
$field = GridField_FormAction::create($gridField, 'Publish' . $record->ID, false, "publish", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-publish')->setAttribute('title', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & Publish'))->setAttribute('data-icon', 'accept')->setDescription(_t('News.BUTTONUNPUBLISHDESC', 'Publish news item'));
}
return $field->Field();
}
示例14: getHTMLFragments
public function getHTMLFragments($gridField)
{
$singleton = singleton($gridField->getModelClass());
$record = $gridField->Form && $gridField->Form->Record ? $gridField->Form->Record : null;
if (!$singleton->canCreate() || !singleton('SiteTree')->canCreate() || !$record || !$record->SiteTreeID) {
return [];
}
if (!$this->buttonName) {
// provide a default button name, can be changed by calling {@link setButtonName()} on this component
$this->buttonName = _t('Link.COPY_CHILDREN_FROM_CURRENT_PAGE', 'Copy children from {title}', ['title' => $record->SiteTree()->Title]);
}
return [$this->targetFragment => \GridField_FormAction::create($gridField, 'CopyChildrenFromCurrentPage-' . \Convert::raw2att($this->urlSegment), $this->buttonName, $this->urlSegment, [])->addExtraClass('gridfield-button-copyChildrenFromCurrentPage')->setAttribute('title', $this->buttonName)->setDescription($this->buttonName)->Field()];
}
示例15: getColumnContent
/**
*
* @param GridField $gridField
* @param DataObject $record
* @param string $columnName
* @return string - the HTML for the column
*/
public function getColumnContent($gridField, $record, $columnName)
{
// Disable the export icon if current user doesn't have access to view CMS Security settings
if (!Permission::check('CMS_ACCESS_SecurityAdmin')) {
return '';
}
$field = GridField_FormAction::create($gridField, 'ExportRecord' . $record->ID, false, "exportrecord", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-export')->setAttribute('title', _t('GridAction.Export', "Export"))->setAttribute('data-icon', 'export')->setDescription(_t('GridAction.EXPORT_DESCRIPTION', 'Export'));
$segment1 = Director::baseURL();
$segment2 = Config::inst()->get('AdvancedWorkflowAdmin', 'url_segment');
$segment3 = $record->getClassName();
$fields = new ArrayData(array('Link' => Controller::join_links($segment1, 'admin', $segment2, $segment3, 'export', $record->ID)));
return $field->Field()->renderWith('GridField_ExportAction', $fields);
}