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


PHP slug函数代码示例

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


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

示例1: productAlmostOutOfStock

 public static function productAlmostOutOfStock($type)
 {
     $almost_out_of_stock = Product::with(array('brand' => function ($query) {
         $query->select('id', 'name');
     }, 'categories' => function ($query) {
         $query->select('id', 'name');
     }))->select('id', 'name', 'quantity', 'productcat_id', 'brand_id', 'almost_finished', 'published')->orderBy('quantity', 'asc')->get()->toArray();
     //tt(count($almost_out_of_stock), true);
     $counter = 0;
     // Counter for count alert
     if ($type === 'list' || $type === 'all') {
     }
     if (!empty($almost_out_of_stock)) {
         foreach ($almost_out_of_stock as $key) {
             if ($key['published'] != 0 && $key['quantity'] <= $key['almost_finished']) {
                 //We'll take record is we're requesting for listing the items
                 if ($type === 'list' || $type === 'all') {
                     $key['linktoproduct'] = User::permitted('role.stock manager') ? URL::route('adminShowProduct', array(slug($key['brand']['name']), slug($key['categories']['name']))) : '';
                     //tt($key);
                     $data['products'][] = $key;
                 }
                 $counter++;
             }
         }
     }
     $data['count'] = $counter;
     //tt(count($data['products']));
     return $data;
 }
开发者ID:sliekasirdis79,项目名称:POS,代码行数:29,代码来源:AlertController.php

示例2: create_list_item

function create_list_item($child)
{
    $id = slug($child->label);
    if ($child->type == 'region-monde') {
        return "<div id='{$id}' class='{$child->type}'>";
    }
    if ($child->type == 'pays') {
        return "<div id='{$id}' class='{$child->type}'><h2>{$child->label}</h2>";
    }
    if ($child->type == 'region') {
        return "<div id='{$id}'><h3>{$child->label}</h3>";
    }
    if ($child->type == 'sous-region') {
        return "<div id='{$id}'><h4>{$child->label}</h4>";
    }
    if ($child->type == 'promo') {
        return "<div>" . create_promo_wines($child->id);
    }
    if ($child->type == 'vins-au-verre') {
        return "<div>" . print_vins_au_verre($child->id);
    }
    if ($child->type == 'demi-bouteilles') {
        return "<div>" . print_demi_bouteilles($child->id);
    } else {
        return "";
    }
}
开发者ID:Razinsky,项目名称:echaude-com,代码行数:27,代码来源:vins.php

示例3: initialize_page

function initialize_page()
{
    $category_id = requestIdParam();
    $category = Categories::FindById($category_id);
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if (isset($_POST['delete'])) {
        $category->delete(true);
        setFlash("<h3>Category Deleted</h3>");
        redirect("/admin/list_categories/");
    } else {
        if ($post_action == "Edit Category" || $post_action == "Edit and Return to List") {
            $category->display_name = getPostValue('display_name');
            $category->name = slug(getPostValue('display_name'));
            $category->content = getPostValue('category_content');
            $category->save();
            setFlash("<h3>Category Edited</h3>");
            if ($post_action == "Edit and Return to List") {
                redirect("admin/list_categories/");
            }
        }
    }
}
开发者ID:highchair,项目名称:hcd-trunk,代码行数:25,代码来源:edit_category.php

示例4: register_upload_option

/**
 * Register an upload option
 * ---------------------------------------------------------------------------------------
 * Updated by Fawaz Tahir on 9th Sep, 2012 
 * -----------------------------------------------
 * Introducing object parameter. This way we dont need to make separate
 * variables for different objects. To make sure right object is provided, we'll
 * check it against $Cbucket->search_types key. If it exists in variable, we'll
 * add it.
 * ---------------------------------------------------------------------------------------
 * 
 * @global OBJECT $Cbucket
 * @param ARRAY $array
 * @return boolean
 */
