/** * 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' ) ) { // $router = JApplication::getInstance( 'site' )->getRouter(); // $a = $router->build( $url ); // $url = $router->build( $url )->toString(); // } if (!defined('SOBIPRO_ADM')) { $url = JRoute::_($url, false); } $url = Sobi::FixPath("{$root}{$url}"); } else { $adm = defined('SOBIPRO_ADM') ? SOBI_ADM_FOLDER : null; $url = Sobi::FixPath(Sobi::Cfg('live_site') . $adm . '/' . $url); } } $url = str_replace('%3A', ':', $url); // all urls in front are passed to the XML/XSL template are going to be encoded anyway $o = SPRequest::cmd('format', SPRequest::cmd('out')); if (!in_array($o, array('raw', 'xml')) && !defined('SOBI_ADM_PATH')) { $url = html_entity_decode($url); } $url = str_replace(' ', '%20', urldecode($url)); return $js ? str_replace('amp;', null, $url) : $url; }