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


PHP util::strToSlug方法代码示例

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


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

示例1: buildProdURL

 /**
  * Construit l'URL d'un produit donné
  *
  * @param string $title
  * @param string $url
  * @param integer $product_id
  * @return string
  */
 protected function buildProdURL($title, $url, $product_id)
 {
     if (empty($url)) {
         $url = $title;
     }
     $url = util::strToSlug($url, false);
     # Let's check if URL is taken…
     $query = 'SELECT slug FROM ' . $this->t_products . ' ' . 'WHERE slug=\'' . $this->db->escapeStr($url) . '\' ' . 'AND id <> ' . (int) $product_id . ' ' . 'ORDER BY slug DESC';
     $rs = $this->db->select($query);
     if (!$rs->isEmpty()) {
         $query = 'SELECT slug FROM ' . $this->t_products . ' ' . 'WHERE slug LIKE \'' . $this->db->escapeStr($url) . '%\' ' . 'AND id <> ' . (int) $product_id . ' ' . 'ORDER BY slug DESC ';
         $rs = $this->db->select($query);
         $a = array();
         while ($rs->fetch()) {
             $a[] = $rs->slug;
         }
         $url = util::getIncrementedString($a, $url, '-');
     }
     # URL is empty?
     if ($url == '') {
         throw new Exception(__('Empty entry URL'));
     }
     return $url;
 }
开发者ID:jewelhuq,项目名称:okatea,代码行数:32,代码来源:module_handler.php

示例2: setItemSlug

 /**
  * Création du slug d'un élément donné dans une langue donnée.
  *
  * @param integer $iItemId
  * @param string $sLanguage
  * @return boolean
  */
 protected function setItemSlug($iItemId, $sLanguage)
 {
     $rsItem = $this->getItems(array('id' => $iItemId, 'language' => $sLanguage, 'active' => 2));
     if ($rsItem->isEmpty()) {
         throw new Exception(sprintf(__('m_galleries_error_item_%s_doesnt_exist'), $iItemId));
     }
     if (empty($rsItem->slug)) {
         $sUrl = $rsItem->title;
     } else {
         $sUrl = $rsItem->slug;
     }
     $sUrl = util::strToSlug($sUrl, false);
     # Let's check if URL is taken…
     $rsTakenSlugs = $this->db->select('SELECT slug FROM ' . $this->t_items_locales . ' ' . 'WHERE slug=\'' . $this->db->escapeStr($sUrl) . '\' ' . 'AND item_id <> ' . (int) $iItemId . ' ' . 'AND language=\'' . $this->db->escapeStr($sLanguage) . '\' ' . 'ORDER BY slug DESC');
     if (!$rsTakenSlugs->isEmpty()) {
         $rsCurrentSlugs = $this->db->select('SELECT slug FROM ' . $this->t_items_locales . ' ' . 'WHERE slug LIKE \'' . $this->db->escapeStr($sUrl) . '%\' ' . 'AND item_id <> ' . (int) $iItemId . ' ' . 'AND language=\'' . $this->db->escapeStr($sLanguage) . '\' ' . 'ORDER BY slug DESC ');
         $a = array();
         while ($rsCurrentSlugs->fetch()) {
             $a[] = $rsCurrentSlugs->slug;
         }
         $sUrl = util::getIncrementedString($a, $sUrl, '-');
     }
     $sQuery = 'UPDATE ' . $this->t_items_locales . ' SET ' . 'slug=\'' . $this->db->escapeStr($sUrl) . '\' ' . 'WHERE item_id=' . (int) $iItemId . ' ' . 'AND language=\'' . $this->db->escapeStr($sLanguage) . '\' ';
     if (!$this->db->execute($sQuery)) {
         return false;
     }
     return true;
 }
开发者ID:jewelhuq,项目名称:okatea,代码行数:35,代码来源:class.galleries.items.php

