source: extensions/lmt/lmt_aip.class.inc.php

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

bug:2726

  • Property svn:executable set to *
File size: 24.2 KB
RevLine 
[3396]1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : LMT
4  Author     : Grum
5    email    : grum@piwigo.org
[4396]6    website  : http://photos.grum.fr
[3396]7
8    << May the Little SpaceFrog be with you ! >>
9  ------------------------------------------------------------------------------
10  See main.inc.php for release information
11
[4396]12  LMT_AIP : classe to manage plugin admin pages
[3396]13
14  --------------------------------------------------------------------------- */
15
16include_once('lmt_root.class.inc.php');
[5548]17include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php');
[7560]18include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php');
[5548]19include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/genericjs.class.inc.php');
[10974]20include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCPagesNavigation.class.inc.php');
[3396]21include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
22
23class LMT_AIP extends LMT_root
24{
25  protected $tabsheet;
26
[5548]27  public function __construct($prefixeTable, $filelocation)
[3396]28  {
29    parent::__construct($prefixeTable, $filelocation);
[5548]30    $this->loadConfig();
31    $this->initEvents();
[3396]32
33    $this->tabsheet = new tabsheet();
34    $this->tabsheet->add('list',
35                          l10n('lmt_list'),
[15341]36                          $this->getAdminLink()."-list");
[3396]37    $this->tabsheet->add('manage',
38                          l10n('lmt_manage'),
[15341]39                          $this->getAdminLink()."-manage");
[3396]40    $this->tabsheet->add('manageaut',
41                          l10n('lmt_manageaut'),
[15341]42                          $this->getAdminLink()."-manageaut");
[7560]43    $this->tabsheet->add('search',
44                          l10n('lmt_search'),
[15341]45                          $this->getAdminLink()."-search");
[3396]46    $this->tabsheet->add('config',
47                          l10n('lmt_config'),
[15341]48                          $this->getAdminLink()."-config");
[3396]49    $this->tabsheet->add('help',
50                          l10n('lmt_help'),
[15341]51                          $this->getAdminLink()."-help");
[3396]52  }
53
[5548]54  public function __destruct()
55  {
56    unset($this->tabsheet);
57    parent::__destruct();
58  }
59
[3396]60  /*
61    initialize events call for the plugin
62  */
[5548]63  public function initEvents()
[3396]64  {
[5548]65    parent::initEvents();
[7560]66
[15341]67    if(isset($_GET['tab']) and $_GET['tab']=='search')
[7560]68    {
69      // load request builder JS only on the search page
70      GPCRequestBuilder::loadJSandCSS();
71    }
[16014]72  }
[7560]73
74
[3396]75  /*
76    display administration page
77  */
78  public function manage()
79  {
80    global $template;
81
82    $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/lmt_admin.tpl");
[16014]83    GPCCore::setTemplateToken();
[3396]84
[15341]85    if(!isset($_GET['tab'])) $_GET['tab']='list';
[3396]86
[15341]87    switch($_GET['tab'])
[3396]88    {
89      case 'list':
90        $this->display_list_page();
91        break;
92      case 'manage':
93        $this->display_manage_page();
94        break;
95      case 'manageaut':
96        $this->display_manageaut_page();
97        break;
98      case 'managedoc':
99        $this->display_managedoc_page();
100        break;
[7560]101      case 'search':
102        $this->displaySearch();
103        break;
[3396]104      case 'help':
105        $this->display_help_page();
106        break;
107      case 'config':
108        $this->display_config_page();
109        break;
110    }
111
[15341]112    $this->tabsheet->select($_GET['tab']);
[3396]113    $this->tabsheet->assign();
114    $selected_tab=$this->tabsheet->get_selected();
115    $template->assign($this->tabsheet->get_titlename(), "[".$selected_tab['caption']."]");
116
[5548]117    $template_plugin["LMT_VERSION"] = "<i>".$this->getPluginName()."</i> ".l10n('lmt_release').LMT_VERSION;
[15341]118    $template_plugin["LMT_PAGE"] = $_GET['tab'];
[3396]119    $template_plugin["LMT_TITLE"] = "";
120
121    $template->assign('plugin', $template_plugin);
122    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
123  }
124
125
126  /*
127    manage display of config page & save config
128  */
129  protected function display_config_page()
130  {
131    $languages=get_languages();
[15341]132
133    GPCCore::addHeaderJS('lmt.config', './plugins/lmt/js/lmtConfig.js', array('jquery'));
134    GPCCore::addUI('inputNum,simpleTip');
[3396]135    if(!$this->adviser_abort())
136    {
137
138      if(isset($_POST['submit_save_config']))
139      {
[5548]140        foreach($this->config as $key => $val)
[3396]141        {
142          if(is_array($val))
143          {
144            foreach($languages as $key2 => $val2)
145            {
146              if(isset($_REQUEST[str2url('f_'.$key.'_'.$key2)]))
147              {
[5548]148                $this->config[$key][$key2] = htmlspecialchars(stripslashes($_REQUEST[str2url('f_'.$key.'_'.$key2)]), ENT_QUOTES);
[3396]149              }
150            }
151          }
152          else
153          {
154            if(isset($_REQUEST['f_'.$key]))
155            {
[5548]156              $this->config[$key] = $_REQUEST['f_'.$key];
[3396]157            }
158          }
159
160        }
[5548]161        $this->displayResult(l10n('lmt_save_config'), $this->saveConfig());
[3396]162      }
163    }
164    $this->display_config();
165  }
166
167
168  /*
[4396]169
[3396]170  */
171  protected function display_help_page()
172  {
173    global $template;
174
175    $template->set_filename('body_page',
[5548]176                dirname($this->getFileLocation()).'/admin/plugin_admin_help.tpl');
[3396]177
178    $template->assign('imgdir', LMT_PATH."img/");
179
180    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
181  }
182
183  /*
184  */
185  protected function display_list_page()
186  {
187    global $template, $conf, $user;
188
189    $template->set_filename('body_page',
[5548]190                dirname($this->getFileLocation()).'/admin/plugin_admin_list.tpl');
[3396]191
192    if(!isset($_REQUEST['filter']) ||
193       !($_REQUEST['filter']=="BY" ||
194         $_REQUEST['filter']=="BY-SA" ||
195         $_REQUEST['filter']=="BY-ND" ||
196         $_REQUEST['filter']=="BY-NC-ND" ||
197         $_REQUEST['filter']=="BY-NC-SA" ||
198         $_REQUEST['filter']=="BY-NC" ||
199         $_REQUEST['filter']=="CRIGHT" ||
[15341]200         $_REQUEST['filter']=="CLEFT" ||
[11342]201         $_REQUEST['filter']=="CC0" ||
202         $_REQUEST['filter']=="PD"
[3396]203      ))
204    {
205      $_REQUEST['filter']='';
206    }
207
208    $datas=array(
[7560]209      "LMT_AJAX_URL_LIST" =>  $this->getAdminLink('ajax')
[3396]210    );
211
212    $filter_list_selected = '';
[7560]213    $filter_list_values = array_slice(LMT_root::$licences,0,count(LMT_root::$licences)-1);
[3396]214    $filter_list_labels = array();
215    foreach($filter_list_values as $key=>$val)
216    {
[17604]217      $filter_list_labels[] = "[".$this->translateCopyright("lmt_lbl_cc_s-".strtolower($val))."] ".$this->translateCopyright("lmt_lbl_cc-".strtolower($val));
[4396]218      if($val==$_REQUEST['filter'])
[3396]219      {
220        $filter_list_selected = $val;
221      }
222    }
[4396]223
[3396]224    $filter_list_values = array_merge(array(''), $filter_list_values);
225    $filter_list_labels = array_merge(array(l10n('lmt_nofilter')), $filter_list_labels);
[17604]226    $default_licence = $this->translateCopyright("lmt_lbl_cc-".strtolower($this->config['lmt_licence_default']));
[5548]227    $default_licence_img =LMT_PATH."img/".strtolower($this->config['lmt_licence_default'])."_80x15.png";
[3396]228
229    $results=true;
230    if(isset($_POST["submit_replace_caddie"]))
231    {
232      $sql="DELETE FROM ".CADDIE_TABLE." WHERE user_id='".$user['id']."'";
233      $result=pwg_query($sql);
234      ($result)?$results=true:$results=false;
235    }
236
237    if(isset($_POST["submit_add_to_caddie"]) || isset($_POST["submit_replace_caddie"]))
238    {
[3666]239
[4396]240      $sql="REPLACE INTO ".CADDIE_TABLE."
241        SELECT '".$user['id']."', it.id FROM ".IMAGES_TABLE." it, ".$this->tables["images"]." lmti
[3666]242        WHERE it.id = lmti.image_id";
243      if($_REQUEST['filter']!="")
244      {
245        $sql.=" AND lmti.licence_type='".$_REQUEST['filter']."'";
246      }
247
[3396]248      $result=pwg_query($sql);
249      if((!$results)||(!$result))
250      {
[5548]251        $this->displayResult(l10n("lmt_caddie_not_updated"), false);
[3396]252      }
253      else
254      {
[5548]255        $this->displayResult(l10n("lmt_caddie_updated"), true);
[3396]256      }
257    }
[4396]258
[3396]259    $template->assign('datas', $datas);
260    $template->assign('default_licence', $default_licence);
261    $template->assign('default_licence_img', $default_licence_img);
262    $template->assign('filter_list_values', $filter_list_values);
263    $template->assign('filter_list_labels', $filter_list_labels);
264    $template->assign('filter_list_selected', $filter_list_selected);
265    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
266  }
267
268
269  /*
270  */
271  protected function display_manage_page()
272  {
273    global $template, $conf, $user;
274
275    /*
276      apply licence
277    */
278    if(isset($_POST['submit_apply_licence']))
279    {
280      $results=array("", "");
281      $lst=array();
282      foreach($_POST as $key => $val)
283      {
284        if((substr($key,0,2)=="fn")&&($val=="1")) $lst[]=substr($key,2);
285      }
286
287      if(count($lst)>0)
288      {
289        if($_POST['manage_caddie']!="napp_clear_selected")
290        {
291          if($_POST['licence']=='DEFAULT')
292          {
[4396]293            $sql="DELETE FROM ".$this->tables['images']."
[3396]294                    WHERE image_id IN (".implode(",", $lst).")";
295          }
296          else
297          {
[4396]298            $sql="REPLACE INTO ".$this->tables['images']."
[3396]299                    SELECT id, '".$_POST['licence']."', '".$_POST['author']."'
[4396]300                    FROM ".IMAGES_TABLE."
[3396]301                    WHERE id IN (".implode(",", $lst).")";
302          }
303          $result=pwg_query($sql);
304          ($result)?$results[0].=l10n("lmt_add_licence_ok")."<br/>":$results[1].=l10n("lmt_add_licence_ko")."<br/>";
305        }
306
307        switch($_POST['manage_caddie'])
308        {
309          case 'app_clear':
310            $sql="DELETE FROM ".CADDIE_TABLE." WHERE user_id = '".$user['id']."'";
311            $result=pwg_query($sql);
312            ($result)?$results[0].=l10n("lmt_clear_caddie_ok")."<br/>":$results[1].=l10n("lmt_clear_caddie_ko")."<br/>";
313            break;
314          case 'app_clear_selected':
315          case 'napp_clear_selected':
[4396]316            $sql="DELETE FROM ".CADDIE_TABLE."
[3396]317                  WHERE user_id = '".$user['id']."'
318                  AND element_id IN (".implode(",", $lst).")";
319            $result=pwg_query($sql);
320            ($result)?$results[0].=l10n("lmt_clear_si_caddie_ok")."<br/>":$results[1].=l10n("lmt_clear_si_caddie_ko")."<br/>";
321            break;
322        }
323
324        if($results[0]!="")
325        {
[5548]326          $this->displayResult($results[0], true);
[3396]327        }
328
329        if($results[1]!="")
330        {
[5548]331          $this->displayResult($results[1], false);
[3396]332        }
333      }
334      else
335      {
[5548]336        $this->displayResult(l10n("lmt_no_element_selected"), false);
[3396]337      }
338    }
339
340
341    $template->set_filename('body_page',
[5548]342                dirname($this->getFileLocation()).'/admin/plugin_admin_manage.tpl');
[3396]343
344    $datas=array(
[7560]345      "LMT_AJAX_URL_LIST" =>  $this->getAdminLink('ajax')
[3396]346    );
347
348    if(!isset($_REQUEST['select']))
349    {
350      $_REQUEST['select']="caddie";
351    }
352
353    $sql="SELECT count(element_id) FROM ".CADDIE_TABLE." WHERE user_id = '".$user['id']."'";
354    $result=pwg_query($sql);
[5431]355    $nbphotos=pwg_db_fetch_row($result);
[3396]356
357    $author_list_values = array(0);
358    $author_list_labels = array(l10n("lmt_no_author"));
359    $sql="SELECT * FROM ".$this->tables["licence_author"]." ORDER BY id";
360    $result=pwg_query($sql);
361    if($result)
362    {
[5431]363      while($row=pwg_db_fetch_assoc($result))
[3396]364      {
365        $author_list_values[]=$row['id'];
366        $author_list_labels[]=$row['text1']."&nbsp;".$row['text2'];
367      }
368    }
369
370    $licences_list_values = array();
[7560]371    $licences_list_values = self::$licences;
[3396]372    $licences_list_labels = array();
373    foreach($licences_list_values as $key=>$val)
374    {
[17604]375      $licences_list_labels[] = "[".$this->translateCopyright("lmt_lbl_cc_s-".strtolower($val))."] ".$this->translateCopyright("lmt_lbl_cc-".strtolower($val));
[3396]376    }
[4396]377
[3396]378/*    $licences_list_values = array_merge(array('DEFAULT'), $licences_list_values);
379    $licences_list_labels = array_merge(array(l10n('lmt_bydefault')), $licences_list_labels);*/
380
381    $selectlist_list_values=array("-", "all", "none", "invert");
382    $selectlist_list_values=array_merge($selectlist_list_values, $licences_list_values);
383
384    $selectlist_list_labels=array(
[4396]385        l10n("lmt_choose_select"),
386        l10n("lmt_select_all"),
387        l10n("lmt_select_none"),
388        l10n("lmt_select_invert")
[3396]389    );
390    $selectlist_list_labels=array_merge($selectlist_list_labels, $licences_list_labels);
391
392    $template->assign('datas', $datas);
393    $template->assign('nbphotos', $nbphotos[0]);
394    $template->assign('selectlist_list_values', $selectlist_list_values);
395    $template->assign('selectlist_list_labels', $selectlist_list_labels);
396    $template->assign('filter_list_selected', "");
397    $template->assign('licences_list_values', $licences_list_values);
398    $template->assign('licences_list_labels', $licences_list_labels);
399    $template->assign('licences_list_selected', "");
400    $template->assign('author_list_values', $author_list_values);
401    $template->assign('author_list_labels', $author_list_labels);
402    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
403  }
404
405
406  /*
407    display config page
408  */
409  protected function display_config()
410  {
411    global $template, $lang;
412
413    $template->set_filename('body_page',
[5548]414                dirname($this->getFileLocation()).'/admin/plugin_admin_config.tpl');
[3396]415
[4396]416
[3396]417    $datas=array(
418      "img_directory" => LMT_PATH."img/"
419    );
[5548]420    foreach($this->config as $key => $val)
[3396]421    {
422      if(!is_array($val))
423      {
424        $datas[$key]=$val;
425      }
426    }
427
428    $lmt_yesno_values=array("y", "n");
429    $lmt_yesno_labels=array(l10n("lmt_yesno_y"), l10n("lmt_yesno_n"));
430
431    $lmt_licence_logo_values=array("80x15", "88x31", "text");
432    $lmt_licence_logo_labels=array(l10n("lmt_icon_80x15"), l10n("lmt_icon_88x31"), l10n("lmt_icon_text"));
433
434    $datas['lmt_redirect_urls']=array();
[7560]435    $lmt_licence_default_values = array_slice(self::$licences,0,count(self::$licences)-1);
[3396]436    $lmt_licence_default_labels = array();
437
[4396]438    $tmp=array();
[3396]439    foreach($lmt_licence_default_values as $key=>$val)
440    {
[17604]441      $lmt_licence_default_labels[] = "[".$this->translateCopyright("lmt_lbl_cc_s-".strtolower($val))."] ".$this->translateCopyright("lmt_lbl_cc-".strtolower($val));
[3396]442
443      $tmp[]="'".str2url("ilmt_redirect_url-".strToLower($val))."'";
444      $datas['lmt_redirect_urls'][str2url('lmt_redirect_url-'.strToLower($val))]=array(
[17604]445        'text' => $this->translateCopyright("lmt_lbl_cc_s-".strToLower($val)),
[3396]446        'langs' => array()
447      );
448    }
449    $datas['objnames2'] = implode(",", $tmp);
450
451
452    //langs list & texts
453    $datas['lmt_warning_texts']=array();
454
455    $lmt_language_list=array();
456    $lmt_language_list_values=array();
457    $lmt_language_list_labels=array();
458    $lmt_language_selected=str2url(get_default_language());
459    $languages=get_languages();
460
461    foreach($languages as $key => $val)
462    {
463      $lmt_language_list_values[]=str2url($key);
464      $lmt_language_list_labels[]=$val;
465
466      $datas['lmt_warning_texts'][]=array(
467        'lang' => str2url($key),
[5548]468        'text' => $this->config['lmt_warning_texts'][$key]
[3396]469      );
[4396]470
[3396]471      foreach($lmt_licence_default_values as $key2 => $val2)
472      {
473        $datas['lmt_redirect_urls'][str2url('lmt_redirect_url-'.strToLower($val2))]['langs'][str2url($key)]=
[5548]474            $this->config['lmt_redirect_url-'.strToLower($val2)][$key];
[3396]475      }
476    }
477
478    $lmt_licence_default_author_values=array(0);
479    $lmt_licence_default_author_labels=array(l10n("lmt_no_author"));
480    $sql="SELECT * FROM ".$this->tables['licence_author']." ORDER BY id";
481    $result=pwg_query($sql);
482    if($result)
483    {
[5431]484      while($row=pwg_db_fetch_assoc($result))
[3396]485      {
486        $lmt_licence_default_author_values[]=$row['id'];
487        $lmt_licence_default_author_labels[]=$row['text1']." ".$row['text2'];
488      }
489    }
490
491    $template->assign('datas', $datas);
492    $template->assign('extended_code', $this->generate_js_licence_author());
493    $template->assign('lmt_yesno_values', $lmt_yesno_values);
494    $template->assign('lmt_yesno_labels', $lmt_yesno_labels);
495    $template->assign('lmt_licence_logo_values', $lmt_licence_logo_values);
496    $template->assign('lmt_licence_logo_labels', $lmt_licence_logo_labels);
497    $template->assign('lmt_licence_default_values', $lmt_licence_default_values);
498    $template->assign('lmt_licence_default_labels', $lmt_licence_default_labels);
499    $template->assign('lmt_licence_default_author_values', $lmt_licence_default_author_values);
500    $template->assign('lmt_licence_default_author_labels', $lmt_licence_default_author_labels);
501    $template->assign('lmt_language_list_values', $lmt_language_list_values);
502    $template->assign('lmt_language_list_labels', $lmt_language_list_labels);
503    $template->assign('lmt_language_selected', $lmt_language_selected);
504    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
505
506  } //display_config
507
508
509
[7560]510  /**
511   * display the search page
512   *
513   */
514  protected function displaySearch()
515  {
516    global $template;
[3396]517
[7560]518    $template->set_filename('body_page',
519                dirname($this->getFileLocation()).'/admin/lmt_search.tpl');
520
521    $template->assign('lmt_search_page', GPCRequestBuilder::displaySearchPage($this->getPluginName()));
522
523    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
524  }
525
526
527
[3396]528  /*
529  */
530  protected function display_manageaut_page()
531  {
532    global $template, $conf, $user;
533
534    if(!isset($_REQUEST['action']))
535    {
536      $_REQUEST['action']="list";
537    }
538    if(!isset($_REQUEST['id']))
539    {
540      $_REQUEST['id']="";
541    }
542
[10974]543
[3396]544    /* ------------------------------------------------------------------------
[4396]545     * Add an author
[3396]546     * ---------------------------------------------------------------------- */
547    if(isset($_POST['submit_add_author']))
548    {
549      if($_POST["text1"]!="")
550      {
[6703]551        $sql="INSERT INTO ".$this->tables["licence_author"]." VALUES('', '". htmlspecialchars($_POST["text1"], ENT_QUOTES)."', '".htmlspecialchars($_POST["text2"], ENT_QUOTES)."')";
[3396]552        $result=pwg_query($sql);
553        if($result)
554        {
[5548]555          $this->displayResult(l10n("lmt_author_added"), true);
[3396]556          $_REQUEST['action']="list";
557        }
558        else
559        {
[5548]560          $this->displayResult(l10n("lmt_cannot_add_author"), false);
[3396]561        }
562      }
563      else
564      {
[5548]565        $this->displayResult(l10n("lmt_no_text"), false);
[3396]566      }
567    }
[4396]568
[3396]569    /* ------------------------------------------------------------------------
[4396]570     * Modify an author
[3396]571     * ---------------------------------------------------------------------- */
572    if(isset($_POST['submit_modify_author']))
573    {
574      if($_POST["text1"]!="")
575      {
[4396]576        $sql="UPDATE ".$this->tables["licence_author"]."
[6703]577              SET text1 = '". htmlspecialchars($_POST["text1"], ENT_QUOTES)."',
578                  text2 = '".htmlspecialchars($_POST["text2"], ENT_QUOTES)."'
[3396]579              WHERE id = '".$_POST["id"]."'";
580        $result=pwg_query($sql);
581        if($result)
582        {
[5548]583          $this->displayResult(l10n("lmt_author_modified"), true);
[3396]584          $_REQUEST['action']="list";
585        }
586        else
587        {
[5548]588          $this->displayResult(l10n("lmt_cannot_modify_author"), false);
[3396]589        }
590      }
591      else
592      {
[5548]593        $this->displayResult(l10n("lmt_no_text"), false);
[3396]594      }
595    }
596
597    /* ------------------------------------------------------------------------
[4396]598     * delete an author
[3396]599     * ---------------------------------------------------------------------- */
600    if($_REQUEST['action']=="delete")
601    {
602      $sql="DELETE FROM ".$this->tables['licence_author']." WHERE id = '".$_REQUEST['id']."'";
603      $result=pwg_query($sql);
604      if($result)
605      {
[6701]606        if(pwg_db_changes($result)==1)
[3396]607        {
[5548]608          $this->displayResult(l10n("lmt_author_deleted"), true);
[3396]609
[4396]610          $sql="UPDATE ".$this->tables["images"]." SET author_id = NULL
[3396]611                WHERE author_id = '".$_REQUEST['id']."'";
612          $result=pwg_query($sql);
613          if($result)
614          {
[6701]615            $nbimages=pwg_db_changes($result);
[3396]616            if($nbimages>0)
617            {
[5548]618              $this->displayResult($nbimages."&nbsp;".l10n("lmt_author_nb_images_updated"), true);
[3396]619            }
620          }
621          else
622          {
[5548]623            $this->displayResult(l10n("lmt_cannot_delete_author"), false);
[3396]624          }
625        }
626        else
627        {
[5548]628          $this->displayResult(l10n("lmt_cannot_delete_author"), false);
[4396]629        }
[3396]630      }
631      else
632      {
[5548]633        $this->displayResult(l10n("lmt_cannot_delete_author"), false);
[3396]634      }
635      $this->display_manageaut_page_list();
636    }
637    elseif($_REQUEST['action']=="add")
638    {
639      $this->display_manageaut_page_add_modify("add");
640    }
641    elseif($_REQUEST['action']=="edit")
642    {
643      $this->display_manageaut_page_add_modify("edit");
644    }
645    else
646    {
647      // list
648      $this->display_manageaut_page_list();
649    }
650  } //display_manageaut
651
652  protected function display_manageaut_page_list()
653  {
654    global $template;
655
656    $template->set_filename('body_page',
[5548]657                dirname($this->getFileLocation()).'/admin/plugin_admin_manageaut.tpl');
[3396]658
659    $datas=array(
660      "author_list" => array(),
661      "img_directory" => LMT_PATH."img/",
[17604]662      "default_licencepublished" => $this->translateCopyright("lmt_lbl_under-".strToLower($this->config['lmt_licence_default'])),
[5548]663      "default_licenceL" => strToLower($this->config['lmt_licence_default']),
[17604]664      "default_licenceU" => $this->translateCopyright("lmt_lbl_cc_s-".strToLower($this->config['lmt_licence_default'])),
[5548]665      "lmt_licence_logo" => $this->config['lmt_licence_logo'],
[3396]666      "nbauthor" => 0,
[15341]667      "add_link" => $this->getAdminLink().'-manageaut&amp;action=add'
[3396]668    );
669
670    $sql="SELECT * FROM ".$this->tables['licence_author']." ORDER BY id";
671    $result=pwg_query($sql);
672    if($result)
673    {
[5431]674      while($row=pwg_db_fetch_assoc($result))
[3396]675      {
676        $datas["author_list"][]=array(
677          "id" => $row['id'],
678          "text1" => $row['text1'],
679          "text2" => $row['text2'],
[15341]680          "lnk_delete" => $this->getAdminLink().'-manageaut&amp;action=delete&amp;id='.$row['id'],
681          "lnk_edit" => $this->getAdminLink().'-manageaut&amp;action=edit&amp;id='.$row['id']
[3396]682        );
683      }
684      $datas["nbauthor"] = count($datas["author_list"]);
685    }
686
687    $template->assign('datas', $datas);
688    //$template->assign('extended_code', $this->generate_js_licence_author());
689    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
690  }
691
692  protected function display_manageaut_page_add_modify()
693  {
694    global $template;
695
696    $template->set_filename('body_page',
[5548]697                dirname($this->getFileLocation()).'/admin/plugin_admin_manageaut_edit.tpl');
[3396]698
699    if($_REQUEST["action"]=="edit")
[4396]700    {
[3396]701      $sql="SELECT * FROM ".$this->tables['licence_author']." WHERE id = '".$_REQUEST['id']."'";
702      $result = pwg_query($sql);
703      if($result)
704      {
[6272]705        while($row=pwg_db_fetch_assoc($result))
[3396]706        {
707          $datas=array(
708            "action" => "modify",
709            "id" => $_REQUEST['id'],
710            "text1" => $row["text1"],
711            "text2" => $row["text2"]
712          );
713        }
714      }
715      else
716      {
717        $datas=array(
718          "action" => "add",
719          "id" => "",
720          "text1" => "",
721          "text2" => "",
722        );
723      }
724    }
725    else
726    {
727      $datas=array(
728        "action" => "add",
729        "id" => "",
730        "text1" => "",
731        "text2" => "",
732      );
733    }
734
[15341]735    $datas["urllist"] = $this->getAdminLink().'-manageaut';
[3396]736
737    $template->assign('datas', $datas);
738    //$template->assign('extended_code', $this->generate_js_licence_author());
739    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
740  }
741
742
743  /*
744    manage adviser profile
745      return true if user is adviser
746  */
747  protected function adviser_abort()
748  {
749    if(is_adviser())
750    {
[5548]751      $this->displayResult(l10n("lmt_adviser_not_allowed"), false);
[3396]752      return(true);
753    }
754    return(false);
755  }
756
757
758  /*
[4396]759    this function return a js to manage licence text
[3396]760  */
761  protected function generate_js_licence_author()
762  {
763    $local_tpl = new Template(LMT_PATH."admin/", "");
764    $local_tpl->set_filename('body_page',
[5548]765                  dirname($this->getFileLocation()).'/admin/lmt_js.tpl');
[3396]766
[7560]767    $lmt_licence_default_values=array_slice(self::$licences,0,count(self::$licences)-1);
[3396]768    $datas['shortlicencetext']=array();
769    foreach($lmt_licence_default_values as $key=>$val)
770    {
771      $datas['shortlicencetext'][$val] = array(
[17604]772        "txt" => $this->translateCopyright("lmt_lbl_cc_s-".strtolower($val)),
773        "published" => $this->translateCopyright("lmt_lbl_under-".strtolower($val))
[3396]774      );
775    }
776
777    $local_tpl->assign("datas",$datas);
778
779    return($local_tpl->parse('body_page', true));
780  }
781
782
783  /* ---------------------------------------------------------------------------
784    function to manage database manipulation
785  --------------------------------------------------------------------------- */
786
787} //class
788
[5548]789
[3396]790?>
Note: See TracBrowser for help on using the repository browser.