]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/theme.php
Merge branch '0.7.x' into 0.8.x
[quix0rs-gnu-social.git] / lib / theme.php
1 <?php
2 /**
3  * Laconica, the distributed open-source microblogging tool
4  *
5  * Utilities for theme files and paths
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @category  Paths
23  * @package   Laconica
24  * @author    Evan Prodromou <evan@controlyourself.ca>
25  * @author    Sarven Capadisli <csarven@controlyourself.ca>
26  * @copyright 2008 Control Yourself, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28  * @link      http://laconi.ca/
29  */
30
31 if (!defined('LACONICA')) {
32     exit(1);
33 }
34
35 /**
36  * Gets the full path of a file in a theme dir based on its relative name
37  *
38  * @param string $relative relative path within the theme directory
39  * @param string $theme    name of the theme; defaults to current theme
40  *
41  * @return string File path to the theme file
42  */
43
44 function theme_file($relative, $theme=null)
45 {
46     if (!$theme) {
47         $theme = common_config('site', 'theme');
48     }
49     return INSTALLDIR.'/theme/'.$theme.'/'.$relative;
50 }
51
52 /**
53  * Gets the full URL of a file in a theme dir based on its relative name
54  *
55  * @param string $relative relative path within the theme directory
56  * @param string $theme    name of the theme; defaults to current theme
57  *
58  * @return string URL of the file
59  */
60
61 function theme_path($relative, $theme=null)
62 {
63     if (!$theme) {
64         $theme = common_config('site', 'theme');
65     }
66     $server = common_config('theme', 'server');
67     if ($server) {
68         return 'http://'.$server.'/'.$theme.'/'.$relative;
69     } else {
70         return common_path('theme/'.$theme.'/'.$relative);
71     }
72 }
73
74 /**
75  * Gets the full URL of a file in a skin dir based on its relative name
76  *
77  * @param string $relative relative path within the theme, skin directory
78  * @param string $theme    name of the theme; defaults to current theme
79  * @param string $skin    name of the skin; defaults to current theme
80  *
81  * @return string URL of the file
82  */
83
84 function skin_path($relative, $theme=null, $skin=null)
85 {
86     if (!$theme) {
87         $theme = common_config('site', 'theme');
88     }
89     if (!$skin) {
90         $skin = common_config('site', 'skin');
91     }
92     $server = common_config('theme', 'server');
93     if ($server) {
94         return 'http://'.$server.'/'.$theme.'/skin/'.$skin.'/'.$relative;
95     } else {
96         return common_path('theme/'.$theme.'/skin/'.$skin.'/'.$relative);
97     }
98 }
99