POSTTEMPLATE;
?>
set_permalink($_GET["permalink"]);
$blogpost = $totalblog->get_contents();
} else {
$blogpost = $totalblog->get_blog_post("blog", $_GET["permalink"]);
}
}
}
$filter = array(
"sort" => "new",
"date" => "past",
"featured" => "top",
"draft" => "hide",
"archived" => "hide"
);
$authorGallery = $categoryGallery = $tagGallery = $genreGallery = false;
//
//
//
//
// Blog post is not defined, default to false
$postGenre = false;
$postLabel = false;
$postAuthor = false;
$postCategory = false;
$postTag = false;
if (isset($blogpost) && is_object($blogpost)) {
$postAuthor = false;
$postGenre = false;
$postLabel = false;
$postCategory = false;
$postTag = false;
//
$filter["exclude"] = $blogpost->permalink;
//
}
//
//
//
//
//
//
//
if (!empty($_GET)) {
// Merge in with GET variables. GET wins
$filter = array_merge($filter, $_GET);
}
//
if ($publish) {
if (empty($_GET["search"])) {
$posts = $totalblog->filter_posts($filter);
} else {
$posts = $totalblog->search_posts(trim(urldecode($_GET["search"])), $filter);
}
$baseUrl = "";
//
$posturl = $totalblog->posturl;
//
} else {
$posts = $totalblog->get_blog("blog", $filter);
$baseUrl = "https://emmanueladams.org/";
$posturl = "#";
}
//
$imagetype = "thumbs-auto";
$maxcount = 3;
$cardColumns = 2;
$postdata = array();
foreach ($posts as $post) {
if ($post->gallery) {
array_map(function ($image) use ($baseUrl) {
$image->img = $baseUrl.$image->img;
$image->thumb->sq = $baseUrl.$image->thumb->sq;
$image->thumb->th = $baseUrl.$image->thumb->th;
return $image;
}, $post->gallery);
$post->slideshow = false;
$post->type = $imagetype;
$imagecount = count($post->gallery);
//
//
// Dont process just one image unless its a thumb layout
if ($imagecount > 1 || strpos($imagetype, "thumb") !== false) {
switch ($imagetype) {
case "featured":
usort($post->gallery, function ($a, $b) {
return $b->featured - $a->featured;
});
$post->gallery = array(array_shift($post->gallery));
break;
case "first":
$post->gallery = array(array_shift($post->gallery));
break;
case "last":
$post->gallery = array(array_pop($post->gallery));
break;
case "random":
shuffle($post->gallery);
$post->gallery = array(array_shift($post->gallery));
break;
case "orbit":
$post->slideshow = true;
$post->gallery = array_slice($post->gallery, 0, $maxcount);
break;
case "thumbs":
$thumbCount = $maxcount;
if ($cardColumns == 0) {
$max = $maxcount > $imagecount ? $imagecount : $maxcount;
$thumbCount = $max;
} elseif ($cardColumns > $imagecount) {
// If there isn"t enough images to fill one row, only have one image
$post->type = "first";
$thumbCount = 1;
} else {
// Make sure that there are no empty slots in a row
$max = $maxcount > $imagecount ? $imagecount : $maxcount;
$thumbCount = floor($max/$cardColumns) * $cardColumns;
}
$post->gallery = array_slice($post->gallery, 0, $thumbCount);
break;
case "thumbs-auto":
$thumbCount = $maxcount;
$mincount = 4;
if ($mincount > $imagecount) {
// If there isn"t enough images to fill one grid, only have one image
$post->type = "first";
$thumbCount = 1;
} else {
// Make sure that there are no empty slots in a row
$max = $maxcount > $imagecount ? $imagecount : $maxcount;
$columns = floor(sqrt($max));
$thumbCount = $columns * $columns;
$post->type = $post->type." thumb-grid-".$columns;
}
$post->gallery = array_slice($post->gallery, 0, $thumbCount);
break;
}
}
}
$post->summary = $totalblog->format_text($post->summary);
$post->datetime = $totalblog->to_date($post->timestamp);
$post->timer = (5*1000) + rand(0, 2500);
$post->url = $posturl.$post->permalink;
$post->id = "blog/".$post->permalink;
$post->aria = "Read more about ";
$post->genrelink = $totalblog->urlify_string($post->genre);
if (is_object($genreGallery)) {
$genreImage = $genreGallery->get_image_path($post->genrelink, "sq");
$defaultgenre = "";
if (empty($defaultGenre)) {
$defaultGenre = "https://emmanueladams.org/cms-data/image/defaultGenreCMSID.png";
}
$post->genreimage = $genreImage ? $baseUrl.$genreImage : $defaultGenre;
}
$post->authorlink = $totalblog->urlify_string($post->author);
if (is_object($authorGallery)) {
$authorImage = $authorGallery->get_image_path($post->authorlink, "sq");
$defaultAuthor = "";
if (empty($defaultAuthor)) {
$defaultAuthor = "https://emmanueladams.org/cms-data/image/defaultAuthorCMSID.png";
}
$post->authorimage = $authorImage ? $baseUrl.$authorImage : $defaultAuthor;
}
$post->tags = array_map(function ($tag) use ($totalblog, $tagGallery) {
// ignore if the tag is already converted to array
if (is_array($tag)) {
return $tag;
}
// ignore if the tag starts with -
if (strpos($tag, "-") === 0) {
return false;
}
$link = $totalblog->urlify_string($tag);
$new = array("label"=>$tag,"link"=>$link);
if (is_object($tagGallery)) {
$image = $tagGallery->get_image_path($link, "sq");
$defaultTag = "";
if (empty($defaultTag)) {
$defaultTag = "https://emmanueladams.org/cms-data/image/defaultTagCMSID.png";
}
$new["image"] = $image ? "https://emmanueladams.org/".$image : $defaultTag;
}
return $new;
}, $post->tags);
$post->tags = array_filter($post->tags, "is_array");
$post->categories = array_map(function ($category) use ($totalblog, $categoryGallery) {
// ignore if the category is already converted to array
if (is_array($category)) {
return $category;
}
// ignore if the category starts with -
if (strpos($category, "-") === 0) {
return false;
}
$link = $totalblog->urlify_string($category);
$new = array("label"=>$category,"link"=>$link);
if (is_object($categoryGallery)) {
$image = $categoryGallery->get_image_path($link, "sq");
$defaultCategory = "";
if (empty($defaultCategory)) {
$defaultCategory = "https://emmanueladams.org/cms-data/image/defaultCategoryCMSID.png";
}
$new["image"] = $image ? "https://emmanueladams.org/".$image : $defaultCategory;
}
return $new;
}, $post->categories);
$post->categories = array_filter($post->categories, "is_array");
// This is here for pre-1.7 posts that do not have labels
if (!isset($post->labels)) {
$post->labels = [];
}
$post->labels = array_map(function ($label) use ($totalblog) {
// ignore if the label is already converted to array
if (is_array($label)) {
return $label;
}
// ignore if the label starts with -
if (strpos($label, "-") === 0) {
return false;
}
$link = $totalblog->urlify_string($label);
$new = array("label"=>$label,"link"=>$link);
return $new;
}, $post->labels);
$post->labels = array_filter($post->labels, "is_array");
$postdata[] = $post;
}
if (count($postdata) == 0) {
echo "
No Posts Found
";
} else {
foreach (array_slice($postdata, 0, 10) as $post) {
echo $totalblog->process_template($post_template, $post);
}
}
?>