From 0df247887909c1fe081fb31ea4de38de59dcbe9f Mon Sep 17 00:00:00 2001 From: sean1138 Date: Tue, 12 Jan 2021 14:47:34 -0500 Subject: [PATCH 01/10] label for must = input id https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label#using_the_for_attribute --- system/admin/views/config.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/admin/views/config.html.php b/system/admin/views/config.html.php index 2ad86e5..b6fa129 100644 --- a/system/admin/views/config.html.php +++ b/system/admin/views/config.html.php @@ -41,7 +41,7 @@ foreach ($array as $key => $value) { echo ''; echo ''; - echo ''; + echo ''; echo ''; } ?> From c48290f4e5574f40e3ba9170d7c52cb87963ca13 Mon Sep 17 00:00:00 2001 From: sean1138 Date: Tue, 12 Jan 2021 14:58:31 -0500 Subject: [PATCH 02/10] add category column for view posts tables, each post can have multiplt tags so table column header "Tags" --- system/admin/views/popular-posts.html.php | 4 +++- system/admin/views/posts-list.html.php | 4 +++- system/admin/views/user-draft.html.php | 4 +++- system/admin/views/user-posts.html.php | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/system/admin/views/popular-posts.html.php b/system/admin/views/popular-posts.html.php index 1265928..03ed3ab 100644 --- a/system/admin/views/popular-posts.html.php +++ b/system/admin/views/popular-posts.html.php @@ -6,7 +6,8 @@ - + + views ?> author ?> + category ?> tag ?> Edit Delete diff --git a/system/admin/views/posts-list.html.php b/system/admin/views/posts-list.html.php index 52f6cd4..b618170 100644 --- a/system/admin/views/posts-list.html.php +++ b/system/admin/views/posts-list.html.php @@ -6,7 +6,8 @@ Views - + + views ?> author ?> + category ?> tag ?> diff --git a/system/admin/views/user-draft.html.php b/system/admin/views/user-draft.html.php index 57d401f..e77a93e 100644 --- a/system/admin/views/user-draft.html.php +++ b/system/admin/views/user-draft.html.php @@ -4,7 +4,8 @@ - + + "> title ?> date) ?> + category) ?> tag) ?> diff --git a/system/admin/views/user-posts.html.php b/system/admin/views/user-posts.html.php index 7a0a2d3..bf03d6a 100644 --- a/system/admin/views/user-posts.html.php +++ b/system/admin/views/user-posts.html.php @@ -7,7 +7,8 @@ Views - + + views ?> + category ?> tag ?> Edit From 2a7f8e938e8dcb4dfe0d5068332c37f0183c3010 Mon Sep 17 00:00:00 2001 From: sean1138 Date: Tue, 12 Jan 2021 15:07:59 -0500 Subject: [PATCH 03/10] add category column for view posts tables, each post can have multiple tags so table column header "Tags" --- system/admin/admin.php | 95 +++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/system/admin/admin.php b/system/admin/admin.php index 8afcb56..37855be 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -58,7 +58,7 @@ function session($user, $pass) $_SESSION[config("site.url")]['user'] = $user; header('location: admin'); } else { - return $str = '
  • Your username and password mismatch.
  • '; + return $str = '
  • Your username and password mismatch.
  • '; } } else if (old_password_verify($pass, $user_enc, $user_pass)) { update_user($user, $pass, $user_role); @@ -104,46 +104,46 @@ function add_content($title, $tag, $url, $content, $user, $description = null, $ $tagmd = "\n"; } else { $tagmd = ""; - } + } if ($media!== null) { $post_media = "\n"; } else { $post_media = ""; - } + } $post_content = "" . $post_description . $tagmd . $post_media . "\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { - + if (get_magic_quotes_gpc()) { $post_content = stripslashes($post_content); } - + $filename = $post_date . '_' . $post_tag . '_' . $post_url . '.md'; - + if (empty($draft)) { $dir = 'content/' . $user . '/blog/' . $category. '/'.$type. '/'; } else { $dir = 'content/' . $user . '/blog/' . $category. '/draft/'; } - + if (is_dir($dir)) { file_put_contents($dir . $filename, print_r($post_content, true)); } else { mkdir($dir, 0775, true); file_put_contents($dir . $filename, print_r($post_content, true)); } - + save_tag_i18n($post_tag, $post_tagmd); rebuilt_cache('all'); clear_post_cache($post_date, $post_tag, $post_url, $dir . $filename, $category, $type); - + if (empty($draft)) { $redirect = site_url() . 'admin/mine'; } else { $redirect = site_url() . 'admin/draft'; } - + header("Location: $redirect"); } } @@ -154,7 +154,7 @@ function edit_content($title, $tag, $url, $content, $oldfile, $destination = nul $oldurl = explode('_', $oldfile); $dir = explode('/', $oldurl[0]); $olddate = date('Y-m-d-H-i-s', strtotime($date)); - + if ($date !== null) { $oldurl[0] = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/' . $olddate; } @@ -177,47 +177,47 @@ function edit_content($title, $tag, $url, $content, $oldfile, $destination = nul $tagmd = "\n"; } else { $tagmd = ""; - } + } if ($media !== null) { $post_media = "\n"; } else { $post_media = ""; - } + } $post_content = "" . $post_description . $tagmd . $post_media . "\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { - + if (get_magic_quotes_gpc()) { $post_content = stripslashes($post_content); } - + if(!empty($revertPost) || !empty($publishDraft)) { - + $dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/' . $type . '/'; $dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/'; - + if($dir[4] == 'draft') { - $filename = $dirBlog . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + $filename = $dirBlog . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; } else { - $filename = $dirDraft . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + $filename = $dirDraft . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; } - + if (is_dir($dirBlog)) { } else { - mkdir($dirBlog, 0775, true); + mkdir($dirBlog, 0775, true); } - + if (is_dir($dirDraft)) { } else { - mkdir($dirDraft, 0775, true); + mkdir($dirDraft, 0775, true); } - + file_put_contents($filename, print_r($post_content, true)); unlink($oldfile); $newfile = $olddate . '_' . $post_tag . '_' . $post_url . '.md'; - + } else { - + if ($dir[3] === $category) { $newfile = $oldurl[0] . '_' . $post_tag . '_' . $post_url . '.md'; if ($oldfile === $newfile) { @@ -227,37 +227,37 @@ function edit_content($title, $tag, $url, $content, $oldfile, $destination = nul file_put_contents($newfile, print_r($post_content, true)); } } else { - + $dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/' . $type. '/'; $dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/'; if($dir[4] == 'draft') { - $filename = $dirDraft . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + $filename = $dirDraft . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; } else { - $filename = $dirBlog . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + $filename = $dirBlog . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; } if (is_dir($dirBlog)) { } else { - mkdir($dirBlog, 0775, true); + mkdir($dirBlog, 0775, true); } if (is_dir($dirDraft)) { } else { - mkdir($dirDraft, 0775, true); + mkdir($dirDraft, 0775, true); } file_put_contents($filename, print_r($post_content, true)); unlink($oldfile); $newfile = $olddate . '_' . $post_tag . '_' . $post_url . '.md'; - + } - + } if(!empty($publishDraft)) { $dt = $olddate; - $t = str_replace('-', '', $dt); + $t = str_replace('-', '', $dt); $time = new DateTime($t); $timestamp = $time->format("Y-m-d"); } else { @@ -267,19 +267,19 @@ function edit_content($title, $tag, $url, $content, $oldfile, $destination = nul $time = new DateTime($t); $timestamp = $time->format("Y-m-d"); } - + // The post date $postdate = strtotime($timestamp); - + // The post URL if (config('permalink.type') == 'post') { $posturl = site_url() . 'post/' . $post_url; } else { $posturl = site_url() . date('Y/m', $postdate) . '/' . $post_url; } - + save_tag_i18n($post_tag, $post_tagmd); - + rebuilt_cache('all'); clear_post_cache($dt, $post_tag, $post_url, $newfile, $category, $type); if ($destination == 'post') { @@ -375,7 +375,7 @@ function add_sub_page($title, $url, $content, $static, $description = null) function edit_page($title, $url, $content, $oldfile, $destination = null, $description = null, $static = null) { $dir = substr($oldfile, 0, strrpos($oldfile, '/')); - + $post_title = safe_html($title); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); $description = safe_html($description); @@ -410,7 +410,7 @@ function edit_page($title, $url, $content, $oldfile, $destination = null, $descr } else { $posturl = site_url() . $post_url; } - + rebuilt_cache('all'); clear_page_cache($post_url); if ($destination == 'post') { @@ -471,7 +471,7 @@ function edit_category($title, $url, $content, $oldfile, $destination = null, $d } $post_content = '' . $post_description . "\n\n" . $content; if (!empty($post_title) && !empty($post_url) && !empty($post_content)) { - + if (get_magic_quotes_gpc()) { $post_content = stripslashes($post_content); } @@ -482,9 +482,9 @@ function edit_category($title, $url, $content, $oldfile, $destination = null, $d rename($oldfile, $newfile); file_put_contents($newfile, print_r($post_content, true)); } - + rename_category_folder($post_url, $oldfile); - + rebuilt_cache('all'); if ($destination == 'post') { header("Location: $posturl"); @@ -681,7 +681,7 @@ function get_user_posts() echo '' . i18n('Title') . '' . i18n('Published') . ''; if (config("views.counter") == "true") echo 'Views'; - echo '' . i18n('Tag') . '' . i18n('Operations') . ''; + echo '' . i18n('Category') . '' . i18n('Tags') . '' . i18n('Operations') . ''; $i = 0; $len = count($posts); foreach ($posts as $p) { @@ -698,6 +698,7 @@ function get_user_posts() echo '' . format_date($p->date) . ''; if (config("views.counter") == "true") echo '' . $p->views . ''; + echo '' . $p->category . ''; echo '' . $p->tag . ''; echo '' . i18n('Edit') . ' ' . i18n('Delete') . ''; echo ''; @@ -815,7 +816,7 @@ function clear_post_cache($post_date, $post_tag, $post_url, $filename, $category if (file_exists($p)) { unlink($p); } - + // Delete post permalink $pp = 'cache/page/' . $b . 'post#' . $post_url . '.cache'; if (file_exists($pp)) { @@ -873,7 +874,7 @@ function clear_post_cache($post_date, $post_tag, $post_url, $filename, $category foreach (glob('cache/page/' . $b . 'search#*.cache', GLOB_NOSORT) as $file) { unlink($file); } - + // Delete category $cc = 'cache/page/' . $b . 'category#' . $category . '.cache'; if (file_exists($cc)) { @@ -882,7 +883,7 @@ function clear_post_cache($post_date, $post_tag, $post_url, $filename, $category foreach (glob('cache/page/' . $b . 'category#' . $category . '~*.cache', GLOB_NOSORT) as $file) { unlink($file); } - + // Delete type $tp = 'cache/page/' . $b . 'type#' . $type . '.cache'; if (file_exists($tp)) { From 394f667692d2d34de5efc629eecd16a6a4f45eb4 Mon Sep 17 00:00:00 2001 From: sean1138 Date: Tue, 12 Jan 2021 16:07:00 -0500 Subject: [PATCH 04/10] more labels for form inputs --- system/admin/views/add-content.html.php | 102 +++++++++++++++++--------------- system/admin/views/add-page.html.php | 29 +++++---- 2 files changed, 69 insertions(+), 62 deletions(-) diff --git a/system/admin/views/add-content.html.php b/system/admin/views/add-content.html.php index d65688a..50ce84d 100644 --- a/system/admin/views/add-content.html.php +++ b/system/admin/views/add-content.html.php @@ -1,10 +1,10 @@ - - + @@ -27,77 +27,81 @@ $desc = get_category_info(null);
    - * -
    - -

    - * -
    - +

    + +
    + -

    - Tag * -
    - -

    - Url (optional)
    -
    + +

    + +
    + +

    + +
    + +
    If the url leave empty we will use the post title. -

    - (optional)
    - -

    - +

    + +
    + +

    + - Featured Audio * (SoundCloud Only) -
    - + +
    + -
    +
    - + - Featured Video * (Youtube Only) -
    - + +
    + -
    +
    - + - Featured Image * -
    - + +
    + -
    +
    - + - Featured Quote * -
    - + +
    + -
    +
    - + - Featured Link * -
    - + +
    + -
    +
    - + +
    -
    +
    diff --git a/system/admin/views/add-page.html.php b/system/admin/views/add-page.html.php index 22051d7..315e3dd 100644 --- a/system/admin/views/add-page.html.php +++ b/system/admin/views/add-page.html.php @@ -1,5 +1,5 @@ - + @@ -14,21 +14,24 @@
    - Title * -
    - -

    - Url (optional)
    -
    + +
    + +

    + +
    + +
    If the url leave empty we will use the page title. -

    - Meta Description (optional) -
    - -

    +

    + +
    + +

    +
    -
    +
    From cf1f75d664e88079f04114061defde2e987420e1 Mon Sep 17 00:00:00 2001 From: sean1138 Date: Tue, 12 Jan 2021 16:29:46 -0500 Subject: [PATCH 05/10] added if statements to remove inputs not needed for adding a category --- system/admin/views/add-page.html.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/admin/views/add-page.html.php b/system/admin/views/add-page.html.php index 315e3dd..5fb3bf2 100644 --- a/system/admin/views/add-page.html.php +++ b/system/admin/views/add-page.html.php @@ -18,6 +18,7 @@


    +
    @@ -28,8 +29,11 @@


    + +
    +
    From 79732ef9193d4c9eb050cb7e9adb13c65e4cb1bd Mon Sep 17 00:00:00 2001 From: sean1138 Date: Tue, 12 Jan 2021 16:43:51 -0500 Subject: [PATCH 06/10] more labels for form inputs --- system/admin/views/edit-content.html.php | 102 ++++++++++++++++--------------- system/admin/views/edit-page.html.php | 25 +++++--- 2 files changed, 69 insertions(+), 58 deletions(-) diff --git a/system/admin/views/edit-content.html.php b/system/admin/views/edit-content.html.php index 39ee212..0188e09 100644 --- a/system/admin/views/edit-content.html.php +++ b/system/admin/views/edit-content.html.php @@ -56,7 +56,7 @@ if (config('permalink.type') == 'post') { ?> - + @@ -71,78 +71,84 @@ if (config('permalink.type') == 'post') {
    - * -
    - -

    - * -
    - +

    + +
    + -

    - Tag *
    -

    - Url (optional)
    - -
    + +

    + +
    +

    + +
    + +
    If the url leave empty we will use the post title. -

    - Year, Month, Day
    - -
    - Hour, Minute, Second
    - -

    - Meta Description (optional)
    - -

    - +

    + +
    + +
    + +
    + +

    + +
    + +

    + - Featured Audio * (SoundCloud Only) -
    - + +
    + - + - Featured Video * (Youtube Only) -
    - + +
    + - + - Featured Image * -
    - + +
    + - + - Featured Quote * -
    - + +
    + - + - Featured Link * -
    - + +
    + - + -
    +
    +
    -
    +
    diff --git a/system/admin/views/edit-page.html.php b/system/admin/views/edit-page.html.php index fde8ca1..61ea563 100644 --- a/system/admin/views/edit-page.html.php +++ b/system/admin/views/edit-page.html.php @@ -64,7 +64,7 @@ if ($type == 'is_frontpage') { ?> - + @@ -79,20 +79,25 @@ if ($type == 'is_frontpage') {
    - * -
    -

    + +
    +

    - Url (optional)
    -
    + +
    + +
    If the url leave empty we will use the page title. -

    - (optional)
    -

    +

    + +
    + +

    +
    -
    +
    From 32807b09f788d158736490a7ff7060f69f6208ec Mon Sep 17 00:00:00 2001 From: sean1138 Date: Tue, 12 Jan 2021 17:16:51 -0500 Subject: [PATCH 07/10] add basic selected styles for toolbar links --- system/includes/functions.php | 377 +++++++++++++++++++-------------------- system/resources/css/toolbar.css | 16 ++ 2 files changed, 200 insertions(+), 193 deletions(-) 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[] = ''; $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 '
        • No popular posts found
        '; @@ -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 .= '
            '; //previous button - if ($page > 1) + if ($page > 1) $pagination .= '
          • « Prev
          • '; else - $pagination .= '
          • « Prev
          • '; - - //pages + $pagination .= '
          • « Prev
          • '; + + //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up - { + { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination .= '
          • '. $counter.'
          • '; else - $pagination .= '
          • '. $counter .'
          • '; + $pagination .= '
          • '. $counter .'
          • '; } } elseif($lastpage >= 7 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages - if($page < 1 + ($adjacents * 3)) + if($page < 1 + ($adjacents * 3)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination .= '
          • '. $counter .'
          • '; else - $pagination .= '
          • '. $counter .'
          • '; + $pagination .= '
          • '. $counter .'
          • '; } $pagination .= '
          • ...
          • '; $pagination .= '
          • '. $lpm1 .'
          • '; - $pagination .= '
          • '. $lastpage .'
          • '; + $pagination .= '
          • '. $lastpage .'
          • '; } //in middle; hide some front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) @@ -1618,11 +1618,11 @@ function get_pagination($page = 1, $totalitems, $perpage = 10, $adjacents = 1, $ if ($counter == $page) $pagination .= '
          • '. $counter .'
          • '; else - $pagination .= '
          • '. $counter .'
          • '; + $pagination .= '
          • '. $counter .'
          • '; } $pagination .= '
          • ...
          • '; $pagination .= '
          • '. $lpm1 .'
          • '; - $pagination .= '
          • '. $lastpage .'
          • '; + $pagination .= '
          • '. $lastpage .'
          • '; } //close to end; only hide early pages else @@ -1635,19 +1635,19 @@ function get_pagination($page = 1, $totalitems, $perpage = 10, $adjacents = 1, $ if ($counter == $page) $pagination .= '
          • '. $counter .'
          • '; else - $pagination .= '
          • '. $counter .'
          • '; + $pagination .= '
          • '. $counter .'
          • '; } } } - + //next button - if ($page < $counter - 1) + if ($page < $counter - 1) $pagination .= '
          • Next »
          • '; else $pagination .= '
          • Next »
          • '; $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()