function register_upload_option($array)
{
    global $Cbucket;
    /**
     * -- for reference
     * an array will have
     * title -> required
     * description -> required
     * icon -> optional
     * function -> required , a php callback function to display in upload
     * window.
     */
    extract($array);
    if (!$title || !$description || !function_exists($function) || !$function) {
        return false;
    }
    /* $type checking - Added by Fawaz Tahir */
    if (!$Cbucket->search_types[$object]) {
        return false;
    }
    if (!$id) {
        $id = slug($title);
    }
    $upload_option = array('title' => $title, 'id' => $id, 'description' => $description, 'icon' => $icon, 'function' => $function);
    apply_filters($upload_option, 'register_upload_option');
    $Cbucket->upload_options[$object][] = $upload_option;
    return $upload_option;
}
开发者ID:yukisky,项目名称:clipbucket,代码行数:43,代码来源:functions_upload.php

示例5: create_folder

function create_folder($userid, $semester_id, $subject_id)
{
    $CI =& get_instance();
    $user = $CI->common_model->query("SELECT user_type.`type`, users.user_name FROM users LEFT JOIN user_type ON users.user_type = user_type.id WHERE users.id = " . $userid . "")->row();
    $folder1 = strtolower($user->type);
    $path = './uploads/' . $folder1;
    if (!file_exists($path)) {
        mkdir($path, 0777, true);
    }
    $folder2 = strtolower($user->user_name);
    $path = './uploads/' . $folder1 . '/' . $folder2;
    if (!file_exists($path)) {
        mkdir($path, 0777, true);
    }
    if (strtolower($user->type) == "student") {
        $semester = $CI->common_model->query("SELECT semesters.semester FROM semesters WHERE semesters.id = " . $semester_id . "")->row();
        $folder3 = slug($semester->semester);
        $path = './uploads/' . $folder1 . '/' . $folder2 . '/' . $folder3;
        if (!file_exists($path)) {
            mkdir($path, 0777, true);
        }
    }
    $subjects = $CI->common_model->query("SELECT subjects.subjects FROM subjects WHERE subjects.id = " . $subject_id . "")->row();
    $folder4 = slug($subjects->subjects);
    if (strtolower($user->type) == "student") {
        $path = './uploads/' . $folder1 . '/' . $folder2 . '/' . $folder3 . '/' . $folder4;
    } else {
        $path = './uploads/' . $folder1 . '/' . $folder2 . '/' . $folder4;
    }
    if (!file_exists($path)) {
        mkdir($path, 0777, true);
    }
    return $path;
}
开发者ID:sweetevil,项目名称:DataDrive,代码行数:34,代码来源:common_helper.php

示例6: add

 public function add()
 {
     if ($this->request->is('post')) {
         ///debug('Hiiiiiii');die;
         //debug($this->request->data);
         /*$folderName = 'profiles';	 */
         $slug = substr(slug($this->request->data['NoticeBoard']['title']), 0, 40);
         $document_path = '/files/' . $this->request->data['NoticeBoard']['url']['name'];
         $path = move_uploaded_file($this->data['NoticeBoard']['url']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . '/app/webroot/files/' . $this->data['NoticeBoard']['url']['name']);
         /*debug($_SERVER['DOCUMENT_ROOT']);		
           debug($path);*/
         /* $image_path = $this->Upload->upload_image_and_thumbnail($this->request->data,"name1",600,125,$folderName,false,$slug);*/
         $this->request->data['NoticeBoard']['url'] = $document_path;
         //debug($image_path);
         //$this->request->data['NoticeBoard']['url']	= $document_path;
         // $this->request->data['Event']['image']	= $image_path;
         $this->NoticeBoard->create();
         if ($this->NoticeBoard->save($this->request->data)) {
             $this->Session->setFlash(__('The notice board has been saved'));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The notice board could not be saved. Please, try again.'));
         }
     }
 }
开发者ID:Numerico-Informatic-Systems-Pvt-Ltd,项目名称:gsmpoly,代码行数:25,代码来源:NoticeBoardsController1.php

