function replaceTitle($title){
	$title	= remove_accent($title);
	$arr_str	= array( "<",">","/","\\","'", ""","&","lt;", "gt;","apos;", "quot;","amp;","&lt", "&gt","&apos", "&quot","&amp",""","'","&","<",">");
	$title	= str_replace($arr_str, " ", $title);
	$title = preg_replace('/[^0-9a-zA-Z\s]+/', ' ', $title);
	//Remove double space
	$array = array(
		'    ' => ' ',
		'   ' => ' ',
		'  ' => ' ',
	);
	$title = trim(strtr($title, $array));
	$title	= str_replace(" ", "-", $title);
	$title	= urlencode($title);
	// remove cac ky tu dac biet sau khi urlencode
	$array_apter = array("%0D%0A","%","&");
	$title	=	str_replace($array_apter,"-",$title);
	$title	= strtolower($title);
	return $title;
}
Example #2
0
themes/blog/css/font-awesome.min.css">
    <!-- Theme CSS -->  
    <link id="theme-style" rel="stylesheet" href="<?php 
echo site_url();
?>
themes/blog/css/styles.css">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head> 
<?php 
if (isset($_GET['search'])) {
    $search = $_GET['search'];
    $url = site_url() . 'search/' . remove_accent($search);
    header("Location: {$url}");
}
?>
<body class="<?php 
echo $bodyclass;
?>
" itemscope="itemscope" itemtype="http://schema.org/Blog">
<div class="hide">
    <meta content="<?php 
echo blog_title();
?>
" itemprop="name"/>
    <meta content="<?php 
echo blog_description();
?>
function post_slug($str)
{
    return strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($str)));
}
Example #4
0
function generate_rss($posts)
{
    $feed = new Feed();
    $channel = new Channel();
    $rssLength = config('rss.char');
    $channel->title(blog_title())->description(blog_description())->url(site_url())->appendTo($feed);
    foreach ($posts as $p) {
        if (!empty($rssLength)) {
            if (strlen(strip_tags($p->body)) < config('rss.char')) {
                $string = preg_replace('/\\s\\s+/', ' ', strip_tags($p->body));
                $body = $string . '...';
            } else {
                $string = preg_replace('/\\s\\s+/', ' ', strip_tags($p->body));
                $string = substr($string, 0, config('rss.char'));
                $string = substr($string, 0, strrpos($string, ' '));
                $body = $string . '...';
            }
        } else {
            $body = $p->body;
        }
        $item = new Item();
        $cats = explode(',', str_replace(' ', '', strip_tags(remove_accent($p->category))));
        foreach ($cats as $cat) {
            $item->category($cat, site_url() . 'category/' . strtolower($cat));
        }
        $item->title($p->title)->pubDate($p->date)->description($body)->url($p->url)->appendTo($channel);
    }
    echo $feed;
}
Example #5
0
function get_feed($feed_url, $credit)
{
    $source = file_get_contents($feed_url);
    $feed = new SimpleXmlElement($source);
    if (!empty($feed->channel->item)) {
        foreach ($feed->channel->item as $entry) {
            $descriptionA = $entry->children('content', true);
            $descriptionB = $entry->description;
            if (!empty($descriptionA)) {
                $content = $descriptionA;
            } elseif (!empty($descriptionB)) {
                $content = preg_replace('#<br\\s*/?>#i', "\n", $descriptionB);
            } else {
                return $str = '<li>Can not read the feed content.</li>';
            }
            $time = new DateTime($entry->pubDate);
            $timestamp = $time->format("Y-m-d H:i:s");
            $time = strtotime($timestamp);
            $tags = $entry->category;
            $title = rtrim($entry->title, ' \\,\\.\\-');
            $title = ltrim($title, ' \\,\\.\\-');
            $user = $_SESSION[config("site.url")]['user'];
            $url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \\-\\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($title)));
            if ($credit == 'yes') {
                $source = $entry->link;
            } else {
                $source = null;
            }
            migrate($title, $time, $tags, $content, $url, $user, $source);
        }
    } else {
        return $str = '<li>Unsupported feed.</li>';
    }
}
Example #6
0
function create_slug($string)
{
    $string = remove_accent($string);
    $slug = preg_replace('/[^A-Za-z0-9-]+/', '-', $string);
    return strtolower($slug);
}
Example #7
0
function mod_url_rewriter($str)
{
    return strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('-', '-', ''), remove_accent($str)));
}
Example #8
0
function get_description($string, $char = null)
{
    if (empty($char)) {
        $char = config('description.char');
    }
    $string = remove_accent($string);
    $string = preg_replace('/[^A-Za-z0-9 !@#$%^&*(),.-]/u', ' ', strip_tags($string));
    $string = ltrim($string);
    $string = substr($string, 0, $char);
    return $string = substr($string, 0, strrpos($string, ' '));
}
Example #9
0
/**
 * Générateur de Slug (Friendly Url) : convertit un titre en une URL conviviale.
 * @param  [type] $str [description]
 * @return [type]      [description]
 */
function slug($str)
{
    return mb_strtolower(preg_replace(array('/[^a-zA-Z0-9 \'-]/', '/[ -\']+/', '/^-|-$/'), array('', '-', ''), remove_accent($str)));
}