diff --git a/system/admin/admin.php b/system/admin/admin.php index dd4ccba..53644e1 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -98,14 +98,21 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, $post_title = $title; $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), $tag); $post_tag = rtrim($post_tag, ','); + $post_tagmd = rtrim($post_tagmd, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { $post_description = "\n"; } else { $post_description = ""; - } - $post_content = '' . $post_description ."\n\n" . $content; + } + if ($tag !== null) { + $tagmd = "\n"; + } else { + $tagmd = ""; + } + $post_content = '' . $post_description . $tagmd ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { @@ -170,6 +177,8 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, // The post URL $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); if ($destination == 'post') { @@ -207,19 +216,26 @@ function edit_image($title, $tag, $url, $content, $oldfile, $destination = null, $post_title = $title; $post_image = preg_replace('/\s\s+/', ' ', strip_tags($image)); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), $tag); $post_tag = rtrim($post_tag, ','); + $post_tagmd = rtrim($post_tagmd, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { $post_description = "\n"; } else { $post_description = ""; } + if ($tag !== null) { + $tagmd = "\n"; + } else { + $tagmd = ""; + } if ($image !== null) { $post_image = "\n"; } else { $post_image = ""; } - $post_content = '' . $post_description . $post_image ."\n\n" . $content; + $post_content = '' . $post_description . $tagmd . $post_image ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { @@ -284,6 +300,8 @@ function edit_image($title, $tag, $url, $content, $oldfile, $destination = null, // The post URL $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); if ($destination == 'post') { @@ -321,19 +339,26 @@ function edit_video($title, $tag, $url, $content, $oldfile, $destination = null, $post_title = $title; $post_video = preg_replace('/\s\s+/', ' ', strip_tags($video)); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), $tag); $post_tag = rtrim($post_tag, ','); + $post_tagmd = rtrim($post_tagmd, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { $post_description = "\n"; } else { $post_description = ""; } + if ($tag !== null) { + $tagmd = "\n"; + } else { + $tagmd = ""; + } if ($video !== null) { $post_video = "\n"; } else { $post_video = ""; } - $post_content = '' . $post_description . $post_video ."\n\n" . $content; + $post_content = '' . $post_description . $tagmd . $post_video ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { @@ -398,6 +423,8 @@ function edit_video($title, $tag, $url, $content, $oldfile, $destination = null, // The post URL $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); if ($destination == 'post') { @@ -435,19 +462,26 @@ function edit_link($title, $tag, $url, $content, $oldfile, $destination = null, $post_title = $title; $post_link = preg_replace('/\s\s+/', ' ', strip_tags($link)); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), $tag); $post_tag = rtrim($post_tag, ','); + $post_tagmd = rtrim($post_tagmd, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { $post_description = "\n"; } else { $post_description = ""; } + if ($tag !== null) { + $tagmd = "\n"; + } else { + $tagmd = ""; + } if ($link !== null) { $post_link = "\n"; } else { $post_link = ""; } - $post_content = '' . $post_description . $post_link ."\n\n" . $content; + $post_content = '' . $post_description . $tagmd . $post_link ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { @@ -512,6 +546,8 @@ function edit_link($title, $tag, $url, $content, $oldfile, $destination = null, // The post URL $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); if ($destination == 'post') { @@ -549,19 +585,26 @@ function edit_quote($title, $tag, $url, $content, $oldfile, $destination = null, $post_title = $title; $post_quote = preg_replace('/\s\s+/', ' ', strip_tags($quote)); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), $tag); $post_tag = rtrim($post_tag, ','); + $post_tagmd = rtrim($post_tagmd, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { $post_description = "\n"; } else { $post_description = ""; } + if ($tag !== null) { + $tagmd = "\n"; + } else { + $tagmd = ""; + } if ($quote !== null) { $post_quote = "\n"; } else { $post_quote = ""; } - $post_content = '' . $post_description . $post_quote ."\n\n" . $content; + $post_content = '' . $post_description . $tagmd . $post_quote ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { @@ -626,6 +669,8 @@ function edit_quote($title, $tag, $url, $content, $oldfile, $destination = null, // The post URL $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); if ($destination == 'post') { @@ -663,19 +708,26 @@ function edit_audio($title, $tag, $url, $content, $oldfile, $destination = null, $post_title = $title; $post_audio = preg_replace('/\s\s+/', ' ', strip_tags($audio)); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), $tag); $post_tag = rtrim($post_tag, ','); + $post_tagmd = rtrim($post_tagmd, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { $post_description = "\n"; } else { $post_description = ""; } + if ($tag !== null) { + $tagmd = "\n"; + } else { + $tagmd = ""; + } if ($audio !== null) { $post_audio = "\n"; } else { $post_audio = ""; } - $post_content = '' . $post_description . $post_audio ."\n\n" . $content; + $post_content = '' . $post_description . $tagmd . $post_audio ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { @@ -740,6 +792,8 @@ function edit_audio($title, $tag, $url, $content, $oldfile, $destination = null, // The post URL $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); if ($destination == 'post') { @@ -764,7 +818,7 @@ function edit_audio($title, $tag, $url, $content, $oldfile, $destination = null, } // Edit static page -function edit_page($title, $url, $content, $oldfile, $destination = null, $description = null) +function edit_page($title, $url, $content, $oldfile, $destination = null, $description = null, $static = null) { $dir = substr($oldfile, 0, strrpos($oldfile, '/')); @@ -789,8 +843,12 @@ function edit_page($title, $url, $content, $oldfile, $destination = null, $descr file_put_contents($newfile, print_r($post_content, true)); } - $posturl = site_url() . $post_url; - + if (!empty($static)) { + $posturl = site_url() . $static .'/'. $post_url; + } else { + $posturl = site_url() . $post_url; + } + rebuilt_cache('all'); clear_page_cache($post_url); if ($destination == 'post') { @@ -809,14 +867,21 @@ function add_post($title, $tag, $url, $content, $user, $description = null, $dra $post_date = date('Y-m-d-H-i-s'); $post_title = $title; $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), $tag); $post_tag = rtrim($post_tag, ','); + $post_tagmd = rtrim($post_tagmd, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { $post_description = "\n"; } else { $post_description = ""; - } - $post_content = '' . $post_description ."\n\n" . $content; + } + if ($tag !== null) { + $tagmd = "\n"; + } else { + $tagmd = ""; + } + $post_content = '' . $post_description . $tagmd ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { @@ -838,6 +903,8 @@ function add_post($title, $tag, $url, $content, $user, $description = null, $dra 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); @@ -860,19 +927,26 @@ function add_image($title, $tag, $url, $content, $user, $description = null, $im $post_title = $title; $post_image = preg_replace('/\s\s+/', ' ', strip_tags($image)); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), $tag); $post_tag = rtrim($post_tag, ','); + $post_tagmd = rtrim($post_tagmd, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { $post_description = "\n"; } else { $post_description = ""; } + if ($tag !== null) { + $tagmd = "\n"; + } else { + $tagmd = ""; + } if ($image !== null) { $post_image = "\n"; } else { $post_image = ""; } - $post_content = '' . $post_description . $post_image ."\n\n" . $content; + $post_content = '' . $post_description . $tagmd . $post_image ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { @@ -894,6 +968,8 @@ function add_image($title, $tag, $url, $content, $user, $description = null, $im 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); @@ -916,19 +992,26 @@ function add_video($title, $tag, $url, $content, $user, $description = null, $vi $post_title = $title; $post_video = preg_replace('/\s\s+/', ' ', strip_tags($video)); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), $tag); $post_tag = rtrim($post_tag, ','); + $post_tagmd = rtrim($post_tagmd, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { $post_description = "\n"; } else { $post_description = ""; } + if ($tag !== null) { + $tagmd = "\n"; + } else { + $tagmd = ""; + } if ($video !== null) { $post_video = "\n"; } else { $post_video = ""; } - $post_content = '' . $post_description . $post_video ."\n\n" . $content; + $post_content = '' . $post_description . $tagmd . $post_video ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { @@ -950,6 +1033,8 @@ function add_video($title, $tag, $url, $content, $user, $description = null, $vi 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); @@ -972,19 +1057,26 @@ function add_audio($title, $tag, $url, $content, $user, $description = null, $au $post_title = $title; $post_audio = preg_replace('/\s\s+/', ' ', strip_tags($audio)); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), $tag); $post_tag = rtrim($post_tag, ','); + $post_tagmd = rtrim($post_tagmd, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { $post_description = "\n"; } else { $post_description = ""; } + if ($tag !== null) { + $tagmd = "\n"; + } else { + $tagmd = ""; + } if ($audio !== null) { $post_audio = "\n"; } else { $post_audio = ""; } - $post_content = '' . $post_description . $post_audio ."\n\n" . $content; + $post_content = '' . $post_description . $tagmd . $post_audio ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { @@ -1006,6 +1098,8 @@ function add_audio($title, $tag, $url, $content, $user, $description = null, $au 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); @@ -1028,19 +1122,26 @@ function add_link($title, $tag, $url, $content, $user, $description = null, $lin $post_title = $title; $post_link = preg_replace('/\s\s+/', ' ', strip_tags($link)); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), $tag); $post_tag = rtrim($post_tag, ','); + $post_tagmd = rtrim($post_tagmd, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { $post_description = "\n"; } else { $post_description = ""; } + if ($tag !== null) { + $tagmd = "\n"; + } else { + $tagmd = ""; + } if ($link !== null) { $post_link = "\n"; } else { $post_link = ""; } - $post_content = '' . $post_description . $post_link ."\n\n" . $content; + $post_content = '' . $post_description . $tagmd . $post_link ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { @@ -1062,6 +1163,8 @@ function add_link($title, $tag, $url, $content, $user, $description = null, $lin 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); @@ -1084,19 +1187,26 @@ function add_quote($title, $tag, $url, $content, $user, $description = null, $qu $post_title = $title; $post_quote = preg_replace('/\s\s+/', ' ', strip_tags($quote)); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), $tag); $post_tag = rtrim($post_tag, ','); + $post_tagmd = rtrim($post_tagmd, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { $post_description = "\n"; } else { $post_description = ""; } + if ($tag !== null) { + $tagmd = "\n"; + } else { + $tagmd = ""; + } if ($quote !== null) { $post_quote = "\n"; } else { $post_quote = ""; } - $post_content = '' . $post_description . $post_quote ."\n\n" . $content; + $post_content = '' . $post_description . $tagmd . $post_quote ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { @@ -1118,6 +1228,8 @@ function add_quote($title, $tag, $url, $content, $user, $description = null, $qu 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); diff --git a/system/htmly.php b/system/htmly.php index 6bc59e7..a49f224 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -1228,13 +1228,13 @@ get('/tag/:tag', function ($tag) { not_found(); } render('main', array( - 'title' => 'Posts tagged: ' . $tag . ' - ' . blog_title(), - 'description' => 'All posts tagged: ' . $tag . ' on ' . blog_title() . '.', + 'title' => 'Posts tagged: ' . tag_i18n($tag) . ' - ' . blog_title(), + 'description' => 'All posts tagged: ' . tag_i18n($tag) . ' on ' . blog_title() . '.', 'canonical' => site_url() . 'tag/' . $tag, 'page' => $page, 'posts' => $posts, 'bodyclass' => 'intag', - 'breadcrumb' => '' . config('breadcrumb.home') . ' » Posts tagged: ' . $tag, + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Posts tagged: ' . tag_i18n($tag), 'pagination' => has_pagination($total, $perpage, $page), 'is_tag' => is_tag(true), )); @@ -1311,13 +1311,13 @@ get('/search/:keyword', function ($keyword) { } render('main', array( - 'title' => 'Search results for: ' . $keyword . ' - ' . blog_title(), - 'description' => 'Search results for: ' . $keyword . ' on ' . blog_title() . '.', + 'title' => 'Search results for: ' . tag_i18n($keyword) . ' - ' . blog_title(), + 'description' => 'Search results for: ' . tag_i18n($keyword) . ' on ' . blog_title() . '.', 'canonical' => site_url() . 'search/' . $keyword, 'page' => $page, 'posts' => $posts, 'bodyclass' => 'insearch', - 'breadcrumb' => '' . config('breadcrumb.home') . ' » Search results for: ' . $keyword, + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Search results for: ' . tag_i18n($keyword), 'pagination' => has_pagination($total, $perpage, $page), 'is_search' => is_search(true), )); @@ -1781,10 +1781,10 @@ post('/:static/:sub/edit', function ($static, $sub) { } if ($proper && !empty($title) && !empty($content)) { if (!empty($url)) { - edit_page($title, $url, $content, $oldfile, $destination, $description); + edit_page($title, $url, $content, $oldfile, $destination, $description, $static); } else { $url = $title; - edit_page($title, $url, $content, $oldfile, $destination, $description); + edit_page($title, $url, $content, $oldfile, $destination, $description, $static); } } else { $message['error'] = ''; diff --git a/system/includes/functions.php b/system/includes/functions.php index 2ff626d..8b97b13 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -236,13 +236,33 @@ function get_posts($posts, $page = 1, $perpage = 0) // The post URL $post->url = site_url() . date('Y/m', $post->date) . '/' . str_replace('.md', '', $arr[2]); + $post->file = $filepath; + + $content = file_get_contents($filepath); + + // Extract the title and body + $post->title = get_content_tag('t', $content, 'Untitled: ' . date('l jS \of F Y', $post->date)); + $post->image = get_content_tag('image', $content); + $post->video = get_youtube_id(get_content_tag('video', $content)); + $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(); - + + $tLang = get_content_tag('tag', $content); + $tl = explode(',', rtrim($tLang, ',')); $t = explode(',', rtrim($arr[1], ',')); - foreach ($t as $tt) { - $tag[] = array($tt, site_url() . 'tag/' . $tt); + $tCom = array_combine($t, $tl); + + foreach ($tCom as $key => $val) { + if(!empty($val)) { + $tag[] = array($val, site_url() . 'tag/' . $key); + } else { + $tag[] = array($key, site_url() . 'tag/' . $key); + } } foreach ($tag as $a) { @@ -254,18 +274,6 @@ function get_posts($posts, $page = 1, $perpage = 0) $post->tagb = implode(' ยป ', $bc); - $post->file = $filepath; - - $content = file_get_contents($filepath); - - // Extract the title and body - $post->title = get_content_tag('t', $content, 'Untitled: ' . date('l jS \of F Y', $post->date)); - $post->image = get_content_tag('image', $content); - $post->video = get_youtube_id(get_content_tag('video', $content)); - $post->link = get_content_tag('link', $content); - $post->quote = get_content_tag('quote', $content); - $post->audio = get_content_tag('audio', $content); - // Get the contents and convert it to HTML $post->body = MarkdownExtra::defaultTransform(remove_html_comments($content)); @@ -657,7 +665,7 @@ function get_related($tag, $custom = null, $count = null) } } - $posts = get_tag(strip_tags($tag), 1, $count + 1, true); + $posts = get_tag(strip_tags(remove_accent($tag)), 1, $count + 1, true); $tmp = array(); $req = urldecode($_SERVER['REQUEST_URI']); @@ -944,7 +952,7 @@ function tag_cloud($custom = null) if(empty($custom)) { echo '