示例3: is_array

    }
    exit;
}
# formulaire envoyé
if (!empty($_POST['sended'])) {
    if ($bHasPagesModule) {
        $aFirstPages = !empty($_POST['p_first_pages']) && is_array($_POST['p_first_pages']) ? $_POST['p_first_pages'] : array();
        $iPageHome = !empty($_POST['p_page_home']) ? intval($_POST['p_page_home']) : 0;
        # création des premières pages
        $aAddedPages = array();
        foreach ($aFirstPages as $i => $aPageInfos) {
            if (!empty($aPageInfos['title'])) {
                $iNewId = $okt->pages->addPage($okt->pages->openPageCursor(array('active' => 1)), array('fr' => array('title' => $aPageInfos['title'], 'content' => !empty($aPageInfos['content']) ? util::nlToP($aPageInfos['content']) : __('i_pages_first_default_content'))), array());
                if ($iPageHome == $i) {
                    $iPageHome = $iNewId;
                    $iPageHomeSlug = util::strToSlug($aPageInfos['title']);
                }
            }
        }
        # défintion d'une route par défaut
        if (!empty($iPageHome)) {
            try {
                $okt->config->write(array('default_route' => array('class' => 'pagesController', 'method' => 'pagesItem', 'args' => $iPageHomeSlug)));
            } catch (InvalidArgumentException $e) {
                $okt->error->set(__('c_c_error_writing_configuration'));
                $okt->error->set($e->getMessage());
            }
        }
    }
    http::redirect('index.php?step=' . $stepper->getNextStep());
}
开发者ID:jewelhuq,项目名称:okatea,代码行数:31,代码来源:pages.php

示例4: setPostSlug

 /**
  * Création du slug d'un article donné dans une langue donnée.
  *
  * @param integer $iPostId
  * @param string $sLanguage
  * @return boolean
  */
 protected function setPostSlug($iPostId, $sLanguage)
 {
     $rsPost = $this->getPostsRecordset(array('id' => $iPostId, 'language' => $sLanguage));
     if ($rsPost->isEmpty()) {
         throw new Exception(sprintf(__('m_news_post_%s_not_exists'), $iPostId));
     }
     if (empty($rsPost->slug)) {
         $sUrl = $rsPost->title;
     } else {
         $sUrl = $rsPost->slug;
     }
     $sUrl = util::strToSlug($sUrl, false);
     # Let's check if URL is taken…
     $rsTakenSlugs = $this->db->select('SELECT slug FROM ' . $this->t_news_locales . ' ' . 'WHERE slug=\'' . $this->db->escapeStr($sUrl) . '\' ' . 'AND post_id <> ' . (int) $iPostId . ' ' . 'AND language=\'' . $this->db->escapeStr($sLanguage) . '\' ' . 'ORDER BY slug DESC');
     if (!$rsTakenSlugs->isEmpty()) {
         $rsCurrentSlugs = $this->db->select('SELECT slug FROM ' . $this->t_news_locales . ' ' . 'WHERE slug LIKE \'' . $this->db->escapeStr($sUrl) . '%\' ' . 'AND post_id <> ' . (int) $iPostId . ' ' . 'AND language=\'' . $this->db->escapeStr($sLanguage) . '\' ' . 'ORDER BY slug DESC ');
         $a = array();
         while ($rsCurrentSlugs->fetch()) {
             $a[] = $rsCurrentSlugs->slug;
         }
         $sUrl = util::getIncrementedString($a, $sUrl, '-');
     }
     $sQuery = 'UPDATE ' . $this->t_news_locales . ' SET ' . 'slug=\'' . $this->db->escapeStr($sUrl) . '\' ' . 'WHERE post_id=' . (int) $iPostId . ' ' . 'AND language=\'' . $this->db->escapeStr($sLanguage) . '\' ';
     if (!$this->db->execute($sQuery)) {
         return false;
     }
     return true;
 }
开发者ID:jewelhuq,项目名称:okatea,代码行数:35,代码来源:module_handler.php

示例5: setCategorySlug

 /**
  * Création du slug d'une rubrique donnée dans une langue donnée.
  *
  * @param integer $iCategoryId
  * @param string $sLanguage
  * @return boolean
  */
 protected function setCategorySlug($iCategoryId, $sLanguage)
 {
     $rsCategory = $this->getCategories(array('id' => $iCategoryId, 'language' => $sLanguage, 'active' => 2));
     if ($rsCategory->isEmpty()) {
         throw new Exception(sprintf(__('m_pages_cat_%s_not_exists'), $iCategoryId));
     }
     if (empty($rsCategory->slug)) {
         $rsParent = $this->getCategories(array('id' => $rsCategory->parent_id, 'language' => $sLanguage, 'active' => 2));
         $sSlug = $rsParent->slug . '/' . $rsCategory->title;
     } else {
         $sSlug = $rsCategory->slug;
     }
     $sSlug = util::strToSlug($sSlug, true);
     # Let's check if URL is taken…
     $query = 'SELECT slug FROM ' . $this->t_categories_locales . ' ' . 'WHERE slug=\'' . $this->db->escapeStr($sSlug) . '\' ' . 'AND category_id <> ' . (int) $iCategoryId . ' ' . 'AND language=\'' . $this->db->escapeStr($sLanguage) . '\' ' . 'ORDER BY slug DESC';
     $rsTakenSlugs = $this->db->select($query);
     if (!$rsTakenSlugs->isEmpty()) {
         $query = 'SELECT slug FROM ' . $this->t_categories_locales . ' ' . 'WHERE slug LIKE \'' . $this->db->escapeStr($sSlug) . '%\' ' . 'AND category_id <> ' . (int) $iCategoryId . ' ' . 'AND language=\'' . $this->db->escapeStr($sLanguage) . '\' ' . 'ORDER BY slug DESC ';
         $rsCurrentSlugs = $this->db->select($query);
         $a = array();
         while ($rsCurrentSlugs->fetch()) {
             $a[] = $rsCurrentSlugs->slug;
         }
         $sSlug = util::getIncrementedString($a, $sSlug, '-');
     }
     $query = 'UPDATE ' . $this->t_categories_locales . ' SET ' . 'slug=\'' . $this->db->escapeStr($sSlug) . '\' ' . 'WHERE category_id=' . (int) $iCategoryId . ' ' . 'AND language=\'' . $this->db->escapeStr($sLanguage) . '\' ';
     if (!$this->db->execute($query)) {
         throw new Exception('Unable to update category in database.');
     }
     return true;
 }
