本文整理汇总了PHP中DataObject::getDefaultSearchContext方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObject::getDefaultSearchContext方法的具体用法?PHP DataObject::getDefaultSearchContext怎么用?PHP DataObject::getDefaultSearchContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObject
的用法示例。
在下文中一共展示了DataObject::getDefaultSearchContext方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDefaultSearchContext
public function getDefaultSearchContext()
{
$context = parent::getDefaultSearchContext();
$context->getFields()->dataFieldByName('Status')->setHasEmptyDefault(true);
$context->getFields()->dataFieldByName('Origin')->setHasEmptyDefault(true);
return $context;
}
示例2: getDefaultSearchContext
public function getDefaultSearchContext()
{
$context = parent::getDefaultSearchContext();
$fields = $context->getFields();
$fields->push(CheckboxField::create("HasBeenUsed"));
//add date range filtering
$fields->push(ToggleCompositeField::create("StartDate", "Start Date", array(DateField::create("q[StartDateFrom]", "From")->setConfig('showcalendar', true), DateField::create("q[StartDateTo]", "To")->setConfig('showcalendar', true))));
$fields->push(ToggleCompositeField::create("EndDate", "End Date", array(DateField::create("q[EndDateFrom]", "From")->setConfig('showcalendar', true), DateField::create("q[EndDateTo]", "To")->setConfig('showcalendar', true))));
//must be enabled in config, because some sites may have many products = slow load time, or memory maxes out
//future solution is using an ajaxified field
if (self::config()->filter_by_product) {
$fields->push(ListboxField::create("Products", "Products", Product::get()->map()->toArray())->setMultiple(true));
}
if (self::config()->filter_by_category) {
$fields->push(ListboxField::create("Categories", "Categories", ProductCategory::get()->map()->toArray())->setMultiple(true));
}
if ($field = $fields->fieldByName("Code")) {
$field->setDescription("This can be a partial match.");
}
//get the array, to maniplulate name, and fullname seperately
$filters = $context->getFilters();
$filters['StartDateFrom'] = GreaterThanOrEqualFilter::create('StartDate');
$filters['StartDateTo'] = LessThanOrEqualFilter::create('StartDate');
$filters['EndDateFrom'] = GreaterThanOrEqualFilter::create('EndDate');
$filters['EndDateTo'] = LessThanOrEqualFilter::create('EndDate');
$context->setFilters($filters);
return $context;
}
示例3: getDefaultSearchContext
/**
* Change search context to use a dropdown for list of gateways.
*/
public function getDefaultSearchContext()
{
$context = parent::getDefaultSearchContext();
$fields = $context->getSearchFields();
$fields->removeByName('Gateway');
$fields->insertBefore(DropdownField::create('Gateway', 'Gateway', GatewayInfo::get_supported_gateways())->setHasEmptyDefault(true), 'Status');
$fields->fieldByName('Status')->setHasEmptyDefault(true);
return $context;
}
示例4: getDefaultSearchContext
public function getDefaultSearchContext()
{
$context = parent::getDefaultSearchContext();
$results = $this->blockManager->getBlockClasses();
if (sizeof($results) > 1) {
$classfield = new DropdownField('ClassName', _t('Block.BlockType', 'Block Type'));
$classfield->setSource($results);
$classfield->setEmptyString(_t('Block.Any', '(any)'));
$context->addField($classfield);
}
return $context;
}
示例5: getDefaultSearchContext
/**
* Change search context to use a dropdown for list of gateways.
*/
public function getDefaultSearchContext()
{
$context = parent::getDefaultSearchContext();
$fields = $context->getSearchFields();
$fields->removeByName('Gateway');
$fields->removeByName('Created');
$fields->insertAfter(DropdownField::create('Gateway', _t('Payment.GATEWAY', 'Gateway'), GatewayInfo::get_supported_gateways())->setHasEmptyDefault(true), 'Money');
// create a localized status dropdown for the search-context
$fields->insertAfter(DropdownField::create('Status', _t('Payment.db_Status', 'Status'), $this->getStatusValues())->setHasEmptyDefault(true), 'Gateway');
// update "money" to localized title
$fields->fieldByName('Money')->setTitle(_t('Payment.MONEY', 'Money'));
$context->addFilter(new PartialMatchFilter('Gateway'));
return $context;
}
示例6: getDefaultSearchContext
/**
* Adjust scafolded search context
*
* @return SearchContext the updated search context
*/
public function getDefaultSearchContext()
{
$context = parent::getDefaultSearchContext();
$fields = $context->getFields();
$fields->push(ListboxField::create("Status", _t('Order.db_Status', "Status"))->setSource(array_combine(self::config()->placed_status, self::config()->placed_status))->setMultiple(true));
// add date range filtering
$fields->insertBefore(DateField::create("DateFrom", _t('Order.DateFrom', "Date from"))->setConfig('showcalendar', true), 'Status');
$fields->insertBefore(DateField::create("DateTo", _t('Order.DateTo', "Date to"))->setConfig('showcalendar', true), 'Status');
// get the array, to maniplulate name, and fullname seperately
$filters = $context->getFilters();
$filters['DateFrom'] = GreaterThanFilter::create('Placed');
$filters['DateTo'] = LessThanFilter::create('Placed');
// filter customer need to use a bunch of different sources
$filters['FirstName'] = new MultiFieldPartialMatchFilter('FirstName', false, array('SplitWords'), array('Surname', 'Member.FirstName', 'Member.Surname', 'BillingAddress.FirstName', 'BillingAddress.Surname', 'ShippingAddress.FirstName', 'ShippingAddress.Surname'));
$context->setFilters($filters);
$this->extend('updateDefaultSearchContext', $context);
return $context;
}
示例7: getDefaultSearchContext
/**
* Adjust scafolded search context
* @return SearchContext the updated search context
*/
public function getDefaultSearchContext()
{
$context = parent::getDefaultSearchContext();
$fields = $context->getFields();
$fields->push(ListboxField::create("Status", "Status")->setSource(array_combine(self::config()->placed_status, self::config()->placed_status))->setMultiple(true));
//add date range filtering
$fields->insertBefore(DateField::create("DateFrom", "Date from")->setConfig('showcalendar', true), 'Status');
$fields->insertBefore(DateField::create("DateTo", "Date to")->setConfig('showcalendar', true), 'Status');
//get the array, to maniplulate name, and fullname seperately
$filters = $context->getFilters();
$filters['DateFrom'] = GreaterThanFilter::create('Placed');
$filters['DateTo'] = LessThanFilter::create('Placed');
$context->setFilters($filters);
return $context;
}