Highway to PSR2
[openemr.git] / interface / modules / zend_modules / module / Application / src / Application / Helper / Javascript.php
bloba90c266978470e981e842f69680fcc2cdaae01eb
1 <?php
2 /* +-----------------------------------------------------------------------------+
3 * OpenEMR - Open Source Electronic Medical Record
4 * Copyright (C) 2014 Z&H Consultancy Services Private Limited <sam@zhservices.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 * @author Basil PT <basil@zhservices.com>
19 * +------------------------------------------------------------------------------+
22 namespace Application\Helper;
24 use Zend\View\Helper\AbstractHelper;
26 class Javascript extends AbstractHelper
28 public function __invoke()
30 switch (true) {
31 case (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] === true)):
32 case (isset($_SERVER['HTTP_SCHEME']) && ($_SERVER['HTTP_SCHEME'] == 'https')):
33 case (443 === $_SERVER['SERVER_PORT']):
34 $scheme = 'https://';
35 break;
36 default:
37 $scheme = 'http://';
38 break;
41 $basePath = str_replace("/index.php", "", $_SERVER['PHP_SELF']);
42 echo '<script type="text/javascript">';
43 echo 'var basePath = "'.$scheme.$_SERVER['SERVER_NAME'].$basePath.'";';
44 echo 'var dateFormat = "yy-mm-dd"';
45 echo '</script>';