本文整理汇总了PHP中DataObjectSet::sort方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObjectSet::sort方法的具体用法?PHP DataObjectSet::sort怎么用?PHP DataObjectSet::sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObjectSet
的用法示例。
在下文中一共展示了DataObjectSet::sort方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Tables
function Tables()
{
$tables = new DataObjectSet();
foreach (DB::tableList() as $table) {
$tables->push(new DBP_Table($table));
}
$tables->sort('LowerCaseName');
return $tables;
}
示例2: blogOwners
/**
* Get members who have BLOGMANAGEMENT and ADMIN permission
*/
function blogOwners($sort = 'Name', $direction = "ASC")
{
$adminMembers = Permission::get_members_by_permission('ADMIN');
$blogOwners = Permission::get_members_by_permission('BLOGMANAGEMENT');
if (!$adminMembers) {
$adminMembers = new DataObjectSet();
}
if (!$blogOwners) {
$blogOwners = new DataObjectSet();
}
$blogOwners->merge($adminMembers);
$blogOwners->sort($sort, $direction);
$this->extend('extendBlogOwners', $blogOwners);
return $blogOwners;
}
示例3: 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;
}
}
示例4: getEstimates
function getEstimates()
{
if ($this->calculated) {
return $this->estimates;
}
$output = new DataObjectSet();
if ($options = $this->getShippingMethods()) {
foreach ($options as $option) {
$option->CalculatedRate = $option->calculateRate($this->package, $this->address);
if ($option->CalculatedRate !== null) {
$output->push($option);
}
}
}
$output->sort("CalculatedRate", "ASC");
//sort by rate, lowest to highest
// cache estimates
$this->estimates = $output;
$this->calculated = true;
return $output;
}
示例5: 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;
}
}
示例6: PageTypes
/**
* Populates an array of classes in the CMS
* which allows the user to change the page type.
*
* @return DataObjectSet
*/
public function PageTypes()
{
$classes = SiteTree::page_type_classes();
$result = new DataObjectSet();
foreach ($classes as $class) {
$instance = singleton($class);
if ($instance instanceof HiddenClass) {
continue;
}
if (!$instance->canCreate()) {
continue;
}
// skip this type if it is restricted
if ($instance->stat('need_permission') && !$this->can(singleton($class)->stat('need_permission'))) {
continue;
}
$addAction = $instance->i18n_singular_name();
// if we're in translation mode, the link between the translated pagetype
// title and the actual classname might not be obvious, so we add it in parantheses
// Example: class "RedirectorPage" has the title "Weiterleitung" in German,
// so it shows up as "Weiterleitung (RedirectorPage)"
if (i18n::get_locale() != 'en_US') {
$addAction .= " ({$class})";
}
$result->push(new ArrayData(array('ClassName' => $class, 'AddAction' => $addAction)));
}
$result->sort('AddAction');
return $result;
}
示例7: PageTypes
/**
* Populates an array of classes in the CMS which allows the
* user to change the page type.
*/
public function PageTypes()
{
$classes = ClassInfo::getValidSubClasses();
array_shift($classes);
$result = new DataObjectSet();
$kill_ancestors = array();
// figure out if there are any classes we don't want to appear
foreach ($classes as $class) {
$instance = singleton($class);
// do any of the progeny want to hide an ancestor?
if ($ancestor_to_hide = $instance->stat('hide_ancestor')) {
// note for killing later
$kill_ancestors[] = $ancestor_to_hide;
}
}
// If any of the descendents don't want any of the elders to show up, cruelly render the elders surplus to requirements.
if ($kill_ancestors) {
foreach ($kill_ancestors as $mark) {
// unset from $classes
$idx = array_search($mark, $classes);
unset($classes[$idx]);
}
}
foreach ($classes as $class) {
$instance = singleton($class);
if ($instance instanceof HiddenClass) {
continue;
}
if (!$instance->canCreate()) {
continue;
}
// skip this type if it is restricted
if ($instance->stat('need_permission') && !$this->can(singleton($class)->stat('need_permission'))) {
continue;
}
/*
* Since i18n_singular_name() this is not necessary
$addAction = $instance->uninherited('add_action', true);
if($addAction) {
// backwards compatibility for actions like "a page" (instead of "page")
$addAction = preg_replace('/^a /','',$addAction);
$addAction = ucfirst($addAction);
} else {
$addAction = $instance->i18n_singular_name();
}
*/
$addAction = $instance->i18n_singular_name();
$result->push(new ArrayData(array("ClassName" => $class, "AddAction" => $addAction)));
}
$result->sort('AddAction');
return $result;
}
示例8: getCMSFields
function getCMSFields()
{
if ($this->FolderID) {
// New token - select file:
$folder = DataObject::get_by_id('Folder', $this->FolderID);
$files = new DataObjectSet();
if ($folder->myChildren()) {
foreach ($folder->myChildren() as $file) {
if (!$file instanceof Folder) {
$files->push($file);
}
}
$files->sort('Name');
}
$fileField = new DropdownField('FileID', 'File', $files->map('ID', 'Name'));
} else {
// Existing token:
$fileField = new ReadonlyField('FileDummy', 'File', $this->File()->Name);
}
$fields = new FieldSet();
$fields->push($root = new TabSet('Root'));
$root->push($main = new Tab('Main'));
$main->push($fileField);
if (ClassInfo::exists('DatetimeField')) {
// 2.4.x
$main->push($expiry_field = new DatetimeField('Expiry', 'Expiry'));
$expiry_field->getDateField()->setConfig('showcalendar', true);
$expiry_field->getTimeField()->setConfig('showdropdown', true);
} else {
// 2.3.x
$main->push($expiry_field = new PopupDateTimeField('Expiry', 'Expiry'));
}
$main->push(new ReadonlyField('MemberDummyField', 'Member', $this->MemberNice()));
if ($this->ID) {
$main->push(new ReadonlyField('Token', 'Token'));
}
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例9: sourceRecords
function sourceRecords($params, $sort, $limit)
{
$join = '';
$sortBrokenReason = false;
if ($sort) {
$parts = explode(' ', $sort);
$field = $parts[0];
$direction = $parts[1];
if ($field == 'AbsoluteLink') {
$sort = 'URLSegment ' . $direction;
} elseif ($field == 'Subsite.Title') {
$join = 'LEFT JOIN "Subsite" ON "Subsite"."ID" = "SiteTree"."SubsiteID"';
} elseif ($field == 'BrokenReason') {
$sortBrokenReason = true;
$sort = '';
}
}
$q = DB::USE_ANSI_SQL ? '"' : '`';
if (!isset($_REQUEST['CheckSite']) || $params['CheckSite'] == 'Published') {
$ret = Versioned::get_by_stage('SiteTree', 'Live', "({$q}SiteTree{$q}.{$q}HasBrokenLink{$q} = 1 OR {$q}SiteTree{$q}.{$q}HasBrokenFile{$q} = 1)", $sort, $join, $limit);
} else {
$ret = DataObject::get('SiteTree', "({$q}SiteTree{$q}.{$q}HasBrokenFile{$q} = 1 OR {$q}HasBrokenLink{$q} = 1)", $sort, $join, $limit);
}
$returnSet = new DataObjectSet();
if ($ret) {
foreach ($ret as $record) {
$reason = false;
$isRedirectorPage = in_array($record->ClassName, ClassInfo::subclassesFor('RedirectorPage'));
$isVirtualPage = in_array($record->ClassName, ClassInfo::subclassesFor('VirtualPage'));
if ($isVirtualPage) {
if ($record->HasBrokenLink) {
$reason = _t('BrokenLinksReport.VirtualPageNonExistent', "virtual page pointing to non-existent page");
$reasonCodes = array("VPBROKENLINK");
}
} else {
if ($isRedirectorPage) {
if ($record->HasBrokenLink) {
$reason = _t('BrokenLinksReport.RedirectorNonExistent', "redirector page pointing to non-existent page");
$reasonCodes = array("RPBROKENLINK");
}
} else {
if ($record->HasBrokenLink && $record->HasBrokenFile) {
$reason = _t('BrokenLinksReport.HasBrokenLinkAndFile', "has broken link and file");
$reasonCodes = array("BROKENFILE", "BROKENLINK");
} else {
if ($record->HasBrokenLink && !$record->HasBrokenFile) {
$reason = _t('BrokenLinksReport.HasBrokenLink', "has broken link");
$reasonCodes = array("BROKENLINK");
} else {
if (!$record->HasBrokenLink && $record->HasBrokenFile) {
$reason = _t('BrokenLinksReport.HasBrokenFile', "has broken file");
$reasonCodes = array("BROKENFILE");
}
}
}
}
}
if ($reason) {
if (isset($params['Reason']) && $params['Reason'] && !in_array($params['Reason'], $reasonCodes)) {
continue;
}
$record->BrokenReason = $reason;
$returnSet->push($record);
}
}
}
if ($sortBrokenReason) {
$returnSet->sort('BrokenReason', $direction);
}
return $returnSet;
}
示例10: getVideosFeed
/**
* Retrieves a Videos Feed - generic method
*
* @param method - video function, actually the sub url of the feed eg:/playlists
* @param params - params to pass
* @param max_results - maximum results to return
* @param start_index - start index of the video feed
* @param orderby - Sorting method. The possible valus are relevance, updated, published, viewCount, rating
* @return DataObjectSet
*/
function getVideosFeed($method = NULL, $params = array(), $max_results = NULL, $start_index = NULL, $orderby = NULL)
{
if (array_key_exists($orderby, self::$sortby_processing)) {
$default_params = array('max-results' => 50);
} else {
$default_params = array('max-results' => $max_results, 'start-index' => $start_index, 'orderby' => $orderby);
}
$params = array_merge($params, $default_params);
$this->baseURL = self::$api_base_url . $method;
$this->setQueryString($params);
$response = $this->request();
//have to make a custom XML object
try {
$xml = @new SimpleXMLElement($response->getBody());
$videos = $xml->entry;
$results = new DataObjectSet();
foreach ($videos as $video) {
$data = $this->extractVideoInfo($video);
// Get the data requested
if (array_key_exists($orderby, self::$sortby_processing)) {
$customSortObj = $video->xpath(self::$sortby_processing[$orderby]);
$data['customsortby'] = count($customSortObj) ? (string) $customSortObj[0] : null;
}
$results->push(new ArrayData($data));
}
if (array_key_exists($orderby, self::$sortby_processing)) {
$results->sort('customsortby', 'DESC');
$results = $results->getRange(0, $max_results);
// we can't allow paging on custom filters
$this->videoCount = $results->Count();
$this->pageCount = 1;
} else {
//get total number of videos
$this->videoCount = $this->searchValue($response->getBody(), 'openSearch:totalResults');
$this->pageCount = (int) ($this->videoCount / $max_results);
}
return $results;
} catch (Exception $e) {
user_error("Error occurred in processing YouTube response");
return false;
}
}
示例11: dirname
/**
* Returns a list of valid languages from GeSHi
* @return DatObjectSet
*/
static function get_valid_languages()
{
require_once dirname(__DIR__) . '/thirdparty/geshi/geshi.php';
$g = new GeSHi();
$languages = new DataObjectSet();
foreach ($g->get_supported_languages(false) as $language) {
$languages->push(new ArrayData(array('ID' => $language, 'Name' => $language)));
}
$languages->sort('Name');
return $languages;
}
示例12: testSort
/**
* Test {@link DataObjectSet->sort()}
*/
function testSort()
{
$set = new DataObjectSet(array(array('Name' => 'Object1', 'F1' => 1, 'F2' => 2, 'F3' => 3), array('Name' => 'Object2', 'F1' => 2, 'F2' => 1, 'F3' => 4), array('Name' => 'Object3', 'F1' => 5, 'F2' => 2, 'F3' => 2)));
// test a single sort ASC
$set->sort('F3', 'ASC');
$this->assertEquals($set->First()->Name, 'Object3', 'Object3 should be first in the set');
// test a single sort DESC
$set->sort('F3', 'DESC');
$this->assertEquals($set->First()->Name, 'Object2', 'Object2 should be first in the set');
// test a multi sort
$set->sort(array('F2' => 'ASC', 'F1' => 'ASC'));
$this->assertEquals($set->Last()->Name, 'Object3', 'Object3 should be last in the set');
// test a multi sort
$set->sort(array('F2' => 'ASC', 'F1' => 'DESC'));
$this->assertEquals($set->Last()->Name, 'Object1', 'Object1 should be last in the set');
}
示例13: PageTypes
/**
* Populates an array of classes in the CMS
* which allows the user to change the page type.
*
* @return DataObjectSet
*/
public function PageTypes()
{
$classes = SiteTree::page_type_classes();
$result = new DataObjectSet();
foreach ($classes as $class) {
$instance = singleton($class);
if ($instance instanceof HiddenClass) {
continue;
}
if (!$instance->canCreate()) {
continue;
}
// skip this type if it is restricted
if ($instance->stat('need_permission') && !$this->can(singleton($class)->stat('need_permission'))) {
continue;
}
$addAction = $instance->i18n_singular_name();
// Get description
$description = _t($class . 'DESCRIPTION');
if (!$description) {
$description = $instance->uninherited('description');
}
if ($class == 'Page' && !$description) {
$description = singleton('SiteTree')->uninherited('description');
}
$result->push(new ArrayData(array('ClassName' => $class, 'AddAction' => $addAction, 'Description' => $description, 'IconURL' => $instance->stat('icon'))));
}
$result->sort('AddAction');
return $result;
}
示例14: getStickyTopics
/**
* Return the Sticky Threads
* @return DataObjectSet
*/
function getStickyTopics($include_global = true)
{
$standard = DataObject::get("ForumThread", "\"ForumThread\".\"ForumID\" = {$this->ID} AND \"ForumThread\".\"IsSticky\" = 1", "MAX(\"PostList\".\"Created\") DESC", "INNER JOIN \"Post\" AS \"PostList\" ON \"PostList\".\"ThreadID\" = \"ForumThread\".\"ID\"");
if (!$standard || !$standard->count()) {
$standard = new DataObjectSet();
}
if ($include_global) {
// We have to join posts through their forums to their holders, and then restrict the holders to just the parent of this forum.
$global = DataObject::get("ForumThread", "\"ForumThread\".\"IsGlobalSticky\" = 1", "MAX(\"PostList\".\"Created\") DESC", "INNER JOIN \"Post\" AS \"PostList\" ON \"PostList\".\"ThreadID\" = \"ForumThread\".\"ID\"");
if (!$global || !$global->count()) {
$global = new DataObjectSet();
}
$standard->merge($global);
$standard->removeDuplicates();
}
if ($standard->count()) {
$standard->sort('PostList.Created');
}
return $standard;
}