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


PHP util::getIncrementedString方法代码示例

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


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

示例1: 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

示例2: 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

示例3: buildFieldHtmlId

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


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