예제 #1
0
 /**
  * @return array
  */
 public function getUnregisteredExtensions()
 {
     $unregisteredExtensions = array();
     $coreFiles = $this->fileManager->findFiles($this->core->getApplicationDir() . DIRECTORY_SEPARATOR . 'Fraym' . DIRECTORY_SEPARATOR . '*.php');
     $extensionFiles = $this->fileManager->findFiles($this->core->getApplicationDir() . DIRECTORY_SEPARATOR . 'Extension' . DIRECTORY_SEPARATOR . '*.php');
     $files = array_merge($coreFiles, $extensionFiles);
     foreach ($files as $file) {
         $classname = basename($file, '.php');
         $namespace = str_ireplace($this->core->getApplicationDir(), '', dirname($file));
         $namespace = str_replace('/', '\\', $namespace) . '\\';
         $class = $namespace . $classname;
         if (is_file($file)) {
             require_once $file;
             if (class_exists($class)) {
                 $classAnnotation = $this->getRegistryConfig($class);
                 if ($classAnnotation) {
                     $registryEntry = $this->db->getRepository('\\Fraym\\Registry\\Entity\\Registry')->findOneByClassName($class);
                     if ($registryEntry === null) {
                         $unregisteredExtensions[$class] = (array) $classAnnotation;
                         $unregisteredExtensions[$class]['file'] = $file;
                         $unregisteredExtensions[$class]['fileHash'] = md5($file);
                     }
                 }
             }
         }
     }
     return $unregisteredExtensions;
 }
예제 #2
0
파일: Response.php 프로젝트: jewelhuq/fraym
 /**
  * @param bool $exit
  * @param bool $parseOutput
  * @return $this
  */
 public function finish($exit = true, $parseOutput = false)
 {
     // get the output and eval for precaching
     $content = ob_get_clean();
     if ($parseOutput === true) {
         // Output the source to the client, for dynamic cache we need to eval the output source
         $content = $this->core->evalString($content);
         // Filter the output to assign css or js files, sets title or meta tags
         $content = $this->template->outputFilter($content);
     }
     $this->addHTTPHeader("Content-Length: " . strlen($content));
     foreach ($this->_httpHeaders as $header) {
         $this->sendHTTPHeader($header);
     }
     echo $content;
     if ($exit) {
         exit;
     }
     return $this;
 }
예제 #3
0
 /**
  * @return array
  */
 public function getExtensions()
 {
     $extensions = [];
     $coreFiles = $this->fileManager->findFiles($this->core->getApplicationDir() . DIRECTORY_SEPARATOR . 'Fraym' . DIRECTORY_SEPARATOR . '*.php');
     $extensionFiles = $this->fileManager->findFiles($this->core->getApplicationDir() . DIRECTORY_SEPARATOR . 'Extension' . DIRECTORY_SEPARATOR . '*.php');
     $files = array_merge($coreFiles, $extensionFiles);
     foreach ($files as $file) {
         $classname = basename($file, '.php');
         $namespace = str_ireplace($this->core->getApplicationDir(), '', dirname($file));
         $namespace = str_replace('/', '\\', $namespace) . '\\';
         $namespace = preg_replace('#^' . preg_quote('\\') . 'Extension' . preg_quote('\\') . '#', '\\Fraym\\Extension\\', $namespace);
         $namespace = preg_replace('#^' . preg_quote('\\') . 'Hook' . preg_quote('\\') . '#', '\\Fraym\\Hook\\', $namespace);
         $namespace = preg_replace('#^' . preg_quote('\\') . 'Test' . preg_quote('\\') . '#', '\\Fraym\\Test\\', $namespace);
         $class = $namespace . $classname;
         if (is_file($file)) {
             require_once $file;
             if (class_exists($class)) {
                 $classAnnotation = $this->getRegistryConfig($class);
                 if ($classAnnotation) {
                     $registryEntry = $this->db->getRepository('\\Fraym\\Registry\\Entity\\Registry')->findOneByClassName($class);
                     $extensions[$class] = (array) $classAnnotation;
                     if ($classAnnotation->composerPackage === true) {
                         $package = $this->getPackage($classAnnotation->repositoryKey);
                         if ($package) {
                             $package = $this->getLatestPackageVersion($package);
                             $extensions[$class]['package'] = $package->getName();
                             $extensions[$class]['description'] = $package->getDescription();
                             $extensions[$class]['version'] = $package->getVersion();
                             $extensions[$class]['homepage'] = $package->getHomepage();
                             $extensions[$class]['author'] = $this->getAuthorsFromPackage($package);
                         }
                     } else {
                         $extensions[$class]['package'] = $classAnnotation->repositoryKey;
                         $extensions[$class]['description'] = '';
                         $extensions[$class]['version'] = '0.0.0';
                         $extensions[$class]['homepage'] = null;
                         $extensions[$class]['author'] = null;
                     }
                     $extensions[$class]['registred'] = $registryEntry !== null;
                 }
             }
         }
     }
     return $extensions;
 }
