/** * Decorates an entity or an array of entities * @param mixed $components SystemComponent or array of SystemComponents * @return mixed SystemComponentController or array of SystemComponentControllers */ protected function decorate($components) { if (!$components) { return $components; } if (!is_array($components)) { $yamlDir = $this->cx->getClassLoader()->getFilePath($components->getDirectory(false) . '/Model/Yaml'); if (file_exists($yamlDir)) { $this->cx->getDb()->addSchemaFileDirectories(array($yamlDir)); } $entity = $this->decorateEntity($components); return $entity; } $yamlDirs = array(); foreach ($components as $component) { if (isset($this->loadedComponents[$component->getId()])) { continue; } $yamlDir = $this->cx->getClassLoader()->getFilePath($component->getDirectory(false) . '/Model/Yaml'); if ($yamlDir) { $yamlDirs[] = $yamlDir; } } $this->cx->getDb()->addSchemaFileDirectories($yamlDirs); foreach ($components as &$component) { if (isset($this->loadedComponents[$component->getId()])) { $component = $this->loadedComponents[$component->getId()]; continue; } $component = $this->decorateEntity($component); \Cx\Core\Json\JsonData::addAdapter($component->getControllersAccessableByJson(), $component->getNamespace() . '\\Controller'); } return $components; }
/** * Get all content pages. * * @return array */ public function getSites() { $jd = new JsonData(); $data = $jd->data('node', 'getTree', array('get' => array('recursive' => 'true'))); $pageStack = array(); $data['data']['tree'] = array_reverse($data['data']['tree']); foreach ($data['data']['tree'] as &$entry) { $entry['attr']['level'] = 0; array_push($pageStack, $entry); } $return = array(); while (count($pageStack)) { $entry = array_pop($pageStack); $page = $entry['data'][0]; $arrPage['level'] = $entry['attr']['level']; $arrPage['node_id'] = $entry['attr']['rel_id']; $children = $entry['children']; $children = array_reverse($children); foreach ($children as &$entry) { $entry['attr']['level'] = $arrPage['level'] + 1; array_push($pageStack, $entry); } $arrPage['catname'] = $page['title']; $arrPage['catid'] = $page['attr']['id']; $arrPage['lang'] = BACKEND_LANG_ID; $arrPage['protected'] = $page['attr']['protected']; $arrPage['type'] = Page::TYPE_CONTENT; $arrPage['alias'] = $page['title']; $arrPage['frontend_access_id'] = $page['attr']['frontend_access_id']; $arrPage['backend_access_id'] = $page['attr']['backend_access_id']; $jsondata = json_decode($page['attr']['data-href']); $path = $jsondata->path; if (trim($jsondata->module) != '') { $arrPage['type'] = Page::TYPE_APPLICATION; $module = explode(' ', $jsondata->module, 2); $arrPage['modulename'] = $module[0]; if (count($module) > 1) { $arrPage['cmd'] = $module[1]; } } $url = '[[' . NodePlaceholder::PLACEHOLDER_PREFIX; // TODO: This only works for regular application pages. Pages of type fallback that are linked to an application // will be parsed using their node-id ({NODE_<ID>}) if ($arrPage['type'] == Page::TYPE_APPLICATION) { $url .= $arrPage['modulename']; if (!empty($arrPage['cmd'])) { $url .= '_' . $arrPage['cmd']; } $url = strtoupper($url); } else { $url .= $arrPage['node_id']; } $url .= "]]"; $return[] = array('click' => "javascript:{setUrl('{$url}',null,null,'" . \FWLanguage::getLanguageCodeById(BACKEND_LANG_ID) . $path . "','page')}", 'name' => $arrPage['catname'], 'extension' => 'Html', 'level' => $arrPage['level'], 'url' => $path, 'node' => $url); } return $return; }
public function multipleSetShutdown() { if ($this->multipleSetState) { $this->multipleSetState['state'] = 'timeout'; echo \Cx\Core\Json\JsonData::json($this->multipleSetState, true); } }
/** * Loads the systemComponent using the doctrine entity manager for the existing SystemComponentController and adds it to the repository * @param array $preLoadedComponents An array containing the preloaded components */ public function setPreLoadedComponents($preLoadedComponents) { foreach ($preLoadedComponents as $componentName => $preLoadedComponent) { // get systemComponent by name $systemComponent = parent::findOneBy(array('name' => $componentName)); // set systemComponent on existing systemComponentController $preLoadedComponent->setSystemComponent($systemComponent); // add yaml directory $yamlDir = $this->cx->getClassLoader()->getFilePath($preLoadedComponent->getDirectory(false) . '/Model/Yaml'); if (file_exists($yamlDir)) { $this->cx->getDb()->addSchemaFileDirectories(array($yamlDir)); } // store the systemComponent with its now loaded id as key to the array of loaded components $this->loadedComponents[$preLoadedComponent->getId()] = $preLoadedComponent; // Add JSON adapter \Cx\Core\Json\JsonData::addAdapter($preLoadedComponent->getControllersAccessableByJson(), $preLoadedComponent->getNamespace() . '\\Controller'); } }