/** * @return array */ public function getModules() { if (!isset($this->Modules)) { $AccessLevels = implode(',', Factory::getUser()->getAuthorizedLevels()); $dbh = Factory::getDBH(); $CurrentMenuID = Factory::getRouter()->getCurrentMenuID(); if ($CurrentMenuID) { $MenuIDs = implode(',', $this->getAvailableMenuIDs($CurrentMenuID)); } else { $MenuIDs = (int) $this->getMainMenuID(); } $stmt = $dbh->prepare("SELECT mdl.ModuleID,mdl.Module FROM Module mdl\n\t\t\t\t\t\t\tINNER JOIN ModuleMenu mdlm ON mdlm.ModuleID = mdl.ModuleID\n\t\t\t\t\t\t\tWHERE mdl.blStatus = 1 AND mdl.ApplicationID = :AppID AND mdl.AccessLevelID IN ({$AccessLevels}) AND (mdlm.MenuID IN ({$MenuIDs}) OR mdlm.MenuID = 0) AND mdlm.Visible != 0 GROUP BY mdl.ModuleID ORDER BY Ordering"); try { $stmt->bindValue(':AppID', Factory::getApplication()->getApplicationID(), PDO::PARAM_STR); $stmt->execute(); $arModules = []; foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $Module) { $Class = '\\Modules\\' . $Module['Module'] . '\\' . $Module['Module']; /** @var Module $Object */ $Object = new $Class($dbh, $Module); array_push($arModules, $Object); $Object->initialize(); } $this->Modules = $arModules; } catch (PDOException $e) { $dbh->catchException($e, $stmt->queryString); } } return $this->Modules; }
/** * Redirect the Application * Calls the Router::getURL() method * * @param string $Route * @param array $Parameters * @param null $Fragment */ public function redirect($Route, $Parameters = [], $Fragment = null) { Factory::getEventManager()->dispatch('Application.onRedirect'); header('Location: ' . Factory::getRouter()->getURL($Route, $Parameters, $Fragment)); exit; }
/** * @return mixed */ public function getComponent() { if (!isset($this->Component)) { $dbh = Factory::getDBH(); $_Component = Factory::getRouter()->getRoute('Component'); $_Controller = Factory::getRouter()->getRoute('Controller'); $Action = Factory::getRouter()->getRoute('Action'); $ID = Factory::getRouter()->getRoute('ID'); try { $stmt = $dbh->prepare('SELECT * FROM Component WHERE ApplicationID = :AppID AND blStatus = 1 AND Component = :Component;'); try { $stmt->bindValue(':AppID', $this->ApplicationID, PDO::PARAM_STR); $stmt->bindValue(':Component', (string) ucfirst($_Component), PDO::PARAM_STR); $stmt->execute(); $Component = new Object($stmt->fetch(PDO::FETCH_OBJ)); } catch (PDOException $e) { $dbh->catchException($e, $stmt->queryString); throw new Exception('EpsilonCMS cannot Load Component DB'); } if ($Component->get('ComponentID')) { $AccessLevels = Factory::getUser()->getAuthorizedLevels(); /** Verify if the current user has access to the component */ if (!in_array($Component->get('AccessLevelID'), $AccessLevels)) { if (Factory::getUser()->isGuest()) { if (Factory::getApplication()->isCLI()) { Factory::getLogger()->alert(Factory::getLanguage()->_('NOT_AUTHORIZED')); } else { Factory::getApplication()->redirectLogin(); } } else { Factory::getApplication()->redirectHome(); } } /** Creates the Class|Controller Namespace */ $Namespace = '\\Components\\' . $_Component . '\\Controllers\\'; /** * If the route contains a controller use that controller * else * use the component name as default controller */ if ($_Controller) { $Controller = $_Controller; } else { $Controller = $_Component; } $Class = $Namespace . $Controller; if (!class_exists($Class)) { throw new \Exception("Controller does not exist {$Controller}->{$Action}({$ID})"); } $Component = new $Class($dbh, $Component); /** Verify if the method (Action) exist */ if (is_callable([$Component, $Action])) { $Component->{$Action}($ID); } else { throw new \Exception("Controller method does not exist {$Controller}->{$Action}({$ID})"); } $this->Component = $Component; } else { throw new \Exception('Component {' . $_Component . '} does not exist in Database'); } } catch (\Exception $e) { Factory::getLogger()->alert('ComponentManagerException: {Message} {File} {Line}', ['Message' => $e->getMessage(), 'File' => $e->getFile(), 'Line' => $e->getLine()]); } } return $this->Component; }
<?php if (Factory::getDocument()->countByPosition("Component")) { foreach (Factory::getDocument()->getByPosition("Component") as $Content) { echo $Content; } } ?> </div> </div> <?php foreach (Factory::getDocument()->get("StyleSheets") as $CSS) { echo "<link rel='stylesheet' href='{$CSS}' />", PHP_EOL; } foreach (Factory::getDocument()->get("JavaScripts") as $JS) { echo "<script src='{$JS}' ></script>", PHP_EOL; } ?> <script type="text/javascript"> function getURL(URL) { return "<?php echo Factory::getRouter()->getURL(); ?> " + URL; } </script> </body> </html>
<?php defined("EPSILON_EXEC") or die; use Epsilon\Factory; /** @var \Epsilon\MVC\View $this */ $eLanguage = Factory::getLanguage(); $eRouter = Factory::getRouter(); ?> <div style="margin-top: 50px;"></div> <div class="row align-center"> <div class="medium-6 large-5 column"> <div class="callout"> <h3 class="text-center"><?php echo $eLanguage->_("COM_LOGIN-TITLE"); ?> </h3> <form action="<?php echo $eRouter->getURL("Authentication/Authenticate"); ?> " method="post"> <div class="row"> <div class="column"> <label for="fEmail"><?php echo $eLanguage->_("COM_LOGIN-EMAIL"), ' / ', $eLanguage->_("COM_LOGIN-USERNAME"); ?> </label> <input name="Login[Email]" id="fEmail" type="text" value="" required> </div> </div> <div class="row">