Browse Source

Cleanup

pull/674/head
danpros 1 year ago
parent
commit
91587d9bcc
2 changed files with 150 additions and 121 deletions
  1. +20
    -18
      system/admin/admin.php
  2. +130
    -103
      system/includes/functions.php

+ 20
- 18
system/admin/admin.php View File

@ -1300,36 +1300,38 @@ function toolbar()
$user = $_SESSION[site_url()]['user']; $user = $_SESSION[site_url()]['user'];
$role = user('role', $user); $role = user('role', $user);
$base = site_url(); $base = site_url();
$toolbar = '';
echo <<<EOF
$toolbar .= <<<EOF
<link href="{$base}system/resources/css/toolbar.css" rel="stylesheet" /> <link href="{$base}system/resources/css/toolbar.css" rel="stylesheet" />
EOF; EOF;
echo '<div id="toolbar"><ul>';
echo '<li class="tb-admin"><a href="' . $base . 'admin">' . i18n('Admin') . '</a></li>';
echo '<li class="tb-addcontent"><a href="' . $base . 'admin/content">' . i18n('Add_content') . '</a></li>';
$toolbar .= '<div id="toolbar"><ul>';
$toolbar .= '<li class="tb-admin"><a href="' . $base . 'admin">' . i18n('Admin') . '</a></li>';
$toolbar .= '<li class="tb-addcontent"><a href="' . $base . 'admin/content">' . i18n('Add_content') . '</a></li>';
if ($role === 'admin') { if ($role === 'admin') {
echo '<li class="tb-posts"><a href="' . $base . 'admin/posts">' . i18n('Posts') . '</a></li>';
$toolbar .= '<li class="tb-posts"><a href="' . $base . 'admin/posts">' . i18n('Posts') . '</a></li>';
if (config('views.counter') == 'true') { if (config('views.counter') == 'true') {
echo '<li class="tb-popular"><a href="' . $base . 'admin/popular">' . i18n('Popular') . '</a></li>';
$toolbar .= '<li class="tb-popular"><a href="' . $base . 'admin/popular">' . i18n('Popular') . '</a></li>';
} }
} }
echo '<li class="tb-mine"><a href="' . $base . 'admin/pages">' . i18n('Pages') . '</a></li>';
echo '<li class="tb-draft"><a href="' . $base . 'admin/scheduled">' . i18n('Scheduled') . '</a></li>';
echo '<li class="tb-draft"><a href="' . $base . 'admin/draft">' . i18n('Draft') . '</a></li>';
$toolbar .= '<li class="tb-mine"><a href="' . $base . 'admin/pages">' . i18n('Pages') . '</a></li>';
$toolbar .= '<li class="tb-draft"><a href="' . $base . 'admin/scheduled">' . i18n('Scheduled') . '</a></li>';
$toolbar .= '<li class="tb-draft"><a href="' . $base . 'admin/draft">' . i18n('Draft') . '</a></li>';
if ($role === 'admin') { if ($role === 'admin') {
echo '<li class="tb-categories"><a href="' . $base . 'admin/categories">' . i18n('Categories') . '</a></li>';
$toolbar .= '<li class="tb-categories"><a href="' . $base . 'admin/categories">' . i18n('Categories') . '</a></li>';
} }
echo '<li class="tb-import"><a href="' . $base . 'admin/menu">' . i18n('Menu') . '</a></li>';
$toolbar .= '<li class="tb-import"><a href="' . $base . 'admin/menu">' . i18n('Menu') . '</a></li>';
if ($role === 'admin') { if ($role === 'admin') {
echo '<li class="tb-config"><a href="' . $base . 'admin/config">' . i18n('Config') . '</a></li>';
$toolbar .= '<li class="tb-config"><a href="' . $base . 'admin/config">' . i18n('Config') . '</a></li>';
} }
echo '<li class="tb-backup"><a href="' . $base . 'admin/backup">' . i18n('Backup') . '</a></li>';
echo '<li class="tb-update"><a href="' . $base . 'admin/update">' . i18n('Update') . '</a></li>';
echo '<li class="tb-clearcache"><a href="' . $base . 'admin/clear-cache">' . i18n('Clear_cache') . '</a></li>';
echo '<li class="tb-editprofile"><a href="' . $base . 'edit/profile">' . i18n('Edit_profile') . '</a></li>';
echo '<li class="tb-logout"><a href="' . $base . 'logout">' . i18n('Logout') . '</a></li>';
$toolbar .= '<li class="tb-backup"><a href="' . $base . 'admin/backup">' . i18n('Backup') . '</a></li>';
$toolbar .= '<li class="tb-update"><a href="' . $base . 'admin/update">' . i18n('Update') . '</a></li>';
$toolbar .= '<li class="tb-clearcache"><a href="' . $base . 'admin/clear-cache">' . i18n('Clear_cache') . '</a></li>';
$toolbar .= '<li class="tb-editprofile"><a href="' . $base . 'edit/profile">' . i18n('Edit_profile') . '</a></li>';
$toolbar .= '<li class="tb-logout"><a href="' . $base . 'logout">' . i18n('Logout') . '</a></li>';
echo '</ul></div>';
$toolbar .= '</ul></div>';
echo $toolbar;
} }
// save the i18n tag // save the i18n tag


