Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions src/administrator/components/com_ccm/ccm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,15 @@
<install>
<sql>
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
<file driver="postgresql" charset="utf8">sql/install.postgresql.utf8.sql</file>
</sql>
</install>
<uninstall>
<sql>
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
<file driver="postgresql" charset="utf8">sql/uninstall.postgresql.utf8.sql</file>
</sql>
</uninstall>
<update>
<sql>
<file driver="mysql" charset="utf8">sql/updates/mysql/1.0.1.sql</file>
</sql>
</update>
<api>
<files folder="api/components/com_ccm">
<folder>src</folder>
</files>
</api>
<administration>
<files>
<folder>services</folder>
Expand Down
10 changes: 10 additions & 0 deletions src/administrator/components/com_ccm/language/en-GB/com_ccm.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
COM_CCM="CMS Content Migration"
COM_CCM_APPLY_MIGRATION_BTN="Apply Migration"
COM_CCM_CMS_DETAILS="CMS Details"
COM_CCM_CMS_ID="CMS ID"
COM_CCM_CMS_FORM_NEW="New CMS"
COM_CCM_CMS_FORM_EDIT="Edit CMS"
COM_CCM_CMS_NAME="CMS Name"
COM_CCM_CMS_NAME_ADD="Add new CMS"
COM_CCM_CMS_NAME_EDIT="Edit CMS"
Expand All @@ -19,6 +22,13 @@ COM_CCM_CONFIG_URL_LABEL="CMS URL"
COM_CCM_CONFIGURATION="CCM Migration Configuration"
COM_CCM_DESCRIPTION="CMS Content Migration . Migrating content via the web services API from a source CMS to a target CMS."
COM_CCM_FILTER_SEARCH="Search"
COM_CCM_MESSAGE_MIGRATION_COMPLETED_PARTIALLY="Partial migration completed. "
COM_CCM_MESSAGE_MIGRATION_COMPLETED_SUCCESSFULLY="All migrations completed successfully: "
COM_CCM_MESSAGE_MIGRATION_FAILED="Failed: "
COM_CCM_MESSAGE_MIGRATION_FAILED_ALL="All migrations failed: "
COM_CCM_MESSAGE_MIGRATION_FAILED_THIS="Migration failed: "
COM_CCM_MESSAGE_MIGRATION_NO_DATA_PROVIDED="No data provided for migration."
COM_CCM_MESSAGE_MIGRATION_SUCCESSFUL="Successful: "
COM_CCM_MIGRATION_FIELDSET_LABEL="Migration Settings"
COM_CCM_MIGRATION_SOURCE_CMS="Source CMS"
COM_CCM_MIGRATION_TARGET_CMS="Target CMS"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--
-- Table structure for table #__ccm_cms
--

CREATE TABLE IF NOT EXISTS "#__ccm_cms" (
"id" serial NOT NULL,
"name" varchar(100) DEFAULT '' NOT NULL,
"url" varchar(255) DEFAULT '' NOT NULL,
"credentials" varchar(255) DEFAULT NULL,
"content_keys_types" json DEFAULT NULL,
"ccm_mapping" json DEFAULT NULL,
"created" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"modified" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ("id")
);

-- Inserting initial data for table #__ccm_cms
INSERT INTO "#__ccm_cms" ("id", "name") VALUES
(1, 'Joomla'),
(2, 'WordPress');
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DROP TABLE IF EXISTS "#__ccm_cms";

Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ protected function getRedirectToListAppend()
return '&view=cmss';
}

