Пример #1
0
/**
 * prepare a slug to gs standads
 * sanitizes, performs translist for filename, truncates to GSFILENAMEMAX
 *
 * @since  3.4
 * @param  str $slug slug to normalize
 * @param  str $default default slug to substitute if conversion empties it
 * @return str       new slug
 */
function prepareSlug($slug, $default = 'temp')
{
    $slug = truncate($slug, GSFILENAMEMAX);
    $slug = doTransliteration($slug);
    $slug = to7bit($slug, "UTF-8");
    $slug = clean_url($slug);
    //old way @todo what does that mean ?
    if (trim($slug) == '' && $default) {
        return $default;
    }
    return $slug;
}
Пример #2
0
     $title = truncate($title, GSTITLEMAX);
     // limit titles to 70 characters
 }
 // is a slug provided?
 if ($_POST['post-id']) {
     $url = truncate($_POST['post-id'], GSFILENAMEMAX);
     // limit slug/filenames to 70 chars
     // @todo abstract this translit stuff
     $url = doTransliteration($url);
     $url = to7bit($url, "UTF-8");
     $url = clean_url($url);
     //old way
 } else {
     if ($title) {
         $url = $title;
         $url = doTransliteration($url);
         $url = to7bit($url, "UTF-8");
         $url = clean_url($url);
         //old way
     } else {
         $url = "temp";
     }
 }
 //check again to see if the URL is empty
 if (trim($url) == '') {
     $url = 'temp';
 }
 $oldslug = "";
 // was the slug changed on an existing page?
 if (isset($existingurl)) {
     if ($_POST['post-id'] != $existingurl) {