示例7: imgFindUploadSaveFromHTML

 function imgFindUploadSaveFromHTML($html, $folderName)
 {
     /* Reference: http://stackoverflow.com/questions/138313/how-to-extract-img-src-title-and-alt-from-html-using-php */
     /* added on 8/28/11 to get images from any HTML content */
     $html = stripslashes($html);
     $doc = new DOMDocument();
     $doc->loadHTML($html);
     $xml = simplexml_import_dom($doc);
     // just to make xpath more simple
     $images = $xml->xpath('//img');
     /* foreach ($images as $img) {
     				echo $img['src'] . ' ' . $img['alt'] . ' ' . $img['title'];
     			}
     			*/
     foreach ($images as $img) {
         // echo $img['src'] . ' ' . $img['alt'] . ' ' . $img['title'];
         if (fopen($img['src'], "r") == true) {
             // run this check to see, if the image is on external server. For internal server, do nothing!
             if (strlen($img['src']) > 4) {
                 $alt = substr(slug($img['alt']), 0, 75);
                 $filename = $this->Upload->save_image_from_url($img['src'], 640, 125, $folderName, false, $alt);
                 if (!empty($filename)) {
                     $new_image_path = '/img/' . $folderName . '/big/' . $this->Upload->save_image_from_url($img['src'], 640, 125, $folderName, false, $alt);
                     if ($new_image_path) {
                         $html = str_replace($img['src'], $new_image_path, $html);
                     }
                 }
             }
         }
     }
     return $html;
 }
开发者ID:Numerico-Informatic-Systems-Pvt-Ltd,项目名称:asha,代码行数:32,代码来源:AppController.php

示例8: add

 function add()
 {
     /*if (!empty($this->data)) {
           $this->Event->create();
           if ($this->Event->save($this->data)) {
               $this->Session->setFlash(__('The event has been saved', true));
               $this->redirect(array('action' => 'index'));
           } else {
               $this->Session->setFlash(__('The event could not be saved. Please, try again.', true));
           }
       }
       $users = $this->Event->User->find('list');
       $this->set(compact('users'));*/
     if ($this->request->is('post')) {
         debug($_POST);
         $folderName = 'events';
         $slug = substr(slug($this->request->data['Event']['title']), 0, 40);
         $image_path = $this->Upload->upload_image_and_thumbnail($this->request->data, "name1", 600, 125, $folderName, false, $slug);
         $this->request->data['Event']['image'] = $image_path;
         $this->Event->create();
         if ($this->Event->save($this->request->data)) {
             $this->Session->setFlash(__('The event has been saved'));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The event could not be saved. Please, try again.'));
         }
     }
     $users = $this->Event->User->find('list');
     $this->set(compact('users'));
 }
开发者ID:Numerico-Informatic-Systems-Pvt-Ltd,项目名称:gsmpoly,代码行数:30,代码来源:EventsController2.php

示例9: editOrSave

 private function editOrSave($action)
 {
     $validations = array("exists" => array("Slug" => slug(POST("title", "clean")), "Year" => date("Y"), "Month" => date("m"), "Day" => date("d"), "Language" => POST("language")), "title" => "required", "content" => "required");
     $this->categories = POST("categories");
     $this->tags = POST("tags");
     $this->URL = PATH("blog/" . date("Y")) . "/" . date("m") . "/" . date("d") . "/" . slug(POST("title", "clean"));
     $this->muralExist = POST("mural_exist");
     $this->Files = $this->core("Files");
     $this->mural = FILES("mural");
     if ($this->mural["name"] !== "") {
         $dir = "www/lib/files/images/mural/";
         $this->mural = $this->Files->uploadImage($dir, "mural", "mural");
         if (is_array($this->mural)) {
             return $this->mural["alert"];
         }
     }
     $dir = "www/lib/files/images/blog/";
     $this->image = $this->Files->uploadImage($dir, "image", "resize", TRUE, TRUE, FALSE);
     $data = array("ID_User" => SESSION("ZanUserID"), "ID_URL" => 1, "Slug" => slug(POST("title", "clean")), "Content" => POST("content", "clean"), "Author" => SESSION("ZanUser"), "Year" => date("Y"), "Month" => date("m"), "Day" => date("d"), "Image_Small" => isset($this->image["small"]) ? $this->image["small"] : NULL, "Image_Medium" => isset($this->image["medium"]) ? $this->image["medium"] : NULL, "Pwd" => POST("pwd") ? POST("pwd", "encrypt") : NULL, "Start_Date" => now(4), "Text_Date" => now(2));
     $this->Data->ignore(array("categories", "tags", "mural_exists", "mural", "pwd", "category", "language_category", "application", "mural_exist"));
     $this->data = $this->Data->proccess($data, $validations);
     if (isset($this->data["error"])) {
         return $this->data["error"];
     }
 }
