source: extensions/grum_plugins_classes-2/css.class.inc.php @ 16859

Last change on this file since 16859 was 3395, checked in by grum, 15 years ago

Add plugin Grum Plugins Class-2

  • Property svn:executable set to *
File size: 1.8 KB
RevLine 
[3395]1<?php
2
3/* -----------------------------------------------------------------------------
4  class name: css
5  class version: 2.0
6  date: 2008-07-13
7
8  ------------------------------------------------------------------------------
9  Author     : Grum
10    email    : grum@grum.dnsalias.com
11    website  : http://photos.grum.dnsalias.com
12    PWG user : http://forum.phpwebgallery.net/profile.php?id=3706
13
14    << May the Little SpaceFrog be with you ! >>
15  ------------------------------------------------------------------------------
16
17   this classes provides base functions to manage css
18    classe consider that $filename is under plugins/ directory
19
20
21    - constructor css($filename)
22    - (public) function css_file_exists()
23    - (public) function make_CSS($css)
24    - (public) function apply_CSS()
25   ---------------------------------------------------------------------- */
26class css
27{
28  private $filename;
29
30  public function css($filename)
31  {
32    $this->filename=$filename;
33  }
34
35  /*
36    make the css file
37  */
38  public function make_CSS($css)
39  {
40    if($css!="")
41    {
42      $handle=fopen($this->filename, "w");
43      if($handle)
44      {
45        fwrite($handle, $css);
46        fclose($handle);
47      }
48    }
49  }
50
51  /*
52    return true if css file exists
53  */
54  public function css_file_exists()
55  {
56    return(file_exists($this->filename));
57  }
58
59  /*
60    put a link in the template to load the css file
61    this function have to be called in a 'loc_end_page_header' trigger
62
63    if $text="", insert link to css file, otherwise insert directly a <style> markup
64  */
65  public function apply_CSS()
66  {
67    global $template;
68
69    if($this->css_file_exists())
70    {
71      $template->append('head_elements', '<link rel="stylesheet" type="text/css" href="plugins/'.basename(dirname($this->filename))."/".basename($this->filename).'">');
72    }
73  }
74} //class
75
76?>
Note: See TracBrowser for help on using the repository browser.