Changeset 8962


Ignore:
Timestamp:
Jan 28, 2011, 5:10:45 PM (13 years ago)
Author:
grum
Message:

release 3.0.0
fix bug:1716, bug:2128, bug:1296, bug:2052, bug:1910, bug:1723, bug:1709, bug:1680, bug:1477, bug:2129
rewrite plugin core, implement ajax interface, optimize JS

Location:
extensions/AMenuManager
Files:
25 added
19 edited

Legend:

Unmodified
Added
Removed
  • extensions/AMenuManager/admin/amm_admin.tpl

    r5421 r8962  
    11<h2 style="float:right;top:-24px;position:relative;height:auto;font-size:12px;font-weight:normal;">{$plugin.AMM_VERSION}</h2>
    22
    3 <div style="position:relative;top:-24px;clear:right;">
    4   {if isset($page_nfo)}
    5   <p>{$page_nfo}</p>
     3<div class='helps'>
     4  {if isset($pageNfo)}
     5  <p>{$pageNfo}</p>
    66  {/if}
     7</div>
     8
     9<div id='iBDProcessing' style="display:none;position:absolute;left:0;top:0;width:100%;height:100%;background:#000000;opacity:0.75;z-index:800;">
     10  <img src="plugins/GrumPluginClasses/icons/processing.gif" style="margin-top:20%;">
     11</div>
     12
     13<div id='iConfigState' style='display:none;'>
    714</div>
    815
  • extensions/AMenuManager/admin/amm_linksconfig.tpl

    r3681 r8962  
    11{literal}
    22<script type="text/javascript">
     3  var ulc;
    34
    4   //global var ; need to not have to initialize them every time a value is changed
    5   var objlang;
    6   var objnames = new Array('iamm_links_title');
    7   var objinput = new Array();   //input text from form => objinput[name]
    8   var objhidden = new Array();  //input hidden from form => objhidden[name][lang]
    9 
    10   function init()
    11   {
    12     objlang = document.getElementById('islang');
    13     for(i=0;i<objnames.length;i++)
     5  $(window).load(
     6    function ()
    147    {
    15       objinput[i] = document.getElementById(objnames[i]);
    16       objhidden[i] = new Array();
    17       for(j=0;j<objlang.options.length;j++)
    18       {
    19         objhidden[i][j] = document.getElementById(objnames[i]+'_'+objlang.options[j].value);
    20       }
     8      ulc=new userLinksConfig(
     9        {}, {},
     10        '{/literal}{$token}{literal}',
     11        {
     12          'showIcons':'{/literal}{$datas.config.showIcons}{literal}',
     13          'userLang':'{/literal}{$datas.selectedLang}{literal}',
     14          'titles':
     15            {
     16            {/literal}
     17            {foreach from=$datas.config.titles name=items key=langCode item=title}
     18              "{$langCode}":"{$title}"{if !$smarty.foreach.items.last},{/if}
     19            {/foreach}
     20            {literal}
     21            },
     22          'langs':[
     23              {/literal}
     24              {foreach from=$datas.config.titles name=items key=langCode item=title}
     25                "{$langCode}"{if !$smarty.foreach.items.last},{/if}
     26              {/foreach}
     27              {literal}
     28            ]
     29        }
     30      );
    2131    }
    22   }
    23 
    24   function change_lang()
    25   {
    26     for(i=0;i<objnames.length;i++)
    27     {
    28       objinput[i].value = objhidden[i][objlang.options.selectedIndex].value;
    29     }
    30   }
    31 
    32   function apply_changes(input_id)
    33   {
    34     var obj=document.getElementById(input_id);
    35     objhidden[objnames.indexOf(input_id)][objlang.options.selectedIndex].value = obj.value;
    36   }
    37 
    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 
     32  );
    4733</script>
    4834{/literal}
    4935
     36<form method="post" action="" class="general">
    5037
    51 
    52 <h3><span style="font-weight:normal"><a href="{$datas.lnk_list}" title="{'g002_configlinks'|@translate}">{'g002_linkslist'|@translate} </span></a> / {'g002_configlinks'|@translate}
    53 </h3>
    54 
    55 
    56 <form method="post" action="" class="general">
    5738  <fieldset>
    5839    <legend>{'g002_setting_block_menu'|@translate}</legend>
    59 
    60     {if isset($datas.language_list) and count($datas.language_list)}
    61       {foreach from=$datas.language_list key=name item=language_row}
    62         <input type="hidden" name="famm_links_title_{$language_row.LANG}"
    63                 id="iamm_links_title_{$language_row.LANG}" value="{$language_row.MENUBARTIT}">
    64       {/foreach}
    65     {/if}
    6640
    6741    <table class="formtable">
     
    6943        <td>{'g002_setting_block_title'|@translate}</td>
    7044        <td>
    71           <input type="text" id="iamm_links_title" value="" maxlength="50" onkeyup="apply_changes('iamm_links_title');" onblur="apply_changes('iamm_links_title');"/>
    72           <select onchange="change_lang();" id="islang">
    73             {html_options values=$datas.language_list_values output=$datas.language_list_labels selected=$datas.lang_selected}
    74           </select><br>
     45          <div id="iamm_links_title"></div>
     46          <div id="islang">
     47            [
     48            {foreach from=$datas.langs key=langCode item=langLabel name=items}
     49              {ldelim}"value":"{$langCode}","cols":["{$langLabel}"]{rdelim}{if !$smarty.foreach.items.last},{/if}
     50            {/foreach}
     51            ]
     52          </div>
    7553        </td>
    7654      </tr>
     
    7856        <td></td>
    7957        <td style="font-size:80%;">
    80           <a style="cursor:pointer;" onclick="do_translation()">{'g002_translate'|@translate}</a>
     58          <a style="cursor:pointer;" onclick="$('#iamm_links_title').inputText('doTranslation');">{'g002_translate'|@translate}</a>
    8159        </td>
    8260      </tr>
    8361
    8462    </table>
    85 
    86 
    8763  </fieldset>
    8864
     
    9369        <td>{'g002_setting_link_show_icon'|@translate}</td>
    9470        <td>
    95           <select name="famm_links_show_icons" id="iamm_links_show_icons">
    96             {html_options values=$datas.yesno_values output=$datas.yesno_labels selected=$datas.show_icons_selected}
    97           </select>
     71          <div id='iamm_links_show_icons'>
     72            <label><input type="radio" value="y">&nbsp;{'g002_yesno_y'|@translate}<br></label>
     73            <label><input type="radio" value="n">&nbsp;{'g002_yesno_n'|@translate}</label>
     74          </div>
    9875        </td>
    9976      </tr>
     
    10279
    10380  <p>
    104     <input type="submit" name="famm_submit_apply" id="iamm_submit_apply" value="{'g002_apply'|@translate}" >
     81    <input type="button" id="iamm_submit_apply" value="{'g002_apply'|@translate}" onclick="ulc.submit();">
    10582  </p>
    106 
    107   <input type="hidden" name="famm_modeedit" value="config">
    10883
    10984</form>
    11085
    111 <script type="text/javascript">
    112   init();
    113   change_lang();
    114 </script>
  • extensions/AMenuManager/admin/amm_randompicconfig.tpl

    r5545 r8962  
    1 {known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js"}
    2 {known_script id="jquery.ui.slider" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.slider.packed.js"}
    3 
    41{literal}
    52<style>
    63 .ui-slider {
    7     width:350px;
     4    width:360px;
    85    height:10px;
    96    border-width:1px;
     
    2219  }
    2320</style>
     21
    2422<script type="text/javascript">
     23  var rpc;
    2524
    26   //global var ; need to not have to initialize them every time a value is changed
    27   var objlang;
    28   var objnames = new Array('iamm_randompicture_title');
    29   var objinput = new Array();   //input text from form => objinput[name]
    30   var objhidden = new Array();  //input hidden from form => objhidden[name][lang]
    31 
    32   function init()
    33   {
    34     objlang = document.getElementById('islang');
    35     for(i=0;i<objnames.length;i++)
     25  $(window).load(
     26    function ()
    3627    {
    37       objinput[i] = document.getElementById(objnames[i]);
    38       objhidden[i] = new Array();
    39       for(j=0;j<objlang.options.length;j++)
    40       {
    41         objhidden[i][j] = document.getElementById(objnames[i]+'_'+objlang.options[j].value);
    42       }
     28      rpc=new randomPictConfig(
     29        {},
     30        {
     31          g002_setting_randompic_periodicchange_deactivated:"{/literal}{'g002_setting_randompic_periodicchange_deactivated'|@translate}{literal}",
     32          g002_setting_randompic_height_auto:"{/literal}{'g002_setting_randompic_height_auto'|@translate}{literal}"
     33        },
     34        '{/literal}{$token}{literal}',
     35        {
     36          'selectMode':"{/literal}{$datas.config.selectMode}{literal}",
     37          'selectCat':{/literal}{$datas.config.selectCat}{literal},
     38          'infosName':"{/literal}{$datas.config.infosName}{literal}",
     39          'infosComment':"{/literal}{$datas.config.infosComment}{literal}",
     40          'freqDelay':"{/literal}{$datas.config.freqDelay}{literal}",
     41          'blockHeight':"{/literal}{$datas.config.blockHeight}{literal}",
     42          'blockTitles':
     43            {
     44            {/literal}
     45            {foreach from=$datas.config.blockTitles name=items key=langCode item=title}
     46              "{$langCode}":"{$title}"{if !$smarty.foreach.items.last},{/if}
     47            {/foreach}
     48            {literal}
     49            },
     50          'userLang':'{/literal}{$datas.selectedLang}{literal}',
     51          'langs':[
     52              {/literal}
     53              {foreach from=$datas.config.blockTitles name=items key=langCode item=title}
     54                "{$langCode}"{if !$smarty.foreach.items.last},{/if}
     55              {/foreach}
     56              {literal}
     57            ]
     58        }
     59      );
    4360    }
    44 
    45     formatDelay({/literal}{$datas.periodic_change}{literal});
    46     $("#iamm_rp_pc_slider").slider(
    47       {
    48         min:0,
    49         max:60000,
    50         steps:120,
    51         value:{/literal}{$datas.periodic_change}{literal},
    52         slide: function(event, ui) { formatDelay(ui.value); }
    53       });
    54     $("#iamm_rp_pc_slider a").addClass('gcBgInput');
    55 
    56     formatHeight({/literal}{$datas.height}{literal});
    57     $("#iamm_rp_height_slider").slider(
    58       {
    59         min:99,
    60         max:300,
    61         steps:201,
    62         value:affectHeight({/literal}{$datas.height}{literal}),
    63         slide: function(event, ui) { formatHeight(ui.value); }
    64       });
    65     $("#iamm_rp_height_slider a").addClass('gcBgInput');
    66   }
    67 
    68   function formatDelay(delay)
    69   {
    70     $("#iamm_randompicture_periodicchange").val(delay);
    71     if(delay==0)
    72     {
    73       $("#iamm_rp_pc_display").html("{/literal}{'g002_setting_randompic_periodicchange_deactivated'|@translate}{literal}");
    74     }
    75     else
    76     {
    77       $("#iamm_rp_pc_display").html((delay/1000).toFixed(2)+"s");
    78     }
    79   }
    80 
    81   function formatHeight(height)
    82   {
    83     (height==99)?vheight=0:vheight=height;
    84 
    85     $("#iamm_randompicture_height").val(vheight);
    86     if(vheight==0)
    87     {
    88       $("#iamm_rp_height_display").html("{/literal}{'g002_setting_randompic_height_auto'|@translate}{literal}");
    89     }
    90     else
    91     {
    92       $("#iamm_rp_height_display").html(vheight+"px");
    93     }
    94   }
    95 
    96   function affectHeight(height)
    97   {
    98     if(height==0)
    99     {return(0);}else{return(height);}
    100   }
    101 
    102   function change_lang()
    103   {
    104     for(i=0;i<objnames.length;i++)
    105     {
    106       objinput[i].value = objhidden[i][objlang.options.selectedIndex].value;
    107     }
    108   }
    109 
    110   function apply_changes(input_id)
    111   {
    112     var obj=document.getElementById(input_id);
    113     objhidden[objnames.indexOf(input_id)][objlang.options.selectedIndex].value = obj.value;
    114   }
    115 
    116   function do_translation()
    117   {
    118     var inputid = document.getElementById('iamm_randompicture_title');
    119     var tolang = objlang.options[objlang.options.selectedIndex].value.substr(0,2);
    120 
    121     google_translate(inputid.value, '{/literal}{$datas.fromlang}{literal}', tolang, inputid, 'value', apply_changes, inputid.id);
    122 
    123   }
    124 
     61  );
    12562
    12663</script>
    12764{/literal}
    12865
     66<div id='iBDProcessing' style="display:none;position:absolute;left:0;top:0;width:100%;height:100%;background:#000000;opacity:0.75;z-index:800;">
     67  <img src="plugins/GrumPluginClasses/icons/processing.gif" style="margin-top:20%;">
     68</div>
    12969
    130 
    131 <h3>{'g002_configrandompic'|@translate}</h3>
    132 
     70<div id='iConfigState' style='display:none;'>
     71</div>
    13372
    13473<form method="post" action="" class="general">
     
    13675    <legend>{'g002_setting_block_menu'|@translate}</legend>
    13776
    138     {if isset($datas.language_list) and count($datas.language_list)}
    139       {foreach from=$datas.language_list key=name item=language_row}
    140         <input type="hidden" name="famm_randompicture_title_{$language_row.LANG}"
    141                 id="iamm_randompicture_title_{$language_row.LANG}" value="{$language_row.MENUBARTIT}">
    142       {/foreach}
    143     {/if}
    144 
    14577    <table class="formtable">
    14678      <tr>
    14779        <td>{'g002_setting_block_title'|@translate}</td>
    14880        <td colspan="2">
    149           <input type="text" id="iamm_randompicture_title" value="" maxlength="50" onkeyup="apply_changes('iamm_randompicture_title');" onblur="apply_changes('iamm_randompicture_title');"/>
    150           <select onchange="change_lang();" id="islang">
    151             {html_options values=$datas.language_list_values output=$datas.language_list_labels selected=$datas.lang_selected}
    152           </select><br>
     81          <div id="iamm_randompicture_title"></div>
     82
     83          <div id="islang">
     84            [
     85            {foreach from=$datas.langs key=langCode item=langLabel name=items}
     86              {ldelim}"value":"{$langCode}","cols":["{$langLabel}"]{rdelim}{if !$smarty.foreach.items.last},{/if}
     87            {/foreach}
     88            ]
     89          </div>
    15390        </td>
    15491      </tr>
     92
    15593      <tr>
    15694        <td></td>
    15795        <td style="font-size:80%;" colspan="2">
    158           <a style="cursor:pointer;" onclick="do_translation()">{'g002_translate'|@translate}</a>
     96          <a style="cursor:pointer;" onclick="$('#iamm_randompicture_title').inputText('doTranslation');">{'g002_translate'|@translate}</a>
    15997        </td>
    16098      </tr>
     
    163101        <td>{'g002_setting_randompic_height'|@translate}</td>
    164102        <td>
    165           <input type="hidden" name="famm_randompicture_height" id="iamm_randompicture_height" value="{$datas.height}">
    166103          <div id="iamm_rp_height_slider" class="gcBgInput gcBorderInput"></div>
    167104        </td>
     
    178115  <fieldset>
    179116    <legend>{'g002_setting_randompic_aboutpicture'|@translate}</legend>
    180       <table class="formclass">
     117      <table class="formtable">
    181118        <tr>
    182119          <td>{'g002_setting_randompic_showname'|@translate}</td>
    183120          <td>
    184             <select name="famm_randompicture_showname" id="iamm_randompicture_showname">
    185               {html_options values=$datas.show_values output=$datas.show_labels selected=$datas.showname_selected}
    186             </select>
     121            <div id="iamm_randompicture_showname">
     122              [
     123                {ldelim}"value":"n","cols":["{'g002_show_n'|@translate}"]{rdelim},
     124                {ldelim}"value":"o","cols":["{'g002_show_o'|@translate}"]{rdelim},
     125                {ldelim}"value":"u","cols":["{'g002_show_u'|@translate}"]{rdelim}
     126              ]
     127            </div>
    187128          </td>
    188129        </tr>
     
    191132          <td>{'g002_setting_randompic_showcomment'|@translate}</td>
    192133          <td>
    193             <select name="famm_randompicture_showcomment" id="iamm_randompicture_showcomment">
    194               {html_options values=$datas.show_values output=$datas.show_labels selected=$datas.showcomment_selected}
    195             </select>
     134            <div id="iamm_randompicture_showcomment">
     135              [
     136                {ldelim}"value":"n","cols":["{'g002_show_n'|@translate}"]{rdelim},
     137                {ldelim}"value":"o","cols":["{'g002_show_o'|@translate}"]{rdelim},
     138                {ldelim}"value":"u","cols":["{'g002_show_u'|@translate}"]{rdelim}
     139              ]
     140            </div>
    196141          </td>
    197142        </tr>
     
    203148  <fieldset>
    204149    <legend>{'g002_setting_randompic_periodicchange'|@translate}</legend>
    205       <table class="formclass">
     150      <table class="formtable">
    206151        <tr>
    207152          <td>{'g002_setting_randompic_periodicchange_delay'|@translate}</td>
    208153          <td>
    209             <input type="hidden" name="famm_randompicture_periodicchange" id="iamm_randompicture_periodicchange" value="{$datas.periodic_change}">
    210154            <div id="iamm_rp_pc_slider" class="gcBgInput gcBorderInput"></div>
    211155          </td>
     
    214158          </td>
    215159        </tr>
     160      </table>
     161  </fieldset>
    216162
    217163
     164  <fieldset>
     165    <legend>{'g002_selectedpict'|@translate}</legend>
     166      <table class="formtable">
     167        <tr>
     168          <td>
     169            <div id='iamm_randompicture_selectedMode'>
     170              <label><input type="radio" value="a">&nbsp;{'g002_selected_all_gallery'|@translate}<br></label>
     171              <label><input type="radio" value="f">&nbsp;{'g002_selected_favorites_wm'|@translate}<br></label>
     172              <label><input type="radio" value="c">&nbsp;{'g002_selected_categories'|@translate}<br></label>
     173                <div id='iamm_randompicture_selectedCat'></div>
     174            </div>
     175          </td>
     176        </tr>
    218177      </table>
    219178  </fieldset>
    220179
    221180  <p>
    222     <input type="submit" name="famm_submit_apply" id="iamm_submit_apply" value="{'g002_apply'|@translate}" >
     181    <input type="button" id="iamm_submit_apply" value="{'g002_apply'|@translate}" onclick="rpc.submit();">
    223182  </p>
    224183
    225   <input type="hidden" name="famm_modeedit" value="config">
    226184
    227185</form>
    228 
    229 <script type="text/javascript">
    230   init();
    231   change_lang();
    232 </script>
  • extensions/AMenuManager/admin/plugin_admin.php

    r5545 r8962  
    33  Plugin     : Advanced Menu Manager
    44  Author     : Grum
    5     email    : grum@grum.dnsalias.com
     5    email    : grum@piwigo.org
    66    website  : http://photos.grum.dnsalias.com
    77    PWG user : http://forum.phpwebgallery.net/profile.php?id=3706
  • extensions/AMenuManager/amm.css

    r4389 r8962  
     1#iHeaderList { width:100%; border:1px solid; border-collapse: collapse; margin-top:3px; }
     2div#iList { width:100%; border:1px solid; height:280px; border-top:0px; overflow:auto; position:relative; left:-1px;}
     3#iListNb { width:99%; text-align:right; margin-bottom:8px; padding:2px; font-size:80%; }
     4
     5#iList table, table.listLinks { width:100%; text-align:left; border-collapse: collapse; }
     6
     7div#iList.roma table tr:hover { background:#303030; }
     8div#iList.clear table tr:hover { color: #D54E21; background:#dbe8f3; }
     9#iList table tr.connectedSortable,
     10#iList li.connectedSortable { cursor: move; }
     11#iList table tr.alignTop { vertical-align:top; }
     12
     13div.addLink, div.addBlock { text-align:left; }
     14
     15img.button { cursor:pointer; }
     16
     17
    118
    219.littlefont { font-size:90%; }
     
    421table.littlefont td { text-align:left; padding:0px;padding-left:3px;padding-right:3px; }
    522
    6 .containerMenuSection { width:250px;  margin:auto; padding:10px; display:inline-block; vertical-align:top; }
    7 li.menuItem { padding:4px; width:230px; cursor:move;}
     23.containerMenuBlock { width:250px;  margin:auto; padding:10px; display:inline-block; vertical-align:top; }
     24li.menuItem { padding:0px; cursor:move; border:none; }
     25li.menuItem div { padding:4px; width:auto; min-height: 19px;}
     26li.menuItem div.visibility { overflow:hidden;display:none;padding-left:20px; }
    827li.menuItemDisabled { cursor:defaut;}
    9 div.visibility { width:100%;overflow:hidden;display:none;margin-left:30px; }
    1028
    1129div.visibility p { margin:0px; }
    1230div.visibility input { margin-right:8px; }
    1331div.visibility h3 { position:relative; font-size:14px; height:auto; margin:5px 0px 0px;padding:0px;text-align:left;}
     32
     33
     34.ui-inputList-value span.iconColImg {
     35}
     36.ui-inputList-value span.iconColImg img {
     37  float: left;
     38  margin-left: 2px;
     39}
     40.ui-inputList-value span.iconColText {
     41  position:relative;
     42  top:-2px;
     43  display:inline;
     44}
     45
     46#iamm_album_selectedCat, #iamm_randompicture_selectedCat { min-width:300px; }
     47#iamm_randompicture_selectedCat { margin-left:30px; }
     48img.visibilitySwitch { cursor:pointer; }
     49
     50#containerMenu { text-align:left; }
     51#containerMenu table { text-align:left; margin-left:0; }
     52#containerMenu table tr { vertical-align:top; }
     53#containerMenu table td.leftBar { border-left:1px dotted; }
     54#containerMenu input[type="button"] { margin-bottom:4px; }
     55
     56li.menuListItem {
     57  margin-bottom:5px;
     58  padding:3px;
     59  cursor:move;
     60  min-height:30px;
     61}
     62li.menuListItem span.menuListMove {
     63  position:absolute;
     64  width:22px;
     65  display:inline-block;
     66}
     67li.menuListItem span.menuListName {
     68  margin-left:26px;
     69  display:inline-block;
     70}
     71li.menuListItem div.menuListUsers,
     72li.menuListItem div.menuListGroups {
     73  display:inline-block;
     74  min-width:150px;
     75  width:100%;
     76  margin-right: 2px;
     77}
     78li.menuListItem .ui-inputList-value li.ui-inputList-selected-item {
     79  float:left;
     80}
     81li.menuListItem .ui-inputList-value li span.ui-inputList-delete-item {
     82  top:0;
     83}
     84li.menuListItem .ui-inputList-value span {
     85  height:13px;
     86  min-height:0px;
     87}
     88table.menuListAccess {
     89  width:100%;
     90}
     91table.menuListAccess tr {
     92  vertical-align:top;
     93}
  • extensions/AMenuManager/amm_aim.class.inc.php

    r5545 r8962  
    33  Plugin     : Advanced Menu Manager
    44  Author     : Grum
    5     email    : grum@grum.dnsalias.com
     5    email    : grum@piwigo.org
    66    website  : http://photos.grum.dnsalias.com
    77    PWG user : http://forum.phpwebgallery.net/profile.php?id=3706
     
    3333    parent::initEvents();
    3434    add_event_handler('get_admin_plugin_menu_links', array(&$this, 'pluginAdminMenu') );
     35    add_event_handler('loc_end_page_header', array(&$this, 'adminPanel'));
     36  }
     37
     38  public function adminPanel()
     39  {
     40    global $template;
     41
     42    $template->append('footer_elements', "<script>$(document).ready(function () { $('li a[href=".$template->get_template_vars('U_CONFIG_MENUBAR')."]').attr('href', '".$this->getAdminLink()."&amp;fAMM_tabsheet=setmenu&amp;fAMM_page=position'); });</script>");
    3543  }
    3644
  • extensions/AMenuManager/amm_aip.class.inc.php

    r5545 r8962  
    33  Plugin     : Advanced Menu Manager
    44  Author     : Grum
    5     email    : grum@grum.dnsalias.com
     5    email    : grum@piwigo.org
    66    website  : http://photos.grum.fr
    77    PWG user : http://forum.phpwebgallery.net/profile.php?id=3706
     
    1919include_once(PHPWG_ROOT_PATH.'include/block.class.php');
    2020include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
    21 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php');
    22 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/genericjs.class.inc.php');
    23 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTranslate.class.inc.php');
     21include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTabSheet.class.inc.php');
     22
    2423
    2524class AMM_AIP extends AMM_root
    2625{
    27   protected $google_translate;
     26  protected $googleTranslate;
    2827  protected $tabsheet;
    29   protected $sectionsId=array('menu' => 'Menu', 'special' => 'Specials');
    30 
    31   protected $urls_modes=array(0 => 'new_window', 1 => 'current_window');
    32 
    33   function AMM_AIP($prefixeTable, $filelocation)
     28  protected $blocksId=array('menu' => 'Menu', 'special' => 'Specials');
     29
     30
     31  public function __construct($prefixeTable, $filelocation)
    3432  {
    3533    parent::__construct($prefixeTable, $filelocation);
     
    5149                          l10n('g002_personnalblock'),
    5250                          $this->getAdminLink().'&amp;fAMM_tabsheet=personnalblock');
     51    $this->tabsheet->add('album',
     52                          l10n('g002_album'),
     53                          $this->getAdminLink().'&amp;fAMM_tabsheet=album');
    5354    $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
    54     $this->google_translate = new GPCTranslate();
    55   }
    56 
    57 
    58   /* ---------------------------------------------------------------------------
    59   Public classe functions
    60   --------------------------------------------------------------------------- */
    61 
    62   /*
    63     manage plugin integration into piwigo's admin interface
    64   */
     55  }
     56
     57
     58  /**
     59   * manage plugin integration into piwigo's admin interface
     60   */
    6561  public function manage()
    6662  {
     
    6965    $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/amm_admin.tpl");
    7066
    71     $this->return_ajax_content();
    72 
    73     $this->init_request();
     67    $this->initRequest();
    7468
    7569    $this->tabsheet->select($_REQUEST['fAMM_tabsheet']);
     
    8377
    8478    $template->assign('plugin', $template_plugin);
    85 
    86 
    87     if(isset($_POST['famm_modeedit']))
    88     {
    89       $post_action=$_POST['famm_modeedit'];
    90     }
    91     else
    92     {
    93       $post_action="";
    94     }
    95 
    96     $page_nfo="";
     79    $template->assign('token', get_pwg_token());
     80
     81
     82    switch($_REQUEST['fAMM_tabsheet'])
     83    {
     84      case 'links':
     85        $this->displayLinksPage($_REQUEST['fAMM_page']);
     86        break;
     87
     88      case 'randompict':
     89        $this->displayRandompicPage();
     90        break;
     91
     92      case 'personnalblock':
     93        $this->displayPersonalisedBlockPage();
     94        break;
     95
     96      case 'setmenu':
     97        $this->displayBlocksPage($_REQUEST['fAMM_page']);
     98        break;
     99
     100      case 'album':
     101        $this->displayAlbumPage();
     102        break;
     103    }
     104
     105    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
     106  }
     107
     108
     109  /**
     110   * initialize events call for the plugin
     111   */
     112  public function initEvents()
     113  {
     114    add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS'));
     115    GPCCss::applyGpcCss();
     116  }
     117
     118
     119  /**
     120   * if empty, initialize the $_REQUEST var
     121   *
     122   * if not empty, check validity for the request values
     123   *
     124   */
     125  private function initRequest()
     126  {
     127    //initialise $REQUEST values if not defined
     128    if(!array_key_exists('fAMM_tabsheet', $_REQUEST)) $_REQUEST['fAMM_tabsheet']='setmenu';
     129
     130    if(!($_REQUEST['fAMM_tabsheet']=='links' or
     131         $_REQUEST['fAMM_tabsheet']=='randompict' or
     132         $_REQUEST['fAMM_tabsheet']=='personnalblock' or
     133         $_REQUEST['fAMM_tabsheet']=='setmenu' or
     134         $_REQUEST['fAMM_tabsheet']=='album'
     135        )
     136      ) $_REQUEST['fAMM_tabsheet']='setmenu';
     137
     138
     139    /*
     140     * checks for links page
     141     */
    97142    if($_REQUEST['fAMM_tabsheet']=='links')
    98143    {
    99       $page_nfo=l10n('g002_addlinks_nfo');
    100 
    101       switch($_REQUEST['action'])
    102       {
    103         case 'list':
    104           $this->display_links_list_page();
    105           break;
    106         case 'create':
    107         case 'modify':
    108           if($post_action==$_REQUEST['action'])
    109           {
    110             if(!$this->adviser_abort())
    111             {
    112               $this->action_create_modify_url();
    113             }
    114             $this->display_links_list_page();
    115           }
    116           else
    117           {
    118             ($_REQUEST['action']=='modify')?$urlid=$_REQUEST['fItem']:$urlid=0;
    119             $this->display_links_manage_page($_REQUEST['action'], $urlid);
    120           }
    121           break;
    122         case 'config':
    123           if($post_action==$_REQUEST['action'])
    124           {
    125             if(!$this->adviser_abort())
    126             {
    127               $this->action_links_modify_config();
    128             }
    129           }
    130           $this->display_links_config_page();
    131           break;
    132       }
    133     }
    134     elseif($_REQUEST['fAMM_tabsheet']=='randompict')
    135     {
    136       $page_nfo=l10n('g002_randompict_nfo');
    137       if($post_action=='config')
    138       {
    139         if(!$this->adviser_abort())
    140         {
    141           $this->action_randompic_modify_config();
    142         }
    143       }
    144       $this->display_randompic_config_page();
    145     }
    146     elseif($_REQUEST['fAMM_tabsheet']=='personnalblock')
    147     {
    148       $page_nfo=l10n('g002_personnalblock_nfo');
    149 
    150       switch($_REQUEST['action'])
    151       {
    152         case 'list':
    153           $this->display_personalised_list_page();
    154           break;
    155         case 'create':
    156         case 'modify':
    157           if($post_action==$_REQUEST['action'])
    158           {
    159             if(!$this->adviser_abort())
    160             {
    161               $this->action_create_modify_personalised();
    162             }
    163             $this->display_personalised_list_page();
    164           }
    165           else
    166           {
    167             ($_REQUEST['action']=='modify')?$sectionid=$_REQUEST['fItem']:$sectionid=0;
    168             $this->display_personalised_manage_page($_REQUEST['action'], $sectionid);
    169           }
    170           break;
    171       }
    172     }
    173     elseif($_REQUEST['fAMM_tabsheet']=='setmenu')
    174     {
    175       $page_nfo=l10n('g002_setmenu_nfo');
    176       $this->display_sections_page();
    177     }
    178 
    179     $template->assign('page_nfo', $page_nfo);
    180 
    181     $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
    182 
    183 
    184   }
    185 
    186   /*
    187     initialize events call for the plugin
    188   */
    189   public function initEvents()
    190   {
    191     add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS'));
    192   }
    193 
    194   /* ---------------------------------------------------------------------------
    195   Private classe functions
    196   --------------------------------------------------------------------------- */
    197 
    198   /*
    199     return ajax content
    200   */
    201   protected function return_ajax_content()
    202   {
    203     global $ajax, $template;
    204 
    205     if(isset($_REQUEST['ajaxfct']))
    206     {
    207       //$this->debug("AJAXFCT:".$_REQUEST['ajaxfct']);
    208       $result="<p class='errors'>".l10n('g002_error_invalid_ajax_call')."</p>";
    209       switch($_REQUEST['ajaxfct'])
    210       {
    211         case 'links_list':
    212           $result=$this->ajax_amm_links_list();
    213           break;
    214         case 'links_permut':
    215           $result=$this->ajax_amm_links_permut($_REQUEST['fItem'], $_REQUEST['fPermut']);
    216           break;
    217         case 'links_delete':
    218           $result=$this->ajax_amm_links_delete($_REQUEST['fItem']);
    219           break;
    220 
    221 /*
    222         case 'setmenu_modmenu_sections_list':
    223           $result=$this->ajax_amm_setmenu_mod_section_list('amm_sections_modmenu');
    224           break;
    225         case 'setmenu_modmenu_sections_showhide':
    226           $result=$this->ajax_amm_setmenu_mod_section_showhide('amm_sections_modmenu', $_REQUEST['fItem']);
    227           break;
    228 
    229         case 'setmenu_modspecial_sections_list':
    230           $result=$this->ajax_amm_setmenu_mod_section_list('amm_sections_modspecials');
    231           break;
    232         case 'setmenu_modspecial_sections_showhide':
    233           $result=$this->ajax_amm_setmenu_mod_section_showhide('amm_sections_modspecials', $_REQUEST['fItem']);
    234           break;
    235 */
    236 
    237         case 'personalised_list':
    238           $result=$this->ajax_amm_personalised_list();
    239           break;
    240         case 'personalised_delete':
    241           $result=$this->ajax_amm_personalised_delete($_REQUEST['fItem']);
    242           break;
    243       }
    244 
    245       GPCAjax::returnResult($result);
    246     }
    247   }
    248 
    249   /*
    250     if empty, initialize $_request
    251   */
    252   private function init_request()
    253   {
    254     //initialise $REQUEST values if not defined
    255     if(!array_key_exists('fAMM_tabsheet', $_REQUEST))
    256     {
    257       $_REQUEST['fAMM_tabsheet']='setmenu';
    258     }
    259 
    260     if((($_REQUEST['fAMM_tabsheet']=='links') or
    261         ($_REQUEST['fAMM_tabsheet']=='personnalblock')) and !isset($_REQUEST['action']))
    262     {
    263       $_REQUEST['action']='list';
    264     }
    265     elseif((($_REQUEST['fAMM_tabsheet']=='setmenu')) and !isset($_REQUEST['action']))
    266     {
    267       $_REQUEST['action']='modmenu';
    268     }
    269 
    270 
    271 
    272   } //init_request
    273 
    274 
    275   /*
    276     manage display for urls table page
    277   */
    278   private function display_links_list_page()
     144      if(!isset($_REQUEST['fAMM_page'])) $_REQUEST['fAMM_page']='links';
     145
     146      if(!($_REQUEST['fAMM_page']=='links' or
     147           $_REQUEST['fAMM_page']=='config'
     148          )
     149        ) $_REQUEST['fAMM_page']='config';
     150    }
     151
     152
     153    /*
     154     * checks for blocks menu page
     155     */
     156    if($_REQUEST['fAMM_tabsheet']=='setmenu')
     157    {
     158      if(!isset($_REQUEST['fAMM_page'])) $_REQUEST['fAMM_page']='position';
     159
     160      if(!($_REQUEST['fAMM_page']=='position' or
     161           $_REQUEST['fAMM_page']=='blocksContent'
     162          )
     163        ) $_REQUEST['fAMM_page']='position';
     164    }
     165
     166  } //initRequest
     167
     168
     169  /**
     170   * display the links management page
     171   */
     172  private function displayLinksPage($tab)
    279173  {
    280174    global $template, $user;
     175
     176    GPCCore::addHeaderJS('jquery.ui', 'themes/default/js/ui/packed/ui.core.packed.js');
     177    GPCCore::addHeaderJS('jquery.ui.sortable', 'themes/default/js/ui/packed/ui.sortable.packed.js');
     178    GPCCore::addHeaderJS('jquery.ui.dialog', 'themes/default/js/ui/packed/ui.dialog.packed.js');
     179
    281180    $template->set_filename('body_page',
    282                             dirname($this->getFileLocation()).'/admin/amm_linkslist.tpl');
    283 
    284     $tmp=$this->get_count_url();
    285     if($tmp==0)
    286     {
    287       $tmp=l10n("g002_nolinks");
    288     }
    289     elseif($tmp==1)
    290     {
    291       $tmp="1 ".l10n("g002_link");
    292     }
    293     else
    294     {
    295       $tmp=$tmp." ".l10n("g002_links");
    296     }
    297 
    298 
    299     $template_datas=array(
    300       'lnk_create' => $this->getAdminLink().'&amp;fAMM_tabsheet=links&amp;action=create',
    301       'lnk_config' => $this->getAdminLink().'&amp;fAMM_tabsheet=links&amp;action=config',
    302       'AMM_AJAX_URL_LIST' => $this->getAdminLink()."&ajaxfct=",
    303       'nburl' => $tmp
     181                            dirname($this->getFileLocation()).'/admin/amm_links.tpl');
     182
     183    $linksTabsheet = new GPCTabSheet('linksTabsheet', $this->tabsheet->get_titlename(), 'tabsheet2 gcBorder', 'itab2');
     184    $linksTabsheet->select($tab);
     185    $linksTabsheet->add('links',
     186                          l10n('g002_setting_link_links'),
     187                          $this->getAdminLink().'&amp;fAMM_tabsheet=links&amp;fAMM_page=links');
     188    $linksTabsheet->add('config',
     189                          l10n('g002_configlinks'),
     190                          $this->getAdminLink().'&amp;fAMM_tabsheet=links&amp;fAMM_page=config');
     191    $linksTabsheet->assign();
     192
     193    switch($tab)
     194    {
     195      case 'links':
     196        $template->assign('sheetContent', $this->displayLinksPageLinks());
     197        break;
     198      case 'config':
     199        $template->assign('sheetContent', $this->displayLinksPageConfig());
     200        break;
     201    }
     202
     203    $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
     204    $template->assign('pageNfo', l10n('g002_addlinks_nfo'));
     205  }
     206
     207  /**
     208   * display the randompict management page
     209   */
     210  private function displayRandompicPage()
     211  {
     212    global $template, $user;
     213
     214    GPCCore::addHeaderJS('jquery.ui', 'themes/default/js/ui/packed/ui.core.packed.js');
     215    GPCCore::addHeaderJS('jquery.ui.slider', 'themes/default/js/ui/packed/ui.slider.packed.js');
     216    GPCCore::addHeaderJS('gpc.categorySelector', 'plugins/GrumPluginClasses/js/ui.categorySelector'.GPCCore::getMinified().'.js');
     217    GPCCore::addUI('inputList,inputText,inputRadio,categorySelector,googleTranslate');
     218    GPCCore::addHeaderJS('amm.rpc', 'plugins/AMenuManager/js/amm_randomPictConfig'.GPCCore::getMinified().'.js');
     219
     220    $template->set_filename('body_page',
     221                            dirname($this->getFileLocation()).'/admin/amm_randompicconfig.tpl');
     222
     223    $datas=array(
     224      'config' => array(
     225          'infosName' => $this->config['amm_randompicture_showname'],
     226          'infosComment' => $this->config['amm_randompicture_showcomment'],
     227          'freqDelay' => $this->config['amm_randompicture_periodicchange'],
     228          'selectMode' => $this->config['amm_randompicture_selectMode'],
     229          'selectCat' => json_encode($this->config['amm_randompicture_selectCat']),
     230          'blockHeight' => $this->config['amm_randompicture_height'],
     231          'blockTitles' => array()
     232        ),
     233      'selectedLang' => $user['language'],
     234      'fromLang' => substr($user['language'],0,2),
     235      'langs' => array()
    304236    );
    305 
    306     $template->assign("datas", $template_datas);
    307     $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
    308   }
    309 
    310   /*
    311     manage display for urls config page
    312   */
    313   private function display_links_config_page()
    314   {
    315     global $template, $user;
    316     $template->set_filename('body_page',
    317                             dirname($this->getFileLocation()).'/admin/amm_linksconfig.tpl');
    318 
    319     $template_datas=array(
    320       'lnk_list' => $this->getAdminLink().'&amp;fAMM_tabsheet=links',
    321       'AMM_AJAX_URL_LIST' => $this->getAdminLink()."&ajaxfct=",
    322       'show_icons_selected' => $this->config['amm_links_show_icons'],
    323       'lang_selected' => $user['language'],
    324       'fromlang' => substr($user['language'],0,2)
    325     );
    326 
    327     $template_datas['language_list'] = array();
    328     foreach($this->config['amm_links_title'] as $key => $val)
    329     {
    330       $template_datas['language_list'][] = array(
    331         'LANG' => $key,
    332         'MENUBARTIT' => base64_decode($val)
    333       );
    334     }
    335 
    336 
    337237
    338238    $lang=get_languages();
    339239    foreach($lang as $key => $val)
    340240    {
    341       $template_datas['language_list_values'][] = $key;
    342       $template_datas['language_list_labels'][] = $val;
    343     }
    344 
    345 
    346     $template_datas['yesno_values'] = array('y','n');
    347     $template_datas['yesno_labels'][] = l10n('g002_yesno_y');
    348     $template_datas['yesno_labels'][] = l10n('g002_yesno_n');
    349 
    350 
    351     $template->assign("datas", $template_datas);
     241      $datas['langs'][$key] = $val;
     242      $datas['config']['blockTitles'][$key] = isset($this->config['amm_randompicture_title'][$key])?base64_decode($this->config['amm_randompicture_title'][$key]):'';
     243    }
     244
     245    $template->assign("datas", $datas);
     246
    352247    $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
    353   }
     248    $template->assign('pageNfo', l10n('g002_randompict_nfo'));
     249  }
     250
     251  /**
     252   * display the personnal blocks management page
     253   */
     254  private function displayPersonalisedBlockPage()
     255  {
     256    global $template, $user;
     257
     258    GPCCore::addHeaderJS('jquery.ui', 'themes/default/js/ui/packed/ui.core.packed.js');
     259    GPCCore::addHeaderJS('jquery.ui.dialog', 'themes/default/js/ui/packed/ui.dialog.packed.js');
     260    GPCCore::addUI('inputList,inputText,inputRadio,googleTranslate');
     261    GPCCore::addHeaderJS('amm.upbm', 'plugins/AMenuManager/js/amm_personalisedBlocks'.GPCCore::getMinified().'.js');
     262
     263
     264    $template->set_filename('body_page',
     265                            dirname($this->getFileLocation()).'/admin/amm_personalised.tpl');
     266
     267    $datas=array(
     268      'selectedLang' => $user['language'],
     269      'fromLang' => substr($user['language'],0,2),
     270      'langs' => get_languages()
     271    );
     272
     273    $template->assign("datas", $datas);
     274
     275    $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
     276    $template->assign('pageNfo', l10n('g002_personnalblock_nfo'));
     277  }
     278
     279  /**
     280   * display the core blocks menu management page
     281   */
     282  private function displayBlocksPage($tab)
     283  {
     284    global $template, $conf;
     285
     286    GPCCore::addHeaderJS('jquery.ui', 'themes/default/js/ui/packed/ui.core.packed.js');
     287    GPCCore::addHeaderJS('jquery.ui.sortable', 'themes/default/js/ui/packed/ui.sortable.packed.js');
     288    GPCCore::addUI('inputList');
     289    GPCCore::addHeaderJS('amm.cbm', 'plugins/AMenuManager/js/amm_blocks'.GPCCore::getMinified().'.js');
     290
     291    $template->set_filename('body_page',
     292                            dirname($this->getFileLocation()).'/admin/amm_coreBlocks.tpl');
     293
     294    $blocksTabsheet = new GPCTabSheet('blocksTabsheet', $this->tabsheet->get_titlename(), 'tabsheet2 gcBorder', 'itab2');
     295    $blocksTabsheet->add('position',
     296                          l10n('g002_setting_blocks_position'),
     297                          '', false, "cbm.displayTabContent('position');");
     298    $blocksTabsheet->add('config',
     299                          l10n('g002_setting_core_blocks_content'),
     300                          '', false, "cbm.displayTabContent('blocksContent');");
     301    $blocksTabsheet->select($tab);
     302    $blocksTabsheet->assign();
     303
     304
     305    $users=new GPCUsers();
     306    $groups=new GPCGroups();
     307
     308    $this->sortCoreBlocksItems();
     309
     310    foreach($this->config['amm_blocks_items'] as $menuId=>$menu)
     311    {
     312      $this->config['amm_blocks_items'][$menuId]['visibilityForm'] = $this->makeBlockVisibility($menu['visibility'], $menuId);
     313      $this->config['amm_blocks_items'][$menuId]['translation']=$this->defaultMenus[$menuId]['translation'];
     314      $this->defaultMenus[$menuId]['visibilityForm'] = $this->makeBlockVisibility("/", $menuId);
     315    }
     316
     317    $registeredBlocks=$this->getRegisteredBlocks();
     318    foreach($registeredBlocks as $key=>$val)
     319    {
     320      $registeredBlocks[$key]['users']=json_encode($registeredBlocks[$key]['users']);
     321      $registeredBlocks[$key]['groups']=json_encode($registeredBlocks[$key]['groups']);
     322    }
     323
     324    $datas=array(
     325      'tab' => $tab,
     326      'users' => $users->getList(),
     327      'groups' => $groups->getList(),
     328      'coreBlocks' => array(
     329            'blocks' => $this->blocksId,
     330            'defaultValues' => $this->defaultMenus,
     331            'items' => $this->config['amm_blocks_items']
     332          ),
     333      'menuBlocks' => $registeredBlocks
     334    );
     335
     336    $template->assign("datas", $datas);
     337
     338    $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
     339    $template->assign('pageNfo', l10n('g002_setmenu_nfo'));
     340  }
     341
     342
     343
     344  /**
     345   * display the album to menu management page
     346   */
     347  private function displayAlbumPage()
     348  {
     349    global $template, $user;
     350
     351    GPCCore::addHeaderCSS('gpc.categorySelector', 'plugins/GrumPluginClasses/css/categorySelector_'.$template->get_themeconf('name').'.css');
     352    GPCCore::addHeaderJS('jquery.ui', 'themes/default/js/ui/packed/ui.core.packed.js');
     353    GPCCore::addHeaderJS('gpc.categorySelector', 'plugins/GrumPluginClasses/js/ui.categorySelector'.GPCCore::getMinified().'.js');
     354    GPCCore::addHeaderJS('amm.ac', 'plugins/AMenuManager/js/amm_albumConfig'.GPCCore::getMinified().'.js');
     355
     356    $template->set_filename('body_page',
     357                            dirname($this->getFileLocation()).'/admin/amm_album.tpl');
     358
     359    $datas=array(
     360      'albums' => json_encode($this->config['amm_albums_to_menu'])
     361    );
     362
     363    $template->assign("datas", $datas);
     364
     365    $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
     366    $template->assign('pageNfo', l10n('g002_album_nfo'));
     367  }
     368
    354369
    355370  /*
    356     manage display for urls create/modify page
    357   */
    358   private function display_links_manage_page($modeedit = 'create', $urlid=0)
     371   *  ---------------------------------------------------------------------------
     372   * links functionnalities
     373   * ---------------------------------------------------------------------------
     374   */
     375
     376  /**
     377   * display the links management page
     378   */
     379  private function displayLinksPageLinks()
    359380  {
    360381    global $template, $user;
    361     $template->set_filename('body_page',
    362                             dirname($this->getFileLocation()).'/admin/amm_linkslist_edit.tpl');
    363 
    364     $extensions_list=array('jpg'=>0,'jpeg'=>0,'gif'=>0,'png'=>0);
    365     $template_icons_list=array();
     382
     383    GPCCore::addUI('inputList,inputRadio,inputText,inputCheckbox');
     384    GPCCore::addHeaderJS('amm.ulm', 'plugins/AMenuManager/js/amm_links'.GPCCore::getMinified().'.js');
     385
     386    $template->set_filename('sheet_page',
     387                            dirname($this->getFileLocation()).'/admin/amm_linkslinks.tpl');
     388
     389    $users=new GPCUsers();
     390    $groups=new GPCGroups();
     391
     392    $datas=array(
     393      'access' => array('users' => $users->getList(), 'groups' => $groups->getList()),
     394      'iconsValues' => array(),
     395      'modesValues' => array(
     396        array(
     397          'value' => 0,
     398          'label' => l10n("g002_mode_".$this->urlsModes[0])
     399        ),
     400        array(
     401          'value' => 1,
     402          'label' => l10n("g002_mode_".$this->urlsModes[1])
     403        )
     404      )
     405    );
     406
    366407    $directory=dir(dirname($this->getFileLocation()).'/links_pictures/');
    367408    while($file=$directory->read())
    368409    {
    369       if(isset($extensions_list[get_extension(strtolower($file))]))
     410      if(in_array(get_extension(strtolower($file)), array('jpg', 'jpeg','gif','png')))
    370411      {
    371         $template_icons_list[]=$file;
     412        $datas['iconsValues'][] = array(
     413          'img' => AMM_PATH."links_pictures/".$file,
     414          'value' => $file,
     415          'label' => $file
     416        );
    372417      }
    373418    }
    374419
    375 
    376     if($modeedit=='modify')
    377     {
    378       $url=$this->get_url($urlid);
    379 
    380       $template_datas=array(
    381         'id' => $urlid,
    382         'modeedit' => 'modify',
    383         'label' => htmlentities($url['label'], ENT_QUOTES, 'UTF-8'),
    384         'url' => $url['url'],
    385         'icons_selected' => $url['icon'],
    386         'mode_selected' => $url['mode'],
    387         'visible_selected' => $url['visible']
    388       );
    389     }
    390     else
    391     {
    392       $template_datas=array(
    393         'id' => '',
    394         'modeedit' => 'create',
    395         'label' => '',
    396         'url' => '',
    397         'icons_selected' => $template_icons_list[0],
    398         'mode_selected' => 0,
    399         'visible_selected' => 'y'
    400       );
    401     }
    402 
    403     $template_datas['lnk_list'] = $this->getAdminLink().'&amp;fAMM_tabsheet=links';
    404     $template_datas['icons_img'] = AMM_PATH."links_pictures/".$template_datas['icons_selected'];
    405     $template_datas['icons_values'] = array();
    406     foreach($template_icons_list as $key => $val)
    407     {
    408       $template_datas['icons_values'][] = array(
    409         'img' => AMM_PATH."links_pictures/".$val,
    410         'value' => $val,
    411         'label' => $val
    412       );
    413     }
    414     $template_datas['mode_values'] = array(0,1);
    415     $template_datas['mode_labels'][] = l10n("g002_mode_".$this->urls_modes[0]);
    416     $template_datas['mode_labels'][] = l10n("g002_mode_".$this->urls_modes[1]);
    417     $template_datas['visible_values'] = array('y','n');
    418     $template_datas['visible_labels'][] = l10n('g002_yesno_y');
    419     $template_datas['visible_labels'][] = l10n('g002_yesno_n');
    420 
    421     $template->assign("datas", $template_datas);
    422     $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
    423   }
    424 
    425   /*
    426     manage create/modify url into database and display result
    427   */
    428   protected function action_create_modify_url()
    429   {
     420    $template->assign("datas", $datas);
     421
     422    return($template->parse('sheet_page', true));
     423  }
     424
     425  /**
     426   * display the links config page
     427   */
     428  private function displayLinksPageConfig()
     429  {
     430    global $template, $user;
     431
     432    GPCCore::addUI('inputList,inputRadio,inputText,googleTranslate');
     433    GPCCore::addHeaderJS('amm.ulc', 'plugins/AMenuManager/js/amm_linksConfig'.GPCCore::getMinified().'.js');
     434
     435    $template->set_filename('sheet_page',
     436                            dirname($this->getFileLocation()).'/admin/amm_linksconfig.tpl');
     437
    430438    $datas=array(
    431       'id' => $_POST['famm_id'],
    432       'label' => $_POST['famm_label'],
    433       'url' => $_POST['famm_url'],
    434       'mode' => $_POST['famm_mode'],
    435       'icon' => $_POST['famm_icon'],
    436       'position' => 0,
    437       'visible' => $_POST['famm_visible']
     439      'config' => array(
     440          'showIcons' => $this->config['amm_links_show_icons'],
     441          'titles' => array()
     442        ),
     443      'selectedLang' => $user['language'],
     444      'fromLang' => substr($user['language'],0,2),
     445      'langs' => array()
    438446    );
    439 
    440     switch($_POST['famm_modeedit'])
    441     {
    442       case 'create':
    443         $this->add_url($datas);
    444         break;
    445       case 'modify':
    446         $this->modify_url($datas);
    447     }
    448   }
    449 
    450   /*
    451     manage urls config save into database
    452   */
    453   protected function action_links_modify_config()
    454   {
    455     $this->config['amm_links_show_icons']=$_POST['famm_links_show_icons'];
    456     $languages=get_languages();
    457     foreach($languages as $key => $val)
    458     {
    459       $this->config['amm_links_title'][$key]=base64_encode($_POST['famm_links_title_'.$key]);
    460     }
    461     $this->saveConfig();
    462   }
    463 
    464   /*
    465     manage randompic config save into database
    466   */
    467   protected function action_randompic_modify_config()
    468   {
    469     $this->config['amm_randompicture_height']=$_POST['famm_randompicture_height'];
    470     $this->config['amm_randompicture_periodicchange']=$_POST['famm_randompicture_periodicchange'];
    471     $this->config['amm_randompicture_showname']=$_POST['famm_randompicture_showname'];
    472     $this->config['amm_randompicture_showcomment']=$_POST['famm_randompicture_showcomment'];
    473     $languages=get_languages();
    474     foreach($languages as $key => $val)
    475     {
    476       $this->config['amm_randompicture_title'][$key]=base64_encode(stripslashes($_POST['famm_randompicture_title_'.$key]));
    477     }
    478     $this->saveConfig();
    479   }
    480 
    481 
    482 
    483   /*
    484     manage display for sections table page
    485   */
    486   private function display_sections_page()
    487   {
    488     global $template, $user, $page;
    489     $template->set_filename('body_page', dirname($this->getFileLocation()).'/admin/amm_sections.tpl');
    490 
    491     if(isset($_POST['fList']) && !$this->adviser_abort())
    492     {
    493       /* the returned information in the fList form element are
    494        *  a list of ecah item, separate with a ";"
    495        *  each item have properties separated by a ","
    496        *   id, container, order, visibility
    497       */
    498       $items=explode(";",$_POST['fList']);
    499       for($i=0;$i<count($items)-1;$i++)
    500       {
    501         $properties=explode("#", $items[$i]);
    502         $properties[0]=explode(",", $properties[0]);
    503         $this->config['amm_sections_items'][$properties[0][0]]['container']=$properties[0][1];
    504         $this->config['amm_sections_items'][$properties[0][0]]['order']=$properties[0][2];
    505         $this->config['amm_sections_items'][$properties[0][0]]['visibility']=$properties[1];
    506       }
    507       $this->sortSectionsItems();
    508       if($this->saveConfig())
    509       {
    510         array_push($page['infos'], l10n('g002_config_saved'));
    511       }
    512       else
    513       {
    514         array_push($page['errors'], l10n('g002_adviser_not_allowed'));
    515       }
    516     }
    517 
    518     foreach($this->config['amm_sections_items'] as $key=>$val)
    519     {
    520       $this->config['amm_sections_items'][$key]['visibilityForm'] = $this->makeVisibility($val['visibility'], $key);
    521       $this->defaultMenus[$key]['visibilityForm'] = $this->makeVisibility("guest,generic,normal,webmaster,admin/", $key);
    522     }
    523 
    524     $this->sortSectionsItems();
    525 
    526     $users=new GPCUsers("");
    527     $groups=new GPCGroups("");
    528 
    529 
    530     $template->assign("visibility", Array('users' => $users->access_list, 'groups' => $groups->access_list));
    531     $template->assign("sections", $this->sectionsId);
    532     $template->assign("defaultValues", $this->defaultMenus);
    533     $template->assign("items", $this->config['amm_sections_items']);
    534     $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
    535   }
    536 
    537 
    538   /*
    539     manage display for randompic config page
    540   */
    541   private function display_randompic_config_page()
    542   {
    543     global $template, $user;
    544     $template->set_filename('body_page',
    545                             dirname($this->getFileLocation()).'/admin/amm_randompicconfig.tpl');
    546 
    547     $template_datas=array(
    548       'lnk_list' => $this->getAdminLink().'&amp;fAMM_tabsheet=links',
    549       'showname_selected' => $this->config['amm_randompicture_showname'],
    550       'showcomment_selected' => $this->config['amm_randompicture_showcomment'],
    551       'periodic_change' => $this->config['amm_randompicture_periodicchange'],
    552       'height' => $this->config['amm_randompicture_height'],
    553       'lang_selected' => $user['language'],
    554       'fromlang' => substr($user['language'],0,2)
    555     );
    556 
    557     $template_datas['language_list'] = array();
    558     foreach($this->config['amm_randompicture_title'] as $key => $val)
    559     {
    560       $template_datas['language_list'][] = array(
    561         'LANG' => $key,
    562         'MENUBARTIT' => htmlentities(base64_decode($val), ENT_QUOTES, 'UTF-8')
    563       );
    564     }
    565 
    566 
    567447
    568448    $lang=get_languages();
    569449    foreach($lang as $key => $val)
    570450    {
    571       $template_datas['language_list_values'][] = $key;
    572       $template_datas['language_list_labels'][] = $val;
    573     }
    574 
    575 
    576     $template_datas['yesno_values'] = array('y','n');
    577     $template_datas['yesno_labels'][] = l10n('g002_yesno_y');
    578     $template_datas['yesno_labels'][] = l10n('g002_yesno_n');
    579 
    580     $template_datas['show_values'] = array('n', 'o', 'u');
    581     $template_datas['show_labels'][] = l10n('g002_show_n');
    582     $template_datas['show_labels'][] = l10n('g002_show_o');
    583     $template_datas['show_labels'][] = l10n('g002_show_u');
    584 
    585 
    586     $template->assign("datas", $template_datas);
    587     $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
    588   }
    589 
    590 
    591 
    592 
     451      $datas['langs'][$key] = $val;
     452      $datas['config']['titles'][$key] = isset($this->config['amm_links_title'][$key])?base64_decode($this->config['amm_links_title'][$key]):'';
     453    }
     454
     455    $template->assign("datas", $datas);
     456    return($template->parse('sheet_page', true));
     457  }
    593458
    594459
    595460
    596461  /*
    597     manage display for personalised sections list page
     462   * ---------------------------------------------------------------------------
     463   * blocks functionnalities
     464   * ---------------------------------------------------------------------------
     465   */
     466
     467  /**
     468   * this function returns an HTML FORM to use with each menu items
     469   *
     470   * @param String $visibility : a formatted string like :
     471   *                              users type1(,users typeX)/(groupId0)(,groupIdX)
     472   * @param String $blockId    : block Id
     473   * @return String : html ready to use
    598474  */
    599   private function display_personalised_list_page()
    600   {
    601     global $template, $user;
    602     $template->set_filename('body_page',
    603                             dirname($this->getFileLocation()).'/admin/amm_personalisedlist.tpl');
    604 
    605     $sql="SELECT COUNT(DISTINCT ID) as countid FROM ".$this->tables['personalised'];
    606     $result=pwg_query($sql);
    607     if($result)
    608     {
    609       $tmp=pwg_db_fetch_row($result);
    610       $tmp=$tmp[0];
    611     }
    612     else
    613     {
    614       $tmp=0;
    615     }
    616 
    617     if($tmp==0)
    618     {
    619       $tmp=l10n("g002_nosections");
    620     }
    621     elseif($tmp==1)
    622     {
    623       $tmp="1 ".l10n("g002_section");
    624     }
    625     else
    626     {
    627       $tmp=$tmp." ".l10n("g002_sections");
    628     }
    629 
    630 
    631     $template_datas=array(
    632       'lnk_create' => $this->getAdminLink().'&amp;fAMM_tabsheet=personnalblock&amp;action=create',
    633       'AMM_AJAX_URL_LIST' => $this->getAdminLink()."&ajaxfct=",
    634       'nbsections' => $tmp
    635     );
    636 
    637     $template->assign("datas", $template_datas);
    638     $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
    639   }
    640 
    641 
    642 
    643   /*
    644     manage display for personalised sections create/modify page
    645   */
    646   private function display_personalised_manage_page($modeedit = 'create', $sectionid=0)
    647   {
    648     global $template, $user;
    649     $template->set_filename('body_page',
    650                             dirname($this->getFileLocation()).'/admin/amm_personalisedlist_edit.tpl');
    651 
    652     $template_datas=array();
    653 
    654     $lang=get_languages();
    655     $lang['all']=l10n('g002_all_languages');
    656     foreach($lang as $key => $val)
    657     {
    658       $template_datas['language_list_values'][] = $key;
    659       $template_datas['language_list_labels'][] = $val;
    660       $template_datas['language_list'][$key]=array(
    661         'LANG' => $key,
    662         'MENUBARTIT' => '',
    663         'MENUBARCONTENT' => ''
    664       );
    665     }
    666 
    667 
    668     if($modeedit=='modify')
    669     {
    670       $sections=$this->get_personalised($sectionid);
    671 
    672       $template_datas['id'] = $sectionid;
    673       $template_datas['modeedit'] = 'modify';
    674       $template_datas['visible_selected'] = $sections[0]['visible'];
    675       $template_datas['nfo'] = htmlentities($sections[0]['nfo'], ENT_QUOTES, 'UTF-8');
    676 
    677       foreach($sections as $key => $val)
    678       {
    679         $lang=($val['lang']=='*')?'all':$val['lang'];
    680         $template_datas['language_list'][$lang] = array(
    681           'LANG' => $lang,
    682           'MENUBARTIT' => htmlentities($val['title'], ENT_QUOTES, 'UTF-8'),
    683           'MENUBARCONTENT' => htmlentities($val['content'], ENT_QUOTES, 'UTF-8'),
    684         );
    685       }
    686     }
    687     else
    688     {
    689       $template_datas['nfo'] = '';
    690       $template_datas['id'] = '';
    691       $template_datas['modeedit'] = 'create';
    692       $template_datas['visible_selected'] = 'y';
    693     }
    694 
    695     $template_datas['lang_selected'] = $user['language'];
    696 
    697     $template_datas['personalised_list'] = $this->getAdminLink().'&amp;fAMM_tabsheet=personnalblock';
    698     $template_datas['yesno_values'] = array('y','n');
    699     $template_datas['yesno_labels'][] = l10n('g002_yesno_y');
    700     $template_datas['yesno_labels'][] = l10n('g002_yesno_n');
    701 
    702     $template->assign("datas", $template_datas);
    703     $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page');
    704   }
    705 
    706   /*
    707     manage create/modify pesonalised sections into database and display result
    708   */
    709   protected function action_create_modify_personalised()
    710   {
    711     global $user;
    712 
    713     if($_POST['famm_modeedit']=='create')
    714     {
    715       $id=$this->get_personalised_id();
    716     }
    717     else
    718     {
    719       $id=$_POST['famm_id'];
    720     }
    721     $languages=get_languages();
    722     $languages['all']='*';
    723     foreach($languages as $key => $val)
    724     {
    725       $datas=array(
    726         'id' => $id,
    727         'lang' => ($key=='all')?'*':$key,
    728         'visible' => $_POST['famm_personalised_visible'],
    729         'nfo' => ($_POST['famm_personalised_nfo']=='')?$_POST['famm_personalised_title_'.$user['language']]:$_POST['famm_personalised_nfo'],
    730         'title' => $_POST['famm_personalised_title_'.$key],
    731         'content' => $_POST['famm_personalised_content_'.$key]
    732       );
    733       switch($_POST['famm_modeedit'])
    734       {
    735         case 'create':
    736           $this->add_personalised($datas);
    737           break;
    738         case 'modify':
    739           $this->modify_personalised($datas);
    740       }
    741     }
    742   }
    743 
    744 
    745 
    746   /* this function returns an HTML FORM to use with each menu items
    747    * $visibility is a formatted string looking this :
    748    *   users type1(,users typeX)/(groupId0)(,groupIdX))
    749   */
    750   private function makeVisibility($visibility, $id)
     475  private function makeBlockVisibility($visibility, $menuId)
    751476  {
    752477    $local_tpl = new Template(AMM_PATH."admin/", "");
    753478    $local_tpl->set_filename('body_page',
    754                   dirname($this->getFileLocation()).'/admin/amm_sections_visibility.tpl');
     479                  dirname($this->getFileLocation()).'/admin/amm_coreBlocks_detail.tpl');
    755480
    756481
    757482    $parameters=explode("/", $visibility);
    758483
    759     $users=new GPCUsers(str_replace(",", "/", $parameters[0]));
    760     $users->setAllowed('admin', true);
    761     $groups=new GPCGroups(str_replace(",", "/", $parameters[1]));
    762 
    763     $local_tpl->assign('name', $id);
    764     $local_tpl->assign('users', $users->access_list);
    765     $local_tpl->assign('groups', $groups->access_list);
     484    /* submenu access system is :
     485     *  - by default, everything is accesible
     486     *  - items not accessible are defined
     487     */
     488    $users=new GPCUsers();
     489    $users->setAlloweds(explode(',', $parameters[0]), false);
     490    $groups=new GPCGroups();
     491    $groups->setAlloweds(explode(',', $parameters[1]), false);
     492
     493    $local_tpl->assign('name', $menuId);
     494    $local_tpl->assign('users', $users->getList());
     495    $local_tpl->assign('groups', $groups->getList());
    766496
    767497    return($local_tpl->parse('body_page', true));
     
    769499
    770500
    771 
    772   /*
    773     manage adviser profile
    774       return true if user is adviser
    775   */
    776   protected function adviser_abort()
    777   {
    778     if(is_adviser())
    779     {
    780       $this->displayResult(l10n("g002_adviser_not_allowed"), false);
    781       return(true);
    782     }
    783     return(false);
    784   }
    785 
    786 
    787 
    788   /* ---------------------------------------------------------------------------
    789     functions to manage urls tables
    790   --------------------------------------------------------------------------- */
    791   // protected function get_urls()
    792   // protected function get_count_url()
    793   // => defined in root class
    794 
    795   // return properties of an given url
    796   private function get_url($url_id)
    797   {
    798     $returned=array();
    799     $sql="SELECT * FROM ".$this->tables['urls']." WHERE id = '".$url_id."'";
    800     $result=pwg_query($sql);
    801     if($result)
    802     {
    803       $returned=pwg_db_fetch_assoc($result);
    804       //$returned['label']=stripslashes($returned['label']);
    805     }
    806     return($returned);
    807   }
    808 
    809   // permut position of two 2 urls
    810   private function permut_url($url_id, $url_permut)
    811   {
    812     $sql="SELECT id, position FROM ".$this->tables['urls']." WHERE id IN ('".$url_id."','".$url_permut."')";
    813     $result=pwg_query($sql);
    814     if($result)
    815     {
    816       $tmp=array();
    817       while($row=pwg_db_fetch_assoc($result))
    818       {
    819         $tmp[$row['id']]=$row['position'];
    820       }
    821       $sql="UPDATE ".$this->tables['urls']." SET position = ".$tmp[$url_id]." WHERE id = '".$url_permut."'";
    822       pwg_query($sql);
    823       $sql="UPDATE ".$this->tables['urls']." SET position = ".$tmp[$url_permut]." WHERE id = '".$url_id."'";
    824       pwg_query($sql);
    825     }
    826   }
    827 
    828   // delete an url
    829   private function delete_url($url_id)
    830   {
    831     $sql="DELETE FROM ".$this->tables['urls']." WHERE id = '".$url_id."' ";
    832     return(pwg_query($sql));
    833   }
    834 
    835   // add an url
    836   private function add_url($datas)
    837   {
    838     $numurl=$this->get_count_url();
    839     $sql="INSERT INTO ".$this->tables['urls']." (label, url, mode, icon, position, visible)
    840           VALUES ('".$datas['label']."', '".$datas['url']."', '".$datas['mode']."',
    841                   '".$datas['icon']."', '".$numurl."', '".$datas['visible']."')";
    842     return(pwg_query($sql));
    843   }
    844 
    845   // modify an url
    846   private function modify_url($datas)
    847   {
    848     $sql="UPDATE ".$this->tables['urls']." SET label = '".$datas['label']."',
    849           url = '".$datas['url']."', mode = '".$datas['mode']."', icon = '".$datas['icon']."',
    850           visible = '".$datas['visible']."'
    851           WHERE id = '".$datas['id']."'";
    852     return(pwg_query($sql));
    853   }
    854 
    855   // just modify url visibility
    856   private function set_url_visibility($urlid, $visible)
    857   {
    858     $sql="UPDATE ".$this->tables['urls']." SET visible = '".$visible."'
    859           WHERE id = '".$urlid."'";
    860     return(pwg_query($sql));
    861   }
    862 
    863 
    864 
    865   /* ---------------------------------------------------------------------------
    866     functions to manage sections tables
    867   --------------------------------------------------------------------------- */
    868   // protected function get_sections($only_visible=false, $lang="")
    869   // => defined in root class
    870 
    871   // return properties of a given section (return each languages)
    872   private function get_personalised($section_id)
    873   {
    874     $returned=array();
    875     $sql="SELECT * FROM ".$this->tables['personalised']." WHERE id = '".$section_id."'";
    876     $result=pwg_query($sql);
    877     if($result)
    878     {
    879       while($returned[]=pwg_db_fetch_assoc($result));
    880     }
    881     return($returned);
    882   }
    883 
    884   // delete a section
    885   private function delete_personalised($section_id)
    886   {
    887     $sql="DELETE FROM ".$this->tables['personalised']." WHERE id = '".$section_id."' ";
    888     return(pwg_query($sql));
    889   }
    890 
    891   // add a section
    892   private function add_personalised($datas)
    893   {
    894     $sql="INSERT INTO ".$this->tables['personalised']." (id, lang, title, content, visible, nfo)
    895           VALUES ('".$datas['id']."', '".$datas['lang']."', '".$datas['title']."', '".$datas['content']."', '".$datas['visible']."', '".$datas['nfo']."')";
    896     return(pwg_query($sql));
    897   }
    898 
    899   // modify a section
    900   private function modify_personalised($datas)
    901   {
    902     $sql="UPDATE ".$this->tables['personalised']." SET title = '".$datas['title']."',
    903           content = '".$datas['content']."',  visible = '".$datas['visible']."',
    904           nfo = '".$datas['nfo']."'
    905           WHERE id = '".$datas['id']."'
    906           AND lang = '".$datas['lang']."'";
    907     return(pwg_query($sql));
    908   }
    909 
    910   // return the next personalised id
    911   private function get_personalised_id()
    912   {
    913     $sql='SELECT MAX(ID) FROM '.$this->tables['personalised'];
    914     $result=pwg_query($sql);
    915     if($result)
    916     {
    917       $row=pwg_db_fetch_row($result);
    918       if(is_array($row))
    919       {
    920         return($row[0]+1);
    921       }
    922     }
    923     return(0);
    924   }
    925 
    926 
    927 
    928 
    929 
    930   /* ---------------------------------------------------------------------------
    931     ajax functions
    932   --------------------------------------------------------------------------- */
    933 
    934   // return a html formatted list of urls
    935   private function ajax_amm_links_list()
    936   {
    937     global $template, $user;
    938     $local_tpl = new Template(AMM_PATH."admin/", "");
    939     $local_tpl->set_filename('body_page',
    940                   dirname($this->getFileLocation()).'/admin/amm_linkslist_detail.tpl');
    941 
    942     $template_datas['urls']=array();
    943     $urls=$this->get_urls();
    944     for($i=0;$i<count($urls);$i++)
    945     {
    946       $template_datas['urls'][]=array(
    947         'img' => AMM_PATH."links_pictures/".$urls[$i]['icon'],
    948         'label' => $urls[$i]['label'],
    949         'url' => $urls[$i]['url'],
    950         'mode' => l10n("g002_mode_".$this->urls_modes[$urls[$i]['mode']]),
    951         'up' =>  ($i==0)?false:true,
    952         'down' =>  ($i<(count($urls)-1))?true:false,
    953         'edit' => $this->getAdminLink().'&amp;fAMM_tabsheet=links&amp;action=modify&amp;fItem='.$urls[$i]['id'],
    954         'ID' => $urls[$i]['id'],
    955         'IDPREV' => ($i==0)?0:$urls[$i-1]['id'],
    956         'IDNEXT' => ($i<(count($urls)-1))?$urls[$i+1]['id']:0,
    957         'visible' => l10n('g002_yesno_'.$urls[$i]['visible'])
    958       );
    959     }
    960 
    961     $themeconf=array(
    962       'icon_dir' => $template->get_themeconf('icon_dir')
    963     );
    964 
    965     $local_tpl->assign('themeconf', $themeconf);
    966     $local_tpl->assign('datas', $template_datas);
    967     $local_tpl->assign('plugin', array('PATH' => AMM_PATH));
    968 
    969     return($local_tpl->parse('body_page', true));
    970   }
    971 
    972   // permut position of 2 urls and returns a html formatted list of urls
    973   private function ajax_amm_links_permut($urlid, $urlpermut)
    974   {
    975     $this->permut_url($urlid, $urlpermut);
    976     return($this->ajax_amm_links_list());
    977   }
    978 
    979   // delete an url and returns a html formatted list of urls
    980   private function ajax_amm_links_delete($urlid)
    981   {
    982     if(!$this->adviser_abort())
    983     {
    984       $this->delete_url($urlid);
    985     }
    986     return($this->ajax_amm_links_list());
    987   }
    988 
    989 
    990 
    991 
    992 
    993   // return a html formatted list of personalised sections
    994   private function ajax_amm_personalised_list()
    995   {
    996     global $template, $user;
    997     $local_tpl = new Template(AMM_PATH."admin/", "");
    998     $local_tpl->set_filename('body_page',
    999                   dirname($this->getFileLocation()).'/admin/amm_personalisedlist_detail.tpl');
    1000 
    1001     $template_datas['sections']=array();
    1002 
    1003     $sections=$this->get_sections(false, '', false);
    1004     $is_done=array();
    1005     foreach($sections as $key => $val)
    1006     {
    1007       if(!isset($is_done[$val['id']]))
    1008       {
    1009         $template_datas['sections'][]=array(
    1010           'title' => ($val['title']!='')?$val['title']:l10n('g002_notitle'),
    1011           'edit' => $this->getAdminLink().'&amp;fAMM_tabsheet=personnalblock&amp;action=modify&amp;fItem='.$val['id'],
    1012           'ID' => $val['id'],
    1013           'visible' => l10n('g002_yesno_'.$val['visible']),
    1014           'nfo' => $val['nfo']
    1015         );
    1016         $is_done[$val['id']]='';
    1017       }
    1018     }
    1019 
    1020     $themeconf=array(
    1021       'icon_dir' => $template->get_themeconf('icon_dir')
    1022     );
    1023 
    1024     $local_tpl->assign('themeconf', $themeconf);
    1025     $local_tpl->assign('datas', $template_datas);
    1026     $local_tpl->assign('plugin', array('PATH' => AMM_PATH));
    1027 
    1028     return($local_tpl->parse('body_page', true));
    1029   }
    1030 
    1031   // delete a section and returns a html formatted list
    1032   private function ajax_amm_personalised_delete($sectionid)
    1033   {
    1034     if(!$this->adviser_abort())
    1035     {
    1036       $this->delete_personalised($sectionid);
    1037     }
    1038     return($this->ajax_amm_personalised_list());
    1039   }
    1040 
    1041 
    1042501} // AMM_AIP class
    1043502
  • extensions/AMenuManager/amm_install.class.inc.php

    r5545 r8962  
    33  Plugin     : Advanced Menu Manager
    44  Author     : Grum
    5     email    : grum@grum.dnsalias.com
     5    email    : grum@piwigo.org
    66    website  : http://photos.grum.fr
    77    PWG user : http://forum.phpwebgallery.net/profile.php?id=3706
     
    2121  class AMM_install extends AMM_root
    2222  {
    23     private $tablesManager;
    24     private $exportfile;
    25 
    26     public function AMM_install($prefixeTable, $filelocation)
     23    private $tablef;
     24
     25    public function __construct($prefixeTable, $filelocation)
    2726    {
    2827      parent::__construct($prefixeTable, $filelocation);
    29       $this->tablesManager= new GPCTables($this->tables);
    30       $this->exportfile=dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().'.sql';
    31     }
    32 
    33     /*
    34         function for installation process
    35         return true if install process is ok, otherwise false
    36     */
     28      $this->tablef= new GPCTables($this->tables);
     29    }
     30
     31    public function __destruct()
     32    {
     33      unset($this->tablesManager);
     34      unset($this->tablef);
     35      parent::__destruct();
     36    }
     37
     38
     39    /**
     40     * function for installation process
     41     *
     42     * @return Bool : true if install process is ok, otherwise false
     43     */
    3744    public function install()
    3845    {
     
    4047      $this->loadConfig();
    4148      $this->config['installed']=AMM_VERSION2;
     49      $this->config['newInstall']='y';
    4250      $this->saveConfig();
    4351
     
    5159  `position` int(11) NOT NULL default '0',
    5260  `visible` char(1) NOT NULL default 'y',
     61  `accessUsers` varchar(1024) NOT NULL,
     62  `accessGroups` varchar(1024) NOT NULL,
    5363  PRIMARY KEY  (`id`),
    5464  KEY `order_key` (`position`)
     
    5666
    5767"CREATE TABLE  `".$this->tables['personalised']."` (
    58   `id` int(11) NOT NULL default '0',
    59   `lang` varchar(5) NOT NULL default '',
    60   `title` varchar(255) NOT NULL default '',
    61   `content` text NOT NULL,
     68  `id` int(11) NOT NULL auto_increment,
    6269  `visible` char(1) NOT NULL default 'y',
    6370  `nfo` varchar(255) NOT NULL default '',
    64   PRIMARY KEY  (`id`,`lang`)
     71  PRIMARY KEY  (`id`)
     72)",
     73
     74"CREATE TABLE `".$this->tables['personalised_langs']."` (
     75  `id` INTEGER UNSIGNED NOT NULL DEFAULT 0,
     76  `lang` CHAR(5)  NOT NULL default '*',
     77  `title` VARCHAR(255)  NOT NULL default '',
     78  `content` TEXT  NOT NULL,
     79  PRIMARY KEY (`id`, `lang`)
     80)",
     81
     82"CREATE TABLE `".$this->tables['blocks']."` (
     83  `id` VARCHAR(40)  NOT NULL,
     84  `order` INTEGER UNSIGNED NOT NULL,
     85  `users` VARCHAR(1024)  NOT NULL,
     86  `groups` VARCHAR(1024)  NOT NULL,
     87  PRIMARY KEY (`id`),
     88  INDEX `byOrder`(`order`)
    6589)"
     90
    6691);
    6792      //$table_def array
    6893      $tables_def = create_table_add_character_set($tables_def);
    69       $result=$this->tablesManager->create($tables_def);
     94      $result=$this->tablef->create($tables_def);
     95      unset($tables_def);
     96
     97      GPCCore::register($this->getPluginName(), AMM_VERSION, AMM_GPC_NEEDED);
     98
    7099      return($result);
    71100    }
    72101
    73102
    74     /*
    75        function for uninstall process
    76     */
     103    /**
     104     * function for uninstall process
     105     */
    77106    public function uninstall()
    78107    {
    79       $this->tablesManager->export($this->exportfile);
    80108      $this->deleteConfig();
    81       $this->tablesManager->drop();
     109      $this->tablef->drop();
     110      GPCCore::unregister($this->getPluginName());
    82111    }
    83112
     
    91120      $this->udpateTablesDef();
    92121
     122      $this->config['newInstall']='n';
    93123      $this->config['installed']=AMM_VERSION2; //update the installed release number
    94124      $this->saveConfig();
     125
     126      GPCCore::register($this->getPluginName(), AMM_VERSION, AMM_GPC_NEEDED);
    95127    }
    96128
    97129    public function deactivate()
    98130    {
     131      $this->initConfig();
     132      $this->loadConfig();
     133      $this->restoreMenuConfig();
    99134    }
    100135
     
    106141    protected function udpateTablesDef()
    107142    {
     143      global $conf;
     144
    108145      /* AMM release earlier than the 2.1.3 uses two parameters to manage the display
    109146       * of the menu items ("amm_sections_modspecials" and "amm_sections_modmenu")
    110147       *
    111        * These two parameters are replaced by a single parameter "amm_sections_items"
     148       * These two parameters are replaced by a single parameter "amm_blocks_items"
    112149       *
    113150       * This function aim to import the old conf into the new conf property
     
    117154        foreach($this->config['amm_sections_modspecials'] as $key=>$val)
    118155        {
    119           $this->config['amm_sections_items'][$key]['visibility']=($val=="y")?"guest,generic,normal,admin/":"admin/";
     156          $this->config['amm_blocks_items'][$key]['visibility']=($val=="y")?"guest,generic,normal,admin/":"admin/";
    120157        }
    121158        unset($this->config['amm_sections_modspecials']);
     
    126163        foreach($this->config['amm_sections_modmenu'] as $key=>$val)
    127164        {
    128           $this->config['amm_sections_items'][$key]['visibility']=($val=="y")?"guest,generic,normal,admin/":"admin/";
     165          $this->config['amm_blocks_items'][$key]['visibility']=($val=="y")?"guest,generic,normal,admin/":"admin/";
    129166        }
    130167        unset($this->config['amm_sections_modmenu']);
     
    140177      }
    141178
    142       if($this->config['installed']<="02.01.06")
    143       {
    144         /*
    145          * 2.2.0 updates
    146          *
    147          * - update fields length for table 'personalised'
    148          * - update config for menu translation
    149          */
    150         $sql="ALTER TABLE `".$this->tables['personalised']."`
    151               MODIFY COLUMN `title` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
    152               MODIFY COLUMN `nfo` VARCHAR(255)  CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;";
    153         pwg_query($sql);
    154 
    155         foreach($this->config['amm_sections_items'] as $key => $val)
     179      switch($this->config['installed'])
     180      {
     181        case '02.01.06':
     182          $this->config['newInstall']='n';
     183          $this->updateFrom_020106();
     184        case '02.02.00':
     185          $this->config['newInstall']='n';
     186          $this->updateFrom_020200();
     187        default:
     188          /*
     189           * default is applied for fresh install
     190           */
     191
     192          if($this->config['installed']<='02.02.02' or
     193             $this->config['newInstall']=='y')
     194          {
     195            /*
     196             * if    new install
     197             *    or plugin updated from a release <= 2.2.0
     198             *    or plugin
     199             *
     200             * update AMM menu from piwigo's menu
     201             */
     202            $this->backupMenuConfig(true);
     203          }
     204          else
     205          {
     206            /*
     207             * plugin actived without being installed or updated, only backup
     208             * the piwigo's menu
     209             */
     210            $this->backupMenuConfig(false);
     211          }
     212          break;
     213      }
     214
     215    }
     216
     217    /**
     218     * update the database from the release 2.1.6
     219     *
     220     * - update config for menu translation
     221     * - update fields length for table 'personalised'
     222     */
     223    private function updateFrom_020106()
     224    {
     225      $sql="ALTER TABLE `".$this->tables['personalised']."`
     226            MODIFY COLUMN `id` INTEGER  NOT NULL AUTO_INCREMENT,
     227            MODIFY COLUMN `title` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
     228            MODIFY COLUMN `nfo` VARCHAR(255)  CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;";
     229      pwg_query($sql);
     230
     231      foreach($this->config['amm_blocks_items'] as $key => $val)
     232      {
     233        $this->config['amm_blocks_items'][$key]['translation'] = $this->defaultMenus[$key]['translation'];
     234      }
     235    }
     236
     237
     238
     239    /**
     240     * update the database from the release 2.2.0
     241     *
     242     * - create 'personalised_lang' table ; filled from the 'personalised' table
     243     *   values
     244     * - modify 'personalised' table structure (remove lang attributes)
     245     * - modify 'urls' table structure (add users&group access)
     246     * - update 'urls' table values (default values for users access)
     247     * - update config (parameter 'amm_sections_items' is renamed into 'amm_blocks_items')
     248     */
     249    private function updateFrom_020200()
     250    {
     251      $tables_def=array(
     252"CREATE TABLE `".$this->tables['personalised_langs']."` (
     253  `id` INTEGER UNSIGNED NOT NULL DEFAULT 0,
     254  `lang` CHAR(5)  NOT NULL default '*',
     255  `title` VARCHAR(255)  NOT NULL default '',
     256  `content` TEXT  NOT NULL,
     257  PRIMARY KEY (`id`, `lang`)
     258)",
     259
     260"CREATE TABLE `".$this->tables['blocks']."` (
     261  `id` VARCHAR(40)  NOT NULL,
     262  `order` INTEGER UNSIGNED NOT NULL,
     263  `users` VARCHAR(1024)  NOT NULL,
     264  `groups` VARCHAR(1024)  NOT NULL,
     265  PRIMARY KEY (`id`),
     266  INDEX `byOrder`(`order`)
     267)"
     268      );
     269
     270      $tables_def = create_table_add_character_set($tables_def);
     271      $result=$this->tablef->create($tables_def);
     272
     273      $sql="INSERT INTO `".$this->tables['personalised_langs']."`
     274              SELECT pap.id, pap.lang, pap.title, pap.content
     275              FROM `".$this->tables['personalised']."` pap
     276              WHERE pap.title!='' OR pap.content!='';";
     277      pwg_query($sql);
     278
     279      $sql="ALTER TABLE `".$this->tables['personalised']."` DROP COLUMN `lang`,
     280             DROP COLUMN `title`,
     281             DROP COLUMN `content`;";
     282      pwg_query($sql);
     283
     284      $sql="ALTER TABLE `".$this->tables['urls']."`
     285            ADD COLUMN `accessUsers` VARCHAR(1024)  NOT NULL AFTER `visible`,
     286            ADD COLUMN `accessGroups` VARCHAR(1024)  NOT NULL AFTER `accessUser`;";
     287      pwg_query($sql);
     288
     289
     290      $users=new GPCUsers();
     291      $sql="UPDATE `".$this->tables['urls']."`
     292            SET accessUsers='".pwg_db_real_escape_string(implode(',', $users->getList()))."';";
     293      pwg_query($sql);
     294
     295      if(isset($this->config['amm_sections_items']))
     296      {
     297        $this->config['amm_blocks_items']=$this->config['amm_sections_items'];
     298        unset($this->config['amm_sections_items']);
     299      }
     300    }
     301
     302    /**
     303     * report hidden menu from piwigo's config to AMM config
     304     */
     305    private function backupMenuConfig($updateMenu=false)
     306    {
     307      global $conf;
     308
     309      $this->config['amm_old_blk_menubar']=$conf['blk_menubar'];
     310      pwg_query("UPDATE ".CONFIG_TABLE." SET value = '' WHERE param='blk_menubar';");
     311
     312      if($updateMenu)
     313      {
     314        $tmp=unserialize($conf['blk_menubar']);
     315        foreach($tmp as $key => $val)
    156316        {
    157           $this->config['amm_sections_items'][$key]['translation'] = $this->defaultMenus[$key]['translation'];
     317          pwg_query("REPLACE INTO ".$this->tables['blocks']." VALUES ('$key', '".abs($val)."', '".($val<0?'guest,generic,normal,webmaster,admin':'')."', '');");
    158318        }
    159319      }
    160320    }
    161321
     322    /**
     323     * restore piwigo's menu
     324     */
     325    private function restoreMenuConfig()
     326    {
     327      pwg_query("UPDATE ".CONFIG_TABLE." SET value = '".pwg_db_real_escape_string($this->config['amm_old_blk_menubar'])."' WHERE param='blk_menubar';");
     328    }
     329
     330
     331
    162332  } //class
    163333
  • extensions/AMenuManager/amm_pip.class.inc.php

    r5545 r8962  
    2222{
    2323  protected $displayRandomImageBlock=true;
     24  protected $registeredBlocks;
     25  protected $randomPictProp=null;
     26  protected $users;
     27  protected $groups;
     28  protected $currentBuiltMenu=-1;
    2429
    2530  function AMM_PIP($prefixeTable, $filelocation)
     
    2833    $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles()."2.css");
    2934
     35    $this->users=new GPCUsers();
     36    $this->groups=new GPCGroups();
     37
    3038    $this->loadConfig();
    3139    $this->initEvents();
     
    3341
    3442
    35   /* ---------------------------------------------------------------------------
    36   Public classe functions
    37   --------------------------------------------------------------------------- */
    38 
    39 
    40   /*
    41     initialize events call for the plugin
    42   */
     43  /**
     44   * initialize events call for the plugin
     45   */
    4346  public function initEvents()
    4447  {
    45     //TODELETE: add_event_handler('loc_begin_menubar', array(&$this, 'modify_menu') );
    4648    parent::initEvents();
    47     add_event_handler('loading_lang', array(&$this, 'load_lang'));
    48     add_event_handler('blockmanager_apply', array(&$this, 'blockmanager_apply') );
     49
     50    add_event_handler('blockmanager_prepare_display', array(&$this, 'blockmanagerSortBlocks') );
     51    add_event_handler('blockmanager_apply', array(&$this, 'blockmanagerApply') );
    4952    add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS'));
    50     add_event_handler('loc_end_page_tail', array(&$this, 'applyJS'));
    51   }
    52 
    53   /*
    54     load language file
    55   */
    56   public function load_lang()
    57   {
    58     global $lang;
    59 
    60     //load_language('plugin.lang', AMM_PATH);
    61 
    62     // ajax is managed here ; this permit to use user&language properties inside
    63     // ajax content
    64     $this->return_ajax_content();
    65   }
    66 
    67   public function blockmanager_apply( $menu_ref_arr )
    68   {
    69     global $user, $page;
    70     $menu = & $menu_ref_arr[0];
    71 
    72 
    73     /*
    74       Add a new random picture section
    75     */
    76     if ( ( ($block = $menu->get_block( 'mbAMM_randompict' ) ) != null ) && ($user['nb_total_images'] > 0) )
    77     {
    78       $block->set_title(  base64_decode($this->config['amm_randompicture_title'][$user['language']]) );
    79       $block->data = array(
    80         "delay" => $this->config['amm_randompicture_periodicchange'],
    81         "blockHeight" => $this->config['amm_randompicture_height'],
    82         "firstPicture" => $this->ajax_amm_get_random_picture()
     53    add_event_handler('loc_end_page_header', array(&$this, 'applyJS'));
     54    add_event_handler('get_categories_menu_sql_where', array(&$this, 'buildMenuFromCat'), 75);
     55  }
     56
     57
     58  public function blockmanagerApply($menu_ref_arr)
     59  {
     60    $menu=&$menu_ref_arr[0];
     61
     62    $this->addBlockRandomPicture($menu);
     63    $this->addBlockLinks($menu);
     64    $this->addBlockPersonnal($menu);
     65    $this->addBlockAlbum($menu);
     66    $this->manageBlocksContent($menu);
     67    $this->manageBlocks($menu);
     68  }
     69
     70
     71  /**
     72   * Add a new random picture block
     73   */
     74  private function addBlockRandomPicture(&$menu)
     75  {
     76    global $user;
     77
     78    if((
     79        ($block=$menu->get_block('mbAMM_randompict'))!=null) and
     80        ($user['nb_total_images']>0) and
     81        isset($this->config['amm_randompicture_title'][$user['language']])
     82      )
     83    {
     84      GPCCore::addHeaderJS('jquery', 'themes/default/js/jquery.packed.js');
     85      GPCCore::addHeaderJS('amm.randomPictPublic', 'plugins/AMenuManager/js/amm_randomPictPublic'.GPCCore::getMinified().'.js');
     86
     87      $block->set_title(base64_decode($this->config['amm_randompicture_title'][$user['language']]));
     88      $block->template=dirname(__FILE__).'/menu_templates/menubar_randompic.tpl';
     89
     90      $this->randomPictProp = array(
     91        'delay' => $this->config['amm_randompicture_periodicchange'],
     92        'blockHeight' => $this->config['amm_randompicture_height'],
     93        'showname' => $this->config['amm_randompicture_showname'],
     94        'showcomment' => $this->config['amm_randompicture_showcomment'],
     95        'pictures' => $this->getRandomPictures($this->config['amm_randompicture_preload'])
    8396      );
    84       $block->template = dirname(__FILE__).'/menu_templates/menubar_randompic.tpl';
     97
     98      if(count($this->randomPictProp['pictures'])==0) $this->displayRandomImageBlock=false;
    8599    }
    86100    else
     
    88102      $this->displayRandomImageBlock=false;
    89103    }
    90 
    91     /*
    92       Add a new section (links)
    93     */
    94     if ( ($block = $menu->get_block( 'mbAMM_links' ) ) != null )
    95     {
    96       $urls=$this->get_urls(true);
    97       if ( count($urls)>0 )
    98       {
     104  }
     105
     106
     107  /**
     108   * Add a new block (links)
     109   */
     110  private function addBlockLinks(&$menu)
     111  {
     112    global $user;
     113
     114    $nbLink=0;
     115
     116    if(($block=$menu->get_block('mbAMM_links'))!=null &&
     117       isset($this->config['amm_links_title'][$user['language']])
     118      )
     119    {
     120      $urls=$this->getLinks(true);
     121
     122      if(count($urls)>0)
     123      {
     124        $userGroups=$this->getUserGroups($user['id']);;
     125
     126        foreach($urls as $key => $val)
     127        {
     128          $this->users->setAlloweds(explode(",", $val['accessUsers']), false);
     129          $this->groups->setAlloweds(explode(",", $val['accessGroups']), false);
     130
     131          if(!$this->users->isAllowed($user['status']))
     132          {
     133            unset($urls[$key]);
     134          }
     135          else
     136          {
     137            $ok=true;
     138            foreach($userGroups as $group)
     139            {
     140              if(!$this->groups->isAllowed($group)) $ok=false;
     141            }
     142            if(!$ok) unset($urls[$key]);
     143          }
     144        }
     145
    99146        if($this->config['amm_links_show_icons']=='y')
    100147        {
    101           for($i=0;$i<count($urls);$i++)
     148          foreach($urls as $key => $url)
    102149          {
    103             $urls[$i]['icon']=get_root_url().'plugins/'.AMM_DIR."/links_pictures/".$urls[$i]['icon'];
     150            $urls[$key]['icon']=get_root_url().'plugins/'.AMM_DIR."/links_pictures/".$url['icon'];
    104151          }
    105152        }
    106153
    107         $block->set_title( base64_decode($this->config['amm_links_title'][$user['language']]) );
    108         $block->template = dirname(__FILE__).'/menu_templates/menubar_links.tpl';
     154        $block->set_title(base64_decode($this->config['amm_links_title'][$user['language']]));
     155        $block->template=dirname(__FILE__).'/menu_templates/menubar_links.tpl';
    109156
    110157        $block->data = array(
     
    114161      }
    115162    }
    116 
    117     /*
    118       Add personnal blocks random picture section
    119     */
    120     $sections=$this->get_sections(true);
     163  }
     164
     165
     166  /**
     167   * Add personnal blocks
     168   */
     169  private function addBlockPersonnal(&$menu)
     170  {
     171    $sections=$this->getPersonalisedBlocks(true);
    121172
    122173    if(count($sections))
    123174    {
    124       $id_done=array();
     175      $idDone=array();
    125176      foreach($sections as $key => $val)
    126177      {
    127         if(!isset($id_done[$val['id']]))
     178        if(!isset($idDone[$val['id']]))
    128179        {
    129           if ( ($block = $menu->get_block( 'mbAMM_personalised'.$val['id'] ) ) != null )
     180          if(($block=$menu->get_block('mbAMM_personalised'.$val['id']))!= null)
    130181          {
    131             $block->set_title( $val['title'] );
     182            $block->set_title($val['title']);
    132183            $block->template = dirname(__FILE__).'/menu_templates/menubar_personalised.tpl';
    133184            $block->data = stripslashes($val['content']);
    134185          }
    135           $id_done[$val['id']]="";
     186          $idDone[$val['id']]="";
    136187        }
    137188      }
    138189    }
    139 
    140 
    141     /* manage items from special & menu sections
    142      *  reordering items
    143      *  grouping items
    144      *  managing rights to access
    145     */
     190  }
     191
     192
     193
     194
     195  /**
     196   * Add album to menu
     197   */
     198  private function addBlockAlbum(&$menu)
     199  {
     200    if(count($this->config['amm_albums_to_menu'])>0)
     201    {
     202      $sql="SELECT id, name, permalink, global_rank
     203            FROM ".CATEGORIES_TABLE."
     204            WHERE id IN(".implode(',', $this->config['amm_albums_to_menu']).");";
     205
     206      $result=pwg_query($sql);
     207      if($result)
     208      {
     209        while($row=pwg_db_fetch_assoc($result))
     210        {
     211          $this->currentBuiltMenu=$row['id'];
     212
     213          $row['name']=trigger_event('render_category_name', $row['name'], 'amm_album_to_menu');
     214
     215          if(($block=$menu->get_block('mbAMM_album'.$row['id']))!= null)
     216          {
     217            $block->set_title($row['name']);
     218            $block->template = dirname(__FILE__).'/menu_templates/menubar_album.tpl';
     219            $block->data = array(
     220              'album' => get_categories_menu(),
     221              'name' => $row['name'],
     222              'link' => make_index_url(array('category' => $row)),
     223              'nbPictures' => ''
     224            );
     225          }
     226        }
     227      }
     228      $this->currentBuiltMenu=-1;
     229    }
     230  }
     231
     232  /**
     233   * manage items from special & menu blocks
     234   *  - reordering items
     235   *  - grouping items
     236   *  - managing rights to access
     237   */
     238  private function manageBlocksContent(&$menu)
     239  {
     240    global $user;
     241
    146242    $blocks=Array();
    147243
    148244    if($menu->is_hidden('mbMenu'))
    149245    {
    150       // if block is hidden, make a fake to manage AMM features
     246      // if block is hidden, make a fake to manage AMM submenu features
    151247      // the fake block isn't displayed
    152248      $blocks['menu']=new DisplayBlock('amm_mbMenu');
     
    160256    if($menu->is_hidden('mbSpecials'))
    161257    {
    162       // if block is hidden, make a fake to manage AMM features
     258      // if block is hidden, make a fake to manage AMM submenu features
    163259      // the fake block isn't displayed
    164260      $blocks['special']=new DisplayBlock('amm_mbSpecial');
     
    171267
    172268    $menuItems=array_merge($blocks['menu']->data, $blocks['special']->data);
    173     $this->sortSectionsItems();
     269    $this->sortCoreBlocksItems();
    174270
    175271    $blocks['menu']->data=Array();
    176272    $blocks['special']->data=Array();
    177 
    178     $users=new GPCUsers("");
    179     $groups=new GPCGroups("");
    180     $user_groups=$this->get_user_groups($user['id']);
    181 
    182     foreach($this->config['amm_sections_items'] as $key => $val)
     273    $userGroups=$this->getUserGroups($user['id']);
     274
     275    foreach($this->config['amm_blocks_items'] as $key => $val)
    183276    {
    184277      if(isset($menuItems[$key]))
    185278      {
    186279        $access=explode("/",$val['visibility']);
    187         $users->setAlloweds(str_replace(",", "/", $access[0]));
    188         $groups->setAlloweds(str_replace(",", "/", $access[1]));
    189 
    190         /* test if user status is allowed to access the menu item
     280        $this->users->setAlloweds(str_replace(",", "/", $access[0]), false);
     281        $this->groups->setAlloweds(str_replace(",", "/", $access[1]), false);
     282
     283        /*
     284         * test if user status is allowed to access the menu item
    191285         * if access is managed by group, the user have to be associated with an allowed group to access the menu item
    192         */
    193         if($users->isAllowed($user['status']) && (
    194             ($access[1]=='') ||
    195             (($access[1]!='') && $groups->areAllowed($user_groups)))
    196         )
     286         */
     287        if($this->users->isAllowed($user['status']))
    197288        {
    198           $blocks[$val['container']]->data[$key]=$menuItems[$key];
     289          $ok=true;
     290          foreach($userGroups as $group)
     291          {
     292            if(!$this->groups->isAllowed($group)) $ok=false;
     293          }
     294          if($ok) $blocks[$val['container']]->data[$key]=$menuItems[$key];
    199295        }
    200296      }
     
    205301
    206302
    207   protected function get_user_groups($user_id)
    208   {
     303  /**
     304   * return groups for a user
     305   *
     306   * @param String $userId
     307   * @return Array
     308   */
     309  private function getUserGroups($userId)
     310  {
     311    global $user;
     312
    209313    $returned=array();
    210     $sql="SELECT group_id FROM ".USER_GROUP_TABLE."
    211           WHERE user_id = ".$user_id." ";
     314
     315    $sql="SELECT group_id FROM ".USER_GROUP_TABLE." WHERE user_id='".$user['id']."';";
    212316    $result=pwg_query($sql);
    213317    if($result)
     
    215319      while($row=pwg_db_fetch_assoc($result))
    216320      {
    217         array_push($returned, $row['group_id']);
     321        $returned[]=$row['group_id'];
    218322      }
    219323    }
     
    221325  }
    222326
    223   /*
    224     return ajax content
    225   */
    226   protected function return_ajax_content()
    227   {
    228     global $ajax, $template;
    229 
    230     if(isset($_REQUEST['ajaxfct']))
    231     {
    232       if($_REQUEST['ajaxfct']=='randompic')
    233       {
    234         $result="<p class='errors'>".l10n('g002_error_invalid_ajax_call')."</p>";
    235         switch($_REQUEST['ajaxfct'])
     327
     328  /**
     329   * reordering blocks and manage access right
     330   *
     331   */
     332  private function manageBlocks($menu)
     333  {
     334    $this->registeredBlocks=$this->getRegisteredBlocks(true);
     335
     336    foreach($menu->get_registered_blocks() as $key => $block)
     337    {
     338      if(!isset($this->registeredBlocks[$block->get_id()]))
     339      {
     340        $menu->hide_block($block->get_id());
     341      }
     342    }
     343
     344  }
     345
     346
     347  /**
     348   * sort menu blocks according to AMM rules (overriding piwigo's sort rules)
     349   */
     350  public function blockmanagerSortBlocks($blocks)
     351  {
     352    $this->registeredBlocks=$this->getRegisteredBlocks(true);
     353
     354    foreach($blocks[0]->get_registered_blocks() as $key => $block)
     355    {
     356      if(isset($this->registeredBlocks[$block->get_id()]))
     357      {
     358        $blocks[0]->set_block_position($block->get_id(), $this->registeredBlocks[$block->get_id()]['order']);
     359      }
     360    }
     361  }
     362
     363
     364
     365
     366
     367
     368
     369  /**
     370   * return a list of thumbnails
     371   * each array items is an array
     372   *  'imageId'   => (integer)
     373   *  'imageFile' => (String)
     374   *  'comment'   => (String)
     375   *  'path'      => (String)
     376   *  'tn_ext'    => (String)
     377   *  'catId'     => (String)
     378   *  'name'      => (String)
     379   *  'permalink' => (String)
     380   *  'imageName' => (String)
     381   *
     382   * @param Integer $number : number of returned images
     383   * @return Array
     384   */
     385  private function getRandomPictures($num=25)
     386  {
     387    global $user;
     388
     389    $returned=array();
     390
     391    $sql=array();
     392
     393    $sql['select']="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 ";
     394    $sql['from']="FROM ".CATEGORIES_TABLE." c, ".IMAGES_TABLE." i, ".IMAGE_CATEGORY_TABLE." ic ";
     395    $sql['where']="WHERE c.id = ic.category_id
     396            AND ic.image_id = i.id
     397            AND i.level <= ".$user['level']." ";
     398
     399    if($user['forbidden_categories']!="")
     400    {
     401      $sql['where'].=" AND c.id NOT IN (".$user['forbidden_categories'].") ";
     402    }
     403
     404    switch($this->config['amm_randompicture_selectMode'])
     405    {
     406      case 'f':
     407        $sql['from'].=", ".USER_INFOS_TABLE." ui
     408          LEFT JOIN ".FAVORITES_TABLE." f ON ui.user_id=f.user_id ";
     409        $sql['where'].=" AND ui.status='webmaster'
     410                         AND f.image_id = i.id ";
     411        break;
     412      case 'c':
     413        $sql['where'].="AND (";
     414        foreach($this->config['amm_randompicture_selectCat'] as $key => $val)
    236415        {
    237           case 'randompic':
    238             $result=$this->ajax_amm_get_random_picture();
    239             break;
     416          $sql['where'].=($key==0?'':' OR ')." FIND_IN_SET($val, c.uppercats) ";
    240417        }
    241         GPCAjax::returnResult($result);
    242       }
    243     }
    244   }
    245 
    246 
    247   // return the html content for the random picture block
    248   private function ajax_amm_get_random_picture()
    249   {
    250     global $user;
    251 
    252     $local_tpl = new Template(AMM_PATH."menu_templates/", "");
    253     $local_tpl->set_filename('body_page',
    254                   dirname($this->getFileLocation()).'/menu_templates/menubar_randompic_inner.tpl');
    255 
    256       $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
    257             FROM ".CATEGORIES_TABLE." c, ".IMAGES_TABLE." i, ".IMAGE_CATEGORY_TABLE." ic
    258             WHERE c.id = ic.category_id
    259               AND ic.image_id = i.id
    260               AND i.level <= ".$user['level']." ";
    261       if($user['forbidden_categories']!="")
    262       {
    263         $sql.=" AND c.id NOT IN (".$user['forbidden_categories'].") ";
    264       }
    265 
    266       $sql.=" ORDER BY rndvalue
    267             LIMIT 0,1";
    268 
    269 
    270       $result = pwg_query($sql);
    271       if($result and $nfo = pwg_db_fetch_assoc($result))
    272       {
    273         $nfo['section']='category';
    274         $nfo['category']=array(
    275           'id' => $nfo['catid'],
    276           'name' => $nfo['name'],
    277           'permalink' => $nfo['permalink']
     418        $sql['where'].=") ";
     419        break;
     420    }
     421
     422    $sql=$sql['select'].$sql['from'].$sql['where']." ORDER BY rndvalue LIMIT 0,$num";
     423
     424
     425    $result = pwg_query($sql);
     426    if($result)
     427    {
     428      while($row=pwg_db_fetch_assoc($result))
     429      {
     430        $row['section']='category';
     431        $row['category']=array(
     432          'id' => $row['catid'],
     433          'name' => $row['name'],
     434          'permalink' => $row['permalink']
    278435        );
    279436
    280         $template_datas = array(
    281           'LINK' => make_picture_url($nfo),
    282           'IMG' => get_thumbnail_url($nfo),
    283           'IMGNAME' => $nfo['imgname'],
    284           'IMGCOMMENT' => $nfo['comment'],
    285           'SHOWNAME' => $this->config['amm_randompicture_showname'],
    286           'SHOWCOMMENT' => $this->config['amm_randompicture_showcomment']
    287         );
    288       }
    289       else
    290       {
    291         $template_datas = array();
    292       }
    293 
    294     $local_tpl->assign('datas', $template_datas);
    295     $local_tpl->assign('plugin', array('PATH' => AMM_PATH));
    296 
    297     return($local_tpl->parse('body_page', true));
    298   }
     437        $row['link']=make_picture_url($row);
     438        $row['thumb']=get_thumbnail_url($row);
     439
     440        $returned[]=$row;
     441      }
     442    }
     443
     444    return($returned);
     445  }
     446
     447
    299448
    300449
     
    315464    }
    316465
     466
    317467    if($this->displayRandomImageBlock && $page['body_id'] == 'theCategoryPage')
    318468    {
     
    320470      $local_tpl->set_filename('body_page', dirname($this->getFileLocation()).'/menu_templates/menubar_randompic.js.tpl');
    321471
    322       $data = array(
    323         "delay" => $this->config['amm_randompicture_periodicchange'],
    324         "blockHeight" => $this->config['amm_randompicture_height'],
    325         "firstPicture" => $this->ajax_amm_get_random_picture()
    326       );
    327 
    328       $local_tpl->assign('data', $data);
    329 
    330       $template->append('footer_elements', $local_tpl->parse('body_page', true));
    331     }
    332 
     472      $local_tpl->assign('data', $this->randomPictProp);
     473
     474      $template->append('head_elements', $local_tpl->parse('body_page', true));
     475    }
     476  }
     477
     478
     479
     480  public function buildMenuFromCat($where)
     481  {
     482    global $user;
     483
     484    if($this->currentBuiltMenu>-1)
     485    {
     486      if($user['expand'])
     487      {
     488        $where=preg_replace('/id_uppercat\s+is\s+NULL/i', 'id_uppercat is NOT NULL', $where);
     489      }
     490      else
     491      {
     492        $where=preg_replace('/id_uppercat\s+is\s+NULL/i', 'id_uppercat is NULL OR id_uppercat IN ('.$this->currentBuiltMenu.')', $where);
     493      }
     494
     495      $where.=" AND FIND_IN_SET(".$this->currentBuiltMenu.", uppercats) AND cat_id!=".$this->currentBuiltMenu." ";
     496    }
     497
     498    return($where);
    333499  }
    334500
  • extensions/AMenuManager/amm_root.class.inc.php

    r5545 r8962  
    1717if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
    1818
     19include_once(PHPWG_ROOT_PATH.'include/block.class.php');
    1920include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
    2021include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCUsersGroups.class.inc.php');
     
    2627  protected $css;   //the css object
    2728  protected $defaultMenus = array(
    28     'favorites' => array('container' => 'special', 'visibility' => 'guest,generic,normal,webmaster,admin/', 'order' => 0, 'translation' => 'My favorites'),
    29     'most_visited' => array('container' => 'special', 'visibility' => 'guest,generic,normal,webmaster,admin/', 'order' => 1, 'translation' => 'Most visited'),
    30     'best_rated' => array('container' => 'special', 'visibility' => 'guest,generic,normal,webmaster,admin/', 'order' => 2, 'translation' => 'Best rated'),
    31     'random' => array('container' => 'special', 'visibility' => 'guest,generic,normal,webmaster,admin/', 'order' => 3, 'translation' => 'Random pictures'),
    32     'recent_pics' => array('container' => 'special', 'visibility' => 'guest,generic,normal,webmaster,admin/', 'order' => 4, 'translation' => 'Recent pictures'),
    33     'recent_cats' => array('container' => 'special', 'visibility' => 'guest,generic,normal,webmaster,admin/', 'order' => 5, 'translation' => 'Recent categories'),
    34     'calendar' => array('container' => 'special', 'visibility' => 'guest,generic,normal,webmaster,admin/', 'order' => 6, 'translation' => 'Calendar'),
    35     'qsearch' => array('container' => 'menu', 'visibility' => 'guest,generic,normal,webmaster,admin/', 'order' => 0, 'translation' => 'Quick search'),
    36     'tags' => array('container' => 'menu', 'visibility' => 'guest,generic,normal,webmaster,admin/', 'order' => 1, 'translation' => 'Tags'),
    37     'search' => array('container' => 'menu', 'visibility' => 'guest,generic,normal,webmaster,admin/', 'order' => 2, 'translation' => 'Search'),
    38     'comments' => array('container' => 'menu', 'visibility' => 'guest,generic,normal,webmaster,admin/', 'order' => 3, 'translation' => 'Comments'),
    39     'about' => array('container' => 'menu', 'visibility' => 'guest,generic,normal,webmaster,admin/', 'order' => 4, 'translation' => 'About'),
    40     'rss' => array('container' => 'menu', 'visibility' => 'guest,generic,normal,webmaster,admin/', 'order' => 5, 'translation' => 'Notification')
     29    /* about visibility & accessibility system :
     30     *  - by default, everything is visible (users & groups)
     31     *  - items not visibles are listed (in release < 3.3.4, this rule wa applied to groups only)
     32     *
     33     * on the user interface, checked items are visibles => not checked items are stored
     34     */
     35    'favorites' => array('container' => 'special', 'visibility' => '/', 'order' => 0, 'translation' => 'My favorites'),
     36    'most_visited' => array('container' => 'special', 'visibility' => '/', 'order' => 1, 'translation' => 'Most visited'),
     37    'best_rated' => array('container' => 'special', 'visibility' => '/', 'order' => 2, 'translation' => 'Best rated'),
     38    'random' => array('container' => 'special', 'visibility' => '/', 'order' => 3, 'translation' => 'Random pictures'),
     39    'recent_pics' => array('container' => 'special', 'visibility' => '/', 'order' => 4, 'translation' => 'Recent pictures'),
     40    'recent_cats' => array('container' => 'special', 'visibility' => '/', 'order' => 5, 'translation' => 'Recent categories'),
     41    'calendar' => array('container' => 'special', 'visibility' => '/', 'order' => 6, 'translation' => 'Calendar'),
     42    'qsearch' => array('container' => 'menu', 'visibility' => '/', 'order' => 0, 'translation' => 'Quick search'),
     43    'tags' => array('container' => 'menu', 'visibility' => '/', 'order' => 1, 'translation' => 'Tags'),
     44    'search' => array('container' => 'menu', 'visibility' => '/', 'order' => 2, 'translation' => 'Search'),
     45    'comments' => array('container' => 'menu', 'visibility' => '/', 'order' => 3, 'translation' => 'Comments'),
     46    'about' => array('container' => 'menu', 'visibility' => '/', 'order' => 4, 'translation' => 'About'),
     47    'rss' => array('container' => 'menu', 'visibility' => '/', 'order' => 5, 'translation' => 'Notification')
    4148  );
     49  protected $urlsModes=array(0 => 'new_window', 1 => 'current_window');
     50
     51
    4252
    4353  public function __construct($prefixeTable, $filelocation)
     
    4757    parent::__construct($prefixeTable, $filelocation);
    4858
    49     $list=array('urls', 'personalised');
     59    $list=array('urls', 'personalised', 'personalised_langs', 'blocks');
    5060    $this->setTablesList($list);
    5161  }
     
    5868  }
    5969
    60   /* ---------------------------------------------------------------------------
    61   common AIP & PIP functions
    62   --------------------------------------------------------------------------- */
    63 
    64   /* this function initialize var $my_config with default values */
     70  /*
     71   * ---------------------------------------------------------------------------
     72   * common AIP & PIP functions
     73   * ---------------------------------------------------------------------------
     74   */
     75
     76  /**
     77   * this function initialize config var with default values
     78   */
    6579  public function initConfig()
    6680  {
     
    6882      'amm_links_show_icons' => 'y',
    6983      'amm_links_title' => array(),
     84      'amm_randompicture_preload' => 25,     //number preloaded random pictures
    7085      'amm_randompicture_showname' => 'n',     //n:no, o:over, u:under
    7186      'amm_randompicture_showcomment' => 'n',   //n:no, o:over, u:under
     
    7388      'amm_randompicture_height' => 0,           //0: automatic, otherwise it's the fixed height in pixels
    7489      'amm_randompicture_title' => array(),
    75       'amm_sections_items' => $this->defaultMenus
     90      'amm_randompicture_selectMode' => 'a',     // a:all, f:webmaster's favorites, c:categories
     91      'amm_randompicture_selectCat' => array(),  // categories id list
     92      'amm_blocks_items' => $this->defaultMenus,
     93      'amm_albums_to_menu' => array(),
     94      'amm_old_blk_menubar' => ''                // keep a copy of piwigo's menubar config
    7695    );
    7796
     
    99118  public function initEvents()
    100119  {
    101     add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') );
    102   }
    103 
    104   public function register_blocks( $menu_ref_arr )
     120    add_event_handler('blockmanager_register_blocks', array(&$this, 'registerBlocks') );
     121  }
     122
     123  public function registerBlocks( $menu_ref_arr )
    105124  {
    106125    $menu = & $menu_ref_arr[0];
    107     if ($menu->get_id() != 'menubar')
    108       return;
     126    if ($menu->get_id() != 'menubar') return;
     127
    109128    $menu->register_block( new RegisteredBlock( 'mbAMM_randompict', 'Random pictures', 'AMM'));
    110129    $menu->register_block( new RegisteredBlock( 'mbAMM_links', 'Links', 'AMM'));
    111130
    112     $sections=$this->get_sections(true);
    113     if(count($sections))
    114     {
    115       $id_done=array();
    116       foreach($sections as $key => $val)
    117       {
    118         if(!isset($id_done[$val['id']]))
     131    $blocks=$this->getPersonalisedBlocks();
     132    if(count($blocks))
     133    {
     134      $idDone=array();
     135      foreach($blocks as $key => $val)
     136      {
     137        if(!isset($idDone[$val['id']]))
    119138        {
    120139          $menu->register_block( new RegisteredBlock( 'mbAMM_personalised'.$val['id'], $val['title'], 'AMM'));
    121           $id_done[$val['id']]="";
     140          $idDone[$val['id']]="";
    122141        }
    123142      }
    124143    }
    125   }
    126 
    127   // return an array of urls (each url is an array)
    128   protected function get_urls($only_visible=false)
     144
     145    $this->loadConfig();
     146
     147    if(count($this->config['amm_albums_to_menu'])>0)
     148    {
     149      $sql="SELECT id, name
     150            FROM ".CATEGORIES_TABLE."
     151            WHERE id IN(".implode(',', $this->config['amm_albums_to_menu']).");";
     152
     153      $result=pwg_query($sql);
     154      if($result)
     155      {
     156        while($row=pwg_db_fetch_assoc($result))
     157        {
     158          $row['name']=trigger_event('render_category_name', $row['name'], 'amm_album_to_menu');
     159
     160          $menu->register_block( new RegisteredBlock( 'mbAMM_album'.$row['id'], $row['name'].' ('.l10n('g002_album2menu').') ', 'AMM'));
     161        }
     162      }
     163    }
     164  }
     165
     166
     167  /*
     168   *  ---------------------------------------------------------------------------
     169   *
     170   * Links functions
     171   *
     172   * ---------------------------------------------------------------------------
     173   */
     174
     175  /**
     176   * return an array of links (each url is an array)
     177   *
     178   * @param Bool onlyVisible : if true, only visible links are returned
     179   * @return Array
     180   */
     181  protected function getLinks($onlyVisible=false)
    129182  {
    130183    $returned=array();
    131     $sql="SELECT * FROM ".$this->tables['urls'];
    132     if($only_visible)
     184    $sql="SELECT id, label, url, mode, icon, position, visible, accessUsers, accessGroups
     185          FROM ".$this->tables['urls'];
     186    if($onlyVisible)
    133187    {
    134188      $sql.=" WHERE visible = 'y' ";
    135189    }
    136     $sql.=" ORDER BY position";
     190    $sql.=" ORDER BY position ASC, id ASC";
    137191    $result=pwg_query($sql);
    138192    if($result)
     
    140194      while($row=pwg_db_fetch_assoc($result))
    141195      {
    142         $row['label']=stripslashes($row['label']);
    143196        $returned[]=$row;
    144197      }
     
    147200  }
    148201
    149   //return number of url
    150   protected function get_count_url($only_visible=false)
     202  /**
     203   * return values for a given link
     204   *
     205   * @param String $id : link id
     206   * @return Array
     207   */
     208  protected function getLink($id)
     209  {
     210    $returned=array();
     211    $sql="SELECT id, label, url, mode, icon, position, visible, accessUsers, accessGroups
     212          FROM ".$this->tables['urls']."
     213          WHERE id = '$id';";
     214    $result=pwg_query($sql);
     215    if($result)
     216    {
     217      while($row=pwg_db_fetch_assoc($result))
     218      {
     219        $returned=$row;
     220      }
     221    }
     222    return($returned);
     223  }
     224
     225  /**
     226   * set values for a link
     227   * if link id is empty : create a new link
     228   * if not, update link
     229   *
     230   * @param String $id : link id
     231   * @return Integer : -1 if fails
     232   *                   otherwise link id
     233   */
     234  protected function setLink($id, $label, $url, $mode, $icon, $visible, $accessUsers, $accessGroups)
     235  {
     236    if($id=='')
     237    {
     238      $sql="INSERT INTO ".$this->tables['urls']." VALUES
     239            ('',
     240             '".pwg_db_real_escape_string($label)."',
     241             '".pwg_db_real_escape_string($url)."',
     242             '$mode',
     243             '$icon',
     244             0,
     245             '$visible',
     246             '$accessUsers',
     247             '$accessGroups'
     248            );";
     249    }
     250    else
     251    {
     252      $sql="UPDATE ".$this->tables['urls']."
     253            SET label='".pwg_db_real_escape_string($label)."',
     254                url='".pwg_db_real_escape_string($url)."',
     255                mode='$mode',
     256                icon='$icon',
     257                visible='$visible',
     258                accessUsers='".pwg_db_real_escape_string($accessUsers)."',
     259                accessGroups='".pwg_db_real_escape_string($accessGroups)."'
     260            WHERE id='$id';";
     261    }
     262    $result=pwg_query($sql);
     263    if($result)
     264    {
     265      if($id=='')
     266      {
     267        return(pwg_db_insert_id());
     268      }
     269      else
     270      {
     271        return($id);
     272      }
     273    }
     274    return(-1);
     275  }
     276
     277  /**
     278   * delete a given link
     279   *
     280   * @param String $id : link id
     281   * @return Bool : true if deleted, otherwise false
     282   */
     283  protected function deleteLink($id)
     284  {
     285    $sql="DELETE FROM ".$this->tables['urls']."
     286          WHERE id = '$id';";
     287    $result=pwg_query($sql);
     288    if($result) return(true);
     289    return(false);
     290  }
     291
     292
     293
     294  /**
     295   * return number of links
     296   *
     297   * @param Bool onlyVisible : if true, only visible links are counted
     298   * @return Array
     299   */
     300  protected function getLinksCount($onlyVisible=false)
    151301  {
    152302    $returned=0;
    153303    $sql="SELECT count(id) FROM ".$this->tables['urls'];
    154     if($only_visible)
     304    if($onlyVisible)
    155305    {
    156306      $sql.=" WHERE visible = 'y' ";
     
    165315  }
    166316
    167   // return an array of sections (each section is an array)
    168   protected function get_sections($only_visible=false, $lang="", $only_with_content=true)
     317  /**
     318   * set order from given links
     319   *
     320   * @param Array $links : array
     321   *                        each item is an array ('id' => '', 'order' =>'')
     322   * @return Bool :
     323   */
     324  protected function setLinksOrder($links)
     325  {
     326    $returned=true;
     327
     328    foreach($links as $link)
     329    {
     330      $sql="UPDATE ".$this->tables['urls']."
     331            SET position='".$link['order']."'
     332            WHERE id='".$link['id']."';";
     333      $result=pwg_query($sql);
     334      if(!$result) $returned=false;
     335    }
     336    return($returned);
     337  }
     338
     339
     340  /*
     341   *  ---------------------------------------------------------------------------
     342   *
     343   * Personalised Blocks functions
     344   *
     345   * ---------------------------------------------------------------------------
     346   */
     347
     348
     349  /**
     350   * return an array of personalised blocks (each block is an array)
     351   *
     352   * @param Bool onlyVisible : if true, only visibles blocks are returned
     353   * @return Array
     354   */
     355  protected function getPersonalisedBlocks($onlyVisible=false, $lang='', $emptyContent=false)
    169356  {
    170357    global $user;
    171358
    172     if($lang=="")
    173     {
    174       $lang=$user['language'];
    175     }
     359    if($lang=="") $lang=$user['language'];
    176360
    177361    $returned=array();
    178     $sql="SELECT * FROM ".$this->tables['personalised']."
    179 WHERE (lang = '*' OR lang = '".$lang."') ";
    180     if($only_visible)
    181     {
    182       $sql.=" AND visible = 'y' ";
    183     }
    184     if($only_with_content)
    185     {
    186       $sql.=" AND content != '' ";
    187     }
    188     $sql.=" ORDER BY id, lang DESC ";
     362    $sql="SELECT pt.id, pt.visible, pt.nfo, ptl.lang, ptl.title, ptl.content
     363          FROM ".$this->tables['personalised']." pt
     364            LEFT JOIN ".$this->tables['personalised_langs']." ptl
     365            ON pt.id=ptl.id
     366          WHERE (ptl.lang = '*' OR ptl.lang = '".$lang."') ";
     367
     368    if($onlyVisible) $sql.=" AND pt.visible = 'y' ";
     369    if($emptyContent==false) $sql.=" AND ptl.content != '' ";
     370
     371    $sql.=" ORDER BY pt.id, ptl.lang ASC ";
     372
    189373    $result=pwg_query($sql);
    190374    if($result)
     
    198382  }
    199383
    200 
    201   protected function sortSectionsItemsCompare($a, $b)
     384  /**
     385   * return values for a given personalised block
     386   *
     387   * @param String $id : link id
     388   * @return Array
     389   */
     390  protected function getPersonalisedBlock($id)
     391  {
     392    $returned=array(
     393      'visible' => false,
     394      'nfo' => '',
     395      'langs' => array()
     396    );
     397
     398    $sql="SELECT visible, nfo
     399          FROM ".$this->tables['personalised']."
     400          WHERE id='$id';";
     401
     402    $result=pwg_query($sql);
     403    if($result)
     404    {
     405      while($row=pwg_db_fetch_assoc($result))
     406      {
     407        $returned['visible']=$row['visible'];
     408        $returned['nfo']=$row['nfo'];
     409      }
     410
     411      $sql="SELECT lang, title, content
     412            FROM ".$this->tables['personalised_langs']."
     413            WHERE id='$id'
     414            ORDER BY lang ASC;";
     415
     416      $result=pwg_query($sql);
     417      if($result)
     418      {
     419        while($row=pwg_db_fetch_assoc($result))
     420        {
     421          $returned['langs'][$row['lang']]=$row;
     422        }
     423      }
     424    }
     425    return($returned);
     426  }
     427
     428  /**
     429   * set values for a personalised block
     430   * if block id is empty : create a new block
     431   * if not, update block
     432   *
     433   * @param String $id : block id
     434   * @return Integer : -1 if fails
     435   *                   otherwise block id
     436   */
     437  protected function setPersonalisedBlock($id, $visible, $nfo, $langs)
     438  {
     439    $ok=false;
     440
     441    if($id=='')
     442    {
     443      $sql="INSERT INTO ".$this->tables['personalised']." VALUES
     444            ('',
     445             '$visible',
     446             '".pwg_db_real_escape_string($nfo)."'
     447            );";
     448      $result=pwg_query($sql);
     449      if($result) $ok=true;
     450      $id=pwg_db_insert_id();
     451    }
     452    else
     453    {
     454      $sql="UPDATE ".$this->tables['personalised']."
     455            SET visible='$visible',
     456                nfo='".pwg_db_real_escape_string($nfo)."'
     457            WHERE id='$id';";
     458      $result=pwg_query($sql);
     459      if($result)
     460      {
     461        $sql="DELETE FROM ".$this->tables['personalised_langs']."
     462              WHERE id='$id';";
     463        $result=pwg_query($sql);
     464
     465        if($result) $ok=true;
     466      }
     467    }
     468
     469    if($ok)
     470    {
     471      $values=array();
     472      foreach($langs as $key => $lang)
     473      {
     474        $values[]="('$id',
     475                    '".$lang['lang']."',
     476                    '".pwg_db_real_escape_string($lang['title'])."',
     477                    '".pwg_db_real_escape_string($lang['content'])."')";
     478      }
     479      $sql="INSERT INTO ".$this->tables['personalised_langs']." VALUES ".implode(',', $values);
     480      $result=pwg_query($sql);
     481
     482      if($result) $ok=true;
     483    }
     484
     485    if($ok) return($id);
     486    return(-1);
     487  }
     488
     489  /**
     490   * delete a given personalised block
     491   *
     492   * @param String $id : block id
     493   * @return Bool : true if deleted, otherwise false
     494   */
     495  protected function deletePersonalisedBlock($id)
     496  {
     497    $sql="DELETE FROM ".$this->tables['personalised']."
     498          WHERE id = '$id';";
     499    $result=pwg_query($sql);
     500    if($result)
     501    {
     502      $sql="DELETE FROM ".$this->tables['personalised_langs']."
     503            WHERE id = '$id';";
     504      $result=pwg_query($sql);
     505
     506      if($result) return(true);
     507    }
     508
     509    return(false);
     510  }
     511
     512
     513
     514  /**
     515   * return an array of all registered blocks
     516   * each array item is an array :
     517   *  String  'id'      => ''
     518   *  Integer 'order'   => 0
     519   *  Array   'users'   => array()
     520   *  Array   'groups'  => array()
     521   *  String  'name'    => ''
     522   *  String  'owner'   => ''
     523   *
     524   * @param Bool $userFiltered : true if returned blocks are filtered to current
     525   *                             user
     526   * @return Array
     527   */
     528  protected function getRegisteredBlocks($userFiltered=false)
     529  {
     530    global $conf, $user;
     531
     532    $returned=array();
     533    $order=0;
     534    $users=new GPCUsers();
     535    $groups=new GPCGroups();
     536
     537    $menu = new BlockManager('menubar');
     538    $menu->load_registered_blocks();
     539    $registeredBlocks = $menu->get_registered_blocks();
     540
     541    $sql="SELECT id, `order`, users, groups
     542          FROM ".$this->tables['blocks']."
     543          ORDER BY `order`;";
     544    $result=pwg_query($sql);
     545    if($result)
     546    {
     547      while($row=pwg_db_fetch_assoc($result))
     548      {
     549        $row['users']=explode(',', $row['users']);
     550        $row['groups']=explode(',', $row['groups']);
     551
     552        if(isset($registeredBlocks[$row['id']]))
     553        {
     554          $ok=true;
     555          if($userFiltered)
     556          {
     557            $users->setAlloweds($row['users'], false);
     558            if($users->isAllowed($user['status']))
     559            {
     560              $groups->setAlloweds($row['groups'], false);
     561              foreach($row['groups'] as $val)
     562              {
     563                if(!$groups->isAllowed($val)) $ok=false;
     564              }
     565            }
     566            else
     567            {
     568              $ok=false;
     569            }
     570          }
     571
     572          if($ok)
     573          {
     574            $returned[$row['id']]=array(
     575              'id'    => $row['id'],
     576              'order' => $row['order'],
     577              'users' => $row['users'],
     578              'groups'=> $row['groups'],
     579              'name'  => $registeredBlocks[$row['id']]->get_name(),
     580              'owner' => $registeredBlocks[$row['id']]->get_owner()
     581            );
     582            $order=$row['order'];
     583          }
     584          unset($registeredBlocks[$row['id']]);
     585        }
     586      }
     587    }
     588
     589    /*
     590     * add new blocks, unknown from plugin
     591     * by default, users & groups are visibles
     592     */
     593    foreach($registeredBlocks as $key=>$val)
     594    {
     595      $order+=10;
     596
     597      $returned[$key]=array(
     598        'id'    => $key,
     599        'order' => $order,
     600        'users' => array(),
     601        'groups'=> array(),
     602        'name'  => $val->get_name(),
     603        'owner' => $val->get_owner()
     604      );
     605    }
     606
     607    return($returned);
     608  }
     609
     610
     611  /**
     612   * set order for registered blocks
     613   *
     614   * note : Piwigo's order is maintened
     615   *
     616   * @param Array $block : array of block ; each items is an array
     617   *                        String  'id'    => ''
     618   *                        Integer 'order' => ''
     619   *                        Array   'users'   => array()
     620   *                        Array   'groups'  => array()
     621   * @return Bool : true, false is something is wrong
     622   */
     623  protected function setRegisteredBlocks($blocks)
     624  {
     625    $returned=true;
     626
     627    $sql="DELETE FROM ".$this->tables['blocks'];
     628    pwg_query($sql);
     629
     630    foreach($blocks as $block)
     631    {
     632      $sql="INSERT INTO ".$this->tables['blocks']." VALUES (
     633            '".pwg_db_real_escape_string($block['id'])."',
     634            '".$block['order']."',
     635            '".pwg_db_real_escape_string(implode(',', $block['users']))."',
     636            '".pwg_db_real_escape_string(implode(',', $block['groups']))."'
     637            );";
     638      $result=pwg_query($sql);
     639      if(!$result) $returned=false;
     640    }
     641
     642    return($returned);
     643  }
     644
     645
     646
     647
     648
     649
     650
     651  protected function sortCoreBlocksItemsCompare($a, $b)
    202652  {
    203653    if($a['container']==$b['container'])
     
    209659  }
    210660
    211   protected function sortSectionsItems()
    212   {
    213     uasort($this->config['amm_sections_items'], array($this, "sortSectionsItemsCompare"));
     661  protected function sortCoreBlocksItems()
     662  {
     663    uasort($this->config['amm_blocks_items'], array($this, "sortCoreBlocksItemsCompare"));
    214664  }
    215665
  • extensions/AMenuManager/amm_version.inc.php

    r8810 r8962  
    1515  if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    1616
    17   define('AMM_VERSION',  '2.2.3');
    18   define('AMM_VERSION2', '02.02.03');
     17  define('AMM_VERSION',  '3.0.0');
     18  define('AMM_VERSION2', '03.00.00');
     19  define('AMM_GPC_NEEDED', '3.4.0');
    1920?>
  • extensions/AMenuManager/language/en_UK/plugin.lang.php

    r6521 r8962  
    4747$lang['g002_apply'] = 'Apply';
    4848
    49 $lang['g002_sectionslist'] = 'Menu blocks';
     49$lang['g002_sectionslist'] = 'Menu\'s blocks';
    5050
    5151$lang['g002_yesno_y'] = 'Yes';
     
    6060$lang['g002_configrandompic'] = 'Random picture settings';
    6161$lang['g002_setting_randompic_aboutpicture'] = 'Displayed datas';
    62 $lang['g002_setting_randompic_showname'] = 'Show picture name';
    63 $lang['g002_setting_randompic_showcomment'] = 'Show picture comment';
     62$lang['g002_setting_randompic_showname'] = 'Show picture\'s name';
     63$lang['g002_setting_randompic_showcomment'] = 'Show picure\'s comment';
    6464$lang['g002_show_n'] = 'No';
    65 $lang['g002_show_o'] = 'Display above the picture';
    66 $lang['g002_show_u'] = 'Display under the picture';
     65$lang['g002_show_o'] = 'Display over the picture';
     66$lang['g002_show_u'] = 'Display under thpicture';
    6767
    68 $lang['g002_personalisedlist'] = "List of personalized blocks";
     68$lang['g002_personalisedlist'] = "Liste of personalised blocks";
    6969$lang['g002_notitle'] = '[No title]';
    7070$lang['g002_title'] = 'Title';
     
    7575$lang['g002_createofpersonalised'] = 'Create a new personalized block';
    7676$lang['g002_editofpersonalised'] = 'Modify a personalized block';
    77 $lang['g002_setting_block_langchoice'] = 'Language choice';
    78 $lang['g002_setting_personalised_content'] = 'Block content';
     77$lang['g002_setting_block_langchoice'] = 'Lang choice';
     78$lang['g002_setting_personalised_content'] = 'Block\'s content';
    7979$lang['g002_setting_personalised_properties'] = 'Properties';
    8080$lang['g002_setting_personalised_nfo'] = 'Description';
     
    8484$lang['g002_modmenu'] = '\'menu\' block';
    8585$lang['g002_modspecial'] = '\'special\' block';
    86 $lang['g002_labelmenu'] = 'Menu label';
     86$lang['g002_labelmenu'] = 'Menu\'s label';
    8787
    8888$lang['g002_setting_randompic_periodicchange'] = "Periodic change of the image";
     
    100100$lang['g002_click_to_manage_rights'] = "Rights management";
    101101
     102
     103// v3.0.0
     104$lang['g002_ok'] = "OK";
     105$lang['g002_config_saved'] = "Config saved";
     106$lang['g002_config_not_saved'] = "Config was not saved";
     107$lang['g002_selected_all_gallery'] = "All albums";
     108$lang['g002_selected_favorites_wm'] = "Webmaster's favorites pictures";
     109$lang['g002_selected_categories'] = "All selected albums";
     110$lang['g002_loading'] = "Loading...";
     111$lang['g002_valid_order'] = "Apply order";
     112$lang['g002_reset_order'] = "Reset order";
     113$lang['g002_accessibility'] = "Accessibility";
     114$lang['g002_setting_core_blocks_content'] = "Content for 'Menu' & 'Specials' menus";
     115$lang['g002_setting_blocks_position'] = "Visibility & ordering for menus ";
     116$lang['g002_plugin'] = "Plugin";
     117$lang['g002_selectedpict'] = "Selected pictures";
     118$lang['g002_album_nfo'] = 'Allow to convert one or more album into a menu';
     119$lang['g002_album2menu'] = "Converted album to menu";
     120$lang['g002_album'] = "Album &rArr; menu";
     121$lang['g002_setting_albums_menus'] = "Albums to convert to menu";
     122
    102123?>
  • extensions/AMenuManager/language/fr_FR/plugin.lang.php

    r5545 r8962  
    1313$lang['g002_personnalblock'] = 'Menu personnalisé';
    1414
    15 $lang['g002_setmenu_nfo'] = 'Gestion de l\'affichage des sections affichées dans le menu';
    16 $lang['g002_addlinks_nfo'] = 'Section permettant d\'afficher dans le menu une liste d\'hyperliens vers d\'autres sites internet';
    17 $lang['g002_randompict_nfo'] = 'Section permettant d\'afficher dans le menu une image prise au hasard dans la galerie';
    18 $lang['g002_personnalblock_nfo'] = 'Afficher dans le menu des sections au contenu personnalisé';
     15$lang['g002_setmenu_nfo'] = 'Gestion de l\'affichage des blocs du menu';
     16$lang['g002_addlinks_nfo'] = 'Bloc permettant d\'afficher dans le menu une liste d\'hyperliens pointant vers d\'autres sites';
     17$lang['g002_randompict_nfo'] = 'Bloc permettant d\'afficher dans le menu une image prise au hasard dans la galerie';
     18$lang['g002_personnalblock_nfo'] = 'Afficher dans le menu des blocs au contenu personnalisé';
    1919
    2020
     
    4343
    4444$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';
     45$lang['g002_setting_block_active'] = 'Afficher le block dans le menu';
     46$lang['g002_setting_block_title'] = 'Titre du block dans le menu';
    4747$lang['g002_apply'] = 'Appliquer';
    4848
    49 $lang['g002_sectionslist'] = 'Sections du menu';
     49$lang['g002_sectionslist'] = 'Blocks du menu';
    5050
    5151$lang['g002_yesno_y'] = 'Oui';
     
    5858$lang['g002_translate'] = 'Traduire avec Google Translate';
    5959
    60 $lang['g002_configrandompic'] = 'Configuration de l\'image aléatoire';
    6160$lang['g002_setting_randompic_aboutpicture'] = 'Données affichées';
    6261$lang['g002_setting_randompic_showname'] = 'Afficher le nom de la photo';
     
    6665$lang['g002_show_u'] = 'Afficher en-dessous de la photo';
    6766
    68 $lang['g002_personalisedlist'] = "Liste des sections personnalisées";
     67$lang['g002_personalisedlist'] = "Liste des blocks personnalisés";
    6968$lang['g002_notitle'] = '[Pas de titre]';
    7069$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';
     70$lang['g002_sections'] = 'blocks';
     71$lang['g002_section'] = 'block';
     72$lang['g002_nosections'] = 'Pas de blocks';
     73$lang['g002_addsection'] = 'Ajouter un block';
     74$lang['g002_createofpersonalised'] = 'Ajout d\'un block personnalisé';
     75$lang['g002_editofpersonalised'] = 'Modification d\'un block personnalisé';
    7776$lang['g002_setting_block_langchoice'] = 'Choix de la langue';
    78 $lang['g002_setting_personalised_content'] = 'Contenu de la section';
     77$lang['g002_setting_personalised_content'] = 'Contenu du block';
    7978$lang['g002_setting_personalised_properties'] = 'Propriétés';
    8079$lang['g002_setting_personalised_nfo'] = 'Description';
     
    8281$lang['g002_all_languages'] = "Toutes langues";
    8382
    84 $lang['g002_modspecial'] = 'Section \'speciale\'';
    85 $lang['g002_modmenu'] = 'Section \'menu\'';
     83$lang['g002_modspecial'] = 'Block \'speciale\'';
     84$lang['g002_modmenu'] = 'Block \'menu\'';
    8685$lang['g002_labelmenu'] = 'Libellé du menu';
    8786
     
    101100
    102101
     102// v3.0.0
     103$lang['g002_ok'] = "OK";
     104$lang['g002_config_saved'] = "Configuration enregistrée";
     105$lang['g002_config_not_saved'] = "La configuration n'a pu être enregistrée";
     106$lang['g002_selected_all_gallery'] = "Dans tous les albums";
     107$lang['g002_selected_favorites_wm'] = "Les photos favorites du webmaster";
     108$lang['g002_selected_categories'] = "Dans les albums sélectionnés";
     109$lang['g002_loading'] = "Chargement en cours...";
     110$lang['g002_valid_order'] = "Valider les positions";
     111$lang['g002_reset_order'] = "Réinitialiser les positions";
     112$lang['g002_accessibility'] = "Accessibilité";
     113$lang['g002_setting_core_blocks_content'] = "Contenu des menus 'Menu' & 'Spéciales'";
     114$lang['g002_setting_blocks_position'] = "Positionnement & visibilité des menus";
     115$lang['g002_plugin'] = "Plugin";
     116$lang['g002_selectedpict'] = "Sélection";
     117$lang['g002_album_nfo'] = 'Permet de convertir un ou plusieurs albums en blocs de menu';
     118$lang['g002_album2menu'] = "Conversion album &rArr; menu";
     119$lang['g002_album'] = "Album &rArr; menu";
     120$lang['g002_setting_albums_menus'] = "Album à convertir en menu";
     121
     122/* --- removed keys ---
     123$lang['g002_configrandompic'] = 'Configuration de l\'image aléatoire';
     124
     125*/
     126
     127
    103128?>
  • extensions/AMenuManager/main.inc.php

    r8810 r8962  
    22/*
    33Plugin Name: Advanced Menu Manager
    4 Version: 2.2.3
     4Version: 3.0.0
    55Description: Gestion avancée du menu / Advanced management of menu
    66Plugin URI: http://piwigo.org
     
    2323| release | date       |
    2424| 2.0.0b  | 2008/07/27 | * initial release with own blocks classes
     25|         |            |
    2526| 2.0.0   | 2008/10/23 | * first release for piwigo's blocks classes
     27|         |            |
    2628| 2.1.0   | 2009/07/26 | * add a functionality : random image can be changed
    2729|         |            |   every x seconds (from 0.5 to 60)
     30|         |            |
    2831|         |            | * bug resolved : random image block is displayed only
    2932|         |            |   if user have accessibility to more than 0 images
     
    3235|         |            |   (cf. post:107877 on french forum)
    3336|         |            |   (cf. topic:14374 on french forum)
     37|         |            |
    3438| 2.1.1   | 2009/07/27 | * random picture is preloaded before the first ajax
    3539|         |            |   call assuming the display of a thumbnail even if
    3640|         |            |   javascript is disabled on the browser
    3741|         |            |   (cf. post:116807 on french forum)
     42|         |            |
    3843|         |            | * give the possibility to choose between an automatic
    3944|         |            |   and a fixed height for the block menu
    4045|         |            |   (cf. post:116804 on french forum)
     46|         |            |
    4147|         |            | * compatibility with Sylvia theme
    4248|         |            |   (cf. post:116800 on french forum)
     49|         |            |
    4350| 2.1.2   | 2009/11/16 | * adding new translations
    4451|         |            |    - es_ES
    4552|         |            |    - hu_HU (thx to sámli)
     53|         |            |
    4654| 2.1.3   | 2009/11/24 | * mantis: feature 1285
    4755|         |            |   move the js for "random image" in the the footer
    4856|         |            |   (having the js inside the <dl> tag was not w3c
    4957|         |            |   compliant)
     58|         |            |
    5059|         |            | * mantis: feature 1132
    5160|         |            |   Allowing order management for items in Piwigo's core
    5261|         |            |   blocks
     62|         |            |
    5363|         |            | * mantis: feature 1133
    5464|         |            |   Allowing to group content from Piwigo's core blocks
     65|         |            |
    5566|         |            | * mantis: feature 1278
    5667|         |            |   Allowing to manage access to menu items with a right
    5768|         |            |   management system
     69|         |            |
    5870|         |            | * mantis: feature 1100
    5971|         |            |   Random picture : compatibility with theme 'montblanc'
     72|         |            |
    6073| 2.1.4   | 2009/11/29 | * mantis: feature 1299
    6174|         |            |   Allows to manage access for the 'Admin' users
     75|         |            |
    6276|         |            | * mantis: feature 1298
    6377|         |            |   Users 'Webmaster' aren't managed
     78|         |            |
    6479|         |            | * mantis: feature 1297
    6580|         |            |   AMM don't works properly if a block 'menu' or
    6681|         |            |   'specials' is hidden
     82|         |            |
    6783| 2.1.5   | 2009/12/15 | * mantis: feature 1331
    6884|         |            |   JS code used to manage the random picture is always
    6985|         |            |   loaded even if there is no menubar
     86|         |            |
    7087|         |            | * adding new translations
    7188|         |            |    - zh_CN (thx mzs777)
     89|         |            |
    7290|         |            | * update translations
    7391|         |            |    - hu_HU (thx to sámli)
     92|         |            |
    7493| 2.1.6   | 2009/12/19 | * mantis: feature 1336
    7594|         |            |   Error message about an undefined var 'tabsheet' on
    7695|         |            |   the admin panel
     96|         |            |
    7797| 2.2.0   | 2010/03/28 | * updated for Piwigo 2.1 compatibility
     98|         |            |
    7899|         |            | * mantis: feature 1384
    79100|         |            |   Problem of length of title field in the custom menu
    80101|         |            |   module
     102|         |            |
    81103|         |            | * mantis: bug 1476
    82104|         |            |   Error message on login screen
     105|         |            |
    83106|         |            | * mantis: bug 1541
    84107|         |            |   Items order is not respected in admin pages
    85108|         |            |
    86 | 2.2.3   | 2011/01/20 | * Add languages
     109| 3.0.0   | 2011/01/09 | * mantis: feature 1296
     110|         |            |   . add permissions for managing personal menu
    87111|         |            |
     112|         |            | * mantis: feature 1477
     113|         |            |   . Possibility to pre-select the "random images"
    88114|         |            |
     115|         |            | * mantis: bug 1680
     116|         |            |   . Warning if a new lang is added in Piwigo
    89117|         |            |
     118|         |            | * mantis: feature 1709
     119|         |            |   . Change title links by sub tabs
     120|         |            |
     121|         |            | * mantis: feature 1723
     122|         |            |   . Display links using user access right
     123|         |            |
     124|         |            | * mantis: bug 1776
     125|         |            |   . Unable to set access for the administrator
     126|         |            |
     127|         |            | * mantis: bug 1910
     128|         |            |   . Incompatibility with Internet Explorer
     129|         |            |     (partially fixed : works, but lloks a little bit
     130|         |            |      ugly)
     131|         |            |
     132|         |            | * mantis: feature 2052
     133|         |            |   . Convert album to menu
     134|         |            |
     135|         |            | * mantis: feature 2128
     136|         |            |   . Random picture : preload a set of picture
     137|         |            |
     138|         |            | * mantis: feature 2129
     139|         |            |   . User & group access management is not consistent
     140|         |            |
     141|         |            | * plugin core rewrited
    90142|         |            |
    91143|         |            |
  • extensions/AMenuManager/maintain.inc.php

    r5545 r8962  
    1414
    1515
    16 global $gpc_installed, $gpcNeeded, $lang; //needed for plugin manager compatibility
     16global $gpcInstalled, $lang; //needed for plugin manager compatibility
    1717
    1818/* -----------------------------------------------------------------------------
    1919AMM needs the Grum Plugin Classe
    2020----------------------------------------------------------------------------- */
    21 $gpc_installed=false;
    22 $gpcNeeded="3.0.0";
     21$gpcInstalled=false;
    2322if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
    2423{
    2524  @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
    26   // need GPC release greater or equal than 3.0.0
    27   if(CommonPlugin::checkGPCRelease(3,0,0))
     25  // need GPC release greater or equal than 3.3.3
     26  if(CommonPlugin::checkGPCRelease(3,3,3))
    2827  {
    2928    @include_once("amm_install.class.inc.php");
    30     $gpc_installed=true;
     29    $gpcInstalled=true;
    3130  }
    3231}
     
    3433function gpcMsgError(&$errors)
    3534{
    36   global $gpcNeeded;
    37   $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), $gpcNeeded);
     35  $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), AMM_GPC_NEEDED);
    3836  if(is_array($errors))
    3937  {
     
    5149load_language('plugin.lang', AMM_PATH);
    5250
     51
     52
    5353function plugin_install($plugin_id, $plugin_version, &$errors)
    5454{
    55   global $prefixeTable, $gpc_installed, $gpcNeeded;
    56   if($gpc_installed)
     55  global $prefixeTable, $gpcInstalled;
     56  if($gpcInstalled)
    5757  {
    58     //$menu->register('mbAMM_links', 'Links', 0, 'AMM');
    59     //$menu->register('mbAMM_randompict', 'Random pictures', 0, 'AMM');
    6058    $amm=new AMM_install($prefixeTable, __FILE__);
    6159    $result=$amm->install();
    62     GPCCore::register($amm->getPluginName(), AMM_VERSION, $gpcNeeded);
    6360  }
    6461  else
     
    7067function plugin_activate($plugin_id, $plugin_version, &$errors)
    7168{
    72   global $prefixeTable;
    73 
    74   $amm=new AMM_install($prefixeTable, __FILE__);
    75   $result=$amm->activate();
     69  global $prefixeTable, $gpcInstalled;
     70  if($gpcInstalled)
     71  {
     72    $amm=new AMM_install($prefixeTable, __FILE__);
     73    $result=$amm->activate();
     74  }
    7675}
    7776
    7877function plugin_deactivate($plugin_id)
    7978{
     79  global $prefixeTable, $gpcInstalled;
     80
     81  if($gpcInstalled)
     82  {
     83    $amm=new AMM_install($prefixeTable, __FILE__);
     84    $amm->deactivate();
     85  }
    8086}
    8187
    8288function plugin_uninstall($plugin_id)
    8389{
    84   global $prefixeTable, $gpc_installed;
    85   if($gpc_installed)
     90  global $prefixeTable, $gpcInstalled;
     91  if($gpcInstalled)
    8692  {
    8793    $amm=new AMM_install($prefixeTable, __FILE__);
    8894    $result=$amm->uninstall();
    89     GPCCore::unregister($amm->getPluginName());
    9095  }
    9196  else
     
    96101
    97102
    98 
    99103?>
  • extensions/AMenuManager/menu_templates/menubar_links.tpl

    r3681 r8962  
    1 
    21<!-- links menu bar -->
    32{if $block->get_title() !="" }
  • extensions/AMenuManager/menu_templates/menubar_personalised.tpl

    r3681 r8962  
    1 
    21<!-- personalised menu bar -->
    32{if $block->get_title() !="" }
  • extensions/AMenuManager/menu_templates/menubar_randompic.js.tpl

    r4363 r8962  
    11{literal}
    22<script type="text/javascript">
    3 var fixedHeight = {/literal}{$data.blockHeight}{literal};
    4 var vIntervalID;
    5 
    6   $(document).ready(
    7     function ()
    8     {
    9       {/literal}
    10       {if $data.blockHeight>0}
    11         $("#irandompicinner").height(fixedHeight);
    12         {literal}$("#iammrpic").load( function () { computePositionTop(); } );{/literal}
    13       {else}
    14         {literal}
    15         $("#iammrpic").load( function () { $("#irandompicinner").animate({height: ($("#iamm_ill0").innerHeight())+"px"}, "normal"); } );
    16         {/literal}
    17       {/if}
    18       {if $data.delay > 0 }
    19         vIntervalID = window.setInterval(getRandomPicture, {$data.delay});
    20       {/if}
    21       {literal}
    22     }
    23   );
    24 
    25   function computePositionTop()
    26   {
    27     $("#iamm_ill0").css({top:(fixedHeight-$("#iamm_ill0").innerHeight())/2});
    28   }
    29 
    30   function getRandomPicture()
    31   {
    32     $.get("./index.php", {ajaxfct:"randompic"},
    33       function (data)
    34       {
    35         $("#iamm_ill0").fadeTo('slow', 0, function ()
    36         {
    37           $("#iamm_ill0").html(data);
    38 
    39           {/literal}
    40           {if $data.blockHeight>0}
    41             {literal}
    42             $("#iammrpic").load( function () {
    43               computePositionTop();
    44               $("#iamm_ill0").fadeTo('slow', 1);
    45             } );
    46             {/literal}
    47           {else}
    48             {literal}
    49             $("#iammrpic").load( function () {
    50               $("#irandompicinner").animate({height: ($("#iamm_ill0").innerHeight())+"px"}, "normal", function ()
    51               {
    52                 $("#iamm_ill0").fadeTo('slow', 1, function ()
    53                 {
    54                   $("#irandompicinner").animate({height: this.clientHeight+"px"}, "normal");
    55                 });
    56               });
    57             } );
    58             {/literal}
    59           {/if}
    60           {literal}
    61 
    62         } );
    63       }
    64     );
    65   }
    66 
    67   {/literal}
    68 
    69   {literal}
    70 
    71 
     3var randomPictOpt={
     4    {/literal}
     5      fixedHeight:{$data.blockHeight},
     6      delay:{$data.delay},
     7      showName:"{$data.showname}",
     8      showComment:"{$data.showcomment}",
     9      pictures:[
     10        {foreach from=$data.pictures item=picture name=items}
     11          {ldelim}
     12            'comment':"{$picture.comment}",
     13            'link':"{$picture.link}",
     14            'name':"{$picture.name}",
     15            'thumb':"{$picture.thumb}"
     16          {rdelim}
     17          {if !$smarty.foreach.items.last},{/if}
     18        {/foreach}
     19      ]
     20    {literal}
     21    };
    7222</script>
    7323{/literal}
  • extensions/AMenuManager/menu_templates/menubar_randompic.tpl

    r5545 r8962  
    1 {known_script id="jquery" src=$ROOT_URL|cat:"themes/default/js/jquery.packed.js"}
    2 
    31<!-- random picture menu bar -->
    42<dt>{$block->get_title()}</dt>
    5 
    63
    74<dd id="irandompicdd" class="randompicdd">
    85  <div id="irandompicinner" class="illustration">
    96    <div class="ammillustrationc">
    10       <div id="iamm_ill0" class="ammillustration">{$block->data.firstPicture}</div>
     7      <div id="iamm_ill0" class="ammillustration">
     8        <span id='iammRPicNameO' style='display:none;'></span>
     9        <span id='iammRPicCommentO' style='display:none;'></span>
     10        <a id='iammRPicLink' ><img id="iammRPicImg"/></a>
     11        <span id='iammRPicNameU' style='display:none;'></span>
     12        <span id='iammRPicCommentU' style='display:none;'></span>
     13      </div>
    1114    </div>
    1215  </div>
Note: See TracChangeset for help on using the changeset viewer.