+ 130
- 103
system/includes/functions.php View File

@ -976,6 +976,7 @@ function category_list($custom = null)
$tmp = array(); $tmp = array();
$cat = array(); $cat = array();
$list = array(); $list = array();
$cList = '';
if (!is_dir($dir)) { if (!is_dir($dir)) {
mkdir($dir, 0775, true); mkdir($dir, 0775, true);
@ -997,15 +998,16 @@ function category_list($custom = null)
return $cat; return $cat;
} }
echo '<ul>';
$cList .= '<ul>';
foreach ($cat as $k => $v) { foreach ($cat as $k => $v) {
if ($v['2'] !== 0) { if ($v['2'] !== 0) {
echo '<li><a href="' . site_url() . 'category/' . $v['0'] . '">' . $v['1'] . '</a> <span>('. $v['2'] .')</span></li>';
$cList .= '<li><a href="' . site_url() . 'category/' . $v['0'] . '">' . $v['1'] . '</a> <span>('. $v['2'] .')</span></li>';
} }
} }
echo '</ul>';
$cList .= '</ul>';
return $cList;
} }
@ -1255,6 +1257,7 @@ function get_related($tag, $custom = null, $count = null)
$tmp = array(); $tmp = array();
$exp = explode(',', $tag); $exp = explode(',', $tag);
$posts = get_category($exp[0], 1, $count + 1, true); $posts = get_category($exp[0], 1, $count + 1, true);
$related = '';
foreach ($posts as $post) { foreach ($posts as $post) {
if ($post->url !== $exp[1]) { if ($post->url !== $exp[1]) {
@ -1265,15 +1268,17 @@ function get_related($tag, $custom = null, $count = null)
if (empty($custom)) { if (empty($custom)) {
if (!empty($tmp)) { if (!empty($tmp)) {
$i = 1; $i = 1;
echo '<ul>';
$related .= '<ul>';
foreach ($tmp as $post) { foreach ($tmp as $post) {
echo '<li><a href="' . $post->url . '">' . $post->title . '</a></li>';
$related .= '<li><a href="' . $post->url . '">' . $post->title . '</a></li>';
if ($i++ >= $count) if ($i++ >= $count)
break; break;
} }
echo '</ul>';
$related .= '</ul>';
return $related;
} else { } else {
echo '<ul><li>' . i18n('No_related_post_found') . '</li></ul>';
$related .= '<ul><li>' . i18n('No_related_post_found') . '</li></ul>';
return $related;
} }
} else { } else {
@ -1437,6 +1442,7 @@ function recent_posts($custom = null, $count = null)
$filename = "cache/widget/recent.cache"; $filename = "cache/widget/recent.cache";
$tmp = array(); $tmp = array();
$posts = array(); $posts = array();
$recent = '';
if (!is_dir($dir)) { if (!is_dir($dir)) {
mkdir($dir, 0775, true); mkdir($dir, 0775, true);
@ -1458,15 +1464,15 @@ function recent_posts($custom = null, $count = null)
if (!empty($custom)) { if (!empty($custom)) {
return $posts; return $posts;
} else { } else {
echo '<ul>';
$recent .= '<ul>';
foreach ($posts as $post) { foreach ($posts as $post) {
echo '<li><a href="' . $post->url . '">' . $post->title . '</a></li>';
$recent .= '<li><a href="' . $post->url . '">' . $post->title . '</a></li>';
} }
if (empty($posts)) { if (empty($posts)) {
echo '<li>' . i18n('No_posts_found') . '</li>';
$recent .= '<li>' . i18n('No_posts_found') . '</li>';
} }
echo '</ul>';
$recent .= '</ul>';
return $recent;
} }
} }
@ -1483,6 +1489,7 @@ function recent_type($type, $custom = null, $count = null)
$dir = 'cache/widget'; $dir = 'cache/widget';
$filename = 'cache/widget/recent.' . $type . '.cache'; $filename = 'cache/widget/recent.' . $type . '.cache';
$tmp = array(); $tmp = array();
$recent = '';
if (!is_dir($dir)) { if (!is_dir($dir)) {
mkdir($dir, 0775, true); mkdir($dir, 0775, true);
@ -1505,14 +1512,15 @@ function recent_type($type, $custom = null, $count = null)
return $posts; return $posts;
} else { } else {
echo '<ul>';
$recent .= '<ul>';
foreach ($posts as $post) { foreach ($posts as $post) {
echo '<li><a href="' . $post->url . '">' . $post->title . '</a></li>';
$recent .= '<li><a href="' . $post->url . '">' . $post->title . '</a></li>';
} }
if (empty($posts)) { if (empty($posts)) {
echo '<li>No recent ' . $type . ' found</li>';
$recent .= '<li>No recent ' . $type . ' found</li>';
} }
echo '</ul>';
$recent .= '</ul>';
return $recent;
} }
} }
@ -1522,6 +1530,7 @@ function popular_posts($custom = null, $count = null)
static $_views = array(); static $_views = array();
$tmp = array(); $tmp = array();
$posts_list = get_blog_posts(); $posts_list = get_blog_posts();
$pop = '';
if (empty($count)) { if (empty($count)) {
$count = config('popular.count'); $count = config('popular.count');
@ -1575,24 +1584,27 @@ function popular_posts($custom = null, $count = null)
} }
if (empty($custom)) { if (empty($custom)) {
echo '<ul>';
$pop .= '<ul>';
foreach ($posts as $post) { foreach ($posts as $post) {
echo '<li><a href="' . $post->url . '">' . $post->title . '</a></li>';
$pop .= '<li><a href="' . $post->url . '">' . $post->title . '</a></li>';
} }
echo '</ul>';
$pop .= '</ul>';
return $pop;
} else { } else {
return $posts; return $posts;
} }
} else { } else {
if(empty($custom)) { if(empty($custom)) {
echo '<ul><li>No popular posts found</li></ul>';
$pop .= '<ul><li>No popular posts found</li></ul>';
return $pop;
} else { } else {
return $tmp; return $tmp;
} }
} }
} else { } else {
if (empty($custom)) { if (empty($custom)) {
echo '<ul><li>No popular posts found</li></ul>';
$pop .= '<ul><li>No popular posts found</li></ul>';
return $pop;
} else { } else {
return $tmp; return $tmp;
} }
@ -1600,7 +1612,8 @@ function popular_posts($custom = null, $count = null)
} }
} else { } else {
if (empty($custom)) { if (empty($custom)) {
echo '<ul><li>No popular posts found</li></ul>';
$pop .= '<ul><li>No popular posts found</li></ul>';
return $pop;
} else { } else {
return $tmp; return $tmp;
} }
@ -1613,6 +1626,7 @@ function archive_list($custom = null)
$dir = "cache/widget"; $dir = "cache/widget";
$filename = "cache/widget/archive.cache"; $filename = "cache/widget/archive.cache";
$ar = array(); $ar = array();
$arch = '';
if (!is_dir($dir)) { if (!is_dir($dir)) {
mkdir($dir, 0775, true); mkdir($dir, 0775, true);
@ -1673,23 +1687,24 @@ function archive_list($custom = null)
$script = <<<EOF $script = <<<EOF
if (this.parentNode.className.indexOf('expanded') > -1){this.parentNode.className = 'collapsed';this.innerHTML = '&#9658;';} else {this.parentNode.className = 'expanded';this.innerHTML = '&#9660;';} if (this.parentNode.className.indexOf('expanded') > -1){this.parentNode.className = 'collapsed';this.innerHTML = '&#9658;';} else {this.parentNode.className = 'expanded';this.innerHTML = '&#9660;';}
EOF; EOF;
echo '<ul class="archivegroup">';
echo '<li class="' . $class . '">';
echo '<a href="javascript:void(0)" class="toggle" onclick="' . $script . '">' . $arrow . '</a> ';
echo '<a href="' . site_url() . 'archive/' . $year . '">' . $year . '</a> ';
echo '<span class="count">(' . count($months) . ')</span>';
echo '<ul class="month">';
$arch .= '<ul class="archivegroup">';
$arch .= '<li class="' . $class . '">';
$arch .= '<a href="javascript:void(0)" class="toggle" onclick="' . $script . '">' . $arrow . '</a> ';
$arch .= '<a href="' . site_url() . 'archive/' . $year . '">' . $year . '</a> ';
$arch .= '<span class="count">(' . count($months) . ')</span>';
$arch .= '<ul class="month">';
foreach ($by_month as $month => $count) { foreach ($by_month as $month => $count) {
$name = format_date(mktime(0, 0, 0, $month, 1, 2010), 'F'); $name = format_date(mktime(0, 0, 0, $month, 1, 2010), 'F');
echo '<li class="item"><a href="' . site_url() . 'archive/' . $year . '-' . $month . '">' . $name . '</a>';
echo ' <span class="count">(' . $count . ')</span></li>';
$arch .= '<li class="item"><a href="' . site_url() . 'archive/' . $year . '-' . $month . '">' . $name . '</a>';
$arch .= ' <span class="count">(' . $count . ')</span></li>';
} }
echo '</ul>';
echo '</li>';
echo '</ul>';
$arch .= '</ul>';
$arch .= '</li>';
$arch .= '</ul>';
} }
return $arch;
} elseif ($custom === 'month-year') { } elseif ($custom === 'month-year') {
foreach ($by_year as $year => $months) { foreach ($by_year as $year => $months) {
$by_month = array_count_values($months); $by_month = array_count_values($months);
@ -1697,16 +1712,18 @@ EOF;
krsort($by_month); krsort($by_month);
foreach ($by_month as $month => $count) { foreach ($by_month as $month => $count) {
$name = format_date(mktime(0, 0, 0, $month, 1, 2010), 'F'); $name = format_date(mktime(0, 0, 0, $month, 1, 2010), 'F');
echo '<li class="item"><a href="' . site_url() . 'archive/' . $year . '-' . $month . '">' . $name . ' ' . $year .'</a> ('.$count.')</li>';
$arch .= '<li class="item"><a href="' . site_url() . 'archive/' . $year . '-' . $month . '">' . $name . ' ' . $year .'</a> ('.$count.')</li>';
} }
} }
return $arch;
} elseif ($custom === 'year') { } elseif ($custom === 'year') {
foreach ($by_year as $year => $months) { foreach ($by_year as $year => $months) {
$by_month = array_count_values($months); $by_month = array_count_values($months);
# Sort the months # Sort the months
krsort($by_month); krsort($by_month);
echo '<li class="item"><a href="' . site_url() . 'archive/' . $year . '">' . $year .'</a> ('. count($months) .')</li>';
$arch .= '<li class="item"><a href="' . site_url() . 'archive/' . $year . '">' . $year .'</a> ('. count($months) .')</li>';
} }
return $arch;
} else { } else {
return $by_year; return $by_year;
} }
@ -1770,14 +1787,15 @@ function tag_cloud($custom = null)
// this is the increase per tag quantity (times used) // this is the increase per tag quantity (times used)
$step = ($max_size - $min_size)/($spread); $step = ($max_size - $min_size)/($spread);
$wrapper = '';
arsort($tag_collection); arsort($tag_collection);
$sliced_tags = array_slice($tag_collection, 0, $tagcloud_count, true); $sliced_tags = array_slice($tag_collection, 0, $tagcloud_count, true);
ksort($sliced_tags); ksort($sliced_tags);
foreach ($sliced_tags as $tag => $count) { foreach ($sliced_tags as $tag => $count) {
$size = $min_size + (($count - $min_qty) * $step); $size = $min_size + (($count - $min_qty) * $step);
echo ' <a class="tag-cloud-link" href="'. site_url(). 'tag/'. $tag .'" style="font-size:'. $size .'pt;">'.tag_i18n($tag).'</a> ';
$wrapper .= ' <a class="tag-cloud-link" href="'. site_url(). 'tag/'. $tag .'" style="font-size:'. $size .'pt;">'.tag_i18n($tag).'</a> ';
} }
return $wrapper;
} else { } else {
return $tag_collection; return $tag_collection;
@ -2165,15 +2183,17 @@ function tab($p)
{ {
$user = $_SESSION[site_url()]['user']; $user = $_SESSION[site_url()]['user'];
$role = user('role', $user); $role = user('role', $user);
$tab = '';
if (isset($p->author)) { if (isset($p->author)) {
if ($user === $p->author || $role === 'admin') { if ($user === $p->author || $role === 'admin') {
echo '<div class="tab"><ul class="nav nav-tabs"><li role="presentation" class="active"><a href="' . $p->url . '">' . i18n('View') .'</a></li><li><a href="' . $p->url . '/edit?destination=post">'. i18n('Edit') .'</a></li></ul></div>';
$tab = '<div class="tab"><ul class="nav nav-tabs"><li role="presentation" class="active"><a href="' . $p->url . '">' . i18n('View') .'</a></li><li><a href="' . $p->url . '/edit?destination=post">'. i18n('Edit') .'</a></li></ul></div>';
} }
} else { } else {
if ($p->url) { if ($p->url) {
echo '<div class="tab"><ul class="nav nav-tabs"><li role="presentation" class="active"><a href="' . $p->url . '">' . i18n('View') .'</a></li><li><a href="' . $p->url . '/edit?destination=post">'. i18n('Edit') .'</a></li></ul></div>';
$tab = '<div class="tab"><ul class="nav nav-tabs"><li role="presentation" class="active"><a href="' . $p->url . '">' . i18n('View') .'</a></li><li><a href="' . $p->url . '/edit?destination=post">'. i18n('Edit') .'</a></li></ul></div>';
} }
} }
return $tab;
} }
// Social links. Deprecated // Social links. Deprecated
@ -2183,24 +2203,26 @@ function social($imgDir = null)
$facebook = config('social.facebook'); $facebook = config('social.facebook');
$tumblr = config('social.tumblr'); $tumblr = config('social.tumblr');
$rss = site_url() . 'feed/rss'; $rss = site_url() . 'feed/rss';
$social = '';
if ($imgDir === null) { if ($imgDir === null) {
$imgDir = "readable/img/"; $imgDir = "readable/img/";
} }
if (!empty($twitter)) { if (!empty($twitter)) {
echo '<a href="' . $twitter . '" target="_blank"><img src="' . site_url() . 'themes/' . $imgDir . 'twitter.png" width="32" height="32" alt="Twitter"/></a>';
$social .= '<a href="' . $twitter . '" target="_blank"><img src="' . site_url() . 'themes/' . $imgDir . 'twitter.png" width="32" height="32" alt="Twitter"/></a>';
} }
if (!empty($facebook)) { if (!empty($facebook)) {
echo '<a href="' . $facebook . '" target="_blank"><img src="' . site_url() . 'themes/' . $imgDir . 'facebook.png" width="32" height="32" alt="Facebook"/></a>';
$social .= '<a href="' . $facebook . '" target="_blank"><img src="' . site_url() . 'themes/' . $imgDir . 'facebook.png" width="32" height="32" alt="Facebook"/></a>';
} }
if (!empty($tumblr)) { if (!empty($tumblr)) {
echo '<a href="' . $tumblr . '" target="_blank"><img src="' . site_url() . 'themes/' . $imgDir . 'tumblr.png" width="32" height="32" alt="Tumblr"/></a>';
$social .= '<a href="' . $tumblr . '" target="_blank"><img src="' . site_url() . 'themes/' . $imgDir . 'tumblr.png" width="32" height="32" alt="Tumblr"/></a>';
} }
echo '<a href="' . $rss . '" target="_blank"><img src="' . site_url() . 'themes/' . $imgDir . 'rss.png" width="32" height="32" alt="RSS Feed"/></a>';
$social .= '<a href="' . $rss . '" target="_blank"><img src="' . site_url() . 'themes/' . $imgDir . 'rss.png" width="32" height="32" alt="RSS Feed"/></a>';
return $social;
} }
// Copyright // Copyright
@ -2442,7 +2464,7 @@ function menu($class = null)
$json = json_decode(file_get_contents('content/data/menu.json', true)); $json = json_decode(file_get_contents('content/data/menu.json', true));
$nodes = json_decode($json); $nodes = json_decode($json);
if (empty($nodes)) { if (empty($nodes)) {
get_menu($class);
return get_menu($class);
} else { } else {
$html = parseNodes($nodes, null, $class); $html = parseNodes($nodes, null, $class);
libxml_use_internal_errors(true); libxml_use_internal_errors(true);
@ -2468,7 +2490,7 @@ function menu($class = null)
} }
} else { } else {
get_menu($class);
return get_menu($class);
} }
} }
@ -2489,25 +2511,26 @@ function get_menu($custom = null, $auto = null)
{ {
$posts = get_static_pages(); $posts = get_static_pages();
$req = $_SERVER['REQUEST_URI']; $req = $_SERVER['REQUEST_URI'];
$menu = '';
if (!empty($posts)) { if (!empty($posts)) {
asort($posts); asort($posts);
echo '<ul class="nav ' . $custom . '">';
$menu .= '<ul class="nav ' . $custom . '">';
if (is_null($auto)) { if (is_null($auto)) {
if ($req == site_path() . '/' || stripos($req, site_path() . '/?page') !== false) { if ($req == site_path() . '/' || stripos($req, site_path() . '/?page') !== false) {
echo '<li class="item first active"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
$menu .= '<li class="item first active"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
} else { } else {
echo '<li class="item first"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
$menu .= '<li class="item first"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
} }
if (config('blog.enable') == 'true' ) { if (config('blog.enable') == 'true' ) {
if ($req == site_path() . '/blog' || stripos($req, site_path() . '/blog?page') !== false) { if ($req == site_path() . '/blog' || stripos($req, site_path() . '/blog?page') !== false) {
echo '<li class="item active"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
$menu .= '<li class="item active"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
} else { } else {
echo '<li class="item"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
$menu .= '<li class="item"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
} }
} }
} }
@ -2549,9 +2572,9 @@ function get_menu($custom = null, $auto = null)
$subPages = get_static_subpages($filename); $subPages = get_static_subpages($filename);
if (!empty($subPages)) { if (!empty($subPages)) {
asort($subPages); asort($subPages);
echo '<li class="' . $class . $active .' dropdown">';
echo '<a class="dropdown-toggle" data-toggle="dropdown" href="' . $url . '">' . ucwords($title) . '<b class="caret"></b></a>';
echo '<ul class="subnav dropdown-menu" role="menu">';
$menu .= '<li class="' . $class . $active .' dropdown">';
$menu .= '<a class="dropdown-toggle" data-toggle="dropdown" href="' . $url . '">' . ucwords($title) . '<b class="caret"></b></a>';
$menu .= '<ul class="subnav dropdown-menu" role="menu">';
$iSub = 0; $iSub = 0;
$countSub = count($subPages); $countSub = count($subPages);
foreach ($subPages as $index => $sp) { foreach ($subPages as $index => $sp) {
@ -2575,33 +2598,35 @@ function get_menu($custom = null, $auto = null)
$classSub .= ' active'; $classSub .= ' active';
} }
$urlSub = $url . "/" . $baseSub; $urlSub = $url . "/" . $baseSub;
echo '<li class="' . $classSub . '"><a href="' . $urlSub . '">' . get_title_from_file($child_file) . '</a></li>';
$menu .= '<li class="' . $classSub . '"><a href="' . $urlSub . '">' . get_title_from_file($child_file) . '</a></li>';
$iSub++; $iSub++;
} }
echo '</ul>';
$menu .= '</ul>';
} else { } else {
echo '<li class="' . $class . $active .'">';
echo '<a href="' . $url . '">' . ucwords($title) . '</a>';
$menu .= '<li class="' . $class . $active .'">';
$menu .= '<a href="' . $url . '">' . ucwords($title) . '</a>';
} }
echo '</li>';
$menu .= '</li>';
} }
echo '</ul>';
$menu .='</ul>';
return $menu;
} else { } else {
echo '<ul class="nav ' . $custom . '">';
$menu .= '<ul class="nav ' . $custom . '">';
if ($req == site_path() . '/') { if ($req == site_path() . '/') {
echo '<li class="item first active"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
$menu .= '<li class="item first active"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
} else { } else {
echo '<li class="item first"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
$menu .= '<li class="item first"><a href="' . site_url() . '">' . config('breadcrumb.home') . '</a></li>';
} }
if (config('blog.enable') == 'true' ) { if (config('blog.enable') == 'true' ) {
if ($req == site_path() . '/blog' || stripos($req, site_path() . '/blog?page') !== false) { if ($req == site_path() . '/blog' || stripos($req, site_path() . '/blog?page') !== false) {
echo '<li class="item active"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
$menu .= '<li class="item active"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
} else { } else {
echo '<li class="item"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
$menu .= '<li class="item"><a href="' . site_url() . 'blog">' . 'Blog' . '</a></li>';
} }
} }
echo '</ul>';
$menu .= '</ul>';
return $menu;
} }
} }
@ -2812,60 +2837,61 @@ function sitemap_page_path()
function generate_sitemap($str) function generate_sitemap($str)
{ {
$default_priority = '0.5'; $default_priority = '0.5';
$map = '';
header('X-Robots-Tag: noindex'); header('X-Robots-Tag: noindex');
echo '<?xml version="1.0" encoding="UTF-8"?>';
$map .= '<?xml version="1.0" encoding="UTF-8"?>';
if ($str == 'index.xml') { if ($str == 'index.xml') {
echo '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$map .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
if (config('sitemap.priority.base') !== 'false') { if (config('sitemap.priority.base') !== 'false') {
echo '<sitemap><loc>' . site_url() . 'sitemap.base.xml</loc></sitemap>';
$map .= '<sitemap><loc>' . site_url() . 'sitemap.base.xml</loc></sitemap>';
} }
if (config('sitemap.priority.post') !== 'false') { if (config('sitemap.priority.post') !== 'false') {
echo '<sitemap><loc>' . site_url() . 'sitemap.post.xml</loc></sitemap>';
$map .= '<sitemap><loc>' . site_url() . 'sitemap.post.xml</loc></sitemap>';
} }
if (config('sitemap.priority.static') !== 'false') { if (config('sitemap.priority.static') !== 'false') {
echo '<sitemap><loc>' . site_url() . 'sitemap.static.xml</loc></sitemap>';
$map .= '<sitemap><loc>' . site_url() . 'sitemap.static.xml</loc></sitemap>';
} }
if (config('sitemap.priority.category') !== 'false') { if (config('sitemap.priority.category') !== 'false') {
echo '<sitemap><loc>' . site_url() . 'sitemap.category.xml</loc></sitemap>';
$map .= '<sitemap><loc>' . site_url() . 'sitemap.category.xml</loc></sitemap>';
} }
if (config('sitemap.priority.tag') !== 'false') { if (config('sitemap.priority.tag') !== 'false') {
echo '<sitemap><loc>' . site_url() . 'sitemap.tag.xml</loc></sitemap>';
$map .= '<sitemap><loc>' . site_url() . 'sitemap.tag.xml</loc></sitemap>';
} }
if (config('sitemap.priority.archiveDay') !== 'false' || config('sitemap.priority.archiveMonth') !== 'false' || config('sitemap.priority.archiveYear') !== 'false') { if (config('sitemap.priority.archiveDay') !== 'false' || config('sitemap.priority.archiveMonth') !== 'false' || config('sitemap.priority.archiveYear') !== 'false') {
echo '<sitemap><loc>' . site_url() . 'sitemap.archive.xml</loc></sitemap>';
$map .= '<sitemap><loc>' . site_url() . 'sitemap.archive.xml</loc></sitemap>';
} }
if (config('sitemap.priority.author') !== 'false') { if (config('sitemap.priority.author') !== 'false') {
echo '<sitemap><loc>' . site_url() . 'sitemap.author.xml</loc></sitemap>';
$map .= '<sitemap><loc>' . site_url() . 'sitemap.author.xml</loc></sitemap>';
} }
if (config('sitemap.priority.type') !== 'false') { if (config('sitemap.priority.type') !== 'false') {
echo '<sitemap><loc>' . site_url() . 'sitemap.type.xml</loc></sitemap>';
$map .= '<sitemap><loc>' . site_url() . 'sitemap.type.xml</loc></sitemap>';
} }
echo '</sitemapindex>';
$map .= '</sitemapindex>';
} elseif ($str == 'base.xml') { } elseif ($str == 'base.xml') {
$priority = (config('sitemap.priority.base')) ? config('sitemap.priority.base') : '1.0'; $priority = (config('sitemap.priority.base')) ? config('sitemap.priority.base') : '1.0';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$map .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
if ($priority !== 'false') { if ($priority !== 'false') {
echo '<url><loc>' . site_url() . '</loc><priority>' . $priority . '</priority></url>';
$map .= '<url><loc>' . site_url() . '</loc><priority>' . $priority . '</priority></url>';
} }
echo '</urlset>';
$map .= '</urlset>';
} elseif ($str == 'post.xml') { } elseif ($str == 'post.xml') {
@ -2876,14 +2902,14 @@ function generate_sitemap($str)
$posts = sitemap_post_path(); $posts = sitemap_post_path();
} }
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$map .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
foreach ($posts as $p) { foreach ($posts as $p) {
echo '<url><loc>' . $p->url . '</loc><priority>' . $priority . '</priority><lastmod>' . date('Y-m-d\TH:i:sP', $p->lastMod) . '</lastmod></url>';
$map .= '<url><loc>' . $p->url . '</loc><priority>' . $priority . '</priority><lastmod>' . date('Y-m-d\TH:i:sP', $p->lastMod) . '</lastmod></url>';
} }
echo '</urlset>';
$map .= '</urlset>';
} elseif ($str == 'static.xml') { } elseif ($str == 'static.xml') {
@ -2894,14 +2920,14 @@ function generate_sitemap($str)
$posts = sitemap_page_path(); $posts = sitemap_page_path();
} }
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$map .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
foreach ($posts as $p) { foreach ($posts as $p) {
echo '<url><loc>' . $p->url . '</loc><priority>' . $priority . '</priority><lastmod>' . date('Y-m-d\TH:i:sP', $p->lastMod) . '</lastmod></url>';
$map .= '<url><loc>' . $p->url . '</loc><priority>' . $priority . '</priority><lastmod>' . date('Y-m-d\TH:i:sP', $p->lastMod) . '</lastmod></url>';
} }
echo '</urlset>';
$map .= '</urlset>';
} elseif ($str == 'tag.xml') { } elseif ($str == 'tag.xml') {
@ -2914,7 +2940,7 @@ function generate_sitemap($str)
$tags = array(); $tags = array();
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$map .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
if($posts) { if($posts) {
foreach ($posts as $index => $v) { foreach ($posts as $index => $v) {
@ -2936,12 +2962,12 @@ function generate_sitemap($str)
$tag = array_unique($tag, SORT_REGULAR); $tag = array_unique($tag, SORT_REGULAR);
foreach ($tag as $t) { foreach ($tag as $t) {
echo '<url><loc>' . $t . '</loc><priority>' . $priority . '</priority></url>';
$map .= '<url><loc>' . $t . '</loc><priority>' . $priority . '</priority></url>';
} }
} }
} }
echo '</urlset>';
$map .= '</urlset>';
} elseif ($str == 'archive.xml') { } elseif ($str == 'archive.xml') {
@ -2964,27 +2990,27 @@ function generate_sitemap($str)
$month = array_unique($month, SORT_REGULAR); $month = array_unique($month, SORT_REGULAR);
$year = array_unique($year, SORT_REGULAR); $year = array_unique($year, SORT_REGULAR);
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$map .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
if ($priorityDay !== 'false') { if ($priorityDay !== 'false') {
foreach ($day as $d) { foreach ($day as $d) {
echo '<url><loc>' . $d . '</loc><priority>' . $priorityDay . '</priority></url>';
$map .= '<url><loc>' . $d . '</loc><priority>' . $priorityDay . '</priority></url>';
} }
} }
if ($priorityMonth !== 'false') { if ($priorityMonth !== 'false') {
foreach ($month as $m) { foreach ($month as $m) {
echo '<url><loc>' . $m . '</loc><priority>' . $priorityMonth . '</priority></url>';
$map .= '<url><loc>' . $m . '</loc><priority>' . $priorityMonth . '</priority></url>';
} }
} }
if ($priorityYear !== 'false') { if ($priorityYear !== 'false') {
foreach ($year as $y) { foreach ($year as $y) {
echo '<url><loc>' . $y . '</loc><priority>' . $priorityYear . '</priority></url>';
$map .= '<url><loc>' . $y . '</loc><priority>' . $priorityYear . '</priority></url>';
} }
} }
echo '</urlset>';
$map .= '</urlset>';
} elseif ($str == 'author.xml') { } elseif ($str == 'author.xml') {
@ -3002,15 +3028,15 @@ function generate_sitemap($str)
$author = array_unique($author, SORT_REGULAR); $author = array_unique($author, SORT_REGULAR);
} }
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$map .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
if ($priority !== 'false') { if ($priority !== 'false') {
foreach ($author as $a) { foreach ($author as $a) {
echo '<url><loc>' . $a . '</loc><priority>' . $priority . '</priority></url>';
$map .= '<url><loc>' . $a . '</loc><priority>' . $priority . '</priority></url>';
} }
} }
echo '</urlset>';
$map .= '</urlset>';
} elseif ($str == 'category.xml') { } elseif ($str == 'category.xml') {
@ -3023,7 +3049,7 @@ function generate_sitemap($str)
$cats = array(); $cats = array();
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$map .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
if($posts) { if($posts) {
foreach ($posts as $index => $v) { foreach ($posts as $index => $v) {
@ -3043,12 +3069,12 @@ function generate_sitemap($str)
$cat = array_unique($cat, SORT_REGULAR); $cat = array_unique($cat, SORT_REGULAR);
foreach ($cat as $c) { foreach ($cat as $c) {
echo '<url><loc>' . $c . '</loc><priority>' . $priority . '</priority></url>';
$map .= '<url><loc>' . $c . '</loc><priority>' . $priority . '</priority></url>';
} }
} }
} }
echo '</urlset>';
$map .= '</urlset>';
} elseif ($str == 'type.xml') { } elseif ($str == 'type.xml') {
@ -3061,7 +3087,7 @@ function generate_sitemap($str)
$cats = array(); $cats = array();
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$map .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
if($posts) { if($posts) {
foreach ($posts as $index => $v) { foreach ($posts as $index => $v) {
@ -3080,13 +3106,14 @@ function generate_sitemap($str)
$type = array_unique($type, SORT_REGULAR); $type = array_unique($type, SORT_REGULAR);
foreach ($type as $t) { foreach ($type as $t) {
echo '<url><loc>' . $t . '</loc><priority>' . $priority . '</priority></url>';
$map .= '<url><loc>' . $t . '</loc><priority>' . $priority . '</priority></url>';
} }
} }
} }
echo '</urlset>';
$map .= '</urlset>';
} }
echo $map;
} }
// Function to generate OPML file // Function to generate OPML file
@ -3113,7 +3140,7 @@ function generate_opml()
); );
$opml = new opml($opml_data); $opml = new opml($opml_data);
echo $opml->render();
return $opml->render();
} }
// Turn an array of posts into a JSON // Turn an array of posts into a JSON


Loading…
Cancel
Save