开发者ID:no2key,项目名称:MuuCMS,代码行数:25,代码来源:multimedia.php

示例10: index

 public function index()
 {
     $this->language->load('common/home');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->document->addScript('//code.jquery.com/ui/1.11.4/jquery-ui.min.js');
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => 'fa fa-dashboard');
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     } else {
         $this->data['success'] = '';
     }
     $this->load->model('user/user');
     $panels = $this->model_user_user->getDashboard($this->user->getId());
     if (!$panels) {
         $panels = '{dashleft:"",dashcntr:"",dashright:"",dashhide:""}';
     }
     $this->data['panels'] = $panels;
     $this->data['widgets'] = array();
     $files = glob(DIR_APPLICATION . 'controller/dashboard/*.php');
     if ($files) {
         foreach ($files as $file) {
             $extension = basename($file, '.php');
             $this->load->language('dashboard/' . $extension);
             $this->data['widgets'][slug($extension)] = $this->load->controller('dashboard/' . $extension);
         }
     }
     $this->event->trigger('admin.dashboard.widget', $this->data['widgets']);
     $this->template = 'common/home.phtml';
     $this->children = array('common/header', 'common/footer');
     $this->response->setOutput($this->render());
 }
开发者ID:phpsa,项目名称:CoreCMS,代码行数:34,代码来源:home.php

示例11: edit

 /**
  * edit method
  *
  * @throws NotFoundException
  * @param string $id
  * @return void
  */
 public function edit($id = null)
 {
     $this->Event->id = $id;
     if (!$this->Event->exists()) {
         throw new NotFoundException(__('Invalid event'));
     }
     if ($this->request->is('post') || $this->request->is('put')) {
         $slug = substr(slug($this->request->data['Event']['title']), 0, 40);
         $folderName = 'events';
         $image_path = $this->Upload->upload_image_and_thumbnail($this->request->data, "name1", 600, 125, $folderName, false, $slug);
         if (strlen($image_path) > 4) {
             $this->request->data['Event']['image'] = $image_path;
             $detail = $this->Event->findById($id);
             $filename = $detail['Event']['image'];
             $this->Upload->delete_image($filename, $folderName);
         }
         if ($this->Event->save($this->request->data)) {
             $this->Session->setFlash(__('The event has been saved'));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The event could not be saved. Please, try again.'));
         }
     } else {
         $this->request->data = $this->Event->read(null, $id);
     }
     $users = $this->Event->User->find('list');
     $this->set(compact('users'));
 }
开发者ID:Numerico-Informatic-Systems-Pvt-Ltd,项目名称:gsmpoly,代码行数:35,代码来源:EventsController.php

示例12: edit

 /**
  * edit method
  *
  * @throws NotFoundException
  * @param string $id
  * @return void
  */
 public function edit($id = null)
 {
     $this->Picture->id = $id;
     if (!$this->Picture->exists()) {
         throw new NotFoundException(__('Invalid picture'));
     }
     if ($this->request->is('post') || $this->request->is('put')) {
         $slug = substr(slug($this->request->data['Picture']['name']), 0, 40);
         $folderName = 'pictures';
         $image_path = $this->Upload->upload_image_and_thumbnail($this->request->data, "name1", 1024, 768, $folderName, false, $slug);
         if (strlen($image_path) > 4) {
             $this->request->data['Picture']['picture'] = $image_path;
             $detail = $this->Picture->findById($id);
             $filename = $detail['Picture']['picture'];
             $this->Upload->delete_image($filename, $folderName);
         }
         if ($this->Picture->save($this->request->data)) {
             $this->Session->setFlash(__('The picture has been saved'));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The picture could not be saved. Please, try again.'));
         }
     } else {
         $this->request->data = $this->Picture->read(null, $id);
     }
     $albums = $this->Picture->Album->find('list');
     $this->set(compact('albums'));
 }
