本文整理汇总了PHP中SS_List::count方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_List::count方法的具体用法?PHP SS_List::count怎么用?PHP SS_List::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_List
的用法示例。
在下文中一共展示了SS_List::count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getManipulatedData
/**
* If an object ID is set, add the object to the list
*
* @param GridField $gridField
* @param SS_List $dataList
* @return SS_List
*/
public function getManipulatedData(GridField $gridField, SS_List $dataList)
{
if (!$gridField->State->GridFieldAddRelation) {
return $dataList;
}
$objectID = Convert::raw2sql($gridField->State->GridFieldAddRelation);
if ($objectID) {
$object = DataObject::get_by_id($dataList->dataclass(), $objectID);
if ($object) {
if ($this->_item_limit > 0 && $dataList->count() + 1 > $this->_item_limit) {
$gridField->getForm()->getController()->getResponse()->addHeader('X-Status', _t('LimitedRelationsGridField.ITEM_LIMIT_REACHED', '_You cannot add any more items, you can only add {count} items. Please remove one then try again.', array('count' => $this->_item_limit)));
} else {
$dataList->add($object);
}
}
}
$gridField->State->GridFieldAddRelation = null;
return $dataList;
}
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-limitedrelationsgridfield,代码行数:26,代码来源:LRGridFieldAddExistingAutocompleter.php
示例2: merge_owners
/**
* Takes a list of groups and members and return a list of unique member.
*
* @param SS_List $groups
* @param SS_List $members
*
* @return ArrayList
*/
public static function merge_owners(SS_List $groups, SS_List $members)
{
$contentReviewOwners = new ArrayList();
if ($groups->count()) {
$groupIDs = array();
foreach ($groups as $group) {
$familyIDs = $group->collateFamilyIDs();
if (is_array($familyIDs)) {
$groupIDs = array_merge($groupIDs, array_values($familyIDs));
}
}
array_unique($groupIDs);
if (count($groupIDs)) {
$groupMembers = DataObject::get("Member")->where("\"Group\".\"ID\" IN (" . implode(",", $groupIDs) . ")")->leftJoin("Group_Members", "\"Member\".\"ID\" = \"Group_Members\".\"MemberID\"")->leftJoin("Group", "\"Group_Members\".\"GroupID\" = \"Group\".\"ID\"");
$contentReviewOwners->merge($groupMembers);
}
}
$contentReviewOwners->merge($members);
$contentReviewOwners->removeDuplicates();
return $contentReviewOwners;
}
示例3: buildFacets
/**
* This is super-slow. I'm assuming if you're using facets you
* probably also ought to be using Solr or something else. Or
* maybe you have unlimited time and can refactor this feature
* and submit a pull request...
*
* TODO: If this is going to be used for categories we're going
* to have to really clean it up and speed it up.
* Suggestion:
* - option to turn off counts
* - switch order of nested array so we don't go through results unless needed
* - if not doing counts, min/max and link facets can be handled w/ queries
* - separate that bit out into a new function
* NOTE: This is partially done with the "faster_faceting" config
* option but more could be done, particularly by covering link facets as well.
*
* Output - list of ArrayData in the format:
* Label - name of the facet
* Source - field name of the facet
* Type - one of the ShopSearch::FACET_TYPE_XXXX constants
* Values - SS_List of possible values for this facet
*
* @param SS_List $matches
* @param array $facetSpec
* @param bool $autoFacetAttributes [optional]
* @return ArrayList
*/
public function buildFacets(SS_List $matches, array $facetSpec, $autoFacetAttributes = false)
{
$facets = $this->expandFacetSpec($facetSpec);
if (!$autoFacetAttributes && (empty($facets) || !$matches || !$matches->count())) {
return new ArrayList();
}
$fasterMethod = (bool) $this->config()->faster_faceting;
// fill them in
foreach ($facets as $field => &$facet) {
if (preg_match(self::config()->attribute_facet_regex, $field, $m)) {
$this->buildAttributeFacet($matches, $facet, $m[1]);
continue;
}
// NOTE: using this method range and checkbox facets don't get counts
if ($fasterMethod && $facet['Type'] != ShopSearch::FACET_TYPE_LINK) {
if ($facet['Type'] == ShopSearch::FACET_TYPE_RANGE) {
if (isset($facet['RangeMin'])) {
$facet['MinValue'] = $facet['RangeMin'];
}
if (isset($facet['RangeMax'])) {
$facet['MaxValue'] = $facet['RangeMax'];
}
}
continue;
}
foreach ($matches as $rec) {
// If it's a range facet, set up the min/max
if ($facet['Type'] == ShopSearch::FACET_TYPE_RANGE) {
if (isset($facet['RangeMin'])) {
$facet['MinValue'] = $facet['RangeMin'];
}
if (isset($facet['RangeMax'])) {
$facet['MaxValue'] = $facet['RangeMax'];
}
}
// If the field is accessible via normal methods, including
// a user-defined getter, prefer that
$fieldValue = $rec->relObject($field);
if (is_null($fieldValue) && $rec->hasMethod($meth = "get{$field}")) {
$fieldValue = $rec->{$meth}();
}
// If not, look for a VFI field
if (!$fieldValue && $rec->hasExtension('VirtualFieldIndex')) {
$fieldValue = $rec->getVFI($field);
}
// If we found something, process it
if (!empty($fieldValue)) {
// normalize so that it's iterable
if (!is_array($fieldValue) && !$fieldValue instanceof SS_List) {
$fieldValue = array($fieldValue);
}
foreach ($fieldValue as $obj) {
if (empty($obj)) {
continue;
}
// figure out the right label
if (is_object($obj) && $obj->hasMethod('Nice')) {
$lbl = $obj->Nice();
} elseif (is_object($obj) && !empty($obj->Title)) {
$lbl = $obj->Title;
} elseif (is_numeric($obj) && !empty($facet['LabelFormat']) && $facet['LabelFormat'] === 'Currency' && $facet['Type'] !== ShopSearch::FACET_TYPE_RANGE) {
$tmp = Currency::create($field);
$tmp->setValue($obj);
$lbl = $tmp->Nice();
} else {
$lbl = (string) $obj;
}
// figure out the value for sorting
if (is_object($obj) && $obj->hasMethod('getAmount')) {
$val = $obj->getAmount();
} elseif (is_object($obj) && !empty($obj->ID)) {
$val = $obj->ID;
} else {
//.........这里部分代码省略.........
示例4: paginateList
/**
* turns full list into paginated list
* @param SS_List
* @return PaginatedList
*/
protected function paginateList(SS_List $list)
{
if ($list && $list->count()) {
if ($this->IsShowFullList()) {
$obj = PaginatedList::create($list, $this->request);
$obj->setPageLength(EcommerceConfig::get("ProductGroup", "maximum_number_of_products_to_list") + 1);
return $obj;
} else {
$obj = PaginatedList::create($list, $this->request);
$obj->setPageLength($this->MyNumberOfProductsPerPage());
return $obj;
}
}
}
示例5: getTemplateVariables
/**
* Gets list of safe template variables and their values which can be used
* in both the static and editable templates.
*
* {@see ContentReviewAdminHelp.ss}
*
* @param Member $recipient
* @param SiteConfig $config
* @param SS_List $pages
* @param string $type
*
* @return array
*/
protected function getTemplateVariables($recipient = null, $config, $pages)
{
if ($recipient != null) {
return array('Subject' => $config->ReviewSubject, 'PagesCount' => $pages->count(), 'FromEmail' => $config->ReviewFrom, 'ToFirstName' => $recipient->FirstName, 'ToSurname' => $recipient->Surname, 'ToEmail' => $recipient->Email);
} else {
return array('Subject' => $config->ReviewSubjectReminder, 'FirstReminderPagesCount' => $pages->count(), 'SecondReminderPagesCount' => $pages->count(), 'FromEmail' => $config->ReviewFrom, 'ToEmail' => $config->ReviewReminderEmail);
}
}