public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new self(); } return self::$instance; }
public function __construct() { parent::__construct(\Path::instance()->currentProject('*****@*****.**')); $this->collection = new \DB\Config(); $config = $this->dom; $connection_nodes = $config->getElementsByTagNameNS('http://lab.zigmoyd.net/xmlns/bong', 'connection'); $connections = array(); foreach ($connection_nodes as $connection_node) { /*{ Connection attributes*/ $name = $connection_node->getAttribute('name'); $dsn = $connection_node->getAttribute('dsn'); $user = $connection_node->getAttribute('user'); $pass = $connection_node->getAttribute('pass'); $connection = new \DB\Connection($name, $dsn, $user, $pass); /*}*/ /*{ PDO Params*/ $params = array(); $param_nodes = $connection_node->getElementsByTagNameNS('http://lab.zigmoyd.net/xmlns/bong', 'param'); foreach ($param_nodes as $param_node) { $name = $param_node->getAttribute('name'); $value = $param_node->getAttribute('value'); $param = new \DB\ConnectionParam($name, $value); $connection->addParam($param); } /*}*/ $this->collection->addConnection($connection); } $model_nodes = $config->getElementsByTagNameNS('http://lab.zigmoyd.net/xmlns/bong', 'model'); $model_node = $model_nodes->item(0); $default_connection = $model_node->getAttribute('default'); $autoconnect = constant($model_node->getAttribute('autoconnect')); $this->collection->setDefault($default_connection); $this->collection->setAutoconnect($autoconnect); //echo ">> DatabaseConfig::__construct()\n"; }
/** * @load * @param ReflectionMethod $reflection */ protected function _createFromReflection($reflection) { $this->_type = Method::SpiritMethod; parent::_createFromReflection($reflection); //{ Add Views if ($this->isPublic()) { $viewPath = \Path::instance()->evaluate(':' . $this->controller()->project()->name() . '.*' . $this->controller()->name() . '.view.-' . $this->name()); if (file_exists($viewPath)) { $dh = opendir($viewPath); $viewsFound = array(); while (false !== ($file = readdir($dh))) { if ($file != "." && $file != ".." && strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php') { $viewFilePath = rtrim($viewPath, '/') . "/{$file}"; $viewsFound[$file] = $viewFilePath; $this->addView(SpiritView::create($this, pathinfo($file, PATHINFO_FILENAME))); } } closedir($dh); if (array_key_exists('view.php', $viewsFound)) { $this->setHasDefaultView(); } } } //} }
public static function go_to($url) { if (!isset(self::$instance)) { self::$instance = new self(); } return self::$root_path . $url; }
private function _createFromReflection($projectName) { $this->_name = $projectName; $this->_dir = \Fstab::instance()->projectDirectory($projectName); $controllerBasePath = rtrim(\Path::instance()->evaluate(":{$this->_name}.apps.controller"), "/\\"); foreach (glob($controllerBasePath . "/*.php") as $filePath) { $fileName = pathinfo($filePath, PATHINFO_FILENAME); $controllerClassName = $fileName . 'Controller'; if (!class_exists($controllerClassName)) { require $filePath; } if (class_exists($controllerClassName)) { $reflection = new \ReflectionClass($controllerClassName); $this->_controllers[] = AppController::create($this, $reflection); } } $spiritBasePath = rtrim(\Path::instance()->evaluate(":{$this->_name}.spiritPath"), "/\\"); foreach (glob($spiritBasePath . "/*", GLOB_ONLYDIR) as $dirName) { $spiritName = pathinfo($dirName, PATHINFO_FILENAME); $spiritFileName = rtrim($dirName, "/\\") . '/abstractor.php'; $spiritAbstractorClassName = $spiritName . 'Abstractor'; if (!class_exists($spiritAbstractorClassName) && file_exists($spiritFileName)) { require $spiritFileName; } if (class_exists($spiritAbstractorClassName)) { $reflection = new \ReflectionClass($spiritAbstractorClassName); $this->_spirits[] = SpiritController::create($this, $reflection); } } }
public function run() { $fsm = \FSM\Engine::parse('site'); $path = Path::instance()->evaluate('common') . '/fsm.php'; ob_start(); require $path; $this->responseBuffer = ob_get_contents(); ob_end_clean(); }
public function __construct($controllerName) { $controllerPath = Path::instance()->currentProject("apps.+&{$controllerName}.@&{$controllerName}.php"); parent::__construct($controllerPath); $this->registerParam(new BongExceptionParam("controllerName", "controller Name", true)); $this->registerParam(new BongExceptionParam("controllerPath", "controller Path", true)); $this->setParam("controllerName", $controllerName); $this->setParam("controllerPath", $controllerPath); }
public function genParams() { if (!$this->_params) { $viewPath = \Path::instance()->evaluate(':' . $this->project()->name() . ".apps.layout.+{$this->name()}.@params.php"); $this->_params = Params::create($viewPath . '/params.php'); return $this->_params->generate(); } return false; }
public function genParams() { if (!$this->_hasParams) { $viewPath = \Path::instance()->evaluate(':' . $this->controller()->project()->name() . '.apps.view.+' . $this->controller()->name() . '.-' . $this->name()); $this->_params = Params::create($viewPath . '/params.php'); $this->setHasParams(); return $this->_params->generate(); } return false; }
public function __construct($controllerName, $controllerPath = null) { if (!$controllerPath) { $controllerPath = Path::instance()->currentProject("apps.+&{$controllerName}.@&{$controllerName}.php"); } if (!$controllerPath) { !($controllerPath = 'Unknown/could/not/determine/path'); } parent::__construct($controllerPath); $this->registerParam(new BongExceptionParam("controllerName", "controller Name", true)); $this->registerParam(new BongExceptionParam("controllerPath", "controller Path", true)); $this->setParam("controllerName", $controllerName); $this->setParam("controllerPath", $controllerPath); }
public function createProject($projectName, $projectDir) { ControllerTray::instance()->renderLayout = false; $this->data->success = false; $this->data->projectName = $projectName; if (!\Fstab::instance()->addProject($projectName, $projectDir)) { return false; } \Fstab::instance()->save(); $commonProject = \Path::instance()->evaluate("common.template.prj"); $projectPath = \Path::instance()->evaluate(":{$projectName}.root") . "{$projectDir}"; if (!is_dir($projectPath)) { if (!recurse_copy($commonProject, $projectPath)) { $this->data->success = false; } else { $this->data->success = true; } } }
public function module($moduleName) { $modulePath = Path::instance()->evaluate('lib.module'); if (file_exists($modulePath . "/{$moduleName}") && is_dir($modulePath . "/{$moduleName}")) { if (file_exists($modulePath . "/{$moduleName}/{$moduleName}.xml")) { if (is_readable($modulePath . "/{$moduleName}/{$moduleName}.xml")) { foreach (ModuleConf::instance()->dependencies() as $dep) { Loader::instance()->module($dep); } foreach (ModuleConf::instance()->includes() as $inc) { Loader::instance()->inc($modulePath . "/{$moduleName}/" . trim($inc, '/')); } } else { return -2; } } else { return -1; } } return 0; }
/** * @load * @param ReflectionMethod $reflection */ private function _createFromReflection($reflection) { $this->_name = $reflection->getName(); $this->_public = $reflection->isPublic(); $this->_inherited = !($reflection->getDeclaringClass()->getName() == $this->_controller->className()); foreach ($reflection->getParameters() as $paramReflection) { //Argument::create($this, $paramReflection); $this->addArgument(Argument::create($this, $paramReflection)); } //{ Add Views if ($this->isAction()) { $viewPath = \Path::instance()->evaluate(':' . $this->controller()->project()->name() . '.apps.view.+' . $this->controller()->name() . '.-' . $this->name()); if (file_exists($viewPath)) { $this->setViewDirectoryCreated(); $dh = opendir($viewPath); $viewsFound = array(); while (false !== ($file = readdir($dh))) { if ($file != "." && $file != ".." && strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php') { $viewFilePath = rtrim($viewPath, '/') . "/{$file}"; if ($file == 'layout.php') { $this->setHasLayout(); } else { if ($file == 'params.php') { $this->setHasParams(); } else { $viewsFound[$file] = $viewFilePath; $this->addView(ControllerView::create($this, pathinfo($file, PATHINFO_FILENAME))); } } } } closedir($dh); if (array_key_exists('view.php', $viewsFound)) { $this->setHasDefaultView(); } } } //} }
private static function _basePath() { return rtrim(Path::instance()->currentProject('keys'), "/"); }
private function controller() { $controllerPath = Path::instance()->currentProject('apps.+&controller.@&controller.php'); if (!$controllerPath || !file_exists($controllerPath)) { throw new ControllerNotFoundException(MemPool::instance()->get('bong.mvc.controller'), $controllerPath); } else { if (is_readable($controllerPath)) { return $controllerPath; } else { throw new ControllerNotReadableException(MemPool::instance()->get('bong.mvc.controller')); } } }
private function coordinator($spiritName) { return Path::instance()->currentProject("*{$spiritName}.@coordinator.php"); }
public function filePath() { return \Path::instance()->evaluate(':' . $this->_controller->project()->name() . '.apps.view.+' . $this->_controller->name() . '*****@*****.**'); }
protected function _create($name, $methods = array()) { $this->_name = $name; parent::_create($name . 'Abstractor', $methods); $this->_filePath = Path::instance()->evaluate(':' . $this->project()->name() . ".apps.spirit.@{$name}.php"); }
<h6 class="bong-admin-component-headline bong-admin-component-session-headline">User Sessions</h6> <?php $sessionDir = \Path::instance()->currentProject('run'); $_it = new DirectoryIterator("glob://{$sessionDir}/*.usr"); foreach ($_it as $_file) { ?> <a class="bong-admin-component-xdo bong-admin-component-session" href="#"><?php echo $_file->getBasename('.usr'); ?> <script type="text/bongscript" event="click"> bong.href("<?php echo Resource::link(); ?> /+SessionList.res/desc/<?php echo $_file->getBasename('.usr'); ?> ").eval() </script> </a> <?php } ?> <a class="bong-admin-component-xdo-more"></a>
/** * also set's the Module Name and Module Path * @param String $name */ public function __construct($name) { parent::set("moduleName", $name); parent::set("modulePath", Path::instance()->evaluate("lib.module") . "/{$name}"); }
/** * Slash the Url to Get URL Parts. * e.g. exploding it with '/' will extract all URL Parts in an array */ MemPool::instance()->set("bong.url.path", $_SERVER['PATH_INFO']); /** * \required instances * Fstab Project details * Path Path details * Conf Configuration details * URLAnalyzer URL details */ $fstab = Fstab::instance(); print_r($fstab->defaultProjectName()); echo PHP_EOL; print_r($fstab->defaultProject()); print_r($fstab->projectNames()); print_r($fstab->projects()); print_r($fstab->projectExists("bong")); echo PHP_EOL; print_r($fstab->projectLocation("main")); echo PHP_EOL; var_dump($fstab->project("main")->exists()); echo "\n--------------------------\n"; $path = Path::instance(); var_dump($path->evaluate("etc.conf")); var_dump($path->evaluate(":mkt")); var_dump($path->evaluate("project:mkt")); var_dump($path->evaluate(":mkt.etc.conf")); $conf = Conf::instance(); var_dump($conf->evaluate("urlpatterns.sync"));
public function generate($genPresentation = true) { $methodStr = ""; foreach ($this->_methods as $method) { $methodStr .= $method->generate(true); } $interfaces = $this->interfaces(); $interfaceStr = count($interfaces) >= 1 ? 'implements ' . implode(', ', $interfaces) : ''; $controllerBase = $this->controllerBase(); $classStr = <<<CLASSSTR <?php /** * \\controller {$this->name()} */ class {$this->className()} extends {$controllerBase} {$interfaceStr}{ {$methodStr} } ?> CLASSSTR; if ($genPresentation) { $presentationDir = \Path::instance()->evaluate(':' . $this->project()->name() . '.apps.view.+' . $this->name()); if (!is_dir($presentationDir)) { if (!@mkdir($presentationDir, 0777, true)) { return false; } } } $fp = @fopen($this->filePath(), 'w'); if (!$fp) { return false; } fwrite($fp, $classStr, strlen($classStr)); fclose($fp); return true; }
private function controller() { return Path::instance()->currentProject("apps.+{$this->navigation->controllerName}.@{$this->navigation->controllerName}.php"); }
private function filePath() { return \Path::instance()->currentProject('run') . '/fsm'; }
<?php $conf_path = \Path::instance()->currentProject('*****@*****.**'); if (file_exists($conf_path)) { \DB\DatabaseConfig::instance(); }
public function load() { $sessionDir = \Path::instance()->currentProject('run'); $filePath = $sessionDir . "/" . session_id() . ".usr"; if (file_exists($filePath) && is_readable($filePath)) { $buff = unserialize(file_get_contents($filePath)); $this->ClientSignature = $buff->c; $this->IpAddress = $buff->i; $this->SessionId = $buff->s; $this->State = $buff->t; $this->xdos = $buff->x; $this->LastAccess = $buff->l; $this->requestHistory = $buff->h; $this->store = $buff->r; $this->csrf_rand = $buff->csrf_rand; $this->csrf_token = $buff->csrf_token; return true; } return false; }
public function filePath() { return \Path::instance()->evaluate(':' . $this->method()->controller()->project()->name() . '.*' . $this->method()->controller()->name() . '.view.-' . $this->method()->name() . '.@' . $this->name() . '.php'); }
public function run() { if (Fstab::instance()->projectExists($this->projectName)) { $projectDir = Path::instance()->evaluate(':' . $this->projectName); if (is_dir($projectDir)) { $evPath = $this->navigation->systemResource ? '' : ":{$this->projectName}."; $evPath .= "share."; switch ($this->navigation->resourceType) { case 'img': $evPath .= 'image'; break; case 'css': $evPath .= 'css'; break; case 'js': $evPath .= 'javascript'; break; case 'xslt': $evPath .= 'xslt'; break; case 'scrap': $evPath .= 'scrap'; break; default: } $evPath .= ".@{$this->navigation->estimatedContentName}"; $resourcePath = Path::instance()->evaluate($evPath); if (is_file($resourcePath)) { $mime = mime_content_type($resourcePath); switch ($this->navigation->resourceType) { case 'img': http::contentType($mime); break; case 'css': http::contentType('text/css'); break; case 'js': http::contentType('text/javascript'); break; case 'xslt': http::contentType('text/xml+xslt'); break; case 'scrap': http::contentType('text/plain'); break; default: } switch ($this->navigation->resourceType) { case 'img': $this->responseBuffer = file_get_contents($resourcePath); break; default: ob_start(); require $resourcePath; $this->responseBuffer = ob_get_contents(); ob_end_clean(); } } else { throw new FileNotFoundException($resourcePath ? $resourcePath : 'null <Resource Path Could not be Resolved> '); } } else { throw new ProjectDirNotFoundException($this->projectName); } } else { throw new ProjectNotFoundException($this->projectName); } }
private static function _filePath($name, $sessioned) { return rtrim(Path::instance()->currentProject('backend'), "/") . '/' . md5(($sessioned ? session_id() : '') . $name); }
public static function parse($conf, $inputs) { $confPath = \Path::instance()->currentProject('etc.conf.@' . $conf . '.conf.xml'); if (!file_exists($confPath)) { return false; } $dom = new \DOMDocument("1.0", "utf-8"); $dom->load($confPath); $xpath = new \DOMXPath($dom); $xpath->registerNamespace('bong', 'http://lab.zigmoyd.net/xmlns/bong'); $fieldNodes = $xpath->query("//bong:form/bong:field"); $form = new Form(); foreach ($fieldNodes as $fieldNode) { $field = null; $name = self::__attrValue($fieldNode, "name"); $default = self::__attrValue($fieldNode, "default"); if ($name) { $field = new Field($name); $required = self::__attrValue($fieldNode, "required", 'false'); if ($required == 'true') { $field->setRequiredFlag(true); } if (isset($inputs[$name])) { $field->setValue(strlen($inputs[$name]) > 0 ? $inputs[$name] : ($default ? $default : '')); } $ruleNodes = $xpath->query("bong:criteria", $fieldNode); foreach ($ruleNodes as $ruleNode) { $ruleName = self::__attrValue($ruleNode, 'name'); if ($ruleName) { $arg = self::__attrValue($ruleNode, 'value'); $error = self::__attrValue($ruleNode, 'msg'); $rule = new RuleSet($ruleName, $error, $arg); $field->addRuleSet($rule); } } } $form->addField($field); } return $form; }