clean up install file
This commit is contained in:
parent
11dede7f31
commit
d2a2b18308
1 changed files with 28 additions and 44 deletions
72
_install.php
72
_install.php
|
@ -12,57 +12,45 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$new_version = $core->plugins->moduleInfo('postWidgetText', 'version');
|
||||||
|
$old_version = $core->getVersion('postWidgetText');
|
||||||
|
|
||||||
|
if (version_compare($old_version, $new_version, '>=')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
# Check module version
|
|
||||||
if (version_compare(
|
|
||||||
$core->getVersion('postWidgetText'),
|
|
||||||
$core->plugins->moduleInfo('postWidgetText', 'version'),
|
|
||||||
'>='
|
|
||||||
)) {
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check Dotclear version
|
|
||||||
if (!method_exists('dcUtils', 'versionsCompare')
|
|
||||||
|| dcUtils::versionsCompare(DC_VERSION, '2.6', '<', false)) {
|
|
||||||
throw new Exception(sprintf(
|
|
||||||
'%s requires Dotclear %s', 'postWidgetText', '2.6'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
# Table is the same for plugins
|
# Table is the same for plugins
|
||||||
# pollsFactory, postTask, postWidgetText
|
# pollsFactory, postTask, postWidgetText
|
||||||
$s = new dbStruct($core->con,$core->prefix);
|
$s = new dbStruct($core->con, $core->prefix);
|
||||||
$s->post_option
|
$s->post_option
|
||||||
->option_id ('bigint',0,false)
|
->option_id ('bigint', 0, false)
|
||||||
->post_id ('bigint',0,false)
|
->post_id ('bigint', 0, false)
|
||||||
->option_creadt ('timestamp',0,false,'now()')
|
->option_creadt ('timestamp', 0, false, 'now()')
|
||||||
->option_upddt ('timestamp',0,false,'now()')
|
->option_upddt ('timestamp', 0, false, 'now()')
|
||||||
->option_type ('varchar',32,false,"''")
|
->option_type ('varchar', 32, false, "''")
|
||||||
->option_format ('varchar',32,false,"'xhtml'")
|
->option_format ('varchar', 32, false, "'xhtml'")
|
||||||
->option_lang ('varchar',5,true,null)
|
->option_lang ('varchar', 5, true, null)
|
||||||
->option_title ('varchar',255,true,null)
|
->option_title ('varchar', 255, true, null)
|
||||||
->option_content ('text',0,true,null)
|
->option_content ('text', 0, true, null)
|
||||||
->option_content_xhtml ('text',0,false)
|
->option_content_xhtml ('text', 0, false)
|
||||||
|
|
||||||
->index('idx_post_option_option','btree','option_id')
|
->index('idx_post_option_option', 'btree', 'option_id')
|
||||||
->index('idx_post_option_post','btree','post_id')
|
->index('idx_post_option_post', 'btree', 'post_id')
|
||||||
->index('idx_post_option_type','btree','option_type');
|
->index('idx_post_option_type', 'btree', 'option_type');
|
||||||
|
|
||||||
$si = new dbStruct($core->con,$core->prefix);
|
$si = new dbStruct($core->con, $core->prefix);
|
||||||
$changes = $si->synchronize($s);
|
$changes = $si->synchronize($s);
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
$core->blog->settings->addNamespace('postwidgettext');
|
$core->blog->settings->addNamespace('postwidgettext');
|
||||||
$core->blog->settings->postwidgettext->put('postwidgettext_active',
|
$core->blog->settings->postwidgettext->put('postwidgettext_active',
|
||||||
true,'boolean','post widget text plugin enabled',false,true);
|
true, 'boolean', 'post widget text plugin enabled', false, true);
|
||||||
$core->blog->settings->postwidgettext->put('postwidgettext_importexport_active',
|
$core->blog->settings->postwidgettext->put('postwidgettext_importexport_active',
|
||||||
true,'boolean','activate import/export behaviors',false,true);
|
true, 'boolean', 'activate import/export behaviors', false, true);
|
||||||
|
|
||||||
# Transfert records from old table to the new one
|
# Transfert records from old table to the new one
|
||||||
if ($core->getVersion('postWidgetText') !== null
|
if ($core->getVersion('postWidgetText') !== null
|
||||||
|
@ -72,15 +60,11 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set module version
|
# Set module version
|
||||||
$core->setVersion(
|
$core->setVersion('postWidgetText', $new_version);
|
||||||
'postWidgetText',
|
|
||||||
$core->plugins->moduleInfo('postWidgetText', 'version')
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
|
||||||
$core->error->add($e->getMessage());
|
$core->error->add($e->getMessage());
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
Loading…
Reference in a new issue