Skip to content
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

Merged
merged 169 commits into from
Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from 148 commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
3610beb
Load correct core files of override files (#2)
anuragteapot May 23, 2018
6e82f4f
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx May 23, 2018
d4a3b55
CS (#3) Coding Standards
anuragteapot May 23, 2018
c5a2eda
codingstandards
astridx May 23, 2018
880c203
codingstandards (#4)
astridx May 24, 2018
31f4250
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx May 27, 2018
60836d5
Merge branch 'master' of https://github.com/joomla-projects/gsoc18_ov…
astridx May 27, 2018
c1241de
Test (#6)
anuragteapot May 29, 2018
a4e762d
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx May 29, 2018
bcbf86e
Remove Notice: Only available for html-folder
anuragteapot Jun 3, 2018
f386da8
Remove Warning if core file not found (#11)
anuragteapot Jun 4, 2018
cb15bcb
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jun 4, 2018
5adcc2a
Merge branch 'master' of https://github.com/joomla-projects/gsoc18_ov…
astridx Jun 4, 2018
78ef55d
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jun 4, 2018
33ea597
Implement the diff view in template manager
anuragteapot Jun 7, 2018
59218fa
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jun 7, 2018
36be46e
Merge branch 'master' of https://github.com/joomla-projects/gsoc18_ov…
astridx Jun 7, 2018
2461779
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jun 9, 2018
d6e08c2
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jun 10, 2018
b01cb7c
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jun 18, 2018
15e5620
coding standard (#17)
astridx Jun 18, 2018
d370e94
fix diff (#18) Fix bug in path in case of administrator template over…
anuragteapot Jun 18, 2018
ba639ea
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jun 18, 2018
a94d3ba
Notification after update and TEST (#16)
anuragteapot Jun 22, 2018
53f4ed2
resolved conflicts
astridx Jun 22, 2018
a455c92
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jun 22, 2018
bca8cff
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jun 23, 2018
888b7ed
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jun 24, 2018
13b6e01
coding standard (#21)
astridx Jun 25, 2018
b93b118
correction
astridx Jun 25, 2018
fc5702a
correction (#26)
astridx Jun 26, 2018
af558b5
Merge branch 'master' of https://github.com/joomla-projects/gsoc18_ov…
astridx Jun 28, 2018
c76acf8
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jun 28, 2018
d647097
Correcthtmlpath (#27)
astridx Jun 29, 2018
ab9d211
wip
astridx Jul 6, 2018
ff327bb
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jul 8, 2018
097dd57
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jul 10, 2018
b630444
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jul 11, 2018
4d8378a
List of updated override files. (#30)
anuragteapot Jul 11, 2018
b993c1b
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jul 11, 2018
040e551
merge 4.0-dev
astridx Jul 13, 2018
8a7a05c
addcss (#34)
astridx Jul 14, 2018
ee81275
merge conflics solved
astridx Jul 17, 2018
850888a
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jul 17, 2018
dee46fe
Merge branch 'master' of https://github.com/joomla-projects/gsoc18_ov…
astridx Jul 17, 2018
2117faf
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jul 18, 2018
ef31722
Final Product (#39)
anuragteapot Jul 18, 2018
1a98066
save 3 lines :)
astridx Jul 18, 2018
1931ede
Merge pull request #44 from joomla-projects/standardbutton
anuragteapot Jul 18, 2018
95ba636
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jul 18, 2018
e83c665
New feature show status. (#47)
anuragteapot Jul 19, 2018
e96da2a
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jul 19, 2018
10c3d6d
link
Jul 19, 2018
b408ed1
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jul 19, 2018
2067698
Merge remote-tracking branch 'origin/master' into link
Jul 20, 2018
01b7b91
Merge pull request #49 from joomla-projects/link
anuragteapot Jul 20, 2018
b442af5
merge
astridx Jul 20, 2018
32c1e13
corrected namespace
astridx Jul 20, 2018
30e468d
Button to Switch (#35)
astridx Jul 21, 2018
8925968
Sql files for fix database (#50)
astridx Jul 21, 2018
36717c4
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jul 21, 2018
cc607c3
merge 4.0-dev
astridx Jul 24, 2018
5479dd0
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jul 25, 2018
2c393ff
Suggestion for displaying Dates in view updates files (#52)
astridx Jul 25, 2018
023e8d5
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Jul 27, 2018
71fc7bb
Store Date as UTC and show it in server time zone (#57)
astridx Jul 28, 2018
3ff9601
merge 4.0-dev
astridx Jul 28, 2018
de068aa
merge 4.0-dev
astridx Aug 1, 2018
173474b
JToolbarHelper to ToolbarHelper
astridx Aug 1, 2018
5cb2736
CS
Aug 1, 2018
ac943a2
Merge remote-tracking branch 'origin/4.0-dev'
Aug 3, 2018
7c7c268
Merge remote-tracking branch 'origin/master' into cs
Aug 3, 2018
34f1d17
Merge remote-tracking branch 'origin/master' into toolbar
Aug 3, 2018
cf47962
Toolbar namespace
anuragteapot Aug 3, 2018
fce14ad
Merge remote-tracking branch 'origin/master' into cs
Aug 5, 2018
b8155c5
namespace
Aug 5, 2018
9a5b177
plural
Aug 6, 2018
5d50298
name
Aug 6, 2018
30bddaf
clean
Aug 6, 2018
666127d
text
Aug 6, 2018
29ec592
fx
Aug 6, 2018
07ede17
sin
Aug 6, 2018
c5ca74f
files
Aug 6, 2018
80b2c92
s
Aug 6, 2018
3430ded
Merge remote-tracking branch 'origin/4.0-dev'
Aug 6, 2018
54ccfb6
Merge remote-tracking branch 'origin/master' into cs
Aug 6, 2018
eb688cf
merge 4.0-dev
astridx Aug 6, 2018
3280c97
Secure comparison. And clean up.
anuragteapot Aug 7, 2018
af09962
merge 4.0-dev
astridx Aug 9, 2018
c883dcb
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Aug 9, 2018
90722ad
Merge remote-tracking branch 'upstream/4.0-dev'
Aug 10, 2018
7771111
merge 4.0-dev
astridx Aug 10, 2018
c6ba5fe
Merge branch 'master' of https://github.com/joomla-projects/gsoc18_ov…
astridx Aug 10, 2018
2283cb6
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Aug 12, 2018
8e8d85e
Suggestion for language strings (#60)
astridx Aug 12, 2018
a466d98
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Aug 16, 2018
4048f3d
delete media folder plg_quickicon
astridx Aug 16, 2018
9a6c9eb
add folder plg_quickicon to build/media_src
astridx Aug 16, 2018
b402333
delete files in media folder
astridx Aug 16, 2018
e37fa0a
Move media folder
anuragteapot Aug 17, 2018
d02848f
Move media folder - quickicon
anuragteapot Aug 17, 2018
7996018
Merge branch 'master' of github.com:joomla-projects/gsoc18_override_m…
zero-24 Aug 18, 2018
5eb7fb2
Move media folder - System (#66)
anuragteapot Aug 20, 2018
c266dc3
Merge branch '4.0-dev' of github.com:joomla/joomla-cms
astridx Aug 20, 2018
7ad3837
delete files in media folder for joomla toolbar (#67)
astridx Aug 21, 2018
292c1d1
Fix button switchers style. (#70)
anuragteapot Aug 24, 2018
e176da5
merge 4.0-dev
astridx Aug 24, 2018
7f868bb
changed uitab.addTab for updated files
astridx Aug 24, 2018
8d6d8bb
Bring back core.js changes. (#69)
anuragteapot Aug 24, 2018
205fd7f
Merge branch '4.0-dev' of https://github.com/joomla/joomla-cms
Aug 26, 2018
0962080
core
Aug 26, 2018
711defc
hound
Aug 26, 2018
1e27454
Merge branch '4.0-dev' into gsoc
anuragteapot Aug 26, 2018
22edf9c
CS
Aug 26, 2018
de55532
Merge branch 'gsoc' of https://github.com/Anu1601CS/joomla-cms into gsoc
Aug 26, 2018
471ea78
scopr
Aug 26, 2018
dd302a1
grid
Aug 26, 2018
724b105
Merge branch '4.0-dev' into gsoc
anuragteapot Aug 26, 2018
f8daef0
Merge branch '4.0-dev' into gsoc
anuragteapot Aug 26, 2018
f9fadf0
alpha
Aug 26, 2018
6d784b7
Merge branch 'gsoc' of https://github.com/Anu1601CS/joomla-cms into gsoc
Aug 26, 2018
2e08fc0
Merge branch '4.0-dev' into gsoc
anuragteapot Aug 26, 2018
f0563ee
cs
Aug 27, 2018
367ed63
Merge branch 'gsoc' of https://github.com/Anu1601CS/joomla-cms into gsoc
Aug 27, 2018
cf92072
Merge branch '4.0-dev' into gsoc
anuragteapot Aug 27, 2018
af87954
lang
Aug 27, 2018
2d8c13a
Merge branch 'gsoc' of https://github.com/Anu1601CS/joomla-cms into gsoc
Aug 27, 2018
8052186
only override file
Aug 27, 2018
a8a320a
lang
Aug 27, 2018
d7f77d1
override lang installer
Aug 27, 2018
dd9e579
Merge branch '4.0-dev' into gsoc
anuragteapot Aug 27, 2018
b2459ce
Cs
Aug 27, 2018
971a614
Merge branch 'gsoc' of https://github.com/Anu1601CS/joomla-cms into gsoc
Aug 27, 2018
9060688
sub
Aug 27, 2018
5ec9ffb
Update list of core extensions (#71)
brianteeman Aug 28, 2018
bce28b9
Language changes (#76)
brianteeman Aug 28, 2018
6dbf560
Change icon (#74)
brianteeman Aug 28, 2018
4bbca67
Merge branch 'master' of https://github.com/joomla-projects/gsoc18_ov…
Aug 28, 2018
9d2ae3d
Merge branch '4.0-dev' into gsoc
anuragteapot Aug 28, 2018
55390d1
lang
Aug 28, 2018
577d627
Merge branch 'gsoc' of https://github.com/Anu1601CS/joomla-cms into gsoc
Aug 28, 2018
2e3bd86
not core (#75)
brianteeman Aug 28, 2018
b3d6594
conf
Aug 28, 2018
c5f269d
Merge branch 'master' of https://github.com/joomla-projects/gsoc18_ov…
Aug 28, 2018
a33915f
Merge branch 'gsoc' of https://github.com/Anu1601CS/joomla-cms
Aug 28, 2018
3c585ef
namespace
Aug 28, 2018
a987734
Merge branch '4.0-dev' into gsoc
anuragteapot Aug 29, 2018
0182655
cs
Aug 29, 2018
e49a2c2
Merge branch 'gsoc' of https://github.com/Anu1601CS/joomla-cms into gsoc
Aug 29, 2018
10e992f
Merge branch '4.0-dev' into gsoc
anuragteapot Aug 30, 2018
d93fc74
Merge branch '4.0-dev' into gsoc
anuragteapot Aug 31, 2018
730240e
Updated files (#82)
brianteeman Sep 2, 2018
bef1a9c
Update en-GB.com_templates.ini (#81)
brianteeman Sep 2, 2018
93b5113
Update en-GB.plg_quickicon_overridecheck.ini (#80)
brianteeman Sep 2, 2018
90594e7
Update en-GB.plg_quickicon_overridecheck.ini (#79)
brianteeman Sep 2, 2018
5dbe6e2
remove space (#78)
brianteeman Sep 2, 2018
603447e
Merge branch 'master' of https://github.com/joomla-projects/gsoc18_ov…
Sep 2, 2018
ca8dc67
remove hardcoded id
Sep 2, 2018
c0160f3
Merge branch '4.0-dev' into gsoc
anuragteapot Sep 2, 2018
7eb7ff1
null get function
Sep 3, 2018
8422f5a
state
Sep 3, 2018
4b71af8
Merge branch '4.0-dev' into gsoc
anuragteapot Sep 3, 2018
8dca90c
clean
Sep 3, 2018
f034475
More changes "core" to "original" (#85)
richard67 Sep 3, 2018
1468d4e
Merge branch 'master' of https://github.com/joomla-projects/gsoc18_ov…
Sep 3, 2018
dedfcf4
cs
Sep 4, 2018
0abf606
update
Sep 4, 2018
9adaa46
plural
Sep 6, 2018
d9b032f
Merge branch '4.0-dev' into gsoc
anuragteapot Sep 6, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ALTER TABLE `#__users` MODIFY `name` varchar(400) NOT NULL DEFAULT '';
--
-- Step 2.2: Convert all tables to utf8mb4 chracter set with utf8mb4_unicode_ci collation
-- except #__finder_xxx tables, those will have utf8mb4_general_ci collation.
-- Note: The database driver for mysql will change utf8mb4 to utf8 if utf8mb4 is not supported
-- Note: The database driver for mysql will change utf8mb4 to utf8 if utf8mb4 is not supported
--

ALTER TABLE `#__assets` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Expand Down Expand Up @@ -108,6 +108,7 @@ ALTER TABLE `#__redirect_links` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4
ALTER TABLE `#__schemas` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__session` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__tags` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__template_overrides` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__template_styles` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__ucm_base` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__ucm_content` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Expand Down Expand Up @@ -200,6 +201,7 @@ ALTER TABLE `#__redirect_links` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_un
ALTER TABLE `#__schemas` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__session` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__tags` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__template_overrides` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__template_styles` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__ucm_base` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__ucm_content` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Expand Down
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, '');
3 changes: 3 additions & 0 deletions administrator/components/com_installer/Model/UpdateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ public function update($uids, $minimum_stability = Updater::STABILITY_STABLE)
*/
private function install($update)
{
// Load overrides plugin.
PluginHelper::importPlugin('installer');

$app = Factory::getApplication();

if (!isset($update->get('downloadurl')->_data))
Expand Down
23 changes: 20 additions & 3 deletions administrator/components/com_joomlaupdate/Model/UpdateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Joomla\CMS\Log\Log;
use Joomla\CMS\Http\HttpFactory;
use Joomla\CMS\Installer\Installer;
use Joomla\CMS\Plugin\PluginHelper;

/**
* Joomla! update overview Model
Expand Down Expand Up @@ -389,7 +390,8 @@ protected function downloadPackage($url, $target)
}

/**
* Create restoration file.
* Create restoration file and trigger onJoomlaBeforeUpdate event, which find the updated core files
* which have changed during the update, where there are override for.
*
* @param string $basename Optional base path to the file.
*
Expand All @@ -399,11 +401,17 @@ protected function downloadPackage($url, $target)
*/
public function createRestorationFile($basename = null)
{
// Load overrides plugin.
PluginHelper::importPlugin('installer');

// Get a password
$password = UserHelper::genRandomPassword(32);
$app = Factory::getApplication();
$app->setUserState('com_joomlaupdate.password', $password);

// Trigger on before joomla event.
$app->triggerEvent('onJoomlaBeforeUpdate');

// Do we have to use FTP?
$method = Factory::getApplication()->getUserStateFromRequest('com_joomlaupdate.method', 'method', 'direct', 'cmd');

Expand Down Expand Up @@ -826,19 +834,28 @@ public function finaliseUpgrade()
}

/**
* Removes the extracted package file.
* Removes the extracted package file and trigger onJoomlaAfterUpdate event, which find the updated core files
* which have changed during the update, where there are override for.
*
* @return void
*
* @since 2.5.4
*/
public function cleanUp()
{
// Load overrides plugin.
PluginHelper::importPlugin('installer');

$app = Factory::getApplication();

// Trigger on before joomla event.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update comment

$app->triggerEvent('onJoomlaAfterUpdate');

// Remove the update package.
$config = Factory::getConfig();
$tempdir = $config->get('tmp_path');

$file = Factory::getApplication()->getUserState('com_joomlaupdate.file', null);
$file = $app->getUserState('com_joomlaupdate.file', null);
$target = $tempdir . '/' . $file;

if (!@unlink($target))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@

defined('_JEXEC') or die;

use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\Component\Installer\Administrator\Model\InstallModel;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Factory;
use Joomla\Component\Installer\Administrator\Model\InstallModel;
use Joomla\Utilities\ArrayHelper;

/**
* Template style controller class.
Expand All @@ -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');
}

/**
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -738,4 +801,43 @@ public function extractArchive()
$this->setRedirect(Route::_($url, false));
}
}

/**
* Fetch and report updates in \JSON format, for AJAX requests
*
* @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();
}

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

$result = $model->getUpdatedList(true, true);

echo json_encode($result);

$app->close();
}
}
Loading