source: extensions/lmt/lmt_pip.class.inc.php @ 3396

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

Add plugin LMT

  • Property svn:executable set to *
File size: 6.1 KB
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : LMT
4  Author     : Grum
5    email    : grum@piwigo.org
6    website  : http://photos.grum.fr
7
8    << May the Little SpaceFrog be with you ! >>
9  ------------------------------------------------------------------------------
10  See main.inc.php for release information
11
12  LMT_PIP : classe to manage plugin public pages
13
14  --------------------------------------------------------------------------- */
15
16include_once('lmt_root.class.inc.php');
17include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/public_integration.class.inc.php');
18
19class LMT_PIP extends LMT_root
20{
21  protected $section_page;
22
23  public function LMT_PIP($prefixeTable, $filelocation)
24  {
25    parent::__construct($prefixeTable, $filelocation);
26    $this->load_config();
27
28    // don't create this object inside root classe otherwise header is modified
29    // everywhere in admin pages
30    $this->ajax = new Ajax();
31
32    $this->init_events();
33    $this->load_lang();
34  }
35
36  /*
37    load language file
38  */
39  public function load_lang()
40  {
41    global $lang;
42
43    load_language('plugin.lang', LMT_PATH);
44
45    // ajax is managed here ; this permit to use user&language properties inside
46    // ajax content
47    //$this->return_ajax_content();
48  }
49
50  /*
51    initialize events call for the plugin
52  */
53  public function init_events()
54  {
55    parent::init_events();
56/*
57    add_event_handler('blockmanager_apply', array(&$this, 'blockmanager_apply') );
58    add_event_handler('loading_lang', array(&$this, 'load_lang'));
59*/
60    if($this->my_config['lmt_licence_activated']=='y')
61    {
62      add_event_handler('loc_end_page_header', array(&$this->css_icn, 'apply_CSS'));
63      add_event_handler('loc_end_picture', array(&$this, 'manage_licence_element'));
64
65      if($this->my_config['lmt_warning_visible']=='y')
66      {
67        add_event_handler('loc_end_page_tail', array(&$this, 'manage_warning_text'));
68      }
69    }
70  }
71
72
73
74  /* -------------------------------------------------------------------------
75    FUNCTIONS TO MANAGE LMT DISPLAY
76  ------------------------------------------------------------------------- */
77  public function manage_licence_element()
78  {
79    global $template, $page, $user;
80
81    $licence=$this->get_image_licence($page['image_id']);
82    if($licence['licence']=="")
83    {
84      return("");
85    }
86
87    if($this->my_config['lmt_redirect_activated']=='y')
88    {
89      $url=$this->my_config['lmt_redirect_url-'.strToLower($licence['licence'])][$user['language']];
90      if($url=='')
91      {
92        $url=$this->my_config['lmt_redirect_url-'.strToLower($licence['licence'])]['en_UK'];
93      }     
94    }
95    else
96    {
97      $url="";
98    }
99
100    $style="";
101    $text="";
102    switch($this->my_config['lmt_licence_logo'])
103    {
104      case '80x15':
105        if($url!="")
106        {
107          $text = "<br/><a href='".$url."'><img class='logo80x15' src='". LMT_PATH."img/".strToLower($licence['licence'])."_80x15.png'></a>".$licence['aut_text1']." ".$licence['aut_text2'];
108        }
109        else
110        {
111          $text = "<br/><img class='logo80x15' src='". LMT_PATH."img/".strToLower($licence['licence'])."_80x15.png'>".$licence['aut_text1']." ".$licence['aut_text2'];
112        } 
113      break;
114      case '88x31';
115        $style=" style='text-align:left;'";
116        if($url!="")
117        {
118          $text = "<table style='margin:auto;'><tr><td><a href='".$url."'><img class='logo88x31' style='top:-4px;' src='". LMT_PATH."img/".strToLower($licence['licence'])."_88x31.png'></a></td><td>".$licence['aut_text1']."<br/>".$licence['aut_text2']."</td></tr></table>";
119        }
120        else
121        {
122          $text = "<table style='margin:auto;'><tr><td><img class='logo88x31' style='top:-4px;' src='". LMT_PATH."img/".strToLower($licence['licence'])."_88x31.png'></td><td>".$licence['aut_text1']."<br/>".$licence['aut_text2']."</td></tr></table>";
123        }
124        break;
125      case 'text';
126        if($url!="")
127        {
128          $text ="<br/>".l10n("lmt_lbl_under-".strToLower($licence['licence']))." <a href='".$url."'>".l10n("lmt_lbl_cc_s-".strToLower($licence['licence']))."</a> ".$licence['aut_text1']." ".$licence['aut_text2'];
129        }
130        else
131        {
132          $text ="<br/>".l10n("lmt_lbl_under-".strToLower($licence['licence']))." ".l10n("lmt_lbl_cc_s-".strToLower($licence['licence']))." ".$licence['aut_text1']." ".$licence['aut_text2'];
133        }
134        break;
135    }
136   
137    $template->concat('COMMENT_IMG', '<span class="licencetag" '.$style.'>'.$text.'</span>');
138  }
139
140  public function manage_warning_text()
141  {
142    global $template, $user;
143
144
145    if(isset($this->my_config['lmt_warning_texts'][$user['language']]))
146    {
147      $text=$this->my_config['lmt_warning_texts'][$user['language']];
148    }
149    else
150    {
151      $text=$this->my_config['lmt_warning_texts']['en_UK'];
152    }
153
154    $patterns = array('/\[logo=80x15\]/i', '/\[logo=88x31\]/i', '/\[logo=text\]/i');
155    $replacements = array(
156      "<img class='logo80x15' src='". LMT_PATH."img/".strToLower($this->my_config['lmt_licence_default'])."_80x15.png'>",
157      "<img class='logo88x31' src='". LMT_PATH."img/".strToLower($this->my_config['lmt_licence_default'])."_88x31.png'>",
158      l10n("lmt_lbl_cc_s-".strToLower($this->my_config['lmt_licence_default']))
159    );
160
161    if($this->my_config['lmt_redirect_activated']=='y')
162    {
163      $url=$this->my_config['lmt_redirect_url-'.strToLower($this->my_config['lmt_licence_default'])][$user['language']];
164      if($url=='')
165      {
166        $url=$this->my_config['lmt_redirect_url-'.strToLower($this->my_config['lmt_licence_default'])]['en_UK'];
167      }
168      if($url!="")
169      {
170        $replacements[0]="<a href='".$url."'>".$replacements[0]."</a>";
171        $replacements[1]="<a href='".$url."'>".$replacements[1]."</a>";
172        $replacements[2]="<a href='".$url."'>".$replacements[2]."</a>";
173      }
174    }
175
176    $text = preg_replace($patterns, $replacements, $text);
177
178    $template->append("footer_elements", "<span>".htmlspecialchars_decode($text)."</span>");
179  }
180
181
182  /* ---------------------------------------------------------------------------
183    ajax functions
184  --------------------------------------------------------------------------- */
185
186} //class
187
188?>
Note: See TracBrowser for help on using the repository browser.