Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "main-dev"
"dev-master": "1.0-dev"
}
}
}
15 changes: 15 additions & 0 deletions src/WebApp/BootstrapTheme/Grid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace WebApp\BootstrapTheme;

class Grid extends \WebApp\Component\Div {

public function __construct($parent) {
parent::__construct($parent);
}

public function createRow() {
return new GridRow($this);
}
}

23 changes: 23 additions & 0 deletions src/WebApp/BootstrapTheme/GridCell.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace WebApp\BootstrapTheme;

class GridCell extends \WebApp\Component\Div {

protected $gridSizes;

public function __construct($parent, $content = NULL) {
parent::__construct($parent, $content);
$this->gridSizes = array();
}

public function getGridSizes() {
return $this->gridSizes;
}

public function addSize($class, $span = 0) {
$this->gridSizes[$class] = $span;
return $this;
}
}

23 changes: 23 additions & 0 deletions src/WebApp/BootstrapTheme/GridCellRenderer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace WebApp\BootstrapTheme;

class GridCellRenderer extends \WebApp\DefaultTheme\DivRenderer {

public function __construct($theme, $component) {
parent::__construct($theme, $component);
$sizes = $this->component->getGridSizes();
if (count($sizes) > 0) {
foreach ($sizes AS $class => $span) {
if ($span > 0) {
$this->addClass('col-'.$class.'-'.$span);
} else {
$this->addClass('col-'.$class);
}
}
} else {
$this->addClass('col');
}
}
}

12 changes: 12 additions & 0 deletions src/WebApp/BootstrapTheme/GridRenderer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace WebApp\BootstrapTheme;

class GridRenderer extends \WebApp\DefaultTheme\DivRenderer {

public function __construct($theme, $component) {
parent::__construct($theme, $component);
$this->addClass('container');
}
}

15 changes: 15 additions & 0 deletions src/WebApp/BootstrapTheme/GridRow.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace WebApp\BootstrapTheme;

class GridRow extends \WebApp\Component\Div {

public function __construct($parent) {
parent::__construct($parent);
}

public function createCell($content = NULL) {
return new GridCell($this, $content);
}
}

12 changes: 12 additions & 0 deletions src/WebApp/BootstrapTheme/GridRowRenderer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace WebApp\BootstrapTheme;

class GridRowRenderer extends \WebApp\DefaultTheme\DivRenderer {

public function __construct($theme, $component) {
parent::__construct($theme, $component);
$this->addClass('row');
}
}

16 changes: 8 additions & 8 deletions src/WebApp/BootstrapTheme/LoginPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ public function __construct($app) {
}

public function getPublicMain() {
$rc = new \WebApp\Component\Div($this);
$rc->addClass('jumbotron');
$rc->setStyle('margin-top', '1em');
$title = new \WebApp\Component\Title($rc, 'login_title');
$rc = new \WebApp\Component\MainContent($this);
$panel = new \WebApp\Component\Div($rc);
$panel->addClass('jumbotron');
$title = new \WebApp\Component\Title($panel, 'login_title');
$title->setStyle('margin-top', '0');
$title->setStyle('margin-bottom', '0.5rem');
$lead = new \WebApp\Component\Subtitle($rc, 'please_login');
$rc->addChild('<hr class="my-4">');
$rc->addChild($this->getMessages());
$rc->addChild($this->getLoginForm());
$lead = new \WebApp\Component\Subtitle($panel, 'please_login');
$panel->addChild('<hr class="my-4">');
$panel->addChild($this->getMessages());
$panel->addChild($this->getLoginForm());
return $rc;
}

Expand Down
12 changes: 12 additions & 0 deletions src/WebApp/BootstrapTheme/MainContentRenderer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace WebApp\BootstrapTheme;

class MainContentRenderer extends \WebApp\DefaultTheme\DivRenderer {

public function __construct($theme, $component) {
parent::__construct($theme, $component);
$this->addClass('container-fluid');
}
}

12 changes: 12 additions & 0 deletions src/WebApp/BootstrapTheme/SubtitleRenderer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace WebApp\BootstrapTheme;

class SubtitleRenderer extends \WebApp\DefaultTheme\ContainerRenderer {

public function __construct($theme, $component) {
parent::__construct($theme, $component, 'p');
$this->addClass('lead');
}
}

12 changes: 12 additions & 0 deletions src/WebApp/BootstrapTheme/TitleRenderer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace WebApp\BootstrapTheme;

class TitleRenderer extends \WebApp\DefaultTheme\ContainerRenderer {

public function __construct($theme, $component) {
parent::__construct($theme, $component, 'h1');
$this->addClass('display-4');
}
}

