source: extensions/GrumPluginClasses/classes/GPCCss.class.inc.php @ 15352

Revision 15352, 2.9 KB checked in by grum, 8 years ago (diff)

feature:2634 - Compatibility with Piwigo 2.4
fix some RBuilder css

  • Property svn:executable set to *
Line 
1<?php
2
3/* -----------------------------------------------------------------------------
4  class name: GPCCss
5  class version  : 3.1.0
6  plugin version : 3.5.0
7  date           : 2011-01-31
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| 3.1.0   | 2011/01/31 | * Updated for piwigo 2.2
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   ---------------------------------------------------------------------- */
40class GPCCss
41{
42  private $filename;
43  private $order;
44
45  static public function applyGpcCss()
46  {
47    add_event_handler('loc_end_page_header', array('GPCCss', 'applyCSSFile'));
48  }
49
50  static public function applyCSSFile($fileName="", $order=25)
51  {
52    global $template;
53
54    if($fileName=="")
55    {
56      //if no filename given, load the gpc.css file
57      $fileName='./plugins/'.basename(dirname(dirname(__FILE__))).'/css/gpc';
58      GPCCore::addHeaderCSS('gpc', $fileName.'.css', 10);
59      GPCCore::addHeaderCSS('gpc_theme', $fileName.'_'.$template->get_themeconf('name').'.css', 15);
60    }
61    elseif(file_exists($fileName))
62    {
63      GPCCore::addHeaderCSS(basename(dirname($fileName)), 'plugins/'.basename(dirname($fileName)).'/'.basename($fileName).'', $order);
64    }
65  }
66
67  public function __construct($filename, $order=25)
68  {
69    $this->filename=$filename;
70    $this->order=$order;
71  }
72
73  public function __destruct()
74  {
75    unset($this->filename);
76  }
77
78  /*
79    make the css file
80  */
81  public function makeCSS($css)
82  {
83    if($css!="")
84    {
85      $handle=fopen($this->filename, "w");
86      if($handle)
87      {
88        fwrite($handle, $css);
89        fclose($handle);
90      }
91    }
92  }
93
94  /*
95    return true if css file exists
96  */
97  public function fileExists()
98  {
99    return(file_exists($this->filename));
100  }
101
102  /*
103    put a link in the template to load the css file
104    this function have to be called in a 'loc_end_page_header' trigger
105
106    if $text="", insert link to css file, otherwise insert directly a <style> markup
107  */
108  public function applyCSS()
109  {
110    global $template;
111
112    GPCCss::applyCSSFile($this->filename, $this->order);
113  }
114
115
116} //class
117
118?>
Note: See TracBrowser for help on using the repository browser.