-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.0][GSoC 2018] Improve Override Management #21851
Changes from 110 commits
3610beb
6e82f4f
d4a3b55
c5a2eda
880c203
31f4250
60836d5
c1241de
a4e762d
bcbf86e
f386da8
cb15bcb
5adcc2a
78ef55d
33ea597
59218fa
36be46e
2461779
d6e08c2
b01cb7c
15e5620
d370e94
ba639ea
a94d3ba
53f4ed2
a455c92
bca8cff
888b7ed
13b6e01
b93b118
fc5702a
af558b5
c76acf8
d647097
ab9d211
ff327bb
097dd57
b630444
4d8378a
b993c1b
040e551
8a7a05c
ee81275
850888a
dee46fe
2117faf
ef31722
1a98066
1931ede
95ba636
e83c665
e96da2a
10c3d6d
b408ed1
2067698
01b7b91
b442af5
32c1e13
30e468d
8925968
36717c4
cc607c3
5479dd0
2c393ff
023e8d5
71fc7bb
3ff9601
de068aa
173474b
5cb2736
ac943a2
7c7c268
34f1d17
cf47962
fce14ad
b8155c5
9a5b177
5d50298
30bddaf
666127d
29ec592
07ede17
c5ca74f
80b2c92
3430ded
54ccfb6
eb688cf
3280c97
af09962
c883dcb
90722ad
7771111
c6ba5fe
2283cb6
8e8d85e
a466d98
4048f3d
9a6c9eb
b402333
e37fa0a
d02848f
7996018
5eb7fb2
c266dc3
7ad3837
292c1d1
e176da5
7f868bb
8d6d8bb
205fd7f
0962080
711defc
1e27454
22edf9c
de55532
471ea78
dd302a1
724b105
f8daef0
f9fadf0
6d784b7
2e08fc0
f0563ee
367ed63
cf92072
af87954
2d8c13a
8052186
a8a320a
d7f77d1
dd9e579
b2459ce
971a614
9060688
5ec9ffb
bce28b9
6dbf560
4bbca67
9d2ae3d
55390d1
577d627
2e3bd86
b3d6594
c5f269d
a33915f
3c585ef
a987734
0182655
e49a2c2
10e992f
d93fc74
730240e
bef1a9c
93b5113
90594e7
5dbe6e2
603447e
ca8dc67
c0160f3
7eb7ff1
8422f5a
4b71af8
8dca90c
f034475
1468d4e
dedfcf4
0abf606
9adaa46
d9b032f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CREATE TABLE IF NOT EXISTS `#__template_overrides` ( | ||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | ||
`template` varchar(50) NOT NULL DEFAULT '', | ||
`hash_id` varchar(255) NOT NULL DEFAULT '', | ||
`extension_id` int(11) DEFAULT 0, | ||
`state` tinyint(1) NOT NULL DEFAULT 0, | ||
`action` varchar(50) NOT NULL DEFAULT '', | ||
`client_id` tinyint(1) unsigned NOT NULL DEFAULT 0, | ||
`created_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | ||
`modified_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | ||
PRIMARY KEY (`id`), | ||
KEY `idx_template` (`template`), | ||
KEY `idx_extension_id` (`extension_id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; | ||
|
||
INSERT INTO `#__extensions` (`extension_id`, `package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `checked_out`, `checked_out_time`, `ordering`, `state`, `namespace`) VALUES | ||
(491, 0, 'plg_installer_override', 'plugin', 'override', 'installer', 0, 1, 1, 1, '', '', 0, '0000-00-00 00:00:00', 4, 0, ''), | ||
(492, 0, 'plg_quickicon_overridecheck', 'plugin', 'overridecheck', 'quickicon', 0, 1, 1, 1, '', '', 0, '0000-00-00 00:00:00', 0, 0, ''), |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CREATE TABLE IF NOT EXISTS "#__template_overrides" ( | ||
"id" serial NOT NULL, | ||
"template" varchar(50) DEFAULT '' NOT NULL, | ||
"hash_id" varchar(255) DEFAULT '' NOT NULL, | ||
"extension_id" bigint DEFAULT 0, | ||
"state" smallint DEFAULT 0 NOT NULL, | ||
"action" varchar(50) DEFAULT '' NOT NULL, | ||
"client_id" smallint DEFAULT 0 NOT NULL, | ||
"created_date" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, | ||
"modified_date" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, | ||
PRIMARY KEY ("id") | ||
); | ||
CREATE INDEX "#__template_overrides_idx_template" ON "#__template_overrides" ("template"); | ||
CREATE INDEX "#__template_overrides_idx_extension_id" ON "#__template_overrides" ("extension_id"); | ||
|
||
INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "checked_out", "checked_out_time", "ordering", "state", "namespace") VALUES | ||
(491, 0, 'plg_installer_override', 'plugin', 'override', 'installer', 0, 1, 1, 1, '', '', 0, '1970-01-01 00:00:00', 4, 0, ''), | ||
(492, 0, 'plg_quickicon_overridecheck', 'plugin', 'overridecheck', 'quickicon', 0, 1, 1, 1, '', '', 0, '1970-01-01 00:00:00', 0, 0, ''); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,14 @@ | |
|
||
use Joomla\CMS\MVC\Controller\BaseController; | ||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface; | ||
use Joomla\Component\Installer\Administrator\Model\InstallModel; | ||
use Joomla\Utilities\ArrayHelper; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sort in alpha order. Repeat in other files. |
||
use Joomla\CMS\Session\Session; | ||
use Joomla\CMS\Language\Text; | ||
use Joomla\CMS\Router\Route; | ||
use Joomla\CMS\Session\Session; | ||
use Joomla\CMS\Client\ClientHelper; | ||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Plugin\PluginHelper; | ||
use Joomla\Component\Installer\Administrator\Model\InstallModel; | ||
use Joomla\CMS\Client\ClientHelper; | ||
|
||
/** | ||
* Template style controller class. | ||
|
@@ -44,6 +46,9 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu | |
|
||
// Apply, Save & New, and Save As copy should be standard on forms. | ||
$this->registerTask('apply', 'save'); | ||
$this->registerTask('unpublish', 'publish'); | ||
$this->registerTask('publish', 'publish'); | ||
$this->registerTask('deleteOverrideHistory', 'publish'); | ||
} | ||
|
||
/** | ||
|
@@ -74,6 +79,64 @@ public function close() | |
$this->setRedirect(Route::_($url, false)); | ||
} | ||
|
||
/** | ||
* Marked as Checked/Unchecked of override history. | ||
* | ||
* @return void | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function publish() | ||
{ | ||
// Check for request forgeries. | ||
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); | ||
|
||
$app = Factory::getApplication(); | ||
$file = $this->input->get('file'); | ||
$id = $this->input->get('id'); | ||
|
||
$ids = $this->input->get('cid', array(), 'array'); | ||
$values = array('publish' => 1, 'unpublish' => 0, 'deleteOverrideHistory' => -3); | ||
$task = $this->getTask(); | ||
$value = ArrayHelper::getValue($values, $task, 0, 'int'); | ||
|
||
if (empty($ids)) | ||
{ | ||
$this->setMessage(Text::_('COM_TEMPLATES_ERROR_NO_FILE_SELECTED'), 'warning'); | ||
} | ||
else | ||
{ | ||
/* @var \Joomla\Component\Templates\Administrator\Model\TemplateModel $model */ | ||
$model = $this->getModel(); | ||
|
||
// Change the state of the records. | ||
if (!$model->publish($ids, $value, $id)) | ||
{ | ||
$this->setMessage(implode('<br>', $model->getErrors()), 'warning'); | ||
} | ||
else | ||
{ | ||
if ($value === 1) | ||
{ | ||
$ntext = 'COM_TEMPLATES_N_OVERRIDE_CHECKED'; | ||
} | ||
elseif ($value === 0) | ||
{ | ||
$ntext = 'COM_TEMPLATES_N_OVERRIDE_UNCHECKED'; | ||
} | ||
elseif ($value === -3) | ||
{ | ||
$ntext = 'COM_TEMPLATES_N_OVERRIDE_DELETED'; | ||
} | ||
|
||
$this->setMessage(Text::plural($ntext, count($ids))); | ||
} | ||
} | ||
|
||
$url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file; | ||
$this->setRedirect(Route::_($url, false)); | ||
} | ||
|
||
/** | ||
* Method for copying the template. | ||
* | ||
|
@@ -738,4 +801,46 @@ public function extractArchive() | |
$this->setRedirect(Route::_($url, false)); | ||
} | ||
} | ||
|
||
/** | ||
* Fetch and report updates in \JSON format, for A\JAX requests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it be |
||
* | ||
* @return void | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function ajax() | ||
{ | ||
$app = $this->app; | ||
|
||
if (!Session::checkToken('get')) | ||
{ | ||
$app->setHeader('status', 403, true); | ||
$app->sendHeaders(); | ||
echo Text::_('JINVALID_TOKEN'); | ||
$app->close(); | ||
} | ||
|
||
// Checks status of installer override plugin. | ||
if (!PluginHelper::isEnabled('installer', 'override')) | ||
{ | ||
$error = array('installerOverride' => 'disabled'); | ||
|
||
echo json_encode($error); | ||
|
||
$app->close(); | ||
} | ||
|
||
// Created only for test. | ||
$session = Factory::getSession(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ???? did you intend to commit code marked only for test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test code is deleted now. |
||
|
||
/* @var \Joomla\Component\Templates\Administrator\Model\TemplateModel $model */ | ||
$model = $this->getModel(); | ||
|
||
$result = $model->getUpdatedList(true, true); | ||
|
||
echo json_encode($result); | ||
|
||
$app->close(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update comment