/** * analize and adjust view config if needed * @param array $viewConfig * @param array $rp * @return array */ public function adjustViewConfig($viewConfig, &$rp) { if (empty($viewConfig)) { return array(); } $rez = $viewConfig; $cfg =& $this->config; if (!empty($cfg['views'][$rez['type']])) { $rez = array_merge($rez, $cfg['views'][$rez['type']]); } elseif ($rez['type'] == 'activityStream' && !empty($cfg['views']['stream'])) { $rez = array_merge($rez, $cfg['views']['stream']); } //dashboards extention check if (!empty($rez['extends'])) { $rez = Config::extend('dashboards', $rez); } switch ($rez['type']) { //backward compatibility check case 'pivot': case 'charts': if (!empty($cfg['stats'])) { $stats = array(); foreach ($cfg['stats'] as $item) { $stats[] = array('title' => Util\detectTitle($item), 'field' => $item['field']); } $rez['stats'] = $stats; } $rez['sort'] = null; //check renamed options if (isset($rez['chart_type']) && empty($rez['chartType'])) { $rez['chartType'] = $rez['chart_type']; unset($rez['chart_type']); } if (isset($rez['pivot_type']) && empty($rez['pivotType'])) { $rez['pivotType'] = $rez['pivot_type']; unset($rez['pivot_type']); } break; case 'dashboard': //analize dashboard items and merge referenced config if any if (empty($rez['items'])) { $rez['items'] = array(); } $this->subClasses = array(); $copyConfigProperties = ['title', 'cellCls', 'rowspan', 'colspan', 'width', 'height', 'minWidth', 'minHeight', 'maxWidth', 'maxHeight']; foreach ($rez['items'] as $k => $v) { if (!empty($v['extends'])) { $rez['items'][$k] = Config::extend('treeNodes', $v); } $clsArr = Path::getNodeClasses($rez['items']); if (!empty($clsArr)) { $class = current($clsArr); if (isset($v['pid'])) { $class->id = $v['pid']; } $this->subClasses[$k] = $class; $path = array($class); $customRp = $rp; unset($customRp['userViewChange']); $vc = $class->getViewConfig($path, $customRp); $rez['items'][$k] = array_merge($vc, array_intersect_key($v, array_flip($copyConfigProperties))); } } break; default: // grid // if (!empty($cfg['view']['group'])) { // $rez['group'] = $cfg['view']['group']; // } } return $rez; }