Ignore:
Timestamp:
May 7, 2010, 10:23:47 PM (14 years ago)
Author:
grum
Message:

Plugin is now in a usable state (color analysis is not yet tuned)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/ColorStat/cstat_pip.class.inc.php

    r5961 r6107  
    11<?php
    22/* -----------------------------------------------------------------------------
    3   Plugin     : LMT
     3  Plugin     : ColorStat
    44  Author     : Grum
    55    email    : grum@piwigo.org
     
    1010  See main.inc.php for release information
    1111
    12   LMT_PIP : classe to manage plugin public pages
     12  CStat_PIP : classe to manage plugin public pages
    1313
    1414  --------------------------------------------------------------------------- */
    1515
    16 include_once('lmt_root.class.inc.php');
     16include_once('cstat_root.class.inc.php');
    1717//include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCPublicIntegration.class.inc.php');
    1818
    19 class LMT_PIP extends LMT_root
     19class CStat_PIP extends CStat_root
    2020{
    2121  protected $section_page;
     
    3636  }
    3737
    38   /*
    39     load language file
    40   */
     38  /**
     39   * load language file
     40   */
    4141  public function load_lang()
    4242  {
    4343    global $lang;
    4444
    45     load_language('plugin.lang', LMT_PATH);
    46 
    47     // ajax is managed here ; this permit to use user&language properties inside
    48     // ajax content
    49     //$this->return_ajax_content();
     45    load_language('plugin.lang', CSTAT_PATH);
    5046  }
    5147
    52   /*
    53     initialize events call for the plugin
    54   */
     48  /**
     49   * initialize events call for the plugin
     50   */
    5551  public function initEvents()
    5652  {
    5753    parent::initEvents();
    58 /*
    59     add_event_handler('blockmanager_apply', array(&$this, 'blockmanager_apply') );
    60     add_event_handler('loading_lang', array(&$this, 'load_lang'));
    61 */
    62     if($this->config['lmt_licence_activated']=='y')
     54
     55    if($this->config['display_gallery_showColors']=='y')
    6356    {
    64       add_event_handler('loc_end_page_header', array(&$this->css_icn, 'applyCSS'));
    65       add_event_handler('loc_end_picture', array(&$this, 'manage_licence_element'));
    66 
    67       if($this->config['lmt_warning_visible']=='y')
    68       {
    69         add_event_handler('loc_end_page_tail', array(&$this, 'manage_warning_text'));
    70       }
     57      add_event_handler('loc_begin_picture', array(&$this, 'addColors'));
    7158    }
    7259  }
     
    7562
    7663  /* -------------------------------------------------------------------------
    77     FUNCTIONS TO MANAGE LMT DISPLAY
     64    FUNCTIONS TO MANAGE COLORS DISPLAY
    7865  ------------------------------------------------------------------------- */
    79   public function manage_licence_element()
     66  public function addColors()
    8067  {
    81     global $template, $page, $user;
     68    global $page, $template;
    8269
    83     $licence=$this->get_image_licence($page['image_id']);
    84     if($licence['licence']=="")
     70    $colors=$this->getImageColors($page['image_id']);
     71
     72
     73    if(count($colors['colors'])>0)
    8574    {
    86       return("");
     75      $metadata=$template->get_template_vars('metadata');
     76
     77      $tmp=Array();
     78
     79      for($i=0;$i<count($colors['colors']);$i++)
     80      {
     81        $tmp[$colors['colors'][$i]]['pct']=$colors['colors_pct'][$i];
     82      }
     83
     84      $colorsNfo=Array(
     85        'TITLE' => l10n('cstat_colors'),
     86        'lines' => Array(
     87          l10n('cstat_colors_on_image') => $this->htmlColorList($tmp, 8, 25, "", "color1px", "/"),
     88        )
     89      );
     90
     91      $metadata[]=$colorsNfo;
     92
     93      $template->assign('metadata', $metadata);
    8794    }
    88 
    89     if($this->config['lmt_redirect_activated']=='y')
    90     {
    91       $url=$this->config['lmt_redirect_url-'.strToLower($licence['licence'])][$user['language']];
    92       if($url=='')
    93       {
    94         $url=$this->config['lmt_redirect_url-'.strToLower($licence['licence'])]['en_UK'];
    95       }
    96     }
    97     else
    98     {
    99       $url="";
    100     }
    101 
    102     $style="";
    103     $text="";
    104     $target=($this->config['lmt_redirect_open_target']=="y")?" onclick='window.open(this.href); return false;'":"";
    105     switch($this->config['lmt_licence_logo'])
    106     {
    107       case '80x15':
    108         if($url!="")
    109         {
    110           $text = "<br/><a href='".$url."'".$target."><img class='logo80x15' src='". LMT_PATH."img/".strToLower($licence['licence'])."_80x15.png'></a>".$licence['aut_text1']." ".$licence['aut_text2'];
    111         }
    112         else
    113         {
    114           $text = "<br/><img class='logo80x15' src='". LMT_PATH."img/".strToLower($licence['licence'])."_80x15.png'>".$licence['aut_text1']." ".$licence['aut_text2'];
    115         }
    116       break;
    117       case '88x31';
    118         $style=" style='text-align:left;'";
    119         if($url!="")
    120         {
    121           $text = "<table style='margin:auto;'><tr><td><a href='".$url."'".$target."><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>";
    122         }
    123         else
    124         {
    125           $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>";
    126         }
    127         break;
    128       case 'text';
    129         if($url!="")
    130         {
    131           $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'];
    132         }
    133         else
    134         {
    135           $text ="<br/>".l10n("lmt_lbl_under-".strToLower($licence['licence']))." ".l10n("lmt_lbl_cc_s-".strToLower($licence['licence']))." ".$licence['aut_text1']." ".$licence['aut_text2'];
    136         }
    137         break;
    138     }
    139 
    140     $template->concat('COMMENT_IMG', '<span class="licencetag" '.$style.'>'.$text.'</span>');
    14195  }
    14296
    143   public function manage_warning_text()
    144   {
    145     global $template, $user;
    146 
    147 
    148     if(isset($this->config['lmt_warning_texts'][$user['language']]))
    149     {
    150       $text=$this->config['lmt_warning_texts'][$user['language']];
    151     }
    152     else
    153     {
    154       $text=$this->config['lmt_warning_texts']['en_UK'];
    155     }
    156 
    157     $patterns = array('/\[logo=80x15\]/i', '/\[logo=88x31\]/i', '/\[logo=text\]/i');
    158     $replacements = array(
    159       "<img class='logo80x15' src='". LMT_PATH."img/".strToLower($this->config['lmt_licence_default'])."_80x15.png'>",
    160       "<img class='logo88x31' src='". LMT_PATH."img/".strToLower($this->config['lmt_licence_default'])."_88x31.png'>",
    161       l10n("lmt_lbl_cc_s-".strToLower($this->config['lmt_licence_default']))
    162     );
    163 
    164     if($this->config['lmt_redirect_activated']=='y')
    165     {
    166       $url=$this->config['lmt_redirect_url-'.strToLower($this->config['lmt_licence_default'])][$user['language']];
    167       if($url=='')
    168       {
    169         $url=$this->config['lmt_redirect_url-'.strToLower($this->config['lmt_licence_default'])]['en_UK'];
    170       }
    171       if($url!="")
    172       {
    173         $target=($this->config['lmt_redirect_open_target']=="y")?" onclick='window.open(this.href); return false;'":"";
    174         $replacements[0]="<a href='".$url."'".$target.">".$replacements[0]."</a>";
    175         $replacements[1]="<a href='".$url."'".$target.">".$replacements[1]."</a>";
    176         $replacements[2]="<a href='".$url."'".$target.">".$replacements[2]."</a>";
    177       }
    178     }
    179 
    180     $text = preg_replace($patterns, $replacements, $text);
    181 
    182     $template->append("footer_elements", "<span>".htmlspecialchars_decode($text)."</span>");
    183   }
    18497
    18598
Note: See TracChangeset for help on using the changeset viewer.