Skip to content

Commit 08c2ae2

Browse files
committed
bug fixes, add tamu theme
1 parent ed445f2 commit 08c2ae2

File tree

15 files changed

+1304
-54
lines changed

15 files changed

+1304
-54
lines changed

App/Classes/Controllers/WidgetsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected function configure() {
1717
protected function parts() {
1818
$data = $this->getSite()->getSanitizedInputData();
1919
$widget = $this->widgetsRepo->getById($data['widgetid']);
20-
$this->getPage()->setSubTitle('Parts for '.$widget['name']);
20+
$this->getPage()->setSubTitle('Parts for '.$widget->getName());
2121
$this->getSite()->getViewRenderer()->registerViewVariable("widget",$widget);
2222
$this->getSite()->getViewRenderer()->registerViewVariable("parts",$this->widgetsRepo->getPartsByWidgetId($data['widgetid']));
2323
$this->setViewName('widgets.parts');

App/Classes/ViewRenderers/AppViewRenderer.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,27 @@
66
* An app level customization of Core's HTMLViewRenderer to demonstrate extending a Core ViewRender implementation
77
* Specific ViewRenderers can be activated by setting the VIEW_RENDERER constant to the class name of the desired ViewRenderer
88
*
9-
* Looks in the 'bootstrap' Views directory for a given view first. If not found, falls back to the 'html' directory.
9+
* Looks in the ACTIVE_THEME Views directory for a given view first. If not found, tries 'bootstrap', then 'html' directories.
1010
*
1111
* @author Jason Savell <jsavell@library.tamu.edu>
1212
*/
1313
class AppViewRenderer extends HTMLViewRenderer {
1414
protected $viewPaths = array('bootstrap','html');
1515

16-
public function __construct($globalUser,$pages,$data,$controllerName) {
17-
parent::__construct($globalUser,$pages,$data,$controllerName);
18-
$this->setViewPath($this->viewPaths[0]);
19-
}
20-
2116
public function setView($viewFile,$isAdmin=false) {
2217
$viewSet = false;
23-
foreach ($this->viewPaths as $viewPath) {
24-
$this->setViewPath($viewPath);
25-
if (parent::setView($viewFile,$isAdmin)) {
26-
$viewSet = true;
27-
break;
18+
if (!parent::setView($viewFile,$isAdmin)) {
19+
$config = $this->getAppConfiguration();
20+
$mainViewPath = $this->getViewPath();
21+
foreach ($this->viewPaths as $viewPath) {
22+
$this->setViewPath($config['PATH_VIEWS'].$viewPath.'/');
23+
if (parent::setView($viewFile,$isAdmin)) {
24+
$viewSet = true;
25+
break;
26+
}
2827
}
28+
$this->setViewPath($mainViewPath);
2929
}
30-
$this->setViewPath($this->viewPaths[0]);
31-
if ($viewSet) {
32-
return true;
33-
}
34-
return false;
30+
return $viewSet;
3531
}
3632
}

App/Config/config_sample.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//This must be set to the real file path to the base directory of your server, e.g. '/var/www/html/'
44
define('PATH_ROOT', '/var/www/html/');
55

6-
define('APP_NAME', 'The PipitSeed App');
6+
define('APP_NAME', 'The Pipit Seed App');
77
define('APP_DIRECTORY', 'Pipit-Seed');
88

99
define('PATH_APP', PATH_ROOT.APP_DIRECTORY.'/');
@@ -13,7 +13,7 @@
1313
if (WITH_COMPOSER) {
1414
define('VENDOR_DIRECTORY', 'vendor');
1515
define('PATH_VENDOR', PATH_APP.VENDOR_DIRECTORY.'/');
16-
define('PATH_CORE', PATH_VENDOR.'tamu-lib/pipit/');
16+
define('PATH_CORE', PATH_VENDOR.'tamu-lib/pipit/src/');
1717
} else {
1818
define('PATH_CORE', PATH_ROOT.'Pipit/');
1919
}
@@ -80,10 +80,10 @@
8080
//define('SITE_CLASS','Site');
8181

8282
//If VIEW_RENDERER is not set, the app will use the HTMLViewRenderer by default.
83-
//define('VIEW_RENDERER','AppViewRenderer');
83+
define('VIEW_RENDERER','AppViewRenderer');
8484

85-
//Define the theme folder HTMLViewRenderer based ViewRenderers should use (default options are 'bootstrap' and 'html')
86-
define('ACTIVE_THEME','bootstrap');
85+
//Define the theme folder HTMLViewRenderer based ViewRenderers should use (default options are 'bootstrap', 'html' and 'tamu')
86+
define('ACTIVE_THEME','tamu');
8787

8888
/**
8989
* The page access levels (use when defining pages in the site.pages config file)

App/Config/samples/site.pages.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[widgets]
2-
name = widgets
2+
name = Widgets
33
path = widgets
44
accessLevel = SECURITY_USER
55

66
[DynamicRepo]
7-
name = dynamic repo
7+
name = Dynamic repo
88
path = dynamic-repo
99
accessLevel = SECURITY_USER
1010

@@ -14,6 +14,6 @@ path = files
1414
accessLevel = SECURITY_USER
1515

1616
[users]
17-
name = users
17+
name = Users
1818
path = users
1919
accessLevel = SECURITY_ADMIN

App/Views/bootstrap/widgets.parts.view.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<div class="do-results">
22
<form class="do-submit vertical-spacer-bottom" name="addpart" method="POST" action="<?php echo $app_http;?>">
33
<?php
4-
$modalContext = 'action=parts&widgetid='.$parameters['widget']['id'];
4+
$widget = $parameters['widget'];
5+
$modalContext = 'action=parts&widgetid='.$widget->getId();
56
echo ' <input type="hidden" name="modal_context" value="'.$modalContext.'" />
67
<input type="hidden" name="action" value="parts" />
78
<input type="hidden" name="subaction" value="add" />
8-
<input type="hidden" name="widgetid" value="'.$parameters['widget']['id'].'" />
9+
<input type="hidden" name="widgetid" value="'.$widget->getId().'" />
910
<div class="input-group col col-sm-6 col-xs-10">
1011
<input class="form-control" type="text" name="part[name]" />
1112
<span class="input-group-btn">

App/Views/html/widgets.list.view.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
<?php
1818
foreach ($results as $widget) {
1919
echo "<tr>
20-
<td>{$widget['name']}</td>
20+
<td>{$widget->getName()}</td>
2121
<td class=\"capitalize\">
22-
<a class=\"inline-block button button-small do-loadmodal\" href=\"{$app_http}?action=parts&widgetid={$widget['id']}\">Parts</a>
23-
<a class=\"inline-block button button-small do-loadmodal\" href=\"{$app_http}?action=attachments&widgetid={$widget['id']}\">Attachments</a>
24-
<a class=\"inline-block button button-small do-loadmodal\" href=\"{$app_http}?action=edit&id={$widget['id']}\">Edit</a>";
22+
<a class=\"inline-block button button-small do-loadmodal\" href=\"{$app_http}?action=parts&widgetid={$widget->getId()}\">Parts</a>
23+
<a class=\"inline-block button button-small do-loadmodal\" href=\"{$app_http}?action=attachments&widgetid={$widget->getId()}\">Attachments</a>
24+
<a class=\"inline-block button button-small do-loadmodal\" href=\"{$app_http}?action=edit&id={$widget->getId()}\">Edit</a>";
2525
echo ' <form class="inline-block do-submit-confirm" name="removewidget" method="POST" action="'.$app_http.'">
2626
<input type="hidden" name="action" value="remove" />
27-
<input type="hidden" name="id" value="'.$widget['id'].'" />
27+
<input type="hidden" name="id" value="'.$widget->getId().'" />
2828
<input class="inline-block small" type="submit" name="submitremove" value="Remove" />
2929
</form>';
3030
echo "
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
</div>
2+
</div>
3+
<tl-footer></tl-footer>
4+
<tl-themes active-theme="tamu"/>
5+
<script src="https://api.library.tamu.edu/tl-components/1x/tl-components.js"></script>
6+
</body>
7+
</html>
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
<?php
2+
function buildPageOptions($page,$app_http) {
3+
$html = '';
4+
if ($page->getOptions()) {
5+
$html .= " <div class=\"col col-sm-8\">
6+
<ul class=\"nav nav-pills\">";
7+
foreach ($page->getOptions() as $subnav) {
8+
$isCurrent = (isset($data['action']) && isset($subnav['action']) && $subnav['action'] == $data['action']) || (!isset($data['action']) && !isset($subnav['action']));
9+
$html .= " <li".(($isCurrent) ? ' class="active"':'').">
10+
<a class=\"capitalize".(isset($subnav['modal']) ? ' do-loadmodal':'')."\" href=\"{$app_http}".((isset($subnav['action'])) ? "?action={$subnav['action']}":'')."\">{$subnav['name']}</a>
11+
</li>";
12+
}
13+
$html .= ' </ul>
14+
</div>';
15+
}
16+
return $html;
17+
}
18+
19+
function buildPrimaryNavigation($pages,$controllerName,$path_http,$globalUser) {
20+
$html = '';
21+
if ($globalUser->isLoggedIn()) {
22+
foreach ($pages as $controllerKey=>$sitePage) {
23+
$html .= ' <li'.(($controllerKey == $controllerName) ? ' class="active"':'').'>';
24+
if (!$sitePage->isAdminPage() || ($sitePage->isAdminPage() && $globalUser->isAdmin())) {
25+
$html .= "<a class=\"capitalize\" href=\"{$path_http}{$sitePage->getPath()}/\">{$sitePage->getName()}</a>";
26+
}
27+
$html .= ' </li>';
28+
}
29+
}
30+
return $html;
31+
}
32+
33+
function buildSearchForm($page,$app_http) {
34+
$html = '';
35+
if ($page->isSearchable()) {
36+
$html .= '<div class="col col-sm-4">
37+
<form id="doSearch" class="do-get" name="search" method="POST" action="'.$app_http.'">
38+
<input type="hidden" name="action" value="search" />
39+
<div class="input-group">
40+
<input id="searchTerm" class="form-control" type="text" name="term" />';
41+
$html .= ' <span class="input-group-btn">
42+
<input id="searchResults" class="btn btn-default" type="submit" name="submit" value="Search" />
43+
</span>
44+
</div>
45+
<div class="inline-block" id="searchStatus">
46+
<a class="hidden" href="#clearSearch">clear search</a>
47+
</div>
48+
</form>
49+
</div>';
50+
}
51+
return $html;
52+
}
53+
54+
function buildSystemMessages($systemMessages=null) {
55+
$html = '<div class="sysMsg col-sm-10">';
56+
if ($systemMessages) {
57+
foreach ($systemMessages as $sysMsg) {
58+
$typeMap = array('error'=>'danger');
59+
$msgType = $sysMsg->getType();
60+
if (array_key_exists($msgType,$typeMap)) {
61+
$msgType = $typeMap[$msgType];
62+
}
63+
$html .= " <div class=\"alert alert-{$msgType}\">{$sysMsg->getMessage()}</div>";
64+
}
65+
}
66+
$html .= '</div>';
67+
return $html;
68+
}
69+
70+
function buildUserDashboard($globalUser,$path_http) {
71+
$html = '';
72+
if ($globalUser->isLoggedIn()) {
73+
$html .= '<div class="col-sm-2">
74+
<span>Hi <a href="'.$path_http.'user.php?action=edit">'.$globalUser->getProfileValue('username').'</a>! (<a href="'.$path_http.'user.php?action=logout">logout</a>)</span>
75+
</div>';
76+
}
77+
return $html;
78+
}
79+
80+
function buildPageHeader($page,$app_http) {
81+
$html = '';
82+
if (!empty($page)) {
83+
if ($page->getTitle()) {
84+
$html .= "
85+
<div class=\"page-header\">
86+
<h1>{$page->getTitle()}</h1>
87+
</div>";
88+
}
89+
90+
$html .= '<div id="subNav" class="row">';
91+
$html .= buildPageOptions($page,$app_http);
92+
$html .= buildSearchForm($page,$app_http);
93+
$html .= '</div>';
94+
}
95+
$html .= ' <div id="modalContent">';
96+
if (!empty($page) && $page->getSubTitle()) {
97+
$html .= " <div class=\"page-header\">
98+
<h1 class=\"capitalize\"><small>{$page->getSubTitle()}</small></h1>
99+
</div>";
100+
}
101+
return $html;
102+
}
103+
104+
$themeFolder = $config['ACTIVE_THEME'];
105+
$themePath = $config['PATH_THEMES'].$themeFolder.'/';
106+
?>
107+
<!DOCTYPE html>
108+
<html>
109+
<head>
110+
<meta charset="utf-8">
111+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
112+
<title><?php echo APP_NAME;?></title>
113+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
114+
115+
<meta name="apple-mobile-web-app-capable" content="yes" />
116+
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
117+
<link rel="apple-touch-icon" href="iphone-icon.png" />
118+
119+
<link rel="stylesheet" type="text/css" href="<?php echo $config['PATH_THEMES'];?>tamu/css/bootstrap.min.css" media="screen"/>
120+
<link rel="stylesheet" type="text/css" href="<?php echo $config['PATH_THEMES'];?>tamu/css/prism.css" media="screen"/>
121+
<link rel="stylesheet" type="text/css" href="<?php echo $config['PATH_THEMES'];?>tamu/css/TAMUglobal.css" media="screen"/>
122+
123+
<link rel="stylesheet" type="text/css" href="<?php echo $config['PATH_CSS'];?>helpers.css" media="screen"/>
124+
<link rel="stylesheet" type="text/css" href="<?php echo $themePath;?>css/style.css" media="screen"/>
125+
126+
<?php
127+
if (is_file("{$config['PATH_APP']}{$controllerName}.css")) {
128+
echo '<link rel="stylesheet" type="text/css" href="'.$config['PATH_CSS'].$controller.'.css" media="screen"/>';
129+
}
130+
?>
131+
<script type="text/javascript" src="<?php echo $config['PATH_JS'];?>vendor/jquery.min.js"></script>
132+
<!-- Bootstrap JS - Latest compiled and minified JavaScript -->
133+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
134+
135+
<script type="text/javascript">
136+
var app_http = '<?php echo $app_http;?>';
137+
</script>
138+
139+
<script type="text/javascript" src="<?php echo $config['PATH_JS'];?>pipit.functions.js"></script>
140+
<script type="text/javascript" src="<?php echo $config['PATH_JS'];?>pipit.listeners.js"></script>
141+
<script type="text/javascript" src="<?php echo $themePath;?>js/theme.js"></script>
142+
143+
<?php
144+
if ($controllerName != 'default' && is_file("{$config['PATH_APP']}site/resources/js/{$controllerName}.js")) {
145+
echo '<script type="text/javascript" src="'.$config['PATH_JS'].$controllerName.'.js"></script>';
146+
}
147+
148+
?>
149+
<link rel="shortcut icon" href="ico/favicon.ico">
150+
</head>
151+
<body>
152+
<a href="#content" class="sr-only sr-only-focusable">Skip to main content</a>
153+
<div id="theModal" class="modal fade" tabindex="-1" role="dialog">
154+
<div class="modal-dialog modal-lg">
155+
<div class="modal-content">
156+
<div class="modal-header">
157+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
158+
<span aria-hidden="true">&times;</span>
159+
</button>
160+
</div>
161+
<div class="modal-body"></div>
162+
</div>
163+
</div>
164+
</div>
165+
<header class="globalHeader">
166+
<tl-header page-title="<?php echo $config['APP_NAME'];?>" suppress-call-to-action="true">
167+
<?php
168+
if ($globalUser->isLoggedIn()) {
169+
foreach ($pages as $controllerKey => $sitePage) {
170+
$showNavLink = false;
171+
if ($sitePage->isAdminPage() && $globalUser->isAdmin()) {
172+
$showNavLink = true;
173+
} else if ($sitePage->getAccessLevel() < SECURITY_ADMIN) {
174+
$showNavLink = true;
175+
}
176+
if ($showNavLink) {
177+
echo "<wvre-nav-li href=\"{$config['PATH_HTTP']}{$sitePage->getPath()}/\">
178+
<wvre-text value=\"{$sitePage->getName()}\"/>
179+
</wvre-nav-li>";
180+
}
181+
}
182+
}
183+
?>
184+
</header>
185+
<div id="systemBar" class="clearfix">
186+
<?php
187+
echo buildSystemMessages($systemMessages);
188+
echo buildUserDashboard($globalUser,$config['PATH_HTTP']);
189+
?>
190+
</div>
191+
<div class="container clearfix">
192+
193+
194+
195+
<?php
196+
echo buildPageHeader($page,$app_http);
197+
?>

0 commit comments

Comments
 (0)