當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Page::write方法代碼示例

本文整理匯總了PHP中Page::write方法的典型用法代碼示例。如果您正苦於以下問題:PHP Page::write方法的具體用法?PHP Page::write怎麽用?PHP Page::write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Page的用法示例。


在下文中一共展示了Page::write方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testCanViewStage

 public function testCanViewStage()
 {
     // Create a new page
     $page = new Page();
     $page->URLSegment = 'testpage';
     $page->write();
     $page->publish('Stage', 'Live');
     // Add a stage-only version
     $page->Content = "Version2";
     $page->write();
     $response = $this->get('/testpage');
     $this->assertEquals($response->getStatusCode(), 200, "Doesn't require login for implicit live stage");
     $response = $this->get('/testpage/?stage=Live');
     $this->assertEquals($response->getStatusCode(), 200, "Doesn't require login for explicit live stage");
     try {
         $response = $this->get('/testpage/?stage=Stage');
     } catch (SS_HTTPResponse_Exception $responseException) {
         $response = $responseException->getResponse();
     }
     // should redirect to login
     $this->assertEquals($response->getStatusCode(), 302, 'Redirects to login page when not logged in for draft stage');
     $this->assertContains(Config::inst()->get('Security', 'login_url'), $response->getHeader('Location'));
     $this->logInWithPermission('CMS_ACCESS_CMSMain');
     $response = $this->get('/testpage/?stage=Stage');
     $this->assertEquals($response->getStatusCode(), 200, 'Doesnt redirect to login, but shows page for authenticated user');
 }
開發者ID:aaronleslie,項目名稱:aaronunix,代碼行數:26,代碼來源:ContentControllerPermissionsTest.php

示例2: importItem

 protected function importItem($item, $parentObject, $duplicateStrategy)
 {
     if ($item) {
         $externalId = $item->getExternalId();
         $parentFilter = $parentObject ? ' AND "ParentID" = ' . (int) $parentObject->ID : '';
         $existing = DataObject::get_one('Page', '"MetaTitle" = \'' . $externalId . '\'' . $parentFilter);
         if ($existing && $existing->exists()) {
             if ($duplicateStrategy == ExternalContentTransformer::DS_SKIP) {
                 return;
             }
             if ($duplicateStrategy == ExternalContentTransformer::DS_DUPLICATE) {
                 $existing = new Page();
             }
         } else {
             $existing = new Page();
         }
         $existing->Title = 'Tweet: ' . $item->Title;
         $existing->MetaTitle = $externalId;
         $existing->Content = $item->Tweet;
         if ($parentObject) {
             $existing->ParentID = $parentObject->ID;
         }
         $existing->write();
         $existing->Created = date('Y-m-d H:i:s', strtotime($item->Created));
         $existing->LegacyURL = $item->Link;
         $existing->MetaDescription = 'Tweet from ' . $item->CreatedBy . ' at ' . $item->Created;
         $existing->write();
         return $existing;
     }
 }
開發者ID:nyeholt,項目名稱:silverstripe-twitter-connector,代碼行數:30,代碼來源:TwitterContentItemImporter.php

示例3: testFindOldPage

 public function testFindOldPage()
 {
     $page = new Page();
     $page->Title = 'Test Page';
     $page->URLSegment = 'test-page';
     $page->write();
     $page->publish('Stage', 'Live');
     $page->URLSegment = 'test';
     $page->write();
     $page->publish('Stage', 'Live');
     $router = new ModelAsController();
     $request = new HTTPRequest('GET', 'test-page/action/id/otherid');
     $request->match('$URLSegment/$Action/$ID/$OtherID');
     $response = $router->handleRequest($request);
     $this->assertEquals($response->getHeader('Location'), Controller::join_links(Director::baseURL() . 'test/action/id/otherid'));
 }
開發者ID:racontemoi,項目名稱:shibuichi,代碼行數:16,代碼來源:ModelAsControllerTest.php