public function migrate()
{
error_log('CmsController::migrate called');
$migration = new \Joomla\Component\CCM\Administrator\Migration\Migration();
$migration->migrate();

// Optionally redirect or set a message
$this->setMessage('Migration completed!');
// $this->setRedirect('index.php?option=com_ccm');
}
/**
* Save the CMS item.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ class DisplayController extends BaseController
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached
* @param array $urlparams An array of safe URL parameters and their variable types, for valid values see {@link \JFilterInput::clean()}.
* @param boolean $cachable If true, the view output will be cached
* @param array $urlparams An array of safe URL parameters and their variable types, for valid values see {@link \JFilterInput::clean()}.
*
* @return static This object to support chaining.
*
* @throws \Exception
* @since 1.0.0
*/
public function display($cachable = false, $urlparams = [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,31 @@
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;

class MigrationController extends BaseController
{
/**
* Apply migration from source CMS to target CMS.
*
* @return void
*
* @since 1.0.0
*/
public function apply()
{
$data = $this->input->post->get('jform', [], 'array');
if (empty($data)) {
$this->setMessage('No data provided for migration.', 'error');
$this->setMessage(Text::_('COM_CCM_MESSAGE_MIGRATION_NO_DATA_PROVIDED'), 'error');
$this->setRedirect('index.php?option=com_ccm&view=migration');
return;
}

$sourceCmsId = isset($data['source_cms']) ? (int) $data['source_cms'] : 0;
$targetCmsId = isset($data['target_cms']) ? (int) $data['target_cms'] : 0;

/** @var MigrationModel $model */
/** @var \Joomla\Component\CCM\Administrator\Model\MigrationModel $model */
$model = $this->getModel();

try {
Expand Down Expand Up @@ -68,18 +76,18 @@ public function apply()

// Prepare summary message
if (!empty($successfulMigrations) && empty($failedMigrations)) {
$this->setMessage('All migrations completed successfully: ' . implode(', ', $successfulMigrations));
$this->setMessage(Text::_('COM_CCM_MESSAGE_MIGRATION_COMPLETED_SUCCESSFULLY') . implode(', ', $successfulMigrations));
} elseif (!empty($successfulMigrations) && !empty($failedMigrations)) {
$message = 'Partial migration completed. ';
$message .= 'Successful: ' . implode(', ', $successfulMigrations) . '. ';
$message .= 'Failed: ' . implode(', ', $failedMigrations);
$message = Text::_('COM_CCM_MESSAGE_MIGRATION_COMPLETED_PARTIALLY');
$message .= Text::_('COM_CCM_MESSAGE_MIGRATION_SUCCESSFUL') . implode(', ', $successfulMigrations) . '. ';
$message .= Text::_('COM_CCM_MESSAGE_MIGRATION_FAILED') . implode(', ', $failedMigrations);
$this->setMessage($message, 'warning');
} else {
$this->setMessage('All migrations failed: ' . implode(', ', $failedMigrations), 'error');
$this->setMessage(Text::_('COM_CCM_MESSAGE_MIGRATION_FAILED_ALL') . implode(', ', $failedMigrations), 'error');
}

} catch (\Exception $e) {
$this->setMessage('Migration failed: ' . $e->getMessage(), 'error');
$this->setMessage(Text::_('COM_CCM_MESSAGE_MIGRATION_FAILED_THIS') . $e->getMessage(), 'error');
}
$this->setRedirect('index.php?option=com_ccm&view=migration');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ protected function loadFormData()
/**
* Migrate from source CMS to target CMS.
*
* @return void
* @return boolean
*
* @since 4.0.0
* @since 1.0.0
*/
public function migrate($sourceCmsId, $targetCmsId, $sourceType, $targetType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\Component\CCM\Administrator\Migration\Migration;
use Joomla\Component\CCM\Administrator\Model\MigrationModel;

class HtmlView extends BaseHtmlView
{
Expand All @@ -26,7 +26,7 @@ class HtmlView extends BaseHtmlView

public function display($tpl = null): void
{
/** @var Migration $model */
/** @var MigrationModel $model */
$model = $this->getModel();

$this->item = $model->getItem();
Expand Down
27 changes: 14 additions & 13 deletions src/administrator/components/com_ccm/tmpl/cms/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
Expand All @@ -18,20 +19,20 @@
->useScript('form.validate');
?>

<form action="<?php echo Route::_('index.php?option=com_ccm&view=cms&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="cms-form" class="form-validate">
<div>
<div class="row">
<div class="col-md-9">
<div class="row">
<div class="col-md-6">
<?php foreach ($this->form->getFieldset() as $field) :?>
<?php echo $field->renderField(); ?>
<?php endforeach;?>
</div>
</div>
</div>
</div>
<form action="<?php echo Route::_('index.php?option=com_ccm&view=cms&layout=edit&id=' . (int) $this->item->id); ?>"
method="post" name="adminForm" id="cms-form" aria-label="<?php echo Text::_('COM_CCM_CMS_FORM_' . ((int) $this->item->id === 0 ? 'NEW' : 'EDIT'), true); ?>"
class="main-card form-validate">
<?php echo HTMLHelper::_('uitab.startTabSet', 'myTab', ['active' => 'details', 'recall' => true, 'breakpoint' => 768]); ?>
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'details', Text::_('COM_CCM_CMS_DETAILS')); ?>
<div class="form-grid">
<?php foreach ($this->form->getFieldset() as $field) :?>
<?php echo $field->renderField(); ?>
<?php endforeach;?>
</div>
<?php echo HTMLHelper::_('uitab.endTab'); ?>
<?php echo HTMLHelper::_('uitab.endTabSet'); ?>

<?php echo $this->form->renderControlFields(); ?>
<input type="hidden" name="task" value="">
<?php echo HTMLHelper::_('form.token'); ?>
</form>