getDB();
echo '
Install check
';
/* echo 'The following tables will be created:
';
$tablesdef = simplexml_load_file(__DIR__.DIRECTORY_SEPARATOR.'tables-'.$VERSION.'.xml');
echo '';
foreach ($tablesdef as $tabledef) {
$tableInfo = MFDBTableInfo::fromXML($tabledef);
echo "- table: ".'p_'.$CAT.'#'.$PLUGIN.'_'.$tableInfo->getName().' (columns: '.$tableInfo->getColumnCount().")
\n";
}
echo '
'; */
echo 'Install';
break;
case 2:
$db = \MCMS\System::getInstance()->getDB();
echo 'Install
';
/* echo 'The following tables are created:
';
$tablesdef = simplexml_load_file(__DIR__.DIRECTORY_SEPARATOR.'tables-'.$VERSION.'.xml');
echo '';
foreach ($tablesdef as $tabledef) {
$tableInfo = MFDBTableInfo::fromXML($tabledef);
$tableName = 'p_'.$CAT.'#'.$PLUGIN.'_'.$tableInfo->getName();
$tableInfo->setName($tableName); // we need to add the module prefix
if ($db->tableExists($tableInfo))
echo "- table ".$tableName." skipped
\n";
else {
$db->createTable($tableInfo);
echo "- table ".$tableName." created
\n";
}
}
echo '
'; */
$db->table('installinfo')->insert(array(
'type' => 'plugin','key' => $CAT . ':' . $PLUGIN,'version' => $VERSION,
'attrib' => 0));
echo 'Go back';
break;
default:
throw new BadFunctionCallException('Invalid step');
}
break;
/* case 'upgrade':
switch ($STEP) {
case 1:
$this->installed = \MCMS\System::getInstance()->getDB()->table('installinfo')->getObject(array('type' => 'plugin','key' => 'content:mcms.mmpistatistic'));
echo 'updating from '.$this->installed->version.' to '.$VERSION.'
';
echo 'Update';
break;
case 2:
$db = \MCMS\System::getInstance()->getDB();
$this->installed = $db->table('installinfo')->getObject(array('type' => 'plugin','key' => 'content:mcms.mmpistatistic'));
$old = $this->installed->version;
$versions = array('1.0.0.1');
$error = false;
foreach ($versions as $version) {
echo 'updating from '.$old.' to '.$version.'
';
$updatefile = __DIR__.__DS__.'update-'.$version.'.php';
if (include_exists($updatefile)) {
$db->startTransaction();
include($updatefile);
$db->table('installinfo')->update(array('version' => $version), array('type' => 'plugin','key' => 'content:mcms.mmpistatistic'));
$db->rollback();
// $db->commit();
}
else {
$db->rollback();
$error = true;
echo 'update file for version '.$version.' is missing!
';
}
}
if (!$error)
echo 'Go back';
break;
default:
throw new BadFunctionCallException('Invalid step 123');
}
break;
case 'validate':
switch ($STEP) {
case 1:
$db = \MCMS\System::getInstance()->getDB();
$result = $db->table('p_content#mcms.mmpistatistic_targets')->select();
while ($row = $result->fetchArray()) {
$newdata = array(
'file_hash' => crc32(trim($row['file'])) % 2000000000,
'extra_hash'=> crc32(trim($row['extra'])) % 2000000000
);
$db->table('p_content#mcms.mmpistatistic_targets')->update($newdata, array('id' => $row['id']));
}
$result->close();
break;
default:
throw new BadFunctionCallException('Invalid step');
}
break; */
case 'uninstall':
switch($STEP) {
case 1:
$db = \MCMS\System::getInstance()->getDB();
echo 'Uninstall check
';
/* echo 'The following tables will be removed:
';
$tablesdef = simplexml_load_file(__DIR__.DIRECTORY_SEPARATOR.'tables-'.$VERSION.'.xml');
echo '';
foreach ($tablesdef as $tabledef) {
$tableInfo = MFDBTableInfo::fromXML($tabledef);
echo "- table: ". 'p_'.$CAT.'#'.$PLUGIN.'_'.$tableInfo->getName().' (columns: '.$tableInfo->getColumnCount().")
\n";
}
echo '
'; */
echo 'Uninstall';
break;
case 2:
$db = \MCMS\System::getInstance()->getDB();
echo 'Install check
';
/* echo 'The following tables are removed:
';
$tablesdef = simplexml_load_file(__DIR__.DIRECTORY_SEPARATOR.'tables-'.$VERSION.'.xml');
echo '';
foreach ($tablesdef as $tabledef) {
$tableInfo = MFDBTableInfo::fromXML($tabledef);
$tableName = 'p_'.$CAT.'#'.$PLUGIN.'_'.$tableInfo->getName();
$tableInfo->setName($tableName); // we need to add the module prefix
$db->dropTable($tableInfo);
echo "- table ".$tableName." removed
\n";
}
echo '
'; */
$db->table('installinfo')->delete(array(
'type' => 'plugin','key' => $CAT . ':' . $PLUGIN));
echo 'Go back';
break;
default:
throw new BadFunctionCallException('Invalid step');
}
break;
}