/
copy.php
60 lines (54 loc) · 2.15 KB
/
copy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace Concrete\Controller\SinglePage\Dashboard\System\Multilingual;
use Concrete\Controller\Panel\Multilingual;
use Concrete\Core\Foundation\Queue\Queue;
use Concrete\Core\Multilingual\Page\Section\Processor\MultilingualProcessorTarget;
use Concrete\Core\Multilingual\Page\Section\Processor\Processor;
use Concrete\Core\Multilingual\Page\Section\Section;
use Concrete\Core\Page\Controller\DashboardPageController;
use Concrete\Core\Page\Controller\DashboardSitePageController;
use Concrete\Core\User\User;
defined('C5_EXECUTE') or die("Access Denied.");
class Copy extends DashboardSitePageController
{
public function view()
{
$this->set('locales', $this->getSite()->getLocales());
}
public function tree_copied()
{
$this->set('message', t('Multilingual tree copied. You might consider rescanning links in the section you copied to.'));
$this->view();
}
public function links_rescanned()
{
$this->set('message', t('Multilingual tree links rescanned.'));
$this->view();
}
public function rescan_locale()
{
if ($this->token->validate('rescan_locale')) {
$u = $this->app->make(User::class);
if ($u->isSuperUser()) {
\Core::make('cache/request')->disable();
$section = Section::getByID($_REQUEST['locale']);
$target = new MultilingualProcessorTarget($section);
$processor = new Processor($target);
if (!empty($_POST['process'])) {
foreach ($processor->receive() as $task) {
$processor->execute($task);
}
$obj = new \stdClass();
$obj->totalItems = $processor->getTotalTasks();
echo json_encode($obj);
exit;
} else {
$processor->process();
}
$totalItems = $processor->getTotalTasks();
\View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d task", "%d tasks", $totalItems)));
exit;
}
}
}
}