1 | <?php |
---|
2 | |
---|
3 | /* ----------------------------------------------------------------------------- |
---|
4 | class name: GPCCss |
---|
5 | class version : 3.0.0 |
---|
6 | plugin version : 3.0.0 |
---|
7 | date : 2010-03-30 |
---|
8 | |
---|
9 | ------------------------------------------------------------------------------ |
---|
10 | Author : Grum |
---|
11 | email : grum@piwigo.org |
---|
12 | website : http://photos.grum.fr |
---|
13 | PWG user : http://forum.phpwebgallery.net/profile.php?id=3706 |
---|
14 | |
---|
15 | << May the Little SpaceFrog be with you ! >> |
---|
16 | ------------------------------------------------------------------------------ |
---|
17 | |
---|
18 | :: HISTORY |
---|
19 | |
---|
20 | | release | date | |
---|
21 | | 3.0.0 | 2010/03/30 | * Update class & function names |
---|
22 | | | | |
---|
23 | | | | |
---|
24 | | | | |
---|
25 | | | | |
---|
26 | | | | |
---|
27 | | | | |
---|
28 | |
---|
29 | ------------------------------------------------------------------------------ |
---|
30 | |
---|
31 | this classes provides base functions to manage css |
---|
32 | classe consider that $filename is under plugins/ directory |
---|
33 | |
---|
34 | |
---|
35 | - constructor Css($filename) |
---|
36 | - (public) function fileExists() |
---|
37 | - (public) function makeCSS($css) |
---|
38 | - (public) function applyCSS() |
---|
39 | ---------------------------------------------------------------------- */ |
---|
40 | class GPCCss |
---|
41 | { |
---|
42 | private $filename; |
---|
43 | |
---|
44 | public function __construct($filename) |
---|
45 | { |
---|
46 | $this->filename=$filename; |
---|
47 | } |
---|
48 | |
---|
49 | public function __destruct() |
---|
50 | { |
---|
51 | unset($this->filename); |
---|
52 | } |
---|
53 | |
---|
54 | /* |
---|
55 | make the css file |
---|
56 | */ |
---|
57 | public function makeCSS($css) |
---|
58 | { |
---|
59 | if($css!="") |
---|
60 | { |
---|
61 | $handle=fopen($this->filename, "w"); |
---|
62 | if($handle) |
---|
63 | { |
---|
64 | fwrite($handle, $css); |
---|
65 | fclose($handle); |
---|
66 | } |
---|
67 | } |
---|
68 | } |
---|
69 | |
---|
70 | /* |
---|
71 | return true if css file exists |
---|
72 | */ |
---|
73 | public function fileExists() |
---|
74 | { |
---|
75 | return(file_exists($this->filename)); |
---|
76 | } |
---|
77 | |
---|
78 | /* |
---|
79 | put a link in the template to load the css file |
---|
80 | this function have to be called in a 'loc_end_page_header' trigger |
---|
81 | |
---|
82 | if $text="", insert link to css file, otherwise insert directly a <style> markup |
---|
83 | */ |
---|
84 | public function applyCSS() |
---|
85 | { |
---|
86 | global $template; |
---|
87 | |
---|
88 | if($this->fileExists()) |
---|
89 | { |
---|
90 | $template->append('head_elements', '<link rel="stylesheet" type="text/css" href="plugins/'.basename(dirname($this->filename))."/".basename($this->filename).'">'); |
---|
91 | } |
---|
92 | } |
---|
93 | } //class |
---|
94 | |
---|
95 | ?> |
---|