Skip to content

Commit

Permalink
Stable release
Browse files Browse the repository at this point in the history
Added TINA4_DEBUG const default is off for debugging
  • Loading branch information
andrevanzuydam committed Jul 17, 2019
1 parent 58f4668 commit e6815da
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 13 deletions.
10 changes: 7 additions & 3 deletions Tina4/ParseTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class ParseTemplate {
private $evals = [];

function __construct($root, $fileName, $definedVariables="") {
error_log("TINA4 Filename: ".$fileName);
if (TINA4_DEBUG) {
error_log("TINA4 Filename: " . $fileName);
}
if (defined("TINA4_TEMPLATE_LOCATIONS")) {
$this->locations = TINA4_TEMPLATE_LOCATIONS;
}
Expand Down Expand Up @@ -51,7 +53,9 @@ function parseVariables($content) {
try {
eval($eval);
} catch (\ParseError $error) {
error_log("TINA4: Parse Error for ".$eval);
if (TINA4_DEBUG) {
error_log("TINA4: Parse Error for " . $eval);
}
}
}

Expand Down Expand Up @@ -211,4 +215,4 @@ function __toString()
return (string)$this->content;
}

}
}
14 changes: 11 additions & 3 deletions Tina4/Routing.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ class Routing

function __construct($root = "", $urlToParse = "", $method = "")
{
error_log("TINA4: URL to parse " . $urlToParse);
$this->debug = TINA4_DEBUG;

if ($this->debug) {
error_log("TINA4: URL to parse " . $urlToParse);
}
global $arrRoutes;

if (in_array("*", TINA4_ALLOW_ORIGINS) || in_array($_SERVER["HTTP_ORIGIN"], TINA4_ALLOW_ORIGINS) ) {
Expand Down Expand Up @@ -118,7 +122,9 @@ function __construct($root = "", $urlToParse = "", $method = "")
}
$d->close();
} else {
error_log("TINA4: " . getcwd() . "/" . $route . " not found!");
if ($this->debug) {
error_log("TINA4: " . getcwd() . "/" . $route . " not found!");
}
}
}

Expand Down Expand Up @@ -173,7 +179,9 @@ function __construct($root = "", $urlToParse = "", $method = "")
$fileName = "index";
}

//error_log("TINA4: Variables\n".print_r (get_defined_vars(), 1));
if ($this->debug) {
error_log("TINA4: Variables\n" . print_r(get_defined_vars(), 1));
}
$this->content .= new ParseTemplate($root, $fileName, get_defined_vars());
} else {
$this->content = $result;
Expand Down
6 changes: 4 additions & 2 deletions Tina4/Tina4Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ function save($DBA=null, $tableName="", $fieldMapping=[]) {
//See if the record exists already using the primary key

$sqlCheck = "select * from {$tableName} where {$primaryCheck}";
error_log("TINA4: check ".$sqlCheck);
if (TINA4_DEBUG) {
error_log("TINA4: check " . $sqlCheck);
}
$exists = json_decode($DBA->fetch($sqlCheck, 1)."");


Expand Down Expand Up @@ -364,4 +366,4 @@ function __toString()
}


}
}
13 changes: 8 additions & 5 deletions Tina4/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
define("TINA4_PATCH" , "PATCH");
define("TINA4_DELETE" , "DELETE");



global $twig;
//Twig template engine

Expand All @@ -30,11 +28,16 @@
$webRoot = join(DIRECTORY_SEPARATOR, $webRoot);
}

error_log("TINA4: Webroot ". $webRoot);
if (TINA4_DEBUG) {
error_log("TINA4: Webroot " . $webRoot);
}

$twigPaths = TINA4_TEMPLATE_LOCATIONS;

error_log("TINA4: Twig Paths\n".print_r ($twigPaths, 1));
if (TINA4_DEBUG) {
error_log("TINA4: Twig Paths\n" . print_r($twigPaths, 1));
}

foreach ($twigPaths as $tid => $twigPath) {

if (!file_exists($webRoot."/".$twigPath)) {
Expand Down Expand Up @@ -92,4 +95,4 @@ function tina4_autoloader($class) {
}


spl_autoload_register('tina4_autoloader');
spl_autoload_register('tina4_autoloader');
8 changes: 8 additions & 0 deletions engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
require_once ($documentRoot."/config.php");
}

if (!defined("TINA4_DEBUG")) {
define ("TINA4_DEBUG", false);
} else {
if (TINA4_DEBUG) {
error_log("TINA4 DEBUG: ON");
}
}

if(!defined("TINA4_TEMPLATE_LOCATIONS")) {
define("TINA4_TEMPLATE_LOCATIONS" , ["templates", "assets", "templates/snippets"]);
}
Expand Down

0 comments on commit e6815da

Please sign in to comment.