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


PHP PageModel::GetSchema方法代碼示例

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


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

示例1: pages

	/**
	 * Display a listing of all pages registered in the system.
	 */
	public function pages(){
		$view = $this->getView();
		$request = $this->getPageRequest();

		if(!\Core\user()->checkAccess('p:/core/pages/view')){
			return View::ERROR_ACCESSDENIED;
		}

		// Build a list of create pages for all registered components.
		$components = Core::GetComponents();
		$links = [];
		$componentopts = ['' => '-- ' . t('STRING_VIEW_ALL_COMPONENTS') . ' --'];
		foreach($components as $c){
			/** @var Component_2_1 $c */
			foreach($c->getXML()->getElements('/pages/pagecreate') as $node){
				/** @var DOMElement $node */
				$links[] = ['baseurl' => $node->getAttribute('baseurl'), 'title' => $node->getAttribute('title')];
			}

			$componentopts[$c->getKeyName()] = $c->getName();
		}
		// Sort them by name!
		asort($componentopts);

		$pageschema = PageModel::GetSchema();

		$table = new Core\ListingTable\Table();

		$table->setLimit(20);

		// Set the model that this table will be pulling data from.
		$table->setModelName('PageModel');

		// Gimme filters!
		$table->addFilter(
			'text',
			[
				'name' => 'title',
				'title' => t('STRING_TITLE'),
				'link' => FilterForm::LINK_TYPE_CONTAINS,
			]
		);

		$table->addFilter(
			'text',
			[
				'name' => 'rewriteurl',
				'title' => t('STRING_URL'),
				'link' => FilterForm::LINK_TYPE_CONTAINS,
			]
		);

		$table->addFilter(
			'text',
			[
				'name' => 'parenturl',
				'title' => t('STRING_PARENT_URL'),
				'link' => FilterForm::LINK_TYPE_STARTSWITH,
			]
		);

		$table->addFilter(
			'select',
			[
				'name' => 'component',
				'title' => t('STRING_COMPONENT'),
				'options' => $componentopts,
				'link' => FilterForm::LINK_TYPE_STANDARD,
			]
		);

		$table->addFilter(
			'select',
			[
				'name' => 'page_types',
				'title' => t('STRING_INCLUDE_ADMIN_PAGES'),
				'options' => ['all' => t('STRING_VIEW_ALL_PAGES'), 'no_admin' => t('STRING_EXCLUDE_ADMIN_PAGES')],
				'value' => 'no_admin',
			]
		);

		// Add in all the columns for this listing table.
		if(Core::IsComponentAvailable('multisite') && MultiSiteHelper::IsEnabled() && \Core\user()->checkAccess('g:admin')){
			$table->addColumn('Site', 'site', false);
			$ms = true;
		}
		else{
			$ms = false;
		}
		$table->addColumn(t('STRING_TITLE'), 'title');
		$table->addColumn(t('STRING_URL'), 'rewriteurl');
		$table->addColumn(t('STRING_VIEWS'), 'pageviews', false);
		$table->addColumn(t('STRING_SCORE'), 'popularity');
		$table->addColumn(t('STRING_CACHE'), 'expires');
		$table->addColumn(t('STRING_CREATED'), 'created', false);
		$table->addColumn(t('STRING_LAST_UPDATED'), 'updated', false);
		$table->addColumn(t('STRING_STATUS'));
//.........這裏部分代碼省略.........
開發者ID:nicholasryan,項目名稱:CorePlus,代碼行數:101,代碼來源:AdminController.php

示例2: testSchema

	public function testSchema(){
		$schema = PageModel::GetSchema();

		$this->assertInternalType('array', $schema);

		/** @var PageModel $page */
		$page = PageModel::Construct('/admin');
		$schema2 = $page->getKeySchemas();

		// The two schemas should be identical sizes, (they should contain identical content).
		$this->assertEquals(sizeof($schema), sizeof($schema2));

		$asArray = $page->getAsArray();
		foreach($asArray as $k => $val){
			$this->assertArrayHasKey($k, $schema, 'PageModel schema does not contain key ' . $k);

			// Ensure that this schema element has all the required fields.
			$this->assertArrayHasKey('type', $schema[$k], 'PageModel schema ' . $k . ' does not contain a type');
			$this->assertArrayHasKey('maxlength', $schema[$k], 'PageModel schema ' . $k . ' does not contain a maxlength');
			$this->assertArrayHasKey('default', $schema[$k], 'PageModel schema ' . $k . ' does not contain a default field');
			$this->assertArrayHasKey('comment', $schema[$k], 'PageModel schema ' . $k . ' does not contain a comment');
			$this->assertArrayHasKey('null', $schema[$k], 'PageModel schema ' . $k . ' does not contain a null field');
			$this->assertArrayHasKey('encrypted', $schema[$k], 'PageModel schema ' . $k . ' does not contain an encrypted field');
			$this->assertArrayHasKey('required', $schema[$k], 'PageModel schema ' . $k . ' does not contain a required field');
			$this->assertArrayHasKey('options', $schema[$k], 'PageModel schema ' . $k . ' does not contain an options field');
			$this->assertArrayHasKey('title', $schema[$k], 'PageModel schema ' . $k . ' does not contain a title');

			// If the default is null, then null must be true.
			if($schema[$k]['default'] === null){
				$this->assertTrue($schema[$k]['null']);
			}
		}
	}
開發者ID:nicholasryan,項目名稱:CorePlus,代碼行數:33,代碼來源:PageModelTest.php


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