예제 #4
0
 /**
  * @param $block
  * @param $html
  * @param $xml simplexml object
  * @param bool $force true if to output block info on ajax request
  * @return mixed
  */
 public function addBlockInfo($block, $html, $xml, $force = false)
 {
     if ($this->user->isAdmin() === false) {
         return;
     }
     // do not add block info to ajax requests
     if ($this->request->isXmlHttpRequest() && $force === false) {
         return $html;
     }
     $renderTime = 0;
     if ($this->blockParser->getXMLAttr($xml, 'id')) {
         $renderTime = $this->core->stopTimer('blockExecution_' . $this->blockParser->getXMLAttr($xml, 'id'));
     }
     $this->view->assign('renderTime', $renderTime);
     $this->view->assign('type', $this->blockParser->getXMLAttr($xml, 'type'));
     $this->view->assign('id', $this->blockParser->getXMLAttr($xml, 'id'));
     $this->view->assign('block', $block);
     $this->view->assign('moudleName', $block ? $block->extension->name : '');
     $this->view->assign('content', $html);
     return $this->template->fetch('BlockInfo.tpl');
 }
예제 #5
0
파일: Cache.php 프로젝트: fraym/core
 /**
  * if cacheing is active and a cached file is availible it outputs the cache and exits the script
  *
  * @return void
  */
 public function load()
 {
     // gets the current uri - example: /folder/folder2
     $filename = $this->getCacheName();
     // create the cache filename
     $cacheFilename = self::DIR_PAGES . $filename . '.cache.php';
     $cacheFilenamePhpData = self::DIR_PAGES . $filename . '.cache.config.php';
     $menuItemTranslation = false;
     $domain = false;
     $httpStatusCode = 200;
     $executedBlocks = [];
     if (defined('GLOBAL_CACHING_ENABLED') && GLOBAL_CACHING_ENABLED && !$this->request->isXmlHttpRequest() && !$this->request->isPost() && $this->user->isAdmin() === false && is_file($cacheFilename) && is_file($cacheFilenamePhpData)) {
         include $cacheFilenamePhpData;
         if ($menuItemTranslation) {
             $menuItemTranslation = json_decode($menuItemTranslation);
             if (is_object($menuItemTranslation)) {
                 if ($this->request->isXmlHttpRequest() === false && $this->route->isHttps() === false && $menuItemTranslation->menuItem->https === true) {
                     $this->route->redirectToUrl('https://' . $this->route->getRequestRoute());
                 }
                 $this->locale->setLocale($menuItemTranslation->locale);
                 $this->template->setSiteTemplateDir($menuItemTranslation->menuItem->site->templateDir);
                 $this->route->setCurrentMenuItem($menuItemTranslation->menuItem);
                 $this->route->setCurrentMenuItemTranslation($menuItemTranslation);
                 $this->route->setCurrentDomain($domain);
                 if ($this->isCachingActive($menuItemTranslation->menuItem)) {
                     $this->blockParser->setExecutedBlocks(json_decode($executedBlocks));
                     // display the cached file to the client
                     $contents = file_get_contents($cacheFilename);
                     $this->blockParser->setParseCached(true);
                     $content = $this->blockParser->parse($contents, 'outputFilter');
                     $this->response->sendHTTPStatusCode($httpStatusCode);
                     echo $this->core->includeScript($content);
                     exit;
                 }
             }
         }
     }
 }
