Skip to content

Commit

Permalink
Merge pull request #29 from mreishman/0.1-Dev
Browse files Browse the repository at this point in the history
0.1.2
  • Loading branch information
mreishman authored Jan 6, 2019
2 parents 81b2279 + f17aff0 commit fcb8fb4
Show file tree
Hide file tree
Showing 11 changed files with 205 additions and 17 deletions.
33 changes: 33 additions & 0 deletions core/content/about/info.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
<div>
<h1>Changelog</h1>
<ul>
<li>
0.1.2
<ul>
<li>
Features
<ul>
<li>
Navigation now highlights active page
</li>
<li>
Added sitemap page
</li>
</ul>
</li>
<li>
Bug Fixes
<ul>
<li>
Gallery images do not require id (gets default from src)
</li>
<li>
Added target option for links in galleries
</li>
<li>
Fixed typo in navigation function
</li>
<li>
Having navigation groups without a main page works correctly now
</li>
</ul>
</li>
</ul>
</li>
<li>
0.1.1
<ul>
Expand Down
2 changes: 1 addition & 1 deletion core/content/base/footer.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<footer>
<p><a href="https://github.com/mreishman/WebCoreMJR" >Powered by WebCoreMJR</a></p>
<p><a href="https://github.com/mreishman/WebCoreMJR" >Powered by WebCoreMJR</a> | <a href="/sitemap">Sitemap</a></p>
</footer>
3 changes: 3 additions & 0 deletions core/content/base/sitemap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
$sitemap = $header->generateSitemap();
echo $header->generateNavUL($sitemap);
2 changes: 1 addition & 1 deletion core/content/homepage/home.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div>
<h1 style="text-align: center;" >
WebCoreMJR 0.1
WebCoreMJR 0.1.2
</h1>
<p style="text-align: center;">
WebCoreMJR is a somewhat simple website framework that uses php and xml, and doesn't use a database. I mainly created this for use in my own websites, but decided to create a dedicated website for it.
Expand Down
10 changes: 9 additions & 1 deletion core/css/navigation.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/css/navigation.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion core/php/functions/coreFunctions/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public function loadDirFilesRec($directory, $arrayOfFiles = array(), $addedDir =
{
$arrayOfFiles[$entireFileOrDir] = array(
"fileName" => $fileOrDir,
"fileNamePlusPath" => $addedDir."/".$fileOrDir
"fileNamePlusPath" => $addedDir."/".$fileOrDir,
"path" => $addedDir
);
}
}
Expand Down
41 changes: 33 additions & 8 deletions core/php/functions/pageFunctions/gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

