mirror of
https://github.com/danpros/htmly.git
synced 2026-04-19 12:06:22 +05:30
Multi languange tags and search fixes
This commit is contained in:
parent
f2febf4dc6
commit
0b100044b4
5 changed files with 222 additions and 46 deletions
|
|
@ -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<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$post_description = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description ."\n\n" . $content;
|
||||
}
|
||||
if ($tag !== null) {
|
||||
$tagmd = "\n<!--tag " . $post_tagmd . " tag-->";
|
||||
} else {
|
||||
$tagmd = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $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<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$post_description = "";
|
||||
}
|
||||
if ($tag !== null) {
|
||||
$tagmd = "\n<!--tag " . $post_tagmd . " tag-->";
|
||||
} else {
|
||||
$tagmd = "";
|
||||
}
|
||||
if ($image !== null) {
|
||||
$post_image = "\n<!--image " . $post_image. " image-->";
|
||||
} else {
|
||||
$post_image = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $post_image ."\n\n" . $content;
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $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<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$post_description = "";
|
||||
}
|
||||
if ($tag !== null) {
|
||||
$tagmd = "\n<!--tag " . $post_tagmd . " tag-->";
|
||||
} else {
|
||||
$tagmd = "";
|
||||
}
|
||||
if ($video !== null) {
|
||||
$post_video = "\n<!--video " . $post_video . " video-->";
|
||||
} else {
|
||||
$post_video = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $post_video ."\n\n" . $content;
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $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<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$post_description = "";
|
||||
}
|
||||
if ($tag !== null) {
|
||||
$tagmd = "\n<!--tag " . $post_tagmd . " tag-->";
|
||||
} else {
|
||||
$tagmd = "";
|
||||
}
|
||||
if ($link !== null) {
|
||||
$post_link = "\n<!--link" . $post_link. " link-->";
|
||||
} else {
|
||||
$post_link = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $post_link ."\n\n" . $content;
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $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<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$post_description = "";
|
||||
}
|
||||
if ($tag !== null) {
|
||||
$tagmd = "\n<!--tag " . $post_tagmd . " tag-->";
|
||||
} else {
|
||||
$tagmd = "";
|
||||
}
|
||||
if ($quote !== null) {
|
||||
$post_quote = "\n<!--quote" . $post_quote . " quote-->";
|
||||
} else {
|
||||
$post_quote = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $post_quote ."\n\n" . $content;
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $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<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$post_description = "";
|
||||
}
|
||||
if ($tag !== null) {
|
||||
$tagmd = "\n<!--tag " . $post_tagmd . " tag-->";
|
||||
} else {
|
||||
$tagmd = "";
|
||||
}
|
||||
if ($audio !== null) {
|
||||
$post_audio = "\n<!--audio" . $post_audio . " audio-->";
|
||||
} else {
|
||||
$post_audio = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $post_audio ."\n\n" . $content;
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $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<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$post_description = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description ."\n\n" . $content;
|
||||
}
|
||||
if ($tag !== null) {
|
||||
$tagmd = "\n<!--tag " . $post_tagmd . " tag-->";
|
||||
} else {
|
||||
$tagmd = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $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<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$post_description = "";
|
||||
}
|
||||
if ($tag !== null) {
|
||||
$tagmd = "\n<!--tag " . $post_tagmd . " tag-->";
|
||||
} else {
|
||||
$tagmd = "";
|
||||
}
|
||||
if ($image !== null) {
|
||||
$post_image = "\n<!--image " . $post_image. " image-->";
|
||||
} else {
|
||||
$post_image = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $post_image ."\n\n" . $content;
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $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<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$post_description = "";
|
||||
}
|
||||
if ($tag !== null) {
|
||||
$tagmd = "\n<!--tag " . $post_tagmd . " tag-->";
|
||||
} else {
|
||||
$tagmd = "";
|
||||
}
|
||||
if ($video !== null) {
|
||||
$post_video = "\n<!--video " . $post_video . " video-->";
|
||||
} else {
|
||||
$post_video = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $post_video ."\n\n" . $content;
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $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<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$post_description = "";
|
||||
}
|
||||
if ($tag !== null) {
|
||||
$tagmd = "\n<!--tag " . $post_tagmd . " tag-->";
|
||||
} else {
|
||||
$tagmd = "";
|
||||
}
|
||||
if ($audio !== null) {
|
||||
$post_audio = "\n<!--audio " . $post_audio . " audio-->";
|
||||
} else {
|
||||
$post_audio = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $post_audio ."\n\n" . $content;
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $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<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$post_description = "";
|
||||
}
|
||||
if ($tag !== null) {
|
||||
$tagmd = "\n<!--tag " . $post_tagmd . " tag-->";
|
||||
} else {
|
||||
$tagmd = "";
|
||||
}
|
||||
if ($link !== null) {
|
||||
$post_link = "\n<!--link " . $post_link . " link-->";
|
||||
} else {
|
||||
$post_link = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $post_link ."\n\n" . $content;
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $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<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$post_description = "";
|
||||
}
|
||||
if ($tag !== null) {
|
||||
$tagmd = "\n<!--tag " . $post_tagmd . " tag-->";
|
||||
} else {
|
||||
$tagmd = "";
|
||||
}
|
||||
if ($quote !== null) {
|
||||
$post_quote = "\n<!--quote " . $post_quote . " quote-->";
|
||||
} else {
|
||||
$post_quote = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $post_quote ."\n\n" . $content;
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $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);
|
||||
|
|
|
|||
|
|
@ -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' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Posts tagged: ' . $tag,
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » 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' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Search results for: ' . $keyword,
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » 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'] = '';
|
||||
|
|
|
|||
|
|
@ -236,24 +236,6 @@ 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]);
|
||||
|
||||
$tag = array();
|
||||
$url = array();
|
||||
$bc = array();
|
||||
|
||||
$t = explode(',', rtrim($arr[1], ','));
|
||||
foreach ($t as $tt) {
|
||||
$tag[] = array($tt, site_url() . 'tag/' . $tt);
|
||||
}
|
||||
|
||||
foreach ($tag as $a) {
|
||||
$url[] = '<span><a href="' . $a[1] . '">' . $a[0] . '</a></span>';
|
||||
$bc[] = '<span typeof="v:Breadcrumb"><a property="v:title" rel="v:url" href="' . $a[1] . '">' . $a[0] . '</a></span>';
|
||||
}
|
||||
|
||||
$post->tag = implode(', ', $url);
|
||||
|
||||
$post->tagb = implode(' » ', $bc);
|
||||
|
||||
$post->file = $filepath;
|
||||
|
||||
$content = file_get_contents($filepath);
|
||||
|
|
@ -265,6 +247,32 @@ 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();
|
||||
|
||||
$tLang = get_content_tag('tag', $content);
|
||||
$tl = explode(',', rtrim($tLang, ','));
|
||||
$t = explode(',', rtrim($arr[1], ','));
|
||||
$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) {
|
||||
$url[] = '<span><a href="' . $a[1] . '">' . $a[0] . '</a></span>';
|
||||
$bc[] = '<span typeof="v:Breadcrumb"><a property="v:title" rel="v:url" href="' . $a[1] . '">' . $a[0] . '</a></span>';
|
||||
}
|
||||
|
||||
$post->tag = implode(', ', $url);
|
||||
|
||||
$post->tagb = implode(' » ', $bc);
|
||||
|
||||
// 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 '<ul class="taglist">';
|
||||
foreach ($tag_collection as $tag => $count) {
|
||||
echo '<li class="item"><a href="' . site_url() . 'tag/' . $tag . '">' . $tag . '</a> <span class="count">(' . $count . ')</span></li>';
|
||||
echo '<li class="item"><a href="' . site_url() . 'tag/' . $tag . '">' . tag_i18n($tag) . '</a> <span class="count">(' . $count . ')</span></li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
} else {
|
||||
|
|
@ -1446,7 +1454,8 @@ EOF;
|
|||
EOF;
|
||||
}
|
||||
if (isset($_GET['search'])) {
|
||||
$url = site_url() . 'search/' . $_GET['search'];
|
||||
$search = $_GET['search'];
|
||||
$url = site_url() . 'search/' . remove_accent($search);
|
||||
header("Location: $url");
|
||||
}
|
||||
}
|
||||
|
|
@ -1962,7 +1971,7 @@ EOF;
|
|||
if ($role === 'admin') {
|
||||
echo '<li><a href="' . $base . 'admin/posts">Posts</a></li>';
|
||||
if (config('views.counter') == 'true') {
|
||||
echo '<li><a href="' . $base . 'admin/popular">Popular</a></li>';
|
||||
echo '<li><a href="' . $base . 'admin/popular">Popular</a></li>';
|
||||
}
|
||||
}
|
||||
echo '<li><a href="' . $base . 'admin/mine">Mine</a></li>';
|
||||
|
|
@ -2127,4 +2136,51 @@ function shorten($string = null, $char = null)
|
|||
return $string;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// save the i18n tag
|
||||
function save_tag_i18n($tag,$tagDisplay)
|
||||
{
|
||||
$filename = "content/tags.lang";
|
||||
$tags = array();
|
||||
$tmp = array();
|
||||
$views = array();
|
||||
|
||||
$tt = explode(',', rtrim($tag, ','));
|
||||
$tl = explode(',', rtrim($tagDisplay, ','));
|
||||
$tags = array_combine($tt,$tl);
|
||||
|
||||
if (file_exists($filename)) {
|
||||
$views = unserialize(file_get_contents($filename));
|
||||
foreach ($tags as $key => $val) {
|
||||
if (isset($views[$key])) {
|
||||
$views[$key] = $val;
|
||||
} else {
|
||||
$views[$key] = $val;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$views = $tags;
|
||||
}
|
||||
|
||||
$tmp = serialize($views);
|
||||
file_put_contents($filename, print_r($tmp, true));
|
||||
|
||||
}
|
||||
|
||||
// translate tag to i18n
|
||||
function tag_i18n($tag)
|
||||
{
|
||||
static $tags = array();
|
||||
|
||||
if (empty($tags)) {
|
||||
$filename = "content/tags.lang";
|
||||
if (file_exists($filename)) {
|
||||
$tags = unserialize(file_get_contents($filename));
|
||||
}
|
||||
}
|
||||
if (isset($tags[$tag])) {
|
||||
return $tags[$tag];
|
||||
}
|
||||
return $tag;
|
||||
}
|
||||
|
|
@ -26,7 +26,8 @@
|
|||
</head>
|
||||
<?php
|
||||
if (isset($_GET['search'])) {
|
||||
$url = site_url() . 'search/' . $_GET['search'];
|
||||
$search = $_GET['search'];
|
||||
$url = site_url() . 'search/' . remove_accent($search);
|
||||
header("Location: $url");
|
||||
}
|
||||
?>
|
||||
|
|
@ -169,7 +170,7 @@
|
|||
<div class="tag-cloud">
|
||||
<?php $tags = tag_cloud(true);?>
|
||||
<?php foreach ($tags as $tag => $count):?>
|
||||
<a class="more-link" href="<?php echo site_url();?>tag/<?php echo $tag;?>"><?php echo $tag;?></a>
|
||||
<a class="more-link" href="<?php echo site_url();?>tag/<?php echo $tag;?>"><?php echo tag_i18n($tag);?></a>
|
||||
<?php endforeach;?>
|
||||
</div><!--//content-->
|
||||
</div><!--//section-inner-->
|
||||
|
|
|
|||
|
|
@ -6,6 +6,13 @@ require 'system/includes/session.php';
|
|||
// Load the configuration file
|
||||
config('source', 'config/config.ini');
|
||||
|
||||
// Set the timezone
|
||||
if (config('timezone')) {
|
||||
date_default_timezone_set(config('timezone'));
|
||||
} else {
|
||||
date_default_timezone_set('Asia/Jakarta');
|
||||
}
|
||||
|
||||
$whitelist = array('jpg', 'jpeg', 'png', 'gif');
|
||||
$name = null;
|
||||
$dir = 'content/images/';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue