diff --git a/system/includes/functions.php b/system/includes/functions.php
index 6bb5667..80b6b99 100644
--- a/system/includes/functions.php
+++ b/system/includes/functions.php
@@ -229,11 +229,11 @@ function rebuilt_cache($type)
rebuilt_cache('author');
rebuilt_cache('category');
}
-
+
foreach (glob('cache/widget/*.cache', GLOB_NOSORT) as $file) {
unlink($file);
}
-
+
}
// Return blog posts.
@@ -247,7 +247,7 @@ function get_posts($posts, $page = 1, $perpage = 0)
// Extract a specific page with results
$posts = array_slice($posts, ($page - 1) * $perpage, $perpage);
-
+
$catC = category_list(true);
foreach ($posts as $index => $v) {
@@ -270,14 +270,14 @@ function get_posts($posts, $page = 1, $perpage = 0)
$post->category = '' . $category->title . '';
$post->categoryb = '' . $category->title . '';
} else {
-
+
foreach ($catC as $k => $v) {
if ($v['0'] === $str[count($str) - 3]) {
$post->category = '' . $v['1'] . '';
$post->categoryb = '' . $v['1'] . '';
}
}
-
+
}
$type = $str[count($str) - 2];
$post->ct = $str[count($str) - 3];
@@ -285,7 +285,7 @@ function get_posts($posts, $page = 1, $perpage = 0)
// The post author + author url
$post->author = $author;
$post->authorUrl = site_url() . 'author/' . $author;
-
+
$post->type = $type;
$dt = str_replace($replaced, '', $arr[0]);
@@ -298,13 +298,13 @@ function get_posts($posts, $page = 1, $perpage = 0)
// The archive per day
$post->archive = site_url() . 'archive/' . date('Y-m', $post->date);
-
+
if (config('permalink.type') == 'post') {
$post->url = site_url() . 'post/' . str_replace('.md', '', $arr[2]);
} else {
$post->url = site_url() . date('Y/m', $post->date) . '/' . str_replace('.md', '', $arr[2]);
}
-
+
$post->file = $filepath;
$content = file_get_contents($filepath);
@@ -316,15 +316,15 @@ function get_posts($posts, $page = 1, $perpage = 0)
$post->link = get_content_tag('link', $content);
$post->quote = get_content_tag('quote', $content);
$post->audio = get_content_tag('audio', $content);
-
+
$tag = array();
$url = array();
$bc = array();
$rel = array();
-
+
$tagt = get_content_tag('tag', $content);
$t = explode(',', rtrim($arr[1], ','));
-
+
if(!empty($tagt)) {
$tl = explode(',', rtrim($tagt, ','));
$tCom = array_combine($t, $tl);
@@ -334,13 +334,13 @@ function get_posts($posts, $page = 1, $perpage = 0)
} else {
$tag[] = array($key, site_url() . 'tag/' . strtolower($key));
}
- }
+ }
} else {
foreach ($t as $tt) {
$tag[] = array($tt, site_url() . 'tag/' . strtolower($tt));
}
}
-
+
foreach ($tag as $a) {
$url[] = '' . $a[0] . '';
$bc[] = '' . $a[0] . '';
@@ -349,14 +349,14 @@ function get_posts($posts, $page = 1, $perpage = 0)
$post->tag = implode(' ', $url);
$post->tagb = implode(' » ', $bc);
-
+
$post->related = rtrim($arr[1], ',');
-
+
$more = explode('', $content);
if (isset($more['1'])) {
$content = $more['0'] . '
' . "\n\n" . '' . $more['1'];
}
-
+
// Get the contents and convert it to HTML
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
@@ -386,7 +386,7 @@ function find_post($year, $month, $name)
foreach ($posts as $index => $v) {
$arr = explode('_', $v['basename']);
- if ((strpos($arr[0], "$year-$month") !== false && strtolower($arr[2]) === strtolower($name . '.md')) || ($year === NULL && strtolower($arr[2]) === strtolower($name . '.md'))) {
+ if (strpos($arr[0], "$year-$month") !== false && strtolower($arr[2]) === strtolower($name . '.md') || strtolower($arr[2]) === strtolower($name . '.md')) {
// Use the get_posts method to return
// a properly parsed object
@@ -473,13 +473,13 @@ function get_category($category, $page, $perpage)
$posts = get_post_sorted();
$tmp = array();
-
+
if (empty($perpage)) {
- $perpage = 10;
+ $perpage = 10;
}
foreach ($posts as $index => $v) {
-
+
$filepath = $v['dirname'] . '/' . $v['basename'];
// Extract the date
@@ -491,7 +491,7 @@ function get_category($category, $page, $perpage)
// Author string
$str = explode('/', $replaced);
$cat = $str[count($str) - 3];
-
+
if (strtolower($category) === strtolower($cat)) {
$tmp[] = $v;
}
@@ -500,7 +500,7 @@ function get_category($category, $page, $perpage)
if (empty($tmp)) {
not_found();
}
-
+
$tmp = array_unique($tmp, SORT_REGULAR);
return $tmp = get_posts($tmp, $page, $perpage);
@@ -525,9 +525,9 @@ function get_category_info($category)
// The static page URL
$url= str_replace($replaced, '', $v);
-
+
$desc->url = site_url() . 'category/' . str_replace('.md', '', $url);
-
+
$desc->md = str_replace('.md', '', $url);
$desc->file = $v;
@@ -537,7 +537,7 @@ function get_category_info($category)
// Extract the title and body
$desc->title = get_content_tag('t', $content, $category);
-
+
// Get the contents and convert it to HTML
$desc->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
@@ -547,11 +547,11 @@ function get_category_info($category)
}
}
}
-
+
if (strtolower($category) == 'uncategorized') {
return default_category();
}
-
+
return $tmp;
}
@@ -573,19 +573,19 @@ function default_category()
// Return category list
function category_list($custom = null) {
-
+
$dir = "cache/widget";
$filename = "cache/widget/category.list.cache";
$tmp = array();
$cat = array();
$list = array();
-
+
if (is_dir($dir) === false) {
mkdir($dir, 0775, true);
}
-
+
if (file_exists($filename)) {
- $cat = unserialize(file_get_contents($filename));
+ $cat = unserialize(file_get_contents($filename));
} else {
$arr = get_category_info(null);
foreach ($arr as $a) {
@@ -596,21 +596,21 @@ function category_list($custom = null) {
$tmp = serialize($cat);
file_put_contents($filename, print_r($tmp, true));
}
-
+
if(!empty($custom)) {
return $cat;
}
-
+
echo '
';
-
+
foreach ($cat as $k => $v) {
if (get_categorycount($v['0']) !== 0) {
echo '- ' . $v['1']. '
';
}
}
-
+
echo '
';
-
+
}
// Return type page.
@@ -619,13 +619,13 @@ function get_type($type, $page, $perpage)
$posts = get_post_sorted();
$tmp = array();
-
+
if (empty($perpage)) {
- $perpage = 10;
+ $perpage = 10;
}
foreach ($posts as $index => $v) {
-
+
$filepath = $v['dirname'] . '/' . $v['basename'];
// Extract the date
@@ -637,7 +637,7 @@ function get_type($type, $page, $perpage)
// Author string
$str = explode('/', $replaced);
$tp = $str[count($str) - 2];
-
+
if (strtolower($type) === strtolower($tp)) {
$tmp[] = $v;
}
@@ -646,7 +646,7 @@ function get_type($type, $page, $perpage)
if (empty($tmp)) {
not_found();
}
-
+
$tmp = array_unique($tmp, SORT_REGULAR);
return $tmp = get_posts($tmp, $page, $perpage);
@@ -680,7 +680,7 @@ function get_tag($tag, $page, $perpage, $random)
if (empty($tmp)) {
not_found();
}
-
+
$tmp = array_unique($tmp, SORT_REGULAR);
return $tmp = get_posts($tmp, $page, $perpage);
@@ -766,7 +766,7 @@ function get_author($name)
if (!empty($names)) {
foreach ($names as $index => $v) {
-
+
$author = new stdClass;
// Replaced string
@@ -786,7 +786,7 @@ function get_author($name)
// Extract the title and body
$author->name = get_content_tag('t', $content, $author);
-
+
// Get the contents and convert it to HTML
$author->about = MarkdownExtra::defaultTransform(remove_html_comments($content));
@@ -844,7 +844,7 @@ function get_static_post($static)
// Extract the title and body
$post->title = get_content_tag('t', $content, $static);
-
+
// Get the contents and convert it to HTML
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
@@ -890,7 +890,7 @@ function get_static_sub_post($static, $sub_static)
// Extract the title and body
$post->title = get_content_tag('t', $content, $sub_static);
-
+
// Get the contents and convert it to HTML
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
@@ -910,7 +910,7 @@ function get_static_sub_post($static, $sub_static)
function get_frontpage()
{
$front = new stdClass;
-
+
$filename = 'content/data/frontpage/frontpage.md';
if (file_exists($filename)) {
@@ -924,7 +924,7 @@ function get_frontpage()
$front->url = site_url() . 'front';
$front->body = 'Welcome to our website.';
}
-
+
return $front;
}
@@ -951,8 +951,8 @@ function get_keyword($keyword, $page, $perpage)
return $tmp;
}
- return $tmp = get_posts($tmp, $page, $perpage);
-
+ return $tmp = get_posts($tmp, $page, $perpage);
+
}
// Get related posts base on post tag.
@@ -976,7 +976,7 @@ function get_related($tag, $custom = null, $count = null)
$tmp[] = $post;
}
}
-
+
if (empty($custom)) {
$total = count($tmp);
@@ -991,15 +991,15 @@ function get_related($tag, $custom = null, $count = null)
break;
}
echo '';
-
+
} else {
echo '- ' . i18n('No_related_post_found') . '
';
}
-
+
} else {
return $tmp;
}
-
+
}
// Return post count. Matching $var and $str provided.
@@ -1028,7 +1028,7 @@ function get_categorycount($var)
$tmp = array();
foreach ($posts as $index => $v) {
-
+
$filepath = $v['dirname'] . '/' . $v['basename'];
// Extract the date
@@ -1056,7 +1056,7 @@ function get_typecount($var)
$tmp = array();
foreach ($posts as $index => $v) {
-
+
$filepath = $v['dirname'] . '/' . $v['basename'];
// Extract the date
@@ -1085,7 +1085,7 @@ function get_draftcount($var)
$tmp = array();
foreach ($posts as $index => $v) {
-
+
$filepath = $v['dirname'] . '/' . $v['basename'];
// Extract the date
@@ -1097,7 +1097,7 @@ function get_draftcount($var)
// Author string
$str = explode('/', $replaced);
$cat = $str[count($str) - 3];
-
+
if (stripos($cat, "$var") !== false) {
$tmp[] = $v;
}
@@ -1112,7 +1112,7 @@ function get_tagcount($var, $str)
$posts = get_post_sorted();
$tmp = array();
-
+
foreach ($posts as $index => $v) {
$arr = explode('_', $v[$str]);
$mtag = explode(',', rtrim($arr[1], ','));
@@ -1159,33 +1159,33 @@ function recent_posts($custom = null, $count = null)
$count = 5;
}
}
-
+
$dir = "cache/widget";
$filename = "cache/widget/recent.cache";
$tmp = array();
$posts = array();
-
+
if (is_dir($dir) === false) {
mkdir($dir, 0775, true);
}
-
+
if (file_exists($filename)) {
$posts = unserialize(file_get_contents($filename));
if (count($posts) != $count) {
$posts = get_posts(null, 1, $count);
$tmp = serialize($posts);
file_put_contents($filename, print_r($tmp, true));
- }
+ }
} else {
$posts = get_posts(null, 1, $count);
$tmp = serialize($posts);
file_put_contents($filename, print_r($tmp, true));
}
-
+
if (!empty($custom)) {
- return $posts;
+ return $posts;
} else {
-
+
echo '';
foreach ($posts as $post) {
echo '- ' . $post->title . '
';
@@ -1206,33 +1206,33 @@ function recent_type($type, $custom = null, $count = null)
$count = 5;
}
}
-
+
$dir = 'cache/widget';
$filename = 'cache/widget/recent.' . $type . '.cache';
$tmp = array();
$posts = array();
-
+
if (is_dir($dir) === false) {
mkdir($dir, 0775, true);
}
-
+
if (file_exists($filename)) {
$posts = unserialize(file_get_contents($filename));
if (count($posts) != $count) {
$posts = get_type($type, 1, $count);
$tmp = serialize($posts);
file_put_contents($filename, print_r($tmp, true));
- }
+ }
} else {
$posts = get_type($type, 1, $count);
$tmp = serialize($posts);
file_put_contents($filename, print_r($tmp, true));
}
-
+
if (!empty($custom)) {
- return $posts;
+ return $posts;
} else {
-
+
echo '';
foreach ($posts as $post) {
echo '- ' . $post->title . '
';
@@ -1245,7 +1245,7 @@ function recent_type($type, $custom = null, $count = null)
}
// Return popular posts lists
-function popular_posts($custom = null, $count = null)
+function popular_posts($custom = null, $count = null)
{
static $_views = array();
@@ -1257,7 +1257,7 @@ function popular_posts($custom = null, $count = null)
$count = 5;
}
}
-
+
if (config('views.counter') == 'true') {
if (empty($_views)) {
$filename = 'content/data/views.json';
@@ -1275,7 +1275,7 @@ function popular_posts($custom = null, $count = null)
}
}
}
-
+
$dir = "cache/widget";
$filecache = "cache/widget/popular.cache";
$ar = array();
@@ -1314,7 +1314,7 @@ function popular_posts($custom = null, $count = null)
} else {
return $tmp;
}
- }
+ }
} else {
if (empty($custom)) {
echo '';
@@ -1339,17 +1339,17 @@ function archive_list($custom = null)
$dir = "cache/widget";
$filename = "cache/widget/archive.cache";
$ar = array();
-
+
if (is_dir($dir) === false) {
mkdir($dir, 0775, true);
}
-
+
$posts = get_post_unsorted();
$by_year = array();
$col = array();
if (!empty($posts)) {
-
+
if (!file_exists($filename)) {
foreach ($posts as $index => $v) {
@@ -1370,17 +1370,17 @@ function archive_list($custom = null)
$m = $row['1'];
$by_year[$y][] = $m;
}
-
+
$ar = serialize($by_year);
file_put_contents($filename, print_r($ar, true));
-
+
} else {
- $by_year = unserialize(file_get_contents($filename));
+ $by_year = unserialize(file_get_contents($filename));
}
# Most recent year first
krsort($by_year);
-
+
# Iterate for display
$i = 0;
$len = count($by_year);
@@ -1395,11 +1395,11 @@ function archive_list($custom = null)
$arrow = '►';
}
$i++;
-
+
$by_month = array_count_values($months);
# Sort the months
krsort($by_month);
-
+
$script = << -1){this.parentNode.className = 'collapsed';this.innerHTML = '►';} else {this.parentNode.className = 'expanded';this.innerHTML = '▼';}
EOF;
@@ -1433,11 +1433,11 @@ function tag_cloud($custom = null)
$dir = "cache/widget";
$filename = "cache/widget/tags.cache";
$tg = array();
-
+
if (is_dir($dir) === false) {
mkdir($dir, 0775, true);
}
-
+
$posts = get_post_unsorted();
$tags = array();
@@ -1459,7 +1459,7 @@ function tag_cloud($custom = null)
} else {
$tag_collection = unserialize(file_get_contents($filename));
}
-
+
if(empty($custom)) {
echo '';
foreach ($tag_collection as $tag => $count) {
@@ -1539,7 +1539,7 @@ function has_pagination($total, $perpage, $page = 1)
$total = count(get_post_unsorted());
}
$totalPage = ceil($total / $perpage);
- $number = i18n('Page') . ' ' . $page . ' ' . i18n('of') . ' ' . $totalPage;
+ $number = 'Page '. $page . ' of ' . $totalPage;
$pager = get_pagination($page, $total, $perpage, 2);
return array(
'prev' => $page > 1,
@@ -1553,59 +1553,59 @@ function has_pagination($total, $perpage, $page = 1)
//function to return the pagination string
function get_pagination($page = 1, $totalitems, $perpage = 10, $adjacents = 1, $pagestring = '?page=')
-{
+{
//defaults
if(!$adjacents) $adjacents = 1;
if(!$perpage) $perpage = 10;
if(!$page) $page = 1;
-
+
//other vars
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($totalitems / $perpage); //lastpage is = total items / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
-
- /*
- Now we apply our rules and draw the pagination object.
+
+ /*
+ Now we apply our rules and draw the pagination object.
We're actually saving the code to a variable in case we want to draw it more than once.
*/
$pagination = '';
if($lastpage > 1)
- {
+ {
$pagination .= '';
}
-
+
return $pagination;
}
@@ -1678,16 +1678,16 @@ function get_teaser($string, $url = null, $char = null)
$teaserType = config('teaser.type');
$more = config('read.more');
-
+
if(empty($more)) {
$more = 'Read more';
}
-
+
if(empty($char)) {
$char = config('teaser.char');
if(empty($char)) {
$char = 200;
- }
+ }
}
if ($teaserType === 'full') {
@@ -1858,14 +1858,9 @@ function disqus($title = null, $url = null)
$disqus = config('disqus.shortname');
$script = <<
- var getAbsolutePath = function(href) {
- var link = document.createElement('a');
- link.href = href;
- return link.href;
- };
var disqus_shortname = '{$disqus}';
var disqus_title = '{$title}';
- var disqus_url = getAbsolutePath('{$url}');
+ var disqus_url = '{$url}';
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
@@ -1921,7 +1916,7 @@ function facebook()