/** * 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')); $table->addColumn(t('STRING_PUBLISHED'), 'published'); $table->addColumn(t('STRING_EXPIRES'), 'published_expires'); $table->addColumn(t('STRING_SEO_TITLE')); $table->addColumn(t('STRING_SEO_DESCRIPTION'), null, false); $table->addColumn(t('STRING_ACCESS'), 'access'); $table->addColumn(t('STRING_COMPONENT'), 'component', false); // This page will also feature a quick-edit feature. //$table->setEditFormCaller('AdminController::PagesSave'); $table->loadFiltersFromRequest(); if($table->getFilterValue('page_types') == 'no_admin'){ $table->getModelFactory()->where('admin = 0'); $table->getModelFactory()->where('selectable = 1'); } $view->title = 't:STRING_ALL_PAGES'; //$view->assign('filters', $filters); //$view->assign('listings', $listings); $view->assign('links', $links); $view->assign('multisite', $ms); $view->assign('listing', $table); $view->assign('page_opts', PageModel::GetPagesAsOptions(false, '-- Select Parent URL --')); $view->assign('expire_opts', $pageschema['expires']['form']['options']); }
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']); } } }