Changeset 7560


Ignore:
Timestamp:
Nov 1, 2010, 10:51:58 PM (10 years ago)
Author:
grum
Message:

fix bug:1487 - LMT image not displayed with IE8
implement feature:1689 - Add possibility to search picture by licence

Location:
extensions/lmt
Files:
5 added
15 edited

Legend:

Unmodified
Added
Removed
  • extensions/lmt/admin/plugin_admin.php

    r5548 r7560  
    1414if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
    1515
    16 include(LMT_PATH."lmt_aip.class.inc.php");
     16global $prefixeTable;
    1717
    18 global $prefixeTable;
    1918
    2019load_language('plugin.lang', LMT_PATH);
     
    2221$main_plugin_object = get_plugin_data($plugin_id);
    2322
    24 $plugin_aip = new LMT_AIP($prefixeTable, $main_plugin_object->getFileLocation());
     23
     24if(CommonPlugin::checkGPCRelease(LMT_GPC_NEEDED))
     25{
     26  $config=Array();
     27  GPCCore::loadConfig('lmt', $config);
     28
     29
     30  if($config['installed']!=LMT_VERSION2)
     31  {
     32    /* the plugin was updated without being deactivated
     33     * deactivate + activate the plugin to process the database upgrade
     34     */
     35    include(LMT_PATH."lmt_install.class.inc.php");
     36    $obj=new LMT_Install($prefixeTable, dirname(__FILE__));
     37    $obj->deactivate();
     38    $obj->activate();
     39    $template->delete_compiled_templates();
     40    //$config['newInstall']='n';
     41  }
     42
     43  include(LMT_PATH."lmt_aip.class.inc.php");
     44  $plugin_aip = new LMT_AIP($prefixeTable, $main_plugin_object->getFileLocation());
     45}
     46else
     47{
     48  /*
     49   * plugin was upgraded, but GPC was not
     50   * display a page to inform user to upgrade GPC
     51   */
     52  include(LMT_PATH."lmt_aip_release.class.inc.php");
     53  $plugin_aip = new LMT_AIPRelease($prefixeTable, $main_plugin_object->getFileLocation());
     54}
     55
     56
     57
     58
    2559$plugin_aip->manage();
     60
    2661?>
  • extensions/lmt/admin/plugin_admin_list.tpl

    r6701 r7560  
    33  function loadpage(pagenum)
    44  {
    5     $("#list").html("<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>");
     5    $("#list").html("<div style='margin:20px auto;text-align:center;'><img src='./plugins/GrumPluginClasses/icons/processing.gif'></div>");
    66
    77    $.ajax(
    88      {
    99        type: "POST",
    10         datas:
     10        data:
    1111          {
     12            ajaxfct:'admin.img.list',
     13            numPage:pagenum,
    1214            filter:$("#filter").val()
    1315          },
    14         url: "{/literal}{$datas.LMT_AJAX_URL_LIST}{literal}"+pagenum,
     16        url: "{/literal}{$datas.LMT_AJAX_URL_LIST}{literal}",
    1517        async: true,
    1618        success: function(msg)
  • extensions/lmt/admin/plugin_admin_manage.tpl

    r6701 r7560  
    1010  function loadpage(pagenum)
    1111  {
    12     $("#list").html("<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>");
     12    $("#list").html("<div style='margin:20px auto;text-align:center;'><img src='./plugins/GrumPluginClasses/icons/processing.gif'></div>");
    1313
    1414    $.ajax(
    1515      {
    1616        type: "POST",
    17         url: "{/literal}{$datas.LMT_AJAX_URL_LIST}{literal}"+pagenum,
     17        data:
     18          {
     19            ajaxfct:'admin.manage.list',
     20            numPage:pagenum
     21          },
     22        url: "{/literal}{$datas.LMT_AJAX_URL_LIST}{literal}",
    1823        async: true,
    1924        success: function (msg)
  • extensions/lmt/admin/plugin_admin_manageaut.tpl

    r3396 r7560  
    44
    55  function init() {
    6     $("tr").filter(".TableRow").bind("mouseover",
     6    $("tr").filter(".TableRow_{/literal}{$themeconf.name}{literal}").bind("mouseover",
    77      function (event) {
    88        {/literal}
     
    1616        {literal}
    1717        $("#iexample").attr("innerHTML", txt);
    18       }     
     18      }
    1919    );
    2020
    21     $("tr").filter(".TableRow").bind("mouseout",
     21    $("tr").filter(".TableRow_{/literal}{$themeconf.name}{literal}").bind("mouseout",
    2222      function (event) {
    2323       // $("#iexample").attr("innerHTML", "");
    24       }     
     24      }
    2525    );
    2626  }
     
    5252    </tr>
    5353    {foreach from=$datas.author_list key=name item=data}
    54       <tr class="TableRow">
     54      <tr class="TableRow_{$themeconf.name}">
    5555        <td>{$data.id}</td>
    5656        <td>{$data.text1}</td>
  • extensions/lmt/language/de_DE/plugin.lang.php

    r5872 r7560  
    156156
    157157
     158/*
     159 * need to be translated
     160 *
     161 * thanks ! :-)
     162 */
     163
     164// 1.2.0
     165$lang['To install this plugin, you need to install Grum Plugin Classes %s before'] = 'To install this plugin, you need to install Grum Plugin Classes %s before';
     166
     167// 1.3.0
     168$lang['lmt_add_licence_type'] = "Add a licence type";
     169$lang['lmt_choose_licence_type'] = "Choose licence type";
     170$lang['lmt_search'] = "Search";
     171$lang['lmt_search_by_licence'] = "Search photos under licence";
     172$lang['lmt_licence_type']="Licence type";
     173$lang['lmt_ok']="Ok";
     174$lang['lmt_search_pictures_with_licence_1']="Search photos under licence:";
     175$lang['lmt_search_pictures_with_licence_n']="Search photos under one of theses licences:";
     176$lang['lmt_error_num_items']="At least, one licence must be selected";
     177
     178
     179
    158180?>
  • extensions/lmt/language/en_UK/plugin.lang.php

    r6701 r7560  
    11<?php
    2 
    3 /* -----------------------------------------------------------------------------
    4   This file was created by 'Translator r2.0.0-beta' plugin
    5 
    6   **** Export informations
    7   Export date       : 2009-04-30 22:59:49
    8   Number of items   : 149
    9     Number exported : 149
    10   Exported by       : grum
    11 
    12   **** File informations
    13   Language          : English [ISO en_UK]
    14   Charset           : utf-8
    15   Type              : plugin
    16   Name (Release)    : lmt (2.0.0-beta)
    17 
    18   **** Export options
    19   Items exported    : "ok"
    20   Translator export : NO
    21 ----------------------------------------------------------------------------- */
    22 
    232
    243$lang['example'] = 'Display sample';
     
    176155$lang["lmt_cfg_warning_target"] = "Force the page openning in a new window";
    177156
     157// 1.2.0
     158$lang['To install this plugin, you need to install Grum Plugin Classes %s before'] = 'To install this plugin, you need to install Grum Plugin Classes %s before';
     159
     160// 1.3.0
     161$lang['lmt_add_licence_type'] = "Add a licence type";
     162$lang['lmt_choose_licence_type'] = "Choose licence type";
     163$lang['lmt_search'] = "Search";
     164$lang['lmt_search_by_licence'] = "Search photos under licence";
     165$lang['lmt_licence_type']="Licence type";
     166$lang['lmt_ok']="Ok";
     167$lang['lmt_search_pictures_with_licence_1']="Search photos under licence:";
     168$lang['lmt_search_pictures_with_licence_n']="Search photos under one of theses licences:";
     169$lang['lmt_error_num_items']="At least, one licence must be selected";
    178170
    179171?>
  • extensions/lmt/language/es_ES/plugin.lang.php

    r6701 r7560  
    182182$lang["lmt_cfg_warning_target"] = "Forzar la apertura en una nueva ventana"
    183183
    184 
     184/*
     185 * need to be translated
     186 *
     187 * thanks ! :-)
     188 */
     189
     190// 1.2.0
     191$lang['To install this plugin, you need to install Grum Plugin Classes %s before'] = 'To install this plugin, you need to install Grum Plugin Classes %s before';
     192
     193// 1.3.0
     194$lang['lmt_add_licence_type'] = "Add a licence type";
     195$lang['lmt_choose_licence_type'] = "Choose licence type";
     196$lang['lmt_search'] = "Search";
     197$lang['lmt_search_by_licence'] = "Search photos under licence";
     198$lang['lmt_licence_type']="Licence type";
     199$lang['lmt_ok']="Ok";
     200$lang['lmt_search_pictures_with_licence_1']="Search photos under licence:";
     201$lang['lmt_search_pictures_with_licence_n']="Search photos under one of theses licences:";
     202$lang['lmt_error_num_items']="At least, one licence must be selected";
    185203
    186204?>
  • extensions/lmt/language/fr_FR/plugin.lang.php

    r5548 r7560  
    186186
    187187
     188// 1.3.0
     189$lang['lmt_add_licence_type'] = "Ajouter un type de licence";
     190$lang['lmt_choose_licence_type'] = "Sélectionner le type de licence";
     191$lang['lmt_search'] = "Rechercher";
     192$lang['lmt_search_by_licence'] = "Rechercher des photos en fonction de leur licence";
     193$lang['lmt_licence_type']="Type de licence";
     194$lang['lmt_ok']="Ok";
     195$lang['lmt_search_pictures_with_licence_1']="Rechercher les photos sous licence :";
     196$lang['lmt_search_pictures_with_licence_n']="Rechercher les photos sous l'une des licences suivantes :";
     197$lang['lmt_error_num_items']="Au moins une licence doit être sélectionnée";
     198
    188199?>
  • extensions/lmt/lmt_aip.class.inc.php

    r6703 r7560  
    1717include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTranslate.class.inc.php');
    1818include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php');
     19include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php');
    1920include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/genericjs.class.inc.php');
    20 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCPagesNavigation.class.inc.php');
    2121include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
    2222
    2323class LMT_AIP extends LMT_root
    2424{
    25   protected $google_translate;
    2625  protected $tabsheet;
    2726
     
    4241                          l10n('lmt_manageaut'),
    4342                          $this->getAdminLink()."&amp;f_tabsheet=manageaut");
     43    $this->tabsheet->add('search',
     44                          l10n('lmt_search'),
     45                          $this->getAdminLink()."&amp;f_tabsheet=search");
    4446    $this->tabsheet->add('config',
    4547                          l10n('lmt_config'),
     
    4850                          l10n('lmt_help'),
    4951                          $this->getAdminLink()."&amp;f_tabsheet=help");
    50 
    51 
    52     // don't create the google_translate object everytime, otherwise google's js
    53     // code is always included in the header even if translation functionalities
    54     // aren't needed
    55     // translation is needed only if we are in a ajax request
    56     /*if((isset($_POST['fmypolls_gomodify_translation'])||isset($_POST['fmypolls_goadd_translation'])))
    57     {
    58       $this->google_translate = new GPCTranslate();
    59     }
    60     */
    6152  }
    6253
    6354  public function __destruct()
    6455  {
    65     unset($this->google_translate);
    6656    unset($this->tabsheet);
    6757    parent::__destruct();
     
    7464  {
    7565    parent::initEvents();
     66
     67    if(isset($_REQUEST['f_tabsheet']) and $_REQUEST['f_tabsheet']=='search')
     68    {
     69      // load request builder JS only on the search page
     70      GPCRequestBuilder::loadJSandCSS();
     71    }
     72
    7673    add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS'));
    7774    add_event_handler('loc_end_page_header', array(&$this->css_icn, 'applyCSS'));
     75
     76    GPCCss::applyGpcCss();
    7877  }
    7978
     
    8483  {
    8584    global $template;
    86 
    87     $this->return_ajax_content();
    8885
    8986    $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/lmt_admin.tpl");
     
    108105        $this->display_managedoc_page();
    109106        break;
     107      case 'search':
     108        $this->displaySearch();
     109        break;
    110110      case 'help':
    111111        $this->display_help_page();
     
    127127    $template->assign('plugin', $template_plugin);
    128128    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
    129   }
    130 
    131 
    132   /*
    133     return ajax content
    134   */
    135   protected function return_ajax_content()
    136   {
    137     global $ajax, $template;
    138 
    139     if(isset($_REQUEST['ajaxfct']))
    140     {
    141       //$this->debug("AJAXFCT:".$_REQUEST['ajaxfct']);
    142       $result="<p class='errors'>An error has occured</p>";
    143       switch($_REQUEST['ajaxfct'])
    144       {
    145         case 'img_list':
    146           $result=$this->ajax_img_list($_REQUEST['numpage']);
    147           break;
    148         case 'manage_list':
    149           $result=$this->ajax_manage_list($_REQUEST['numpage']);
    150           break;
    151       }
    152       GPCAjax::returnResult($result);
    153     }
    154129  }
    155130
     
    233208
    234209    $datas=array(
    235       "LMT_AJAX_URL_LIST" =>  $this->getAdminLink().'&ajaxfct=img_list&numpage='
     210      "LMT_AJAX_URL_LIST" =>  $this->getAdminLink('ajax')
    236211    );
    237212
    238213    $filter_list_selected = '';
    239     $filter_list_values = array_slice($this->licences,0,count($this->licences)-1);
     214    $filter_list_values = array_slice(LMT_root::$licences,0,count(LMT_root::$licences)-1);
    240215    $filter_list_labels = array();
    241216    foreach($filter_list_values as $key=>$val)
     
    369344
    370345    $datas=array(
    371       "LMT_AJAX_URL_LIST" =>  $this->getAdminLink().'&ajaxfct=manage_list&numpage='
     346      "LMT_AJAX_URL_LIST" =>  $this->getAdminLink('ajax')
    372347    );
    373348
     
    395370
    396371    $licences_list_values = array();
    397     $licences_list_values = $this->licences;
     372    $licences_list_values = self::$licences;
    398373    $licences_list_labels = array();
    399374    foreach($licences_list_values as $key=>$val)
     
    459434
    460435    $datas['lmt_redirect_urls']=array();
    461     $lmt_licence_default_values = array_slice($this->licences,0,count($this->licences)-1);
     436    $lmt_licence_default_values = array_slice(self::$licences,0,count(self::$licences)-1);
    462437    $lmt_licence_default_labels = array();
    463438
     
    540515
    541516
     517  /**
     518   * display the search page
     519   *
     520   */
     521  protected function displaySearch()
     522  {
     523    global $template;
     524
     525    $template->set_filename('body_page',
     526                dirname($this->getFileLocation()).'/admin/lmt_search.tpl');
     527
     528    $template->assign('lmt_search_page', GPCRequestBuilder::displaySearchPage($this->getPluginName()));
     529
     530    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
     531  }
     532
     533
    542534
    543535  /*
     
    555547      $_REQUEST['id']="";
    556548    }
    557 
    558549
    559550    /* ------------------------------------------------------------------------
     
    780771                  dirname($this->getFileLocation()).'/admin/lmt_js.tpl');
    781772
    782     $lmt_licence_default_values=array_slice($this->licences,0,count($this->licences)-1);
     773    $lmt_licence_default_values=array_slice(self::$licences,0,count(self::$licences)-1);
    783774    $datas['shortlicencetext']=array();
    784775    foreach($lmt_licence_default_values as $key=>$val)
     
    795786  }
    796787
    797   protected function make_image_data($tmp, $imageId)
    798   {
    799     $tmp2=array();
    800     foreach($tmp['id'] as $key=>$val)
    801     {
    802       $tmp2[]=array(
    803         'id' => $tmp['id'][$key],
    804         'name' => $tmp['name'][$key],
    805         'type' => $tmp['type'][$key],
    806         'plinks' => $tmp['plinks'][$key],
    807         'link'=> make_picture_url(
    808                   array(
    809                     'image_id' => $imageId,
    810                     'category' => array
    811                       (
    812                         'id' => $tmp['id'][$key],
    813                         'name' => $tmp['name'][$key],
    814                         'permalink' => $tmp['plinks'][$key]
    815                       )
    816                   )
    817                 )
    818       );
    819     }
    820     return($tmp2);
    821   }
    822788
    823789  /* ---------------------------------------------------------------------------
     
    826792
    827793
    828 
    829 
    830 
    831   /* ---------------------------------------------------------------------------
    832     ajax functions
    833   --------------------------------------------------------------------------- */
    834 
    835   protected function ajax_img_list($pagenum)
    836   {
    837     global $conf;
    838 
    839     $local_tpl = new Template(LMT_PATH."admin/", "");
    840     $local_tpl->set_filename('body_page',
    841                   dirname($this->getFileLocation()).'/admin/plugin_admin_listitems.tpl');
    842 
    843     if(!isset($_REQUEST['filter']) ||
    844        !($_REQUEST['filter']=="BY" ||
    845          $_REQUEST['filter']=="BY-SA" ||
    846          $_REQUEST['filter']=="BY-ND" ||
    847          $_REQUEST['filter']=="BY-NC-ND" ||
    848          $_REQUEST['filter']=="BY-NC-SA" ||
    849          $_REQUEST['filter']=="BY-NC" ||
    850          $_REQUEST['filter']=="CRIGHT" ||
    851          $_REQUEST['filter']=="CLEFT"
    852       ))
    853     {
    854       $_REQUEST['filter']='';
    855     }
    856 
    857     $img_ids=array();
    858     $img_liste = array();
    859     $sql="SELECT SQL_CALC_FOUND_ROWS lmti.*, img.file, img.path, img.tn_ext,
    860                   GROUP_CONCAT(cat.id) AS catid,
    861                   GROUP_CONCAT(CASE WHEN cat.name IS NULL THEN '' ELSE cat.name END SEPARATOR '@sep@') AS catname,
    862                   GROUP_CONCAT(CASE WHEN cat.permalink IS NULL THEN '' ELSE cat.permalink END SEPARATOR '@sep@') AS catpermalink,
    863                   GROUP_CONCAT(CASE WHEN cat.dir IS NULL THEN 'V' ELSE 'P' END) AS cattype,
    864                   lmtla.text1, lmtla.text2
    865           FROM ".$this->tables["images"]." lmti
    866                   LEFT OUTER JOIN ".$this->tables["licence_author"]." lmtla ON lmtla.id = lmti.author_id,
    867                ".IMAGES_TABLE." img
    868                   LEFT OUTER JOIN ".IMAGE_CATEGORY_TABLE." imgcat ON img.id = imgcat.image_id
    869                   LEFT OUTER JOIN ".CATEGORIES_TABLE." cat ON imgcat.category_id = cat.id
    870           WHERE lmti.image_id = img.id ";
    871     if($_REQUEST['filter']!="")
    872     {
    873       $sql.=" AND lmti.licence_type='".$_REQUEST['filter']."'";
    874     }
    875 
    876     $sql.=" GROUP BY lmti.image_id ORDER BY cat.id, img.id ";
    877 
    878     if($this->config['lmt_list_maxitems']>0)
    879     {
    880       $refdbt = ($pagenum-1)*$this->config['lmt_list_maxitems'];
    881       $sql.=" LIMIT ".$refdbt.", ".$this->config['lmt_list_maxitems'];
    882     }
    883 
    884     $result=pwg_query($sql);
    885     if($result)
    886     {
    887       while($row = pwg_db_fetch_assoc($result))
    888       {
    889         $filenfo = pathinfo($row['path']);
    890         preg_match("/(.*)\./i", $filenfo["basename"], $tmp);
    891         $filenfo['filename'] = $tmp[1];
    892 
    893         $tmp=array(
    894               'id'=>explode(',',$row['catid']),
    895               'name'=>explode('@sep@',$row['catname']),
    896               'type'=>explode(',',$row['cattype']),
    897               'plinks'=>explode('@sep@',$row['catpermalink']),
    898               'link'=>array()
    899             );
    900         $tmpcat=$this->make_image_data($tmp, $row['image_id']);
    901 
    902         $img_ids[]=$row['image_id'];
    903         $img_liste[]=array(
    904           'id' => $row['image_id'],
    905           'licence' => ($row['licence_type']=="CRIGHT")?l10n("lmt_lbl_cc_s-".strtolower($row['licence_type'])):"",
    906           'licencei' => LMT_PATH."img/".strtolower($row['licence_type'])."_80x15.png",
    907           'aut_text1' => $row['text1'],
    908           'aut_text2' => $row['text2'],
    909           'file' => $row['file'],
    910           'cat' => $tmpcat,
    911           'thumb' => $filenfo["dirname"]."/thumbnail/".$conf["prefix_thumbnail"].$filenfo["filename"].".".$row["tn_ext"]
    912         );
    913       }
    914     }
    915 
    916     $sql="select FOUND_ROWS()";
    917     $result=pwg_query($sql);
    918     $nb=pwg_db_fetch_row($result);
    919 
    920     $GPCPagesNavigation = new GPCPagesNavigation();
    921     $GPCPagesNavigation->setNbItems($nb[0]);
    922     $GPCPagesNavigation->setNbItemsPerPage($this->config['lmt_list_maxitems']);
    923     $GPCPagesNavigation->setCurrentPage($pagenum);
    924     $GPCPagesNavigation->setOptions(array(
    925       "text_prev" => l10n("lmt_nav_prev"),
    926       "text_next" => l10n("lmt_nav_next"),
    927       "text_first" => l10n("lmt_nav_first"),
    928       "text_last" => l10n("lmt_nav_last")
    929     ));
    930     $navbar=$GPCPagesNavigation->makeNavigation("loadpage");
    931     if($navbar!="")
    932     {
    933       $navbar=", ".$navbar;
    934     }
    935 
    936     $local_tpl->assign('imgliste', $img_liste);
    937     return($nb[0]."&nbsp;".l10n("lmt_lst_nb_photos").$navbar."#".$local_tpl->parse('body_page', true));
    938   }
    939 
    940   protected function ajax_manage_list($pagenum)
    941   {
    942     global $conf, $user;
    943 
    944     $local_tpl = new Template(LMT_PATH."admin/", "");
    945     $local_tpl->set_filename('body_page',
    946                   dirname($this->getFileLocation()).'/admin/plugin_admin_manageitems.tpl');
    947 
    948     if(!isset($_REQUEST['select']))
    949     {
    950       $_REQUEST['select']="caddie";
    951     }
    952 
    953     $img_liste = array();
    954     $sql="SELECT SQL_CALC_FOUND_ROWS img.id as image_id, img.file, img.path, img.tn_ext,
    955                   GROUP_CONCAT(cat.id) AS catid,
    956                   GROUP_CONCAT(CASE WHEN cat.name IS NULL THEN '' ELSE cat.name END SEPARATOR '@sep@') AS catname,
    957                   GROUP_CONCAT(CASE WHEN cat.permalink IS NULL THEN '' ELSE cat.permalink END SEPARATOR '@sep@') AS catpermalink,
    958                   GROUP_CONCAT(CASE WHEN cat.dir IS NULL THEN 'V' ELSE 'P' END) AS cattype,
    959                  lmti.licence_type, lmtla.text1, lmtla.text2
    960           FROM ".CADDIE_TABLE." caddie,
    961               (".IMAGES_TABLE." img
    962                   LEFT OUTER JOIN ".IMAGE_CATEGORY_TABLE." imgcat ON img.id = imgcat.image_id
    963                   LEFT OUTER JOIN ".CATEGORIES_TABLE." cat ON imgcat.category_id = cat.id)
    964                 LEFT OUTER JOIN ".$this->tables["images"]." AS lmti ON img.id = lmti.image_id
    965                 LEFT OUTER JOIN ".$this->tables["licence_author"]." lmtla  ON lmtla.id = lmti.author_id
    966           WHERE img.id = caddie.element_id
    967             AND caddie.user_id = '".$user['id']."'
    968           GROUP BY img.id
    969           ORDER BY cat.id, img.id ";
    970 
    971     if($this->config['lmt_list_maxitems']>0)
    972     {
    973       $refdbt = ($pagenum-1)*$this->config['lmt_list_maxitems'];
    974       $sql.=" LIMIT ".$refdbt.", ".$this->config['lmt_list_maxitems'];
    975     }
    976 
    977     $result=pwg_query($sql);
    978 
    979     if($result)
    980     {
    981       while($row = pwg_db_fetch_assoc($result))
    982       {
    983         $filenfo = pathinfo($row['path']);
    984         preg_match("/(.*)\./i", $filenfo["basename"], $tmp);
    985         $filenfo['filename'] = $tmp[1];
    986 
    987         $tmp=array(
    988               'id'=>explode(',',$row['catid']),
    989               'name'=>explode('@sep@',$row['catname']),
    990               'type'=>explode(',',$row['cattype']),
    991               'plinks'=>explode('@sep@',$row['catpermalink']),
    992               'link'=>array()
    993             );
    994         $tmpcat=$this->make_image_data($tmp, $row['image_id']);
    995 
    996         $img_liste[]=array(
    997           'id' => $row['image_id'],
    998           'licence' => ($row['licence_type']=="")?"DEFAULT":$row['licence_type'],
    999           'licencei' => ($row['licence_type']=="")?"":LMT_PATH."img/".strtolower($row['licence_type'])."_80x15.png",
    1000           'aut_text1' => $row['text1'],
    1001           'aut_text2' => $row['text2'],
    1002           'file' => $row['file'],
    1003           'cat' => $tmpcat,
    1004           'thumb' => $filenfo["dirname"]."/thumbnail/".$conf["prefix_thumbnail"].$filenfo["filename"].".".$row["tn_ext"]
    1005         );
    1006       }
    1007     }
    1008 
    1009     $sql="select FOUND_ROWS()";
    1010     $result=pwg_query($sql);
    1011     $nb=pwg_db_fetch_row($result);
    1012 
    1013     $GPCPagesNavigation = new GPCPagesNavigation();
    1014     $GPCPagesNavigation->setNbItems($nb[0]);
    1015     $GPCPagesNavigation->setNbItemsPerPage($this->config['lmt_list_maxitems']);
    1016     $GPCPagesNavigation->setCurrentPage($pagenum);
    1017     $GPCPagesNavigation->setOptions(array(
    1018       "text_prev" => l10n("lmt_nav_prev"),
    1019       "text_next" => l10n("lmt_nav_next"),
    1020       "text_first" => l10n("lmt_nav_first"),
    1021       "text_last" => l10n("lmt_nav_last")
    1022     ));
    1023     $navbar=$GPCPagesNavigation->makeNavigation("loadpage");
    1024     if($navbar!="")
    1025     {
    1026       $navbar=", ".$navbar;
    1027     }
    1028 
    1029     $local_tpl->assign('imgliste', $img_liste);
    1030     return($nb[0]."&nbsp;".l10n("lmt_lst_nb_photos").$navbar."#".$local_tpl->parse('body_page', true));
    1031   }
    1032 
    1033794} //class
    1034795
  • extensions/lmt/lmt_install.class.inc.php

    r5548 r7560  
    2828      parent::__construct($prefixeTable, $filelocation);
    2929      $this->tablef= new GPCTables($this->tables);
    30       $this->exportfile=dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().'.sql';
    3130    }
    3231
     
    7170      );
    7271
    73       //if present, try to import backup
    74       //if backup file
    75       $import=$this->tablef->import($this->exportfile);
    76       if($import['errors']<0)
    77       {
    78         $result=$this->tablef->create($tables_def);
    79         return($result);
    80       }
    81       else
    82       {
    83         return(true);
    84       }
     72      $result=$this->tablef->create($tables_def);
     73      GPCCore::register($this->getPluginName(), LMT_VERSION, LMT_GPC_NEEDED);
     74
     75      return($result);
    8576    }
    86 
    8777
    8878    /*
     
    9181    public function uninstall()
    9282    {
    93       $this->tablef->export($this->exportfile);
    9483      $this->deleteConfig();
    9584      $this->tablef->drop();
     85      GPCCore::unregister($this->getPluginName());
    9686      return('');
    9787    }
     
    10595      $this->config['installed']=LMT_VERSION2;
    10696      $this->saveConfig();
     97
     98      GPCCore::register($this->getPluginName(), LMT_VERSION, LMT_GPC_NEEDED);
     99      GPCRequestBuilder::register($this->getPluginName(), dirname($this->getFileLocation()).'/lmt_rb_callback.class.inc.php');
    107100      return('');
    108101    }
     
    110103    public function deactivate()
    111104    {
     105      GPCRequestBuilder::unregister($this->getPluginName());
    112106    }
    113 
    114107  } //class
    115108
  • extensions/lmt/lmt_pip.class.inc.php

    r6701 r7560  
    1717//include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCPublicIntegration.class.inc.php');
    1818
     19load_language('plugin.lang', LMT_PATH);
     20
    1921class LMT_PIP extends LMT_root
    2022{
     
    2729
    2830    $this->initEvents();
    29     $this->load_lang();
    3031  }
    3132
     
    3637  }
    3738
    38   /*
    39     load language file
    40   */
    41   public function load_lang()
    42   {
    43     global $lang;
    44 
    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();
    50   }
    51 
    52   /*
    53     initialize events call for the plugin
    54   */
     39  /**
     40   * initialize events call for the plugin
     41   */
    5542  public function initEvents()
    5643  {
    5744    parent::initEvents();
    58 /*
    59     add_event_handler('blockmanager_apply', array(&$this, 'blockmanager_apply') );
    60     add_event_handler('loading_lang', array(&$this, 'load_lang'));
    61 */
     45
    6246    if($this->config['lmt_licence_activated']=='y')
    6347    {
    6448      add_event_handler('loc_end_page_header', array(&$this->css_icn, 'applyCSS'));
    65       add_event_handler('loc_end_picture', array(&$this, 'manage_licence_element'));
     49      add_event_handler('loc_end_picture', array(&$this, 'manageLicenceElement'));
    6650
    6751      if($this->config['lmt_warning_visible']=='y')
    6852      {
    69         add_event_handler('loc_end_page_tail', array(&$this, 'manage_warning_text'));
     53        add_event_handler('loc_end_page_tail', array(&$this, 'manageWarningText'));
    7054      }
    7155    }
     
    7761    FUNCTIONS TO MANAGE LMT DISPLAY
    7862  ------------------------------------------------------------------------- */
    79   public function manage_licence_element()
     63  public function manageLicenceElement()
    8064  {
    8165    global $template, $page, $user;
    8266
    83     $licence=$this->get_image_licence($page['image_id']);
     67    $licence=$this->getImageLicence($page['image_id']);
    8468    if($licence['licence']=="")
    8569    {
     
    148132  }
    149133
    150   public function manage_warning_text()
     134  public function manageWarningText()
    151135  {
    152136    global $template, $user;
     
    198182
    199183
    200   /* ---------------------------------------------------------------------------
    201     ajax functions
    202   --------------------------------------------------------------------------- */
    203 
    204184} //class
    205185
  • extensions/lmt/lmt_root.class.inc.php

    r5548 r7560  
    1313
    1414  --------------------------------------------------------------------------- */
    15   include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
    16   include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php');
    17   include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php');
    18 
    19   class LMT_root extends CommonPlugin
    20   {
    21     protected $css;   //the css object
    22     protected $css_icn;   //the css object
    23 
    24     protected $licences=array('BY', 'BY-ND', 'BY-NC', 'BY-NC-ND', 'BY-NC-SA', 'BY-SA', 'CRIGHT', 'CLEFT', 'DEFAULT');
    25 
    26     public function __construct($prefixeTable, $filelocation)
    27     {
    28       $this->setPluginName('LMT');
    29       $this->setPluginNameFiles("lmt");
    30       parent::__construct($prefixeTable, $filelocation);
    31       $this->section_name=$this->getPluginNameFiles();
    32 
    33       $this->setTablesList(array('images', 'licence_author'));
    34 
    35 
    36       $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
    37       $this->css_icn = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles()."_icn.css");
    38     }
    39 
    40     public function __destruct()
    41     {
    42       unset($this->css);
    43       unset($this->css_icn);
    44       unset($this->licences);
    45       parent::__destruct();
    46     }
    47 
    48     public function initEvents()
    49     {
    50       add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') );
    51     }
    52 
    53     /*
    54       menu block management
    55     */
    56     public function register_blocks()
    57     {
    58     }
    59 
    60 
    61 
    62     /*
    63       surchage of CommonPlugin->saveConfig function
    64     */
    65     public function saveConfig()
    66     {
    67       if(parent::saveConfig())
     15include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
     16include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php');
     17include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php');
     18
     19class LMT_root extends CommonPlugin
     20{
     21  protected $css;   //the css object
     22  protected $css_icn;   //the css object
     23
     24  static public $licences=array('BY', 'BY-ND', 'BY-NC', 'BY-NC-ND', 'BY-NC-SA', 'BY-SA', 'CRIGHT', 'CLEFT', 'DEFAULT');
     25
     26  /**
     27   * constructor
     28   */
     29  public function __construct($prefixeTable, $filelocation)
     30  {
     31    $this->setPluginName('LMT');
     32    $this->setPluginNameFiles("lmt");
     33    parent::__construct($prefixeTable, $filelocation);
     34    $this->section_name=$this->getPluginNameFiles();
     35
     36    $this->setTablesList(array('images', 'licence_author'));
     37
     38    $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
     39    $this->css_icn = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles()."_icn.css");
     40  }
     41
     42  /**
     43   * destructor
     44   */
     45  public function __destruct()
     46  {
     47    unset($this->css);
     48    unset($this->css_icn);
     49    parent::__destruct();
     50  }
     51
     52  public function initEvents()
     53  {
     54    add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') );
     55  }
     56
     57  /**
     58   * menu block management
     59   */
     60  public function register_blocks()
     61  {
     62  }
     63
     64
     65  /**
     66   * initialize default values for config var
     67   */
     68  public function initConfig()
     69  {
     70    //global $user;
     71    $this->config=array(
     72      'lmt_list_maxheight' => '650',
     73      'lmt_list_maxitems' => '0',    /* limit number of item displayed ; 0 : no limit */
     74      'lmt_licence_default' => 'BY',
     75      'lmt_licence_default_author' => 0,
     76      'lmt_licence_activated' => 'n',
     77      'lmt_licence_visible' => 'n',  /* y:always visible, n:only if needed */
     78      'lmt_licence_logo' => '80x15', /* 80x15, 88x31, text */
     79      'lmt_warning_visible' => 'y',     /* y: display a text at the bottom of each page */
     80      'lmt_warning_texts' => array(), /* text displayed - multi lang */
     81      'lmt_redirect_activated' => 'y',     /* y: the text is an url to a warning page */
     82      'lmt_redirect_open_target' => 'n',   /* y: url are openned in a new page/tab */
     83      'lmt_redirect_url-by' => array(),
     84      'lmt_redirect_url-by-nd' => array(),
     85      'lmt_redirect_url-by-nc' => array(),
     86      'lmt_redirect_url-by-nc-nd' => array(),
     87      'lmt_redirect_url-by-nc-sa' => array(),
     88      'lmt_redirect_url-by-sa' => array(),
     89      'lmt_redirect_url-cright' => array(),
     90      'lmt_redirect_url-cleft' => array(),
     91    );
     92
     93    $languages=get_languages();
     94    foreach($languages as $key => $val)
     95    {
     96      $lang=substr($key,0,2)."/";
     97      if($lang=="en/") { $lang=""; }
     98      $this->config['lmt_warning_texts'][$key]='';
     99      $this->config['lmt_redirect_url-by'][$key]='http://creativecommons.org/licenses/by/2.0/'.$lang;
     100      $this->config['lmt_redirect_url-by-nd'][$key]='http://creativecommons.org/licenses/by-nd/2.0/'.$lang;
     101      $this->config['lmt_redirect_url-by-nc'][$key]='http://creativecommons.org/licenses/by-nc/2.0/'.$lang;
     102      $this->config['lmt_redirect_url-by-nc-nd'][$key]='http://creativecommons.org/licenses/by-nc-nd/2.0/'.$lang;
     103      $this->config['lmt_redirect_url-by-nc-sa'][$key]='http://creativecommons.org/licenses/by-nc-sa/2.0/'.$lang;
     104      $this->config['lmt_redirect_url-by-sa'][$key]='http://creativecommons.org/licenses/by-sa/2.0/'.$lang;
     105      $this->config['lmt_redirect_url-cright'][$key]='';
     106      $this->config['lmt_redirect_url-cleft'][$key]='';
     107    }
     108  }
     109
     110  /**
     111   * returns the admin page link
     112   */
     113  public function getAdminLink($mode='')
     114  {
     115    if($mode=='ajax')
     116    {
     117      return('plugins/'.basename(dirname($this->getFileLocation())).'/lmt_ajax.php');
     118    }
     119    else
     120    {
     121      return(parent::getAdminLink());
     122    }
     123  }
     124
     125
     126  /**
     127   * return the licence type for an image
     128   *
     129   * returned array
     130   *  'default'   => 'y' => if no licence for the picture, return de default
     131   *                        licence
     132   *                 'n' => if no licence for the picture, return empty values
     133   *  'licence'   => the licence type
     134   *  'aut_text1' => author, text 1
     135   *  'aut_text2' => author, text 2
     136   *
     137   * @param Integer $image_id : the image id
     138   * @return Array
     139   */
     140  public function getImageLicence($image_id)
     141  {
     142
     143    $return=array(
     144      "default" => "",
     145      "licence" => "",
     146      "aut_text1" => "",
     147      "aut_text2" => ""
     148    );
     149    $sql="SELECT lmti.licence_type, lmta.text1, lmta.text2
     150          FROM ".$this->tables['images']." lmti
     151            LEFT OUTER JOIN ".$this->tables['licence_author']." lmta ON lmti.author_id = lmta.id
     152          WHERE lmti.image_id = '".$image_id."'";
     153    $result=pwg_query($sql);
     154    if($result)
     155    {
     156      while($row=pwg_db_fetch_assoc($result))
    68157      {
    69         $this->css->makeCSS($this->generate_CSS());
    70         $this->css_icn->makeCSS($this->generate_CSS2());
    71         return(true);
     158        $return=array(
     159          "defaut" => "n",
     160          "licence" => $row['licence_type'],
     161          "aut_text1" => $row['text1'],
     162          "aut_text2" => $row['text2']
     163        );
    72164      }
    73       return(false);
    74     }
    75 
    76     /*
    77       surchage of CommonPlugin->saveConfig function
    78     */
    79     public function loadConfig()
    80     {
    81       parent::loadConfig();
    82       if(!$this->css->fileExists())
    83       {
    84         $this->css->makeCSS($this->generate_CSS());
    85       }
    86       if(!$this->css_icn->fileExists())
    87       {
    88         $this->css_icn->makeCSS($this->generate_CSS2());
    89       }
    90     }
    91 
    92     /*
    93       intialize default values
    94     */
    95     public function initConfig()
    96     {
    97       //global $user;
    98       $this->config=array(
    99         'lmt_mouseovercolor' => '303030', /**/
    100         'lmt_list_maxheight' => '650',
    101         'lmt_list_maxitems' => '0',    /* limit number of item displayed ; 0 : no limit */
    102         'lmt_licence_default' => 'BY',
    103         'lmt_licence_default_author' => 0,
    104         'lmt_licence_activated' => 'n',
    105         'lmt_licence_visible' => 'n',  /* y:always visible, n:only if needed */
    106         'lmt_licence_logo' => '80x15', /* 80x15, 88x31, text */
    107         'lmt_warning_visible' => 'y',     /* y: display a text at the bottom of each page */
    108         'lmt_warning_texts' => array(), /* text displayed - multi lang */
    109         'lmt_redirect_activated' => 'y',     /* y: the text is an url to a warning page */
    110         'lmt_redirect_open_target' => 'n',   /* y: url are openned in a new page/tab */
    111         'lmt_redirect_url-by' => array(),
    112         'lmt_redirect_url-by-nd' => array(),
    113         'lmt_redirect_url-by-nc' => array(),
    114         'lmt_redirect_url-by-nc-nd' => array(),
    115         'lmt_redirect_url-by-nc-sa' => array(),
    116         'lmt_redirect_url-by-sa' => array(),
    117         'lmt_redirect_url-cright' => array(),
    118         'lmt_redirect_url-cleft' => array(),
    119       );
    120 
    121       $languages=get_languages();
    122       foreach($languages as $key => $val)
    123       {
    124         $lang=substr($key,0,2)."/";
    125         if($lang=="en/") { $lang=""; }
    126         $this->config['lmt_warning_texts'][$key]='';
    127         $this->config['lmt_redirect_url-by'][$key]='http://creativecommons.org/licenses/by/2.0/'.$lang;
    128         $this->config['lmt_redirect_url-by-nd'][$key]='http://creativecommons.org/licenses/by-nd/2.0/'.$lang;
    129         $this->config['lmt_redirect_url-by-nc'][$key]='http://creativecommons.org/licenses/by-nc/2.0/'.$lang;
    130         $this->config['lmt_redirect_url-by-nc-nd'][$key]='http://creativecommons.org/licenses/by-nc-nd/2.0/'.$lang;
    131         $this->config['lmt_redirect_url-by-nc-sa'][$key]='http://creativecommons.org/licenses/by-nc-sa/2.0/'.$lang;
    132         $this->config['lmt_redirect_url-by-sa'][$key]='http://creativecommons.org/licenses/by-sa/2.0/'.$lang;
    133         $this->config['lmt_redirect_url-cright'][$key]='';
    134         $this->config['lmt_redirect_url-cleft'][$key]='';
    135       }
    136 
    137     }
    138 
    139     /*
    140       generate the css code
    141     */
    142     protected function generate_CSS()
    143     {
    144       $text = "
    145 .TableRow:hover
    146 {
    147   background-color:#".$this->config['lmt_mouseovercolor'].";
    148 }
    149 
    150 .formtable
    151 {
    152   text-align:justify;
    153   display:block;
    154   margin-top:0px;
    155   margin-bottom:0px;
    156   width:100%;
    157 }
    158 
    159 .formtable tr {
    160   vertical-align:top;
    161 }
    162 
    163 .littlefont { font-size:90%; }
    164 table.littlefont th { text-align:center; padding:3px;padding-left:9px;padding-right:9px; }
    165 table.littlefont td { text-align:left; padding:0px;padding-left:3px;padding-right:3px; }
    166 
    167 .lmt_page
    168 {
    169   text-align:justify;
    170   margin:8px;
    171 }
    172 
    173 .lmt  {
    174   text-align:justify;
    175 }
    176 
    177 #list {
    178   width:100%;
    179   overflow-y:scroll;
    180   min-height:250px;
    181   max-height:650px;
    182 }
    183 
    184 #ullist li {
    185   width:300px;
    186   display:block;
    187   float:left;
    188   text-align:left;
    189 }
    190 
    191 #ullist label {
    192   float:left;
    193 }
    194 
    195 #ullist li table {
    196   margin:0px;
    197   text-align:left;
    198   width:300px;
    199   font-size:80%;
    200 }
    201 
    202 #ullist li tr {
    203   vertical-align:top;
    204 }
    205 
    206 .content ul.thumbnails span.extendwrap1 {
    207   margin:0px;
    208   cursor:pointer;
    209 }
    210 
    211 .is_on, .is_off {
    212   z-index:20;
    213   width:12px;
    214   height:12px;
    215   display:block;
    216   cursor:pointer;
    217 }
    218 
    219 .is_on {
    220   background:url(./img/cb_on.png);
    221 }
    222 .is_off {
    223   background:url(./img/cb_off.png);
    224 }
    225 
    226 .icnhelp {
    227   weight:bold;
    228   text-decoration:none;
    229   cursor:help;
    230 }
    231 
    232 .hinthlp {
    233   position:absolute;
    234   max-width:400px;
    235   border:1px solid #000000;
    236   background:#ffffa0;
    237   color:#000000;
    238   top:0px;
    239   left:-450px;
    240   padding:2px;
    241   text-align:justify;
    242 }
    243 
    244       ";
    245       return($text);
    246     }
    247 
    248     /*
    249       generate the css code
    250     */
    251     protected function generate_CSS2()
    252     {
    253       $text = "
    254 .logo80x15 {
    255   position:relative;
    256   top:4px;
    257   margin-right:4px;
    258   border:0px none;
    259 }
    260 
    261 .logo88x31 {
    262   position:relative;
    263   margin-right:4px;
    264   border:0px none;
    265 }
    266 
    267 #theImage img.logo80x15, #theImage img.logo88x31 {
    268   border:0px none;
    269   padding:0px;
    270 }
    271 
    272 .licencetag {
    273   display:block;
    274   padding-top:10px;
    275   font-size:80%;
    276 }
    277       ";
    278       return($text);
    279     }
    280 
    281 
    282 
    283 
    284     /* -------------------------------------------------------------------------
    285      return the licence type for an image
    286       $default = 'y' => if no licence for the picture, return de default licence
    287                  'n' => if no licence for the picture, return empty values
    288     ------------------------------------------------------------------------- */
    289     public function get_image_licence($image_id)
    290     {
    291 
     165    }
     166
     167    if(($return["licence"]=="")&&($this->config["lmt_licence_visible"]=="y"))
     168    {
    292169      $return=array(
    293         "default" => "",
    294         "licence" => "",
     170        "defaut" => "y",
     171        "licence" => $this->config["lmt_licence_default"],
    295172        "aut_text1" => "",
    296173        "aut_text2" => ""
    297174      );
    298       $sql="SELECT lmti.licence_type, lmta.text1, lmta.text2
    299             FROM ".$this->tables['images']." lmti
    300               LEFT OUTER JOIN ".$this->tables['licence_author']." lmta ON lmti.author_id = lmta.id
    301             WHERE lmti.image_id = '".$image_id."'";
     175
     176      $sql="SELECT * FROM ".$this->tables['licence_author']."
     177            WHERE id = '".$this->config["lmt_licence_default_author"]."'";
    302178      $result=pwg_query($sql);
    303179      if($result)
     
    305181        while($row=pwg_db_fetch_assoc($result))
    306182        {
    307           $return=array(
    308             "defaut" => "n",
    309             "licence" => $row['licence_type'],
    310             "aut_text1" => $row['text1'],
    311             "aut_text2" => $row['text2']
    312           );
     183          $return["aut_text1"]=$row['text1'];
     184          $return["aut_text2"]=$row['text2'];
    313185        }
    314186      }
    315 
    316       if(($return["licence"]=="")&&($this->config["lmt_licence_visible"]=="y"))
     187    }
     188
     189    return($return);
     190  }
     191
     192
     193  /**
     194   * returns an array of image id with the asked licence type
     195   * if $licence = "" => return all picture with a specific licences
     196   *
     197   * @param String $licence : licence to be filtered
     198   * @return Array
     199   */
     200  public function getImagesLicences($licence)
     201  {
     202    $sql="".$this->tables['lmt'];
     203
     204    $result=pwg_query($sql.$sql_where.$sql_order);
     205    if($result)
     206    {
     207      $returned=array();
     208      while($row=pwg_db_fetch_assoc($result))
    317209      {
    318         $return=array(
    319           "defaut" => "y",
    320           "licence" => $this->config["lmt_licence_default"],
    321           "aut_text1" => "",
    322           "aut_text2" => ""
     210        array_push($returned, $row);
     211      }
     212      return($returned);
     213    }
     214    return(false);
     215  }
     216
     217
     218  protected function displayResult($action_msg, $result)
     219  {
     220    global $page;
     221
     222    if($result)
     223    {
     224      array_push($page['infos'], $action_msg);
     225    }
     226    else
     227    {
     228      array_push($page['errors'], $action_msg);
     229    }
     230  }
     231
     232
     233  /**
     234   * build image url (for a given category)
     235   *
     236   *
     237   */
     238  protected function makeImageDatas($tmp, $imageId)
     239  {
     240    $tmp2=array();
     241    foreach($tmp['id'] as $key=>$val)
     242    {
     243      $tmp2[]=array(
     244        'id' => $tmp['id'][$key],
     245        'name' => $tmp['name'][$key],
     246        'type' => $tmp['type'][$key],
     247        'plinks' => $tmp['plinks'][$key],
     248        'link'=> make_picture_url(
     249                  array(
     250                    'image_id' => $imageId,
     251                    'category' => array
     252                      (
     253                        'id' => $tmp['id'][$key],
     254                        'name' => $tmp['name'][$key],
     255                        'permalink' => $tmp['plinks'][$key]
     256                      )
     257                  )
     258                )
     259      );
     260    }
     261    return($tmp2);
     262  }
     263
     264} //class
     265
     266
     267
     268
     269class LMT_functions
     270{
     271  static private $tables = Array();
     272  static private $config = Array();
     273
     274  /**
     275   * initialise the class
     276   *
     277   * @param String $prefixeTable : the piwigo prefixe used on tables name
     278   * @param String $pluginNameFile : the plugin name used for tables name
     279   */
     280  static public function init($prefixeTable)
     281  {
     282    GPCCore::loadConfig(LMT_root::$pluginNameFile, self::$config);
     283    $list=LMT_root::$pluginTables;
     284
     285    for($i=0;$i<count($list);$i++)
     286    {
     287      self::$tables[$list[$i]]=$prefixeTable.LMT_root::$pluginNameFile.'_'.$list[$i];
     288    }
     289  }
     290
     291
     292  /**
     293   *  return all HTML&JS code necessary to display a dialogbox to choose
     294   *  geographic area
     295   */
     296  static public function dialogBoxLMT()
     297  {
     298    global $template;
     299
     300    $template->set_filename('lmt_choose',
     301                  dirname(__FILE__).'/templates/lmt_dialog_licence_choose.tpl');
     302
     303    $datas=Array(
     304      'licencesList' => array()
     305    );
     306
     307    foreach(LMT_root::$licences as $licence)
     308    {
     309      if($licence!='DEFAULT')
     310      {
     311        $datas['licencesList'][]=array(
     312          'value' => $licence,
     313          'name' => l10n('lmt_lbl_cc_s-'.strtolower($licence))
    323314        );
    324 
    325         $sql="SELECT * FROM ".$this->tables['licence_author']."
    326               WHERE id = '".$this->config["lmt_licence_default_author"]."'";
    327         $result=pwg_query($sql);
    328         if($result)
    329         {
    330           while($row=pwg_db_fetch_assoc($result))
    331           {
    332             $return["aut_text1"]=$row['text1'];
    333             $return["aut_text2"]=$row['text2'];
    334           }
    335         }
    336315      }
    337 
    338       return($return);
    339     }
    340 
    341 
    342     /* -------------------------------------------------------------------------
    343      returns an array of image id with the licence type
    344       if $licence = "" => return all picture with a specific licences
    345     ------------------------------------------------------------------------- */
    346     public function get_images_licences($licence)
    347     {
    348       $sql="".$this->tables['lmt'];
    349 
    350       $result=pwg_query($sql.$sql_where.$sql_order);
    351       if($result)
    352       {
    353         $returned=array();
    354         while($row=pwg_db_fetch_assoc($result))
    355         {
    356           array_push($returned, $row);
    357         }
    358         return($returned);
    359       }
    360       return(false);
    361     }
    362 
    363   protected function displayResult($action_msg, $result)
    364   {
    365     global $page;
    366 
    367     if($result)
    368     {
    369       array_push($page['infos'], $action_msg);
    370     }
    371     else
    372     {
    373       array_push($page['errors'], $action_msg);
    374     }
    375   }
    376 
    377 
    378     /* ---------------------------------------------------------------------------
    379       ajax functions
    380     --------------------------------------------------------------------------- */
    381 
    382 
    383   } //class
     316    }
     317
     318    $template->assign('datas', $datas);
     319
     320    return($template->parse('lmt_choose', true));
     321  }
     322} //GMaps_functions
     323
     324
    384325
    385326?>
  • extensions/lmt/lmt_version.inc.php

    r6701 r7560  
    1515  if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    1616
    17   define('LMT_VERSION',  '1.2.3');
    18   define('LMT_VERSION2', '01.02.03');
     17  define('LMT_VERSION',  '1.3.0');
     18  define('LMT_VERSION2', '01.03.00');
     19  define('LMT_GPC_NEEDED', '3.3.3');
    1920?>
  • extensions/lmt/main.inc.php

    r6703 r7560  
    22/*
    33Plugin Name: LMT
    4 Version: 1.2.3
     4Version: 1.3.0
    55Description: Appliquer une licence sur ses photos / Apply a licence on photos
    66Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=282
     
    108108{
    109109  //LMT public interface loaded and active only if in public page
    110   include_once("lmt_pip.class.inc.php");
    111   $obj=new LMT_PIP($prefixeTable, __FILE__);
     110  if(CommonPlugin::checkGPCRelease(LMT_GPC_NEEDED))
     111  {
     112    //LMT public interface loaded and active only if in public page
     113    include_once("lmt_pip.class.inc.php");
     114    $obj=new LMT_PIP($prefixeTable, __FILE__);
     115  }
    112116}
    113117
  • extensions/lmt/maintain.inc.php

    r5548 r7560  
    1414if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
    1515
     16include_once('lmt_version.inc.php'); // => Don't forget to update this file !!
     17
    1618if(!defined('LMT_DIR')) define('LMT_DIR' , basename(dirname(__FILE__)));
    1719if(!defined('LMT_PATH')) define('LMT_PATH' , PHPWG_PLUGINS_PATH . LMT_DIR . '/');
     
    2022//ini_set('display_errors', true);
    2123
    22 global $gpc_installed, $gpcNeeded, $lang; //needed for plugin manager compatibility
     24global $gpcInstalled, $lang; //needed for plugin manager compatibility
    2325
    2426/* -----------------------------------------------------------------------------
    25 LMT needs the Grum Plugin Classe
     27LMT needs the Grum Plugin Classes
    2628----------------------------------------------------------------------------- */
    27 $gpc_installed=false;
    28 $gpcNeeded="3.0.0";
     29$gpcInstalled=false;
    2930if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
    3031{
    3132  @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
    32   // need GPC release greater or equal than 3.0.0
    33   if(CommonPlugin::checkGPCRelease(3,0,0))
     33  // need GPC release greater or equal than ...
     34  if(CommonPlugin::checkGPCRelease(LMT_GPC_NEEDED))
    3435  {
    3536    @include_once('lmt_install.class.inc.php');
    36     $gpc_installed=true;
     37    $gpcInstalled=true;
    3738  }
    3839}
     40
    3941
    4042function gpcMsgError(&$errors)
     
    6163function plugin_install($plugin_id, $plugin_version, &$errors)
    6264{
    63   global $prefixeTable, $gpc_installed, $gpcNeeded;
     65  global $prefixeTable, $gpcInstalled;
     66  if(!$gpcInstalled)
     67  {
     68    gpcMsgError($errors, 'gpc');
     69    return(false);
     70  }
    6471
    65   if($gpc_installed)
     72  $obj = new LMT_Install($prefixeTable, __FILE__);
     73  $result=$obj->install();
     74}
     75
     76
     77
     78function plugin_activate($plugin_id, $plugin_version, &$errors)
     79{
     80  global $prefixeTable, $gpcInstalled;
     81
     82  if($gpcInstalled)
    6683  {
    6784    $obj = new LMT_Install($prefixeTable, __FILE__);
    68     $result=$obj->install();
    69     if(!$result)
    70     {
    71       array_push($errors, "error");
    72     }
    73     GPCCore::register($obj->getPluginName(), LMT_VERSION, $gpcNeeded);
    74   }
    75   else
    76   {
    77     gpcMsgError($errors);
     85    $result=$obj->activate();
    7886  }
    7987}
    8088
    81 function plugin_activate($plugin_id, $plugin_version, &$errors)
    82 {
    83   global $prefixeTable, $gpc_installed;
    84 
    85   if($gpc_installed)
    86   {
    87     $obj = new LMT_Install($prefixeTable, __FILE__);
    88     $result=$obj->activate();
    89     if($result===false or $result!='')
    90     {
    91       if(is_string($result))
    92       {
    93         array_push($errors, $result);
    94       }
    95       else
    96       {
    97         array_push($errors, "");
    98       }
    99     }
    100   }
    101   else
    102   {
    103     gpcMsgError($errors);
    104   }
    105 }
    10689
    10790function plugin_deactivate($plugin_id)
    10891{
    109 /*  global $prefixeTable;
    110   $obj = new install_mypolls($prefixeTable, __FILE__);
    111   $obj->deactivate(); */
     92  global $prefixeTable, $gpcInstalled;
     93
     94  if($gpcInstalled)
     95  {
     96    $obj=new LMT_Install($prefixeTable, __FILE__);
     97    $obj->deactivate();
     98  }
    11299}
    113100
    114101function plugin_uninstall($plugin_id)
    115102{
    116   global $prefixeTable, $gpc_installed;
     103  global $prefixeTable, $gpcInstalled;
    117104
    118   if($gpc_installed)
     105  if($gpcInstalled)
    119106  {
    120107    $obj = new LMT_Install($prefixeTable, __FILE__);
    121108    $obj->uninstall();
    122     GPCCore::unregister($obj->getPluginName());
    123   }
    124   else
    125   {
    126     gpcMsgError($errors);
    127109  }
    128110}
Note: See TracChangeset for help on using the changeset viewer.