~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to lib/Controller/MediaManager.php

  • Committer: Dan Garner
  • Date: 2016-02-16 14:21:08 UTC
  • mto: This revision was merged to the branch mainline in revision 484.
  • Revision ID: git-v1:63232095626c7ce5aee618d037440309aa4f8e42
UI/Model/Structure for dynamic display groups.
xibosignage/xibo#724

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
20
20
 */
21
21
namespace Xibo\Controller;
 
22
 
22
23
use Xibo\Factory\LayoutFactory;
23
24
use Xibo\Factory\ModuleFactory;
24
 
use Xibo\Service\ConfigServiceInterface;
25
 
use Xibo\Service\DateServiceInterface;
26
 
use Xibo\Service\LogServiceInterface;
27
 
use Xibo\Service\SanitizerServiceInterface;
28
 
 
29
 
/**
30
 
 * Class MediaManager
31
 
 * @package Xibo\Controller
32
 
 */
 
25
use Xibo\Helper\Sanitize;
 
26
 
 
27
 
33
28
class MediaManager extends Base
34
29
{
35
 
    /**
36
 
     * @var ModuleFactory
37
 
     */
38
 
    private $moduleFactory;
39
 
 
40
 
    /**
41
 
     * @var LayoutFactory
42
 
     */
43
 
    private $layoutFactory;
44
 
 
45
 
    /**
46
 
     * Set common dependencies.
47
 
     * @param LogServiceInterface $log
48
 
     * @param SanitizerServiceInterface $sanitizerService
49
 
     * @param \Xibo\Helper\ApplicationState $state
50
 
     * @param \Xibo\Entity\User $user
51
 
     * @param \Xibo\Service\HelpServiceInterface $help
52
 
     * @param DateServiceInterface $date
53
 
     * @param ConfigServiceInterface $config
54
 
     * @param ModuleFactory $moduleFactory
55
 
     * @param LayoutFactory $layoutFactory
56
 
     */
57
 
    public function __construct($log, $sanitizerService, $state, $user, $help, $date, $config, $moduleFactory, $layoutFactory)
58
 
    {
59
 
        $this->setCommonDependencies($log, $sanitizerService, $state, $user, $help, $date, $config);
60
 
        $this->moduleFactory = $moduleFactory;
61
 
        $this->layoutFactory = $layoutFactory;
62
 
    }
63
30
 
64
31
    public function displayPage()
65
32
    {
 
33
        // Default options
 
34
        if ($this->getSession()->get('mediamanager', 'Filter') == 1) {
 
35
            $filter_pinned = 1;
 
36
            $layout = $this->getSession()->get('mediamanager', 'layout');
 
37
            $region = $this->getSession()->get('mediamanager', 'region');
 
38
            $media = $this->getSession()->get('mediamanager', 'media');
 
39
            $filter_type = $this->getSession()->get('mediamanager', 'type');
 
40
        } else {
 
41
            $filter_pinned = 0;
 
42
            $layout = NULL;
 
43
            $region = NULL;
 
44
            $media = NULL;
 
45
            $filter_type = 0;
 
46
        }
 
47
 
66
48
        $this->getState()->template .= 'media-manager-page';
67
49
        $this->getState()->setData([
68
50
            // Users we have permission to see
69
 
            'modules' => $this->moduleFactory->query(null, ['assignable' => 1])
 
51
            'modules' => ModuleFactory::query(null, ['assignable' => 1]),
 
52
            'defaults' => [
 
53
                'layout' => $layout,
 
54
                'region' => $region,
 
55
                'media' => $media,
 
56
                'type' => $filter_type,
 
57
                'filterPinned' => $filter_pinned
 
58
            ]
70
59
        ]);
71
60
    }
72
61
 
74
63
    {
75
64
        $this->getState()->template = 'grid';
76
65
 
77
 
        $filterLayout = $this->getSanitizer()->getString('layout');
78
 
        $filterRegion = $this->getSanitizer()->getString('region');
79
 
        $filterMedia = $this->getSanitizer()->getString('media');
80
 
        $filterType = $this->getSanitizer()->getString('type');
 
66
        $filterLayout = $this->getSession()->set('mediamanager', Sanitize::getString('layout'));
 
67
        $filterRegion = $this->getSession()->set('mediamanager', Sanitize::getString('region'));
 
68
        $filterMedia = $this->getSession()->set('mediamanager', Sanitize::getString('media'));
 
69
        $filterType = $this->getSession()->set('mediamanager', Sanitize::getString('type'));
 
70
        $this->getSession()->set('mediamanager', 'Filter', Sanitize::getCheckbox('XiboFilterPinned'));
81
71
 
82
72
        $rows = array();
83
73
 
84
 
        foreach ($this->layoutFactory->query(null, ['layout' => $filterLayout]) as $layout) {
 
74
        foreach (LayoutFactory::query(null, ['layout' => $filterLayout]) as $layout) {
85
75
            /* @var \Xibo\Entity\Layout $layout */
86
76
            // We have edit permissions?
87
77
            if (!$this->getUser()->checkEditable($layout))
122
112
                        if (!$this->getUser()->checkEditable($widget))
123
113
                            continue;
124
114
 
125
 
                        // Create a module
126
 
                        $module = $this->moduleFactory->createWithWidget($widget);
127
 
 
128
115
                        // We are good to go
129
116
                        $rows[] = [
130
117
                            'layout' => $layout,
131
118
                            'region' => $region->name,
132
119
                            'playlist' => $playlist->name,
133
 
                            'widget' => $module->getName(),
134
 
                            'type' => $module->getModuleName(),
 
120
                            'widget' => $widget->getOptionValue('name', $widget->type),
 
121
                            'type' => $widget->type,
135
122
                            'displayOrder' => $widget->displayOrder,
136
123
                            'buttons' => [
137
124
                                [