예제 #6
0
파일: BlockParser.php 프로젝트: fraym/core
 /**
  * @param $xml
  * @return array|string
  */
 protected function contentChildViews($xml)
 {
     $childsHtml = [];
     foreach ($xml->children() as $child) {
         $contentId = $this->getContentId($child);
         $blocks = $this->getDataFromBlocksByContentId($contentId);
         // In Editmode we want to render all views to insert content
         if (empty($blocks) && $this->getXmlAttr($child, 'hideEmpty') !== false && empty($placeholder) && $this->block->inEditMode() === false) {
             continue;
         }
         if (empty($blocks) && !empty($placeholder) && $this->block->inEditMode() === false) {
             $blocks = $this->blockController->createEditViewElement($child, $placeholder);
         }
         // result returns an array
         $result = $this->contentChildViews($child);
         $addContent = $this->getXmlAttr($child, 'add') ?: 'afterContent';
         if (!isset($childsHtml[$addContent])) {
             $childsHtml[$addContent] = '';
         }
         if (count($result) > 0) {
             $blockhtml = (isset($result['beforeContent']) ? $result['beforeContent'] : '') . $this->core->includeScript($blocks) . (isset($result['afterContent']) ? $result['afterContent'] : '');
             if (trim($blockhtml) === '') {
                 $childsHtml[$addContent] .= isset($childsHtml[$addContent]) ? $childsHtml[$addContent] : '';
             } else {
                 $childsHtml[$addContent] .= (isset($childsHtml[$addContent]) ? $childsHtml[$addContent] : '') . $this->blockController->createEditViewElement($child, $blockhtml);
             }
         } else {
             $blockhtml = $this->core->includeScript($blocks);
             if (trim($blockhtml) === '') {
                 $childsHtml[$addContent] .= '';
             } else {
                 $childsHtml[$addContent] .= $this->blockController->createEditViewElement($child, $blockhtml);
             }
         }
     }
     return $childsHtml;
 }
