-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdminController.php
executable file
·70 lines (53 loc) · 1.79 KB
/
AdminController.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
61
62
63
64
65
66
67
68
69
70
<?php
/**
* @package ImpressPages
*/
/**
* User: icampana
* Date: 3/3/15
* Time: 00:00 AM
*/
namespace Plugin\MasonryGrid;
class AdminController
{
/**
* MasonryGrid.js ask to provide widget management popup HTML. This controller does this.
* @return \Ip\Response\Json
* @throws \Ip\Exception\View
*/
public function widgetPopupHtml()
{
$versionParts = explode('.', \Ip\Application::getVersion());
if (version_compare(\Ip\Application::getVersion(), '4.2.1') < 0) {
return new \Ip\Response('This widget can be used on ImpressPages 4.2.1 or later.');
}
$widgetId = ipRequest()->getQuery('widgetId');
$widgetRecord = \Ip\Internal\Content\Model::getWidgetRecord($widgetId);
$widgetData = $widgetRecord['data'];
$plugin = ipRoute()->plugin();
//Render form and popup HTML
$viewData = array(
'gridUrl' => ipActionUrl(array('aa' => $plugin . '.grid', 'disableAdminNavbar' => 1, 'widgetId' => $widgetId))
);
$popupHtml = ipView('view/editPopup.php', $viewData)->render();
$data = array(
'popup' => $popupHtml
);
//Return rendered widget management popup HTML in JSON format
return new \Ip\Response\Json($data);
}
/**
* Check widget's posted data and return data to be stored or errors to be displayed
*/
public function grid()
{
$widgetId = ipRequest()->getQuery('widgetId');
ipAddCss('assets/masonryManagement.css');
$config = Config::grid();
if (!empty($widgetId)) {
$config['filter'] = ' `widgetId` = ' . (int) $widgetId;
$config['gatewayData'] = array('widgetId' => $widgetId);
}
return ipGridController($config);
}
}