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

Last change on this file since 18621 was 17604, checked in by grum, 12 years ago

bug:2726

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