Browse Source

Tag creation improvements

Allow to use tag like C++ and double check for the same tag slug.
pull/440/head
danpros 4 years ago
parent
commit
a4f65190b3
3 changed files with 67 additions and 0 deletions
  1. +57
    -0
      system/admin/admin.php
  2. +5
    -0
      system/admin/views/add-content.html.php
  3. +5
    -0
      system/admin/views/edit-content.html.php

+ 57
- 0
system/admin/admin.php View File

@ -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 {


+ 5
- 0
system/admin/views/add-content.html.php View File

@ -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));
?>


+ 5
- 0
system/admin/views/edit-content.html.php View File

@ -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…
Cancel
Save