本文整理汇总了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');
}
示例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;
}
示例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);
}
}
示例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());
}
示例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;
}
示例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;
}
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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);
}
示例11: checkSlug
public function checkSlug($slug)
{
$slugify = slugify($slug);
$checkSlug = $this->mproduct->checkSlug($slug);
if ($checkSlug) {
return $checkSlug;
} else {
return $slugify;
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
}