本文整理汇总了PHP中DataObjectSet::getRange方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObjectSet::getRange方法的具体用法?PHP DataObjectSet::getRange怎么用?PHP DataObjectSet::getRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObjectSet
的用法示例。
在下文中一共展示了DataObjectSet::getRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sourceRecords
function sourceRecords($params, $sort, $limit)
{
increase_time_limit_to(120);
$res = WorkflowThreeStepRequest::get_by_publisher('WorkflowDeletionRequest', Member::currentUser(), array('Approved'));
$doSet = new DataObjectSet();
foreach ($res as $result) {
if ($wf = $result->openWorkflowRequest()) {
if (!$result->canDeleteFromLive()) {
continue;
}
$result->WFAuthorID = $wf->AuthorID;
$result->WFApproverTitle = $wf->Approver()->Title;
$result->WFAuthorTitle = $wf->Author()->Title;
$result->WFApprovedWhen = $wf->ApprovalDate();
$result->WFRequestedWhen = $wf->Created;
$result->WFApproverID = $wf->ApproverID;
$result->WFPublisherID = $wf->PublisherID;
if (isset($_REQUEST['OnlyMine']) && $result->WFApproverID != Member::currentUserID()) {
continue;
}
$result->BacklinkCount = $result->BackLinkTracking()->Count();
$doSet->push($result);
}
}
if ($sort) {
$parts = explode(' ', $sort);
$field = $parts[0];
$direction = $parts[1];
if ($field == 'AbsoluteLink') {
$sort = 'URLSegment ' . $direction;
}
if ($field == 'Subsite.Title') {
$sort = 'SubsiteID ' . $direction;
}
$doSet->sort($sort);
}
if ($limit && $limit['limit']) {
return $doSet->getRange($limit['start'], $limit['limit']);
} else {
return $doSet;
}
}
示例2: sourceRecords
function sourceRecords($params, $sort, $limit)
{
increase_time_limit_to(120);
$res = WorkflowTwoStepRequest::get_by_publisher('WorkflowPublicationRequest', Member::currentUser(), array('AwaitingApproval'));
$doSet = new DataObjectSet();
if ($res) {
foreach ($res as $result) {
if (!$result->canPublish()) {
continue;
}
if ($wf = $result->openWorkflowRequest()) {
if (ClassInfo::exists('Subsite')) {
$result->SubsiteTitle = $result->Subsite()->Title;
}
$result->RequestedAt = $wf->Created;
$result->WFAuthorTitle = $wf->Author()->Title;
$result->HasEmbargo = $wf->getEmbargoDate() ? date('j M Y g:ia', strtotime($wf->getEmbargoDate())) : 'no';
$doSet->push($result);
}
}
}
if ($sort) {
$parts = explode(' ', $sort);
$field = $parts[0];
$direction = $parts[1];
if ($field == 'AbsoluteLink') {
$sort = 'URLSegment ' . $direction;
}
if ($field == 'Subsite.Title') {
$sort = 'SubsiteID ' . $direction;
}
$doSet->sort($sort);
}
if ($limit && $limit['limit']) {
return $doSet->getRange($limit['start'], $limit['limit']);
} else {
return $doSet;
}
}
示例3: sourceRecords
function sourceRecords($params, $sort, $limit)
{
increase_time_limit_to(120);
$wheres = array();
// Emulate Form->loadDataFrom()
$fields = $this->parameterFields();
foreach ($fields as $field) {
if (isset($params[$field->Name()])) {
$val = $params[$field->Name()];
if ($val) {
$field->setValue($val);
}
}
}
$startDate = !empty($params['StartDate']) ? $params['StartDate'] : null;
$endDate = !empty($params['EndDate']) ? $params['EndDate'] : null;
if ($startDate) {
$startDate = $fields->dataFieldByName('StartDate')->dataValue();
}
if ($endDate) {
$endDate = $fields->dataFieldByName('EndDate')->dataValue();
}
if ($startDate && $endDate) {
$wheres[] = "\"EmbargoDate\" >= '" . Convert::raw2sql($startDate) . "' AND \"EmbargoDate\" <= '" . Convert::raw2sql($endDate) . "'";
} else {
if ($startDate && !$endDate) {
$wheres[] = "\"EmbargoDate\" >= '" . Convert::raw2sql($startDate) . "'";
} else {
if (!$startDate && $endDate) {
$wheres[] = "\"EmbargoDate\" <= '" . Convert::raw2sql($endDate) . "'";
} else {
$wheres[] = "\"EmbargoDate\" >= '" . SS_Datetime::now()->URLDate() . "'";
}
}
}
$wheres[] = "\"WorkflowRequest\".\"Status\" = 'Scheduled'";
$query = singleton("SiteTree")->extendedSQL(join(' AND ', $wheres), null, null, "LEFT JOIN \"WorkflowRequest\" ON \"WorkflowRequest\".\"PageID\" = \"SiteTree\".\"ID\"");
$query->select[] = "\"WorkflowRequest\".\"EmbargoDate\" AS \"EmbargoDate\"";
$query->from[] = "LEFT JOIN \"Member\" AS \"Approver\" ON \"WorkflowRequest\".\"ApproverID\" = \"Approver\".\"ID\"";
$query->select[] = Member::get_title_sql('Approver') . ' AS "ApproverName"';
$join = '';
if ($sort) {
$parts = explode(' ', $sort);
$field = $parts[0];
$direction = $parts[1];
if ($field == 'AbsoluteLink') {
$sort = '"URLSegment" ' . $direction;
}
if ($field == 'Subsite.Title') {
$query->from[] = 'LEFT JOIN "Subsite" ON "Subsite"."ID" = "SiteTree"."SubsiteID"';
}
}
if ($sort) {
$query->orderby = $sort;
}
// Postgres and MSSQL require these fields in the groupby[] array:
$query->groupby[] = "\"WorkflowRequest\".\"EmbargoDate\"";
$query->groupby[] = "\"Approver\".\"Surname\"";
$query->groupby[] = "\"Approver\".\"FirstName\"";
// Turn a query into records
$records = singleton('SiteTree')->buildDataObjectSet($query->execute(), 'DataObjectSet', $query);
// Backwards compat method signature with 2.4
$fn = method_exists('SiteTree', 'prepopulate_permission_cache') ? 'prepopulate_permission_cache' : 'prepopuplate_permission_cache';
if ($records) {
SiteTree::$fn('edit', $records->column('ID'));
}
// Filter to only those with canEdit permission
$filteredRecords = new DataObjectSet();
if ($records) {
foreach ($records as $record) {
if ($record->canEdit()) {
$filteredRecords->push($record);
// Add any related pages to the list as well to ensure authors
// can review what they're actually scheduling
$virtualPages = $record->VirtualPages();
if ($virtualPages) {
foreach ($virtualPages as $virtualPage) {
// Simulate custom SQL fields from WorkflowRequest join
$virtualPage->EmbargoDate = $record->EmbargoDate;
$virtualPage->ApproverName = $record->ApproverName;
$filteredRecords->push($virtualPage);
}
}
}
}
}
// Apply limit after that filtering.
if ($limit && $limit['limit']) {
return $filteredRecords->getRange($limit['start'], $limit['limit']);
} else {
return $filteredRecords;
}
}