当前位置: 首页>>代码示例>>PHP>>正文


PHP slugify函数代码示例

本文整理汇总了PHP中slugify函数的典型用法代码示例。如果您正苦于以下问题:PHP slugify函数的具体用法?PHP slugify怎么用?PHP slugify使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了slugify函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSlugCase

 /**
  * 
  */
 public function testSlugCase()
 {
     $test1 = '  Normal case to slug case';
     $test2 = 'Nõrmàl çĀse to   slûg çasé';
     $this->assertEquals(slugify($test1), 'normal-case-to-slug-case');
     $this->assertEquals(slugify($test2), 'normal-case-to-slug-case');
 }
开发者ID:aurelienlhx,项目名称:PhpComponents,代码行数:10,代码来源:CaseHelpersTest.php

示例2: getSlugAttribute

 public function getSlugAttribute()
 {
     if (!$this->slug) {
         $this->slug = slugify($this->getKey(), isset(static::$slugText) ? $this->{static::$slugText} : $this->name ?? $this->title ?? '');
     }
     return $this->slug;
 }
开发者ID:konato-events,项目名称:web,代码行数:7,代码来源:Base.php

示例3: testslugify

 public function testslugify()
 {
     $titles = array("Test" => "test", "Überschrift" => "ueberschrift", "Leer Zeichen" => "leer-zeichen", "Fuß" => "fuss", "Sonderzeichen?=%" => "sonderzeichen", "Rosé" => "rose", "Weinbrief Nr. 18" => "weinbrief-nr-18");
     foreach ($titles as $title => $slug) {
         $this->assertEquals(slugify($title), $slug);
     }
 }
开发者ID:Findus23,项目名称:php-functions,代码行数:7,代码来源:tests.php

示例4: storeDiskSettingsBackEnd

 protected function storeDiskSettingsBackEnd($directory_name, $directory_driver, $is_directory_public = false)
 {
     $directory_url = null;
     $directory_root = null;
     $directory_path = null;
     $directory_name = str_replace('-', '_', slugify($directory_name));
     switch ($directory_driver) {
         case 'local':
         default:
             if ($is_directory_public) {
                 $directory_root = 'uploads/' . Environments::currentEnvironment() . '/' . $directory_name;
                 $directory_url = url($directory_root);
                 $directory_path = public_path($directory_root);
             } else {
                 $directory_root = 'app/' . Environments::currentEnvironment() . '/' . $directory_name;
                 $directory_url = url($directory_root);
                 $directory_path = public_path($directory_root);
             }
             break;
     }
     File::makeDirectory($directory_path, 0777, true);
     $disk = ['driver' => $directory_driver, 'root' => $directory_path];
     if ($is_directory_public) {
         $disk['visibility'] = 'public';
     }
     $this->addFileSystemDisk($directory_name, $disk, Environments::currentEnvironment());
     $this->mountElFinderDisk($directory_name, ['alias' => $directory_path, 'URL' => $directory_url, 'access' => ['readonly' => true, 'roles' => [RolesRepositoryEloquent::ADMIN], 'permissions' => [PermissionsRepositoryEloquent::CAN_READ_BACKUPS_DIRECTORY]]], Environments::currentEnvironment());
 }
开发者ID:cvepdb-cms,项目名称:module-files,代码行数:28,代码来源:ElFinderDiskRepository.php

示例5: fetch_and_parse_image

function fetch_and_parse_image($fansub_id, $url, $description)
{
    global $website_directory;
    preg_match_all('/<img [^>]*src=["|\']([^"|\']+)/i', $description, $matches);
    $first_image_url = NULL;
    if (isset($matches) && isset($matches[1])) {
        for ($i = 0; $i < count($matches[1]); $i++) {
            if (strpos($matches[1][$i], '.svg') === FALSE) {
                $first_image_url = $matches[1][$i];
                break;
            }
        }
    }
    if ($first_image_url != NULL) {
        if (strpos($first_image_url, "://") === FALSE) {
            $first_image_url = $url . $first_image_url;
        }
        if (!is_dir("{$website_directory}/images/news/{$fansub_id}/")) {
            mkdir("{$website_directory}/images/news/{$fansub_id}/");
        }
        if (@copy($first_image_url, "{$website_directory}/images/news/{$fansub_id}/" . slugify($first_image_url))) {
            return slugify($first_image_url);
        } else {
            if (file_exists("{$website_directory}/images/news/{$fansub_id}/" . slugify($first_image_url))) {
                //This means that the file is no longer accessible, but we already have it locally!
                return slugify($first_image_url);
            }
        }
    }
    return NULL;
}
开发者ID:Ereza,项目名称:Fansubs.cat,代码行数:31,代码来源:functions.inc.php

