Browse Source

Unicode support

Support unicode for tag and URL eg. Chinese, Japanese, Arabic etc.
pull/56/head
Danang Probo Sayekti 11 years ago
parent
commit
c7441b84f6
2 changed files with 11 additions and 12 deletions
  1. +10
    -11
      system/admin/admin.php
  2. +1
    -1
      system/includes/functions.php

+ 10
- 11
system/admin/admin.php View File

@ -45,8 +45,8 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null)
$oldurl = explode('_', $oldfile); $oldurl = explode('_', $oldfile);
$post_title = $title; $post_title = $title;
$post_tag = preg_replace(array('/[^a-zA-Z0-9,.-]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag));
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
$post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag));
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content; $post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content;
if(!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { if(!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) {
@ -95,7 +95,7 @@ function edit_page($title, $url, $content, $oldfile, $destination = null) {
$dir = substr($oldfile, 0, strrpos($oldfile, '/')); $dir = substr($oldfile, 0, strrpos($oldfile, '/'));
$post_title = $title; $post_title = $title;
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content; $post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content;
if(!empty($post_title) && !empty($post_url) && !empty($post_content)) { if(!empty($post_title) && !empty($post_url) && !empty($post_content)) {
@ -132,8 +132,8 @@ function add_post($title, $tag, $url, $content, $user) {
$post_date = date('Y-m-d-H-i-s'); $post_date = date('Y-m-d-H-i-s');
$post_title = $title; $post_title = $title;
$post_tag = preg_replace(array('/[^a-zA-Z0-9,.-]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag));
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
$post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag));
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content; $post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content;
if(!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { if(!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) {
@ -162,7 +162,7 @@ function add_post($title, $tag, $url, $content, $user) {
function add_page($title, $url, $content) { function add_page($title, $url, $content) {
$post_title = $title; $post_title = $title;
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content; $post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content;
if(!empty($post_title) && !empty($post_url) && !empty($post_content)) { if(!empty($post_title) && !empty($post_url) && !empty($post_content)) {
@ -271,9 +271,8 @@ function migrate($title, $time, $tags, $content, $url, $user, $source) {
$post_date = date('Y-m-d-H-i-s', $time); $post_date = date('Y-m-d-H-i-s', $time);
$post_title = $title; $post_title = $title;
$post_tag = preg_replace('/[^A-Za-z0-9,.-]/u', '', $tags);
$post_tag = rtrim(ltrim($post_tag, ',\.\-'), ',\.\-');
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
$post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tags));
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
if(!empty($source)) { if(!empty($source)) {
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content . "\n\n" . 'Source: <a target="_blank" href="' . $source . '">' . $title . '</a>'; $post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content . "\n\n" . 'Source: <a target="_blank" href="' . $source . '">' . $title . '</a>';
} }
@ -320,11 +319,11 @@ function get_feed($feed_url, $credit, $message=null) {
$time = new DateTime($entry->pubDate); $time = new DateTime($entry->pubDate);
$timestamp= $time->format("Y-m-d H:i:s"); $timestamp= $time->format("Y-m-d H:i:s");
$time = strtotime($timestamp); $time = strtotime($timestamp);
$tags = strip_tags(preg_replace(array('/[^a-zA-Z0-9,.-]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($entry->category)));
$tags = strip_tags(preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($entry->category)));
$title = rtrim($entry->title, ' \,\.\-'); $title = rtrim($entry->title, ' \,\.\-');
$title = ltrim($title, ' \,\.\-'); $title = ltrim($title, ' \,\.\-');
$user = $_SESSION['user']; $user = $_SESSION['user'];
$url = strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($title)));
$url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($title)));
if ($credit == 'yes') { if ($credit == 'yes') {
$source = $entry->link; $source = $entry->link;
} }


+ 1
- 1
system/includes/functions.php View File

@ -591,7 +591,7 @@ function get_related($tag) {
$perpage = config('related.count'); $perpage = config('related.count');
$posts = get_tag(strip_tags($tag), 1, $perpage+1, true); $posts = get_tag(strip_tags($tag), 1, $perpage+1, true);
$tmp = array(); $tmp = array();
$req = $_SERVER['REQUEST_URI'];
$req = urldecode($_SERVER['REQUEST_URI']);
foreach ($posts as $post) { foreach ($posts as $post) {
$url = $post->url; $url = $post->url;


Loading…
Cancel
Save