Skip to content

Commit

Permalink
Finish Save As Copy implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
joomdonation committed Feb 27, 2021
1 parent ab53782 commit 07454ef
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Expand Up @@ -666,8 +666,6 @@ public function save($data)
{
$input = Factory::getApplication()->input;
$filter = \JFilterInput::getInstance();
$db = $this->getDbo();
$user = Factory::getUser();

if (isset($data['metadata']) && isset($data['metadata']['author']))
{
Expand Down Expand Up @@ -778,6 +776,13 @@ public function save($data)

if ($data['title'] == $origTable->title)
{
// If user did not change title before press Save as Copy in frontend, set Alias to original article
// alias to have the system generates Title and Alias automatically for the creating article
if (Factory::getApplication()->isClient('site'))
{
$data['alias'] = $origTable->alias;
}

list($title, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
$data['title'] = $title;
$data['alias'] = $alias;
Expand Down
5 changes: 5 additions & 0 deletions components/com_content/src/Controller/ArticleController.php
Expand Up @@ -368,6 +368,7 @@ public function save($key = null, $urlVar = 'a_id')
{
$result = parent::save($key, $urlVar);
$app = Factory::getApplication();
$task = $this->getTask();
$articleId = $app->input->getInt('a_id');

// Load the parameters.
Expand All @@ -391,6 +392,10 @@ public function save($key = null, $urlVar = 'a_id')
$this->setRedirect(Route::_('index.php?Itemid=' . $menuitem . $lang, false));
}
}
elseif ($task == 'save2copy')
{
// Redirect to the article page, use the redirect url set from parent controller
}
else
{
// If ok, redirect to the return page.
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/tmpl/form/edit.php
Expand Up @@ -162,7 +162,7 @@
<?php echo Text::_('JSAVE'); ?>
</button>
<?php if ($this->showSaveAsCopy) : ?>
<button type="button" class="btn btn-primary" data-submit-task="article.save">
<button type="button" class="btn btn-primary" data-submit-task="article.save2copy">
<span class="icon-check" aria-hidden="true"></span>
<?php echo Text::_('JSAVEASCOPY'); ?>
</button>
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/MVC/Controller/FormController.php
Expand Up @@ -749,7 +749,7 @@ public function save($key = null, $urlVar = null)
{
case 'apply':
// Set the record data in the session.
$recordId = $model->getState($this->context . '.id');
$recordId = $model->getState($model->getName() . '.id');
$this->holdEditId($context, $recordId);
$app->setUserState($context . '.data', null);
$model->checkout($recordId);
Expand Down

0 comments on commit 07454ef

Please sign in to comment.