本文整理汇总了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'));
//.........这里部分代码省略.........
示例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']);
}
}
}