| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | namespace Http; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | use \Psr\Http\Message\ServerRequestInterface as Request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use \Psr\Http\Message\ResponseInterface as Response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | require 'vendor/autoload.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | require_once('static.js_css.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | class WebPage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     public $body = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     protected $templateName = 'main.html'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     public function __construct($title) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |         $this->settings = \Settings::getInstance(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |         $this->loader = new \Twig_Loader_Filesystem(dirname(__FILE__).'/../templates'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         $twigSettings = array('cache' => '/var/php_cache/twig'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |         if(isset($GLOBALS['TWIG_CACHE'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |             $twigSettings = $twigSettings = array('cache' => $GLOBALS['TWIG_CACHE']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         $this->twig = new \Twig_Environment($this->loader, $twigSettings); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $this->content = array('pageTitle' => $title); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         $this->user = \FlipSession::getUser(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         $this->content['header'] = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         $this->content['header']['sites'] = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         $wwwUri = $this->settings->getGlobalSetting('www_url', 'https://www.burningflipside.com'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $this->content['header']['sites']['Profiles'] = $this->settings->getGlobalSetting('profiles_url', 'https://profiles.burningflipside.com/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         $this->content['header']['sites']['WWW'] = $wwwUri; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $this->content['header']['sites']['Pyropedia'] = $this->settings->getGlobalSetting('wiki_url', 'https://wiki.burningflipside.com'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $this->content['header']['sites']['Secure'] = $this->settings->getGlobalSetting('secure_url', 'https://secure.burningflipside.com/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $aboutUrl = $this->settings->getGlobalSetting('about_url', $wwwUri.'/about'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $this->content['header']['right']['About'] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |           'url' => $aboutUrl, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |           'menu' => $this->settings->getGlobalSetting('about_menu', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             'Burning Flipside' => $wwwUri.'/about/event', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             'AAR, LLC' => $wwwUri.'/organization/aar', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             'Privacy Policy' => $wwwUri.'/about/privacy' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         ))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $this->profilesUrl = $this->settings->getGlobalSetting('profiles_url', 'https://profiles.burningflipside.com/'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $this->registerUrl = $this->settings->getGlobalSetting('register_url', $this->profilesUrl.'/register.php'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $this->resetUrl = $this->settings->getGlobalSetting('reset_url', $this->profilesUrl.'/reset.php'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         $this->loginUrl = $this->settings->getGlobalSetting('login_url', $this->profilesUrl.'/login.php'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 49 |  | View Code Duplication | 	if($this->user === false || $this->user === null) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             if(isset($_SERVER['REQUEST_URI']) && strstr($_SERVER['REQUEST_URI'], 'logout.php') === false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |                 $this->addLink('Login', $this->loginUrl); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             $this->addLink('Logout', $this->settings->getGlobalSetting('logout_url', $this->profilesUrl.'/logout.php')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             $this->addLinks(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $this->minified = 'min'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $this->cdn      = 'cdn'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         if($this->settings->getGlobalSetting('use_minified', true) == false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             $this->minified = 'no'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         if($this->settings->getGlobalSetting('use_cdn', true) == false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             $this->cdn = 'no'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             $this->content['useCDN'] = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     public function addTemplateDir($dir, $namespace) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         $this->loader->addPath($dir, $namespace); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     public function setTemplateName($name) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $this->templateName = $name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                        
                            
            
                                                                    
                                                                                                        
            
            
                | 85 |  | View Code Duplication |     public function addCSS($uri) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |         if(!isset($this->content['css'])) | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |         { | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |             $this->content['css'] = array($uri); | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |             return; | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |         array_push($this->content['css'],$uri); | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * Add a JavaScript file from its src URI | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      * @param string $uri The webpath to the JavaScript file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 100 |  | View Code Duplication |     public function addJS($uri) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         if(!isset($this->content['js'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |             $this->content['js'] = array($uri); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         array_push($this->content['js'],$uri); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * Add a JavaScript file from a set of files known to the framework | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |      * @param string $jsFileID the ID of the JS file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      * @param boolean $async Can the JS file be loaded asynchronously? | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     public function addWellKnownJS($jsFileID) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         global $jsArray; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         $src = $jsArray[$jsFileID][$this->cdn][$this->minified]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         $this->addJS($src); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |      * Add a CSS file from a set of files known to the framework | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |      * @param string $cssFileID the ID of the CSS file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     public function addWellKnownCSS($cssFileID) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         global $cssArray; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         $src = $cssArray[$cssFileID][$this->cdn][$this->minified]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         $this->addCSS($src); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |      * Add a link to the header | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |      * @param string $name The name of the link | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |      * @param boolean|string $url The URL to link to | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |      * @param boolean|array $submenu Any submenu items for the dropdown | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     public function addLink($name, $url = false, $submenu = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         $data = array('url' => $url); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |         if(is_array($submenu)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |             $data['menu'] = $submenu; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |         $this->content['header']['right'] = array($name => $data)+$this->content['header']['right']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     /** Notification that is green for success */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     const NOTIFICATION_SUCCESS = 'alert-success'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |     /** Notification that is blue for infomrational messages */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     const NOTIFICATION_INFO    = 'alert-info'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     /** Notification that is yellow for warning */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |     const NOTIFICATION_WARNING = 'alert-warning'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     /** Notification that is red for error */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     const NOTIFICATION_FAILED  = 'alert-danger'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |      * Add a notification to the page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |      * @param string $message The message to show in the notifcation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |      * @param string $severity The severity of the notifcation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |      * @param boolean $dismissible Can the user dismiss the notificaton? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     public function addNotification($message, $severity = self::NOTIFICATION_INFO, $dismissible = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         if(!isset($this->content['notifications'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |           $this->content['notifications'] = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         array_push($this->content['notifications'], array('msg'=>$message, 'sev'=>$severity, 'dismissible'=>$dismissible)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     protected function addLinks() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |     protected function getContent() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         if(!isset($this->content['body'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |           $this->content['body'] = $this->body; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 	//Add page JS just before rednering so it is after any added by the page explicitly | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |         $this->addJS('js/'.basename($_SERVER['SCRIPT_NAME'], '.php').'.js'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         return $this->twig->render($this->templateName, $this->content); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |     public function handleRequest($request, $response, $args) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         $body = $response->getBody(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |         $body->write($this->getContent()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         return $response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |     public function printPage() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         echo $this->getContent(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |      * Get the currently requested URL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |      * @return string The full URL of the requested page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |      * @SuppressWarnings("Superglobals") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 211 |  | View Code Duplication |     public function currentURL() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         if(!isset($_SERVER['REQUEST_URI'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |             return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |         $requestURI = $_SERVER['REQUEST_URI']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         if($requestURI[0] === '/') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |             $requestURI = substr($requestURI, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         return 'http'.(isset($_SERVER['HTTPS']) ? 's' : '').'://'.$_SERVER['HTTP_HOST'].'/'.$requestURI; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 225 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 226 |  |  |  | 
            
                        
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: