public function getController() { $router = new Router(); $xml = new \DOMDocument(); $xml->load(__DIR__ . '/../../App/' . $this->name . '/Config/route.xml'); $routes = $xml->getElementByTagName("route"); foreach ($routes as $route) { $vars = []; if ($route->hasAttribute('vars')) { $vars = explode(',', $route->getAttribute('vars')); } $router->addRoute(new Route($route->getAttribute('url'), $route->getAttribute('module'), $route->getAttribute('action'), $vars)); } try { $matched_route = $router->getRoute($this->httpRequest->requestURI()); } catch (\RuntimeException $exception) { if ($exception->getCode() == Router::NO_ROUTE) { $this->httpResponse->redirect404(); } } // Add variables in tab: $_GET $_GET = array_merge($_GET, $matched_route->module(), $matched_route->action()); // Instancie the controller $controller_class = 'App\\' . $this->name . '\\Modules\\' . $matched_route->module() . '\\' . $matched_route->module() . 'Controllers'; return new $controller_class($this, $matched_route->module(), $matched_route->action()); }
<?php $your_google_calendar = "https://www.google.com/calendar/embed?src=usa__en@holiday.calendar.google.com&gsessionid=OK"; $url = parse_url($your_google_calendar); $google_domain = $url['scheme'] . '://' . $url['host'] . dirname($url['path']) . '/'; // Load and parse Google's raw calendar $dom = new DOMDocument(); $dom->loadHTMLfile($your_google_calendar); // Change Google's CSS file to use absolute URLs (assumes there's only one element) $css = $dom->getElementByTagName('link')->item(0); $css_href = $css->getAttributes('href'); $css->setAttributes('href', $google_domain . $css_href); // Change Google's JS file to use absolute URLs $scripts = $dom->getElementByTagName('script')->item(0); foreach ($scripts as $script) { $js_src = $script->getAttributes('src'); if ($js_src) { $script->setAttributes('src', $google_domain . $js_src); } } // Create a link to a new CSS file called custom_calendar.css $element = $dom->createElement('link'); $element->setAttribute('type', 'text/css'); $element->setAttribute('rel', 'stylesheet'); $element->setAttribute('href', 'custom_calendar.css'); // Append this link at the end of the element $head = $dom->getElementByTagName('head')->item(0); $head->appendChild($element); // Export the HTML echo $dom->saveHTML();