本文整理汇总了PHP中GridField_FormAction类的典型用法代码示例。如果您正苦于以下问题:PHP GridField_FormAction类的具体用法?PHP GridField_FormAction怎么用?PHP GridField_FormAction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GridField_FormAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHTMLFragments
/**
* Place the print button in a <p> tag below the field
*
* @param GridField
*
* @return array
*/
public function getHTMLFragments($gridField)
{
$button = new GridField_FormAction($gridField, 'print', _t('TableListField.Print', 'Print'), 'print', null);
$button->setAttribute('data-icon', 'grid_print');
$button->addExtraClass('gridfield-button-print');
return array($this->targetFragment => '<p class="grid-print-button">' . $button->Field() . '</p>');
}
示例2: getHTMLFragments
/**
*
* @param GridField $gridField
* @return string - HTML
*/
public function getHTMLFragments($gridField)
{
$searchState = $gridField->State->GridFieldSearchRelation;
$dataClass = $gridField->getList()->dataClass();
$forTemplate = new ArrayData(array());
$forTemplate->Fields = new ArrayList();
$searchFields = $this->getSearchFields() ? $this->getSearchFields() : $this->scaffoldSearchFields($dataClass);
$value = $this->findSingleEntry($gridField, $searchFields, $searchState, $dataClass);
$searchField = new TextField('gridfield_relationsearch', _t('GridField.RelationSearch', "Relation search"), $value);
// Apparently the data-* needs to be double qouted for the jQuery.meta data plugin
$searchField->setAttribute('data-search-url', '\'' . Controller::join_links($gridField->Link('search') . '\''));
$searchField->setAttribute('placeholder', $this->getPlaceholderText($dataClass));
$searchField->addExtraClass('relation-search no-change-track');
$findAction = new GridField_FormAction($gridField, 'gridfield_relationfind', _t('GridField.Find', "Find"), 'find', 'find');
$findAction->setAttribute('data-icon', 'relationfind');
$addAction = new GridField_FormAction($gridField, 'gridfield_relationadd', _t('GridField.LinkExisting', "Link Existing"), 'addto', 'addto');
$addAction->setAttribute('data-icon', 'chain--plus');
// If an object is not found, disable the action
if (!is_int($gridField->State->GridFieldAddRelation)) {
$addAction->setReadonly(true);
}
$forTemplate->Fields->push($searchField);
$forTemplate->Fields->push($findAction);
$forTemplate->Fields->push($addAction);
return array($this->targetFragment => $forTemplate->renderWith($this->itemClass));
}
示例3: getHTMLFragments
/**
* Place the export button in a <p> tag below the field
*/
public function getHTMLFragments($gridField)
{
$button = new GridField_FormAction($gridField, 'export', _t('TableListField.CSVEXPORT', 'Export to CSV'), 'export', null);
$button->setAttribute('data-icon', 'download-csv');
$button->addExtraClass('no-ajax');
return array($this->targetFragment => '<p class="grid-csv-button">' . $button->Field() . '</p>');
}
示例4: getHTMLFragments
public function getHTMLFragments($gridField)
{
$model = Injector::inst()->create($gridField->getModelClass());
$parent = SiteTree::get()->byId(Controller::curr()->currentPageID());
if (!$model->canCreate()) {
return array();
}
$children = $this->getAllowedChildren($parent);
if (count($children) > 1) {
$pageTypes = DropdownField::create("PageType", "Page Type", $children, $model->defaultChild());
$pageTypes->setFieldHolderTemplate("GridFieldSiteTreeAddNewButton_holder")->addExtraClass("gridfield-dropdown no-change-track");
if (!$this->buttonName) {
$this->buttonName = _t('GridFieldSiteTreeAddNewButton.AddMultipleOptions', 'Add new', "Add button text for multiple options.");
}
} else {
$keys = array_keys($children);
$pageTypes = HiddenField::create('PageType', 'Page Type', $keys[0]);
if (!$this->buttonName) {
$this->buttonName = _t('GridFieldSiteTreeAddNewButton.Add', 'Add new {name}', 'Add button text for a single option.', array($children[$keys[0]]));
}
}
$state = $gridField->State->GridFieldSiteTreeAddNewButton;
$state->currentPageID = $parent->ID;
$state->pageType = $parent->defaultChild();
$addAction = new GridField_FormAction($gridField, 'add', $this->buttonName, 'add', 'add');
$addAction->setAttribute('data-icon', 'add')->addExtraClass("no-ajax ss-ui-action-constructive dropdown-action");
$forTemplate = new ArrayData(array());
$forTemplate->Fields = new ArrayList();
$forTemplate->Fields->push($pageTypes);
$forTemplate->Fields->push($addAction);
Requirements::css(LUMBERJACK_DIR . "/css/lumberjack.css");
Requirements::javascript(LUMBERJACK_DIR . "/javascript/GridField.js");
return array($this->targetFragment => $forTemplate->renderWith("GridFieldSiteTreeAddNewButton"));
}
示例5: getHTMLFragments
public function getHTMLFragments($gridField)
{
$button = new GridField_FormAction($gridField, 'syncwithyoutube', _t('GridFieldSyncYoutubeVideos.CTA', 'Sync with Youtube'), 'syncwithyoutube', null);
$button->setAttribute('data-icon', 'accept');
$button->addExtraClass('no-ajax');
return array($this->targetFragment => '<p class="grid-csv-button">' . $button->Field() . '<br><br></p>');
}
示例6: getHTMLFragments
/**
* Place the export button in a <p> tag below the field
*/
public function getHTMLFragments($gridField)
{
$btnLabel = _t('Hail', 'Fetch {type}', ['type' => singleton($gridField->getModelClass())->i18n_plural_name()]);
$button = new GridField_FormAction($gridField, 'fetchhail', $btnLabel, 'fetchhail', null);
$button->setAttribute('data-icon', 'fetchHail');
// $button->addExtraClass('ss-ui-action-constructive');
return array($this->targetFragment => $button->Field());
}
示例7: getHTMLFragments
/**
* Get the html/css button and upload field to perform import.
*/
public function getHTMLFragments($gridField)
{
$button = new GridField_FormAction($gridField, 'import', _t('TableListField.CSVIMPORT', 'Import from CSV'), 'import', null);
$button->setAttribute('data-icon', 'drive-upload');
$button->addExtraClass('no-ajax');
$uploadfield = $this->getUploadField($gridField);
$data = array('Button' => $button, 'UploadField' => $uploadfield);
$importerHTML = ArrayData::create($data)->renderWith("GridFieldImporter");
Requirements::javascript('importexport/javascript/GridFieldImporter.js');
return array($this->targetFragment => $importerHTML);
}
示例8: 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
示例9: 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();
}
示例10: 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();
}
示例11: 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;
}
示例12: 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();
}
示例13: 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();
}
示例14: 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();
}
示例15: 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();
}