/** * Browsing subfolders after a specific file * @var string $path * @var string $search * @return bool */ static function autoSearch($path, $search) { if (self::$platform == "windows") { $seperator = "\\"; $path = str_replace("/", $seperator, $path); } else { $seperator = "/"; $path = str_replace("\\", $seperator, $path); } $dir = self::$relative_path . $path; if (!is_dir($dir)) { return false; } $directoryContent = scandir($dir); if (in_array($search, $directoryContent)) { self::$searchResult = $path; return true; } else { $hasDirectory = false; foreach ($directoryContent as $file) { if (is_dir($dir . $file) && $file != "." && $file != "..") { if (!empty(self::$namespaceRange)) { if (in_array($file, self::$namespaceRange)) { $dirs[] = $path . $file; $hasDirectory = true; } } else { $dirs[] = $path . $file; $hasDirectory = true; } } } if ($hasDirectory == true && !empty($dirs)) { foreach ($dirs as $directory) { if (self::autoSearch($directory . $seperator, $search) == true) { return true; } } return false; } else { return false; } } }
$pr = new PWEL_ROUTING(); $db = new eDB("."); $select = new eDB_Select("docsdb", array("type" => "component")); foreach ($select->result as $row) { print '<li><a href="' . $pc->validateLink($row["url"]) . '">' . $row["name"] . '</a></li>'; if ($param == str_replace("/", "", $row["url"])) { $name = $row["name"]; } } ?> </ul> <div class="smalltitle">Browse Collection</div> <ul> <?php $pc = new PWEL_CONTROLLER(); $pr = new PWEL_ROUTING(); $db = new eDB("."); $select = new eDB_Select("docsdb", array("type" => "collection")); foreach ($select->result as $row) { print '<li><a href="' . $pc->validateLink($row["url"]) . '">' . $row["name"] . '</a></li>'; if ($param == str_replace("/", "", $row["url"])) { $name = $row["name"]; } } ?> </ul> </div> <div class="content"> <div class="smalltitle"><?php print $name; ?>
/** * Inizialize the cool framework */ public function initialize() { PWEL_ROUTING::locateRelativePath(); $this->getConfig(); try { if (self::$configured == false) { $this->autoConfigRouting(); } $routing = new PWEL_ROUTING(); $routing->loadAutoInject(); $components = new PWEL_COMPONENTS(func_get_args()); $routing->start(); $this->disablePlugins(); } catch (Exception $e) { if (PWEL::$config['pwel']['status'] == strtolower('development')) { print '<div style="padding:5px;">'; print '<strong>Message:</strong> ' . $e->getMessage() . '<br />'; print '<strong>File:</strong> ' . $e->getFile() . '<br />'; print '<strong>Line:</strong> ' . $e->getLine() . '<br />'; print '<strong>Trace:</strong> <pre><code>' . $e->getTraceAsString() . '</code></pre><br />'; print '</div>'; } else { $routing = new PWEL_ROUTING(); $routing->displayError(); } } }
public function _execute() { $this->checkValues(); $routing = new PWEL_ROUTING(); if (!isset($this->setRoutes['class'])) { $check = $routing->checkIncludeControllerClass(PWEL_ROUTING::$start_controller); $this->displayController(new $check()); PWEL_ROUTING::$controllerNotFound = false; PWEL_ROUTING::$routed = true; return true; } if (empty(self::$variables) || empty(self::$variables['class'])) { $check = $routing->checkIncludeControllerClass(PWEL_ROUTING::$start_controller); if ($check) { } else { $check = $routing->checkIncludeControllerClass(PWEL_ROUTING::$error_controller); if (!$check) { return; } } $this->displayController(new $check(), 'startController'); PWEL_ROUTING::$controllerNotFound = false; } else { PWEL_ROUTING::$controllerNotFound = false; $check = $routing->checkIncludeControllerClass(self::$variables['class']); if ($check) { } else { $check = $routing->checkIncludeControllerClass(PWEL_ROUTING::$error_controller); PWEL_ROUTING::$controllerNotFound = true; if (!$check) { return; } } $this->displayController(new $check()); } // Routing executed PWEL_ROUTING::$routed = true; }
/** * Returns the path to the displayed file * @param string $filename * @return string */ private function getDisplayPath($filename) { if (preg_match_all('/(.*)\\.(php|html|phtml)/i', $filename, $result)) { if (isset($result[2])) { $filename = $result[1][0]; $extension = "." . $result[2][0]; } else { $extension = ".php"; } } else { $extension = ".php"; } PWEL_ROUTING::correctNamespace(); if (PWEL_ROUTING::$autoSearch == true) { if (isset($extension)) { $searchname = $filename . $extension; } else { $searchname = $filename; } PWEL_ROUTING::autoSearch('app/views/', $searchname); PWEL_ROUTING::$searchResult = str_replace('app/views/', '', PWEL_ROUTING::$searchResult); $namespace = null; } else { $namespace = PWEL_ROUTING::$namespace; } //Set & Correct path $path = PWEL_ROUTING::$relative_path . 'app/views/' . PWEL_ROUTING::$searchResult . $namespace . "{$filename}{$extension}"; return str_replace('//', '/', $path); }
/** * Execute the components * * @var string $typeOf */ private function execComponents($typeOf) { $routing = new PWEL_ROUTING(); $components = $this->prepareComponent($typeOf); //Execute components at start of function if (!empty($components['start'])) { foreach ($components['start'] as $component) { $component->_execute(); if ($component->_standAlone == false) { $func = self::$componentCalls[$typeOf]; $routing->{$func}(); } else { if (PWEL_ROUTING::$routed == false) { $routing->routeCurrentDir(); } } } } ///////////////////////////////////////// //Execute components at end of function if (!empty($components['end'])) { foreach ($components['end'] as $component) { if ($component->_standAlone == false) { $func = self::$componentCalls[$typeOf]; $routing->{$func}(); } else { if (PWEL_ROUTING::$routed == false) { $routing->routeCurrentDir(); } } $component->_execute(); } } /////////////////////////////////////// }
/** * Function which will be automaticly loaded * Execute the component */ public function _execute() { $routing = new PWEL_ROUTING(); $relativePath = $routing->requestRelativePath(); if (self::$visible == true && PWEL_ROUTING::$controllerNotFound == false) { PWEL_ROUTING::autoSearch('app/views/', self::$file); #var_dump(PWEL_ROUTING::$searchResult); $path = $relativePath . PWEL_ROUTING::$searchResult . self::$file; if (file_exists($path)) { $this->display(self::$file, (array) self::$variables); } else { throw new Exception("File: <i>{$path}</i> doenst exist.<br /> <strong>Using '" . "PWEL_ROUTING::\$namespaceRange' and missing adding " . "directory to file?</strong>"); } } }