Commit f17df2a4 authored by Ryan Wade's avatar Ryan Wade

Added $link argument to the constructors of viewpage, nav, footer, and...

Added $link argument to the constructors of viewpage, nav, footer, and breadcrumb to generalize links.  These components can now be used by more than one parent file "viewpage.php" and "admin.php" and create appropriate page links.
parent a23d0d3c
......@@ -3,12 +3,14 @@
class Breadcrumb
{
private $SQL_TABLE = null;
private $link = null;
private $id = null;
private $title = "";
//$title is needed as special pages cannot be accessed from SQL database.
function Breadcrumb($SQL_TABLE, $id, $title)
function Breadcrumb($SQL_TABLE, $link, $id, $title)
{
$this->SQL_TABLE = $SQL_TABLE;
$this->link = $link;
$this->id = $id;
$this->title = $title;
}
......@@ -17,7 +19,7 @@
//Create Link to current Page
$t_id = $this->id;
$t_title = $this->title;
$link = "<a class='breadcrumbLink' href='viewpage.php?id=".$t_id."'>".$t_title."</a>";
$crumb = "<a class='breadcrumbLink' href='".$this->link."?id=".$t_id."'>".$t_title."</a>";
//Get Parent ID
$t_id = $this->SQL_TABLE->GET_ROW($t_id)->GET_ATTRIBUTE(1);
//If parent doesn't exist, end generation
......@@ -25,7 +27,7 @@
{
//If parent exists, add to breadcrumb
$t_title = $this->SQL_TABLE->GET_ROW($t_id)->GET_ATTRIBUTE(2);
$link = "<a class='breadcrumbLink' href='viewpage.php?id=".$t_id."'>".$t_title."</a> > ".$link;
$crumb = "<a class='breadcrumbLink' href='".$this->link."?id=".$t_id."'>".$t_title."</a> > ".$crumb;
//Get parent id
$t_id = $this->SQL_TABLE->GET_ROW($t_id)->GET_ATTRIBUTE(1);
}
......@@ -33,7 +35,7 @@
<div id="breadcrumb">
<div id="breadcrumbBox">
<div id="breadcrumbText">
<?php echo $link;?>
<?php echo $crumb;?>
</div>
</div>
</div>
......
......@@ -2,13 +2,18 @@
//create footer
class Footer
{
private $link = null;
function Footer($link)
{
$this->link = $link;
}
//render footer
public function render()
{
?>
<footer id="footer">
<div class="footerText">
<a class="footerLink" href="viewpage.php?id=-1">Site Map</a>
<a class="footerLink" href="<?php echo $this->link;?>?id=-1">Site Map</a>
</div>
</footer>
<?php
......
......@@ -4,9 +4,11 @@
{
private $SQL_TABLE = null;
private $s_id = null;
function Nav($SQL_TABLE, $s_id)
private $link = null;
function Nav($SQL_TABLE, $link, $s_id)
{
$this->SQL_TABLE = $SQL_TABLE;
$this->link = $link;
$this->s_id = $s_id;
}
......@@ -29,7 +31,7 @@
$linkType="NavLink";
$title=$page->GET_ATTRIBUTE(2);
//Add to navbar
$navbar .= "<li><a class='".$linkType."' href='viewpage.php?id=".$id."'>".$title."</a>";
$navbar .= "<li><a class='".$linkType."' href='".$this->link."?id=".$id."'>".$title."</a>";
if($id != 0)
$navbar .= $this->createLevel($this->SQL_TABLE->GET_ROWS_BY_ATTRIBUTE(1,$id));
$navbar .= "</li>\r\n";
......
......@@ -3,9 +3,11 @@
class Sitemap
{
private $SQL_TABLE = null;
function Sitemap($SQL_TABLE)
private $link = null;
function Sitemap($SQL_TABLE, $link)
{
$this->SQL_TABLE = $SQL_TABLE;
$this->link = $link;
}
//recursive function to build sitemap hierarchy
......@@ -23,7 +25,7 @@
//Highlight the selected page.
$title=$page->GET_ATTRIBUTE(2);
//Add to sitemap
$sitemap .= "<li><a href='viewpage.php?id=".$id."'>".$title."</a>";
$sitemap .= "<li><a href='".$this->link."?id=".$id."'>".$title."</a>";
if($id != 0)
$sitemap .= $this->createSitemap($this->SQL_TABLE->GET_ROWS_BY_ATTRIBUTE(1,$id));
$sitemap .= "</li>\r\n";
......
......@@ -43,12 +43,12 @@
//Initialize page component objects
$css = new CSS();
$header = new Header($site_title, $site_logo);
$nav = new NAV($SQL->GET_TABLE(0), $page_id);
$nav = new NAV($SQL->GET_TABLE(0), "viewpage.php", $page_id);
$title = new Title($page_id, $page_title, $page_desc, $page_img);
$breadcrumb = new Breadcrumb($SQL->GET_TABLE(0), $page_id, $page_title);
$breadcrumb = new Breadcrumb($SQL->GET_TABLE(0), "viewpage.php",$page_id, $page_title);
$body = new Body($page_src);
$sitemap = new Sitemap($SQL->GET_TABLE(0));
$footer = new footer();
$sitemap = new Sitemap($SQL->GET_TABLE(0), "viewpage.php");
$footer = new footer("viewpage.php");
//render HTML output
?>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment