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

Last change on this file since 15896 was 15382, checked in by grum, 12 years ago

feature:2641 - compatibility with Piwigo 2.4
fix minor bug due to changes on GPC

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