mirror of
https://github.com/danpros/htmly.git
synced 2026-04-23 14:06:23 +05:30
Tag creation improvements
Allow to use tag like C++ and double check for the same tag slug.
This commit is contained in:
parent
364a7d6850
commit
a4f65190b3
3 changed files with 67 additions and 0 deletions
|
|
@ -95,6 +95,34 @@ function add_content($title, $tag, $url, $content, $user, $description = null, $
|
|||
$post_tagmd = rtrim($post_tagmd, ',');
|
||||
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
|
||||
$description = safe_html($description);
|
||||
|
||||
$post_t = explode(',', $post_tag);
|
||||
$pret_t = explode(',', $post_tagmd);
|
||||
$tags = tag_cloud(true);
|
||||
$timestamp = date('YmdHis');
|
||||
|
||||
$combine = array_combine($pret_t, $post_t);
|
||||
$inter = array_intersect_key($tags, array_flip($post_t));
|
||||
$newtag = array();
|
||||
|
||||
foreach ($combine as $tag => $v) {
|
||||
if (array_key_exists($v, $tags)) {
|
||||
foreach ($inter as $in => $i){
|
||||
if($v === $in) {
|
||||
if (strtolower($tag) === strtolower(tag_i18n($in))) {
|
||||
$newtag[$v]= $tag;
|
||||
} else {
|
||||
$newtag[$v.'-'. $timestamp]= $tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$newtag[$v] = $tag;
|
||||
}
|
||||
}
|
||||
|
||||
$post_tag = implode(',', array_keys($newtag));
|
||||
|
||||
if ($description !== null) {
|
||||
$post_description = "\n<!--d " . $description . " d-->";
|
||||
} else {
|
||||
|
|
@ -166,6 +194,35 @@ function edit_content($title, $tag, $url, $content, $oldfile, $destination = nul
|
|||
$post_tagmd = rtrim($post_tagmd, ',');
|
||||
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
|
||||
$description = safe_html($description);
|
||||
|
||||
|
||||
$post_t = explode(',', $post_tag);
|
||||
$pret_t = explode(',', $post_tagmd);
|
||||
$tags = tag_cloud(true);
|
||||
$timestamp = date('YmdHis');
|
||||
|
||||
$combine = array_combine($pret_t, $post_t);
|
||||
$inter = array_intersect_key($tags, array_flip($post_t));
|
||||
$newtag = array();
|
||||
|
||||
foreach ($combine as $tag => $v) {
|
||||
if (array_key_exists($v, $tags)) {
|
||||
foreach ($inter as $in => $i){
|
||||
if($v === $in) {
|
||||
if (strtolower($tag) === strtolower(tag_i18n($in))) {
|
||||
$newtag[$v]= $tag;
|
||||
} else {
|
||||
$newtag[$v.'-'. $timestamp]= $tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$newtag[$v] = $tag;
|
||||
}
|
||||
}
|
||||
|
||||
$post_tag = implode(',', array_keys($newtag));
|
||||
|
||||
if ($description !== null) {
|
||||
$post_description = "\n<!--d " . $description . " d-->";
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ if ($type != 'is_post' && $type != 'is_image' && $type != 'is_video' && $type !=
|
|||
$desc = get_category_info(null);
|
||||
|
||||
$tags = tag_cloud(true);
|
||||
$ptags = unserialize(file_get_contents('content/data/tags.lang'));
|
||||
$tkey = array_keys($tags);
|
||||
$newlang = array_intersect_key($ptags, array_flip($tkey));
|
||||
$tmp = serialize($newlang);
|
||||
file_put_contents('content/data/tags.lang', print_r($tmp, true));
|
||||
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,11 @@ if (config('permalink.type') == 'post') {
|
|||
}
|
||||
|
||||
$tags = tag_cloud(true);
|
||||
$ptags = unserialize(file_get_contents('content/data/tags.lang'));
|
||||
$tkey = array_keys($tags);
|
||||
$newlang = array_intersect_key($ptags, array_flip($tkey));
|
||||
$tmp = serialize($newlang);
|
||||
file_put_contents('content/data/tags.lang', print_r($tmp, true));
|
||||
|
||||
?>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css"/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue