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


PHP text::tidyURL方法代码示例

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


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

示例1: sanitizeMetaID

 /**
 Make a metadata ID URL-proof.
 
 @param	str		<b>string</b>	the metadata ID.
 
 @return	<b>string</b>	The sanitized metadata
 */
 public static function sanitizeMetaID($str)
 {
     return text::tidyURL($str, false, true);
 }
开发者ID:nikrou,项目名称:dotclear,代码行数:11,代码来源:class.dc.meta.php

示例2: date

 /**
 Returns URL for a post according to blog setting <var>post_url_format</var>.
 It will try to guess URL and append some figures if needed.
 
 @param	url			<b>string</b>		Origin URL, could be empty
 @param	post_dt		<b>string</b>		Post date (in YYYY-MM-DD HH:mm:ss)
 @param	post_title	<b>string</b>		Post title
 @param	post_id		<b>integer</b>		Post ID
 @return	<b>string</b>	result URL
 */
 public function getPostURL($url, $post_dt, $post_title, $post_id)
 {
     $url = trim($url);
     $url_patterns = array('{y}' => date('Y', strtotime($post_dt)), '{m}' => date('m', strtotime($post_dt)), '{d}' => date('d', strtotime($post_dt)), '{t}' => text::tidyURL($post_title), '{id}' => (int) $post_id);
     # If URL is empty, we create a new one
     if ($url == '') {
         # Transform with format
         $url = str_replace(array_keys($url_patterns), array_values($url_patterns), $this->settings->system->post_url_format);
     } else {
         $url = text::tidyURL($url);
     }
     # Let's check if URL is taken...
     $strReq = 'SELECT post_url FROM ' . $this->prefix . 'post ' . "WHERE post_url = '" . $this->con->escape($url) . "' " . 'AND post_id <> ' . (int) $post_id . ' ' . "AND blog_id = '" . $this->con->escape($this->id) . "' " . 'ORDER BY post_url DESC';
     $rs = $this->con->select($strReq);
     if (!$rs->isEmpty()) {
         if ($this->con->driver() == 'mysql' || $this->con->driver() == 'mysqli') {
             $clause = "REGEXP '^" . $this->con->escape($url) . "[0-9]+\$'";
         } elseif ($this->con->driver() == 'pgsql') {
             $clause = "~ '^" . $this->con->escape($url) . "[0-9]+\$'";
         } else {
             $clause = "LIKE '" . $this->con->escape($url) . "%'";
         }
         $strReq = 'SELECT post_url FROM ' . $this->prefix . 'post ' . "WHERE post_url " . $clause . ' ' . 'AND post_id <> ' . (int) $post_id . ' ' . "AND blog_id = '" . $this->con->escape($this->id) . "' " . 'ORDER BY post_url DESC ';
         $rs = $this->con->select($strReq);
         $a = array();
         while ($rs->fetch()) {
             $a[] = $rs->post_url;
         }
         natsort($a);
         $t_url = end($a);
         if (preg_match('/(.*?)([0-9]+)$/', $t_url, $m)) {
             $i = (int) $m[2];
             $url = $m[1];
         } else {
             $i = 1;
         }
         return $url . ($i + 1);
     }
     # URL is empty?
     if ($url == '') {
         throw new Exception(__('Empty entry URL'));
     }
     return $url;
 }
开发者ID:nikrou,项目名称:dotclear,代码行数:54,代码来源:class.dc.blog.php

示例3: strToSlug

 /**
  * Transform a string in slug regarding to configuration.
  *
  * @param string $str
  */
 public static function strToSlug($str, $with_slashes = true)
 {
     /*
     static $sType = null;
     
     if (is_null($sType))
     {
     	global $okt;
     
     	if (isset($okt) && !empty($okt->config->slug_type)) {
     		$sType = $okt->config->slug_type;
     	}
     	else {
     		$sType = 'ascii';
     	}
     }
     */
     switch ($GLOBALS['okt']->config->slug_type) {
         case 'utf8':
             return text::tidyURL($str, $with_slashes);
         case 'ascii':
         default:
             return self::strToLowerURL($str, $with_slashes);
     }
 }
开发者ID:jewelhuq,项目名称:okatea,代码行数:30,代码来源:lib.util.php


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