modifier.scheme.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 
12 /**
13  * Add the scheme to an url, if missing.
14  *
15  * Example:
16  * @code
17  * <a href="{$url|scheme}">Link</a>
18  * @endcode
19  *
20  * @param $url The url
21  * @return String
22  */
23 function smarty_modifier_scheme($url) {
24  return (!preg_match('/^[a-zA-Z0-9-]+:\/\//', $url)) ? '//'.$url : $url;
25 }
26 ?>