так а в моем коде мы получаем baseSiteUrl а не Base_Path
Абырвалг, ну, а к чему был приведен код метода Mage::getScriptSystemUrl() ???
если он реально в приложени почти не используется
Форум → Программирование → PHP для идиотов → ссылка | роутер нубский вопрос
Страницы: ← Предыдущая страница • Следующая страница →
14 апреля 2010 г. 17:28, спустя 2 минуты 22 секунды
так а в моем коде мы получаем baseSiteUrl а не Base_Path
12 августа 2010 г. 21:38, спустя 120 дней 4 часа 10 минут
protected function prepareBaseUrl()
{
$baseUrl = '';
$filename = basename($this->server->get('SCRIPT_FILENAME'));
if (basename($this->server->get('SCRIPT_NAME')) === $filename) {
$baseUrl = $this->server->get('SCRIPT_NAME');
} elseif (basename($this->server->get('PHP_SELF')) === $filename) {
$baseUrl = $this->server->get('PHP_SELF');
} elseif (basename($this->server->get('ORIG_SCRIPT_NAME')) === $filename) {
$baseUrl = $this->server->get('ORIG_SCRIPT_NAME'); // 1and1 shared hosting compatibility
} else {
// Backtrack up the script_filename to find the portion matching
// php_self
$path = $this->server->get('PHP_SELF', '');
$file = $this->server->get('SCRIPT_FILENAME', '');
$segs = explode('/', trim($file, '/'));
$segs = array_reverse($segs);
$index = 0;
$last = count($segs);
$baseUrl = '';
do {
$seg = $segs[$index];
$baseUrl = '/'.$seg.$baseUrl;
++$index;
} while (($last > $index) && (false !== ($pos = strpos($path, $baseUrl))) && (0 != $pos));
}
// Does the baseUrl have anything in common with the request_uri?
$requestUri = $this->getRequestUri();
if ($baseUrl && 0 === strpos($requestUri, $baseUrl)) {
// full $baseUrl matches
return $baseUrl;
}
if ($baseUrl && 0 === strpos($requestUri, dirname($baseUrl))) {
// directory portion of $baseUrl matches
return rtrim(dirname($baseUrl), '/');
}
$truncatedRequestUri = $requestUri;
if (($pos = strpos($requestUri, '?')) !== false) {
$truncatedRequestUri = substr($requestUri, 0, $pos);
}
$basename = basename($baseUrl);
if (empty($basename) || !strpos($truncatedRequestUri, $basename)) {
// no match whatsoever; set it blank
return '';
}
// If using mod_rewrite or ISAPI_Rewrite strip the script filename
// out of baseUrl. $pos !== 0 makes sure it is not matching a value
// from PATH_INFO or QUERY_STRING
if ((strlen($requestUri) >= strlen($baseUrl)) && ((false !== ($pos = strpos($requestUri, $baseUrl))) && ($pos !== 0))) {
$baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl));
}
return rtrim($baseUrl, '/');
}
12 августа 2010 г. 21:48, спустя 9 минут 22 секунды
12 августа 2010 г. 22:06, спустя 17 минут 46 секунд
12 августа 2010 г. 22:17, спустя 1 минуту 30 секунд
13 августа 2010 г. 7:19, спустя 9 часов 2 минуты 16 секунд
13 августа 2010 г. 10:19, спустя 2 часа 59 минут 48 секунд
13 августа 2010 г. 10:51, спустя 31 минуту 29 секунд
13 августа 2010 г. 11:49, спустя 58 минут 8 секунд
13 августа 2010 г. 11:56, спустя 6 минут 56 секунд
private function _parseRequestString()
{
$this->_moduleName = '';
$this->_actionName = '';
$requestString = trim(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '', '/');
$requestString = str_replace(trim($this->_baseUrl, '/'), '', $requestString);
$pieces = array();
foreach (explode('/', $requestString) as $value) {
if ($value !== ''){
$pieces[] = urldecode($value);
}
}
$this->_moduleName = array_shift($pieces);
$this->_actionName = array_shift($pieces);
while (count($pieces)) {
$_GET[array_shift($pieces)] = array_shift($pieces);
}
}
18 сентября 2010 г. 21:05, спустя 36 дней 9 часов 9 минут
// return location.pathname without base path, scriptname, query params
public function getPath()
{
if ($this->path)
return $this->path;
$requestUri = $this->getRequestUri();
$script = $this->server('SCRIPT_NAME');
if (0 === strpos($requestUri, $script)) {
// requestUri = "/base-path/index.php/foo/bar?c=d"
$path = substr($requestUri, strlen($script));
} else {
// requestUri = "/base-path/foo/bar?c=d"
$basePath = $this->getBasePath();
$path = substr($requestUri, strlen($basePath) - 1);
}
// cut query string
is_int($pos = strpos($path, '?')) && $path = substr($path, 0, $pos);
$path || $path = '/';
return $this->path = $path;
}
public function getBasePath()
{
if ($this->basePath) // да, это байтдроч, я не смог удержаться =)
return $this->basePath;
$script = $this->server('SCRIPT_NAME');
// "/base-path/index.php" -> '/base-path/'
$pos = strrpos($script, '/');
return $this->basePath = substr($script, 0, $pos + 1);
}
public function getBaseUrl()
{
if ($this->baseUrl)
return $this->baseUrl;
$scheme = $this->getScheme();
$port = $this->getPort();
$host = $this->getHost();
$path = $this->getBasePath();
$suffix = (($scheme == 'http' && $port == 80) || ($scheme == 'https' && $port == 443)) ? '' : ':' . $port;
return $this->baseUrl = $scheme . '://' . $host . $suffix . $path;
}
18 сентября 2010 г. 21:07, спустя 1 минуту 39 секунд
ниче так получилось вроде, да?)
18 сентября 2010 г. 21:11, спустя 4 минуты 49 секунд
Страницы: ← Предыдущая страница • Следующая страница →
Пожалуйста, авторизуйтесь, чтобы написать комментарий!