示例4: testReadOnlyTransaction

 function testReadOnlyTransaction()
 {
     if (DB::get_conn()->supportsTransactions() == true && DB::get_conn() instanceof PostgreSQLDatabase) {
         $page = new Page();
         $page->Title = 'Read only success';
         $page->write();
         DB::get_conn()->transactionStart('READ ONLY');
         try {
             $page = new Page();
             $page->Title = 'Read only page failed';
             $page->write();
         } catch (Exception $e) {
             //could not write this record
             //We need to do a rollback or a commit otherwise we'll get error messages
             DB::get_conn()->transactionRollback();
         }
         DB::get_conn()->transactionEnd();
         DataObject::flush_and_destroy_cache();
         $success = DataObject::get('Page', "\"Title\"='Read only success'");
         $fail = DataObject::get('Page', "\"Title\"='Read only page failed'");
         //This page should be in the system
         $this->assertTrue(is_object($success) && $success->exists());
         //This page should NOT exist, we had 'read only' permissions
         $this->assertFalse(is_object($fail) && $fail->exists());
     } else {
         $this->markTestSkipped('Current database is not PostgreSQL');
     }
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-postgresql,代碼行數:28,代碼來源:PostgreSQLDatabaseTest.php

示例5: testCreateWithTransaction

 function testCreateWithTransaction()
 {
     if (DB::getConn()->supportsTransactions() == true) {
         DB::getConn()->transactionStart();
         $page = new Page();
         $page->Title = 'First page';
         $page->write();
         $page = new Page();
         $page->Title = 'Second page';
         $page->write();
         //Create a savepoint here:
         DB::getConn()->transactionSavepoint('rollback');
         $page = new Page();
         $page->Title = 'Third page';
         $page->write();
         $page = new Page();
         $page->Title = 'Forth page';
         $page->write();
         //Revert to a savepoint:
         DB::getConn()->transactionRollback('rollback');
         DB::getConn()->transactionEnd();
         $first = DataObject::get('Page', "\"Title\"='First page'");
         $second = DataObject::get('Page', "\"Title\"='Second page'");
         $third = DataObject::get('Page', "\"Title\"='Third page'");
         $forth = DataObject::get('Page', "\"Title\"='Forth page'");
         //These pages should be in the system
         $this->assertTrue(is_object($first) && $first->exists());
         $this->assertTrue(is_object($second) && $second->exists());
         //These pages should NOT exist, we reverted to a savepoint:
         $this->assertFalse(is_object($third) && $third->exists());
         $this->assertFalse(is_object($forth) && $forth->exists());
     } else {
         $this->markTestSkipped('Current database does not support transactions');
     }
 }
開發者ID:hamishcampbell,項目名稱:silverstripe-sapphire,代碼行數:35,代碼來源:TransactionTest.php

示例6: pageIsBrokenFile

 protected function pageIsBrokenFile($content)
 {
     $page = new Page();
     $page->Content = $content;
     $page->write();
     return $page->HasBrokenFile;
 }
開發者ID:helpfulrobot,項目名稱:comperio-silverstripe-cms,代碼行數:7,代碼來源:SiteTreeLinkTrackingTest.php

示例7: requireDefaultRecords

 function requireDefaultRecords()
 {
     if ($this->class == 'TestPage') {
         return;
     }
     $class = $this->class;
     if (!DataObject::get_one($class)) {
         // Try to create common parent
         $parent = SiteTree::get()->filter('URLSegment', 'feature-test-pages')->First();
         if (!$parent) {
             $parent = new Page(array('Title' => 'Feature Test Pages', 'Content' => 'A collection of pages for testing various features in the SilverStripe CMS', 'ShowInMenus' => 0));
             $parent->write();
             $parent->doPublish();
         }
         // Create actual page
         $page = new $class();
         $page->Title = str_replace("TestPage", "", $class);
         $page->ShowInMenus = 0;
         if ($parent) {
             $page->ParentID = $parent->ID;
         }
         $page->write();
         $page->publish('Stage', 'Live');
     }
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-frameworktest,代碼行數:25,代碼來源:TestPage.php

示例8: testReadOnlyTransaction

 function testReadOnlyTransaction()
 {
     if (DB::getConn()->supportsTransactions() == true) {
         $page = new Page();
         $page->Title = 'Read only success';
         $page->write();
         DB::getConn()->startTransaction('READ ONLY');
         try {
             $page = new Page();
             $page->Title = 'Read only page failed';
             $page->write();
         } catch (Exception $e) {
             //could not write this record
             //We need to do a rollback or a commit otherwise we'll get error messages
             DB::getConn()->transactionRollback();
         }
         DB::getConn()->endTransaction();
         $success = DataObject::get('Page', "\"Title\"='Read only success'");
         $fail = DataObject::get('Page', "\"Title\"='Read only failed'");
         //This page should be in the system
         $this->assertTrue(is_object($success) && $success->exists());
         //This page should NOT exist, we had 'read only' permissions
         $this->assertFalse(is_object($fail) && $fail->exists());
     }
 }
開發者ID:SustainableCoastlines,項目名稱:loveyourwater,代碼行數:25,代碼來源:TransactionTest.php

示例9: run

 function run($request)
 {
     $id = $request->getVar('ID');
     if (!is_numeric($id) && !preg_match('/^[0-9]+_[0-9]+$/', $id) || !$id) {
         echo "<p>Specify ?ID=(number) or ?ID=(ID)_(Code)</p>\n";
         return;
     }
     $includeSelected = false;
     $includeChildren = true;
     $duplicates = 'Duplicate';
     $selected = $id;
     $target = new Page();
     $target->Title = "Import on " . date('Y-m-d H:i:s');
     $target->write();
     $targetType = 'SiteTree';
     $from = ExternalContent::getDataObjectFor($selected);
     if ($from instanceof ExternalContentSource) {
         $selected = false;
     }
     $importer = null;
     $importer = $from->getContentImporter($targetType);
     if ($importer) {
         $importer->import($from, $target, $includeSelected, $includeChildren, $duplicates);
     }
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-staticsiteconnector,代碼行數:25,代碼來源:ExternalContentImportContentTask.php

示例10: testDiffedChangesTitle

 public function testDiffedChangesTitle()
 {
     $page = new Page(array('Title' => 'My Title'));
     $page->write();
     $page->publish('Stage', 'Live');
     $page->Title = 'My Changed Title';
     $page->write();
     $page->publish('Stage', 'Live');
     $page->Title = 'My Unpublished Changed Title';
     $page->write();
     // Strip spaces from test output because they're not reliably maintained by the HTML Tidier
     $cleanDiffOutput = function ($val) {
         return str_replace(' ', '', strip_tags($val));
     };
     $this->assertContains(str_replace(' ', '', _t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Changed Title'), array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle')), 'Detects published title changes');
     $this->assertNotContains(str_replace(' ', '', _t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Unpublished Changed Title'), array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle')), 'Ignores unpublished title changes');
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-versionfeed,代碼行數:17,代碼來源:VersionFeedTest.php

示例11: testCreateNewContent

 public function testCreateNewContent()
 {
     $this->logInWithPermission('CMS_ACCESS_CMSMain');
     $mid = Member::currentUserID();
     // create some content and make a change. When saving, it should be added to the current user's
     // active changeset
     $obj = new Page();
     $obj->Title = "New Page";
     $obj->write();
     // it should have a changeset now
     $cs1 = $obj->getCurrentChangeset();
     $this->assertNotNull($cs1);
     $obj->Title = "New Page Title";
     $obj->write();
     $cs1 = $obj->getCurrentChangeset();
     $this->assertNotNull($cs1);
     $this->assertEquals(1, $cs1->getItems()->Count());
     $this->assertEquals("Active", $cs1->Status);
 }
開發者ID:nyeholt,項目名稱:silverstripe-changesets,代碼行數:19,代碼來源:TestChangesets.php

示例12: testPageURL

 public function testPageURL()
 {
     $page = new Page();
     $page->URLSegment = 'test';
     $page->write();
     $obj = new LinkFieldTest_DataObject();
     $obj->Link->setPageID($page->ID);
     $obj->write();
     $this->assertEquals($page->Link(), $obj->Link->URL);
 }
開發者ID:helpfulrobot,項目名稱:lrc-silverstripe-link-field,代碼行數:10,代碼來源:LinkFieldTest.php

示例13: setUp

 public function setUp()
 {
     parent::setUp();
     for ($i = 0; $i < 100; $i++) {
         $page = new Page(array('title' => "Page {$i}"));
         $page->write();
         $page->publish('Stage', 'Live');
     }
     $sitemap = new SiteMapPage();
     $sitemap->Title = 'SiteMap';
     $sitemap->write();
 }
開發者ID:Marketo,項目名稱:SilverStripe-Performable-Sitemaps,代碼行數:12,代碼來源:SiteMapControllerTest.php

示例14: testCustomSearchFormClassesToTest

	function testCustomSearchFormClassesToTest() {
		FulltextSearchable::enable('File');
		
		$page = new Page();
		$page->URLSegment = 'whatever';
		$page->Content = 'oh really?';
		$page->write();
		$page->publish('Stage', 'Live'); 
		$controller = new ContentController($page);
		$form = $controller->SearchForm(); 
		
		if (get_class($form) == 'SearchForm') $this->assertEquals(array('File'), $form->getClassesToSearch());
	}
開發者ID:redema,項目名稱:silverstripe-cms,代碼行數:13,代碼來源:ContentControllerSearchExtensionTest.php

示例15: setUp

 public function setUp()
 {
     parent::setUp();
     // create 2 pages
     for ($i = 0; $i < 2; ++$i) {
         $page = new Page(array('Title' => "Page {$i}"));
         $page->write();
         $page->publish('Stage', 'Live');
     }
     // reset configuration for the test.
     Config::nest();
     Config::inst()->update('Foo', 'bar', 'Hello!');
 }
開發者ID:titledk,項目名稱:silverstripe-uploaddirrules,代碼行數:13,代碼來源:UploadDirRulesTest.php


注:本文中的Page::write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。