public static function parse(\DOMNode $node) { if ($node->nodeName == self::getNodeName()) { $mime = XMLUtils::getAttributeByName($node, "mime") != null ? XMLUtils::getAttributeByName($node, "mime")->value : null; $code = XMLUtils::getAttributeByName($node, "code") != null ? XMLUtils::getAttributeByName($node, "code")->value : null; switch ($type = XMLUtils::getAttributeByName($node, "type")->value) { case "file": if (is_file($file = FileUtils::getAbsolutePath($node->nodeValue, Star::instance()->getRootDirectory()))) { switch ($extension = FileUtils::getExtension($file)) { case "html": return new HTMLFileView($file, $mime, $code); case "php": return new PHPFileView($file, $mime, $code); /* case "twig": return new TwigFileView($file, $mime, $code); */ /* case "twig": return new TwigFileView($file, $mime, $code); */ default: throw new \Exception("Unhandled file type '" . $extension . "' for file '" . $file . "'"); } } throw new \Exception("No such file '" . $file . "'"); /* case "class": if(ClassLoader::getInstance()->classInstanceOf($node->nodeValue, "AbstractView")){ return ClassLoader::getInstance()->newInstance($node->nodeValue); } throw new Exception("Class '" . $node->nodeValue . "' must be a subclass of '" . ClassLoader::getInstance()->getClassByName('AbstractView') . "'"); */ /* case "class": if(ClassLoader::getInstance()->classInstanceOf($node->nodeValue, "AbstractView")){ return ClassLoader::getInstance()->newInstance($node->nodeValue); } throw new Exception("Class '" . $node->nodeValue . "' must be a subclass of '" . ClassLoader::getInstance()->getClassByName('AbstractView') . "'"); */ default: throw new \Exception("Unhandled type '" . $type . "', expecting type in 'file' or 'class'"); } } throw new \Exception("Unexpected node '" . $node->nodeName . "', expected '" . self::getNodeName() . "'"); }
<?php /* * TODO: deleting all calls to Controller::getUrl() * integration of POST variables * validator declarations * target execution review + redirect * complete param * */ session_start(); include 'vendor/autoload.php'; use PierreLemee\Star\Star; use PierreLemee\Star\Test\Actions\TestAction; Star::load(__DIR__ . "/test/data/website.xml")->process($_SERVER['REQUEST_URI']);
public function __call($name, $arguments) { switch ($name) { case "root": return Star::instance()->getRootDirectory(); case "current": return $this->getCurrent(); case "in": return $this->getInputs(); case "out": return $this->getOutputs(); case "errors": return $this->getErrors(); case "modals": return $this->getMessages(); } }