public function loadThumbnails() { /** * @var $cx \Cx\Core\Core\Controller\Cx */ $pdo = $this->cx->getDb()->getPdoConnection(); $sth = $pdo->query('SELECT id,name, size, 100 as quality, CONCAT(".thumb_",name) as value FROM `' . DBPREFIX . 'settings_thumbnail`'); self::$thumbnails = $sth->fetchAll(); }
/** * Get a component controller object * * @param string $name component name * @return \Cx\Core\Core\Model\Entity\SystemComponentController * The requested component controller or null if no such component exists */ public function getComponent($name) { if (empty($name)) { return null; } $componentRepo = $this->cx->getDb()->getEntityManager()->getRepository('Cx\\Core\\Core\\Model\\Entity\\SystemComponent'); $component = $componentRepo->findOneBy(array('name' => $name)); if (!$component) { return null; } return $component->getSystemComponentController(); }
/** * 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; }
/** * 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'); } }
/** * Get all content pages. * * @return array */ public function getSites() { $pageTree = new MediaBrowserPageTree($this->cx->getDb()->getEntityManager(), $this->cx->getLicense(), 0, null, FRONTEND_LANG_ID, null, false, false, false); $pageTree->render(); return $pageTree->getFlatTree(); }