本文整理汇总了PHP中SS_List::Count方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_List::Count方法的具体用法?PHP SS_List::Count怎么用?PHP SS_List::Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_List
的用法示例。
在下文中一共展示了SS_List::Count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: batchaction
/**
* Helper method for processing batch actions.
* Returns a set of status-updating JavaScript to return to the CMS.
*
* @param $objs The SS_List of objects to perform this batch action
* on.
* @param $helperMethod The method to call on each of those objects.
* @return JSON encoded map in the following format:
* {
* 'modified': {
* 3: {'TreeTitle': 'Page3'},
* 5: {'TreeTitle': 'Page5'}
* },
* 'deleted': {
* // all deleted pages
* }
* }
*/
public function batchaction(SS_List $objs, $helperMethod, $successMessage, $arguments = array()) {
$status = array('modified' => array(), 'error' => array());
foreach($objs as $obj) {
// Perform the action
if (!call_user_func_array(array($obj, $helperMethod), $arguments)) {
$status['error'][$obj->ID] = '';
}
// Now make sure the tree title is appropriately updated
$publishedRecord = DataObject::get_by_id($this->managedClass, $obj->ID);
if ($publishedRecord) {
$status['modified'][$publishedRecord->ID] = array(
'TreeTitle' => $publishedRecord->TreeTitle,
);
}
$obj->destroy();
unset($obj);
}
$response = Controller::curr()->getResponse();
if($response) {
$response->setStatusCode(
200,
sprintf($successMessage, $objs->Count(), count($status['error']))
);
}
return Convert::raw2json($status);
}
示例2: Field
public function Field($properties = array())
{
Requirements::css(FRAMEWORK_DIR . '/css/CheckboxSetField.css');
Requirements::javascript(FRAMEWORK_DIR . '/javascript/PermissionCheckboxSetField.js');
$uninheritedCodes = array();
$inheritedCodes = array();
$records = $this->records ? $this->records : new ArrayList();
// Get existing values from the form record (assuming the formfield name is a join field on the record)
if (is_object($this->form)) {
$record = $this->form->getRecord();
if ($record && (is_a($record, 'Group') || is_a($record, 'PermissionRole')) && !$records->find('ID', $record->ID)) {
$records->push($record);
}
}
// Get all 'inherited' codes not directly assigned to the group (which is stored in $values)
foreach ($records as $record) {
// Get all uninherited permissions
$relationMethod = $this->name;
foreach ($record->{$relationMethod}() as $permission) {
if (!isset($uninheritedCodes[$permission->Code])) {
$uninheritedCodes[$permission->Code] = array();
}
$uninheritedCodes[$permission->Code][] = _t('PermissionCheckboxSetField.AssignedTo', 'assigned to "{title}"', array('title' => $record->Title));
}
// Special case for Group records (not PermissionRole):
// Determine inherited assignments
if (is_a($record, 'Group')) {
// Get all permissions from roles
if ($record->Roles()->Count()) {
foreach ($record->Roles() as $role) {
foreach ($role->Codes() as $code) {
if (!isset($inheritedCodes[$code->Code])) {
$inheritedCodes[$code->Code] = array();
}
$inheritedCodes[$code->Code][] = _t('PermissionCheckboxSetField.FromRole', 'inherited from role "{title}"', 'A permission inherited from a certain permission role', array('title' => $role->Title));
}
}
}
// Get from parent groups
$parentGroups = $record->getAncestors();
if ($parentGroups) {
foreach ($parentGroups as $parent) {
if (!$parent->Roles()->Count()) {
continue;
}
foreach ($parent->Roles() as $role) {
if ($role->Codes()) {
foreach ($role->Codes() as $code) {
if (!isset($inheritedCodes[$code->Code])) {
$inheritedCodes[$code->Code] = array();
}
$inheritedCodes[$code->Code][] = _t('PermissionCheckboxSetField.FromRoleOnGroup', 'inherited from role "%s" on group "%s"', 'A permission inherited from a role on a certain group', array('roletitle' => $role->Title, 'grouptitle' => $parent->Title));
}
}
}
if ($parent->Permissions()->Count()) {
foreach ($parent->Permissions() as $permission) {
if (!isset($inheritedCodes[$permission->Code])) {
$inheritedCodes[$permission->Code] = array();
}
$inheritedCodes[$permission->Code][] = _t('PermissionCheckboxSetField.FromGroup', 'inherited from group "{title}"', 'A permission inherited from a certain group', array('title' => $parent->Title));
}
}
}
}
}
}
$odd = 0;
$options = '';
$globalHidden = (array) Config::inst()->get('Permission', 'hidden_permissions');
if ($this->source) {
$privilegedPermissions = Permission::config()->privileged_permissions;
// loop through all available categorized permissions and see if they're assigned for the given groups
foreach ($this->source as $categoryName => $permissions) {
$options .= "<li><h5>{$categoryName}</h5></li>";
foreach ($permissions as $code => $permission) {
if (in_array($code, $this->hiddenPermissions)) {
continue;
}
if (in_array($code, $globalHidden)) {
continue;
}
$value = $permission['name'];
$odd = ($odd + 1) % 2;
$extraClass = $odd ? 'odd' : 'even';
$extraClass .= ' val' . str_replace(' ', '', $code);
$itemID = $this->id() . '_' . preg_replace('/[^a-zA-Z0-9]+/', '', $code);
$checked = $disabled = $inheritMessage = '';
$checked = isset($uninheritedCodes[$code]) || isset($inheritedCodes[$code]) ? ' checked="checked"' : '';
$title = $permission['help'] ? 'title="' . htmlentities($permission['help'], ENT_COMPAT, 'UTF-8') . '" ' : '';
if (isset($inheritedCodes[$code])) {
// disable inherited codes, as any saving logic would be too complicate to express in this
// interface
$disabled = ' disabled="true"';
$inheritMessage = ' (' . join(', ', $inheritedCodes[$code]) . ')';
} elseif ($this->records && $this->records->Count() > 1 && isset($uninheritedCodes[$code])) {
// If code assignments are collected from more than one "source group",
// show its origin automatically
$inheritMessage = ' (' . join(', ', $uninheritedCodes[$code]) . ')';
}
//.........这里部分代码省略.........
示例3: Count
public function Count()
{
return $this->list->Count();
}
示例4: Field
function Field($properties = array()) {
Requirements::css(FRAMEWORK_DIR . '/css/CheckboxSetField.css');
Requirements::javascript(FRAMEWORK_DIR . '/javascript/PermissionCheckboxSetField.js');
$uninheritedCodes = array();
$inheritedCodes = array();
$records = ($this->records) ? $this->records : new ArrayList();
// Get existing values from the form record (assuming the formfield name is a join field on the record)
if(is_object($this->form)) {
$record = $this->form->getRecord();
if(
$record
&& (is_a($record, 'Group') || is_a($record, 'PermissionRole'))
&& !$records->find('ID', $record->ID)
) {
$records->push($record);
}
}
// Get all 'inherited' codes not directly assigned to the group (which is stored in $values)
foreach($records as $record) {
// Get all uninherited permissions
$relationMethod = $this->name;
foreach($record->$relationMethod() as $permission) {
if(!isset($uninheritedCodes[$permission->Code])) $uninheritedCodes[$permission->Code] = array();
$uninheritedCodes[$permission->Code][] = sprintf(
_t('PermissionCheckboxSetField.AssignedTo', 'assigned to "%s"'),
$record->Title
);
}
// Special case for Group records (not PermissionRole):
// Determine inherited assignments
if(is_a($record, 'Group')) {
// Get all permissions from roles
if ($record->Roles()->Count()) {
foreach($record->Roles() as $role) {
foreach($role->Codes() as $code) {
if (!isset($inheritedCodes[$code->Code])) $inheritedCodes[$code->Code] = array();
$inheritedCodes[$code->Code][] = sprintf(
_t(
'PermissionCheckboxSetField.FromRole',
'inherited from role "%s"',
'A permission inherited from a certain permission role'
),
$role->Title
);
}
}
}
// Get from parent groups
$parentGroups = $record->getAncestors();
if ($parentGroups) {
foreach ($parentGroups as $parent) {
if (!$parent->Roles()->Count()) continue;
foreach($parent->Roles() as $role) {
if ($role->Codes()) {
foreach($role->Codes() as $code) {
if (!isset($inheritedCodes[$code->Code])) $inheritedCodes[$code->Code] = array();
$inheritedCodes[$code->Code][] = sprintf(
_t(
'PermissionCheckboxSetField.FromRoleOnGroup',
'inherited from role "%s" on group "%s"',
'A permission inherited from a role on a certain group'
),
$role->Title,
$parent->Title
);
}
}
}
if ($parent->Permissions()->Count()) {
foreach($parent->Permissions() as $permission) {
if (!isset($inheritedCodes[$permission->Code])) $inheritedCodes[$permission->Code] = array();
$inheritedCodes[$permission->Code][] =
sprintf(
_t(
'PermissionCheckboxSetField.FromGroup',
'inherited from group "%s"',
'A permission inherited from a certain group'
),
$parent->Title
);
}
}
}
}
}
}
$odd = 0;
$options = '';
if($this->source) {
// loop through all available categorized permissions and see if they're assigned for the given groups
foreach($this->source as $categoryName => $permissions) {
//.........这里部分代码省略.........