コード例 #1
0
ファイル: Log.php プロジェクト: roccosportal/pvik
 /**
  * Returns a log trace.
  * Can be used for a exception page.
  * @return string 
  */
 public static function getTrace()
 {
     $traceString = "";
     if (self::$instance != null) {
         $traceString = self::$instance->getTraceString();
     }
     return $traceString;
 }
コード例 #2
0
ファイル: Core.php プロジェクト: roccosportal/pvik
 /**
  * Loads the given configs into \Pvik\Core\Config.
  * @param array $configPaths
  * @return \Pvik\Core\Core
  */
 public function loadConfig(array $configPaths)
 {
     foreach ($configPaths as $configPath) {
         Config::load(Path::realPath($configPath));
     }
     Log::writeLine('[Info] Loaded: ' . implode(",", $configPaths));
     return $this;
 }
コード例 #3
0
ファイル: Manager.php プロジェクト: roccosportal/pvik
 /**
  * Executes a statement.
  * @param string $queryString
  * @return mixed 
  */
 public function execute($queryString)
 {
     Log::writeLine('Executing querystring: ' . $queryString);
     $result = mysql_query($queryString);
     if (!$result) {
         throw new \Exception('Could not execute following statement: ' . $queryString . "\n" . 'MySQLError: ' . mysql_error());
     }
     return $result;
 }
コード例 #4
0
ファイル: View.php プロジェクト: roccosportal/pvik
 /**
  *
  * @param string $viewPath
  * @param Controller $controller 
  */
 public function __construct($viewPath, Controller $controller)
 {
     $this->contents = new KeyValueArray();
     $this->viewPath = $viewPath;
     $this->controller = $controller;
     $this->viewData = $this->controller->getViewData();
     $this->helper = new \Pvik\Web\ViewHelpers\HtmlHelper();
     $this->executePartialCode($this->viewPath);
     if ($this->masterPagePath != null) {
         Log::writeLine('Executing masterpage: ' . $this->masterPagePath);
         $baseMasterPage = new MasterPage($this->realPath($this->masterPagePath), $this);
     }
 }
コード例 #5
0
 /**
  * Execute a action from a controller.
  * @param string $controllerName
  * @param string $actionName
  * @param KeyValueArray $parameters 
  */
 public static function executeController($controllerName, $actionName, Request $request)
 {
     $controllerClassName = $controllerName;
     if ($controllerClassName[0] !== '\\') {
         $controllerClassName = Config::$config['DefaultNamespace'] . Config::$config['DefaultNamespaceControllers'] . '\\' . $controllerClassName;
     }
     $controllerInstance = new $controllerClassName($request, $controllerName);
     /* @var $controllerInstance \Pvik\Web\Controller */
     $actionFunctionName = $actionName . 'Action';
     if (method_exists($controllerInstance, $actionFunctionName)) {
         Log::writeLine('Executing action: ' . $actionFunctionName);
         $controllerInstance->setCurrentActionName($actionName);
         // execute action
         $controllerInstance->{$actionFunctionName}();
     } else {
         throw new \Exception('Action doesn\'t exists: ' . $controllerClassName . '->' . $actionFunctionName);
     }
 }
コード例 #6
0
ファイル: ClassLoader.php プロジェクト: roccosportal/pvik
 /**
  * Tries to load a class.
  * @param String $class  
  */
 protected function loadClass($class)
 {
     if ($class[0] !== '\\') {
         $class = '\\' . $class;
     }
     $name = $class;
     foreach ($this->getNamespaceAssociationList() as $namespace => $path) {
         if (strpos($name, $namespace . '\\') === 0) {
             // starts with
             $name = str_replace($namespace, $path, $name);
             break;
         }
     }
     $path = str_replace('\\', '/', $name);
     $path = str_replace('//', '/', $path);
     $path = Path::realPath($path . '.php');
     if (file_exists($path)) {
         require $path;
         if (class_exists('\\Pvik\\Core\\Log')) {
             Log::writeLine('[Include] ' . $path);
         }
         return true;
     }
 }
