summaryrefslogtreecommitdiffstats
path: root/application/modules/backend/controllers/JsonController.php
blob: 61da9471d0f34ede1dfe46385a1fe3fdc4b38d01 (plain) (blame)
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
<?php

class Backend_JsonController extends Zend_Controller_Action
{
    private $_mkernel;
    private $_msources;
    private $_msystems;
    private $_mbootmedia;
    private $_mmenus;
    private $_logger;

    public function init()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender();

        $this->_mkernels = new Model_Kernels();
        $this->_mmenus = new Model_Menus();
        $this->_msources = new Model_Sources();
        $this->_msystems = new Model_Systems();
        $this->_mbootmedia = new Model_Bootmedia();


        $this->_logger = new Zend_Log();
        $w = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/debug.log');

        $this->_logger->addWriter($w);
    }

    public function indexAction()
    {
        // action body
    }

    public function kernelAction()
    {
        $kernels = $this->_mkernels->fetchAll()->toArray();
        echo (json_encode($kernels));
    }

    public function menuAction()
    {
        $menus = $this->_mmenus->fetchAll()->toArray();
        echo (json_encode($menus));
    }

    public function bootmediaAction()
    {
        $bootmedia= $this->_mbootmedia->fetchAll()->toArray();
        echo (json_encode($bootmedia));
    }

    public function sourcesAction()
    {
        $sources = $this->_msources->fetchAll()->toArray();
        echo (json_encode($sources));

    }

    public function systemsAction()
    {
        $ip = $this->getRequest()->getParam('ip');
        if (!empty($ip)) {
            $s = $this->_msystems->select();
            $s->where('source = ?', $ip);
            $systems = $this->_msystems->fetchAll($s)->toArray();
        } else {
            $systems = $this->_msystems->fetchAll()->toArray();
        }
        echo (json_encode($systems));
    }



}