alias/_install.php

49 lines
1.3 KiB
PHP
Raw Normal View History

2022-11-27 12:57:51 +00:00
<?php
2022-11-27 13:51:46 +00:00
/**
* @brief alias, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Olivier Meunier and contributors
*
2022-11-28 21:52:27 +00:00
* @copyright Jean-Christian Denis
2022-11-27 13:51:46 +00:00
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
2022-11-27 12:57:51 +00:00
}
2022-12-04 10:32:14 +00:00
try {
2022-12-10 13:47:41 +00:00
if (!dcCore::app()->newVersion(
basename(__DIR__),
dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version')
2022-12-07 22:56:25 +00:00
)) {
2022-12-04 10:32:14 +00:00
return null;
}
2022-11-27 13:51:46 +00:00
$s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
2022-11-30 21:51:55 +00:00
$s->{initAlias::ALIAS_TABLE_NAME}
2022-11-27 13:51:46 +00:00
->blog_id('varchar', 32, false)
->alias_url('varchar', 255, false)
->alias_destination('varchar', 255, false)
->alias_position('smallint', 0, false, 1)
->primary('pk_alias', 'blog_id', 'alias_url')
->index('idx_alias_blog_id', 'btree', 'blog_id')
->index('idx_alias_blog_id_alias_position', 'btree', 'blog_id', 'alias_position')
->reference('fk_alias_blog', 'blog_id', 'blog', 'blog_id', 'cascade', 'cascade')
;
$si = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
$changes = $si->synchronize($s);
return true;
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
}
return false;