Skip to content

Commit 0396a32

Browse files
authored
Merge pull request #56 from HermanPeeren/main
Some styling, PostgreSQL files, language strings and minor improvements
2 parents 97d56a6 + 21ab77a commit 0396a32

File tree

10 files changed

+71
-47
lines changed

10 files changed

+71
-47
lines changed

src/administrator/components/com_ccm/ccm.xml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,15 @@
1111
<install>
1212
<sql>
1313
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
14+
<file driver="postgresql" charset="utf8">sql/install.postgresql.utf8.sql</file>
1415
</sql>
1516
</install>
1617
<uninstall>
1718
<sql>
1819
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
20+
<file driver="postgresql" charset="utf8">sql/uninstall.postgresql.utf8.sql</file>
1921
</sql>
2022
</uninstall>
21-
<update>
22-
<sql>
23-
<file driver="mysql" charset="utf8">sql/updates/mysql/1.0.1.sql</file>
24-
</sql>
25-
</update>
26-
<api>
27-
<files folder="api/components/com_ccm">
28-
<folder>src</folder>
29-
</files>
30-
</api>
3123
<administration>
3224
<files>
3325
<folder>services</folder>

src/administrator/components/com_ccm/language/en-GB/com_ccm.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
COM_CCM="CMS Content Migration"
22
COM_CCM_APPLY_MIGRATION_BTN="Apply Migration"
3+
COM_CCM_CMS_DETAILS="CMS Details"
34
COM_CCM_CMS_ID="CMS ID"
5+
COM_CCM_CMS_FORM_NEW="New CMS"
6+
COM_CCM_CMS_FORM_EDIT="Edit CMS"
47
COM_CCM_CMS_NAME="CMS Name"
58
COM_CCM_CMS_NAME_ADD="Add new CMS"
69
COM_CCM_CMS_NAME_EDIT="Edit CMS"
@@ -19,6 +22,13 @@ COM_CCM_CONFIG_URL_LABEL="CMS URL"
1922
COM_CCM_CONFIGURATION="CCM Migration Configuration"
2023
COM_CCM_DESCRIPTION="CMS Content Migration . Migrating content via the web services API from a source CMS to a target CMS."
2124
COM_CCM_FILTER_SEARCH="Search"
25+
COM_CCM_MESSAGE_MIGRATION_COMPLETED_PARTIALLY="Partial migration completed. "
26+
COM_CCM_MESSAGE_MIGRATION_COMPLETED_SUCCESSFULLY="All migrations completed successfully: "
27+
COM_CCM_MESSAGE_MIGRATION_FAILED="Failed: "
28+
COM_CCM_MESSAGE_MIGRATION_FAILED_ALL="All migrations failed: "
29+
COM_CCM_MESSAGE_MIGRATION_FAILED_THIS="Migration failed: "
30+
COM_CCM_MESSAGE_MIGRATION_NO_DATA_PROVIDED="No data provided for migration."
31+
COM_CCM_MESSAGE_MIGRATION_SUCCESSFUL="Successful: "
2232
COM_CCM_MIGRATION_FIELDSET_LABEL="Migration Settings"
2333
COM_CCM_MIGRATION_SOURCE_CMS="Source CMS"
2434
COM_CCM_MIGRATION_TARGET_CMS="Target CMS"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--
2+
-- Table structure for table #__ccm_cms
3+
--
4+
5+
CREATE TABLE IF NOT EXISTS "#__ccm_cms" (
6+
"id" serial NOT NULL,
7+
"name" varchar(100) DEFAULT '' NOT NULL,
8+
"url" varchar(255) DEFAULT '' NOT NULL,
9+
"credentials" varchar(255) DEFAULT NULL,
10+
"content_keys_types" json DEFAULT NULL,
11+
"ccm_mapping" json DEFAULT NULL,
12+
"created" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
13+
"modified" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
14+
PRIMARY KEY ("id")
15+
);
16+
17+
-- Inserting initial data for table #__ccm_cms
18+
INSERT INTO "#__ccm_cms" ("id", "name") VALUES
19+
(1, 'Joomla'),
20+
(2, 'WordPress');
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DROP TABLE IF EXISTS "#__ccm_cms";
2+

src/administrator/components/com_ccm/src/Controller/CmsController.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ protected function getRedirectToListAppend()
2323
return '&view=cmss';
2424
}
2525

26-
public function migrate()
27-
{
28-
error_log('CmsController::migrate called');
29-
$migration = new \Joomla\Component\CCM\Administrator\Migration\Migration();
30-
$migration->migrate();
31-
32-
// Optionally redirect or set a message
33-
$this->setMessage('Migration completed!');
34-
// $this->setRedirect('index.php?option=com_ccm');
35-
}
3626
/**
3727
* Save the CMS item.
3828
*

src/administrator/components/com_ccm/src/Controller/DisplayController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ class DisplayController extends BaseController
2929
/**
3030
* Method to display a view.
3131
*
32-
* @param boolean $cachable If true, the view output will be cached
33-
* @param array $urlparams An array of safe URL parameters and their variable types, for valid values see {@link \JFilterInput::clean()}.
32+
* @param boolean $cachable If true, the view output will be cached
33+
* @param array $urlparams An array of safe URL parameters and their variable types, for valid values see {@link \JFilterInput::clean()}.
3434
*
3535
* @return static This object to support chaining.
3636
*
37+
* @throws \Exception
3738
* @since 1.0.0
3839
*/
3940
public function display($cachable = false, $urlparams = [])

src/administrator/components/com_ccm/src/Controller/MigrationController.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,31 @@
1313
\defined('_JEXEC') or die;
1414
// phpcs:enable PSR1.Files.SideEffects
1515