class gallery
{
private function getDefaultId($data)
{
return preg_replace('/[^a-z0-9]+/', '_', strtolower($data["src"]));
}

public function generateGallery($arrayOfImages, $config = array())
{
$htmlToReturn = "";
Expand Down Expand Up @@ -68,8 +73,13 @@ public function generateGallery($arrayOfImages, $config = array())
$htmlToReturn .= "
";
}
$id = $this->getDefaultId($value);
if(isset($value["id"]))
{
$id = $value["id"];
}
$htmlToReturn .= "<".$tag.">";
$link = "#".$value["id"];
$link = "#".$id;
$image = $value["src"];
$thumb = $value["src"];
if(isset($value["link"]))
Expand All @@ -80,14 +90,19 @@ public function generateGallery($arrayOfImages, $config = array())
{
$thumb = $value["thumb"];
}
$target = "";
if(isset($value["target"]))
{
$target = " target=\"".$value["target"]."\"";
}
$htmlToReturn .= "
<a href=\"".$link."\" >
<a href=\"".$link."\"".$target.">
<img src=\"".$thumb."\" width=\"".$imgWidth."\" height=\"".$imgHeight."\" >
</a>";
if($link === "#".$value["id"])
if($link === "#".$id)
{
$htmlToReturn .= "
<span class=\"lightbox\" id=\"".$value["id"]."\">
<span class=\"lightbox\" id=\"".$id."\">
<span class=\"lightboxForeground\">
<a href=\"#_\" class=\"lightboxClose \" >
<span class=\"lightbox-icon-bar-top\"></span>
Expand All @@ -96,14 +111,14 @@ public function generateGallery($arrayOfImages, $config = array())
if($arrows && $arrayOfImagesCounter !== 0)
{
$htmlToReturn .= "
<a href=\"#".$arrayOfImagesGen[$arrayOfImagesCounter-1]["id"]."\" class=\"arrow left lightboxLeft\" ></a>";
<a href=\"#".$this->getDefaultId($arrayOfImagesGen[$arrayOfImagesCounter-1])."\" class=\"arrow left lightboxLeft\" ></a>";
}
$htmlToReturn .= "
<img src=\"".$image."\">";
if($arrows && ($arrayOfImagesCounter + 1) < $arrayOfImagesCount)
{
$htmlToReturn .= "
<a href=\"#".$arrayOfImagesGen[($arrayOfImagesCounter+1)]["id"]."\" class=\"arrow right lightboxRight\" ></a>";
<a href=\"#".$this->getDefaultId($arrayOfImagesGen[$arrayOfImagesCounter+1])."\" class=\"arrow right lightboxRight\" ></a>";
}
if($galleryThumbs)
{
Expand All @@ -117,8 +132,13 @@ public function generateGallery($arrayOfImages, $config = array())
{
break;
}
$id = $this->getDefaultId($value2);
if(isset($value2["id"]))
{
$id = $value2["id"];
}
$thumb2 = $value2["src"];
$link2 = "#".$value2["id"];
$link2 = "#".$id;
if(isset($value2["thumb"]))
{
$thumb2 = $value2["thumb"];
Expand Down Expand Up @@ -149,8 +169,13 @@ public function generateGallery($arrayOfImages, $config = array())
{
continue;
}
$id = $this->getDefaultId($value2);
if(isset($value2["id"]))
{
$id = $value2["id"];
}
$thumb2 = $value2["src"];
$link2 = "#".$value2["id"];
$link2 = "#".$id;
if(isset($value2["thumb"]))
{
$thumb2 = $value2["thumb"];
Expand Down
100 changes: 97 additions & 3 deletions core/php/functions/pageFunctions/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ private function modifyArrayAgain($newNavArray)
}

public function generateNavigationArray()
{
return $this->generateNavigationArrayWithParams(0);
}

public function generateSitemap()
{
return $this->generateNavigationArrayWithParams(-1);
}

private function generateNavigationArrayWithParams($minCurrent)
{
$currentDir = realpath(__DIR__ . '/../../../..')."/";
$xmlDir = $currentDir."core/xml/content/";
Expand All @@ -66,11 +76,22 @@ public function generateNavigationArray()
$arrayOfFiles[$currentFileKey]["position"] = intval($xmlLayout->menu->position);
$arrayOfFiles[$currentFileKey]["name"] = (string)$xmlLayout->menu->name;
$arrayOfFiles[$currentFileKey]["key"] = (string)$xmlLayout->menu->key;
$current = 0;
$currentURI = "$_SERVER[REQUEST_URI]";
if("$_SERVER[REQUEST_URI]" === "/")
{
$currentURI = "/home";
}
if($currentURI === explode(".xml", $arrayOfFiles[$currentFileKey]["fileNamePlusPath"])[0])
{
$current = 1;
}
$arrayOfFiles[$currentFileKey]["current"] = $current;
}
$newNavArray = array();
foreach ($arrayOfFiles as $AOFvalue)
{
if($AOFvalue["position"] === 0)
if($AOFvalue["position"] <= $minCurrent)
{
continue; //skip if position is 0
}
Expand All @@ -89,21 +110,94 @@ public function generateNavigationArray()
return $newNavArray;
}

private function findIfSubCurrent($files)
{
foreach ($files as $name => $file)
{
if(isset($file["files"]))
{
if(!empty($file["files"]) && $this->findIfSubCurrent($file["files"]))
{
return true;
}
}
if($file["current"] === 1)
{
return true;
}
}
return false;
}

public function generateNavUL($navArray, $htmlToReturn = "")
{
$htmlToReturn .= "<ul>";
foreach ($navArray as $key => $value)
{
$classText = "";
$addClassText = false;
if(isset($value["files"]))
{
if(!empty($value["files"]))
{
$htmlToReturn .= "<li><a href=\"".explode(".xml", $value["fileNamePlusPath"])[0]."\" >".$value["name"]."</a>".$this->generateNavUl($value["files"])."</li>";
$current = $this->findIfSubCurrent($value["files"]);
$classToAdd = " class=\"";
if($current || (isset($value["current"]) && $value["current"] === 1))
{
$classToAdd .= " active ";
$addClassText = true;
}
$linkForAtag = "";
if(isset($value["fileNamePlusPath"]))
{
$linkForAtag = " href=\"".explode(".xml", $value["fileNamePlusPath"])[0]."\"";
}
else
{
$classToAdd .= " noLink ";
$addClassText = true;
}
$name = "";
if(isset($value["name"]))
{
$name = $value["name"];
}
else
{
//no name set, grab from folder
foreach ($value["files"] as $file)
{
$name = $file["path"];
if(strpos($name, "/") === 0)
{
$name = ltrim($name, '/');
}
$name = ucfirst($name);
break;
}
}
$classToAdd .= " \"";
if($addClassText)
{
$classText = $classToAdd;
}
$htmlToReturn .= "<li><a ".$classText." ".$linkForAtag.">".$name."</a>".$this->generateNavUL($value["files"])."</li>";
}
}
else
{
$htmlToReturn .= "<li><a href=\"".explode(".xml", $value["fileNamePlusPath"])[0]."\" >".$value["name"]."</a></li>";
$classToAdd = " class=\"";
if($value["current"] === 1)
{
$classToAdd .= " active ";
$addClassText = true;
}
$classToAdd .= " \"";
if($addClassText)
{
$classText = $classToAdd;
}
$htmlToReturn .= "<li><a ".$classText." href=\"".explode(".xml", $value["fileNamePlusPath"])[0]."\" >".$value["name"]."</a></li>";
}
}
$htmlToReturn .= "</ul>";
Expand Down
11 changes: 10 additions & 1 deletion core/sass/navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@
text-decoration: none;
padding: 12px 16px;
color: $linkColorAlt;

&:hover, &.active {
background-color: $backgroundColorMain;
color: $fontColorMain;
}
}

a:hover, .dropdown:hover .dropbtn {
.dropdown:hover .dropbtn {
background-color: $backgroundColorMain;
color: $fontColorMain;
}
Expand Down Expand Up @@ -133,6 +138,10 @@
display: none;
}

.noLink{
cursor: default;
}

@media only screen and (max-width : 640px) {

.navigationSpan{
Expand Down
15 changes: 15 additions & 0 deletions core/xml/content/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<page>
<layout>oneColumn</layout>
<title>Sitemap</title>
<menu>
<position>-1</position>
<name>Sitemap</name>
<key>sitemap</key>
</menu>
<content>
<group>base</group>
<file>sitemap</file>
<type>php</type>
</content>
</page>

0 comments on commit fcb8fb4

Please sign in to comment.