<?php \QPress\Debug::log('Load libraries config'); /** @var \QPress\LoaderConfiguration $loader */ $loader->registerComponents([['name' => 'thanks-to-qp'], ['name' => 'qp-common'], ['name' => 'markdown']]); $loader->registerApplication(['name' => 'qp-cms']);
<?php \QPress\Debug::log('load log-email config'); /** @var \QPress\LoaderConfiguration $loader */ \QPress\ClassAutoLoader::addNamespace('QpCommon', __DIR__ . '/QpCommon'); $loader->registerGlobalService('Log', '\\QpCommon\\EmailLogService'); $loader->registerGlobalService('Mail', '\\QpCommon\\DummyMailService'); $loader->registerGlobalCommand('staticFiles', function () { require __DIR__ . 'QpCommon/staticFiles.php'; return '\\QpCommon\\staticFiles'; });
<?php use QPress\FrameworkConfiguration; use QPress\LoaderConfiguration; use QPress\ApplicationConfiguration; \QPress\Debug::log('main app'); /** @var FrameworkConfiguration $fw */ $fw->setProperties(['runDataDirectory' => QP_ABSPATH . '/qp-run-data', 'emailSender' => 'tarh@']); /** @var LoaderConfiguration $loader */ $loader->registerApplications([['name' => 'libraries', 'load' => true], ['name' => 'www.helloworld.com']]); $loader->initializeApplication(function (ApplicationConfiguration $app) { \QPress\Debug::log('init main app'); $app->addRoutes([['method' => 'ALL', 'partialRoute' => [], 'action' => ['application' => 'www.helloworld.com']]]); $app->on('APP_READY', function (\QPress\ApplicationTool $tool) { \QPress\Debug::log('app ' . $tool->getProperty('name') . ': READY'); }); });
<?php \QPress\Debug::log('load markdown config'); /** @var \QPress\LoaderConfiguration $loader */ \QPress\ClassAutoLoader::addNamespace('Michelf', __DIR__ . '/md-lib-1.2.7/Michelf');
<?php error_reporting(-1); // 0 prod; -1 dev date_default_timezone_set('Africa/Porto-Novo'); require __DIR__ . '/qp-engine/engine.php'; \QPress\Debug::enableBuffer(); define('QP_ABSPATH', __DIR__); $query = \QPress\FrameworkControl::getHttpQueryFromGlobals(); \QPress\FrameworkControl::unsetSuperGlobals(); \QPress\FrameworkControl::startup(__DIR__ . '/qp-sites')->executeHttpQuery($query); \QPress\Debug::log('Done.'); echo "<pre>\n-- DEBUG --\n" . implode("\n", \QPress\Debug::getBuffer()) . "</pre>\n";
<?php \QPress\Debug::log('load cms-plugins config'); /** @var \QPress\LoaderConfiguration $loader */
function staticFiles(ApplicationTool $tool, array $parameters) { \QPress\Debug::log('command: ' . __FUNCTION__ . ': ' . var_export($parameters, true) . "\n" . print_r($tool->getQuery(), true)); // TODO }
<?php use QPress\ApplicationConfiguration; use QPress\LoaderConfiguration; $siteName = 'helloworld'; \QPress\Debug::log('app: ' . $siteName); /** @var LoaderConfiguration $loader */ $loader->registerGlobalTheme(['name' => "{$siteName}-cms-theme", 'directory' => __DIR__ . '/cms-theme']); $loader->registerComponent(['name' => "{$siteName}-cms-plugins", 'directory' => __DIR__ . '/cms-plugins']); $loader->onGlobal('FW_READY', function (\QPress\FrameworkTool $tool) use($siteName) { /** @var \QpCommon\EmailLogService $emailLog */ $emailLog = $tool->getService('Log'); $emailLog->addChannels(['default' => ['minLevel' => 'warning', 'maxSize' => 307200, 'autoFlush' => true, 'delayS' => 600, 'emailTo' => 'email@here', 'emailSubject' => "[{$siteName}] Errors"]]); }); $loader->initializeApplication(function (ApplicationConfiguration $conf) use($siteName) { \QPress\Debug::log("init {$siteName}"); $cmsParams = ['application' => 'qp-cms', 'parameters' => ['themeName' => "{$siteName}-cms-theme", 'pluginsName' => "{$siteName}-cms-plugins", 'themeStaticDirectory' => __DIR__ . '/cms-theme/static', 'mediasDirectory' => __DIR__ . '/medias', 'site' => $siteName, 'db' => ['tablePrefix' => 'qp_', 'dsn' => 'sqlite:' . __DIR__ . '/db.sqlite', 'initCommands' => ['pragma foreign_keys = on']]]]; $conf->addRoutes([['method' => 'ALL', 'partialRoute' => [], 'action' => $cmsParams]]); }); // 'db' => [ // 'tablePrefix' => 'qp_', // 'dsn' => 'sqlite:website.sqlite', // 'initCommands' => ['PRAGMA foreign_keys = ON'] // ] // 'db' => [ // 'prefix' => 'pgsql', // 'host' => 'localhost', // 'dbname' => 'dbname', // 'user' => 'user', // 'password' => 'pwd', // 'tablePrefix' => 'qp_',
function backend(ApplicationTool $tool, $parameters) { \QPress\Debug::log('command: backend'); }
/** * @param array $parentRes array{TagCacheResource} * @param string $childFragment * @return array|null If a $childFragment is defined, return the array{TagCacheResource} that match with the $childFragment */ private function insertPathChildren(array $parentRes, $childFragment = null) { $matchingChild = null; $children = $this->assistant->getChildResources($parentRes['code']); Debug::log("[ASSISTANT] children of " . $parentRes['code'] . ": " . var_export($children, true)); Helper::formatArray($children, ['collection' => 'list', 'fields' => ['code' => ['validator' => 'is_string'], 'fragment' => []]]); $this->qi->insert(['insertInto' => 'res_parent_sync', 'values' => ['res_id' => [$parentRes['resId'], PDO::PARAM_INT]]])->execute(); foreach ($children as $child) { $childPath = self::childPath($parentRes['path'], $child['fragment']); $childResId = $this->insertChildResource($child['code'], $childPath, $child['fragment'], $parentRes['resId']); if ($childFragment === $child['fragment']) { $matchingChild = ['resId' => $childResId, 'code' => $child['code'], 'path' => $childPath]; } } if (isset($childFragment) && !isset($matchingChild)) { throw new Error("Missing child \"{$childFragment}\" in resource: " . $parentRes['code']); } return $matchingChild; }