Skip to content
This repository has been archived by the owner on Jan 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #28 from nmarulo/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Nicolás Marulanda P authored Dec 3, 2017
2 parents 4907c9c + bb93df4 commit 2c7de7a
Show file tree
Hide file tree
Showing 109 changed files with 3,201 additions and 2,925 deletions.
43 changes: 0 additions & 43 deletions app/config.php

This file was deleted.

33 changes: 0 additions & 33 deletions app/controllers/CUDControllerAbstract.php

This file was deleted.

56 changes: 0 additions & 56 deletions app/controllers/ControllerAbstract.php

This file was deleted.

33 changes: 0 additions & 33 deletions app/controllers/Template.php

This file was deleted.

50 changes: 0 additions & 50 deletions app/controllers/ThemeControllerAbstract.php

This file was deleted.

47 changes: 33 additions & 14 deletions app/controllers/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
namespace SoftnCMS\controllers;

use SoftnCMS\route\Route;
use SoftnCMS\rute\Router;
use SoftnCMS\util\Arrays;
use SoftnCMS\util\Logger;

Expand Down Expand Up @@ -40,13 +39,33 @@ class ViewController {
/** @var \Closure */
private static $VIEW_DATA_BASE_CLOSURE;

/** @var string */
private static $SITE_URL;

/** @var string Directorio del controlador actual. */
private static $CURRENT_DIRECTORY;

/**
* @param string $viewPath
*/
public static function setViewPath($viewPath) {
self::$VIEW_PATH = $viewPath;
}

/**
* @param string $siteUrl
*/
public static function setSiteUrl($siteUrl) {
self::$SITE_URL = $siteUrl;
}

/**
* @param string $currentDirectory
*/
public static function setCurrentDirectory($currentDirectory) {
self::$CURRENT_DIRECTORY = $currentDirectory;
}

/**
* @param string $directoryViews
*/
Expand Down Expand Up @@ -75,6 +94,16 @@ public static function view($fileName) {
self::$VIEW_DATA = [];
}

private static function callViewDataBase() {
if (is_callable(self::$VIEW_DATA_BASE_CLOSURE)) {
$data = call_user_func(self::$VIEW_DATA_BASE_CLOSURE);

if (is_array($data)) {
self::$VIEW_DATA = array_merge($data, self::$VIEW_DATA);
}
}
}

private static function getControllerViewPath($fileName) {
return self::getPath($fileName, self::$DIRECTORY_VIEWS, self::$DIRECTORY_VIEWS_CONTROLLER);
}
Expand Down Expand Up @@ -216,7 +245,7 @@ public static function registerScript($scriptName) {
}

public static function registerScriptRoute($scriptRute) {
$scriptRute = Router::getSiteURL() . $scriptRute;
$scriptRute = self::$SITE_URL . $scriptRute;

if (Arrays::valueExists(self::$VIEW_SCRIPTS, $scriptRute) === FALSE) {
self::$VIEW_SCRIPTS[] = $scriptRute;
Expand All @@ -231,7 +260,7 @@ private static function getPathResources($type, $fileName) {
}

private static function getPathTheme() {
if (Router::getCurrentDirectory() == Route::CONTROLLER_DIRECTORY_NAME_THEME) {
if (self::$CURRENT_DIRECTORY == Route::CONTROLLER_DIRECTORY_NAME_THEME) {
//$DIRECTORY_VIEWS contiene el nombre del tema.
return '/themes/' . self::$DIRECTORY_VIEWS;
}
Expand All @@ -244,7 +273,7 @@ public static function registerStyle($styleName) {
}

public static function registerStyleRoute($styleRute) {
$styleRute = Router::getSiteURL() . $styleRute;
$styleRute = self::$SITE_URL . $styleRute;

if (Arrays::valueExists(self::$VIEW_STYLES, $styleRute) === FALSE) {
self::$VIEW_STYLES[] = $styleRute;
Expand All @@ -260,14 +289,4 @@ public static function registerStyleRoute($styleRute) {
public static function setViewDataBase($closure) {
self::$VIEW_DATA_BASE_CLOSURE = $closure;
}

private static function callViewDataBase() {
if (is_callable(self::$VIEW_DATA_BASE_CLOSURE)) {
$data = call_user_func(self::$VIEW_DATA_BASE_CLOSURE);

if (is_array($data)) {
self::$VIEW_DATA = array_merge($data, self::$VIEW_DATA);
}
}
}
}
Loading

0 comments on commit 2c7de7a

Please sign in to comment.