/** * Maps viewports onto regions of page. * * This mapping is supported to improve content/view abstraction by enabling * content of viewports being assembled into code of page's regions in a * configurable way ... * * @param array $viewports content of viewports * @return array content of regions */ protected function collectRegions($viewports) { $configs = array(config::getList('view.region'), array(array('name' => 'main', 'viewport' => array('flash', 'title', 'error', 'main')), array('name' => 'head', 'viewport' => array('header')), array('name' => 'foot', 'viewport' => array('footer', 'debug')), array('name' => 'left', 'viewport' => array('navigation')), array('name' => 'right', 'viewport' => array('aside')))); $regions = array(); foreach ($configs as $config) { if (is_array($config)) { foreach ($config as $region) { // get name of region to customize $name = trim(@$region['name']); if ($name === '') { log::debug('ignoring nameless region configuration'); continue; } if (!array_key_exists($name, $regions)) { // region haven't been collected before ... if (array_key_exists('code', $region)) { // there is a line of code containing markers selecting viewports to collect their content in current region // e.g. "{{title}}<some-literal-content-to-insert/>{{main}}" $regions[$name] = data::qualifyString($region['code'], $viewports); } else { if (is_array(@$region['viewport'])) { // collect set of viewports named in configuration foreach (@$region['viewport'] as $viewportName) { $regions[$name] .= \de\toxa\txf\view::wrapNotEmpty(@$viewports[$viewportName], config::get('view.viewport.wrap.' . $viewportName, '')); } } } // support default content to show if a region keeps empty finally if (trim($regions[$name]) === '') { $regions[$name] = trim(@$region['default']); } // process any additionally contained markers $regions[$name] = data::qualifyString($regions[$name]); } } } } return $regions; }