16+
use Joomla\CMS\Language\Text;
1617
use Joomla\CMS\MVC\Controller\BaseController;
1718

1819
class MigrationController extends BaseController
1920
{
21+
/**
22+
* Apply migration from source CMS to target CMS.
23+
*
24+
* @return void
25+
*
26+
* @since 1.0.0
27+
*/
2028
public function apply()
2129
{
2230
$data = $this->input->post->get('jform', [], 'array');
2331
if (empty($data)) {
24-
$this->setMessage('No data provided for migration.', 'error');
32+
$this->setMessage(Text::_('COM_CCM_MESSAGE_MIGRATION_NO_DATA_PROVIDED'), 'error');
2533
$this->setRedirect('index.php?option=com_ccm&view=migration');
2634
return;
2735
}
2836

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

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

3543
try {
@@ -68,18 +76,18 @@ public function apply()
6876

6977
// Prepare summary message
7078
if (!empty($successfulMigrations) && empty($failedMigrations)) {
71-
$this->setMessage('All migrations completed successfully: ' . implode(', ', $successfulMigrations));
79+
$this->setMessage(Text::_('COM_CCM_MESSAGE_MIGRATION_COMPLETED_SUCCESSFULLY') . implode(', ', $successfulMigrations));
7280
} elseif (!empty($successfulMigrations) && !empty($failedMigrations)) {
73-
$message = 'Partial migration completed. ';
74-
$message .= 'Successful: ' . implode(', ', $successfulMigrations) . '. ';
75-
$message .= 'Failed: ' . implode(', ', $failedMigrations);
81+
$message = Text::_('COM_CCM_MESSAGE_MIGRATION_COMPLETED_PARTIALLY');
82+
$message .= Text::_('COM_CCM_MESSAGE_MIGRATION_SUCCESSFUL') . implode(', ', $successfulMigrations) . '. ';
83+
$message .= Text::_('COM_CCM_MESSAGE_MIGRATION_FAILED') . implode(', ', $failedMigrations);
7684
$this->setMessage($message, 'warning');
7785
} else {
78-
$this->setMessage('All migrations failed: ' . implode(', ', $failedMigrations), 'error');
86+
$this->setMessage(Text::_('COM_CCM_MESSAGE_MIGRATION_FAILED_ALL') . implode(', ', $failedMigrations), 'error');
7987
}
8088

8189
} catch (\Exception $e) {
82-
$this->setMessage('Migration failed: ' . $e->getMessage(), 'error');
90+
$this->setMessage(Text::_('COM_CCM_MESSAGE_MIGRATION_FAILED_THIS') . $e->getMessage(), 'error');
8391
}
8492
$this->setRedirect('index.php?option=com_ccm&view=migration');
8593
}

src/administrator/components/com_ccm/src/Model/MigrationModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ protected function loadFormData()
8484
/**
8585
* Migrate from source CMS to target CMS.
8686
*
87-
* @return void
87+
* @return boolean
8888
*
89-
* @since 4.0.0
89+
* @since 1.0.0
9090
*/
9191
public function migrate($sourceCmsId, $targetCmsId, $sourceType, $targetType)
9292
{

src/administrator/components/com_ccm/src/View/Migration/HtmlView.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Joomla\CMS\Language\Text;
1717
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1818
use Joomla\CMS\Toolbar\ToolbarHelper;
19-
use Joomla\Component\CCM\Administrator\Migration\Migration;
19+
use Joomla\Component\CCM\Administrator\Model\MigrationModel;
2020

2121
class HtmlView extends BaseHtmlView
2222
{
@@ -26,7 +26,7 @@ class HtmlView extends BaseHtmlView
2626

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

3232
$this->item = $model->getItem();

src/administrator/components/com_ccm/tmpl/cms/edit.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
defined('_JEXEC') or die;
1111

1212
use Joomla\CMS\HTML\HTMLHelper;
13+
use Joomla\CMS\Language\Text;
1314
use Joomla\CMS\Router\Route;
1415

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

21-
<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">
22-
<div>
23-
<div class="row">
24-
<div class="col-md-9">
25-
<div class="row">
26-
<div class="col-md-6">
27-
<?php foreach ($this->form->getFieldset() as $field) :?>
28-
<?php echo $field->renderField(); ?>
29-
<?php endforeach;?>
30-
</div>
31-
</div>
32-
</div>
33-
</div>
22+
<form action="<?php echo Route::_('index.php?option=com_ccm&view=cms&layout=edit&id=' . (int) $this->item->id); ?>"
23+
method="post" name="adminForm" id="cms-form" aria-label="<?php echo Text::_('COM_CCM_CMS_FORM_' . ((int) $this->item->id === 0 ? 'NEW' : 'EDIT'), true); ?>"
24+
class="main-card form-validate">
25+
<?php echo HTMLHelper::_('uitab.startTabSet', 'myTab', ['active' => 'details', 'recall' => true, 'breakpoint' => 768]); ?>
26+
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'details', Text::_('COM_CCM_CMS_DETAILS')); ?>
27+
<div class="form-grid">
28+
<?php foreach ($this->form->getFieldset() as $field) :?>
29+
<?php echo $field->renderField(); ?>
30+
<?php endforeach;?>
3431
</div>
32+
<?php echo HTMLHelper::_('uitab.endTab'); ?>
33+
<?php echo HTMLHelper::_('uitab.endTabSet'); ?>
34+
35+
<?php echo $this->form->renderControlFields(); ?>
3536
<input type="hidden" name="task" value="">
3637
<?php echo HTMLHelper::_('form.token'); ?>
3738
</form>

0 commit comments

Comments
 (0)