本文整理汇总了PHP中SPLang::urlSafe方法的典型用法代码示例。如果您正苦于以下问题:PHP SPLang::urlSafe方法的具体用法?PHP SPLang::urlSafe怎么用?PHP SPLang::urlSafe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPLang
的用法示例。
在下文中一共展示了SPLang::urlSafe方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: url
/**
* Creating URL from a array for the current CMS
* @param array $var
* @param bool $js
* @param bool $sef
* @param bool $live
* @param bool $forceItemId
* @return string
*/
public static function url($var = null, $js = false, $sef = true, $live = false, $forceItemId = false)
{
$url = self::baseUrl;
if ($var == 'current') {
return SPRequest::raw('REQUEST_URI', self::baseUrl, 'SERVER');
}
// don't remember why :(
// Nevertheless it is generating & in URL fro ImEx
// $sef = Sobi::Cfg( 'disable_sef_globally', false ) ? false : ( defined( 'SOBIPRO_ADM' ) && !( $forceItemId ) ? false : $sef );
$sef = Sobi::Cfg('disable_sef_globally', false) ? false : $sef;
Sobi::Trigger('Create', 'Url', array(&$var, $js));
if (is_array($var) && !empty($var)) {
if (isset($var['option'])) {
$url = str_replace('com_sobipro', $var['option'], $url);
unset($var['option']);
}
if (isset($var['sid']) && (!defined('SOBIPRO_ADM') || $forceItemId) || defined('SOBIPRO_ADM') && $sef && $live) {
if (!isset($var['Itemid']) || !$var['Itemid']) {
SPFactory::mainframe()->getItemid($var);
}
}
if (isset($var['title'])) {
if (Sobi::Cfg('url.title', true)) {
$var['title'] = trim(SPLang::urlSafe($var['title']));
$var['sid'] = $var['sid'] . ':' . $var['title'];
}
unset($var['title']);
}
if (isset($var['format']) && $var['format'] == 'raw' && $sef) {
unset($var['format']);
}
foreach ($var as $k => $v) {
if ($k == 'out') {
switch ($v) {
case 'html':
$var['tmpl'] = 'component';
unset($var['out']);
break;
case 'xml':
$var['tmpl'] = 'component';
$var['format'] = 'raw';
case 'raw':
$var['tmpl'] = 'component';
$var['format'] = 'raw';
break;
case 'json':
$var['out'] = 'json';
$var['format'] = 'raw';
$var['tmpl'] = 'component';
break;
}
}
}
foreach ($var as $k => $v) {
$url .= "&{$k}={$v}";
}
} elseif (is_string($var)) {
if (strstr($var, 'index.php?')) {
$url = null;
} else {
$url .= '&';
}
if (strstr($var, '=')) {
$var = str_replace('&', '&', $var);
$var = str_replace('&', '&', $var);
$url .= $var;
} else {
$url .= SOBI_TASK . '=';
$url .= $var;
}
} elseif (is_array($var)) {
}
if ($sef && !$live) {
$url = JRoute::_($url, false);
} else {
$url = preg_replace('/&(?![#]?[a-z0-9]+;)/i', '&', $url);
}
if ($live) {
/*
* SubDir Issues:
* when using SEF Joomla! router returns also the subdir
* and JURI::base returns the subdir too
* So if the URL should be SEF we have to remove the subdirectory once
* Otherwise it doesn't pass the JRoute::_ method so there is no subdir included
* */
if ($sef) {
$base = JURI::base(true);
$root = str_replace($base, null, Sobi::Cfg('live_site'));
$url = explode('/', $url);
$url = $url[count($url) - 1];
// if ( defined( 'SOBIPRO_ADM' ) ) {
//.........这里部分代码省略.........