3 /* +-----------------------------------------------------------------------------+
4 * Copyright 2016 matrix israel
5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 3
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see
15 * http://www.gnu.org/licenses/licenses.html#GPL
16 * @author Oshri Rozmarin <oshri.rozmarin@gmail.com>
17 * +------------------------------------------------------------------------------+
20 namespace Multipledb\Controller
;
22 use Zend\InputFilter\InputFilter
;
23 use Zend\Mvc\Controller\AbstractActionController
;
24 use Application\Listener\Listener
;
25 use Zend\Mvc\Controller\ActionController
;
26 use Zend\View\Model\ViewModel
;
28 class BaseController
extends AbstractActionController
32 * path to file after base pass from ModuleconfigController
35 protected $jsFiles = array(
37 '/jquery-min-1-9-1/index.js',
39 '/bootstrap-3-3-4/dist/js/bootstrap.min.js',
40 '/jquery-validation-1-13-0/dist/jquery.validate.min.js',
45 * path to file after base pass from ModuleconfigController
48 protected $cssFiles = array(
50 '/bootstrap-3-3-4/dist/css/bootstrap.min.css',
53 public function __construct()
55 //load translation class
56 $this->translate
= new Listener();
60 * Add js files per method.
61 * @param $method __METHOD__ magic constant
64 protected function getJsFiles()
69 return $this->jsFiles
;
73 * Add css files per method.
74 * @param $method __METHOD__ magic constant
77 protected function getCssFiles()
82 return $this->cssFiles
;
88 * @return mixed params object
90 protected function getRequestedParams()
93 return $this->getRequest()->getQuery() ;
96 protected function getRequestedParamsArray()
99 return (array)$this->getRequest()->getQuery() ;
102 * @return post params as array
104 protected function getPostParamsArray()
106 $putParams = array();
107 parse_str($this->getRequest()->getContent(), $putParams);
111 * return current user id
114 protected function getUserId()
117 return $_SESSION['authUserID'];
122 * @param bool $convertToJson
123 * @param int $responsecode
124 * @return \Zend\Stdlib\ResponseInterface
125 * @comment to use this function return this $response in your controller
127 public function responseWithNoLayout($data, $convertToJson = true, $responsecode = 200)
130 $response = $this->getResponse();
131 $response->setStatusCode($responsecode);
132 if ($convertToJson) {
133 $response->setContent(json_encode($data));
135 $response->setContent($data);