コード例 #7
0
ファイル: RouteManager.php プロジェクト: roccosportal/pvik
 /**
  * Checks if a url matches with an route. 
  * @param string $orignalUrl
  * @param array $route
  * @return bool
  */
 protected function urlIsMatching($orignalUrl, $route)
 {
     $routeUrl = $route['Url'];
     if ($routeUrl == '*' || strtolower($orignalUrl) == $routeUrl) {
         $request = new Request();
         $request->setRoute($route);
         $request->setUrl($orignalUrl);
         return $request;
     } elseif (strpos($routeUrl, '{') !== false && strpos($routeUrl, '}') !== false) {
         // contains a variable
         $routeUrlParts = explode('/', $routeUrl);
         $orignalUrlParts = explode('/', $orignalUrl);
         // have the same part length
         if (count($routeUrlParts) == count($orignalUrlParts)) {
             for ($index = 0; $index < count($routeUrlParts); $index++) {
                 if (strlen($routeUrlParts[$index]) >= 3 && $routeUrlParts[$index][0] == '{') {
                     // it's a variable
                     $key = substr($routeUrlParts[$index], 1, -1);
                     if (isset($route['Parameters'][$key]) && !preg_match($route['Parameters'][$key], $orignalUrlParts[$index])) {
                         return null;
                     }
                 } else {
                     if (strtolower($routeUrlParts[$index]) != $orignalUrlParts[$index]) {
                         // not matching
                         return null;
                     }
                 }
             }
             Log::writeLine('Route matching: ' . $route['Url']);
             $request = new Request();
             $request->setRoute($route);
             $request->setUrl($orignalUrl);
             // matching successfull
             // save url parameter
             for ($index = 0; $index < count($routeUrlParts); $index++) {
                 if (strlen($routeUrlParts[$index]) >= 3 && $routeUrlParts[$index][0] == '{') {
                     // it's a variable
                     // the key is the name between the brakets
                     $key = substr($routeUrlParts[$index], 1, -1);
                     // add to url parameters
                     $request->getParameters()->add($key, $orignalUrlParts[$index]);
                     if (isset($route['Parameters'][$key])) {
                         Log::writeLine('Url parameter: ' . $key . ' -> ' . $route['Parameters'][$key] . ' -> ' . $orignalUrlParts[$index]);
                     } else {
                         Log::writeLine('Url parameter: ' . $key . ' -> ' . $orignalUrlParts[$index]);
                     }
                 }
             }
             return $request;
         }
     }
     return null;
 }
コード例 #8
0
ファイル: Controller.php プロジェクト: roccosportal/pvik
 /**
  * Redirects to another controllers action with passing the original parameters.
  * @param string $controllerName
  * @param string $actionName 
  */
 protected function redirectToController($controllerName, $actionName, Request $request = null)
 {
     if ($request == null) {
         $request = $this->request;
     }
     Log::writeLine('Redirecting to controller: ' . $controllerName);
     Log::writeLine('Redirecting to action: ' . $actionName);
     ControllerManager::executeController($controllerName, $actionName, $request);
 }
コード例 #9
0
ファイル: Master.php プロジェクト: roccosportal/dashbird
            <div id="message"><?php 
echo nl2br($Exception->getMessage());
?>
</div>
            <span>File:</span>
            <div id="file">File  <?php 
echo $Exception->getFile();
?>
 at line <?php 
echo $Exception->getLine();
?>
</div>
            <span>Stacktrace:</span>
            <div id="stacktrace"><?php 
echo nl2br($Exception->getTraceAsString());
?>
</div>
            <span>Logtrace:</span>
            <div id="logtrace"><?php 
echo nl2br(\Pvik\Core\Log::GetTrace());
?>
</div>
            <span>Code:</span>
            <div id="code"><?php 
echo nl2br($Exception->getCode());
?>
</div>
        </div>
    </body>
</html>