示例6: callbackSubmit

 /**
  * Callback for submit-button.
  *
  */
 public function callbackSubmit()
 {
     $email = $this->Value('email');
     $this->user = new \Anax\Users\User();
     $this->user->setDI($this->di);
     $res = $this->user->findByEmail($email);
     if (count($res) >= 1) {
         $userid = $res[0]->getProperties()['id'];
         $acronym = $res[0]->getProperties()['acronym'];
         $temp = slugify($acronym . '7D3F5G23j5B52D3' . $userid);
         $encrypt = password_hash($temp, PASSWORD_DEFAULT);
         $link = $this->url . 'users/reset/' . $userid . '/' . $encrypt;
         $message = "The password restore link was sent to your e-mail.";
         $to = $email;
         $subject = "Password recovery";
         $from = ADMIN_MAIL;
         $body = 'Hi ' . $acronym . '. Follow this link to choose a new password: ' . $link . ' Kind regards, Volvo S90 Q&A admin.';
         $headers = "From: " . strip_tags($from) . "\r\n";
         $headers .= "Answer to: " . strip_tags($from) . "\r\n";
         $headers .= "MIME-Version: 1.0\r\n";
         $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
         $sent = mail($to, $subject, $body, $headers);
         $this->user->save(array('id' => $userid, 'password' => $encrypt));
         if ($sent) {
             return true;
             header('location: www.volvo-s90.com/users/login');
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
开发者ID:stjo15,项目名称:janax,代码行数:37,代码来源:CFormPasswordRecover.php

示例7: exec_gh_pages

function exec_gh_pages()
{
    ob_start();
    require_once 'www/gh-index.php';
    mkdir('gh-pages');
    $data = ob_get_clean();
    if ($f = fopen('gh-pages/index.html', 'w+')) {
        fwrite($f, $data);
        fclose($f);
    }
    $countries = get_countries();
    /** @var Country $country */
    foreach ($countries as $country) {
        $filename = slugify($country->getCode3l()) . '.html';
        if ($f = fopen('gh-pages/' . $filename, 'w+')) {
            $_GET['code'] = $country->getCode3l();
            ob_start();
            $page_title = $country->getNameOfficial();
            require 'www/includes/header.inc';
            require 'www/detail.php';
            require 'www/includes/footer.inc';
            $data = ob_get_clean();
            fwrite($f, $data);
            fclose($f);
        }
    }
}
开发者ID:AtSeoul,项目名称:countries,代码行数:27,代码来源:build.php

示例8: getJobTitleURL

 public function getJobTitleURL()
 {
     global $lang;
     $job = R::load('jobs', $this->_job_id);
     $job_url = $job->title . " {$lang->t('jobs|at')} " . $job->company_name;
     return slugify($job_url);
 }
开发者ID:florentsuc,项目名称:jobskee-open-source-job-board,代码行数:7,代码来源:Applications.php

示例9: addItem

 /**
  *
  *
  * @param $group
  * @param $text
  * @param bool $permission
  * @param array $attributes
  * @return $this|void
  */
 public function addItem($group, $text, $permission = false, $attributes = array())
 {
     if ($permission === false) {
         $permission = true;
     }
     $this->siteNavModule->addGroupIf($permission, $text, slugify($group), val('class', $attributes), '', $attributes);
     return $this;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:17,代码来源:class.nestedcollectionadapter.php

示例10: postSubmit

 public function postSubmit(EventReq $req)
 {
     $event = new Event();
     $event->save();
     $event->staff()->attach(\Auth::user(), ['created_at' => $event->created_at, 'updated_at' => $event->updated_at]);
     $id_slug = slugify($event->id, $event->title);
     return redirect()->action('EventController@getDetails', $id_slug);
 }
开发者ID:konato-events,项目名称:web,代码行数:8,代码来源:EventController.php

示例11: checkSlug

 public function checkSlug($slug)
 {
     $slugify = slugify($slug);
     $checkSlug = $this->mproduct->checkSlug($slug);
     if ($checkSlug) {
         return $checkSlug;
     } else {
         return $slugify;
     }
 }
开发者ID:4johndoe,项目名称:shop,代码行数:10,代码来源:Dashboard.php

示例12: checkSlug

 function checkSlug($slug)
 {
     $this->db->like('slug', $slug);
     $query = $this->db->get('product');
     if (checkRes($query)) {
         return $this->getLatestExistsSlug($slug);
     } else {
         return slugify($slug);
     }
 }
开发者ID:alfonkdp,项目名称:soad,代码行数:10,代码来源:Mcategory.php

示例13: parse_themes

function parse_themes($str)
{
    if (empty($str)) {
        return;
    }
    $themes = explode(",", $str);
    $themes = array_map(function ($theme) {
        return slugify(trim($theme));
    }, $themes);
    return $themes;
}
开发者ID:Funisaac,项目名称:compohub,代码行数:11,代码来源:export_jams.php

示例14: category_url

 /** Returns the product category url */
 function category_url($category, $parents = array())
 {
     $url = '';
     //check if this is a grandparent, parent, or child
     if ($parents) {
         foreach ($parents as $parent) {
             $url .= slugify($parent->name) . '/';
         }
     }
     $ret = base_url() . 'category/' . $category->id . '/' . $url . slugify($category->name);
     return $ret;
 }
开发者ID:reesretuta,项目名称:beauty-mx,代码行数:13,代码来源:lv_url_helper.php

示例15: callbackSubmit

 /**
  * Callback for submit button.
  *
  */
 public function callbackSubmit()
 {
     $now = date('Y-m-d H:i:s');
     $this->user = new \Anax\Users\User();
     $this->user->setDI($this->di);
     $this->user = $this->user->find($this->userid);
     $acronym = $this->user->getProperties()['acronym'];
     $email = $this->user->getProperties()['email'];
     $web = $this->user->getProperties()['web'];
     $tags = '';
     $tagslugs = '';
     if (isset($_POST['tag'])) {
         foreach ($_POST['tag'] as $key => $val) {
             $slug = slugify($val);
             $tagslugs .= $slug . ',';
             $tags .= $val . ',';
             // Update total number of tags
             $this->tag = new \Anax\Question\Tag();
             $this->tag->setDI($this->di);
             $tag = $this->tag->findTag($slug);
             $questions = $tag[0]->getProperties()['questions'];
             $tagid = $tag[0]->getProperties()['id'];
             $this->tag->customUpdate('tag', array('questions' => $questions + 1), 'id = ' . $tagid);
         }
         // Remove 1 from old data
         $oldtags = explode(',', $this->tagslug);
         foreach ($oldtags as $key => $val) {
             $this->tag = new \Anax\Question\Tag();
             $this->tag->setDI($this->di);
             $tag = $this->tag->findTag($val);
             $questions = $tag[0]->getProperties()['questions'];
             $tagid = $tag[0]->getProperties()['id'];
             $this->tag->customUpdate('tag', array('questions' => $questions - 1), 'id = ' . $tagid);
         }
         $tags = rtrim($tags, ',');
         $tagslugs = rtrim($tagslugs, ',');
     }
     $tags = empty($tags) ? $this->tag : $tags;
     $tagslugs = empty($tagslugs) ? $this->tagslug : $tagslugs;
     $slug = slugify($this->Value('title'));
     $this->question = new \Anax\Question\Question();
     $this->question->setDI($this->di);
     $saved = $this->question->save(array('id' => $this->id, 'tag' => $tags, 'tagslug' => $tagslugs, 'title' => $this->Value('title'), 'slug' => $slug, 'content' => $this->Value('content'), 'mail' => $email, 'acronym' => $acronym, 'web' => $web, 'updated' => $now, 'ip' => $this->di->request->getServer('REMOTE_ADDR'), 'gravatar' => 'http://www.gravatar.com/avatar/' . md5(strtolower(trim($email))) . '.jpg'));
     //$this->saveInSession = true;
     if ($saved) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:stjo15,项目名称:janax,代码行数:54,代码来源:CFormQuestionEdit.php


注:本文中的slugify函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。