This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e07fcb
commit fab13d9
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/* | ||
* Smarty plugin | ||
* ------------------------------------------------------------- | ||
* File: function.baseUrl.php | ||
* Type: function | ||
* Name: baseUrl | ||
* Purpose: outputs url for a function with the defined name method | ||
* ------------------------------------------------------------- | ||
*/ | ||
function smarty_function_baseUrl($params, $template) | ||
{ | ||
$withUri = isset($params['withUri']) ? $params['withUri'] : true; | ||
$appName = isset($params['appname']) ? $params['appname'] : 'default'; | ||
|
||
$req = \Slim\Slim::getInstance($appName)->request(); | ||
$uri = $req->getUrl(); | ||
|
||
if ($withUri) { | ||
$uri .= $req->getRootUri(); | ||
} | ||
|
||
return $uri; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
/* | ||
* Smarty plugin | ||
* ------------------------------------------------------------- | ||
* File: function.siteUrl.php | ||
* Type: function | ||
* Name: siteUrl | ||
* Purpose: outputs url for a function with the defined name method | ||
* ------------------------------------------------------------- | ||
*/ | ||
function smarty_function_siteUrl($params, $template) | ||
{ | ||
$withUri = isset($params['withUri']) ? $params['withUri'] : true; | ||
$appName = isset($params['appname']) ? $params['appname'] : 'default'; | ||
$url = isset($params['url']) ? $params['url'] : ''; | ||
|
||
$req = \Slim\Slim::getInstance($appName)->request(); | ||
$uri = $req->getUrl(); | ||
|
||
if ($withUri) { | ||
$uri .= $req->getRootUri(); | ||
} | ||
|
||
return $uri . '/' . ltrim($url, '/'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/* | ||
* Smarty plugin | ||
* ------------------------------------------------------------- | ||
* File: function.urlFor.php | ||
* Type: function | ||
* Name: urlFor | ||
* Purpose: outputs url for a function with the defined name method | ||
* ------------------------------------------------------------- | ||
*/ | ||
function smarty_function_urlFor($params, $template) | ||
{ | ||
$name = isset($params['name']) ? $params['name'] : ''; | ||
$appName = isset($params['appname']) ? $params['appname'] : 'default'; | ||
|
||
$url = \Slim\Slim::getInstance($appName)->urlFor($name); | ||
|
||
if (isset($params['options'])) | ||
{ | ||
$options = explode('|', $params['options']); | ||
foreach ($options as $option) { | ||
list($key, $value) = explode('.', $option); | ||
$opts[$key] = $value; | ||
} | ||
|
||
$url = \Slim\Slim::getInstance($appName)->urlFor($name, $opts); | ||
} | ||
|
||
return $url; | ||
} |