예제 #7
0
파일: Database.php 프로젝트: fraym/core
 /**
  * @return $this
  */
 public function connect()
 {
     // Prevent to connect twice
     if ($this->entityManager) {
         return $this;
     }
     $applicationDir = $this->core->getApplicationDir();
     $this->createModuleDirCache();
     $cache = $this->cache->getCacheProvider();
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl($cache);
     $config->addCustomStringFunction('MD5', '\\DoctrineExtensions\\Query\\Mysql\\Md5');
     $config->addCustomStringFunction('ACOS', '\\DoctrineExtensions\\Query\\Mysql\\Acos');
     $config->addCustomStringFunction('ASIN', '\\DoctrineExtensions\\Query\\Mysql\\Asin');
     $config->addCustomStringFunction('ATAN', '\\DoctrineExtensions\\Query\\Mysql\\Atan');
     $config->addCustomStringFunction('ATAN2', '\\DoctrineExtensions\\Query\\Mysql\\Atan2');
     $config->addCustomStringFunction('BINARY', '\\DoctrineExtensions\\Query\\Mysql\\Binary');
     $config->addCustomStringFunction('CHARLENGTH', '\\DoctrineExtensions\\Query\\Mysql\\CharLength');
     $config->addCustomStringFunction('CONCATWS', '\\DoctrineExtensions\\Query\\Mysql\\ConcatWs');
     $config->addCustomStringFunction('COS', '\\DoctrineExtensions\\Query\\Mysql\\Cos');
     $config->addCustomStringFunction('COT', '\\DoctrineExtensions\\Query\\Mysql\\COT');
     $config->addCustomStringFunction('COUNTIF', '\\DoctrineExtensions\\Query\\Mysql\\CountIf');
     $config->addCustomStringFunction('CRC32', '\\DoctrineExtensions\\Query\\Mysql\\Crc32');
     $config->addCustomStringFunction('DATE', '\\DoctrineExtensions\\Query\\Mysql\\Date');
     $config->addCustomStringFunction('DATEADD', '\\DoctrineExtensions\\Query\\Mysql\\DateAdd');
     $config->addCustomStringFunction('DATEDIFF', '\\DoctrineExtensions\\Query\\Mysql\\DateFormat');
     $config->addCustomStringFunction('DAY', '\\DoctrineExtensions\\Query\\Mysql\\Day');
     $config->addCustomStringFunction('DEGREES', '\\DoctrineExtensions\\Query\\Mysql\\Degrees');
     $config->addCustomStringFunction('FIELD', '\\DoctrineExtensions\\Query\\Mysql\\Field');
     $config->addCustomStringFunction('FINDINSET', '\\DoctrineExtensions\\Query\\Mysql\\FindInSet');
     $config->addCustomStringFunction('GROUPCONCAT', '\\DoctrineExtensions\\Query\\Mysql\\GroupConcat');
     $config->addCustomStringFunction('HOUR', '\\DoctrineExtensions\\Query\\Mysql\\Hour');
     $config->addCustomStringFunction('IFELSE', '\\DoctrineExtensions\\Query\\Mysql\\IfElse');
     $config->addCustomStringFunction('IFNULL', '\\DoctrineExtensions\\Query\\Mysql\\IfNUll');
     $config->addCustomStringFunction('MATCHAGAINST', '\\DoctrineExtensions\\Query\\Mysql\\MatchAgainst');
     $config->addCustomStringFunction('MONTH', '\\DoctrineExtensions\\Query\\Mysql\\Month');
     $config->addCustomStringFunction('NULLIF', '\\DoctrineExtensions\\Query\\Mysql\\NullIf');
     $config->addCustomStringFunction('PI', '\\DoctrineExtensions\\Query\\Mysql\\Pi');
     $config->addCustomStringFunction('RADIANS', '\\DoctrineExtensions\\Query\\Mysql\\Radians');
     $config->addCustomStringFunction('RAND', '\\DoctrineExtensions\\Query\\Mysql\\Rand');
     $config->addCustomStringFunction('REGEXP', '\\DoctrineExtensions\\Query\\Mysql\\Regexp');
     $config->addCustomStringFunction('ROUND', '\\DoctrineExtensions\\Query\\Mysql\\Round');
     $config->addCustomStringFunction('SHA1', '\\DoctrineExtensions\\Query\\Mysql\\Sha1');
     $config->addCustomStringFunction('SHA2', '\\DoctrineExtensions\\Query\\Mysql\\Sha2');
     $config->addCustomStringFunction('SIN', '\\DoctrineExtensions\\Query\\Mysql\\Sin');
     $config->addCustomStringFunction('STRTODATE', '\\DoctrineExtensions\\Query\\Mysql\\StrToDate');
     $config->addCustomStringFunction('TAN', '\\DoctrineExtensions\\Query\\Mysql\\Tan');
     $config->addCustomStringFunction('TIMESTAMPDIFF', '\\DoctrineExtensions\\Query\\Mysql\\TimestampDiff');
     $config->addCustomStringFunction('WEEK', '\\DoctrineExtensions\\Query\\Mysql\\Week');
     $config->addCustomStringFunction('YEAR', '\\DoctrineExtensions\\Query\\Mysql\\Year');
     if (!defined('ENV') || ENV === \Fraym\Core::ENV_DEVELOPMENT) {
         $config->setAutoGenerateProxyClasses(true);
     }
     $modelDirs = $this->getModuleDirCache();
     \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(function ($class) {
         return class_exists($class, true);
     });
     $annotationReader = new \Doctrine\Common\Annotations\AnnotationReader();
     $this->cachedAnnotationReader = new \Doctrine\Common\Annotations\CachedReader($annotationReader, $cache);
     $this->annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($this->cachedAnnotationReader, $modelDirs);
     /**
      * Ignore PHP-DI Annotation
      */
     $annotationReader->addGlobalIgnoredName('Injectable');
     $annotationReader->addGlobalIgnoredName('Inject');
     $config->setMetadataDriverImpl($this->annotationDriver);
     $config->setQueryCacheImpl($cache);
     $config->setResultCacheImpl($cache);
     $config->setProxyDir($applicationDir . DIRECTORY_SEPARATOR . CACHE_DOCTRINE_PROXY_PATH);
     $config->setProxyNamespace('Proxies');
     $this->fetchMode = \PDO::FETCH_OBJ;
     $tablePrefix = new TablePrefix(DB_TABLE_PREFIX);
     $this->eventManager = new \Doctrine\Common\EventManager();
     $this->eventManager->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $tablePrefix);
     $this->entityManager = \Doctrine\ORM\EntityManager::create($this->connectionOptions, $config, $this->eventManager);
     $this->pdo = $this->entityManager->getConnection();
     $this->pdo->getDatabasePlatform()->registerDoctrineTypeMapping('set', 'string');
     $driverChain = new \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
     \Gedmo\DoctrineExtensions::registerAbstractMappingIntoDriverChainORM($driverChain, $this->cachedAnnotationReader);
     $this->eventManager->addEventListener([\Doctrine\ORM\Events::preRemove, \Doctrine\ORM\Events::postRemove, \Doctrine\ORM\Events::prePersist, \Doctrine\ORM\Events::postPersist, \Doctrine\ORM\Events::preUpdate, \Doctrine\ORM\Events::postUpdate, \Doctrine\ORM\Events::postLoad, \Doctrine\ORM\Events::onFlush], $this->eventListener);
     return $this;
 }
