getConfiguration(); if (sfConfig::get('sf_no_script_name')) { // wont work throw new sfException(__FUNCTION__.' : the cross app link helper will not work with sf_no_script_name to true'); } // get the environment if (is_null($env)) { $env = sfContext::getInstance()->getConfiguration()->getEnvironment(); } // context creation if (!sfContext::hasInstance($appname)) { $c = ProjectConfiguration::getApplicationConfiguration($appname, $env, $debug); sfContext::createInstance($c, $appname); } $request = sfContext::getInstance($appname)->getRequest(); $url_root = $request->getRelativeUrlRoot(); if ($absolute) { $url_root = 'http'.($request->isSecure() ? 's' : '').'://'.$request->getHost().$url_root; } //scriptname $scriptname = ''; if (($env != 'prod') and ($env)) { $env_suf = '_'.$env; } else { $env_suf = ''; } if (!file_exists(sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$appname.$env_suf.'.php')) { //test with index ? if (file_exists(sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.'index'.$env_suf.'.php')) $scriptname = 'index'.$env_suf.'.php'; else throw new sfException(__FUNCTION__.' : can\'t find a script name for appname : '.$appname.' and env : '.$env); } else { $scriptname = $appname.$env_suf.'.php'; } $fragment = ''; // strip fragment if (false !== ($pos = strpos($url, '#'))) { $fragment = substr($url, $pos + 1); $url = substr($url, 0, $pos); } // generate url $parameters = sfContext::getInstance($appname)->getRouting()->parse($url); if (sfConfig::get('sf_url_format') == 'PATH') { // use PATH format $divider = '/'; $equals = '/'; $querydiv = '/'; } else { // use GET format $divider = ini_get('arg_separator.output'); $equals = '='; $querydiv = '?'; } $web_url = $url_root.$querydiv.$scriptname.sfContext::getInstance($appname)->getRouting()->generate(null, $parameters, $querydiv, $divider, $equals); if ($fragment) { $web_url .= '#'.$fragment; } // restore the default / current configuration sfContext::switchTo($currentConfiguration->getApplication()); return $web_url; }