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

Last change on this file since 17267 was 16014, checked in by grum, 12 years ago

feature:2641- compatibility with Piwigo 2.4

  • Property svn:executable set to *
File size: 6.7 KB
RevLine 
[3396]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');
[5548]17//include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCPublicIntegration.class.inc.php');
[3396]18
[7560]19load_language('plugin.lang', LMT_PATH);
20
[3396]21class LMT_PIP extends LMT_root
22{
23  protected $section_page;
24
[5548]25  public function __construct($prefixeTable, $filelocation)
[3396]26  {
27    parent::__construct($prefixeTable, $filelocation);
[5548]28    $this->loadConfig();
[3396]29
[5548]30    $this->initEvents();
[3396]31  }
32
[5548]33  public function __destruct()
34  {
35    unset($section_page);
36    parent::__destruct();
37  }
38
[7560]39  /**
40   * initialize events call for the plugin
41   */
[5548]42  public function initEvents()
[3396]43  {
[5548]44    parent::initEvents();
[7560]45
[5548]46    if($this->config['lmt_licence_activated']=='y')
[3396]47    {
[7560]48      add_event_handler('loc_end_picture', array(&$this, 'manageLicenceElement'));
[3396]49
[5548]50      if($this->config['lmt_warning_visible']=='y')
[3396]51      {
[7560]52        add_event_handler('loc_end_page_tail', array(&$this, 'manageWarningText'));
[3396]53      }
54    }
55  }
56
[16014]57  public function loadCSS()
58  {
59    //parent::loadCSS();  -- don't call the ancestor!
60    GPCCore::addHeaderCSS('lmt_icn.css', 'plugins/'.$this->getDirectory().'/'.$this->getPluginNameFiles()."_icn.css");
61  }
[3396]62
63  /* -------------------------------------------------------------------------
64    FUNCTIONS TO MANAGE LMT DISPLAY
65  ------------------------------------------------------------------------- */
[7560]66  public function manageLicenceElement()
[3396]67  {
68    global $template, $page, $user;
69
[7560]70    $licence=$this->getImageLicence($page['image_id']);
[3396]71    if($licence['licence']=="")
72    {
73      return("");
74    }
75
[5548]76    if($this->config['lmt_redirect_activated']=='y')
[3396]77    {
[5548]78      $url=$this->config['lmt_redirect_url-'.strToLower($licence['licence'])][$user['language']];
[3396]79      if($url=='')
80      {
[5548]81        $url=$this->config['lmt_redirect_url-'.strToLower($licence['licence'])]['en_UK'];
[4396]82      }
[3396]83    }
84    else
85    {
86      $url="";
87    }
88
[6701]89    $alternateText=" alt='".htmlspecialchars(l10n('lmt_lbl_cc_s-'.strtolower($licence['licence'])), ENT_QUOTES)."'
90      title='".htmlspecialchars(
91        l10n('lmt_lbl_under-'.strtolower($licence['licence'])).' '.
92        l10n('lmt_lbl_cc_s-'.strtolower($licence['licence'])).' : '.
93        l10n('lmt_lbl_cc-'.strtolower($licence['licence'])),ENT_QUOTES
94    )."' ";
95
[3396]96    $style="";
97    $text="";
[5548]98    $target=($this->config['lmt_redirect_open_target']=="y")?" onclick='window.open(this.href); return false;'":"";
99    switch($this->config['lmt_licence_logo'])
[3396]100    {
101      case '80x15':
102        if($url!="")
103        {
[6701]104          $text = "<br/><a href='".$url."'".$target."><img $alternateText class='logo80x15' src='". LMT_PATH."img/".strToLower($licence['licence'])."_80x15.png'></a>".$licence['aut_text1']." ".$licence['aut_text2'];
[3396]105        }
106        else
107        {
[6701]108          $text = "<br/><img $alternateText class='logo80x15' src='". LMT_PATH."img/".strToLower($licence['licence'])."_80x15.png'>".$licence['aut_text1']." ".$licence['aut_text2'];
[4396]109        }
[3396]110      break;
111      case '88x31';
112        $style=" style='text-align:left;'";
113        if($url!="")
114        {
[16014]115          $text = "<table style='margin:auto;'><tr><td><a href='".$url."'".$target."><img $alternateText class='logo88x31' src='". LMT_PATH."img/".strToLower($licence['licence'])."_88x31.png'></a></td><td>".$licence['aut_text1']."<br/>".$licence['aut_text2']."</td></tr></table>";
[3396]116        }
117        else
118        {
[16014]119          $text = "<table style='margin:auto;'><tr><td><img $alternateText class='logo88x31' src='". LMT_PATH."img/".strToLower($licence['licence'])."_88x31.png'></td><td>".$licence['aut_text1']."<br/>".$licence['aut_text2']."</td></tr></table>";
[3396]120        }
121        break;
122      case 'text';
123        if($url!="")
124        {
[4396]125          $text ="<br/>".l10n("lmt_lbl_under-".strToLower($licence['licence']))." <a href='".$url."'".$target.">".l10n("lmt_lbl_cc_s-".strToLower($licence['licence']))."</a> ".$licence['aut_text1']." ".$licence['aut_text2'];
[3396]126        }
127        else
128        {
129          $text ="<br/>".l10n("lmt_lbl_under-".strToLower($licence['licence']))." ".l10n("lmt_lbl_cc_s-".strToLower($licence['licence']))." ".$licence['aut_text1']." ".$licence['aut_text2'];
130        }
131        break;
132    }
[4396]133
[3396]134    $template->concat('COMMENT_IMG', '<span class="licencetag" '.$style.'>'.$text.'</span>');
135  }
136
[7560]137  public function manageWarningText()
[3396]138  {
139    global $template, $user;
140
141
[5548]142    if(isset($this->config['lmt_warning_texts'][$user['language']]))
[3396]143    {
[5548]144      $text=$this->config['lmt_warning_texts'][$user['language']];
[3396]145    }
146    else
147    {
[5548]148      $text=$this->config['lmt_warning_texts']['en_UK'];
[3396]149    }
150
[6701]151    $alternateText=" alt='".htmlspecialchars(l10n('lmt_lbl_cc_s-'.strtolower($this->config['lmt_licence_default'])), ENT_QUOTES)."'
152      title='".htmlspecialchars(
153        l10n('lmt_lbl_under-'.strtolower($this->config['lmt_licence_default'])).' '.
154        l10n('lmt_lbl_cc_s-'.strtolower($this->config['lmt_licence_default'])).' : '.
155        l10n('lmt_lbl_cc-'.strtolower($this->config['lmt_licence_default'])),ENT_QUOTES
156    )."' ";
157
[3396]158    $patterns = array('/\[logo=80x15\]/i', '/\[logo=88x31\]/i', '/\[logo=text\]/i');
159    $replacements = array(
[6701]160      "<img $alternateText class='logo80x15' src='". LMT_PATH."img/".strToLower($this->config['lmt_licence_default'])."_80x15.png'>",
161      "<img $alternateText class='logo88x31' src='". LMT_PATH."img/".strToLower($this->config['lmt_licence_default'])."_88x31.png'>",
[5548]162      l10n("lmt_lbl_cc_s-".strToLower($this->config['lmt_licence_default']))
[3396]163    );
164
[5548]165    if($this->config['lmt_redirect_activated']=='y')
[3396]166    {
[5548]167      $url=$this->config['lmt_redirect_url-'.strToLower($this->config['lmt_licence_default'])][$user['language']];
[3396]168      if($url=='')
169      {
[5548]170        $url=$this->config['lmt_redirect_url-'.strToLower($this->config['lmt_licence_default'])]['en_UK'];
[3396]171      }
172      if($url!="")
173      {
[5548]174        $target=($this->config['lmt_redirect_open_target']=="y")?" onclick='window.open(this.href); return false;'":"";
[4396]175        $replacements[0]="<a href='".$url."'".$target.">".$replacements[0]."</a>";
176        $replacements[1]="<a href='".$url."'".$target.">".$replacements[1]."</a>";
177        $replacements[2]="<a href='".$url."'".$target.">".$replacements[2]."</a>";
[3396]178      }
179    }
180
181    $text = preg_replace($patterns, $replacements, $text);
182
183    $template->append("footer_elements", "<span>".htmlspecialchars_decode($text)."</span>");
184  }
185
186
187} //class
188
189?>
Note: See TracBrowser for help on using the repository browser.