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

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

feature:2641 - Compatibility with Piwigo 2.4

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