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


PHP Functions::CreateSlug方法代码示例

本文整理汇总了PHP中Functions::CreateSlug方法的典型用法代码示例。如果您正苦于以下问题:PHP Functions::CreateSlug方法的具体用法?PHP Functions::CreateSlug怎么用?PHP Functions::CreateSlug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Functions的用法示例。


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

示例1: Get

 /**
  * Extract values from database and set them to object properties
  * @param integer $id ID of record to be instantiated
  * @return void DB record's fields are loaded into object properties
  */
 private function Get($id)
 {
     $query = "SELECT " . DB_PREFIX . self::$table . ".*, username FROM " . DB_PREFIX . self::$table . " INNER JOIN " . DB_PREFIX . "users on " . DB_PREFIX . self::$table . ".user_id = " . DB_PREFIX . "users.user_id WHERE " . self::$id_name . "= {$id}";
     $result = $this->db->Query($query);
     $row = $this->db->FetchAssoc($result);
     foreach ($row as $key => $value) {
         $this->{$key} = $value;
     }
     // Video Specific values
     $this->tags = preg_split('/\\s?,\\s?/', $this->tags);
     $this->duration = substr($this->duration, 0, 3) == '00:' ? substr($this->duration, 3) : $this->duration;
     $this->slug = Functions::CreateSlug($this->title);
     $this->date_created = Functions::GmtToLocal($this->date_created);
     $this->url = HOST . '/videos/' . $this->video_id . (!empty($this->slug) ? '/' . $this->slug : '');
     Plugin::Trigger('video.get');
 }
开发者ID:KmServer,项目名称:CumulusClips,代码行数:21,代码来源:Video.php

示例2: array

Functions::RedirectIf(User::CheckPermissions('admin_panel', $admin), HOST . '/myaccount/');
$page_title = 'Video Categories';
$categories = array();
$data = array();
$errors = array();
$message = null;
/**************************
Handle create category form
**************************/
if (isset($_POST['submitted_add'])) {
    try {
        // Validate title
        if (empty($_POST['cat_name']) || ctype_space($_POST['cat_name'])) {
            throw new Exception('Invalid category name. Please try again.');
        }
        $data['slug'] = Functions::CreateSlug(trim($_POST['cat_name']));
        $data['cat_name'] = htmlspecialchars(trim($_POST['cat_name']));
        if (Category::Exist(array('slug' => $data['slug']))) {
            throw new Exception('Category name or slug already exists. Please note that in the slug special characters are replaced by hyphens.');
        }
        Category::Create($data);
        $message = $data['cat_name'] . ' was successfully created.';
        $message_type = 'success';
        unset($data);
    } catch (Exception $e) {
        $errors['cat_name'] = true;
        $message = $e->getMessage();
        $message_type = 'error';
    }
}
/*******************************
开发者ID:KmServer,项目名称:CumulusClips,代码行数:31,代码来源:videos_categories.php

示例3: dirname

// Include required files
include_once dirname(dirname(__FILE__)) . '/cc-core/config/admin.bootstrap.php';
App::LoadClass('User');
App::LoadClass('Page');
// Establish page variables, objects, arrays, etc
Functions::RedirectIf($logged_in = User::LoginCheck(), HOST . '/login/');
$admin = new User($logged_in);
Functions::RedirectIf(User::CheckPermissions('admin_panel', $admin), HOST . '/myaccount/');
// Validate Slug
if (!empty($_POST['action']) && in_array($_POST['action'], array('slug', 'title'))) {
    if ($_POST['action'] == 'slug') {
        $slug = Functions::CreateSlug(trim($_POST['slug']));
    } else {
        if ($_POST['action'] == 'title') {
            $slug = Functions::CreateSlug(trim($_POST['title']));
        } else {
            App::Throw404();
        }
    }
} else {
    App::Throw404();
}
// Validate Page ID
if (isset($_POST['page_id']) && $_POST['page_id'] == 0) {
    $page_id = 0;
} else {
    if (!empty($_POST['page_id']) && is_numeric($_POST['page_id']) && Page::Exist(array('page_id' => $_POST['page_id']))) {
        $page_id = $_POST['page_id'];
    } else {
        App::Throw404();
开发者ID:KmServer,项目名称:CumulusClips,代码行数:30,代码来源:pages_slug.php

示例4: htmlspecialchars

 }
 // Validate status
 if (!empty($_POST['status']) && in_array($_POST['status'], array('published', 'draft'))) {
     $data['status'] = $_POST['status'];
 } else {
     $errors['status'] = "You didn't provide a valid status";
 }
 // Validate title
 if (!empty($_POST['title']) && !ctype_space($_POST['title'])) {
     $data['title'] = htmlspecialchars(trim($_POST['title']));
 } else {
     $errors['title'] = "You didn't enter a valid title";
 }
 // Validate slug
 if (!empty($_POST['slug']) && !ctype_space($_POST['slug'])) {
     $slug = Functions::CreateSlug(trim($_POST['slug']));
     if ($slug == $page->slug || !Page::IsReserved($slug) && !Page::Exist(array('slug' => $slug))) {
         $data['slug'] = $slug;
     } else {
         $errors['slug'] = "URL is not available";
     }
 } else {
     $errors['slug'] = "You didn't enter a valid URL";
 }
 // Validate content
 if (!empty($_POST['content']) && !ctype_space($_POST['content'])) {
     $data['content'] = trim($_POST['content']);
 } else {
     $data['content'] = '';
 }
 // Update record if no errors were found
开发者ID:KmServer,项目名称:CumulusClips,代码行数:31,代码来源:pages_edit.php


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