本文整理匯總了PHP中DataObjectSet::column方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataObjectSet::column方法的具體用法?PHP DataObjectSet::column怎麽用?PHP DataObjectSet::column使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DataObjectSet
的用法示例。
在下文中一共展示了DataObjectSet::column方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
function run(DataObjectSet $pages)
{
$pageIDs = $pages->column('ID');
foreach ($pageIDs as $pageID) {
FormResponse::add("\$('Form_EditForm').reloadIfSetTo({$pageID});");
}
$this->batchaction($pages, 'batchApprove', _t('BatchApprovePages.APPROVED_PAGES', 'Approved %d pages, %d failures'));
return FormResponse::respond();
}
示例2: getCMSFields
/**
* Caution: Only call on instances, not through a singleton.
*
* @return FieldSet
*/
public function getCMSFields()
{
$fields = new FieldSet(new TabSet("Root", new Tab(_t('SecurityAdmin.MEMBERS', 'Members'), new TextField("Title", $this->fieldLabel('Title')), $memberList = new MemberTableField($this, "Members", $this, null, false)), $permissionsTab = new Tab(_t('SecurityAdmin.PERMISSIONS', 'Permissions'), new PermissionCheckboxSetField('Permissions', false, 'Permission', 'GroupID', $this)), new Tab(_t('Security.IPADDRESSES', 'IP Addresses'), new LiteralField("", _t('SecurityAdmin.IPADDRESSESHELP', "<p>You can restrict this group to a particular \n\t\t\t\t\t\tIP address range (one range per line). <br />Ranges can be in any of the following forms: <br />\n\t\t\t\t\t\t203.96.152.12<br />\n\t\t\t\t\t\t203.96.152/24<br />\n\t\t\t\t\t\t203.96/16<br />\n\t\t\t\t\t\t203/8<br /><br />If you enter one or more IP address ranges in this box, then members will only get\n\t\t\t\t\t\tthe rights of being in this group if they log on from one of the valid IP addresses. It won't prevent\n\t\t\t\t\t\tpeople from logging in. This is because the same user might have to log in to access parts of the\n\t\t\t\t\t\tsystem without IP address restrictions.")), new TextareaField("IPRestrictions", "IP Ranges", 10))));
// Only add a dropdown for HTML editor configurations if more than one is available.
// Otherwise Member->getHtmlEditorConfigForCMS() will default to the 'cms' configuration.
$editorConfigMap = HtmlEditorConfig::get_available_configs_map();
if (count($editorConfigMap) > 1) {
$fields->addFieldToTab('Root.Permissions', new DropdownField('HtmlEditorConfig', 'HTML Editor Configuration', $editorConfigMap), 'Permissions');
}
if (!Permission::check('EDIT_PERMISSIONS')) {
$fields->removeFieldFromTab('Root', 'Permissions');
$fields->removeFieldFromTab('Root', 'IP Addresses');
}
// Only show the "Roles" tab if permissions are granted to edit them,
// and at least one role exists
if (Permission::check('APPLY_ROLES') && DataObject::get('PermissionRole')) {
$fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.ROLES', 'Roles'));
$fields->addFieldToTab('Root.Roles', new LiteralField("", "<p>" . _t('SecurityAdmin.ROLESDESCRIPTION', "This section allows you to add roles to this group. Roles are logical groupings of permissions, which can be editied in the Roles tab") . "</p>"));
// Add roles (and disable all checkboxes for inherited roles)
$allRoles = Permission::check('ADMIN') ? DataObject::get('PermissionRole') : DataObject::get('PermissionRole', 'OnlyAdminCanApply = 0');
$groupRoles = $this->Roles();
$inheritedRoles = new DataObjectSet();
$ancestors = $this->getAncestors();
foreach ($ancestors as $ancestor) {
$ancestorRoles = $ancestor->Roles();
if ($ancestorRoles) {
$inheritedRoles->merge($ancestorRoles);
}
}
$fields->findOrMakeTab('Root.Roles', 'Root.' . _t('SecurityAdmin.ROLES', 'Roles'));
$fields->addFieldToTab('Root.Roles', $rolesField = new CheckboxSetField('Roles', 'Roles', $allRoles));
$rolesField->setDefaultItems($inheritedRoles->column('ID'));
$rolesField->setDisabledItems($inheritedRoles->column('ID'));
}
$memberList->setController($this);
$memberList->setPermissions(array('edit', 'delete', 'export', 'add', 'inlineadd'));
$memberList->setParentClass('Group');
$memberList->setPopupCaption(_t('SecurityAdmin.VIEWUSER', 'View User'));
$memberList->setRelationAutoSetting(false);
$fields->push($idField = new HiddenField("ID"));
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例3: run
function run(DataObjectSet $pages)
{
$pageIDs = $pages->column('ID');
foreach ($pageIDs as $pageID) {
FormResponse::add("\$('Form_EditForm').reloadIfSetTo({$pageID});");
}
$count = array();
$count['PUBLISH_SUCCESS'] = $count['DELETE_SUCCESS'] = 0;
$count['PUBLISH_FAILURE'] = $count['DELETE_FAILURE'] = 0;
$arbitraryPage = $pages->First();
$arbitraryPage->invokeWithExtensions('onBeforeBatchPublish', $pages);
foreach ($pages as $page) {
$type = $page->openWorkflowRequest() instanceof WorkflowDeletionRequest ? 'DELETE' : 'PUBLISH';
if ($page->batchPublish()) {
$count[$type . '_SUCCESS']++;
// Now make sure the tree title is appropriately updated
$publishedRecord = DataObject::get_by_id('SiteTree', $page->ID);
if ($publishedRecord) {
$JS_title = Convert::raw2js($publishedRecord->TreeTitle());
FormResponse::add("\$('sitetree').setNodeTitle({$page->ID}, '{$JS_title}');");
}
} else {
$count[$type . '_FAILURE']++;
FormResponse::add("\$('sitetree').addNodeClassByIdx('{$page->ID}', 'failed');");
}
$page->destroy();
unset($page);
}
$arbitraryPage->invokeWithExtensions('onAfterBatchPublish', $pages);
$messages = array('PUBLISH_SUCCESS' => _t('BatchPublishPages.PUBLISH_SUCCESS', 'Published %d pages.'), 'PUBLISH_FAILURE' => _t('BatchPublishPages.PUBLISH_FAILURE', 'Failed to publish %d pages.'), 'DELETE_SUCCESS' => _t('BatchPublishPages.DELETE_SUCCESS', 'Deleted %d pages from the published site.'), 'DELETE_FAILURE' => _t('BatchPublishPages.DELETE_FAILURE', 'Failed to delete %d pages from the published site.'), 'PUBLISH_SUCCESS_ONE' => _t('BatchPublishPages.PUBLISH_SUCCESS_ONE', 'Published %d page.'), 'PUBLISH_FAILURE_ONE' => _t('BatchPublishPages.PUBLISH_FAILURE_ONE', 'Failed to publish %d page.'), 'DELETE_SUCCESS_ONE' => _t('BatchPublishPages.DELETE_SUCCESS_ONE', 'Deleted %d page from the published site.'), 'DELETE_FAILURE_ONE' => _t('BatchPublishPages.DELETE_FAILURE_ONE', 'Failed to delete %d page from the published site.'));
$displayedMessages = array();
foreach ($count as $type => $count) {
if ($count) {
$message = $count == 1 ? $messages[$type . '_ONE'] : $messages[$type];
$displayedMessages[] = sprintf($message, $count);
}
}
$displayedMessage = implode(" ", $displayedMessages);
FormResponse::add('statusMessage("' . $displayedMessage . '","good");');
return FormResponse::respond();
}
示例4: run
function run(DataObjectSet $pages)
{
$ids = $pages->column('ID');
$this->batchaction($pages, 'doUnpublish', _t('CMSBatchActions.DELETED_PAGES', 'Deleted %d pages from the published site, %d failures'));
foreach ($ids as $pageID) {
$id = $pageID;
// check to see if the record exists on the stage site, if it doesn't remove the tree node
$stageRecord = Versioned::get_one_by_stage('SiteTree', 'Stage', "\"SiteTree\".\"ID\"={$id}");
if ($stageRecord) {
$stageRecord->IsAddedToStage = true;
$title = Convert::raw2js($stageRecord->TreeTitle());
FormResponse::add("\$('sitetree').setNodeTitle({$id}, '{$title}');");
FormResponse::add("\$('Form_EditForm').reloadIfSetTo({$id});");
} else {
FormResponse::add("var node = \$('sitetree').getTreeNodeByIdx('{$id}');");
FormResponse::add("if(node && node.parentTreeNode)\tnode.parentTreeNode.removeTreeNode(node);");
FormResponse::add("\$('Form_EditForm').reloadIfSetTo({$id});");
}
}
return FormResponse::respond();
}
示例5: testBatchSetResetExpiry
function testBatchSetResetExpiry()
{
$oldRequest = $_REQUEST;
$action = new BatchSetExpiry();
$this->assertTrue(is_string($action->getActionTitle()));
$this->assertTrue(is_string($action->getDoingText()));
$this->assertTrue($action->getParameterFields() instanceof FieldSet);
$this->logInAs($this->objFromFixture('Member', 'admin'));
$page1 = new Page();
$page1->write();
$page1->openOrNewWorkflowRequest('WorkflowPublicationRequest');
$page1ID = $page1->ID;
$page2 = new Page();
$page2->Content = '<a href="' . $page1->AbsoluteLink() . '">link here</a>';
$page2->write();
$page2ID = $page2->ID;
$pages = new DataObjectSet();
$pages->push($page1);
$pages->push($page2);
$this->assertEquals(array($page1->ID), $action->applicablePages($pages->column('ID')), 'applicableIds only returns pages with open requests');
SS_Datetime::set_mock_now('2009-06-15 15:00:00');
$_REQUEST['ExpiryDate_Batch'] = array('date' => '31/01/2010', 'time' => '3:00 pm');
$_REQUEST['ajax'] = 1;
// Test confirmation dialog
$page1->BacklinkTracking()->add($page2);
$confirmation = $action->confirmationDialog($pages->column('ID'));
$this->assertTrue($confirmation['alert']);
$action->run($pages);
$page1 = DataObject::get_by_id('Page', $page1ID);
$page2 = DataObject::get_by_id('Page', $page2ID);
$this->assertEquals($page1->ExpiryDate, '2010-01-31 15:00:00');
$this->assertNull($page2->openWorkflowRequest());
$this->assertNull($page2->ExpiryDate);
// Now test resetting
$action = new BatchResetExpiry();
$this->assertTrue(is_string($action->getActionTitle()));
$this->assertTrue(is_string($action->getDoingText()));
$pages = new DataObjectSet();
$pages->push($page1);
$pages->push($page2);
$this->assertEquals(array($page1->ID), $action->applicablePages(array($page1->ID, $page2->ID)), 'applicableIds only returns pages with open requests');
$action->run($pages);
$page1 = DataObject::get_by_id('Page', $page1ID);
$page2 = DataObject::get_by_id('Page', $page2ID);
$this->assertNull($page1->openWorkflowRequest()->ExpiryDate);
$this->assertNull($page2->openWorkflowRequest());
$_REQUEST = $oldRequest;
SS_Datetime::clear_mock_now();
}
示例6: testBatchActionsAndFilters
function testBatchActionsAndFilters()
{
// Get fixtures
$page1 = $this->objFromFixture('SiteTree', 'batchTest1');
$page2 = $this->objFromFixture('SiteTree', 'batchTest2');
$page3 = $this->objFromFixture('SiteTree', 'batchTest3');
$page4 = $this->objFromFixture('SiteTree', 'batchTest4');
$page5 = $this->objFromFixture('SiteTree', 'batchTest5');
$custompublisher = $this->objFromFixture('Member', 'custompublisher');
$customauthor = $this->objFromFixture('Member', 'customauthor');
$customapprover = $this->objFromFixture('Member', 'customapprover');
// Modify content
$page1->Title = rand();
$page1->write();
$page2->Title = rand();
$page2->write();
$page3->Title = rand();
$page3->write();
$page4->Title = rand();
$page4->write();
$page5->Title = rand();
$page5->write();
// Create WF requests for each of em
$customauthor->logIn();
$wf1 = $page1->openOrNewWorkflowRequest('WorkflowPublicationRequest');
$wf2 = $page2->openOrNewWorkflowRequest('WorkflowPublicationRequest');
$wf3 = $page3->openOrNewWorkflowRequest('WorkflowPublicationRequest');
$wf4 = $page4->openOrNewWorkflowRequest('WorkflowPublicationRequest');
$wf5 = $page5->openOrNewWorkflowRequest('WorkflowPublicationRequest');
// // Create dataset
$doSet = new DataObjectSet();
$doSet->push($page1);
$doSet->push($page2);
$doSet->push($page3);
$doSet->push($page4);
// Test awaiting approval filters
$filter = new CMSWorkflowThreeStepFilters_PagesAwaitingApproval();
$this->assertTrue(is_string(CMSWorkflowThreeStepFilters_PagesAwaitingApproval::title()));
// If it is ss2.4
if ($filter->hasMethod('includeInTree')) {
$filter->getTree();
$this->assertTrue($filter->includeInTree($page1));
$this->assertTrue($filter->includeInTree($page2));
$this->assertTrue($filter->includeInTree($page3));
$this->assertTrue($filter->includeInTree($page4));
} else {
$this->assertTrue($filter->isPageIncluded($page1));
$this->assertTrue($filter->isPageIncluded($page2));
$this->assertTrue($filter->isPageIncluded($page3));
$this->assertTrue($filter->isPageIncluded($page4));
}
// Batch approve
$customapprover->logIn();
$this->session()->inst_set('loggedInAs', $customapprover->ID);
$_REQUEST['ajax'] = 1;
// Simulate response and request for batch action
$controller = Controller::curr();
$controller->handleRequest(new SS_HTTPRequest('GET', 'admin'));
$pageIds = $doSet->column('ID');
$action = new BatchApprovePages();
$this->assertTrue(is_string($action->getActionTitle()));
$this->assertTrue(is_string($action->getDoingText()));
$this->assertEquals($pageIds, $action->applicablePages($pageIds), 'applicableIds only returns pages with open requests');
$action->run($doSet);
$page1 = DataObject::get_by_id('SiteTree', $pageIds[0]);
$page2 = DataObject::get_by_id('SiteTree', $pageIds[1]);
$page3 = DataObject::get_by_id('SiteTree', $pageIds[2]);
$page4 = DataObject::get_by_id('SiteTree', $pageIds[3]);
$doSet = new DataObjectSet();
$doSet->push($page1);
$doSet->push($page2);
$doSet->push($page3);
$doSet->push($page4);
$this->assertEquals($page1->openWorkflowRequest()->Status, 'Approved', 'Workflow status is approved after batch action');
$this->assertEquals($page2->openWorkflowRequest()->Status, 'Approved', 'Workflow status is approved after batch action');
$this->assertEquals($page3->openWorkflowRequest()->Status, 'Approved', 'Workflow status is approved after batch action');
$this->assertEquals($page4->openWorkflowRequest()->Status, 'Approved', 'Workflow status is approved after batch action');
// Test awaiting publication filters
$filter = new CMSWorkflowThreeStepFilters_PagesAwaitingPublishing();
$this->assertTrue(is_string(CMSWorkflowThreeStepFilters_PagesAwaitingPublishing::title()));
// If it is ss2.4
if ($filter->hasMethod('includeInTree')) {
$filter->getTree();
$this->assertTrue($filter->includeInTree($page1));
$this->assertTrue($filter->includeInTree($page2));
$this->assertTrue($filter->includeInTree($page3));
$this->assertTrue($filter->includeInTree($page4));
} else {
$this->assertTrue($filter->isPageIncluded($page1));
$this->assertTrue($filter->isPageIncluded($page2));
$this->assertTrue($filter->isPageIncluded($page3));
$this->assertTrue($filter->isPageIncluded($page4));
}
// Batch publish
$custompublisher->logIn();
$action = new BatchPublishPages();
$this->assertTrue(is_string($action->getActionTitle()));
$this->assertTrue(is_string($action->getDoingText()));
$this->assertEquals($pageIds, $action->applicablePages($doSet->column('ID')), 'applicableIds only returns pages with open requests');
$action->run($doSet);
//.........這裏部分代碼省略.........
示例7: get_by_publisher
public static function get_by_publisher($class, $publisher, $status = null)
{
// To ensure 2.3 and 2.4 compatibility
$bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
if ($status) {
$statusStr = "'" . implode("','", $status) . "'";
}
$classes = (array) ClassInfo::subclassesFor($class);
$classesSQL = implode("','", $classes);
// build filter
$filter = "{$bt}WorkflowRequest{$bt}.{$bt}ClassName{$bt} IN ('{$classesSQL}') ";
if ($status) {
$filter .= "AND {$bt}WorkflowRequest{$bt}.{$bt}Status{$bt} IN (" . $statusStr . ")";
}
$onDraft = Versioned::get_by_stage("SiteTree", "Stage", $filter, "{$bt}SiteTree{$bt}.{$bt}LastEdited{$bt} DESC", "LEFT JOIN {$bt}WorkflowRequest{$bt} ON {$bt}WorkflowRequest{$bt}.{$bt}PageID{$bt} = {$bt}SiteTree{$bt}.{$bt}ID{$bt} ");
$onLive = Versioned::get_by_stage("SiteTree", "Live", $filter, "{$bt}SiteTree_Live{$bt}.{$bt}LastEdited{$bt} DESC", "LEFT JOIN {$bt}WorkflowRequest{$bt} ON {$bt}WorkflowRequest{$bt}.{$bt}PageID{$bt} = {$bt}SiteTree_Live{$bt}.{$bt}ID{$bt} ");
$return = new DataObjectSet();
$return->merge($onDraft);
$return->merge($onLive);
$return->removeDuplicates();
$canPublish = SiteTree::batch_permission_check($return->column('ID'), $publisher->ID, 'CanPublishType', 'SiteTree_PublisherGroups', 'canPublish');
foreach ($return as $page) {
if (!isset($canPublish[$page->ID]) || !$canPublish[$page->ID]) {
$return->remove($page);
}
}
return $return;
}