开发者ID:Numerico-Informatic-Systems-Pvt-Ltd,项目名称:gsmpoly,代码行数:35,代码来源:PicturesController.php

示例13: initialize_page

function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Add Document" || $post_action == "Add and Return to List") {
        $name = $_POST['name'];
        $file_type = getFileExtension($_FILES['file']['name']);
        $filename = slug(getFileName($_FILES['file']['name']));
        $filename_string = $filename . "." . $file_type;
        // Check to make sure there isn't already a file with that name
        $possibledoc = Documents::FindByFilename($filename_string);
        if (is_object($possibledoc)) {
            setFlash("<h3>Failure: Document filename already exists!</h3>");
            redirect("admin/add_document");
        }
        $target_path = SERVER_DOCUMENTS_ROOT . $filename_string;
        if (move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
            $new_doc = MyActiveRecord::Create('Documents', array('name' => $name, 'filename' => $filename_string, 'file_type' => $file_type));
            $new_doc->save();
            if (!chmod($target_path, 0644)) {
                setFlash("<h3>Warning: Document Permissions not set; this file may not display properly</h3>");
            }
            setFlash("<h3>Document uploaded</h3>");
        } else {
            setFlash("<h3>Failure: Document could not be uploaded</h3>");
        }
        if ($post_action == "Add and Return to List") {
            redirect("admin/list_documents");
        }
    }
}
开发者ID:highchair,项目名称:hcd-trunk,代码行数:33,代码来源:add_document.php

示例14: update

function update($conn, $dados, $id)
{
    $update = $conn->prepare('UPDATE pages SET title=:title, body=:body, slug=:slug WHERE id=:id;');
    $update->bindValue(':title', $dados['title'], PDO::PARAM_STR);
    $update->bindValue(':body', $dados['body'], PDO::PARAM_STR);
    $update->bindValue(':slug', slug($dados['title']), PDO::PARAM_STR);
    $update->bindValue(':id', $id, PDO::PARAM_INT);
    return $update->execute();
}
开发者ID:hsnunes,项目名称:rhtransparencia,代码行数:9,代码来源:_Pages.php

示例15: initialize_page

function initialize_page()
{
    $page_id = requestIdParam();
    $page = Pages::FindById($page_id);
    // get all the areas
    $areas = Areas::FindPublicAreas();
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Save Page" || $post_action == "Save and Return to List") {
        if (isset($_POST['delete'])) {
            $page->delete(true);
            setFlash("<h3>Page deleted</h3>");
            redirect("/admin/list_pages");
        } else {
            $page->display_name = $_POST['display_name'];
            $oldname = $page->name;
            if (ALLOW_SHORT_PAGE_NAMES) {
                if ($_POST['name'] == "") {
                    $page->name = slug($_POST['display_name']);
                } else {
                    $page->name = slug($_POST['name']);
                }
            } else {
                $page->name = slug($_POST['display_name']);
            }
            $page->content = $_POST['page_content'];
            $page->template = $_POST['template'];
            $page->public = checkboxValue($_POST, 'public');
            // Pages can either be directly assigned to areas, or assigned as a sub-page.
            // It's an either-or thing. For now, default to areas if they're selected (ie, if both selected, ignore the sub-page)
            // synchronize the users area selections
            $selected_areas = array();
            if (isset($_POST['selected_areas'])) {
                $selected_areas = $_POST['selected_areas'];
            }
            if (count($selected_areas) > 0) {
                $page->parent_page_id = null;
                $page->updateSelectedAreas($selected_areas);
            } else {
                if ($_POST['parent_page'] != "") {
                    $page->parent_page_id = $_POST['parent_page'];
                } else {
                    $page->parent_page_id = null;
                }
            }
            $page->save();
            $page->checkAlias($selected_areas, $oldname);
            setFlash("<h3>Success. Database Updated</h3>");
            if ($post_action == "Save and Return to List") {
                redirect("admin/list_pages");
            }
        }
    }
}
开发者ID:highchair,项目名称:hcd-trunk,代码行数:56,代码来源:edit_page.php


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