예제 #8
0
파일: Template.php 프로젝트: fraym/core
 /**
  * @param $templateFile
  * @return bool|string
  */
 public function getTemplateFilePath($templateFile)
 {
     if (strpos(strtolower($templateFile), '.tpl') === false) {
         $templateFile .= '.tpl';
     }
     $folders = $this->getTemplateFolders();
     foreach ($folders as $folder) {
         if (is_file($file = $folder . DIRECTORY_SEPARATOR . $templateFile)) {
             return $file;
         } elseif (is_file($file = $folder . DIRECTORY_SEPARATOR . $this->core->createDirNameFromClassName($this->moduleName) . DIRECTORY_SEPARATOR . basename(str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $templateFile)))) {
             return $file;
         } elseif (is_file($templateFile)) {
             return realpath($templateFile);
         }
     }
     return false;
 }
예제 #9
0
 /**
  * @param $xml
  * @return array|string
  */
 private function contentChildViews($xml)
 {
     $childsHtml = array();
     foreach ($xml->children() as $child) {
         $contentId = $this->getContentId($child);
         $blocks = $this->getDataFromBlocksByContentId($contentId);
         // In Editmode we want to render all views to insert content
         if (empty($blocks) && $this->getXMLAttr($child, 'hideEmpty') !== false && $this->block->inEditMode() === false) {
             continue;
         }
         // result returns an array
         $result = $this->contentChildViews($child);
         $addContent = $this->getXMLAttr($child, 'add') ?: 'afterContent';
         if (!isset($childsHtml[$addContent])) {
             $childsHtml[$addContent] = '';
         }
         if (count($result) > 0) {
             $blockhtml = (isset($result['beforeContent']) ? $result['beforeContent'] : '') . $this->core->evalString($blocks) . (isset($result['afterContent']) ? $result['afterContent'] : '');
             if (($this->getXMLAttr($child, 'hideEmpty') === null || $this->getXMLAttr($child, 'hideEmpty') === true) && $this->block->inEditMode() === false && trim($blockhtml) == '') {
                 $childsHtml[$addContent] .= isset($childsHtml[$addContent]) ? $childsHtml[$addContent] : '';
             } else {
                 $childsHtml[$addContent] .= (isset($childsHtml[$addContent]) ? $childsHtml[$addContent] : '') . $this->blockController->createEditViewContentDIV($child, $blockhtml);
             }
         } else {
             $blockhtml = $this->core->evalString($blocks);
             if (($this->getXMLAttr($child, 'hideEmpty') === null || $this->getXMLAttr($child, 'hideEmpty') === true) && $this->block->inEditMode() === false && trim($blockhtml) == '') {
                 $childsHtml[$addContent] .= '';
             } else {
                 $childsHtml[$addContent] .= $this->blockController->createEditViewContentDIV($child, $blockhtml);
             }
         }
     }
     return $childsHtml;
 }
예제 #10
0
파일: Route.php 프로젝트: jewelhuq/fraym
 /**
  * @return bool
  */
 public function checkVirtualRoute()
 {
     foreach ($this->virutalRoutes as $data) {
         $isRelativeRoute = substr($data->route, 0, 1) === '/' ? false : true;
         $route = rtrim($this->getSiteBaseURI(false), '/') . $data->route;
         if ($this->core->isCLI() && $route == $this->getRequestRoute(false, false) || ($isRelativeRoute === true && ltrim($this->getAddionalURI(), '/') == $data->route || $isRelativeRoute === false && $route == $this->getRequestRoute(false, false))) {
             $controller = $data->controller;
             $action = $data->action;
             $instance = $this->serviceLocator->get($controller);
             return $instance->{$action}();
         }
     }
     return false;
 }
예제 #11
0
파일: Route.php 프로젝트: fraym/core
 /**
  * Init annotation and extension routes
  */
 public function loadRoutes()
 {
     if ($this->core->isCLI() === false && $this->cache->isCachingActive() && $this->user->isAdmin() === false) {
         if (($routes = $this->cache->getDataCache('routes')) === false) {
             $this->initAnnotationRoutes();
             $this->cache->setDataCache('routes', $this->virutalRoutes);
         } else {
             $this->virutalRoutes = $routes;
         }
     } else {
         $this->initExtensionRoutes();
         $this->initAnnotationRoutes();
     }
 }