ControllerSliders.php
2.93 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
namespace Nextend\SmartSlider3\Application\Admin\Sliders;
use Nextend\Framework\Misc\Zip\Creator;
use Nextend\Framework\Model\StorageSectionManager;
use Nextend\Framework\PageFlow;
use Nextend\Framework\Request\Request;
use Nextend\SmartSlider3\Application\Admin\AbstractControllerAdmin;
use Nextend\SmartSlider3\Application\Admin\Sliders\Pro\ViewSlidersActivate;
use Nextend\SmartSlider3\Application\Model\ModelLicense;
use Nextend\SmartSlider3\Application\Model\ModelSliders;
use Nextend\SmartSlider3\BackupSlider\ExportSlider;
use Nextend\SmartSlider3\Settings;
class ControllerSliders extends AbstractControllerAdmin {
protected function actionGettingStarted() {
if (!StorageSectionManager::getStorage('smartslider')
->get('tutorial', 'GettingStarted')) {
$view = new ViewSlidersGettingStarted($this);
$view->display();
} else {
$this->redirectToSliders();
}
}
protected function actionGettingStartedDontShow() {
StorageSectionManager::getStorage('smartslider')
->set('tutorial', 'GettingStarted', 1);
$this->redirectToSliders();
}
protected function actionIndex() {
$this->loadSliderManager();
$view = new ViewSlidersIndex($this);
$view->setPaginationIndex(max(0, intval(Request::$REQUEST->getInt('pageIndex', 0)) - 1)); /*-1 needs because beautified query string*/
$view->display();
}
protected function actionTrash() {
$view = new ViewSlidersTrash($this);
$view->display();
}
protected function actionExportAll() {
$slidersModel = new ModelSliders($this);
$groupID = (Request::$REQUEST->getVar('inSearch', false))?'*':Request::$REQUEST->getInt('currentGroupID', 0);
$sliders = $slidersModel->getAll($groupID, 'published');
$ids = Request::$REQUEST->getVar('sliders');
$files = array();
foreach ($sliders as $slider) {
if (!empty($ids) && !in_array($slider['id'], $ids)) {
continue;
}
$export = new ExportSlider($this, $slider['id']);
$files[] = $export->create(true);
}
$zip = new Creator();
foreach ($files as $file) {
$zip->addFile(file_get_contents($file), basename($file));
unlink($file);
}
PageFlow::cleanOutputBuffers();
header('Content-disposition: attachment; filename=sliders_unzip_to_import.zip');
header('Content-type: application/zip');
echo $zip->file();
PageFlow::exitApplication();
}
protected function actionImport() {
if ($this->validatePermission('smartslider_edit')) {
$groupID = Request::$REQUEST->getVar('groupID', 0);
$view = new ViewSlidersImport($this);
$view->setGroupID($groupID);
$view->display();
}
}
}