Ignore:
Timestamp:
Apr 1, 2010, 9:05:29 PM (14 years ago)
Author:
grum
Message:

Update the plugin for compatibility with Piwigo 2.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/lmt/lmt_aip.class.inc.php

    r5431 r5548  
    1515
    1616include_once('lmt_root.class.inc.php');
    17 include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/translate.class.inc.php');
    18 include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/tables.class.inc.php');
    19 include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/genericjs.class.inc.php');
    20 include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/pages_navigation.class.inc.php');
     17include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTranslate.class.inc.php');
     18include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php');
     19include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/genericjs.class.inc.php');
     20include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCPagesNavigation.class.inc.php');
    2121include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
    2222
     
    2626  protected $tabsheet;
    2727
    28   public function LMT_AIP($prefixeTable, $filelocation)
     28  public function __construct($prefixeTable, $filelocation)
    2929  {
    3030    parent::__construct($prefixeTable, $filelocation);
    31     $this->load_config();
    32     $this->init_events();
     31    $this->loadConfig();
     32    $this->initEvents();
    3333
    3434    $this->tabsheet = new tabsheet();
    3535    $this->tabsheet->add('list',
    3636                          l10n('lmt_list'),
    37                           $this->page_link."&f_tabsheet=list");
     37                          $this->getAdminLink()."&f_tabsheet=list");
    3838    $this->tabsheet->add('manage',
    3939                          l10n('lmt_manage'),
    40                           $this->page_link."&f_tabsheet=manage");
     40                          $this->getAdminLink()."&f_tabsheet=manage");
    4141    $this->tabsheet->add('manageaut',
    4242                          l10n('lmt_manageaut'),
    43                           $this->page_link."&f_tabsheet=manageaut");
     43                          $this->getAdminLink()."&f_tabsheet=manageaut");
    4444    $this->tabsheet->add('config',
    4545                          l10n('lmt_config'),
    46                           $this->page_link."&f_tabsheet=config");
     46                          $this->getAdminLink()."&f_tabsheet=config");
    4747    $this->tabsheet->add('help',
    4848                          l10n('lmt_help'),
    49                           $this->page_link."&f_tabsheet=help");
    50 
    51     // don't create this object inside root classe otherwise header is modified
    52     // everywhere in admin pages
    53     $this->ajax = new Ajax();
     49                          $this->getAdminLink()."&f_tabsheet=help");
     50
    5451
    5552    // don't create the google_translate object everytime, otherwise google's js
     
    5956    /*if((isset($_POST['fmypolls_gomodify_translation'])||isset($_POST['fmypolls_goadd_translation'])))
    6057    {
    61       $this->google_translate = new translate();
     58      $this->google_translate = new GPCTranslate();
    6259    }
    6360    */
     61  }
     62
     63  public function __destruct()
     64  {
     65    unset($this->google_translate);
     66    unset($this->tabsheet);
     67    parent::__destruct();
    6468  }
    6569
     
    6771    initialize events call for the plugin
    6872  */
    69   public function init_events()
    70   {
    71     parent::init_events();
    72     add_event_handler('loc_end_page_header', array(&$this->css, 'apply_CSS'));
    73     add_event_handler('loc_end_page_header', array(&$this->css_icn, 'apply_CSS'));
     73  public function initEvents()
     74  {
     75    parent::initEvents();
     76    add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS'));
     77    add_event_handler('loc_end_page_header', array(&$this->css_icn, 'applyCSS'));
    7478  }
    7579
     
    117121    $template->assign($this->tabsheet->get_titlename(), "[".$selected_tab['caption']."]");
    118122
    119     $template_plugin["LMT_VERSION"] = "<i>".$this->plugin_name."</i> ".l10n('lmt_release').LMT_VERSION;
     123    $template_plugin["LMT_VERSION"] = "<i>".$this->getPluginName()."</i> ".l10n('lmt_release').LMT_VERSION;
    120124    $template_plugin["LMT_PAGE"] = $_REQUEST['f_tabsheet'];
    121125    $template_plugin["LMT_TITLE"] = "";
     
    146150          break;
    147151      }
    148       //$template->
    149       $this->ajax->return_result($result);
     152      GPCAjax::returnResult($result);
    150153    }
    151154  }
     
    163166      if(isset($_POST['submit_save_config']))
    164167      {
    165         foreach($this->my_config as $key => $val)
     168        foreach($this->config as $key => $val)
    166169        {
    167170          if(is_array($val))
     
    171174              if(isset($_REQUEST[str2url('f_'.$key.'_'.$key2)]))
    172175              {
    173                 $this->my_config[$key][$key2] = htmlspecialchars(stripslashes($_REQUEST[str2url('f_'.$key.'_'.$key2)]), ENT_QUOTES);
     176                $this->config[$key][$key2] = htmlspecialchars(stripslashes($_REQUEST[str2url('f_'.$key.'_'.$key2)]), ENT_QUOTES);
    174177              }
    175178            }
     
    179182            if(isset($_REQUEST['f_'.$key]))
    180183            {
    181               $this->my_config[$key] = $_REQUEST['f_'.$key];
     184              $this->config[$key] = $_REQUEST['f_'.$key];
    182185            }
    183186          }
    184187
    185188        }
    186         $this->display_result(l10n('lmt_save_config'), $this->save_config());
     189        $this->displayResult(l10n('lmt_save_config'), $this->saveConfig());
    187190      }
    188191    }
     
    199202
    200203    $template->set_filename('body_page',
    201                 dirname($this->filelocation).'/admin/plugin_admin_help.tpl');
     204                dirname($this->getFileLocation()).'/admin/plugin_admin_help.tpl');
    202205
    203206    $template->assign('imgdir', LMT_PATH."img/");
     
    213216
    214217    $template->set_filename('body_page',
    215                 dirname($this->filelocation).'/admin/plugin_admin_list.tpl');
     218                dirname($this->getFileLocation()).'/admin/plugin_admin_list.tpl');
    216219
    217220    if(!isset($_REQUEST['filter']) ||
     
    230233
    231234    $datas=array(
    232       "LMT_AJAX_URL_LIST" =>  $this->page_link.'&ajaxfct=img_list&numpage='
     235      "LMT_AJAX_URL_LIST" =>  $this->getAdminLink().'&ajaxfct=img_list&numpage='
    233236    );
    234237
     
    247250    $filter_list_values = array_merge(array(''), $filter_list_values);
    248251    $filter_list_labels = array_merge(array(l10n('lmt_nofilter')), $filter_list_labels);
    249     $default_licence = l10n("lmt_lbl_cc-".strtolower($this->my_config['lmt_licence_default']));
    250     $default_licence_img =LMT_PATH."img/".strtolower($this->my_config['lmt_licence_default'])."_80x15.png";
     252    $default_licence = l10n("lmt_lbl_cc-".strtolower($this->config['lmt_licence_default']));
     253    $default_licence_img =LMT_PATH."img/".strtolower($this->config['lmt_licence_default'])."_80x15.png";
    251254
    252255    $results=true;
     
    272275      if((!$results)||(!$result))
    273276      {
    274         $this->display_result(l10n("lmt_caddie_not_updated"), false);
     277        $this->displayResult(l10n("lmt_caddie_not_updated"), false);
    275278      }
    276279      else
    277280      {
    278         $this->display_result(l10n("lmt_caddie_updated"), true);
     281        $this->displayResult(l10n("lmt_caddie_updated"), true);
    279282      }
    280283    }
     
    347350        if($results[0]!="")
    348351        {
    349           $this->display_result($results[0], true);
     352          $this->displayResult($results[0], true);
    350353        }
    351354
    352355        if($results[1]!="")
    353356        {
    354           $this->display_result($results[1], false);
     357          $this->displayResult($results[1], false);
    355358        }
    356359      }
    357360      else
    358361      {
    359         $this->display_result(l10n("lmt_no_element_selected"), false);
     362        $this->displayResult(l10n("lmt_no_element_selected"), false);
    360363      }
    361364    }
     
    363366
    364367    $template->set_filename('body_page',
    365                 dirname($this->filelocation).'/admin/plugin_admin_manage.tpl');
     368                dirname($this->getFileLocation()).'/admin/plugin_admin_manage.tpl');
    366369
    367370    $datas=array(
    368       "LMT_AJAX_URL_LIST" =>  $this->page_link.'&ajaxfct=manage_list&numpage='
     371      "LMT_AJAX_URL_LIST" =>  $this->getAdminLink().'&ajaxfct=manage_list&numpage='
    369372    );
    370373
     
    435438
    436439    $template->set_filename('body_page',
    437                 dirname($this->filelocation).'/admin/plugin_admin_config.tpl');
     440                dirname($this->getFileLocation()).'/admin/plugin_admin_config.tpl');
    438441
    439442
     
    441444      "img_directory" => LMT_PATH."img/"
    442445    );
    443     foreach($this->my_config as $key => $val)
     446    foreach($this->config as $key => $val)
    444447    {
    445448      if(!is_array($val))
     
    489492      $datas['lmt_warning_texts'][]=array(
    490493        'lang' => str2url($key),
    491         'text' => $this->my_config['lmt_warning_texts'][$key]
     494        'text' => $this->config['lmt_warning_texts'][$key]
    492495      );
    493496
     
    495498      {
    496499        $datas['lmt_redirect_urls'][str2url('lmt_redirect_url-'.strToLower($val2))]['langs'][str2url($key)]=
    497             $this->my_config['lmt_redirect_url-'.strToLower($val2)][$key];
     500            $this->config['lmt_redirect_url-'.strToLower($val2)][$key];
    498501      }
    499502    }
     
    565568        if($result)
    566569        {
    567           $this->display_result(l10n("lmt_author_added"), true);
     570          $this->displayResult(l10n("lmt_author_added"), true);
    568571          $_REQUEST['action']="list";
    569572        }
    570573        else
    571574        {
    572           $this->display_result(l10n("lmt_cannot_add_author"), false);
     575          $this->displayResult(l10n("lmt_cannot_add_author"), false);
    573576        }
    574577      }
    575578      else
    576579      {
    577         $this->display_result(l10n("lmt_no_text"), false);
     580        $this->displayResult(l10n("lmt_no_text"), false);
    578581      }
    579582    }
     
    593596        if($result)
    594597        {
    595           $this->display_result(l10n("lmt_author_modified"), true);
     598          $this->displayResult(l10n("lmt_author_modified"), true);
    596599          $_REQUEST['action']="list";
    597600        }
    598601        else
    599602        {
    600           $this->display_result(l10n("lmt_cannot_modify_author"), false);
     603          $this->displayResult(l10n("lmt_cannot_modify_author"), false);
    601604        }
    602605      }
    603606      else
    604607      {
    605         $this->display_result(l10n("lmt_no_text"), false);
     608        $this->displayResult(l10n("lmt_no_text"), false);
    606609      }
    607610    }
     
    618621        if(pwg_db_changes()==1)
    619622        {
    620           $this->display_result(l10n("lmt_author_deleted"), true);
     623          $this->displayResult(l10n("lmt_author_deleted"), true);
    621624
    622625          $sql="UPDATE ".$this->tables["images"]." SET author_id = NULL
     
    628631            if($nbimages>0)
    629632            {
    630               $this->display_result($nbimages."&nbsp;".l10n("lmt_author_nb_images_updated"), true);
     633              $this->displayResult($nbimages."&nbsp;".l10n("lmt_author_nb_images_updated"), true);
    631634            }
    632635          }
    633636          else
    634637          {
    635             $this->display_result(l10n("lmt_cannot_delete_author"), false);
     638            $this->displayResult(l10n("lmt_cannot_delete_author"), false);
    636639          }
    637640        }
    638641        else
    639642        {
    640           $this->display_result(l10n("lmt_cannot_delete_author"), false);
     643          $this->displayResult(l10n("lmt_cannot_delete_author"), false);
    641644        }
    642645      }
    643646      else
    644647      {
    645         $this->display_result(l10n("lmt_cannot_delete_author"), false);
     648        $this->displayResult(l10n("lmt_cannot_delete_author"), false);
    646649      }
    647650      $this->display_manageaut_page_list();
     
    667670
    668671    $template->set_filename('body_page',
    669                 dirname($this->filelocation).'/admin/plugin_admin_manageaut.tpl');
     672                dirname($this->getFileLocation()).'/admin/plugin_admin_manageaut.tpl');
    670673
    671674    $datas=array(
    672675      "author_list" => array(),
    673676      "img_directory" => LMT_PATH."img/",
    674       "default_licencepublished" => l10n("lmt_lbl_under-".strToLower($this->my_config['lmt_licence_default'])),
    675       "default_licenceL" => strToLower($this->my_config['lmt_licence_default']),
    676       "default_licenceU" => l10n("lmt_lbl_cc_s-".strToLower($this->my_config['lmt_licence_default'])),
    677       "lmt_licence_logo" => $this->my_config['lmt_licence_logo'],
     677      "default_licencepublished" => l10n("lmt_lbl_under-".strToLower($this->config['lmt_licence_default'])),
     678      "default_licenceL" => strToLower($this->config['lmt_licence_default']),
     679      "default_licenceU" => l10n("lmt_lbl_cc_s-".strToLower($this->config['lmt_licence_default'])),
     680      "lmt_licence_logo" => $this->config['lmt_licence_logo'],
    678681      "nbauthor" => 0,
    679       "add_link" => $this->page_link.'&amp;f_tabsheet=manageaut&amp;action=add'
     682      "add_link" => $this->getAdminLink().'&amp;f_tabsheet=manageaut&amp;action=add'
    680683    );
    681684
     
    690693          "text1" => $row['text1'],
    691694          "text2" => $row['text2'],
    692           "lnk_delete" => $this->page_link.'&amp;f_tabsheet=manageaut&amp;action=delete&amp;id='.$row['id'],
    693           "lnk_edit" => $this->page_link.'&amp;f_tabsheet=manageaut&amp;action=edit&amp;id='.$row['id']
     695          "lnk_delete" => $this->getAdminLink().'&amp;f_tabsheet=manageaut&amp;action=delete&amp;id='.$row['id'],
     696          "lnk_edit" => $this->getAdminLink().'&amp;f_tabsheet=manageaut&amp;action=edit&amp;id='.$row['id']
    694697        );
    695698      }
     
    707710
    708711    $template->set_filename('body_page',
    709                 dirname($this->filelocation).'/admin/plugin_admin_manageaut_edit.tpl');
     712                dirname($this->getFileLocation()).'/admin/plugin_admin_manageaut_edit.tpl');
    710713
    711714    if($_REQUEST["action"]=="edit")
     
    745748    }
    746749
    747     $datas["urllist"] = $this->page_link.'&f_tabsheet=manageaut';
     750    $datas["urllist"] = $this->getAdminLink().'&f_tabsheet=manageaut';
    748751
    749752    $template->assign('datas', $datas);
     
    761764    if(is_adviser())
    762765    {
    763       $this->display_result(l10n("lmt_adviser_not_allowed"), false);
     766      $this->displayResult(l10n("lmt_adviser_not_allowed"), false);
    764767      return(true);
    765768    }
     
    775778    $local_tpl = new Template(LMT_PATH."admin/", "");
    776779    $local_tpl->set_filename('body_page',
    777                   dirname($this->filelocation).'/admin/lmt_js.tpl');
     780                  dirname($this->getFileLocation()).'/admin/lmt_js.tpl');
    778781
    779782    $lmt_licence_default_values=array_slice($this->licences,0,count($this->licences)-1);
     
    833836    $local_tpl = new Template(LMT_PATH."admin/", "");
    834837    $local_tpl->set_filename('body_page',
    835                   dirname($this->filelocation).'/admin/plugin_admin_listitems.tpl');
     838                  dirname($this->getFileLocation()).'/admin/plugin_admin_listitems.tpl');
    836839
    837840    if(!isset($_REQUEST['filter']) ||
     
    870873    $sql.=" GROUP BY lmti.image_id ORDER BY cat.id, img.id ";
    871874
    872     if($this->my_config['lmt_list_maxitems']>0)
    873     {
    874       $refdbt = ($pagenum-1)*$this->my_config['lmt_list_maxitems'];
    875       $sql.=" LIMIT ".$refdbt.", ".$this->my_config['lmt_list_maxitems'];
     875    if($this->config['lmt_list_maxitems']>0)
     876    {
     877      $refdbt = ($pagenum-1)*$this->config['lmt_list_maxitems'];
     878      $sql.=" LIMIT ".$refdbt.", ".$this->config['lmt_list_maxitems'];
    876879    }
    877880
     
    921924    $nb=pwg_db_fetch_row($result);
    922925
    923     $pages_navigation = new pages_navigation();
    924     $pages_navigation->set_nb_items($nb[0]);
    925     $pages_navigation->set_nb_items_per_page($this->my_config['lmt_list_maxitems']);
    926     $pages_navigation->set_current_page($pagenum);
    927     $pages_navigation->set_options(array(
     926    $GPCPagesNavigation = new GPCPagesNavigation();
     927    $GPCPagesNavigation->setNbItems($nb[0]);
     928    $GPCPagesNavigation->setNbItemsPerPage($this->config['lmt_list_maxitems']);
     929    $GPCPagesNavigation->setCurrentPage($pagenum);
     930    $GPCPagesNavigation->setOptions(array(
    928931      "text_prev" => l10n("lmt_nav_prev"),
    929932      "text_next" => l10n("lmt_nav_next"),
     
    931934      "text_last" => l10n("lmt_nav_last")
    932935    ));
    933     $navbar=$pages_navigation->make_navigation("loadpage");
     936    $navbar=$GPCPagesNavigation->makeNavigation("loadpage");
    934937    if($navbar!="")
    935938    {
     
    947950    $local_tpl = new Template(LMT_PATH."admin/", "");
    948951    $local_tpl->set_filename('body_page',
    949                   dirname($this->filelocation).'/admin/plugin_admin_manageitems.tpl');
     952                  dirname($this->getFileLocation()).'/admin/plugin_admin_manageitems.tpl');
    950953
    951954    if(!isset($_REQUEST['select']))
     
    972975          ORDER BY cat.id, img.id ";
    973976
    974     if($this->my_config['lmt_list_maxitems']>0)
    975     {
    976       $refdbt = ($pagenum-1)*$this->my_config['lmt_list_maxitems'];
    977       $sql.=" LIMIT ".$refdbt.", ".$this->my_config['lmt_list_maxitems'];
     977    if($this->config['lmt_list_maxitems']>0)
     978    {
     979      $refdbt = ($pagenum-1)*$this->config['lmt_list_maxitems'];
     980      $sql.=" LIMIT ".$refdbt.", ".$this->config['lmt_list_maxitems'];
    978981    }
    979982
     
    10231026    $nb=pwg_db_fetch_row($result);
    10241027
    1025     $pages_navigation = new pages_navigation();
    1026     $pages_navigation->set_nb_items($nb[0]);
    1027     $pages_navigation->set_nb_items_per_page($this->my_config['lmt_list_maxitems']);
    1028     $pages_navigation->set_current_page($pagenum);
    1029     $pages_navigation->set_options(array(
     1028    $GPCPagesNavigation = new GPCPagesNavigation();
     1029    $GPCPagesNavigation->setNbItems($nb[0]);
     1030    $GPCPagesNavigation->setNbItemsPerPage($this->config['lmt_list_maxitems']);
     1031    $GPCPagesNavigation->setCurrentPage($pagenum);
     1032    $GPCPagesNavigation->setOptions(array(
    10301033      "text_prev" => l10n("lmt_nav_prev"),
    10311034      "text_next" => l10n("lmt_nav_next"),
     
    10331036      "text_last" => l10n("lmt_nav_last")
    10341037    ));
    1035     $navbar=$pages_navigation->make_navigation("loadpage");
     1038    $navbar=$GPCPagesNavigation->makeNavigation("loadpage");
    10361039    if($navbar!="")
    10371040    {
     
    10451048} //class
    10461049
     1050
    10471051?>
Note: See TracChangeset for help on using the changeset viewer.