开发者ID:jewelhuq,项目名称:okatea,代码行数:38,代码来源:class.pages.categories.php

示例6: buildQuestionSlug

 /**
  * Construit le slug d'une question donnée dans une langue donnée
  *
  * @param string $title
  * @param string $url
  * @param $question_id
  * @param $lang_code
  * @return string
  */
 protected function buildQuestionSlug($title, $url, $question_id, $lang_code)
 {
     if (empty($url)) {
         $url = $title;
     }
     $url = util::strToSlug($url, false);
     # URL is empty?
     if ($url == '') {
         return $url;
     }
     # Let's check if URL is taken…
     $query = 'SELECT slug FROM ' . $this->t_faq_locales . ' ' . 'WHERE slug=\'' . $this->db->escapeStr($url) . '\' ' . 'AND faq_id <> ' . (int) $question_id . ' ' . 'AND language=\'' . $this->db->escapeStr($lang_code) . '\' ' . 'ORDER BY slug DESC';
     $rs = $this->db->select($query);
     if (!$rs->isEmpty()) {
         $query = 'SELECT slug FROM ' . $this->t_faq_locales . ' ' . 'WHERE slug LIKE \'' . $this->db->escapeStr($url) . '%\' ' . 'AND faq_id <> ' . (int) $question_id . ' ' . 'AND language=\'' . $this->db->escapeStr($lang_code) . '\' ' . 'ORDER BY slug DESC ';
         $rs = $this->db->select($query);
         $a = array();
         while ($rs->fetch()) {
             $a[] = $rs->slug;
         }
         $url = util::getIncrementedString($a, $url, '-');
     }
     # URL is empty?
     //		if ($url == '') {
     //			throw new Exception(__('Empty questions URL'));
     //		}
     return $url;
 }
开发者ID:jewelhuq,项目名称:okatea,代码行数:37,代码来源:module_handler.php

示例7: intval

            $okt->redirect('module.php?m=catalog&action=categories&added=1');
        } else {
            $okt->error->set('Impossible d’ajouter la catégorie.');
        }
    }
}
# modification d’une catégorie
if (!empty($_POST['edit_category']) && $category_id) {
    $edit_category_active = !empty($_POST['edit_category_active']) ? 1 : 0;
    $edit_category_name = !empty($_POST['edit_category_name']) ? $_POST['edit_category_name'] : '';
    $edit_category_parent = !empty($_POST['edit_category_parent']) ? intval($_POST['edit_category_parent']) : 0;
    if (empty($edit_category_name)) {
        $okt->error->set('Vous devez saisir un nom.');
    }
    if ($okt->error->isEmpty()) {
        $edit_category_slug = util::strToSlug($edit_category_name, false);
        if ($okt->catalog->updCategory($category_id, $edit_category_active, $edit_category_name, $edit_category_slug, $edit_category_parent) !== false) {
            $okt->redirect('module.php?m=catalog&action=categories&updated=1');
        } else {
            $okt->error->set('Impossible de mettre à jour la catégorie.');
        }
    }
}
# changement de l’ordre des categories voisines
$order = array();
if (empty($_POST['categories_order']) && !empty($_POST['order'])) {
    $order = $_POST['order'];
    asort($order);
    $order = array_keys($order);
} elseif (!empty($_POST['categories_order'])) {
    $order = explode(',', $_POST['categories_order']);
开发者ID:jewelhuq,项目名称:okatea,代码行数:31,代码来源:categories.php


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