first commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
content:
|
||||
resource: "@ContentBundle/Controller/"
|
||||
type: annotation
|
||||
29
bundles/KupShop/ContentBundle/Resources/config/services.yml
Normal file
29
bundles/KupShop/ContentBundle/Resources/config/services.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
services:
|
||||
_defaults:
|
||||
autoconfigure: true
|
||||
autowire: true
|
||||
|
||||
KupShop\ContentBundle\:
|
||||
resource: ../../{Controller,EventListener,EventSubscriber,Page,Sitemap,View,Util,Feed,AdminRegister,Template,Inspection}
|
||||
exclude: ../../{Sitemap/BaseSitemap.php}
|
||||
|
||||
KupShop\ContentBundle\Util\SitemapLocator:
|
||||
class: KupShop\ContentBundle\Util\SitemapLocator
|
||||
arguments: [!tagged kupshop.sitemap]
|
||||
|
||||
KupShop\ContentBundle\Page\FragmentPage:
|
||||
shared: false
|
||||
|
||||
kupshop.content.ignoretableslistener:
|
||||
class: KupShop\ContentBundle\IgnoreTablesListener
|
||||
tags:
|
||||
- {name: doctrine.event_listener, event: postGenerateSchema }
|
||||
|
||||
KupShop\ContentBundle\Entity\Wrapper\PhotoWrapper:
|
||||
shared: false
|
||||
|
||||
KupShop\ContentBundle\Entity\Wrapper\PageWrapper:
|
||||
shared: false
|
||||
|
||||
KupShop\ContentBundle\Util\MenuLinksPage:
|
||||
shared: false
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\script;
|
||||
|
||||
use KupShop\AdminBundle\Util\Script\Script;
|
||||
use Query\Operator;
|
||||
|
||||
class BlocekLegacyBlockMigrateScript extends Script
|
||||
{
|
||||
protected static $name = 'Blocek - Převést LegacyBlocky na TextBlocky';
|
||||
protected static $defaultParameters = ['translations' => false];
|
||||
|
||||
protected function run(array $arguments)
|
||||
{
|
||||
$rows = sqlQueryBuilder()->select('id, json_content')->from('blocks')
|
||||
->where('json_content LIKE "%legacy%"')
|
||||
->execute()->fetchAllAssociative();
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$json = json_decode($row['json_content']);
|
||||
$this->fix($json);
|
||||
$jsonFixed = json_encode($json);
|
||||
sqlQueryBuilder()->update('blocks')->directValues(['json_content' => $jsonFixed])
|
||||
->where(Operator::equals(['id' => $row['id']]))
|
||||
->execute();
|
||||
}
|
||||
|
||||
if (!$arguments['translations']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rows = sqlQueryBuilder()->select('id, json_content')->from('blocks_translations')
|
||||
->where('json_content LIKE "%legacy%"')
|
||||
->execute()->fetchAllAssociative();
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$json = json_decode($row['json_content']);
|
||||
$this->fix($json);
|
||||
$jsonFixed = json_encode($json);
|
||||
sqlQueryBuilder()->update('blocks_translations')->directValues(['json_content' => $jsonFixed])
|
||||
->where(Operator::equals(['id' => $row['id']]))
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
protected function fix(array $json)
|
||||
{
|
||||
foreach ($json as $block) {
|
||||
if ($block->type == 'legacy') {
|
||||
$block->type = 'text';
|
||||
|
||||
if ($block->settings) {
|
||||
$block->settings->migrated = 'legacy';
|
||||
} else {
|
||||
$block->settings = ['migrated' => 'legacy'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($block->children) && is_array($block->children)) {
|
||||
$this->fix($block->children);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return BlocekLegacyBlockMigrateScript::class;
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\script;
|
||||
|
||||
use KupShop\AdminBundle\Util\Script\Script;
|
||||
use KupShop\CatalogBundle\Entity\Section;
|
||||
use KupShop\CatalogBundle\Section\SectionTree;
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
use KupShop\KupShopBundle\Util\Excel\ExcelGenerator;
|
||||
|
||||
class CategoryTreeScript extends Script
|
||||
{
|
||||
protected static $name = 'Vygenerovat strom sekcí do excelu';
|
||||
|
||||
protected function run(array $arguments)
|
||||
{
|
||||
$menu = ServiceContainer::getService(SectionTree::class)->getTree();
|
||||
|
||||
$table = [];
|
||||
$this->buildTree($menu, $table);
|
||||
|
||||
$result = [];
|
||||
foreach ($table as $row) {
|
||||
$result[] = $this->column($row['name'], $row['level']);
|
||||
}
|
||||
|
||||
/** @var ExcelGenerator $excelGenerator */
|
||||
$excelGenerator = ServiceContainer::getService(ExcelGenerator::class);
|
||||
|
||||
$header = [
|
||||
['name' => 'level1'],
|
||||
['name' => 'level2'],
|
||||
['name' => 'level3'],
|
||||
['name' => 'level4'],
|
||||
['name' => 'level5'],
|
||||
['name' => 'level6'],
|
||||
['name' => 'level7'],
|
||||
['name' => 'level8'],
|
||||
['name' => 'level9'],
|
||||
['name' => 'level10'],
|
||||
];
|
||||
|
||||
$data = function ($result) {
|
||||
foreach ($result as $item) {
|
||||
yield array_values($item);
|
||||
}
|
||||
};
|
||||
|
||||
$excelGenerator->generateExcel($header, $data($result), 'section_tree.xlsx');
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
public function buildTree($menu, &$table, $level = 0): array
|
||||
{
|
||||
/** @var Section $item */
|
||||
foreach ($menu as $item) {
|
||||
if (($item->getFigure() == 'N') || ($item->getFigure() == 'O')) {
|
||||
continue;
|
||||
}
|
||||
$name = $item->getName();
|
||||
$table[] = [
|
||||
'name' => $name,
|
||||
'level' => $level,
|
||||
];
|
||||
$this->buildTree($item->getChildren(), $table, $level + 1);
|
||||
}
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
protected function column(string $name, int $level): array
|
||||
{
|
||||
$row = array_fill(0, 10, null);
|
||||
$row[$level] = $name;
|
||||
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
return CategoryTreeScript::class;
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\script;
|
||||
|
||||
use KupShop\AdminBundle\Util\Script\Script;
|
||||
use Query\Operator;
|
||||
|
||||
class FixLegacyBlocksScript extends Script
|
||||
{
|
||||
protected static $name = 'Content cleanup - remove empty legacy blocks';
|
||||
protected static $defaultParameters = [
|
||||
'tables' => ['blocks', 'blocks_translations'],
|
||||
'fix' => false,
|
||||
];
|
||||
|
||||
protected function run(array $arguments)
|
||||
{
|
||||
$tables = $arguments['tables'] ?? [];
|
||||
foreach ($tables as $table) {
|
||||
$this->fixBlocks($table, $arguments['fix'] ?? false);
|
||||
}
|
||||
}
|
||||
|
||||
protected function fixBlocks($table, $fix)
|
||||
{
|
||||
$this->log("Table `{$table}`: ");
|
||||
$qb = sqlQueryBuilder()
|
||||
->select('b.id, b.json_content')
|
||||
->from($table, 'b')
|
||||
->andWhere(Operator::like(['b.json_content' => '%"type":"legacy"%']))
|
||||
->andWhere(Operator::orX(
|
||||
Operator::like(['b.json_content' => '%"html":""%']),
|
||||
Operator::like(['b.json_content' => '%"html":null%'])
|
||||
))->execute();
|
||||
|
||||
$this->log('Total content blocks: '.$qb->rowCount());
|
||||
|
||||
$deleted = 0;
|
||||
foreach ($qb as $item) {
|
||||
$json_content = json_decode($item['json_content'], true);
|
||||
$message = $item['id'].': blocks total = '.count($json_content);
|
||||
$block_types = array_column($json_content, 'type');
|
||||
$legacy_blocks = array_count_values($block_types)['legacy'] ?? 0;
|
||||
$message .= "; legacy blocks = {$legacy_blocks}; ";
|
||||
$fixed = $this->fixJSONContent($json_content);
|
||||
if ($fixed) {
|
||||
echo $message.'<br>';
|
||||
if ($fix) {
|
||||
$json_content = empty($json_content) ? null : json_encode(array_values($json_content));
|
||||
sqlQueryBuilder()->update($table)
|
||||
->directValues(['json_content' => $json_content])
|
||||
->where(Operator::equals(['id' => $item['id']]))
|
||||
->execute();
|
||||
}
|
||||
$deleted += $fixed;
|
||||
}
|
||||
}
|
||||
|
||||
$this->log('Legacy blocks: '.$deleted);
|
||||
|
||||
if ($fix) {
|
||||
$c = sqlQuery('UPDATE '.$table.' SET content = REPLACE(content, \'<div class=""></div>\', \'\')');
|
||||
$this->log('Fixed content: '.$c->rowCount());
|
||||
}
|
||||
}
|
||||
|
||||
protected function fixJSONContent(array &$json_content)
|
||||
{
|
||||
$count = 0;
|
||||
foreach ($json_content as $key => $block) {
|
||||
if ($block['type'] == 'legacy') {
|
||||
if (empty($block['settings']['html'])) {
|
||||
unset($json_content[$key]);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
|
||||
return FixLegacyBlocksScript::class;
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\script;
|
||||
|
||||
use KupShop\AdminBundle\Util\Script\Script;
|
||||
|
||||
class OldArticleTagsScript extends Script
|
||||
{
|
||||
protected static $name = 'Otagovat staré články bez Bločku';
|
||||
|
||||
protected function run(array $arguments)
|
||||
{
|
||||
$this->log('Vytvářím tag "Článek s hlavním obrázkem"');
|
||||
sqlQuery("INSERT INTO articles_tags (tag) VALUES ('Článek s hlavním obrázkem');");
|
||||
|
||||
$id = sqlInsertId();
|
||||
$this->log('Tag ID:', $id);
|
||||
|
||||
$this->log('Značkuju články');
|
||||
sqlQuery("INSERT INTO articles_tags_relation SELECT id, '{$id}' FROM articles");
|
||||
}
|
||||
}
|
||||
|
||||
return OldArticleTagsScript::class;
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use KupShop\ContentBundle\Util\ArticlesUtil;
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
|
||||
function smarty_function_get_articles_tags($params, &$smarty)
|
||||
{
|
||||
$articleUtil = ServiceContainer::getService(ArticlesUtil::class);
|
||||
$tags = $articleUtil->getArticleTags($params['id_article'], $params['only_active']);
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'], $tags);
|
||||
} else {
|
||||
return $tags;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use KupShop\KupShopBundle\Util\StringUtil;
|
||||
use Query\Operator;
|
||||
|
||||
function smarty_function_get_author_slug($params, $smarty)
|
||||
{
|
||||
if (!$params['id'] || !findModule(\Modules::ARTICLES_AUTHORS)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$qb = sqlQueryBuilder()
|
||||
->select('name, surname, nick')
|
||||
->from('articles_authors')
|
||||
->where(Operator::equals(['id' => (int) $params['id']]))
|
||||
->execute()->fetchAssociative();
|
||||
|
||||
$authorName = '';
|
||||
|
||||
if (!empty($qb['name'])) {
|
||||
$authorName = $qb['name'];
|
||||
}
|
||||
|
||||
if (!empty($qb['surname'])) {
|
||||
$authorName .= ' '.$qb['surname'];
|
||||
}
|
||||
|
||||
if (!empty($qb['nickname'])) {
|
||||
$authorName = $qb['nick'];
|
||||
}
|
||||
|
||||
$authorName = StringUtil::slugify($authorName);
|
||||
|
||||
if ($params['assign']) {
|
||||
$smarty->assign($params['assign'], $authorName);
|
||||
} else {
|
||||
return $authorName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use KupShop\ContentBundle\Util\Block;
|
||||
use KupShop\ContentBundle\Util\InlineEdit;
|
||||
use KupShop\I18nBundle\Translations\ProducersTranslation;
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
|
||||
function smarty_function_get_producer($params, &$smarty)
|
||||
{
|
||||
if (empty($params['id_producer'])) {
|
||||
throw new InvalidArgumentException('Parameter \'id_producer\' is missing');
|
||||
}
|
||||
|
||||
$producer = sqlQueryBuilder()->select('pr.*')
|
||||
->from('producers', 'pr')
|
||||
->where(\Query\Operator::equals(['pr.id' => $params['id_producer']]))
|
||||
->andWhere(\Query\Translation::coalesceTranslatedFields(ProducersTranslation::class, ['data' => 'data_translated']))
|
||||
->execute()->fetch();
|
||||
|
||||
$producer['data'] = array_replace_recursive(json_decode($producer['data'], true) ?: [], json_decode($producer['data_translated'], true) ?: []);
|
||||
|
||||
if ($producer['id_block'] ?? false) {
|
||||
$blockUtils = ServiceContainer::getService(Block::class);
|
||||
$inlineEdit = ServiceContainer::getService(InlineEdit::class);
|
||||
$blockList = $blockUtils->getBlocks($producer['id_block']);
|
||||
$object_info = json_encode([
|
||||
'type' => 'producer',
|
||||
'id' => $params['id_producer'],
|
||||
'name' => (translate('objects', 'blocks', false, true)['producer'] ?? 'producer').': '.$producer['name'],
|
||||
]);
|
||||
|
||||
$producer['blocks'] = [];
|
||||
foreach ($blockList as $block) {
|
||||
$block['object_info'] = $object_info;
|
||||
$producer['blocks'][] = $inlineEdit->wrapBlock($block);
|
||||
}
|
||||
|
||||
$producer['descr'] = join('', array_column($producer['blocks'], 'content'));
|
||||
} else {
|
||||
$row['blocks'] = [];
|
||||
$producer['descr'] = '';
|
||||
}
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'], $producer);
|
||||
} else {
|
||||
return $producer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use KupShop\CatalogBundle\Entity\Wrapper\ProductWrapper;
|
||||
use KupShop\ContentBundle\Entity\ProductUnified;
|
||||
use KupShop\ContentBundle\Entity\Wrapper\ProductUnifiedWrapper;
|
||||
|
||||
function smarty_function_get_unified_product($params, &$smarty)
|
||||
{
|
||||
if (empty($params['product']) && empty($params['id_product'])) {
|
||||
throw new InvalidArgumentException('Missing required parameter \'product\' or \'id_product\'');
|
||||
}
|
||||
|
||||
if (!empty($params['id_product'])) {
|
||||
$product = new Product();
|
||||
$product->createFromDB($params['id_product']);
|
||||
} else {
|
||||
$product = $params['product'];
|
||||
if ($product instanceof ProductWrapper) {
|
||||
$product = $product->getObject();
|
||||
}
|
||||
}
|
||||
|
||||
$variationId = $params['id_variation'] ?? false;
|
||||
|
||||
$variations = $variationId ? $product->fetchVariations() : null;
|
||||
$unified = new ProductUnified($product, $variations);
|
||||
if ($variationId) {
|
||||
$unified->selectVariation((int) $variationId);
|
||||
}
|
||||
|
||||
$unified = ProductUnifiedWrapper::wrap($unified);
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'], $unified);
|
||||
} else {
|
||||
return $unified;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
use KupShop\ContentBundle\Util\ArticleList;
|
||||
use KupShop\ContentBundle\Util\Block;
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
|
||||
function smarty_function_insert_article($params, &$smarty)
|
||||
{
|
||||
if (!findModule(Modules::ARTICLES)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($params['id'])) {
|
||||
trigger_error("insert_article: missing 'id' parameter");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$default = [
|
||||
'template' => 'block.article.tpl',
|
||||
'id' => null,
|
||||
];
|
||||
|
||||
$params = array_merge($default, $params);
|
||||
|
||||
$articleList = ServiceContainer::getService(ArticleList::class);
|
||||
|
||||
$id_article = $params['id'];
|
||||
$spec = function (Query\QueryBuilder $qb) use ($id_article) {
|
||||
$qb->resetQueryPart('where');
|
||||
$qb->resetQueryPart('having');
|
||||
$qb->andWhere(\Query\Operator::equals(['a.id' => $id_article]));
|
||||
};
|
||||
$articleList->setImage(1);
|
||||
$article = $articleList->getArticles($spec)[0] ?? null;
|
||||
if ($article) {
|
||||
if ($blockID = $article['id_block']) {
|
||||
$block = ServiceContainer::getService(Block::class);
|
||||
$blocks = $block->getBlocks($blockID);
|
||||
$object_info = json_encode([
|
||||
'type' => 'articles',
|
||||
'id' => $article['id'],
|
||||
'name' => (translate('objects', 'blocks', true, true)['article'] ?? 'article').': '.$article['title'],
|
||||
]);
|
||||
$article['blocks'] = array_map(function ($block) use ($object_info) {
|
||||
$block['object_info'] = $object_info;
|
||||
|
||||
return $block;
|
||||
}, $blocks);
|
||||
} else {
|
||||
$article['blocks'] = [];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($params['template'])) {
|
||||
$params['article'] = $article;
|
||||
$_smarty_tpl_vars = $smarty->tpl_vars;
|
||||
echo $smarty->_subTemplateRender($params['template'], $smarty->cache_id, $smarty->compile_id, 0, null, $params, 0, false);
|
||||
$smarty->tpl_vars = $_smarty_tpl_vars;
|
||||
} elseif (!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'], $article);
|
||||
} else {
|
||||
return $article;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use KupShop\ContentBundle\Util\ArticlesUtil;
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
|
||||
function smarty_function_insert_article_sections($params, &$smarty)
|
||||
{
|
||||
$articlesUtil = ServiceContainer::getService(ArticlesUtil::class);
|
||||
|
||||
$topSection = null;
|
||||
if (isset($params['id_top_section'])) {
|
||||
$topSection = $params['id_top_section'];
|
||||
}
|
||||
|
||||
$sections = $articlesUtil->getArticleSections($topSection);
|
||||
|
||||
if (!empty($params['template'])) {
|
||||
$params['sections'] = $sections;
|
||||
$_smarty_tpl_vars = $smarty->tpl_vars;
|
||||
echo $smarty->_subTemplateRender($params['template'], $smarty->cache_id, $smarty->compile_id, 0, null, $params, 0, true);
|
||||
$smarty->tpl_vars = $_smarty_tpl_vars;
|
||||
} elseif (!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'], $sections);
|
||||
} else {
|
||||
return $sections;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
use KupShop\ContentBundle\Exception\PageException;
|
||||
use KupShop\ContentBundle\Page\FragmentPage;
|
||||
use KupShop\ContentBundle\Util\PageLocator;
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
use Query\Operator;
|
||||
|
||||
function smarty_function_insert_page($params, &$smarty)
|
||||
{
|
||||
if (!isset($params['type']) && !isset($params['code'])) {
|
||||
throw new InvalidArgumentException('Parameter \'type\' or \'code\' is required.');
|
||||
}
|
||||
|
||||
/** @var PageLocator $pageLocator */
|
||||
$pageLocator = ServiceContainer::getService(PageLocator::class);
|
||||
|
||||
static $pagesCache;
|
||||
|
||||
$addToPagesCache = function (array $item) use (&$pagesCache) {
|
||||
$pagesCache['byType'][$item['type']] = $item;
|
||||
if (!empty($item['code'])) {
|
||||
$pagesCache['byCode'][$item['code']] = $item;
|
||||
}
|
||||
};
|
||||
|
||||
if ($pagesCache === null) {
|
||||
$qb = sqlQueryBuilder()->select('type, code')->from('pages');
|
||||
|
||||
$pagesCache = [
|
||||
'byType' => [],
|
||||
'byCode' => [],
|
||||
];
|
||||
|
||||
foreach ($qb->execute() as $item) {
|
||||
$addToPagesCache($item);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($params['type'])) {
|
||||
$page = $pagesCache['byType'][$params['type']] ?? null;
|
||||
$spec = Operator::equals(['type' => $params['type']]);
|
||||
} else {
|
||||
$page = $pagesCache['byCode'][$params['code']] ?? null;
|
||||
$spec = Operator::equals(['code' => $params['code']]);
|
||||
}
|
||||
|
||||
if (!$page && ($params['use_default'] ?? false)) {
|
||||
try {
|
||||
$pageService = $pageLocator->getPageService($params['type'] ?? '');
|
||||
$pageService->createPage();
|
||||
|
||||
$page = sqlQueryBuilder()
|
||||
->select('type, code')
|
||||
->from('pages')
|
||||
->where($spec)
|
||||
->execute()->fetchAssociative();
|
||||
|
||||
if ($page) {
|
||||
$addToPagesCache($page);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
if (isDevelopment()) {
|
||||
throw new Exception("Neexistující systémová stránka: {$params['type']}");
|
||||
}
|
||||
$page = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($page) {
|
||||
$view = $smarty->getTemplateVars('view');
|
||||
|
||||
$pageService = $pageLocator->getPageService($page['type']);
|
||||
if ($pageService instanceof FragmentPage) {
|
||||
$pageService->setFragmentCode($page['code']);
|
||||
}
|
||||
if ($view) {
|
||||
$pageService->setView($view);
|
||||
}
|
||||
|
||||
try {
|
||||
$page = $pageService->getPage($params['placeholders'] ?? []);
|
||||
} catch (PageException $e) {
|
||||
$page = false;
|
||||
}
|
||||
|
||||
$smarty->loadPlugin('Smarty_modifier_inline_edit');
|
||||
|
||||
$unwrappedContent = getAdminUser() ? ($page['block']['unwrapped_content'] ?? null) : ($page['block']['content'] ?? null);
|
||||
if ($unwrappedContent || getVal('inlineEditable')) {
|
||||
$result = smarty_modifier_inline_edit($page['block']);
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
if (!empty($params['exists'])) {
|
||||
$smarty->assign($params['exists'], (bool) $result);
|
||||
}
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'], $page);
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
function smarty_function_web_version($params, &$smarty)
|
||||
{
|
||||
$version = 'default';
|
||||
if (isset($_COOKIE['web_version'])) {
|
||||
switch ($_COOKIE['web_version']) {
|
||||
case '1':
|
||||
$version = 'desktop';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'], $version);
|
||||
} else {
|
||||
return $version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
[
|
||||
{
|
||||
"type": "spacing",
|
||||
"id": "2e065e22-f372-4ee3-b2ca-c4dd9ebe8da3",
|
||||
"settings": {
|
||||
"size": 40
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "products",
|
||||
"id": "2e8ba81c-431a-495b-8705-4db1dbc0f4a2",
|
||||
"settings": {
|
||||
"order_dir": "ASC",
|
||||
"order_by": "sell",
|
||||
"count": 12,
|
||||
"column_count": 4,
|
||||
"products_filter": "{ \"parametersValuesOperator\":\"AND\",\"variationsValuesOperator\":\"AND\",\"discount\":{ \"min\":\"\",\"max\":\"\"},\"price\":{ \"min\":\"\",\"max\":\"\"},\"only_not_discounted\":\"N\",\"in_store_range\":{ \"min\":\"\",\"max\":\"\"}}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "legacy",
|
||||
"id": "dc9adcaa-c8c3-4f48-ad61-398c7ed04721",
|
||||
"settings": {
|
||||
"html": ""
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,290 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
use KupShop\ContentBundle\Util\Block;
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
|
||||
class ArticlesUpgrade extends \UpgradeNew
|
||||
{
|
||||
public function isAllowed()
|
||||
{
|
||||
return findModule(\Modules::ARTICLES);
|
||||
}
|
||||
|
||||
public function check_articlesToBlocks()
|
||||
{
|
||||
return $this->checkColumnExists('articles', 'id_block');
|
||||
}
|
||||
|
||||
/** Migration: articles_bodies to blocks */
|
||||
public function upgrade_articlesToBlocks()
|
||||
{
|
||||
sqlQuery('ALTER TABLE articles ADD COLUMN id_block INT(11) UNSIGNED DEFAULT NULL AFTER id,
|
||||
ADD FOREIGN KEY (id_block) REFERENCES blocks(id)');
|
||||
|
||||
$this->migrateArticles();
|
||||
|
||||
sqlQuery('DROP TABLE articles_bodies');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
/** Migrate table articles_bodies into blocks */
|
||||
private function migrateArticles()
|
||||
{
|
||||
$block = ServiceContainer::getService(Block::class);
|
||||
$bodies = sqlQueryBuilder()
|
||||
->select('*')
|
||||
->from('articles_bodies')
|
||||
->execute();
|
||||
|
||||
foreach ($bodies as $body) {
|
||||
if ($block->insertFirstBlock('articles', $body['id_article'], $body['body'])) {
|
||||
$article = $this->selectSQL('articles', ['id' => $body['id_article']])->fetch();
|
||||
$title = $body['part_title'];
|
||||
if (empty($title)) {
|
||||
$title = $article['title'];
|
||||
}
|
||||
$this->updateSQL('blocks', ['name' => $title], ['id' => $article['id_block']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function check_articlesBranchesPositionColumn()
|
||||
{
|
||||
return $this->checkColumnExists('articles_branches', 'position');
|
||||
}
|
||||
|
||||
/** Add position column into articles_branches */
|
||||
public function upgrade_articlesBranchesPositionColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE articles_branches ADD COLUMN position INT(11) DEFAULT NULL');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_DataColumn()
|
||||
{
|
||||
return $this->checkColumnExists('articles', 'data');
|
||||
}
|
||||
|
||||
/** Add data column into articles */
|
||||
public function upgrade_DataColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE articles ADD COLUMN data MEDIUMTEXT DEFAULT NULL');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_articleSectionTemplate()
|
||||
{
|
||||
return $this->checkColumnExists('articles_branches', 'template');
|
||||
}
|
||||
|
||||
/** Add columns template and items_per_page to articles_branches */
|
||||
public function upgrade_articleSectionTemplate()
|
||||
{
|
||||
sqlQuery('ALTER TABLE articles_branches ADD COLUMN template VARCHAR(255) DEFAULT NULL;');
|
||||
sqlQuery('ALTER TABLE articles_branches ADD COLUMN items_per_page INT(11) DEFAULT NULL AFTER template;');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_articlesTagsTable()
|
||||
{
|
||||
return $this->checkTableExists('articles_tags');
|
||||
}
|
||||
|
||||
/** Add 'articles_tags' table */
|
||||
public function upgrade_articlesTagsTable()
|
||||
{
|
||||
sqlQuery('CREATE TABLE articles_tags (
|
||||
id INT(11) PRIMARY KEY AUTO_INCREMENT,
|
||||
tag VARCHAR(50) NOT NULL UNIQUE KEY
|
||||
)');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_articlesTagsRelationTable()
|
||||
{
|
||||
return $this->checkTableExists('articles_tags_relation');
|
||||
}
|
||||
|
||||
/** Add 'articles_tags_relation' table */
|
||||
public function upgrade_articlesTagsRelationTable()
|
||||
{
|
||||
sqlQuery(
|
||||
'CREATE TABLE articles_tags_relation (
|
||||
id_article INT(11) NOT NULL,
|
||||
id_tag INT(11) NOT NULL,
|
||||
PRIMARY KEY (id_article, id_tag),
|
||||
CONSTRAINT articles_tags_relation_articles_id_fk
|
||||
FOREIGN KEY (id_article) REFERENCES articles (id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
CONSTRAINT articles_tags_relation_articles_tags_id_fk
|
||||
FOREIGN KEY (id_tag) REFERENCES articles_tags (id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE)'
|
||||
);
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ArticlesBranchesTopBranch()
|
||||
{
|
||||
return $this->checkColumnIsNull('articles_branches', 'top_branch', true);
|
||||
}
|
||||
|
||||
/** articles_branches.top_branch - change default column value to null */
|
||||
public function upgrade_ArticlesBranchesTopBranch()
|
||||
{
|
||||
sqlQuery('ALTER TABLE articles_branches CHANGE COLUMN top_branch top_branch INT(11) DEFAULT NULL');
|
||||
sqlQuery('UPDATE articles_branches SET top_branch = null WHERE top_branch = 0');
|
||||
sqlQuery('ALTER TABLE articles_branches ADD FOREIGN KEY (top_branch) REFERENCES articles_branches (id)');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ArticlesDataColumns()
|
||||
{
|
||||
return $this->checkColumnExists('articles', 'meta_title');
|
||||
}
|
||||
|
||||
/** Add meta-title and meta-description to articles */
|
||||
public function upgrade_ArticlesDataColumns()
|
||||
{
|
||||
sqlQuery('ALTER TABLE articles ADD COLUMN meta_title VARCHAR(100) NULL;
|
||||
ALTER TABLE articles ADD COLUMN meta_description VARCHAR(250) NULL;');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_articlesAuthorsRelation_ForeignKey()
|
||||
{
|
||||
return $this->checkForeignKeyExists('articles_authors_relation', 'id_art');
|
||||
}
|
||||
|
||||
public function check_ArticlesMetaTitleLength(): bool
|
||||
{
|
||||
return $this->checkColumnType('articles', 'meta_title', 'VARCHAR(100)');
|
||||
}
|
||||
|
||||
/** Increase length of articles.meta_title */
|
||||
public function upgrade_ArticlesMetaTitleLength(): void
|
||||
{
|
||||
sqlQuery('ALTER TABLE articles CHANGE COLUMN meta_title meta_title VARCHAR(100) NULL');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
/** Add foreign keys into 'articles_authors_relation' */
|
||||
public function upgrade_articlesAuthorsRelation_ForeignKey()
|
||||
{
|
||||
sqlQuery('ALTER TABLE articles_authors_relation
|
||||
ADD CONSTRAINT articles_authors_relation_ibfk1
|
||||
FOREIGN KEY (id_art) REFERENCES articles(id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT articles_authors_relation_ibfk2
|
||||
FOREIGN KEY (id_auth) REFERENCES articles_authors(id) ON DELETE CASCADE ON UPDATE CASCADE ');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ArticlesUrlColumn()
|
||||
{
|
||||
return $this->checkColumnExists('articles', 'url');
|
||||
}
|
||||
|
||||
/** Add 'url' column into 'articles' table */
|
||||
public function upgrade_ArticlesUrlColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE articles ADD COLUMN url VARCHAR(255) DEFAULT NULL AFTER data');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ArticlesAuthorsPhotoColumn()
|
||||
{
|
||||
return $this->checkColumnExists('articles_authors', 'photo');
|
||||
}
|
||||
|
||||
/** Add 'photo' column into 'articles_authors' table */
|
||||
public function upgrade_ArticlesAuthorsPhotoColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE articles_authors ADD COLUMN photo varchar(250) NULL AFTER sex');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ArticlesRelated(): bool
|
||||
{
|
||||
return $this->checkTableExists('articles_related');
|
||||
}
|
||||
|
||||
/** Add 'articles_related' table */
|
||||
public function upgrade_ArticlesRelated(): void
|
||||
{
|
||||
sqlQuery(
|
||||
'CREATE TABLE articles_related (
|
||||
id_article INT(11) NOT NULL,
|
||||
id_article_related INT(11) NOT NULL,
|
||||
position INT(11) DEFAULT 0,
|
||||
PRIMARY KEY (id_article, id_article_related),
|
||||
CONSTRAINT articles_related_relation_articles_id_fk
|
||||
FOREIGN KEY (id_article) REFERENCES articles (id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
CONSTRAINT articles_related_relation_articles_id_related_fk
|
||||
FOREIGN KEY (id_article_related) REFERENCES articles (id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE)'
|
||||
);
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_trigger_ArticlesRelated()
|
||||
{
|
||||
return $this->checkIfTriggerExists('trigger_articles_related');
|
||||
}
|
||||
|
||||
/** Add trigger (incrementing position) to articles_related */
|
||||
public function upgrade_trigger_ArticlesRelated()
|
||||
{
|
||||
sqlQuery('CREATE TRIGGER trigger_articles_related BEFORE INSERT ON articles_related
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.position IS NULL THEN
|
||||
SET NEW.position = (SELECT COALESCE(MAX(articles_related.position) + 1, 0) FROM articles_related WHERE id_article = NEW.id_article);
|
||||
END IF;
|
||||
END;');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ArticlesBranchesSEO()
|
||||
{
|
||||
return $this->checkColumnExists('articles_branches', 'meta_title')
|
||||
&& $this->checkColumnExists('articles_branches', 'meta_description');
|
||||
}
|
||||
|
||||
/** Add meta-title and meta-description to articles sections */
|
||||
public function upgrade_ArticlesBranchesSEO()
|
||||
{
|
||||
sqlQuery('ALTER TABLE articles_branches ADD COLUMN meta_title VARCHAR(100) NULL;
|
||||
ALTER TABLE articles_branches ADD COLUMN meta_description VARCHAR(250) NULL;');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ArticlesAuthorsDateUpdate()
|
||||
{
|
||||
return findModule(\Modules::ARTICLES_AUTHORS) && $this->checkColumnExists('articles_authors', 'date_update');
|
||||
}
|
||||
|
||||
/** Add date_update column to articles_authors because of cache */
|
||||
public function upgrade_ArticlesAuthorsDateUpdate()
|
||||
{
|
||||
sqlQuery('ALTER TABLE articles_authors ADD COLUMN date_update DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
class CategoriesUpgrade extends \UpgradeNew
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
use Query\Operator;
|
||||
|
||||
class EmailUpgrade extends \UpgradeNew
|
||||
{
|
||||
public function __construct($verbose = self::VERBOSE_NO, $useLocalUpgrades = self::LOCAL_UPGRADES_YES)
|
||||
{
|
||||
parent::__construct($verbose, $useLocalUpgrades);
|
||||
}
|
||||
|
||||
public function check_trigger_emails()
|
||||
{
|
||||
return $this->checkIfTriggerExists('trigger_emails');
|
||||
}
|
||||
|
||||
/** Add trigger (incrementing position) to emails */
|
||||
public function upgrade_trigger_emails()
|
||||
{
|
||||
sqlQuery('CREATE TRIGGER trigger_emails BEFORE INSERT ON emails
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.position IS NULL THEN
|
||||
SET NEW.position = (SELECT COALESCE(MAX(position) + 1, 0) FROM emails);
|
||||
END IF;
|
||||
END;');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_unique()
|
||||
{
|
||||
return $this->checkIndexNameExists('emails', 'emails_type_name_uindex');
|
||||
}
|
||||
|
||||
/** Add UNIQUE index to emails */
|
||||
public function upgrade_unique()
|
||||
{
|
||||
sqlQuery('UPDATE emails SET name = "" WHERE name IS NULL');
|
||||
sqlQuery('ALTER TABlE emails MODIFY name VARCHAR(250) DEFAULT "" NOT NULL');
|
||||
sqlQuery('CREATE UNIQUE INDEX emails_type_name_uindex ON emails (type, name)');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_emailsEnabledColumn()
|
||||
{
|
||||
return $this->checkColumnExists('emails', 'enabled');
|
||||
}
|
||||
|
||||
/** Add `enabled` column to `emails` */
|
||||
public function upgrade_emailsEnabledColumn()
|
||||
{
|
||||
sqlQuery("ALTER TABLE emails ADD COLUMN enabled ENUM('Y', 'N') DEFAULT 'Y' NOT NULL");
|
||||
$disabled = [];
|
||||
$dbcfg = \Settings::getDefault();
|
||||
if (($dbcfg['order_send_received_mail'] ?? 'N') == 'N') {
|
||||
$disabled[] = 'ORDER_CREATE';
|
||||
}
|
||||
if (($dbcfg['order_send_status_mail'] ?? 'N') == 'N') {
|
||||
$disabled[] = 'ORDER_STATUS_CHANGE';
|
||||
}
|
||||
if (($dbcfg['order_send_to_shopkeeper'] ?? 'N') == 'N') {
|
||||
$disabled[] = 'ORDER_CREATE_ADMIN';
|
||||
}
|
||||
if ($disabled) {
|
||||
sqlQueryBuilder()->update('emails')
|
||||
->directValues(['enabled' => 'N'])
|
||||
->andWhere(Operator::inStringArray($disabled, 'type'))
|
||||
->execute();
|
||||
}
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
use Query\Operator;
|
||||
|
||||
class InfoPanelUpgrade extends \UpgradeNew
|
||||
{
|
||||
public function check_createInfoPanelTable()
|
||||
{
|
||||
return $this->checkTableExists('info_panels');
|
||||
}
|
||||
|
||||
/** info_panels: create table */
|
||||
public function upgrade_createInfoPanelTable()
|
||||
{
|
||||
sqlQuery('CREATE TABLE info_panels (
|
||||
id INT AUTO_INCREMENT NOT NULL,
|
||||
name VARCHAR(60) NOT NULL,
|
||||
type VARCHAR(50) DEFAULT "default" NOT NULL,
|
||||
active ENUM("Y", "N") DEFAULT "Y" NOT NULL,
|
||||
version INT NOT NULL,
|
||||
date_from DATETIME NULL,
|
||||
date_to DATETIME NULL,
|
||||
body MEDIUMTEXT NULL,
|
||||
data LONGTEXT NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE = InnoDB');
|
||||
|
||||
$infoPanel = sqlQueryBuilder()
|
||||
->select('*')
|
||||
->from('settings', 's')
|
||||
->andWhere(Operator::equals(['key_name' => 'info_panel']))
|
||||
->execute()
|
||||
->fetchAssociative();
|
||||
|
||||
if (($infoPanel ?? false) && !empty($infoPanel['value']) && $infoPanel['value'] != 'null') {
|
||||
$infoPanelValues = json_decode($infoPanel['value'], true);
|
||||
sqlQueryBuilder()
|
||||
->insert('info_panels')
|
||||
->directValues([
|
||||
'name' => 'Informační panel',
|
||||
'type' => 'default',
|
||||
'active' => ($infoPanelValues['enable'] == 'Y') ? 1 : 0,
|
||||
'date_from' => (!empty($infoPanelValues['date_from'])) ? $this->prepareDateTime($infoPanelValues['date_from']) : null,
|
||||
'date_to' => (!empty($infoPanelValues['date_to'])) ? $this->prepareDateTime($infoPanelValues['date_to']) : null,
|
||||
'body' => "{$infoPanelValues['text']}",
|
||||
'version' => $infoPanelValues['version'],
|
||||
])->execute();
|
||||
}
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
use Query\Operator;
|
||||
|
||||
class MenuLabelsUpgrade extends \UpgradeNew
|
||||
{
|
||||
protected $priority = 999;
|
||||
|
||||
protected $label = 'cookies_policy';
|
||||
|
||||
public function check_RevertGDPRLabels()
|
||||
{
|
||||
return \Settings::getDefault()->user_rights_version == 8;
|
||||
}
|
||||
|
||||
/** Revert GDPR labels */
|
||||
public function upgrade_RevertGDPRLabels()
|
||||
{
|
||||
$settings = \Settings::getDefault();
|
||||
|
||||
$labels = ['shopping-rules', 'privacy_policy', 'consent'];
|
||||
|
||||
foreach ($labels as $label) {
|
||||
$url = translate_shop($label, 'SEO_URL');
|
||||
sqlQueryBuilder()->update('menu_links')
|
||||
->directValues(['code' => $label])
|
||||
->where(Operator::equals(['url' => trim($url, '/')]))
|
||||
->execute();
|
||||
}
|
||||
|
||||
$this->commitDataMigration(9);
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
// public function check_CookiesPolicyLabels()
|
||||
// {
|
||||
// return sqlQueryBuilder()->select('count(id)')
|
||||
// ->from('menu_links')
|
||||
// ->where(Operator::equals(['code' => $this->label]))
|
||||
// ->execute()->fetchColumn() > 0 ? false : true;
|
||||
// }
|
||||
//
|
||||
// /** Add cookie policy page */
|
||||
// public function upgrade_CookiesPolicyLabels()
|
||||
// {
|
||||
// sqlQueryBuilder()->insert('blocks')
|
||||
// ->execute();
|
||||
// $idBlock = sqlInsertId();
|
||||
//
|
||||
// sqlQueryBuilder()->insert('blocks')
|
||||
// ->directValues(
|
||||
// [
|
||||
// 'id_parent' => $idBlock,
|
||||
// 'id_root' => $idBlock,
|
||||
// 'position' => 1,
|
||||
// 'content' => ' <h2 class="text-left">Zásady používání soborů cookie</h2><div class="w-text"><p>Na našich webových stránkách využíváme různé technologie, abychom mohli zlepšit Vaši zkušenost s jejich používáním. K nim patří zpracování údajů, které je technicky nutné k fungování webových stránek a jejich funkcionalit, stejně jako další technologie sloužící k pohodlnému nastavení webových stránek, k vytváření anonymních statistik nebo pro inzerci personalizovaných (reklamních) obsahů.</p><p>V patičce webu pod tlačítkem "Nastavení cookies" se můžete kdykoliv svobodně rozhodnout, které typy užití chcete povolit.</p></div><div class="w-table"><figure class="table"><table><thead><tr><th>jméno</th><th>poskytovatel</th><th>účel</th><th>vypršení</th><th>typ</th></tr></thead><tbody><tr><td>cookie-bar</td><td>e-shop</td><td>Zvolení souhlasů s ukládáním cookies</td><td>2 roky</td><td>Nezbytné</td></tr><tr><td>infopanel-hide</td><td>e-shop</td><td>Nastavuje schování informačního panelu</td><td>Bez omezení</td><td>Nezbytné</td></tr><tr><td>cat_show</td><td>e-shop</td><td>Nastavuje styl zobrazení produktů v sekci</td><td>30 dnů</td><td>Nezbytné</td></tr><tr><td>filter_onpage</td><td>e-shop</td><td>Nastavuje počet produktů na stránce</td><td>30 dnů</td><td>Nezbytné</td></tr><tr><td>web_version</td><td>e-shop</td><td>Nastavuje preferenci pro desktopovou verzi na mobilu</td><td>Do zavření prohlížeče</td><td>Nezbytné</td></tr><tr><td>last_visited</td><td>e-shop</td><td>Ukládá naposled prohlížené produkty</td><td>30 dnů</td><td>Preferenční</td></tr><tr><td>remember</td><td>e-shop</td><td>Zapamatování přihlášení uživatele</td><td>1 rok</td><td>Nezbytné</td></tr><tr><td>cartID</td><td>e-shop</td><td>Ukládání zboží vloženého do košíku</td><td>1 rok</td><td>Nezbytné</td></tr><tr><td>PHPSESSID</td><td>e-shop</td><td>Dočasné úložiště dat nezbytných pro použití webu</td><td>Do zavření prohlížeče</td><td>Nezbytné</td></tr></tbody></table></figure></div>',
|
||||
// 'json_content' => '[{"type":"heading","id":"a241d31c-b604-4da0-9e86-0fb4cfaa65e6","settings":{"level":"2","align":"left","text":"Zásady používání soborů cookie"}},{"type":"text","id":"ad6ab9a5-dfb9-4fca-807c-7b11f7cf6eeb","settings":{"html":"<p>Na našich webových stránkách využíváme různé technologie, abychom mohli zlepšit Vaši zkušenost s jejich používáním. K nim patří zpracování údajů, které je technicky nutné k fungování webových stránek a jejich funkcionalit, stejně jako další technologie sloužící k pohodlnému nastavení webových stránek, k vytváření anonymních statistik nebo pro inzerci personalizovaných (reklamních) obsahů.</p><p>V patičce webu pod tlačítkem \"Nastavení cookies\" se můžete kdykoliv svobodně rozhodnout, které typy užití chcete povolit.</p>"}},{"type":"table","id":"f7c8f8d6-87dc-4cad-be1c-f8f32b56db72","settings":{"html":"<figure class=\"table\"><table><thead><tr><th>jméno</th><th>poskytovatel</th><th>účel</th><th>vypršení</th><th>typ</th></tr></thead><tbody><tr><td>cookie-bar</td><td>e-shop</td><td>Zvolení souhlasů s ukládáním cookies</td><td>2 roky</td><td>Nezbytné</td></tr><tr><td>infopanel-hide</td><td>e-shop</td><td>Nastavuje schování informačního panelu</td><td>Bez omezení</td><td>Nezbytné</td></tr><tr><td>cat_show</td><td>e-shop</td><td>Nastavuje styl zobrazení produktů v sekci</td><td>30 dnů</td><td>Nezbytné</td></tr><tr><td>filter_onpage</td><td>e-shop</td><td>Nastavuje počet produktů na stránce</td><td>30 dnů</td><td>Nezbytné</td></tr><tr><td>web_version</td><td>e-shop</td><td>Nastavuje preferenci pro desktopovou verzi na mobilu</td><td>Do zavření prohlížeče</td><td>Nezbytné</td></tr><tr><td>last_visited</td><td>e-shop</td><td>Ukládá naposled prohlížené produkty</td><td>30 dnů</td><td>Preferenční</td></tr><tr><td>remember</td><td>e-shop</td><td>Zapamatování přihlášení uživatele</td><td>1 rok</td><td>Nezbytné</td></tr><tr><td>cartID</td><td>e-shop</td><td>Ukládání zboží vloženého do košíku</td><td>1 rok</td><td>Nezbytné</td></tr><tr><td>PHPSESSID</td><td>e-shop</td><td>Dočasné úložiště dat nezbytných pro použití webu</td><td>Do zavření prohlížeče</td><td>Nezbytné</td></tr></tbody></table></figure>"}}]', ]
|
||||
// )
|
||||
// ->execute();
|
||||
//
|
||||
// sqlQueryBuilder()->insert('menu_links')
|
||||
// ->directValues([
|
||||
// 'code' => $this->label,
|
||||
// 'id_block' => $idBlock,
|
||||
// 'type' => 1,
|
||||
// 'name' => 'Soubory cookie',
|
||||
// 'url' => 'soubory-cookie/',
|
||||
// ])
|
||||
// ->execute();
|
||||
// $this->upgradeOK();
|
||||
// }
|
||||
//
|
||||
// public function check_CookiesPolicyTemplate()
|
||||
// {
|
||||
// return empty(sqlQueryBuilder()->select('template')
|
||||
// ->from('menu_links')
|
||||
// ->where(Operator::equals(['code' => $this->label]))
|
||||
// ->execute()->fetchColumn());
|
||||
// }
|
||||
//
|
||||
// /** Set template for cookie policy page */
|
||||
// public function upgrade_CookiesPolicyTemplate()
|
||||
// {
|
||||
// sqlQueryBuilder()->update('menu_links')
|
||||
// ->directValues(['template' => 'page/page.cookies.tpl'])
|
||||
// ->where(Operator::equals(['code' => $this->label]))
|
||||
// ->execute();
|
||||
//
|
||||
// $this->upgradeOK();
|
||||
// }
|
||||
}
|
||||
528
bundles/KupShop/ContentBundle/Resources/upgrade/MenuUpgrade.php
Normal file
528
bundles/KupShop/ContentBundle/Resources/upgrade/MenuUpgrade.php
Normal file
@@ -0,0 +1,528 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
use KupShop\ContentBundle\Util\MenuUtil;
|
||||
use KupShop\I18nBundle\Translations\MenuLinksTranslation;
|
||||
use KupShop\KupShopBundle\Config;
|
||||
use KupShop\KupShopBundle\Context\LanguageContext;
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
use KupShop\KupShopBundle\Util\StringUtil;
|
||||
use Query\Operator;
|
||||
|
||||
class MenuUpgrade extends \UpgradeNew
|
||||
{
|
||||
public function check_menuType()
|
||||
{
|
||||
return $this->checkColumnExists('menu_links', 'type');
|
||||
}
|
||||
|
||||
/** Add menu_links.type */
|
||||
public function upgrade_menuType()
|
||||
{
|
||||
// id_root is temporary and will be renamed to id_menu later in this migration
|
||||
sqlQuery(
|
||||
"ALTER TABLE menu_links
|
||||
ADD COLUMN id_root INT UNSIGNED DEFAULT NULL AFTER id,
|
||||
ADD COLUMN type TINYINT UNSIGNED DEFAULT 2 NOT NULL AFTER id_root,
|
||||
ADD COLUMN name_short VARCHAR(50) DEFAULT '' AFTER name,
|
||||
ADD COLUMN code VARCHAR(50) DEFAULT NULL UNIQUE AFTER name_short,
|
||||
ADD COLUMN url VARCHAR(255) DEFAULT NULL AFTER code,
|
||||
ADD COLUMN id_block INT(11) UNSIGNED NULL AFTER data,
|
||||
ADD COLUMN template VARCHAR(255) DEFAULT '' NOT NULL AFTER id_block,
|
||||
ADD COLUMN meta_title VARCHAR(70) NULL AFTER template,
|
||||
ADD COLUMN meta_description VARCHAR(250) NULL AFTER meta_title,
|
||||
ADD COLUMN meta_keywords VARCHAR(100) NULL AFTER meta_description,
|
||||
ADD COLUMN old_id_page INT(11) NULL AFTER meta_keywords"
|
||||
);
|
||||
sqlQuery('ALTER TABLE menu_links MODIFY parent INT UNSIGNED DEFAULT NULL;');
|
||||
sqlQuery('ALTER TABLE menu_links ENGINE InnoDB;');
|
||||
sqlQuery('ALTER TABLE menu_links MODIFY link VARCHAR(255) DEFAULT NULL;');
|
||||
sqlQuery("UPDATE menu_links SET link=NULL WHERE link='';");
|
||||
|
||||
$menu = Config::get()['Menu']['own'] ?? [];
|
||||
$i = 0;
|
||||
foreach ($menu as $menuID => $menu) {
|
||||
$existing = sqlQuery('SELECT * FROM menu_links WHERE id=:menuID', ['menuID' => $menuID])->fetch();
|
||||
if ($existing) {
|
||||
// re-insert row with required id (so it can be used for this menu)
|
||||
unset($existing['id']);
|
||||
$this->insertSQL('menu_links', $existing);
|
||||
$newID = sqlInsertId();
|
||||
sqlQuery('UPDATE menu_links SET parent=:new_parent WHERE parent=:old_parent', [
|
||||
'new_parent' => $newID,
|
||||
'old_parent' => $menuID,
|
||||
]);
|
||||
$this->deleteSQL('menu_links', ['id' => $menuID]);
|
||||
}
|
||||
sqlQuery('INSERT INTO menu_links (id, id_root, parent, list_order, type, name, name_short) VALUES (:id, :id_root, NULL, :position, :type, :name, :name_short);', [
|
||||
'id' => $menuID,
|
||||
'id_root' => $menuID,
|
||||
'position' => $i++,
|
||||
'type' => MenuUtil::TYPE_GROUP,
|
||||
'name' => $menu['name'],
|
||||
'name_short' => $menu['title'],
|
||||
]);
|
||||
sqlQuery('UPDATE menu_links SET parent=:parent WHERE id_menu=:id_menu AND parent IS NULL', [
|
||||
'parent' => $menuID,
|
||||
'id_menu' => $menuID,
|
||||
]);
|
||||
sqlQuery('UPDATE menu_links SET id_root=:id_root WHERE id_menu=:id_menu', [
|
||||
'id_root' => $menuID,
|
||||
'id_menu' => $menuID,
|
||||
]);
|
||||
|
||||
// move orphans to their root and set figure = N
|
||||
sqlQuery('DELETE m1 FROM menu_links m1
|
||||
LEFT JOIN menu_links m2 ON m2.id = m1.parent
|
||||
WHERE m2.id IS NULL AND m1.parent IS NOT NULL;');
|
||||
}
|
||||
|
||||
// edit type of menu_links
|
||||
foreach (sqlQuery('SELECT * FROM menu_links WHERE type = :type', ['type' => MenuUtil::TYPE_LINK]) as $menuLink) {
|
||||
if (empty($menuLink['link'])) {
|
||||
if (!empty(sqlQuery('SELECT * FROM menu_links WHERE parent = :id', ['id' => $menuLink['id']])->fetch())) {
|
||||
$this->updateSQL('menu_links', ['type' => MenuUtil::TYPE_GROUP], ['id' => $menuLink['id']]);
|
||||
} else {
|
||||
$this->updateSQL('menu_links', ['link' => '/'], ['id' => $menuLink['id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// drop id_menu
|
||||
sqlQuery('ALTER TABLE menu_links DROP COLUMN id_menu;');
|
||||
sqlQuery('ALTER TABLE menu_links CHANGE id_root id_menu INT UNSIGNED DEFAULT NULL;');
|
||||
|
||||
sqlQuery('
|
||||
ALTER TABLE menu_links
|
||||
ADD CONSTRAINT menu_links_fk_parent FOREIGN KEY (parent) REFERENCES menu_links(id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
ADD CONSTRAINT menu_links_fk_id_menu FOREIGN KEY (id_menu) REFERENCES menu_links(id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE;');
|
||||
sqlQuery('CREATE UNIQUE INDEX menu_links_uix_url ON menu_links(url);');
|
||||
|
||||
sqlQuery("
|
||||
CREATE TABLE photos_menu_relation (
|
||||
id_photo INT(11) UNSIGNED DEFAULT 0 NOT NULL,
|
||||
id_menu INT UNSIGNED DEFAULT 0 NOT NULL,
|
||||
show_in_lead ENUM('Y', 'N') DEFAULT 'N' NOT NULL,
|
||||
active ENUM('Y', 'N') DEFAULT 'Y' NOT NULL,
|
||||
date_added DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
||||
position INT NULL,
|
||||
CONSTRAINT id_photo
|
||||
UNIQUE (id_photo, id_menu),
|
||||
CONSTRAINT photos_menu_relation_ibfk_1
|
||||
FOREIGN KEY (id_photo) REFERENCES photos(id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
CONSTRAINT photos_menu_relation_ibfk_2
|
||||
FOREIGN KEY (id_menu) REFERENCES menu_links(id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
);
|
||||
");
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_menuTranslation()
|
||||
{
|
||||
return findModule(\Modules::TRANSLATIONS)
|
||||
&& $this->checkColumnExists('menu_links_translations', 'id_block');
|
||||
}
|
||||
|
||||
/** Add menu_links_translations.id_block... */
|
||||
public function upgrade_menuTranslation()
|
||||
{
|
||||
sqlQuery(
|
||||
'ALTER TABLE menu_links_translations
|
||||
ADD COLUMN name_short VARCHAR(50) DEFAULT NULL AFTER name,
|
||||
ADD COLUMN url VARCHAR(255) DEFAULT NULL AFTER name_short,
|
||||
ADD COLUMN id_block INT(11) UNSIGNED NULL,
|
||||
ADD COLUMN meta_title VARCHAR(70) NULL,
|
||||
ADD COLUMN meta_description VARCHAR(250) NULL,
|
||||
ADD COLUMN meta_keywords VARCHAR(100) NULL;'
|
||||
);
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_html_pages()
|
||||
{
|
||||
return !$this->checkTableIsEmpty('html_pages');
|
||||
}
|
||||
|
||||
/** Remove html_pages table */
|
||||
public function upgrade_html_pages()
|
||||
{
|
||||
$pages = sqlQuery('SELECT * FROM html_pages');
|
||||
$menuLinks = sqlQuery('SELECT * FROM menu_links')->fetchAll();
|
||||
|
||||
if (findModule(\Modules::TRANSLATIONS)) {
|
||||
/** @var MenuLinksTranslation $translationService */
|
||||
$translationService = ServiceContainer::getService(MenuLinksTranslation::class);
|
||||
}
|
||||
|
||||
$usedLabels = [];
|
||||
|
||||
$unclassifiedPagesCounter = 0;
|
||||
foreach ($pages as $page) {
|
||||
$menuLink = null;
|
||||
|
||||
// homepage vytvorit v systemovych strankach
|
||||
if ($page['label'] == 'leadpage') {
|
||||
$this->insertSQL('pages', [
|
||||
'id_block' => $page['id_block'],
|
||||
'code' => 'system-home',
|
||||
'type' => 'HOME',
|
||||
]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$label = null;
|
||||
if (!empty($page['label']) && !in_array($page['label'], $usedLabels)) {
|
||||
if ($seoUrl = translate_shop($page['label'], 'SEO_URL', true)) {
|
||||
$pattern = '/'.$seoUrl.'/';
|
||||
$label = $page['label'];
|
||||
} else {
|
||||
$pattern = '/_p'.$page['id'].'.html/';
|
||||
}
|
||||
} else {
|
||||
$pattern = '/_p'.$page['id'].'.html/';
|
||||
}
|
||||
|
||||
// zkusit najit menu_link patrici ke strance
|
||||
foreach ($menuLinks as $link) {
|
||||
if ($this->isExternalUrl($link['link'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match($pattern, $link['link'])) {
|
||||
if ($label && strpos($link['link'], '.html')) {
|
||||
continue;
|
||||
}
|
||||
$menuLink = $link;
|
||||
if ($label) {
|
||||
$usedLabels[] = $label;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// pokud nebylo nic nalezeno a je nastaven label, tak zkusit hledat jeste jednou podle odkazu stranky
|
||||
if (!$menuLink && !empty($page['label'])) {
|
||||
$pattern = '/_p'.$page['id'].'.html/';
|
||||
foreach ($menuLinks as $link) {
|
||||
if ($this->isExternalUrl($link['link'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match($pattern, $link['link'])) {
|
||||
$menuLink = $link;
|
||||
// pokud ma label URL, tak ji nastavit
|
||||
if ($seoUrl = translate_shop($page['label'], 'SEO_URL', true)) {
|
||||
$menuLink['link'] = $seoUrl;
|
||||
}
|
||||
$label = $page['label'];
|
||||
$usedLabels[] = $page['label'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$iLabel = null;
|
||||
if (!empty($page['label'])) {
|
||||
if (!$this->selectSQL('menu_links', ['code' => $page['label']])->fetch()) {
|
||||
$iLabel = $page['label'];
|
||||
}
|
||||
}
|
||||
|
||||
$updateName = false;
|
||||
if ($menuLink) { // aktualizovat menu_links podle stranky
|
||||
$url = parse_url($menuLink['link']);
|
||||
$url = ltrim($url['path'] ?? $menuLink['link'], '/');
|
||||
if (!preg_match('/.+(.html)$/', $url)) {
|
||||
$url = trim($url, '/').'/';
|
||||
}
|
||||
$update = [
|
||||
'type' => MenuUtil::TYPE_PAGE,
|
||||
'id_block' => $page['id_block'],
|
||||
'template' => $page['template'],
|
||||
'meta_title' => $page['meta_title'],
|
||||
'meta_description' => $page['meta_description'],
|
||||
'meta_keywords' => $page['meta_keywords'],
|
||||
'url' => $url,
|
||||
'link' => null,
|
||||
'old_id_page' => $page['id'],
|
||||
];
|
||||
|
||||
if ($iLabel) {
|
||||
$update['code'] = $iLabel;
|
||||
}
|
||||
|
||||
if ($menuLink['name'] != $page['name']) {
|
||||
$update['name'] = $page['name'];
|
||||
$update['name_short'] = $menuLink['name'];
|
||||
$updateName = true;
|
||||
}
|
||||
|
||||
$this->updateSQL('menu_links', $update, ['id' => $menuLink['id']]);
|
||||
|
||||
if (findModule(\Modules::TRANSLATIONS)) {
|
||||
if (!$label) {
|
||||
sqlQuery(
|
||||
'UPDATE menu_links_translations SET url = link, link = null WHERE id_menu_link = :id_menu_link',
|
||||
[
|
||||
'id_menu_link' => $menuLink['id'],
|
||||
]
|
||||
);
|
||||
} else {
|
||||
// translate label and insert it into translations
|
||||
$this->translateLabel($menuLink['id'], $label, $translationService);
|
||||
}
|
||||
}
|
||||
|
||||
$menuLinkId = $menuLink['id'];
|
||||
} else { // vytvorit novy menu_link mimo strukturu se strankou
|
||||
$updateName = true;
|
||||
|
||||
$insertLink = StringUtil::slugify($page['name']).'_p'.$page['id'].'.html';
|
||||
if (!empty($page['label']) && !in_array($page['label'], $usedLabels) && $link = translate_shop($page['label'], 'SEO_URL', true)) {
|
||||
$insertLink = $link.'/';
|
||||
}
|
||||
|
||||
$this->insertSQL('menu_links', [
|
||||
'type' => MenuUtil::TYPE_PAGE,
|
||||
'code' => $iLabel,
|
||||
'name' => $page['name'],
|
||||
'list_order' => $unclassifiedPagesCounter++,
|
||||
'id_block' => $page['id_block'],
|
||||
'url' => $insertLink,
|
||||
'template' => $page['template'],
|
||||
'meta_title' => $page['meta_title'],
|
||||
'meta_description' => $page['meta_description'],
|
||||
'meta_keywords' => $page['meta_keywords'],
|
||||
'old_id_page' => $page['id'],
|
||||
]);
|
||||
$menuLinkId = sqlInsertId();
|
||||
}
|
||||
|
||||
// photos_pages_relation -> photos_menu_relation
|
||||
$photos = sqlQueryBuilder()->select('*')->from('photos_pages_relation')
|
||||
->where(Operator::equals(['id_page' => $page['id']]))
|
||||
->orderBy('position')->execute();
|
||||
foreach ($photos as $photo) {
|
||||
$this->insertSQL('photos_menu_relation', [
|
||||
'id_photo' => $photo['id_photo'],
|
||||
'id_menu' => $menuLinkId,
|
||||
'show_in_lead' => $photo['show_in_lead'],
|
||||
'active' => $photo['active'],
|
||||
'date_added' => $photo['date_added'],
|
||||
'position' => $photo['position'],
|
||||
]);
|
||||
}
|
||||
|
||||
// pokud jsou preklady, tak premigrovat taky
|
||||
if (findModule(\Modules::TRANSLATIONS)) {
|
||||
$translations = sqlQuery('SELECT * FROM html_pages_translations WHERE id_html_page = :id', ['id' => $page['id']]);
|
||||
|
||||
foreach ($translations as $translation) {
|
||||
$values = [
|
||||
'meta_title' => $translation['meta_title'],
|
||||
'meta_description' => $translation['meta_description'],
|
||||
'meta_keywords' => $translation['meta_keywords'],
|
||||
];
|
||||
|
||||
if ($updateName) {
|
||||
$values['name'] = $translation['name'];
|
||||
|
||||
$menuLinkName = sqlQuery('SELECT name FROM menu_links_translations WHERE id_menu_link = :id AND id_language = :id_language', [
|
||||
'id' => $menuLinkId,
|
||||
'id_language' => $translation['id_language'],
|
||||
])->fetchColumn();
|
||||
|
||||
if (!empty($menuLinkName)) {
|
||||
$values['name_short'] = $menuLinkName;
|
||||
}
|
||||
}
|
||||
|
||||
$translationService->saveSingleObject($translation['id_language'], $menuLinkId, $values);
|
||||
}
|
||||
|
||||
sqlQuery('DELETE FROM html_pages_translations');
|
||||
}
|
||||
}
|
||||
|
||||
// promazat html_pages tabulky
|
||||
sqlQuery('DELETE FROM html_pages');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $translationService MenuLinksTranslation
|
||||
*/
|
||||
private function translateLabel($menuLinkId, $label, $translationService)
|
||||
{
|
||||
$languageContext = ServiceContainer::getService(LanguageContext::class);
|
||||
$originalLanguage = $languageContext->getActiveId();
|
||||
foreach ($languageContext->getSupported() as $language) {
|
||||
if ($languageContext->getDefaultId() == $language->getId()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$languageContext->activate($language->getId());
|
||||
|
||||
$url = translate($label, 'SEO_URL').'/';
|
||||
|
||||
$translationService->saveSingleObject($language->getId(), $menuLinkId, ['link' => null, 'url' => $url]);
|
||||
}
|
||||
|
||||
$languageContext->activate($originalLanguage);
|
||||
}
|
||||
|
||||
private function isExternalUrl($url)
|
||||
{
|
||||
$cfg = Config::get();
|
||||
$url = parse_url($url);
|
||||
|
||||
if (!empty($url['host'])) {
|
||||
if (strpos($url['host'], trim($cfg['Addr']['print'], '/')) !== false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function check_OldIdPageColumn()
|
||||
{
|
||||
return $this->checkColumnExists('menu_links', 'old_id_page');
|
||||
}
|
||||
|
||||
/** Add old_id_page column into menu_links table */
|
||||
public function upgrade_OldIdPageColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE menu_links ADD COLUMN old_id_page INT(11) NULL AFTER meta_keywords');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_CodeColumn()
|
||||
{
|
||||
return $this->checkColumnExists('menu_links', 'code');
|
||||
}
|
||||
|
||||
/** Add code column into menu_links table */
|
||||
public function upgrade_CodeColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE menu_links ADD COLUMN code VARCHAR(50) DEFAULT NULL UNIQUE AFTER name_short');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_DeleteHtmlPagesTableTranslations()
|
||||
{
|
||||
return !$this->checkTableExists('html_pages_translations');
|
||||
}
|
||||
|
||||
/** Delete html_pages_translations table */
|
||||
public function upgrade_DeleteHtmlPagesTableTranslations()
|
||||
{
|
||||
sqlQuery('DROP TABLE html_pages_translations');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_DeleteHtmlPagesTableRelation()
|
||||
{
|
||||
return !$this->checkTableExists('photos_pages_relation');
|
||||
}
|
||||
|
||||
/** Delete photos_pages_relation table */
|
||||
public function upgrade_DeleteHtmlPagesTableRelation()
|
||||
{
|
||||
sqlQuery('DROP TABLE photos_pages_relation');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_DeleteHtmlPagesBlocksTable()
|
||||
{
|
||||
return !$this->checkTableExists('html_pages_blocks');
|
||||
}
|
||||
|
||||
/** Delete html_pages and html_pages_blocks tables */
|
||||
public function upgrade_DeleteHtmlPagesBlocksTable()
|
||||
{
|
||||
sqlQuery('DROP TABLE html_pages_blocks');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_DeleteHtmlPagesTable()
|
||||
{
|
||||
return !$this->checkTableExists('html_pages');
|
||||
}
|
||||
|
||||
/** Delete html_pages and photos_pages_relation tables */
|
||||
public function upgrade_DeleteHtmlPagesTable()
|
||||
{
|
||||
sqlQuery('DROP TABLE html_pages');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_MenuLinkSlash()
|
||||
{
|
||||
return $this->checkDataMigration(16);
|
||||
}
|
||||
|
||||
/** Ensure menu_links links begin with a slash */
|
||||
public function upgrade_MenuLinkSlash()
|
||||
{
|
||||
$this->addSlashPrefixToLink();
|
||||
|
||||
$this->commitDataMigration(16);
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_MenuLinkSlash2()
|
||||
{
|
||||
return $this->checkDataMigration(17);
|
||||
}
|
||||
|
||||
/** Ensure menu_links links begin with a slash */
|
||||
public function upgrade_MenuLinkSlash2()
|
||||
{
|
||||
$this->addSlashPrefixToLink();
|
||||
|
||||
$this->commitDataMigration(17);
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function addSlashPrefixToLink(): void
|
||||
{
|
||||
$qb = sqlQueryBuilder()->select('*')->from('menu_links')
|
||||
->where("link != '' AND link IS NOT NULL AND link NOT LIKE '/%'
|
||||
AND link NOT LIKE 'http://%' AND link NOT LIKE 'https://%'");
|
||||
foreach ($qb->execute() as $menuLink) {
|
||||
if (!preg_match('@^(/|[a-zA-Z]{3,6}://|mailto:|tel:)@', $menuLink['link'])) {
|
||||
sqlQueryBuilder()->update('menu_links')->directValues(['link' => '/'.$menuLink['link']])
|
||||
->where(Operator::equals(['id' => $menuLink['id']]))
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function check_sectionsTemplateColumn()
|
||||
{
|
||||
return $this->checkColumnExists('sections', 'template');
|
||||
}
|
||||
|
||||
/** Add template column to sections */
|
||||
public function upgrade_sectionsTemplateColumn()
|
||||
{
|
||||
sqlQuery("ALTER TABLE sections ADD COLUMN template VARCHAR(255) DEFAULT '' NOT NULL AFTER data");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
use FilipSedivy\EET\Utils\UUID;
|
||||
|
||||
class BlocksUpgrade extends \UpgradeNew
|
||||
{
|
||||
public function check_PageBlockPhotos()
|
||||
{
|
||||
return $this->checkTableExists('photos_page_blocks_relation') && $this->checkTableExists('photos_blocks_relation');
|
||||
}
|
||||
|
||||
/** Add selectable photos to each page block */
|
||||
public function upgrade_PageBlockPhotos()
|
||||
{
|
||||
sqlQuery('
|
||||
CREATE TABLE photos_blocks_relation
|
||||
(
|
||||
id_photo INT UNSIGNED,
|
||||
`id_block` int(11) UNSIGNED DEFAULT NULL,
|
||||
position int null,
|
||||
CONSTRAINT id_photo UNIQUE (id_photo, id_block),
|
||||
FOREIGN KEY (id_photo) REFERENCES photos (id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (id_block) REFERENCES blocks (id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
)');
|
||||
}
|
||||
|
||||
public function check_RenameBlocksPhotosTable()
|
||||
{
|
||||
// run migration only if photos_page_blocks_relation exists AND photos_blocks_relation doesn't
|
||||
return !$this->checkTableExists('photos_page_blocks_relation') && $this->checkTableExists('photos_blocks_relation');
|
||||
}
|
||||
|
||||
/** Rename photos_page_blocks_relation to photos_blocks_relation*/
|
||||
public function upgrade_RenameBlocksPhotosTable()
|
||||
{
|
||||
sqlQuery('RENAME TABLE photos_page_blocks_relation TO photos_blocks_relation;');
|
||||
sqlQuery('
|
||||
ALTER TABLE photos_blocks_relation
|
||||
DROP FOREIGN KEY photos_blocks_relation_ibfk_2,
|
||||
DROP KEY id_page_block,
|
||||
CHANGE `id_page_block` `id_block` int(11) UNSIGNED DEFAULT NULL,
|
||||
ADD FOREIGN KEY (id_block) REFERENCES blocks (id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE;');
|
||||
}
|
||||
|
||||
public function check_Name100Chars()
|
||||
{
|
||||
return $this->checkColumnType('blocks', 'name', 'VARCHAR(100)');
|
||||
}
|
||||
|
||||
/** Make block title 100 chars long */
|
||||
public function upgrade_Name100Chars()
|
||||
{
|
||||
sqlQuery('
|
||||
ALTER TABLE blocks
|
||||
CHANGE `name` `name` VARCHAR(100);');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_JsonContent()
|
||||
{
|
||||
return $this->checkColumnExists('blocks', 'json_content');
|
||||
}
|
||||
|
||||
/** Add json_content into blocks */
|
||||
public function upgrade_JsonContent()
|
||||
{
|
||||
sqlQuery('ALTER TABLE blocks ADD COLUMN json_content LONGTEXT NULL AFTER content');
|
||||
|
||||
$blocks_translations = false;
|
||||
if (findModule(\Modules::TRANSLATIONS) && $this->checkColumnExists('blocks_translations', 'json_content')) {
|
||||
sqlQuery('ALTER TABLE blocks_translations ADD COLUMN json_content LONGTEXT NULL AFTER content');
|
||||
$blocks_translations = true;
|
||||
}
|
||||
|
||||
foreach (sqlQuery('SELECT id, content FROM blocks') as $block) {
|
||||
$id_block = $block['id'];
|
||||
$uuid = UUID::v4();
|
||||
$blockObj = new \stdClass();
|
||||
$blockObj->type = 'legacy';
|
||||
$blockObj->id = $uuid;
|
||||
$settings = new \stdClass();
|
||||
$settings->html = $block['content'];
|
||||
$blockObj->settings = $settings;
|
||||
|
||||
$json = json_encode([$blockObj]);
|
||||
$this->updateSQL('blocks', ['json_content' => $json], ['id' => $block['id']]);
|
||||
|
||||
if ($blocks_translations) {
|
||||
foreach (sqlQuery('SELECT id, content FROM blocks_translations WHERE id_block='.$id_block) as $block_tr) {
|
||||
$blockObj = new \stdClass();
|
||||
$blockObj->type = 'legacy';
|
||||
$blockObj->id = $uuid;
|
||||
$settings = new \stdClass();
|
||||
$settings->html = $block_tr['content'];
|
||||
$blockObj->settings = $settings;
|
||||
|
||||
$json = json_encode([$blockObj]);
|
||||
$this->updateSQL('blocks_translations', ['json_content' => $json], ['id' => $block_tr['id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_PhotosBlocksNewRelation()
|
||||
{
|
||||
return $this->checkTableExists('photos_blocks_new_relation');
|
||||
}
|
||||
|
||||
/** add photos_blocks_new_relation */
|
||||
public function upgrade_PhotosBlocksNewRelation()
|
||||
{
|
||||
sqlQuery('
|
||||
CREATE TABLE photos_blocks_new_relation
|
||||
(
|
||||
id_photo INT UNSIGNED,
|
||||
`id_block` int(11) UNSIGNED DEFAULT NULL,
|
||||
position int null,
|
||||
CONSTRAINT id_photo UNIQUE (id_photo, id_block),
|
||||
FOREIGN KEY (id_photo) REFERENCES photos (id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (id_block) REFERENCES blocks (id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
)');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_BlocksDateUpdatedColumn(): bool
|
||||
{
|
||||
return $this->checkColumnExists('blocks', 'date_updated');
|
||||
}
|
||||
|
||||
/** Add `blocks.date_updated` column */
|
||||
public function upgrade_BlocksDateUpdatedColumn(): void
|
||||
{
|
||||
sqlQuery('ALTER TABLE blocks ADD COLUMN date_updated DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP AFTER position;');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
}
|
||||
199
bundles/KupShop/ContentBundle/Resources/upgrade/PageUpgrade.php
Normal file
199
bundles/KupShop/ContentBundle/Resources/upgrade/PageUpgrade.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
use Doctrine\DBAL\Exception\TableNotFoundException;
|
||||
use KupShop\ContentBundle\Exception\UnknownPageTypeException;
|
||||
use KupShop\ContentBundle\Util\PageLocator;
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
use Query\Operator;
|
||||
|
||||
class PageUpgrade extends \UpgradeNew
|
||||
{
|
||||
protected $priority = -200;
|
||||
|
||||
public function check_PagesTable()
|
||||
{
|
||||
return $this->checkTableExists('pages');
|
||||
}
|
||||
|
||||
/** Create 'pages' table */
|
||||
public function upgrade_PagesTable()
|
||||
{
|
||||
sqlQuery('CREATE TABLE pages (
|
||||
id INT(11) PRIMARY KEY AUTO_INCREMENT,
|
||||
id_block INT(11) UNSIGNED NULL,
|
||||
name VARCHAR(50) NULL,
|
||||
code VARCHAR(50) NOT NULL UNIQUE,
|
||||
type VARCHAR(20) NOT NULL,
|
||||
url VARCHAR(50) DEFAULT NULL,
|
||||
CONSTRAINT FK_id_block_pages
|
||||
FOREIGN KEY (id_block) REFERENCES blocks (id)
|
||||
ON UPDATE CASCADE ON DELETE SET NULL
|
||||
)');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_UpdatedColumn()
|
||||
{
|
||||
return $this->checkColumnExists('pages', 'updated');
|
||||
}
|
||||
|
||||
/** Add `updated` column to `pages` table */
|
||||
public function upgrade_UpdatedColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE `pages` ADD COLUMN `updated` TIMESTAMP NULL');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_TypeLength(): bool
|
||||
{
|
||||
return $this->checkColumnType('pages', 'type', 'VARCHAR(100)');
|
||||
}
|
||||
|
||||
/** Modify type length */
|
||||
public function upgrade_TypeLength(): void
|
||||
{
|
||||
sqlQuery('alter table pages modify type varchar(100) not null;');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_PagesDefaultContent()
|
||||
{
|
||||
if (isFunctionalTests()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$pages = sqlQueryBuilder()
|
||||
->select('*')->from('pages')
|
||||
->where('`updated` IS NULL')
|
||||
->execute();
|
||||
|
||||
if ($pages->rowCount()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (findModule(\Modules::TRANSLATIONS)) {
|
||||
try {
|
||||
$translations = sqlQueryBuilder()
|
||||
->select('p.*')->from('pages', 'p')
|
||||
->leftJoin('p', 'blocks', 'b', 'b.id_root=p.id_block')
|
||||
->leftJoin('b', 'blocks_translations', 't', 't.id_block = b.id')
|
||||
->where('t.updated IS NULL')
|
||||
->groupBy('p.id')
|
||||
->execute();
|
||||
|
||||
if ($translations->rowCount()) {
|
||||
return true;
|
||||
}
|
||||
} catch (TableNotFoundException $e) {
|
||||
// blocks_translations jeste nemusi existovat a nevim jestli by vadilo, kdybych dal tomuhle upgradu jinou prioritu, tak radsi takhle
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** update default Pages content */
|
||||
public function upgrade_PagesDefaultContent()
|
||||
{
|
||||
$pages = sqlFetchAll(sqlQueryBuilder()
|
||||
->select('*')->from('pages')->where('`updated` IS NULL')
|
||||
->execute(),
|
||||
'id');
|
||||
|
||||
if (findModule(\Modules::TRANSLATIONS)) {
|
||||
$translations = sqlFetchAll(sqlQueryBuilder()
|
||||
->select("p.*, NULLIF(CONCAT_WS('-', t.updated), '') concat_updated")->from('pages', 'p')
|
||||
->leftJoin('p', 'blocks', 'b', 'b.id_root=p.id_block')
|
||||
->leftJoin('b', 'blocks_translations', 't', 't.id_block = b.id')
|
||||
->having('concat_updated IS NULL')
|
||||
->groupBy('p.id')
|
||||
->execute(),
|
||||
'id');
|
||||
|
||||
if ($translations) {
|
||||
$pages = $pages + $translations;
|
||||
}
|
||||
}
|
||||
|
||||
if ($pages) {
|
||||
/** @var PageLocator $pageLocator */
|
||||
$pageLocator = ServiceContainer::getService(PageLocator::class);
|
||||
foreach ($pages as $row) {
|
||||
try {
|
||||
$page = $pageLocator->getPageService($row['type']);
|
||||
} catch (UnknownPageTypeException $e) {
|
||||
// pokud stranka existuje v DB, ale neexistuje k ni servisa, tak chybu ignoruju
|
||||
// a stranku preskakuju - pravdepodobne je to smazana systemova stranka, ktera zustala jen v DB
|
||||
continue;
|
||||
}
|
||||
if ($json_contents = $page->getDefaultJson()) {
|
||||
$blocks = sqlQueryBuilder()->select('*')
|
||||
->from('blocks')
|
||||
->where('id_root=:id_root')->setParameter('id_root', $row['id_block'])
|
||||
->orderBy('position')
|
||||
->execute()->fetchAll();
|
||||
|
||||
$json_contents = json_decode($json_contents, true);
|
||||
$areas = $json_contents['areas'] ?? [$json_contents];
|
||||
|
||||
$update = false;
|
||||
for ($i = 0; $i < max(count($blocks), count($areas)); $i++) {
|
||||
$area = $areas[$i] ?? null;
|
||||
$block = $blocks[$i] ?? null;
|
||||
|
||||
if (!$area && $block) {
|
||||
sqlQueryBuilder()->delete('blocks')->where(Operator::equals(['id' => $block['id']]))->execute();
|
||||
} elseif ($area && !$block) {
|
||||
sqlQueryBuilder()->insert('blocks')
|
||||
->directValues(['id_parent' => $row['id_block'],
|
||||
'id_root' => $row['id_block'],
|
||||
'content' => '',
|
||||
'json_content' => '', ])->execute();
|
||||
$blocks[$i]['id'] = sqlInsertId();
|
||||
$update = true;
|
||||
} elseif ($row['updated'] || (md5($block['json_content']) !== md5(json_encode($area)))) {
|
||||
$update = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($update) {
|
||||
$page->generateDefaultContent(array_map(function ($val) {
|
||||
return $val['id'];
|
||||
}, $blocks));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function check_PagesTypeVarcharLength30()
|
||||
{
|
||||
return !$this->checkColumnType('pages', 'type', 'varchar(20)')
|
||||
&& $this->checkColumnType('pages', 'type', 'varchar(30)');
|
||||
}
|
||||
|
||||
/** Increase pages type varchar length to 30 */
|
||||
public function upgrade_PagesTypeVarcharLength30()
|
||||
{
|
||||
sqlQuery('
|
||||
alter table pages
|
||||
modify type varchar(30) not null;
|
||||
');
|
||||
}
|
||||
|
||||
public function check_PagesDataColumn()
|
||||
{
|
||||
return $this->checkColumnExists('pages', 'data');
|
||||
}
|
||||
|
||||
/** Add data column to pages table */
|
||||
public function upgrade_PagesDataColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE pages ADD COLUMN data MEDIUMTEXT DEFAULT NULL');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
class ParametersUpgrade extends \UpgradeNew
|
||||
{
|
||||
public function check_trigger_parameters()
|
||||
{
|
||||
return $this->checkIfTriggerExists('trigger_parameters');
|
||||
}
|
||||
|
||||
/** Add trigger (incrementing position) to parameters */
|
||||
public function upgrade_trigger_parameters()
|
||||
{
|
||||
sqlQuery('CREATE TRIGGER trigger_parameters BEFORE INSERT ON parameters
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.position IS NULL THEN
|
||||
SET NEW.position = (SELECT COALESCE(MAX(position) + 1, 0) FROM parameters);
|
||||
END IF;
|
||||
END;');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_trigger_parametersList()
|
||||
{
|
||||
return $this->checkIfTriggerExists('trigger_parameters_list');
|
||||
}
|
||||
|
||||
/** Add trigger (incrementing position) to parameters_list */
|
||||
public function upgrade_trigger_parametersList()
|
||||
{
|
||||
sqlQuery('CREATE TRIGGER trigger_parameters_list BEFORE INSERT ON parameters_list
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.position IS NULL THEN
|
||||
SET NEW.position = (SELECT COALESCE(MAX(position) + 1, 0) FROM parameters_list);
|
||||
END IF;
|
||||
END;');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ValueMeaningColumn()
|
||||
{
|
||||
return $this->checkColumnExists('parameters', 'value_meaning');
|
||||
}
|
||||
|
||||
/** Add column value_meaning */
|
||||
public function upgrade_ValueMeaningColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE parameters ADD COLUMN value_meaning ENUM("text", "color", "image") DEFAULT "text" AFTER value_type');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ValueMeaningValues()
|
||||
{
|
||||
return $this->checkEnumOptions('parameters', 'value_meaning', ['text', 'color', 'image', 'progress']);
|
||||
}
|
||||
|
||||
/** Update Parameter.value_meaning enum options */
|
||||
public function upgrade_ValueMeaningValues()
|
||||
{
|
||||
$this->updateEnumOptions('parameters', 'value_meaning', ['text', 'color', 'image', 'progress']);
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ParametersFigureColumn()
|
||||
{
|
||||
return $this->checkColumnExists('parameters', 'figure');
|
||||
}
|
||||
|
||||
/** Add 'figure' column into parameters table */
|
||||
public function upgrade_ParametersFigureColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE parameters ADD COLUMN figure ENUM("Y", "N") DEFAULT "Y"');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ParametersCatalogFigureColumn()
|
||||
{
|
||||
return findModule(\Modules::COMPONENTS) && $this->checkColumnExists('parameters', 'catalog_figure');
|
||||
}
|
||||
|
||||
/** Add 'catalog_figure' column into parameters table */
|
||||
public function upgrade_ParametersCatalogFigureColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE parameters ADD COLUMN catalog_figure ENUM("Y", "N") DEFAULT "N"');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_switch_parameters_list_description_value()
|
||||
{
|
||||
return $this->checkDataMigration(14);
|
||||
}
|
||||
|
||||
/** Switch value and description for meaning photo and type list */
|
||||
public function upgrade_switch_parameters_list_description_value()
|
||||
{
|
||||
sqlQuery('update parameters_list set description=value
|
||||
where description="" and id_parameter in
|
||||
(select id from parameters where value_meaning="image" and value_type = "list");');
|
||||
|
||||
sqlQuery('update parameters_list set value=description
|
||||
where value="" and id_parameter in
|
||||
(select id from parameters where value_meaning="image" and value_type = "list");');
|
||||
|
||||
sqlQuery('update parameters_list set description=value, value=@temp
|
||||
where (@temp:=description) is not null
|
||||
and id_parameter in
|
||||
(select id from parameters where value_meaning="image" and value_type = "list");');
|
||||
|
||||
$this->commitDataMigration(14);
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ParametersSectionsRequiredColumn(): bool
|
||||
{
|
||||
return $this->checkColumnExists('parameters_sections', 'required');
|
||||
}
|
||||
|
||||
/** Add parameters_sections.enabled and parameters_sections.required columns */
|
||||
public function upgrade_ParametersSectionsRequiredColumn(): void
|
||||
{
|
||||
sqlQuery('ALTER TABLE parameters_sections ADD COLUMN filter ENUM("Y", "N") DEFAULT "Y" AFTER id_section');
|
||||
sqlQuery('ALTER TABLE parameters_sections ADD COLUMN required ENUM("Y", "N") DEFAULT "Y" AFTER filter');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ParametersProductsAddIndex_id_product(): bool
|
||||
{
|
||||
return $this->checkIndexNameExists('parameters_products', 'id_product');
|
||||
}
|
||||
|
||||
/** Add parameters_products index for id_product when missing */
|
||||
public function upgrade_ParametersProductsAddIndex_id_product(): void
|
||||
{
|
||||
sqlQuery('create index id_product on parameters_products (id_product);');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ParametersProductsRemoveCompoundIndex_id_product_id_parameter(): bool
|
||||
{
|
||||
return !$this->checkIndexNameExists('parameters_products', 'parameters_products_id_product_id_parameter_index');
|
||||
}
|
||||
|
||||
/** Remove parameters_products old compound index (id_product, id_parameter), replace it with (id_parameter, id_product) */
|
||||
public function upgrade_ParametersProductsRemoveCompoundIndex_id_product_id_parameter(): void
|
||||
{
|
||||
sqlQuery('drop index parameters_products_id_product_id_parameter_index on parameters_products;');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ParametersProductsCompoundIndex_id_parameter_id_product(): bool
|
||||
{
|
||||
return $this->checkIndexNameExists('parameters_products', 'id_parameter_id_product_index');
|
||||
}
|
||||
|
||||
/** Add parameters_products compound index (id_parameter, id_product) */
|
||||
public function upgrade_ParametersProductsCompoundIndex_id_parameter_id_product(): void
|
||||
{
|
||||
sqlQuery('create index id_parameter_id_product_index on parameters_products (id_parameter, id_product);');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ParametersProductsCompoundIndex_value_list_id_product(): bool
|
||||
{
|
||||
return $this->checkIndexNameExists('parameters_products', 'value_list_id_product_index');
|
||||
}
|
||||
|
||||
/** Add parameters_products compound index (id_parameter, id_product) */
|
||||
public function upgrade_ParametersProductsCompoundIndex_value_list_id_product(): void
|
||||
{
|
||||
sqlQuery('create index value_list_id_product_index on parameters_products (value_list, id_product);');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ParametersAdminNameColumnDelete(): bool
|
||||
{
|
||||
return !$this->checkColumnExists('parameters', 'name_admin');
|
||||
}
|
||||
|
||||
public function upgrade_ParametersAdminNameColumnDelete(): void
|
||||
{
|
||||
sqlQuery('ALTER TABLE parameters DROP COLUMN name_admin;');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ParametersNameFrontendColumn(): bool
|
||||
{
|
||||
return $this->checkColumnExists('parameters', 'name_frontend');
|
||||
}
|
||||
|
||||
public function upgrade_ParametersNameFrontendColumn(): void
|
||||
{
|
||||
sqlQuery('ALTER TABLE parameters ADD COLUMN name_frontend VARCHAR(255) AFTER name;');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ParametersNameFrontendTranslationColumn(): bool
|
||||
{
|
||||
return findModule(\Modules::TRANSLATIONS) && $this->checkColumnExists('parameters_translations', 'name_frontend');
|
||||
}
|
||||
|
||||
public function upgrade_ParametersNameFrontendTranslationColumn(): void
|
||||
{
|
||||
sqlQuery('ALTER TABLE parameters_translations ADD COLUMN name_frontend VARCHAR(255) AFTER name;');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
class PhotosRelationUpgrade extends \UpgradeNew
|
||||
{
|
||||
public function __construct($verbose = self::VERBOSE_NO, $useLocalUpgrades = self::LOCAL_UPGRADES_YES)
|
||||
{
|
||||
parent::__construct($verbose, $useLocalUpgrades);
|
||||
}
|
||||
|
||||
public function check_trigger_photos_products_relation()
|
||||
{
|
||||
return $this->checkIfTriggerExists('trigger_photos_products_relation');
|
||||
}
|
||||
|
||||
/** Add trigger (incrementing position) to photos_products_relation */
|
||||
public function upgrade_trigger_photos_products_relation()
|
||||
{
|
||||
sqlQuery('CREATE TRIGGER trigger_photos_products_relation BEFORE INSERT ON photos_products_relation
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.position IS NULL THEN
|
||||
SET NEW.position = (SELECT COALESCE(MAX(photos_products_relation.position) + 1, 0) FROM photos_products_relation WHERE id_product = NEW.id_product);
|
||||
END IF;
|
||||
END;');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_trigger_photos_sections_relation()
|
||||
{
|
||||
return $this->checkIfTriggerExists('trigger_photos_sections_relation');
|
||||
}
|
||||
|
||||
/** Add trigger (incrementing position) to photos_sections_relation */
|
||||
public function upgrade_trigger_photos_sections_relation()
|
||||
{
|
||||
sqlQuery('CREATE TRIGGER trigger_photos_sections_relation BEFORE INSERT ON photos_sections_relation
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.position IS NULL THEN
|
||||
SET NEW.position = (SELECT COALESCE(MAX(photos_sections_relation.position) + 1, 0) FROM photos_sections_relation WHERE id_section= NEW.id_section);
|
||||
END IF;
|
||||
END;');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_trigger_photos_producers_relation()
|
||||
{
|
||||
return $this->checkIfTriggerExists('trigger_photos_producers_relation');
|
||||
}
|
||||
|
||||
/** Add trigger (incrementing position) to photos_producers_relation */
|
||||
public function upgrade_trigger_photos_producers_relation()
|
||||
{
|
||||
sqlQuery('CREATE TRIGGER trigger_photos_producers_relation BEFORE INSERT ON photos_producers_relation
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.position IS NULL THEN
|
||||
SET NEW.position = (SELECT COALESCE(MAX(photos_producers_relation.position) + 1,0) FROM photos_producers_relation WHERE id_producer = NEW.id_producer);
|
||||
END IF;
|
||||
END;');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_trigger_photos_menu_relation()
|
||||
{
|
||||
return $this->checkIfTriggerExists('trigger_photos_menu_relation');
|
||||
}
|
||||
|
||||
/** Add trigger (incrementing position) to photos_menu_relation */
|
||||
public function upgrade_trigger_photos_menu_relation()
|
||||
{
|
||||
sqlQuery('CREATE TRIGGER trigger_photos_menu_relation BEFORE INSERT ON photos_menu_relation
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.position IS NULL THEN
|
||||
SET NEW.position = (SELECT COALESCE(MAX(photos_menu_relation.position) + 1,0) FROM photos_menu_relation WHERE id_menu = NEW.id_menu);
|
||||
END IF;
|
||||
END;');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_trigger_photos_articles_relation()
|
||||
{
|
||||
return $this->checkIfTriggerExists('trigger_photos_articles_relation');
|
||||
}
|
||||
|
||||
/** Add trigger (incrementing position) to photos_articles_relation */
|
||||
public function upgrade_trigger_photos_articles_relation()
|
||||
{
|
||||
sqlQuery('CREATE TRIGGER trigger_photos_articles_relation BEFORE INSERT ON photos_articles_relation
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.position IS NULL THEN
|
||||
SET NEW.position = (SELECT COALESCE(MAX(photos_articles_relation.position) + 1,0) FROM photos_articles_relation WHERE id_art = NEW.id_art);
|
||||
END IF;
|
||||
END;');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_trigger_photos_blocks_relation()
|
||||
{
|
||||
return $this->checkIfTriggerExists('trigger_photos_blocks_relation');
|
||||
}
|
||||
|
||||
public function update_trigger_photos_blocks_relation()
|
||||
{
|
||||
sqlQuery('CREATE TRIGGER trigger_photos_blocks_relation BEFORE INSERT ON photos_blocks_relation
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.position IS NULL THEN
|
||||
SET NEW.position = (SELECT COALESCE(MAX(photos_blocks_relation.position) + 1,0) FROM photos_blocks_relation WHERE id_block = NEW.id_block);
|
||||
END IF;
|
||||
END;');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_compound_index_ppr_show_in_lead_id_product()
|
||||
{
|
||||
return $this->checkIndexNameExists('photos_products_relation', 'photos_products_relation_show_in_lead_id_product_index');
|
||||
}
|
||||
|
||||
/** Upgrade index (show_in_lead) to (show_in_lead, id_product) in photos_articles_relation table */
|
||||
public function upgrade_compound_index_ppr_show_in_lead_id_product()
|
||||
{
|
||||
sqlQuery('CREATE INDEX photos_products_relation_show_in_lead_id_product_index
|
||||
ON photos_products_relation (show_in_lead, id_product);');
|
||||
|
||||
if (!$this->checkIndexNameExists('photos_products_relation', 'show_in_lead')) {
|
||||
sqlQuery('DROP INDEX show_in_lead ON photos_products_relation;');
|
||||
}
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
class PhotosUpgrade extends \UpgradeNew
|
||||
{
|
||||
public function check_PhotosFilenameColumn()
|
||||
{
|
||||
return $this->checkColumnExists('photos', 'filename');
|
||||
}
|
||||
|
||||
/** Add filename column into photos table */
|
||||
public function upgrade_PhotosFilenameColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE photos ADD COLUMN filename VARCHAR(100) DEFAULT NULL AFTER id');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_PhotosDateUpdate()
|
||||
{
|
||||
return $this->checkColumnExists('photos', 'date_update');
|
||||
}
|
||||
|
||||
/** Add date_update column into photos table */
|
||||
public function upgrade_PhotosDateUpdate()
|
||||
{
|
||||
sqlQuery('ALTER TABLE photos ADD date_update DATETIME DEFAULT NOW() NULL;');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_ResponsivePhotoFields(): bool
|
||||
{
|
||||
return $this->checkColumnExists('photos', 'image_tablet');
|
||||
}
|
||||
|
||||
/** Add image_tablet and image_mobile fields to photos table */
|
||||
public function upgrade_ResponsivePhotoFields(): void
|
||||
{
|
||||
sqlQuery('ALTER TABLE photos ADD COLUMN image_tablet VARCHAR(100) DEFAULT NULL AFTER image_2;');
|
||||
sqlQuery('ALTER TABLE photos ADD COLUMN image_mobile VARCHAR(100) DEFAULT NULL AFTER image_tablet;');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_CustomDataField(): bool
|
||||
{
|
||||
return $this->checkColumnExists('photos', 'data');
|
||||
}
|
||||
|
||||
/** Add custom_data field to photos table **/
|
||||
public function upgrade_CustomDataField(): void
|
||||
{
|
||||
sqlQuery('alter table photos add data longtext null;');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
use FilipSedivy\EET\Utils\UUID;
|
||||
use KupShop\ContentBundle\Util\Block;
|
||||
use KupShop\KupShopBundle\Query\JsonOperator;
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
use Query\Operator;
|
||||
|
||||
class ProducersUpgrade extends \UpgradeNew
|
||||
{
|
||||
protected function isAllowed()
|
||||
{
|
||||
return findModule(\Modules::PRODUCERS);
|
||||
}
|
||||
|
||||
public function check_dataColumn(): bool
|
||||
{
|
||||
return $this->checkColumnExists('producers', 'data');
|
||||
}
|
||||
|
||||
/** producers: add data column */
|
||||
public function upgrade_dataColumn(): void
|
||||
{
|
||||
sqlQuery('ALTER TABLE producers ADD COLUMN data MEDIUMTEXT DEFAULT NULL');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_trigger_producers(): bool
|
||||
{
|
||||
return !$this->checkIfTriggerExists('trigger_producers');
|
||||
}
|
||||
|
||||
/** Drops trigger */
|
||||
public function upgrade_trigger_producers(): void
|
||||
{
|
||||
sqlQuery('DROP TRIGGER IF EXISTS trigger_producers');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_topProducers(): bool
|
||||
{
|
||||
return $this->checkColumnExists('producers', 'top');
|
||||
}
|
||||
|
||||
/** Add top to producers and set top = Y for all existing records */
|
||||
public function upgrade_topProducers(): void
|
||||
{
|
||||
sqlQuery('
|
||||
ALTER TABLE producers
|
||||
ADD COLUMN `top` enum ("Y","N") DEFAULT "N" AFTER name;
|
||||
');
|
||||
|
||||
sqlQueryBuilder()->update('producers')->directValues(['top' => 'Y'])->execute();
|
||||
}
|
||||
|
||||
public function check_blocksForProducers(): bool
|
||||
{
|
||||
return $this->checkColumnExists('producers', 'id_block');
|
||||
}
|
||||
|
||||
/** Add id_block to producers and move content from producers.descr to blocks */
|
||||
public function upgrade_blocksForProducers(): void
|
||||
{
|
||||
sqlQuery('
|
||||
ALTER TABLE producers
|
||||
ADD COLUMN `id_block` int(11) UNSIGNED DEFAULT NULL AFTER id,
|
||||
ADD CONSTRAINT `fk_producers_blocks` FOREIGN KEY (id_block) REFERENCES blocks(id)
|
||||
ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
');
|
||||
|
||||
$translations = findModule(\Modules::TRANSLATIONS);
|
||||
|
||||
$producers = sqlQueryBuilder()->select('*')->from('producers')->execute();
|
||||
foreach ($producers as $producer) {
|
||||
if (!($producer['descr'] ?? null)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// create root block and assign it to producers.id_block
|
||||
$this->insertSQL('blocks', []);
|
||||
$rootBlockID = sqlInsertId();
|
||||
$this->updateSQL('producers', ['id_block' => $rootBlockID], ['id' => $producer['id']]);
|
||||
|
||||
$uuid = UUID::v4();
|
||||
$blockObj = new \stdClass();
|
||||
$blockObj->type = 'legacy';
|
||||
$blockObj->id = $uuid;
|
||||
$settings = new \stdClass();
|
||||
$settings->html = $producer['descr'];
|
||||
$blockObj->settings = $settings;
|
||||
|
||||
$json = json_encode([$blockObj]);
|
||||
|
||||
$this->insertSQL('blocks', [
|
||||
'id_root' => $rootBlockID,
|
||||
'id_parent' => $rootBlockID,
|
||||
'position' => 1,
|
||||
'name' => $producer['name'],
|
||||
'content' => $producer['descr'],
|
||||
'json_content' => $json,
|
||||
]);
|
||||
$id_block = sqlInsertId();
|
||||
|
||||
if ($translations) {
|
||||
$producer_translations = sqlQuery('SELECT name, descr, id_language, id_admin FROM producers_translations WHERE id_producer='.$producer['id']);
|
||||
foreach ($producer_translations as $producer_tr) {
|
||||
$blockObj = new \stdClass();
|
||||
$blockObj->type = 'legacy';
|
||||
$blockObj->id = $uuid;
|
||||
$settings = new \stdClass();
|
||||
$settings->html = $producer_tr['descr'];
|
||||
$blockObj->settings = $settings;
|
||||
|
||||
$json = json_encode([$blockObj]);
|
||||
|
||||
$this->insertSQL('blocks_translations', [
|
||||
'id_block' => $id_block,
|
||||
'id_language' => $producer_tr['id_language'],
|
||||
'id_admin' => $producer_tr['id_admin'],
|
||||
'name' => $producer_tr['name'],
|
||||
'content' => $producer_tr['descr'],
|
||||
'json_content' => $json,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sqlQuery('ALTER TABLE producers DROP COLUMN `descr`;');
|
||||
|
||||
if ($translations) {
|
||||
// sqlQuery('ALTER TABLE producers_translations DROP COLUMN `descr`;');
|
||||
}
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_producersOrderByEnum()
|
||||
{
|
||||
$categoryView = \KupShop\KupShopBundle\Util\Compat\ServiceContainer::getService(\KupShop\CatalogBundle\View\CategoryView::class);
|
||||
|
||||
$values = '';
|
||||
$this->checkEnumExists('producers', 'orderby', '', $values);
|
||||
|
||||
foreach ($categoryView->getSortOptions() as $value => $_) {
|
||||
if (strstr($values, "'{$value}'") === false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Update producers.orderby enum */
|
||||
public function upgrade_producersOrderByEnum()
|
||||
{
|
||||
$categoryView = \KupShop\KupShopBundle\Util\Compat\ServiceContainer::getService(\KupShop\CatalogBundle\View\CategoryView::class);
|
||||
$enums = implode(',', array_map(function ($x) { return '\''.$x.'\''; }, array_keys($categoryView->getSortOptions())));
|
||||
|
||||
sqlQuery('ALTER TABLE producers CHANGE orderby orderby ENUM('.$enums.') DEFAULT "title" ');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_producersDateUpdated()
|
||||
{
|
||||
return $this->checkColumnExists('producers', 'date_updated');
|
||||
}
|
||||
|
||||
/** Add date_updated to producers*/
|
||||
public function upgrade_producersDateUpdated()
|
||||
{
|
||||
sqlQuery('ALTER TABLE producers ADD COLUMN date_updated DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_blocksForProducersSections(): bool
|
||||
{
|
||||
return $this->checkColumnExists('section_producer', 'id_block');
|
||||
}
|
||||
|
||||
/** Add id_block to section_producer and move content from descr to blocks */
|
||||
public function upgrade_blocksForProducersSections(): void
|
||||
{
|
||||
sqlQuery('
|
||||
ALTER TABLE section_producer
|
||||
ADD COLUMN `id_block` int(11) UNSIGNED DEFAULT NULL AFTER id,
|
||||
ADD CONSTRAINT `fk_section_producer_blocks` FOREIGN KEY (id_block) REFERENCES blocks(id)
|
||||
ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
');
|
||||
|
||||
$translations = findModule(\Modules::TRANSLATIONS);
|
||||
$block = ServiceContainer::getService(Block::class);
|
||||
|
||||
$section_producer = sqlQueryBuilder()->select('*')->from('section_producer')->execute();
|
||||
foreach ($section_producer as $producer) {
|
||||
if (!($producer['text'] ?? null)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// create root block and assign it to section_producer.id_block
|
||||
$id_block = $block->insertFirstBlock('section_producer', $producer['id'], $producer['text']);
|
||||
$uuid = sqlQueryBuilder()
|
||||
->select(JsonOperator::extract('json_content', '$[0].id'))
|
||||
->from('blocks')
|
||||
->andWhere(Operator::equals(['id' => $id_block]))
|
||||
->execute()->fetchOne();
|
||||
|
||||
if ($translations) {
|
||||
$producer_translations = sqlQuery('SELECT text, id_language, id_admin FROM section_producer_translations WHERE id_section_producer='.$producer['id']);
|
||||
foreach ($producer_translations as $producer_tr) {
|
||||
$blockObj = new \stdClass();
|
||||
$blockObj->type = 'legacy';
|
||||
$blockObj->id = $uuid;
|
||||
$settings = new \stdClass();
|
||||
$settings->html = $producer_tr['text'];
|
||||
$blockObj->settings = $settings;
|
||||
|
||||
$json = json_encode([$blockObj]);
|
||||
|
||||
$this->insertSQL('blocks_translations', [
|
||||
'id_block' => $id_block,
|
||||
'id_language' => $producer_tr['id_language'],
|
||||
'id_admin' => $producer_tr['id_admin'],
|
||||
'name' => '',
|
||||
'content' => $producer_tr['text'],
|
||||
'json_content' => $json,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_producersGPSRData()
|
||||
{
|
||||
return $this->checkColumnExists('producers', 'company_name');
|
||||
}
|
||||
|
||||
/** Add data for GPSR to producers*/
|
||||
public function upgrade_producersGPSRData()
|
||||
{
|
||||
sqlQuery('
|
||||
ALTER TABLE producers
|
||||
ADD COLUMN company_name VARCHAR(250) DEFAULT null,
|
||||
ADD COLUMN company_street VARCHAR(100) DEFAULT null,
|
||||
ADD COLUMN company_city VARCHAR(50) DEFAULT null ,
|
||||
ADD COLUMN company_zip VARCHAR(50) DEFAULT null,
|
||||
ADD COLUMN company_country VARCHAR(50) DEFAULT null,
|
||||
ADD COLUMN company_email VARCHAR(100) DEFAULT null,
|
||||
ADD COLUMN company_web VARCHAR(100) DEFAULT null
|
||||
AFTER orderdir
|
||||
');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_importersGPSRData()
|
||||
{
|
||||
return $this->checkColumnExists('producers', 'import_company_name');
|
||||
}
|
||||
|
||||
/** Add data for GPSR importers to producers*/
|
||||
public function upgrade_importersGPSRData()
|
||||
{
|
||||
sqlQuery('
|
||||
ALTER TABLE producers
|
||||
ADD COLUMN import_company_name VARCHAR(250) DEFAULT null,
|
||||
ADD COLUMN import_company_street VARCHAR(100) DEFAULT null,
|
||||
ADD COLUMN import_company_city VARCHAR(50) DEFAULT null ,
|
||||
ADD COLUMN import_company_zip VARCHAR(50) DEFAULT null,
|
||||
ADD COLUMN import_company_country VARCHAR(50) DEFAULT null,
|
||||
ADD COLUMN import_company_email VARCHAR(100) DEFAULT null,
|
||||
ADD COLUMN import_company_web VARCHAR(100) DEFAULT null
|
||||
AFTER company_web
|
||||
');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
use KupShop\KupShopBundle\Context\LanguageContext;
|
||||
use KupShop\KupShopBundle\Email\UserRegisterEmail;
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
use KupShop\KupShopBundle\Util\System\PathFinder;
|
||||
|
||||
class RegistrationEmailUpgrade extends \UpgradeNew
|
||||
{
|
||||
protected $priority = 200;
|
||||
|
||||
public function check_RegistrationEmailUpgrade()
|
||||
{
|
||||
return !$this->selectSQL('emails', ['type' => UserRegisterEmail::getType()], ['id'])->fetchColumn();
|
||||
}
|
||||
|
||||
/** Move Registration email to database */
|
||||
public function upgrade_RegistrationEmailUpgrade()
|
||||
{
|
||||
$languageContext = ServiceContainer::getService(LanguageContext::class);
|
||||
|
||||
// nejdriv default language, abych ho tam mel ulozeny jako prvni
|
||||
$content = $this->getEmailContent($languageContext->getDefaultId());
|
||||
$this->insertSQL(
|
||||
'emails',
|
||||
[
|
||||
'type' => UserRegisterEmail::getType(),
|
||||
'body' => $content,
|
||||
'subject' => translate('RegConfirm', 'login'),
|
||||
'name' => '',
|
||||
]
|
||||
);
|
||||
$objectID = sqlInsertId();
|
||||
|
||||
// pak ostatni languages
|
||||
if (findModule(\Modules::TRANSLATIONS)) {
|
||||
foreach ($languageContext->getSupported() as $language) {
|
||||
$content = $this->getEmailContent($language->getId());
|
||||
|
||||
if ($languageContext->translationActive()) {
|
||||
$this->insertSQL('emails_translations', [
|
||||
'id_email' => $objectID,
|
||||
'id_language' => $language->getId(),
|
||||
'id_admin' => null,
|
||||
'subject' => translate('RegConfirm', 'login'),
|
||||
'body' => $content,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
private function getEmailContent($language)
|
||||
{
|
||||
global $cfg;
|
||||
|
||||
$languageContext = ServiceContainer::getService(LanguageContext::class);
|
||||
$languageContext->activate($language);
|
||||
|
||||
// HACK musim zalohovat a vracet config, protoze smarty mi smaze Connection host, password, user, ktery potom
|
||||
// chybi testum
|
||||
$cfgBackup = clone $cfg;
|
||||
$smarty = createSmarty();
|
||||
$cfg = $cfgBackup;
|
||||
|
||||
$smarty->assign(['email' => '{EMAIL_UZIVATELE}']);
|
||||
|
||||
$content = $smarty->fetch(PathFinder::getService()->getAdminDir().'/templates/email/email_user_register.tpl');
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
use KupShop\ContentBundle\Util\SliderUtil;
|
||||
use KupShop\I18nBundle\Translations\PhotosTranslation;
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
use KupShop\KupShopBundle\Util\System\PathFinder;
|
||||
use Query\Operator;
|
||||
|
||||
class SlidersUpgrade extends \UpgradeNew
|
||||
{
|
||||
protected $priority = 1000;
|
||||
|
||||
protected function isAllowed()
|
||||
{
|
||||
return findModule(\Modules::SLIDERS);
|
||||
}
|
||||
|
||||
public function check_dataColumn()
|
||||
{
|
||||
return $this->checkColumnExists('sliders', 'data');
|
||||
}
|
||||
|
||||
/** sliders: add data column */
|
||||
public function upgrade_dataColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE sliders ADD COLUMN data MEDIUMTEXT DEFAULT NULL');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_SlidersImagesDataColumn()
|
||||
{
|
||||
return $this->checkColumnExists('sliders_images', 'data');
|
||||
}
|
||||
|
||||
/** sliders_images: add data column */
|
||||
public function upgrade_SlidersImagesDataColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE sliders_images ADD COLUMN data MEDIUMTEXT DEFAULT NULL');
|
||||
|
||||
foreach (sqlQuery('SELECT * FROM sliders') as $slider) {
|
||||
$sliderData = [];
|
||||
$data = json_decode($slider['data'], true) ?: [];
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_numeric($key)) {
|
||||
$slideData = json_encode($value);
|
||||
sqlQuery('UPDATE sliders_images SET data = :data WHERE id = :id_slide AND id_slider = :id_slider', [
|
||||
'data' => $slideData,
|
||||
'id_slide' => $key,
|
||||
'id_slider' => $slider['id'],
|
||||
]);
|
||||
} else {
|
||||
$sliderData[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
sqlQuery('UPDATE sliders SET data = :data WHERE id = :id', [
|
||||
'id' => $slider['id'],
|
||||
'data' => empty($sliderData) ? null : json_encode($sliderData),
|
||||
]);
|
||||
}
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_trigger_sliders_images()
|
||||
{
|
||||
return !$this->checkIfTriggerExists('trigger_sliders_images');
|
||||
}
|
||||
|
||||
/** Delete old trigger trigger_sliders_images */
|
||||
public function upgrade_trigger_sliders_images()
|
||||
{
|
||||
sqlQuery('DROP TRIGGER trigger_sliders_images');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_trigger_sliders_images3()
|
||||
{
|
||||
return $this->checkIfTriggerExists('trigger_sliders_images3', 'sliders_images');
|
||||
}
|
||||
|
||||
/** Add trigger (incrementing position) to sliders_images 3 */
|
||||
public function upgrade_trigger_sliders_images3()
|
||||
{
|
||||
sqlQuery('ALTER TABLE sliders_images ALTER COLUMN position DROP DEFAULT');
|
||||
sqlQuery('DROP TRIGGER IF EXISTS trigger_sliders_images2');
|
||||
sqlQuery('CREATE TRIGGER trigger_sliders_images3 BEFORE INSERT ON sliders_images
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.position IS NULL THEN
|
||||
SET NEW.position = ((SELECT IFNULL(MAX(position), 0) FROM sliders_images WHERE id_slider = NEW.id_slider) + 1);
|
||||
END IF;
|
||||
END;');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_labelColumn()
|
||||
{
|
||||
return $this->checkColumnExists('sliders', 'label');
|
||||
}
|
||||
|
||||
/** sliders: add label column */
|
||||
public function upgrade_labelColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE sliders ADD COLUMN label VARCHAR(50) DEFAULT NULL UNIQUE');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_SizeColumns(): bool
|
||||
{
|
||||
return $this->checkColumnExists('sliders', 'size_tablet');
|
||||
}
|
||||
|
||||
/** Add size_* columns into sliders table */
|
||||
public function upgrade_SizeColumns(): void
|
||||
{
|
||||
sqlQuery('ALTER TABLE sliders ADD COLUMN size_tablet VARCHAR(100) DEFAULT NULL AFTER size');
|
||||
sqlQuery('ALTER TABLE sliders ADD COLUMN size_mobile VARCHAR(100) DEFAULT NULL AFTER size_tablet');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_PhotoIdColumn(): bool
|
||||
{
|
||||
return $this->checkColumnExists('sliders_images', 'id_photo');
|
||||
}
|
||||
|
||||
/** Migrate sliders_images to photos */
|
||||
public function upgrade_PhotoIdColumn(): void
|
||||
{
|
||||
sqlQuery('ALTER TABLE sliders_images ADD COLUMN id_photo INT(11) UNSIGNED AFTER image');
|
||||
sqlQuery('ALTER TABLE sliders_images ADD FOREIGN KEY (id_photo)
|
||||
REFERENCES photos(id) ON UPDATE CASCADE ON DELETE CASCADE;');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_OldImageColumn(): bool
|
||||
{
|
||||
return !$this->checkColumnExists('sliders_images', 'image');
|
||||
}
|
||||
|
||||
/** Remove old image column */
|
||||
public function upgrade_OldImageColumn(): void
|
||||
{
|
||||
$pathFinder = PathFinder::getService();
|
||||
|
||||
$qb = sqlQueryBuilder()
|
||||
->select('id, image')
|
||||
->from('sliders_images')
|
||||
->where('id_photo IS NULL');
|
||||
|
||||
// convert slider images to photos table
|
||||
foreach ($qb->execute() as $item) {
|
||||
$path = $pathFinder->dataPath('photos/sliders/'.$item['image']);
|
||||
|
||||
$photo = [
|
||||
'name' => $item['image'],
|
||||
'tmp_name' => $path,
|
||||
];
|
||||
|
||||
$img = \Photos::get();
|
||||
// use copy to keep original files in sliders dir
|
||||
if (file_exists($path)) {
|
||||
if ($img->uploadImage($photo, false, true)) {
|
||||
$img->insertImageIntoDB();
|
||||
}
|
||||
}
|
||||
|
||||
sqlQueryBuilder()
|
||||
->update('sliders_images')
|
||||
->directValues(
|
||||
[
|
||||
'id_photo' => $img->getID(),
|
||||
]
|
||||
)
|
||||
->where(Operator::equals(['id' => $item['id']]))
|
||||
->execute();
|
||||
}
|
||||
|
||||
sqlQuery('ALTER TABLE sliders_images DROP COLUMN image');
|
||||
|
||||
// migrovat sliders_images_translations do photos_translations
|
||||
if (findModule(\Modules::TRANSLATIONS)) {
|
||||
$qb = sqlQueryBuilder()
|
||||
->select('si.id, si.id_photo, sit.id_language, sit.image')
|
||||
->from('sliders_images', 'si')
|
||||
->join('si', 'sliders_images_translations', 'sit', 'si.id = sit.id_sliders_image');
|
||||
|
||||
$photosTranslation = ServiceContainer::getService(PhotosTranslation::class);
|
||||
foreach ($qb->execute() as $item) {
|
||||
if (empty($item['image'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = $pathFinder->dataPath('photos/sliders/'.$item['image']);
|
||||
if (!file_exists($path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$photo = [
|
||||
'name' => $item['image'],
|
||||
'tmp_name' => $path,
|
||||
];
|
||||
|
||||
$img = \Photos::get((int) $item['id_photo']);
|
||||
if (file_exists($path)) {
|
||||
$img->uploadImage($photo, false, true, $item['id_language']);
|
||||
}
|
||||
|
||||
$photosTranslation->saveSingleObject($item['id_language'], $item['id_photo'], ['image_2' => $img->image['filename']]);
|
||||
}
|
||||
|
||||
sqlQuery('ALTER TABLE sliders_images_translations DROP COLUMN image');
|
||||
}
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_FigureColumn()
|
||||
{
|
||||
return $this->checkColumnExists('sliders_images', 'figure');
|
||||
}
|
||||
|
||||
/** Add `sliders_images.figure` column */
|
||||
public function upgrade_FigureColumn()
|
||||
{
|
||||
sqlQuery("ALTER TABLE sliders_images ADD figure ENUM('Y', 'N') NULL DEFAULT 'Y'");
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_multipleSlidersInSection(): bool
|
||||
{
|
||||
return $this->checkTableExists('sliders_in_sections');
|
||||
}
|
||||
|
||||
/** Create table sliders_in_sections */
|
||||
public function upgrade_multipleSlidersInSection(): void
|
||||
{
|
||||
$positions = array_keys(SliderUtil::getPositions());
|
||||
$positions = "'".implode("', '", $positions)."'";
|
||||
|
||||
sqlQuery("CREATE TABLE sliders_in_sections (
|
||||
id_section INT NOT NULL,
|
||||
position ENUM({$positions}) NOT NULL DEFAULT 'main',
|
||||
id_slider INT NOT NULL,
|
||||
|
||||
PRIMARY KEY (id_section, position),
|
||||
INDEX (id_slider),
|
||||
FOREIGN KEY `slider_to_section_fk` (id_slider) REFERENCES sliders(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY `section_to_slider_fk` (id_section) REFERENCES sections(id) ON DELETE CASCADE
|
||||
)");
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_migrateSectionSliders(): bool
|
||||
{
|
||||
return !$this->checkColumnExists('sections', 'id_slider');
|
||||
}
|
||||
|
||||
/** Migrate id_slider column (and additional slider) into sliders_in_sections table */
|
||||
public function upgrade_migrateSectionSliders(): void
|
||||
{
|
||||
sqlQuery("
|
||||
INSERT IGNORE INTO sliders_in_sections (id_slider, id_section, position)
|
||||
SELECT * FROM (
|
||||
(SELECT s.id_slider, s.id AS id_section, 'main' AS position
|
||||
FROM sections s
|
||||
WHERE s.id_slider IS NOT NULL
|
||||
)
|
||||
UNION
|
||||
(SELECT CAST(JSON_UNQUOTE(JSON_EXTRACT(s.data, '$.additional_slider')) AS INTEGER) AS id_slider, s.id AS id_section, 'additional' AS position
|
||||
FROM sections s
|
||||
WHERE s.data IS NOT NULL
|
||||
AND JSON_EXTRACT(s.data, '$.additional_slider') IS NOT NULL
|
||||
AND EXISTS (
|
||||
SELECT * FROM sliders WHERE id = JSON_UNQUOTE(JSON_EXTRACT(s.data, '$.additional_slider'))
|
||||
)
|
||||
)
|
||||
) t;
|
||||
|
||||
ALTER TABLE sections DROP FOREIGN KEY IF EXISTS sections_ibfk_1;
|
||||
ALTER TABLE sections DROP COLUMN id_slider;
|
||||
");
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_sliderPositionInSection(): bool
|
||||
{
|
||||
$positions = array_keys(SliderUtil::getPositions());
|
||||
|
||||
return $this->checkEnumOptions('sliders_in_sections', 'position', $positions);
|
||||
}
|
||||
|
||||
/** Update sliders_in_sections positions ENUM from module config */
|
||||
public function upgrade_sliderPositionInSection(): void
|
||||
{
|
||||
$positions = array_keys(SliderUtil::getPositions());
|
||||
|
||||
$this->updateEnumOptions('sliders_in_sections', 'position', $positions);
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
use FilipSedivy\EET\Utils\UUID;
|
||||
use Query\Operator;
|
||||
|
||||
class TemplatesUpgrade extends \UpgradeNew
|
||||
{
|
||||
protected function isAllowed()
|
||||
{
|
||||
return findModule(\Modules::TEMPLATES);
|
||||
}
|
||||
|
||||
public function check_blocksForTemplates()
|
||||
{
|
||||
return $this->checkColumnExists('templates', 'id_block');
|
||||
}
|
||||
|
||||
/** Add id_block to templates and move content from templates.text to blocks */
|
||||
public function upgrade_blocksForTemplates()
|
||||
{
|
||||
sqlQuery('
|
||||
ALTER TABLE templates
|
||||
ADD COLUMN `id_block` int(11) UNSIGNED DEFAULT NULL,
|
||||
ADD CONSTRAINT `fk_templates_blocks` FOREIGN KEY (id_block) REFERENCES blocks(id)
|
||||
ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
');
|
||||
|
||||
$translations = findModule(\Modules::TRANSLATIONS);
|
||||
|
||||
$templates = sqlQueryBuilder()->select('*')->from('templates')->execute();
|
||||
foreach ($templates as $template) {
|
||||
// create root block and assign it to templates.id_block
|
||||
$this->insertSQL('blocks', []);
|
||||
$rootBlockID = sqlInsertId();
|
||||
$this->updateSQL('templates', ['id_block' => $rootBlockID], ['id' => $template['id']]);
|
||||
|
||||
$uuid = UUID::v4();
|
||||
$blockObj = new \stdClass();
|
||||
$blockObj->type = 'legacy';
|
||||
$blockObj->id = $uuid;
|
||||
$settings = new \stdClass();
|
||||
$settings->html = $template['text'];
|
||||
$blockObj->settings = $settings;
|
||||
|
||||
$json = json_encode([$blockObj]);
|
||||
|
||||
$this->insertSQL('blocks', [
|
||||
'id_root' => $rootBlockID,
|
||||
'id_parent' => $rootBlockID,
|
||||
'position' => 1,
|
||||
'name' => $template['name'],
|
||||
'content' => $template['text'],
|
||||
'json_content' => $json,
|
||||
]);
|
||||
$id_block = sqlInsertId();
|
||||
|
||||
if ($translations) {
|
||||
$template_translations = sqlQuery('SELECT name, text, id_language, id_admin FROM templates_translations WHERE id_template='.$template['id']);
|
||||
foreach ($template_translations as $template_tr) {
|
||||
$blockObj = new \stdClass();
|
||||
$blockObj->type = 'legacy';
|
||||
$blockObj->id = $uuid;
|
||||
$settings = new \stdClass();
|
||||
$settings->html = $template_tr['text'];
|
||||
$blockObj->settings = $settings;
|
||||
|
||||
$json = json_encode([$blockObj]);
|
||||
|
||||
$this->insertSQL('blocks_translations', [
|
||||
'id_block' => $id_block,
|
||||
'id_language' => $template_tr['id_language'],
|
||||
'id_admin' => $template_tr['id_admin'],
|
||||
'name' => $template_tr['name'],
|
||||
'content' => $template_tr['text'],
|
||||
'json_content' => $json,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sqlQuery('ALTER TABLE templates DROP COLUMN `text`;');
|
||||
|
||||
if ($translations) {
|
||||
// sqlQuery('ALTER TABLE templates_translations DROP COLUMN `text`;');
|
||||
}
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_positionTemplates()
|
||||
{
|
||||
return $this->checkColumnExists('templates', 'position');
|
||||
}
|
||||
|
||||
/** Add position and fill it with values */
|
||||
public function upgrade_positionTemplates()
|
||||
{
|
||||
sqlQuery('
|
||||
ALTER TABLE templates
|
||||
ADD COLUMN `position` int(11) UNSIGNED DEFAULT NULL');
|
||||
|
||||
$templates = sqlQueryBuilder()->select('id')->from('templates')->orderBy('id_category')->execute()->fetchAll();
|
||||
$position = 0;
|
||||
foreach ($templates as $template) {
|
||||
sqlQueryBuilder()->update('templates')
|
||||
->directValues(['position' => $position])
|
||||
->where(Operator::equals(['id' => $template['id']]))
|
||||
->execute();
|
||||
$position++;
|
||||
}
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_trigger_Templates()
|
||||
{
|
||||
return $this->checkIfTriggerExists('trigger_templates');
|
||||
}
|
||||
|
||||
/** Add trigger (incrementing position) to templates */
|
||||
public function upgrade_trigger_Templates()
|
||||
{
|
||||
sqlQuery('CREATE TRIGGER trigger_templates BEFORE INSERT ON templates
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.position IS NULL THEN
|
||||
SET NEW.position = (SELECT COALESCE(MAX(templates.position) + 1, 0) FROM templates WHERE id_category = NEW.id_category);
|
||||
END IF;
|
||||
END;');
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_TemplateCatLabelsCol()
|
||||
{
|
||||
return $this->checkColumnExists('templates_categories', 'label');
|
||||
}
|
||||
|
||||
/** templates_cagories: Add 'labels' column */
|
||||
public function upgrade_TemplateCatLabelsCol()
|
||||
{
|
||||
sqlQuery("
|
||||
ALTER TABLE `templates_categories` ADD COLUMN `label` ENUM('')");
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_TemplateCatLabels()
|
||||
{
|
||||
if ($labels = findModule('templates', 'labels')) {
|
||||
return $this->checkEnumOptions('templates_categories', 'label', array_keys($labels));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** templates_cagories: Add 'labels' column */
|
||||
public function upgrade_TemplateCatLabels()
|
||||
{
|
||||
$this->updateEnumOptions(
|
||||
'templates_categories',
|
||||
'label',
|
||||
array_keys(findModule('templates', 'labels')));
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_dataColumn()
|
||||
{
|
||||
return $this->checkColumnExists('templates_categories', 'data');
|
||||
}
|
||||
|
||||
/** templates_cagories: add data column */
|
||||
public function upgrade_dataColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE templates_categories ADD COLUMN data MEDIUMTEXT DEFAULT NULL');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_TemplatesDataColumn(): bool
|
||||
{
|
||||
return $this->checkColumnExists('templates', 'data');
|
||||
}
|
||||
|
||||
/** templates: add data column */
|
||||
public function upgrade_TemplatesDataColumn(): void
|
||||
{
|
||||
sqlQuery('ALTER TABLE templates ADD COLUMN data MEDIUMTEXT DEFAULT NULL');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
public function check_TemplatesFigureColumn()
|
||||
{
|
||||
return $this->checkColumnExists('templates', 'figure');
|
||||
}
|
||||
|
||||
/** Add 'figure' column into templates table */
|
||||
public function upgrade_TemplatesFigureColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE templates ADD COLUMN figure ENUM("Y", "N") DEFAULT "Y"');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\ContentBundle\Resources\upgrade;
|
||||
|
||||
class VatsUpgrade extends \UpgradeNew
|
||||
{
|
||||
public function check_vatsDataColumn()
|
||||
{
|
||||
return $this->checkColumnExists('vats', 'data');
|
||||
}
|
||||
|
||||
/** Add 'data' column into table 'vats' */
|
||||
public function upgrade_vatsDataColumn()
|
||||
{
|
||||
sqlQuery('ALTER TABLE vats ADD COLUMN data MEDIUMTEXT DEFAULT NULL');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user