2 changes: 1 addition & 1 deletion src/WebApp/Component/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Image extends Component {

public function __construct($parent, $url, $title) {
parent::__construct($parent);
$this->setAttribute('href', $url);
$this->setAttribute('src', $url);
$this->setAttribute('title', $title);
}

Expand Down
13 changes: 13 additions & 0 deletions src/WebApp/Component/MainContent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace WebApp\Component;

class MainContent extends Div {

public function __construct($parent, $child = NULL) {
parent::__construct($parent, $child);
$this->addClass('content-main');
}

}

8 changes: 4 additions & 4 deletions src/WebApp/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ protected function renderLinks() {
$files = $this->app->getCssFiles();
if (!is_array($files)) $files = array($files);
foreach ($files AS $file) {
if (strpos($file, '://') === FALSE) {
$rc .= '<link rel="stylesheet" href="'.Utils::getCssBaseUrl().'/'.$file.'" rel="stylesheet" type="text/css">';
} else {
//if (strpos($file, '://') === FALSE) {
// $rc .= '<link rel="stylesheet" href="'.Utils::getCssBaseUrl().'/'.$file.'" rel="stylesheet" type="text/css">';
//} else {
$rc .= '<link rel="stylesheet" href="'.$file.'" rel="stylesheet" type="text/css">';
}
//}
}
return $rc;
}
Expand Down
3 changes: 1 addition & 2 deletions src/WebApp/Page/LoginPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public function getRequiredRight() {
}

public function getPublicMain() {
$rc = new \WebApp\Component\Div($this);
$rc->addClass('container-fluid');
$rc = new \WebApp\Component\MainContentContainer($this);
new \WebApp\Component\Title($rc, 'login_title');
$rc->addChild($this->getMessages());
$rc->addChild($this->getLoginForm());
Expand Down
54 changes: 47 additions & 7 deletions src/WebApp/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public function getPage() {

// Strip of the leading part
$afterName = substr($pagePath, strlen($mapEntry));
Log::debug($this->searchPageInNamespace($afterName, $name));

// Fix special cases such as empty start or trailing slash
if ($afterName == '') $afterName .= '/index';
Expand Down Expand Up @@ -208,13 +209,7 @@ public function getPage() {
}
}

// Check whether the class exists
if ($className != NULL) {
if (substr($className, 0, 1) != '\\') $className = '\\'.$className;
if (class_exists($className)) $page = new $className($this->app);
}

return $page;
return $this->createPageInstance($className);
}

/** Returns the absolute path to a relative app path */
Expand All @@ -223,5 +218,50 @@ public function getAbsolutePath($relativePath) {
return $request->webRoot.$request->relativeAppPath.$relativePath;
}

protected function searchPageInNamespace($pagePath, $namespace) {
// Fix special cases such as empty start or trailing slash
if ($pagePath == '') $pagePath .= '/index';
if (substr($pagePath, -1) == '/') $pagePath .= 'index';

// strip of the ending .html
if (substr($pagePath, -5) == '.html') $pagePath = substr($pagePath, 0, strlen($pagePath)-5);

// split in parts and remove first part if it's empty
$names = explode('/', $pagePath);
if ($names[0] == '') array_shift($names);

// Replace special characters by whitespace and make it camel case and concatenate again
$className = $name;
foreach ($names AS $idx => $path) {
if ($idx > 0) $className .= '\\';
$path = str_replace(' ', '', ucwords(str_replace(array('_','-'), array(' ', ' '), $path)));
$className .= ucfirst($path);
}

// Make a bottom-2-top search for the class as long as you are in the namespace of the mapEntry
$toSearch = '\\'.$className.'Page';
while (!class_exists($toSearch) && (strpos($toSearch, $namespace) !== FALSE)) {
// strip off from last backslash
$toSearch = substr($toSearch, 0, strrpos($toSearch, '\\')).'Page';
}
if (class_exists($toSearch)) {
$className = $toSearch;
} else {
$className .= 'Page';
}
Log::debug('Router::searchPageInNamespace(): '.$namespace.$className);
return $namespace.$className;
}

/** Returns the instance of the page or NULL if it doesnt exist */
protected function createPageInstance($className) {
$page = NULL;
// Check whether the class exists
if ($className != NULL) {
if (substr($className, 0, 1) != '\\') $className = '\\'.$className;
if (class_exists($className)) $page = new $className($this->app);
}
return $page;
}
}

5 changes: 3 additions & 2 deletions src/WebApp/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ public static function getCssBasePath($webapp = FALSE) {
return self::getWebRootPath($webapp).'/css';
}

public function getFontBaseUrl($webapp = FALSE) {
public static function getFontBaseUrl($webapp = FALSE) {
return self::getWebRootUrl($webapp).'/fonts';
}

public function getFontBasePath($webapp = FALSE) {
public static function getFontBasePath($webapp = FALSE) {
return self::getWebRootPath($webapp).'/fonts';
}

}