Changeset 2468


Ignore:
Timestamp:
Aug 7, 2008, 11:52:45 PM (16 years ago)
Author:
grum
Message:

updating files for the Menu class (test_menu)

+ add functionnalities

updating files for the AMenuManager plugin

+ fixes some bugs
+ add functionnalities

updating common classes grum_plugins_classes-2
(needed for the AMenuManager plugin)

+ add functionalities for google_translator use

Location:
trunk/plugins
Files:
8 added
2 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/AMenuManager/admin/amm_linksconfig.tpl

    r2466 r2468  
    3636  }
    3737
     38  function do_translation()
     39  {
     40    var inputid = document.getElementById('iamm_links_title');
     41    var tolang = objlang.options[objlang.options.selectedIndex].value.substr(0,2);
     42
     43    google_translate(inputid.value, '{/literal}{$datas.fromlang}{literal}', tolang, inputid, 'value', apply_changes, inputid.id);
     44  }
     45
     46
    3847</script>
    3948{/literal}
     
    4756<form method="post" action="" class="general">
    4857  <fieldset>
    49     <legend>{'g002_setting_link_block_menu'|@translate}</legend>
     58    <legend>{'g002_setting_block_menu'|@translate}</legend>
    5059
    5160    {if isset($datas.language_list) and count($datas.language_list)}
     
    5867    <table class="formtable">
    5968      <tr>
    60         <td>{'g002_setting_link_block_active'|@translate}</td>
     69        <td>{'g002_setting_block_active'|@translate}</td>
    6170        <td>
    6271          <select name="famm_links_active" id="iamm_links_active">
     
    6776
    6877      <tr>
    69         <td>{'g002_setting_link_block_title'|@translate}</td>
     78        <td>{'g002_setting_block_title'|@translate}</td>
    7079        <td>
    71           <input type="text" id="iamm_links_title" value="" maxlength="50" onkeyup="apply_changes('iamm_links_title');" />
     80          <input type="text" id="iamm_links_title" value="" maxlength="50" onkeyup="apply_changes('iamm_links_title');" onblur="apply_changes('iamm_links_title');"/>
    7281          <select onchange="change_lang();" id="islang">
    7382            {html_options values=$datas.language_list_values output=$datas.language_list_labels selected=$datas.lang_selected}
    74           </select>
     83          </select><br>
     84        </td>
     85      </tr>
     86      <tr>
     87        <td></td>
     88        <td style="font-size:80%;">
     89          <a style="cursor:pointer;" onclick="do_translation()">{'g002_translate'|@translate}</a>
    7590        </td>
    7691      </tr>
  • trunk/plugins/AMenuManager/amm_aip.class.inc.php

    r2466 r2468  
    2121include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/ajax.class.inc.php');
    2222include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/genericjs.class.inc.php');
     23include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/translate.class.inc.php');
    2324
    2425class AMM_AIP extends AMM_root
    2526{
     27  protected $google_translate;
    2628  protected $tabsheet;
    2729  protected $css;   //the css object
     
    5254    $this->css = new css(dirname($this->filelocation).'/'.$this->plugin_name_files.".css");
    5355    $this->ajax = new Ajax();
     56    $this->google_translate = new translate();
    5457  }
    5558
     
    116119          else
    117120          {
    118             $this->display_links_manage_page($_REQUEST['action']);
     121            ($_REQUEST['action']=='modify')?$urlid=$_REQUEST['fItem']:$urlid=0;
     122            $this->display_links_manage_page($_REQUEST['action'], $urlid);
    119123          }
    120124          break;
     
    124128            if(!$this->adviser_abort())
    125129            {
    126               $this->action_modify_config();
     130              $this->action_links_modify_config();
    127131            }
    128132          }
     
    134138    {
    135139      $page_nfo=l10n('g002_randompict_nfo');
     140      if($post_action=='config')
     141      {
     142        if(!$this->adviser_abort())
     143        {
     144          $this->action_randompic_modify_config();
     145        }
     146      }
     147      $this->display_randompic_config_page();
    136148    }
    137149    elseif($_REQUEST['fAMM_tabsheet']=='personnalblock')
    138150    {
    139151      $page_nfo=l10n('g002_personnalblock_nfo');
     152
     153      switch($_REQUEST['action'])
     154      {
     155        case 'list':
     156          $this->display_personalised_list_page();
     157          break;
     158        case 'create':
     159        case 'modify':
     160          if($post_action==$_REQUEST['action'])
     161          {
     162            if(!$this->adviser_abort())
     163            {
     164              $this->action_create_modify_personalised();
     165            }
     166            $this->display_personalised_list_page();
     167          }
     168          else
     169          {
     170            ($_REQUEST['action']=='modify')?$sectionid=$_REQUEST['fItem']:$sectionid=0;
     171            $this->display_personalised_manage_page($_REQUEST['action'], $sectionid);
     172          }
     173          break;
     174      }
    140175    }
    141176    elseif($_REQUEST['fAMM_tabsheet']=='setmenu')
    142177    {
    143178      $page_nfo=l10n('g002_setmenu_nfo');
    144       $this->display_sections_list_page();
     179      $this->display_sections_list_page($_REQUEST['action']);
    145180    }
    146181
     
    185220          $result=$this->ajax_amm_links_delete($_REQUEST['fItem']);
    186221          break;
    187         case 'sections_list':
    188           $result=$this->ajax_amm_section_list();
    189           break;
    190         case 'sections_position':
    191           $result=$this->ajax_amm_section_position($_REQUEST['fItem'], $_REQUEST['fPosition']);
    192           break;
    193         case 'sections_showhide':
    194           $result=$this->ajax_amm_section_showhide($_REQUEST['fItem']);
     222        case 'setmenu_list_sections_list':
     223          $result=$this->ajax_amm_setmenu_list_section_list();
     224          break;
     225        case 'setmenu_list_sections_position':
     226          $result=$this->ajax_amm_setmenu_list_section_position($_REQUEST['fItem'], $_REQUEST['fPosition']);
     227          break;
     228        case 'setmenu_list_sections_showhide':
     229          $result=$this->ajax_amm_setmenu_list_section_showhide($_REQUEST['fItem']);
     230          break;
     231
     232        case 'setmenu_modmenu_sections_list':
     233          $result=$this->ajax_amm_setmenu_mod_section_list('amm_sections_modmenu');
     234          break;
     235        case 'setmenu_modmenu_sections_showhide':
     236          $result=$this->ajax_amm_setmenu_mod_section_showhide('amm_sections_modmenu', $_REQUEST['fItem']);
     237          break;
     238
     239        case 'setmenu_modspecial_sections_list':
     240          $result=$this->ajax_amm_setmenu_mod_section_list('amm_sections_modspecial');
     241          break;
     242        case 'setmenu_modspecial_sections_showhide':
     243          $result=$this->ajax_amm_setmenu_mod_section_showhide('amm_sections_modspecial', $_REQUEST['fItem']);
     244          break;
     245
     246        case 'personalised_list':
     247          $result=$this->ajax_amm_personalised_list();
     248          break;
     249        case 'personalised_delete':
     250          $result=$this->ajax_amm_personalised_delete($_REQUEST['fItem']);
    195251          break;
    196252      }
     
    211267    }
    212268
    213     if(($_REQUEST['fAMM_tabsheet']=='links') and !isset($_REQUEST['action']))
     269    if((($_REQUEST['fAMM_tabsheet']=='links') or
     270        ($_REQUEST['fAMM_tabsheet']=='personnalblock') or
     271        ($_REQUEST['fAMM_tabsheet']=='setmenu')) and !isset($_REQUEST['action']))
    214272    {
    215273      $_REQUEST['action']='list';
     
    269327      'show_icons_selected' => $this->my_config['amm_links_show_icons'],
    270328      'active_selected' => $this->my_config['amm_links_active'],
    271       'lang_selected' => $user['language']
     329      'lang_selected' => $user['language'],
     330      'fromlang' => substr($user['language'],0,2)
    272331    );
    273332
     
    328387        'id' => $urlid,
    329388        'modeedit' => 'modify',
    330         'label' => $url['label'],
     389        'label' => htmlentities($url['label'], ENT_QUOTES, 'UTF-8'),
    331390        'url' => $url['url'],
    332391        'icons_selected' => $url['icon'],
     
    398457    manage urls config save into database
    399458  */
    400   protected function action_modify_config()
     459  protected function action_links_modify_config()
    401460  {
    402461    $this->my_config['amm_links_show_icons']=$_POST['famm_links_show_icons'];
     
    405464    foreach($languages as $key => $val)
    406465    {
    407       $this->my_config['amm_links_title'][$key]=base64_encode(stripslashes($_POST['famm_links_title_'.$key]));
     466      $this->my_config['amm_links_title'][$key]=base64_encode($_POST['famm_links_title_'.$key]);
    408467    }
    409468    $this->save_config();
     
    411470
    412471  /*
     472    manage randompic config save into database
     473  */
     474  protected function action_randompic_modify_config()
     475  {
     476    $this->my_config['amm_randompicture_active']=$_POST['famm_randompicture_active'];
     477    $this->my_config['amm_randompicture_showname']=$_POST['famm_randompicture_showname'];
     478    $this->my_config['amm_randompicture_showcomment']=$_POST['famm_randompicture_showcomment'];
     479    $languages=get_languages();
     480    foreach($languages as $key => $val)
     481    {
     482      $this->my_config['amm_randompicture_title'][$key]=base64_encode(stripslashes($_POST['famm_randompicture_title_'.$key]));
     483    }
     484    $this->save_config();
     485  }
     486
     487
     488
     489  /*
    413490    manage display for sections table page
    414491  */
    415   private function display_sections_list_page()
     492  private function display_sections_list_page($action)
    416493  {
    417494    global $template, $user;
    418495    $template->set_filename('body_page',
    419                             dirname($this->filelocation).'/admin/amm_sectionslist.tpl');
     496                            dirname($this->filelocation).'/admin/amm_sections.tpl');
     497
     498    switch($action)
     499    {
     500      case 'list':
     501        $tmp_list=array(
     502          array('separator' => '', 'link' => '', 'label' => 'g002_sectionslist'),
     503          array('separator' => ' / ', 'link' => $this->page_link.'&amp;fAMM_tabsheet=setmenu&amp;action=modmenu', 'label' => 'g002_modmenu'),
     504          array('separator' => ' / ', 'link' => $this->page_link.'&amp;fAMM_tabsheet=setmenu&amp;action=modspecial', 'label' => 'g002_modspecial')
     505        );
     506        break;
     507      case 'modmenu':
     508        $tmp_list=array(
     509          array('separator' => '', 'link' => $this->page_link.'&amp;fAMM_tabsheet=setmenu&amp;action=list', 'label' => 'g002_sectionslist'),
     510          array('separator' => ' / ', 'link' => '', 'label' => 'g002_modmenu'),
     511          array('separator' => ' / ', 'link' => $this->page_link.'&amp;fAMM_tabsheet=setmenu&amp;action=modspecial', 'label' => 'g002_modspecial')
     512        );
     513        break;
     514      case 'modspecial':
     515        $tmp_list=array(
     516          array('separator' => '', 'link' => $this->page_link.'&amp;fAMM_tabsheet=setmenu&amp;action=list', 'label' => 'g002_sectionslist'),
     517          array('separator' => ' / ', 'link' => $this->page_link.'&amp;fAMM_tabsheet=setmenu&amp;action=modmenu', 'label' => 'g002_modmenu'),
     518          array('separator' => ' / ', 'link' => '', 'label' => 'g002_modspecial')
     519        );
     520        break;
     521    }
    420522
    421523    $template_datas=array(
    422       'AMM_AJAX_URL_LIST' => $this->page_link."&ajaxfct=",
     524      'AMM_AJAX_URL_LIST' => $this->page_link."&ajaxfct=setmenu_".$action."_",
     525      'LIST' => $tmp_list
    423526    );
    424527   
    425528    $template->assign("datas", $template_datas);
    426529    $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
     530  }
     531
     532
     533  /*
     534    manage display for randompic config page
     535  */
     536  private function display_randompic_config_page()
     537  {
     538    global $template, $user;
     539    $template->set_filename('body_page',
     540                            dirname($this->filelocation).'/admin/amm_randompicconfig.tpl');
     541
     542    $template_datas=array(
     543      'lnk_list' => $this->page_link.'&amp;fAMM_tabsheet=links',
     544      'active_selected' => $this->my_config['amm_randompicture_active'],
     545      'showname_selected' => $this->my_config['amm_randompicture_showname'],
     546      'showcomment_selected' => $this->my_config['amm_randompicture_showcomment'],
     547      'lang_selected' => $user['language'],
     548      'fromlang' => substr($user['language'],0,2)
     549    );
     550
     551    $template_datas['language_list'] = array();
     552    foreach($this->my_config['amm_randompicture_title'] as $key => $val)
     553    {
     554      $template_datas['language_list'][] = array(
     555        'LANG' => $key,
     556        'MENUBARTIT' => htmlentities(base64_decode($val), ENT_QUOTES, 'UTF-8')
     557      );
     558    }
     559
     560
     561
     562    $lang=get_languages();
     563    foreach($lang as $key => $val)
     564    {
     565      $template_datas['language_list_values'][] = $key;
     566      $template_datas['language_list_labels'][] = $val;
     567    }
     568
     569
     570    $template_datas['yesno_values'] = array('y','n');
     571    $template_datas['yesno_labels'][] = l10n('g002_yesno_y');
     572    $template_datas['yesno_labels'][] = l10n('g002_yesno_n');
     573
     574    $template_datas['show_values'] = array('n', 'o', 'u');
     575    $template_datas['show_labels'][] = l10n('g002_show_n');
     576    $template_datas['show_labels'][] = l10n('g002_show_o');
     577    $template_datas['show_labels'][] = l10n('g002_show_u');
     578
     579   
     580    $template->assign("datas", $template_datas);
     581    $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
     582  }
     583
     584
     585
     586
     587
     588
     589
     590  /*
     591    manage display for personalised sections list page
     592  */
     593  private function display_personalised_list_page()
     594  {
     595    global $template, $user;
     596    $template->set_filename('body_page',
     597                            dirname($this->filelocation).'/admin/amm_personalisedlist.tpl');
     598
     599    $sql="SELECT COUNT(DISTINCT ID) as countid FROM ".$this->tables['personalised'];
     600    $result=pwg_query($sql);
     601    if($result)
     602    {
     603      $tmp=mysql_fetch_row($result);
     604      $tmp=$tmp[0];
     605    }
     606    else
     607    {
     608      $tmp=0;
     609    }
     610
     611    if($tmp==0)
     612    {
     613      $tmp=l10n("g002_nosections");
     614    }
     615    elseif($tmp==1)
     616    {
     617      $tmp="1 ".l10n("g002_section");
     618    }
     619    else
     620    {
     621      $tmp=$tmp." ".l10n("g002_sections");
     622    }
     623
     624
     625    $template_datas=array(
     626      'lnk_create' => $this->page_link.'&amp;fAMM_tabsheet=personnalblock&amp;action=create',
     627      'AMM_AJAX_URL_LIST' => $this->page_link."&ajaxfct=",
     628      'nbsections' => $tmp
     629    );
     630   
     631    $template->assign("datas", $template_datas);
     632    $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
     633  }
     634
     635
     636
     637  /*
     638    manage display for personalised sections create/modify page
     639  */
     640  private function display_personalised_manage_page($modeedit = 'create', $sectionid=0)
     641  {
     642    global $template, $user;
     643    $template->set_filename('body_page',
     644                            dirname($this->filelocation).'/admin/amm_personalisedlist_edit.tpl');
     645
     646    $template_datas=array();
     647
     648    $lang=get_languages();
     649    $lang['all']=l10n('g002_all_languages');
     650    foreach($lang as $key => $val)
     651    {
     652      $template_datas['language_list_values'][] = $key;
     653      $template_datas['language_list_labels'][] = $val;
     654      $template_datas['language_list'][$key]=array(
     655        'LANG' => $key,
     656        'MENUBARTIT' => '',
     657        'MENUBARCONTENT' => ''
     658      );
     659    }
     660
     661
     662    if($modeedit=='modify')
     663    {
     664      $sections=$this->get_personalised($sectionid);
     665
     666      $template_datas['id'] = $sectionid;
     667      $template_datas['modeedit'] = 'modify';
     668      $template_datas['visible_selected'] = $sections[0]['visible'];
     669      $template_datas['nfo'] = htmlentities($sections[0]['nfo'], ENT_QUOTES, 'UTF-8');
     670
     671      foreach($sections as $key => $val)
     672      {
     673        $lang=($val['lang']=='*')?'all':$val['lang'];
     674        $template_datas['language_list'][$lang] = array(
     675          'LANG' => $lang,
     676          'MENUBARTIT' => htmlentities($val['title'], ENT_QUOTES, 'UTF-8'),
     677          'MENUBARCONTENT' => htmlentities($val['content'], ENT_QUOTES, 'UTF-8'),
     678        );
     679      }
     680    }
     681    else
     682    {
     683      $template_datas['nfo'] = '';
     684      $template_datas['id'] = '';
     685      $template_datas['modeedit'] = 'create';
     686      $template_datas['visible_selected'] = 'y';
     687    }
     688
     689    $template_datas['lang_selected'] = $user['language'];
     690
     691    $template_datas['personalised_list'] = $this->page_link.'&amp;fAMM_tabsheet=personnalblock';
     692    $template_datas['yesno_values'] = array('y','n');
     693    $template_datas['yesno_labels'][] = l10n('g002_yesno_y');
     694    $template_datas['yesno_labels'][] = l10n('g002_yesno_n');
     695
     696    $template->assign("datas", $template_datas);
     697    $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
     698  }
     699
     700  /*
     701    manage create/modify pesonalised sections into database and display result
     702  */
     703  protected function action_create_modify_personalised()
     704  {
     705    global $menu, $user;
     706
     707    if($_POST['famm_modeedit']=='create')
     708    {
     709      $id=$this->get_personalised_id();
     710    }
     711    else
     712    {
     713      $id=$_POST['famm_id'];
     714    }
     715    $languages=get_languages();
     716    $languages['all']='*';
     717    foreach($languages as $key => $val)
     718    {
     719      $datas=array(
     720        'id' => $id,
     721        'lang' => ($key=='all')?'*':$key,
     722        'visible' => $_POST['famm_personalised_visible'],
     723        'nfo' => ($_POST['famm_personalised_nfo']=='')?$_POST['famm_personalised_title_'.$user['language']]:$_POST['famm_personalised_nfo'],
     724        'title' => $_POST['famm_personalised_title_'.$key],
     725        'content' => $_POST['famm_personalised_content_'.$key]
     726      );
     727      switch($_POST['famm_modeedit'])
     728      {
     729        case 'create':
     730          $this->add_personalised($datas);
     731          break;
     732        case 'modify':
     733          $this->modify_personalised($datas);
     734      }
     735    }
     736
     737    if($_POST['famm_modeedit']=='create')
     738    {
     739      $menu->register('mbAMM_personalised'.$id, ($_POST['famm_personalised_nfo']=='')?$_POST['famm_personalised_title_'.$user['language']]:$_POST['famm_personalised_nfo'], 0, 'AMM');
     740    }
     741
     742
     743
    427744  }
    428745
     
    461778    {
    462779      $returned=mysql_fetch_array($result);
     780      //$returned['label']=stripslashes($returned['label']);
    463781    }
    464782    return($returned);
     
    496814    $numurl=$this->get_count_url();
    497815    $sql="INSERT INTO ".$this->tables['urls']." (id, label, url, mode, icon, position, visible)
    498           VALUES ('', '".addslashes($datas['label'])."', '".$datas['url']."', '".$datas['mode']."',
     816          VALUES ('', '".$datas['label']."', '".$datas['url']."', '".$datas['mode']."',
    499817                  '".$datas['icon']."', '".$numurl."', '".$datas['visible']."')";
    500818    return(pwg_query($sql));
     
    504822  private function modify_url($datas)
    505823  {
    506     $sql="UPDATE ".$this->tables['urls']." SET label = '".addslashes($datas['label'])."',
     824    $sql="UPDATE ".$this->tables['urls']." SET label = '".$datas['label']."',
    507825          url = '".$datas['url']."', mode = '".$datas['mode']."', icon = '".$datas['icon']."',
    508826          visible = '".$datas['visible']."'
     
    517835          WHERE id = '".$urlid."'";
    518836    return(pwg_query($sql));
     837  }
     838
     839  /* ---------------------------------------------------------------------------
     840    functions to manage sections tables
     841  --------------------------------------------------------------------------- */
     842  // protected function get_sections($only_visible=false, $lang="")
     843  // => defined in root class
     844
     845  // return properties of a given section (return each languages)
     846  private function get_personalised($section_id)
     847  {
     848    $returned=array();
     849    $sql="SELECT * FROM ".$this->tables['personalised']." WHERE id = '".$section_id."'";
     850    $result=pwg_query($sql);
     851    if($result)
     852    {
     853      while($returned[]=mysql_fetch_array($result));
     854    }
     855    return($returned);
     856  }
     857
     858  // delete a section
     859  private function delete_personalised($section_id)
     860  {
     861    $sql="DELETE FROM ".$this->tables['personalised']." WHERE id = '".$section_id."' ";
     862    return(pwg_query($sql));
     863  }
     864
     865  // add a section
     866  private function add_personalised($datas)
     867  {
     868    $sql="INSERT INTO ".$this->tables['personalised']." (id, lang, title, content, visible, nfo)
     869          VALUES ('".$datas['id']."', '".$datas['lang']."', '".$datas['title']."', '".$datas['content']."', '".$datas['visible']."', '".$datas['nfo']."')";
     870    return(pwg_query($sql));
     871  }
     872
     873  // modify a section
     874  private function modify_personalised($datas)
     875  {
     876    $sql="UPDATE ".$this->tables['personalised']." SET title = '".$datas['title']."',
     877          content = '".$datas['content']."',  visible = '".$datas['visible']."',
     878          nfo = '".$datas['nfo']."'
     879          WHERE id = '".$datas['id']."'
     880          AND lang = '".$datas['lang']."'";
     881    return(pwg_query($sql));
     882  }
     883
     884  // return the next personalised id
     885  private function get_personalised_id()
     886  {
     887    $sql='SELECT MAX(ID) FROM '.$this->tables['personalised'];
     888    $result=pwg_query($sql);
     889    if($result)
     890    {
     891      $row=mysql_fetch_row($result);
     892      if(is_array($row))
     893      {
     894        return($row[0]+1);
     895      }
     896    }
     897    return(0);
    519898  }
    520899
     
    583962
    584963  // return a html formatted list of menu's sections
    585   private function ajax_amm_section_list()
     964  private function ajax_amm_setmenu_list_section_list()
    586965  {
    587966    global $menu;
     
    615994
    616995  // move item to the specified position
    617   private function ajax_amm_section_position($urlid, $position)
     996  private function ajax_amm_setmenu_list_section_position($urlid, $position)
    618997  {
    619998    global $menu;
    620999
    6211000    $menu->register_position($urlid, $position);
    622     return($this->ajax_amm_section_list());
    623   }
    624 
    625   // move item to the specified position
    626   private function ajax_amm_section_showhide($urlid)
    627   {
    628     global $menu;
    629 
     1001    return($this->ajax_amm_setmenu_list_section_list());
     1002  }
     1003
     1004  // show/hide item to the specified position
     1005  private function ajax_amm_setmenu_list_section_showhide($urlid)
     1006  {
    6301007    $switchvisible=array('y'=>'n', 'n'=>'y');
    6311008
     
    6331010    $this->save_config();
    6341011
    635     return($this->ajax_amm_section_list());
    636   }
     1012    return($this->ajax_amm_setmenu_list_section_list());
     1013  }
     1014
     1015  // return a html formatted list of personalised sections
     1016  private function ajax_amm_personalised_list()
     1017  {
     1018    global $template, $user;
     1019    $local_tpl = new Template(AMM_PATH."admin/", "");
     1020    $local_tpl->set_filename('body_page',
     1021                  dirname($this->filelocation).'/admin/amm_personalisedlist_detail.tpl');
     1022
     1023    $template_datas['sections']=array();
     1024
     1025    $sections=$this->get_sections(false, '', false);
     1026    $is_done=array();
     1027    foreach($sections as $key => $val)
     1028    {
     1029      if(!isset($is_done[$val['id']]))
     1030      {
     1031        $template_datas['sections'][]=array(
     1032          'title' => ($val['title']!='')?$val['title']:l10n('g002_notitle'),
     1033          'edit' => $this->page_link.'&amp;fAMM_tabsheet=personnalblock&amp;action=modify&amp;fItem='.$val['id'],
     1034          'ID' => $val['id'],
     1035          'visible' => l10n('g002_yesno_'.$val['visible']),
     1036          'nfo' => $val['nfo']
     1037        );
     1038        $is_done[$val['id']]='';
     1039      }
     1040    }
     1041
     1042    $themeconf=array(
     1043      'icon_dir' => $template->get_themeconf('icon_dir')
     1044    );
     1045
     1046    $local_tpl->assign('themeconf', $themeconf);
     1047    $local_tpl->assign('datas', $template_datas);
     1048    $local_tpl->assign('plugin', array('PATH' => AMM_PATH));
     1049
     1050    return($local_tpl->parse('body_page', true));
     1051  }
     1052
     1053  // delete a section and returns a html formatted list
     1054  private function ajax_amm_personalised_delete($sectionid)
     1055  {
     1056    global $menu;
     1057
     1058    if(!$this->adviser_abort())
     1059    {
     1060      $this->delete_personalised($sectionid);
     1061      $menu->unregister('mbAMM_personalised'.$sectionid);
     1062    }
     1063    return($this->ajax_amm_personalised_list());
     1064  }
     1065
     1066
     1067
     1068
     1069  // return a html formatted list of special menu sections items
     1070  private function ajax_amm_setmenu_mod_section_list($menuname)
     1071  {
     1072    $local_tpl = new Template(AMM_PATH."admin/", "");
     1073    $local_tpl->set_filename('body_page',
     1074                  dirname($this->filelocation).'/admin/amm_sectionsmod_detail.tpl');
     1075
     1076    $template_datas = array('LIST' => array());
     1077    foreach($this->my_config[$menuname] as $key => $val)
     1078    {
     1079      $template_datas['LIST'][] = array(
     1080        'ID' => base64_encode($key),
     1081        'LABEL' => $key,
     1082        'VISIBLE' => 'g002_yesno_'.$val
     1083      );
     1084    }
     1085
     1086    $local_tpl->assign('datas', $template_datas);
     1087    $local_tpl->assign('plugin', array('PATH' => AMM_PATH));
     1088
     1089    return($local_tpl->parse('body_page', true));
     1090  }
     1091
     1092
     1093  // move item to the specified position
     1094  private function ajax_amm_setmenu_mod_section_showhide($menuname, $urlid)
     1095  {
     1096    $switchvisible=array('y'=>'n', 'n'=>'y');
     1097
     1098    $this->my_config[$menuname][base64_decode($urlid)]=$switchvisible[$this->my_config[$menuname][base64_decode($urlid)]];
     1099    $this->save_config();
     1100
     1101    return($this->ajax_amm_setmenu_mod_section_list($menuname));
     1102  }
     1103
     1104
    6371105
    6381106
  • trunk/plugins/AMenuManager/amm_install.class.inc.php

    r2466 r2468  
    4848  PRIMARY KEY  (`id`),
    4949  KEY `order_key` (`position`)
     50) ENGINE=MyISAM DEFAULT CHARSET=latin1",
     51
     52"CREATE TABLE  `".$this->tables['personalised']."` (
     53  `id` int(11) NOT NULL default '0',
     54  `lang` varchar(5) NOT NULL default '',
     55  `title` varchar(50) NOT NULL default '',
     56  `content` text NOT NULL,
     57  `visible` char(1) NOT NULL default 'y',
     58  `nfo` varchar(25) NOT NULL default '',
     59  PRIMARY KEY  (`id`,`lang`)
    5060) ENGINE=MyISAM DEFAULT CHARSET=latin1"
    51       );
     61);
    5262      //$table_def array
    5363
  • trunk/plugins/AMenuManager/amm_pip.class.inc.php

    r2466 r2468  
    5050
    5151
    52 
    5352    /*
    5453      Add a new section (links)
     
    6867      $section->set_items(array(
    6968        'LINKS' => $urls,
    70         'icons' => 'y'
     69        'icons' => $this->my_config['amm_links_show_icons']
    7170      ));
    7271      $menu->add($section->get());
    7372    }
     73
     74
     75    /*
     76      Add a new random picture section
     77    */
     78    if($this->my_config['amm_randompicture_active']=='y')
     79    {
     80      $sql="SELECT i.id as image_id, i.file as image_file, i.comment, i.path, i.tn_ext, c.id as catid, c.name, c.permalink, RAND() as rndvalue, i.name as imgname
     81FROM ".CATEGORIES_TABLE." c, ".IMAGES_TABLE." i, ".IMAGE_CATEGORY_TABLE." ic
     82WHERE c.status='public'
     83  AND c.id = ic.category_id
     84  AND ic.image_id = i.id
     85ORDER BY rndvalue
     86LIMIT 0,1
     87";
     88      $result=pwg_query($sql);
     89      if($result)
     90      {
     91        $nfo = mysql_fetch_array($result);
     92        $nfo['section']='category';
     93        $nfo['category']=array(
     94          'id' => $nfo['catid'],
     95          'name' => $nfo['name'],
     96          'permalink' => $nfo['permalink']
     97        );
     98
     99        $section = new Section('mbAMM_randompict', base64_decode($this->my_config['amm_randompicture_title'][$user['language']]), dirname(__FILE__).'/menu_templates/menubar_randompic.tpl');
     100        $section->set_items(array(
     101          'LINK' => make_picture_url($nfo),
     102          'IMG' => get_thumbnail_url($nfo),
     103          'IMGNAME' => $nfo['imgname'],
     104          'IMGCOMMENT' => $nfo['comment'],
     105          'SHOWNAME' => $this->my_config['amm_randompicture_showname'],
     106          'SHOWCOMMENT' => $this->my_config['amm_randompicture_showcomment']
     107        ));
     108        $menu->add($section->get());
     109      }
     110    }
     111
     112    /*
     113      Add personnal blocks random picture section
     114    */
     115    $sections=$this->get_sections(true);
     116
     117    if(count($sections))
     118    {
     119      $id_done=array();
     120      foreach($sections as $key => $val)
     121      {
     122        if(!isset($id_done[$val['id']]))
     123        {
     124          $section = new Section('mbAMM_personalised'.$val['id'], $val['title'], dirname(__FILE__).'/menu_templates/menubar_personalised.tpl');
     125          $section->set_items(array(
     126            'CONTENT' => stripslashes($val['content'])));
     127          $menu->add($section->get());
     128
     129          $id_done[$val['id']]="";
     130        }
     131      }
     132    }
     133
    74134
    75135    /*
     
    84144    }
    85145
     146    /*
     147      hide items from special & menu sections
     148    */
     149    foreach(array('mbMenu' => 'amm_sections_modmenu', 'mbSpecial' =>'amm_sections_modspecial') as $key0 => $val0)
     150    {
     151      $section_menu=$menu->section($key0);
     152      foreach($this->my_config[$val0] as $key => $val)
     153      {
     154        if($val=='n')
     155        {
     156          unset($section_menu['ITEMS'][$key]);
     157        }
     158      }
     159      $menu->replace($section_menu);
     160    }
     161
    86162  }
    87163
  • trunk/plugins/AMenuManager/amm_root.class.inc.php

    r2466 r2468  
    2727    parent::__construct($prefixeTable, $filelocation);
    2828
    29     $list=array('urls');
     29    $list=array('urls', 'personalised');
    3030    $this->set_tables_list($list);
    3131  }
     
    4444      'amm_links_active' => 'y',
    4545      'amm_links_title' => array(),
    46       'amm_sections_visible' => array()
     46      'amm_sections_visible' => array(),
     47      'amm_randompicture_active' => 'n',
     48      'amm_randompicture_showname' => 'n',     //n:no, o:over, u:under
     49      'amm_randompicture_showcomment' => 'n',   //n:no, o:over, u:under
     50      'amm_randompicture_title' => array(),
     51      'amm_sections_modspecial' => array(
     52        'favorite_cat' => 'y',
     53        'most_visited_cat' => 'y',
     54        'best_rated_cat' => 'y',
     55        'random_cat' => 'y',
     56        'recent_pics_cat' => 'y',
     57        'recent_cats_cat' => 'y',
     58        'calendar' => 'y'
     59      ),
     60      'amm_sections_modmenu' => array(
     61        'qsearch' => 'y',
     62        'Tags' => 'y',
     63        'Search' => 'y',
     64        'comments' => 'y',
     65        'About' => 'y',
     66        'Notification' => 'y'
     67      )
    4768    );
    4869
     
    5273      if($key=='fr_FR')
    5374      {
    54         $this->my_config['amm_links_title'][$key]='Liens';
     75        $this->my_config['amm_links_title'][$key]=base64_encode('Liens');
     76        $this->my_config['amm_randompicture_title'][$key]=base64_encode('Une image au hasard');
    5577      }
    5678      else
    5779      {
    58         $this->my_config['amm_links_title'][$key]='Links';
     80        $this->my_config['amm_links_title'][$key]=base64_encode('Links');
     81        $this->my_config['amm_randompicture_title'][$key]=base64_encode('A random picture');
    5982      }
    6083    }
     
    6790  }
    6891
     92  public function load_config()
     93  {
     94    global $menu;
     95
     96    parent::load_config();
     97
     98    $sections=$menu->registered();
     99    foreach($sections as $key => $val)
     100    {
     101      if(!isset($this->my_config['amm_sections_visible'][$key]))
     102      {
     103        $this->my_config['amm_sections_visible'][$key]='y';
     104      }
     105    }
     106   
     107  }
    69108
    70109  // return an array of urls (each url is an array)
     
    83122      while($row=mysql_fetch_array($result))
    84123      {
     124        $row['label']=stripslashes($row['label']);
    85125        $returned[]=$row;
    86126      }
     
    107147  }
    108148
     149  // return an array of sections (each section is an array)
     150  protected function get_sections($only_visible=false, $lang="", $only_with_content=true)
     151  {
     152    global $user;
     153
     154    if($lang=="")
     155    {
     156      $lang=$user['language'];
     157    }
     158
     159    $returned=array();
     160    $sql="SELECT * FROM ".$this->tables['personalised']."
     161WHERE (lang = '*' OR lang = '".$lang."') ";
     162    if($only_visible)
     163    {
     164      $sql.=" AND visible = 'y' ";
     165    }
     166    if($only_with_content)
     167    {
     168      $sql.=" AND content != '' ";
     169    }
     170    $sql.=" ORDER BY id, lang DESC ";
     171    $result=pwg_query($sql);
     172    if($result)
     173    {
     174      while($row=mysql_fetch_array($result))
     175      {
     176        $returned[]=$row;
     177      }
     178    }
     179    return($returned);
     180  }
     181
     182
    109183
    110184} // amm_root  class
  • trunk/plugins/AMenuManager/language/en_UK/plugin.lang.php

    r2466 r2468  
    3939
    4040$lang['g002_configlinks'] = 'Links settings';
    41 $lang['g002_setting_link_block_menu'] = 'Menu integration';
    4241$lang['g002_setting_link_links']='Links';
    4342$lang['g002_setting_link_show_icon'] = 'Display links representative picture';
    44 $lang['g002_setting_link_block_active'] = 'Display block in menu';
    45 $lang['g002_setting_link_block_title'] = 'Block title';
     43
     44$lang['g002_setting_block_menu'] = 'Menu integration';
     45$lang['g002_setting_block_active'] = 'Display block in menu';
     46$lang['g002_setting_block_title'] = 'Block title';
    4647$lang['g002_apply'] = 'Apply';
    4748
     
    5556$lang['g002_name'] = 'Label';
    5657
     58$lang['g002_translate'] = 'Translate with Google Translate';
     59
     60$lang['g002_configrandompic'] = 'Random picture settings';
     61$lang['g002_setting_randompic_aboutpicture'] = 'Displayed datas';
     62$lang['g002_setting_randompic_showname'] = 'Show picture\'s name';
     63$lang['g002_setting_randompic_showcomment'] = 'Show picure\'s comment';
     64$lang['g002_show_n'] = 'No';
     65$lang['g002_show_o'] = 'Display over the picture';
     66$lang['g002_show_u'] = 'Display under thpicture';
     67
     68$lang['g002_personalisedlist'] = "Liste of personalised blocks";
     69$lang['g002_notitle'] = '[No title]';
     70$lang['g002_title'] = 'Title';
     71$lang['g002_sections'] = 'blocks';
     72$lang['g002_section'] = 'block';
     73$lang['g002_nosections'] = 'No blocks';
     74$lang['g002_addsection'] = 'Add a new block';
     75$lang['g002_createofpersonalised'] = 'Create a new personalized block';
     76$lang['g002_editofpersonalised'] = 'Modify a personalized block';
     77$lang['g002_setting_block_langchoice'] = 'Lang choice';
     78$lang['g002_setting_personalised_content'] = 'Block\'s content';
     79$lang['g002_setting_personalised_properties'] = 'Properties';
     80$lang['g002_setting_personalised_nfo'] = 'Description';
     81
     82$lang['g002_all_languages'] = "All languages";
     83
     84$lang['g002_modmenu'] = '\'menu\' block';
     85$lang['g002_modspecial'] = '\'special\' block';
     86$lang['g002_labelmenu'] = 'Menu\'s label';
     87
    5788
    5889?>
  • trunk/plugins/AMenuManager/language/fr_FR/plugin.lang.php

    r2466 r2468  
    1616$lang['g002_addlinks_nfo'] = 'Section permettant d\'afficher dans le menu une liste d\'hyperliens vers d\'autres sites internet';
    1717$lang['g002_randompict_nfo'] = 'Section permettant d\'afficher dans le menu une image prise au hasard dans la gallerie';
    18 $lang['g002_personnalblock_nfo'] = 'Afficher dans le menu des sections au contenu personnalisés';
     18$lang['g002_personnalblock_nfo'] = 'Afficher dans le menu des sections au contenu personnalisé';
    1919
    2020
     
    3939
    4040$lang['g002_configlinks'] = 'Configuration des liens';
    41 $lang['g002_setting_link_block_menu'] = 'Intégration dans le menu';
    4241$lang['g002_setting_link_links']='Liens';
    4342$lang['g002_setting_link_show_icon'] = 'Afficher les icônes de liens';
    44 $lang['g002_setting_link_block_active'] = 'Afficher la section dans le menu';
    45 $lang['g002_setting_link_block_title'] = 'Titre de la section dans le menu';
     43
     44$lang['g002_setting_block_menu'] = 'Intégration dans le menu';
     45$lang['g002_setting_block_active'] = 'Afficher la section dans le menu';
     46$lang['g002_setting_block_title'] = 'Titre de la section dans le menu';
    4647$lang['g002_apply'] = 'Appliquer';
    4748
     
    5556$lang['g002_name'] = 'Libellé';
    5657
     58$lang['g002_translate'] = 'Traduire avec Google Translate';
     59
     60$lang['g002_configrandompic'] = 'Configuration de l\'image aléatoire';
     61$lang['g002_setting_randompic_aboutpicture'] = 'Données affichées';
     62$lang['g002_setting_randompic_showname'] = 'Afficher le nom de la photo';
     63$lang['g002_setting_randompic_showcomment'] = 'Afficher le commentaire de la photo';
     64$lang['g002_show_n'] = 'Non';
     65$lang['g002_show_o'] = 'Afficher au-dessus de la photo';
     66$lang['g002_show_u'] = 'Afficher en-dessous de la photo';
     67
     68$lang['g002_personalisedlist'] = "Liste des sections personnalisées";
     69$lang['g002_notitle'] = '[Pas de titre]';
     70$lang['g002_title'] = 'Titre';
     71$lang['g002_sections'] = 'sections';
     72$lang['g002_section'] = 'section';
     73$lang['g002_nosections'] = 'Pas de sections';
     74$lang['g002_addsection'] = 'Ajouter une section';
     75$lang['g002_createofpersonalised'] = 'Ajout d\'une section personnalisée';
     76$lang['g002_editofpersonalised'] = 'Modification d\'une section personnalisée';
     77$lang['g002_setting_block_langchoice'] = 'Choix de la langue';
     78$lang['g002_setting_personalised_content'] = 'Contenu de la section';
     79$lang['g002_setting_personalised_properties'] = 'Propriétés';
     80$lang['g002_setting_personalised_nfo'] = 'Description';
     81
     82$lang['g002_all_languages'] = "Toutes langues";
     83
     84$lang['g002_modspecial'] = 'Section \'speciale\'';
     85$lang['g002_modmenu'] = 'Section \'menu\'';
     86$lang['g002_labelmenu'] = 'Libellé du menu';
    5787
    5888?>
  • trunk/plugins/grum_plugins_classes-2/google_translate.js

    r2466 r2468  
    1313  ------------------------------------------------------------------------------
    1414  HISTORY VERSION
    15   v2.0.0  +
     15  v2.0.0  + adapted for piwigo
     16          + add of a 5th&6th parameters for the google_translate function
    1617             
    1718   -------------------------------------------------------------------------- */
     
    2223  var global_google_translate_plugin_objdest;
    2324  var global_google_translate_plugin_objproperty;
     25  var global_google_translate_plugin_objcallback;
     26  var global_google_translate_plugin_objcallback_param;
    2427
    2528
    2629  function google_translate(text, pfrom, pto, objdest, objproperty)
    2730  {
     31    /*
     32      ** args needed **
     33      1st arg : text to translate
     34      2nd arg : translate from lang ("en", "fr", "es", ...)
     35      3rd arg : translate to lang ("en", "fr", "es", ...)
     36      4th arg : target of result (id)
     37      5th arg : affected propertie ('value' or 'innerHTML')
     38      ** facultative args **
     39      6th arg : pointer on a function definition (callback is made when
     40                translation is done ; notice that translation is made asynchronous)
     41      7th arg : arg for the callback (or array of arg if callbakc need more than
     42                one parameter)
     43    */
     44    if(arguments.length>=6)
     45    {
     46      global_google_translate_plugin_objcallback=arguments[5];
     47    }
     48    else
     49    {
     50      global_google_translate_plugin_objcallback=null;
     51    }
     52
     53    if(arguments.length>=7)
     54    {
     55      if(arguments[6].pop)
     56      {
     57        global_google_translate_plugin_objcallback_param=arguments[6];
     58      }
     59      else
     60      {
     61        global_google_translate_plugin_objcallback_param=new Array(arguments[6]);
     62      }
     63    }
     64    else
     65    {
     66      global_google_translate_plugin_objcallback_param=null;
     67    }
     68
     69
    2870    global_google_translate_plugin_objdest = objdest;
    2971    global_google_translate_plugin_objproperty = objproperty;
    3072    google.language.translate(text, pfrom, pto, google_translate_do);
    3173  }
     74
    3275
    3376  function google_translate_do(result)
     
    4386        global_google_translate_plugin_objdest.innerHTML = result.translation;
    4487      }
     88      if(global_google_translate_plugin_objcallback!=null)
     89      {
     90        if(global_google_translate_plugin_objcallback_param!=null)
     91        {
     92          global_google_translate_plugin_objcallback.apply(null, global_google_translate_plugin_objcallback_param);
     93        }
     94        else
     95        {
     96          global_google_translate_plugin_objcallback();
     97        }
     98      }
    4599    }   
    46100  }
  • trunk/plugins/test_menu/menu.class.inc.php

    r2466 r2468  
    22
    33/* -----------------------------------------------------------------------------
    4   class name: menu, blocks
    5   class version: 1.0
    6   date: 2008-07-25
     4  classes names : menu, section
     5  class version : 1.0
     6  date : 2008-07-25
    77
    88  ------------------------------------------------------------------------------
     
    5757    registered()
    5858    apply()
     59    get_registered_filename()
    5960 
    6061  How to use Menu class :
     
    100101  protected $registered_file="registered.dat";
    101102
    102   public function Menu()
    103   {
     103  public function Menu($registered_path='')
     104  {
     105    if($registered_path!='')
     106    {
     107      $this->registered_file=$registered_path.$this->registered_file;
     108    }
    104109    $this->load_registered();
    105110  }
     
    108113    public functions
    109114  */
     115  public function get_registered_filename()
     116  {
     117    // return filename of file for maintain of registered sections
     118    return($this->registered_file);
     119  }
     120
    110121  public function add($section_datas)
    111122  {
  • trunk/plugins/test_menu/menu_templates/menubar_menu.tpl

    r2466 r2468  
    33<dt>{$section.NAME|@translate}</dt>
    44<dd>
    5   <form action="{$ROOT_URL}qsearch.php" method="get" id="quicksearch">
    6     <p>
    7       <input type="text" name="q" id="qsearchInput" onfocus="if (value==qsearch_prompt) value='';" onblur="if (value=='') value=qsearch_prompt;" />
    8     </p>
    9   </form>
    10   <script type="text/javascript">var qsearch_prompt="{'qsearch'|@translate|@escape:'javascript'}"; document.getElementById('qsearchInput').value=qsearch_prompt;</script>
     5  {if isset($section.ITEMS.qsearch) and $section.ITEMS.qsearch=='y'}
     6    <form action="{$ROOT_URL}qsearch.php" method="get" id="quicksearch">
     7      <p>
     8        <input type="text" name="q" id="qsearchInput" onfocus="if (value==qsearch_prompt) value='';" onblur="if (value=='') value=qsearch_prompt;" />
     9      </p>
     10    </form>
     11    <script type="text/javascript">var qsearch_prompt="{'qsearch'|@translate|@escape:'javascript'}"; document.getElementById('qsearchInput').value=qsearch_prompt;</script>
     12  {/if}
    1113
    1214  <ul>
    1315  {foreach from=$section.ITEMS item=sum}
    14     <li><a href="{$sum.U_SUMMARY}" title="{$sum.TITLE}" {if isset($sum.REL)}{$sum.REL}{/if}>{$sum.NAME}</a></li>
     16    {if is_array($sum)}
     17      <li><a href="{$sum.U_SUMMARY}" title="{$sum.TITLE}" {if isset($sum.REL)}{$sum.REL}{/if}>{$sum.NAME}</a></li>
     18    {/if}
    1519  {/foreach}
    1620  </ul>
  • trunk/plugins/test_menu/menubar.inc.php

    r2466 r2468  
    111111
    112112//---------------------------------------------------------- special categories
    113 // favorites categories
     113/*
     114  ** note for usage with Menu class **
     115  items of Special section are defined with a named key rather than a
     116  numeric key
     117
     118  Example :
     119    $datas['special']=array(
     120      'favorite_cat' => array( ... ),
     121      'most_visited_cat' => array( ... ),
     122      'best_rated_cat' => array( ... ),
     123      [...]
     124    );
     125
     126  This permits to easily find datas and modify content with a callback on the
     127  'loc_begin_menubar' event.
     128
     129  Example :
     130    $section_special=$menu->section('mbSpecial');
     131    unset($section['ITEMS']['favorite_cat']);
     132    $menu->replace($section_special);
     133
     134    this code permit to remove the items "favorite_cat" from the
     135    section "mbSpecial"
     136*/
    114137$datas['special']=array();
    115138if ( !is_a_guest() )
     
    214237
    215238//--------------------------------------------------------------- menu summaries
     239/*
     240  ** note for usage with Menu class **
     241  items of menu section are defined with a named key rather than a numeric key
     242
     243  see notes from "sepcial categories" for more informations
     244*/
    216245$datas['menu']=array();
     246//qsearch input zone visible y/n ; if set to 'n' the qsearch zone isn't visible
     247$datas['menu']['qsearch']='y';
     248
    217249// tags link
    218 $datas['menu']['tags']=array(
     250$datas['menu']['Tags']=array(
    219251    'TITLE' => l10n('See available tags'),
    220252    'NAME' => l10n('Tags'),
     
    223255
    224256// search link
    225 $datas['menu']['search']=array(
     257$datas['menu']['Search']=array(
    226258    'TITLE'=>l10n('hint_search'),
    227259    'NAME'=>l10n('Search'),
     
    238270
    239271// about link
    240 $datas['menu']['about']=array(
     272$datas['menu']['About']=array(
    241273    'TITLE'     => l10n('about_page_title'),
    242274    'NAME'      => l10n('About'),
     
    245277
    246278// notification
    247 $datas['menu']['notification']=array(
     279$datas['menu']['Notification']=array(
    248280    'TITLE'=>l10n('RSS feed'),
    249281    'NAME'=>l10n('Notification'),
Note: See TracChangeset for help on using the changeset viewer.