Changeset 8962
- Timestamp:
- Jan 28, 2011, 5:10:45 PM (14 years ago)
- Location:
- extensions/AMenuManager
- Files:
-
- 25 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/AMenuManager/admin/amm_admin.tpl
r5421 r8962 1 1 <h2 style="float:right;top:-24px;position:relative;height:auto;font-size:12px;font-weight:normal;">{$plugin.AMM_VERSION}</h2> 2 2 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> 6 6 {/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;'> 7 14 </div> 8 15 -
extensions/AMenuManager/admin/amm_linksconfig.tpl
r3681 r8962 1 1 {literal} 2 2 <script type="text/javascript"> 3 var ulc; 3 4 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 () 14 7 { 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 ); 21 31 } 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 ); 47 33 </script> 48 34 {/literal} 49 35 36 <form method="post" action="" class="general"> 50 37 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">57 38 <fieldset> 58 39 <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}66 40 67 41 <table class="formtable"> … … 69 43 <td>{'g002_setting_block_title'|@translate}</td> 70 44 <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> 75 53 </td> 76 54 </tr> … … 78 56 <td></td> 79 57 <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> 81 59 </td> 82 60 </tr> 83 61 84 62 </table> 85 86 87 63 </fieldset> 88 64 … … 93 69 <td>{'g002_setting_link_show_icon'|@translate}</td> 94 70 <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"> {'g002_yesno_y'|@translate}<br></label> 73 <label><input type="radio" value="n"> {'g002_yesno_n'|@translate}</label> 74 </div> 98 75 </td> 99 76 </tr> … … 102 79 103 80 <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();"> 105 82 </p> 106 107 <input type="hidden" name="famm_modeedit" value="config">108 83 109 84 </form> 110 85 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 4 1 {literal} 5 2 <style> 6 3 .ui-slider { 7 width:3 50px;4 width:360px; 8 5 height:10px; 9 6 border-width:1px; … … 22 19 } 23 20 </style> 21 24 22 <script type="text/javascript"> 23 var rpc; 25 24 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 () 36 27 { 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 ); 43 60 } 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 ); 125 62 126 63 </script> 127 64 {/literal} 128 65 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> 129 69 130 131 <h3>{'g002_configrandompic'|@translate}</h3> 132 70 <div id='iConfigState' style='display:none;'> 71 </div> 133 72 134 73 <form method="post" action="" class="general"> … … 136 75 <legend>{'g002_setting_block_menu'|@translate}</legend> 137 76 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 145 77 <table class="formtable"> 146 78 <tr> 147 79 <td>{'g002_setting_block_title'|@translate}</td> 148 80 <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> 153 90 </td> 154 91 </tr> 92 155 93 <tr> 156 94 <td></td> 157 95 <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> 159 97 </td> 160 98 </tr> … … 163 101 <td>{'g002_setting_randompic_height'|@translate}</td> 164 102 <td> 165 <input type="hidden" name="famm_randompicture_height" id="iamm_randompicture_height" value="{$datas.height}">166 103 <div id="iamm_rp_height_slider" class="gcBgInput gcBorderInput"></div> 167 104 </td> … … 178 115 <fieldset> 179 116 <legend>{'g002_setting_randompic_aboutpicture'|@translate}</legend> 180 <table class="form class">117 <table class="formtable"> 181 118 <tr> 182 119 <td>{'g002_setting_randompic_showname'|@translate}</td> 183 120 <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> 187 128 </td> 188 129 </tr> … … 191 132 <td>{'g002_setting_randompic_showcomment'|@translate}</td> 192 133 <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> 196 141 </td> 197 142 </tr> … … 203 148 <fieldset> 204 149 <legend>{'g002_setting_randompic_periodicchange'|@translate}</legend> 205 <table class="form class">150 <table class="formtable"> 206 151 <tr> 207 152 <td>{'g002_setting_randompic_periodicchange_delay'|@translate}</td> 208 153 <td> 209 <input type="hidden" name="famm_randompicture_periodicchange" id="iamm_randompicture_periodicchange" value="{$datas.periodic_change}">210 154 <div id="iamm_rp_pc_slider" class="gcBgInput gcBorderInput"></div> 211 155 </td> … … 214 158 </td> 215 159 </tr> 160 </table> 161 </fieldset> 216 162 217 163 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"> {'g002_selected_all_gallery'|@translate}<br></label> 171 <label><input type="radio" value="f"> {'g002_selected_favorites_wm'|@translate}<br></label> 172 <label><input type="radio" value="c"> {'g002_selected_categories'|@translate}<br></label> 173 <div id='iamm_randompicture_selectedCat'></div> 174 </div> 175 </td> 176 </tr> 218 177 </table> 219 178 </fieldset> 220 179 221 180 <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();"> 223 182 </p> 224 183 225 <input type="hidden" name="famm_modeedit" value="config">226 184 227 185 </form> 228 229 <script type="text/javascript">230 init();231 change_lang();232 </script> -
extensions/AMenuManager/admin/plugin_admin.php
r5545 r8962 3 3 Plugin : Advanced Menu Manager 4 4 Author : Grum 5 email : grum@ grum.dnsalias.com5 email : grum@piwigo.org 6 6 website : http://photos.grum.dnsalias.com 7 7 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; } 2 div#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 7 div#iList.roma table tr:hover { background:#303030; } 8 div#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 13 div.addLink, div.addBlock { text-align:left; } 14 15 img.button { cursor:pointer; } 16 17 1 18 2 19 .littlefont { font-size:90%; } … … 4 21 table.littlefont td { text-align:left; padding:0px;padding-left:3px;padding-right:3px; } 5 22 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; } 24 li.menuItem { padding:0px; cursor:move; border:none; } 25 li.menuItem div { padding:4px; width:auto; min-height: 19px;} 26 li.menuItem div.visibility { overflow:hidden;display:none;padding-left:20px; } 8 27 li.menuItemDisabled { cursor:defaut;} 9 div.visibility { width:100%;overflow:hidden;display:none;margin-left:30px; }10 28 11 29 div.visibility p { margin:0px; } 12 30 div.visibility input { margin-right:8px; } 13 31 div.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; } 48 img.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 56 li.menuListItem { 57 margin-bottom:5px; 58 padding:3px; 59 cursor:move; 60 min-height:30px; 61 } 62 li.menuListItem span.menuListMove { 63 position:absolute; 64 width:22px; 65 display:inline-block; 66 } 67 li.menuListItem span.menuListName { 68 margin-left:26px; 69 display:inline-block; 70 } 71 li.menuListItem div.menuListUsers, 72 li.menuListItem div.menuListGroups { 73 display:inline-block; 74 min-width:150px; 75 width:100%; 76 margin-right: 2px; 77 } 78 li.menuListItem .ui-inputList-value li.ui-inputList-selected-item { 79 float:left; 80 } 81 li.menuListItem .ui-inputList-value li span.ui-inputList-delete-item { 82 top:0; 83 } 84 li.menuListItem .ui-inputList-value span { 85 height:13px; 86 min-height:0px; 87 } 88 table.menuListAccess { 89 width:100%; 90 } 91 table.menuListAccess tr { 92 vertical-align:top; 93 } -
extensions/AMenuManager/amm_aim.class.inc.php
r5545 r8962 3 3 Plugin : Advanced Menu Manager 4 4 Author : Grum 5 email : grum@ grum.dnsalias.com5 email : grum@piwigo.org 6 6 website : http://photos.grum.dnsalias.com 7 7 PWG user : http://forum.phpwebgallery.net/profile.php?id=3706 … … 33 33 parent::initEvents(); 34 34 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()."&fAMM_tabsheet=setmenu&fAMM_page=position'); });</script>"); 35 43 } 36 44 -
extensions/AMenuManager/amm_aip.class.inc.php
r5545 r8962 3 3 Plugin : Advanced Menu Manager 4 4 Author : Grum 5 email : grum@ grum.dnsalias.com5 email : grum@piwigo.org 6 6 website : http://photos.grum.fr 7 7 PWG user : http://forum.phpwebgallery.net/profile.php?id=3706 … … 19 19 include_once(PHPWG_ROOT_PATH.'include/block.class.php'); 20 20 include_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'); 21 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTabSheet.class.inc.php'); 22 24 23 25 24 class AMM_AIP extends AMM_root 26 25 { 27 protected $google _translate;26 protected $googleTranslate; 28 27 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) 34 32 { 35 33 parent::__construct($prefixeTable, $filelocation); … … 51 49 l10n('g002_personnalblock'), 52 50 $this->getAdminLink().'&fAMM_tabsheet=personnalblock'); 51 $this->tabsheet->add('album', 52 l10n('g002_album'), 53 $this->getAdminLink().'&fAMM_tabsheet=album'); 53 54 $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 */ 65 61 public function manage() 66 62 { … … 69 65 $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/amm_admin.tpl"); 70 66 71 $this->return_ajax_content(); 72 73 $this->init_request(); 67 $this->initRequest(); 74 68 75 69 $this->tabsheet->select($_REQUEST['fAMM_tabsheet']); … … 83 77 84 78 $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 */ 97 142 if($_REQUEST['fAMM_tabsheet']=='links') 98 143 { 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) 279 173 { 280 174 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 281 180 $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().'&fAMM_tabsheet=links&action=create', 301 'lnk_config' => $this->getAdminLink().'&fAMM_tabsheet=links&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().'&fAMM_tabsheet=links&fAMM_page=links'); 188 $linksTabsheet->add('config', 189 l10n('g002_configlinks'), 190 $this->getAdminLink().'&fAMM_tabsheet=links&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() 304 236 ); 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 page312 */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().'&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 337 237 338 238 $lang=get_languages(); 339 239 foreach($lang as $key => $val) 340 240 { 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 352 247 $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 354 369 355 370 /* 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() 359 380 { 360 381 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 366 407 $directory=dir(dirname($this->getFileLocation()).'/links_pictures/'); 367 408 while($file=$directory->read()) 368 409 { 369 if(i sset($extensions_list[get_extension(strtolower($file))]))410 if(in_array(get_extension(strtolower($file)), array('jpg', 'jpeg','gif','png'))) 370 411 { 371 $template_icons_list[]=$file; 412 $datas['iconsValues'][] = array( 413 'img' => AMM_PATH."links_pictures/".$file, 414 'value' => $file, 415 'label' => $file 416 ); 372 417 } 373 418 } 374 419 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().'&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 430 438 $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() 438 446 ); 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 database452 */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 database466 */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 page485 */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 are494 * a list of ecah item, separate with a ";"495 * each item have properties separated by a ","496 * id, container, order, visibility497 */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 else513 {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 page540 */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().'&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 567 447 568 448 $lang=get_languages(); 569 449 foreach($lang as $key => $val) 570 450 { 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 } 593 458 594 459 595 460 596 461 /* 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 598 474 */ 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().'&fAMM_tabsheet=personnalblock&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().'&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) 751 476 { 752 477 $local_tpl = new Template(AMM_PATH."admin/", ""); 753 478 $local_tpl->set_filename('body_page', 754 dirname($this->getFileLocation()).'/admin/amm_ sections_visibility.tpl');479 dirname($this->getFileLocation()).'/admin/amm_coreBlocks_detail.tpl'); 755 480 756 481 757 482 $parameters=explode("/", $visibility); 758 483 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()); 766 496 767 497 return($local_tpl->parse('body_page', true)); … … 769 499 770 500 771 772 /*773 manage adviser profile774 return true if user is adviser775 */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 tables790 --------------------------------------------------------------------------- */791 // protected function get_urls()792 // protected function get_count_url()793 // => defined in root class794 795 // return properties of an given url796 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 urls810 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 url829 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 url836 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 url846 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 visibility856 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 tables867 --------------------------------------------------------------------------- */868 // protected function get_sections($only_visible=false, $lang="")869 // => defined in root class870 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 section885 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 section892 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 section900 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 id911 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 functions932 --------------------------------------------------------------------------- */933 934 // return a html formatted list of urls935 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().'&fAMM_tabsheet=links&action=modify&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 urls973 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 urls980 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 sections994 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().'&fAMM_tabsheet=personnalblock&action=modify&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 list1032 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 1042 501 } // AMM_AIP class 1043 502 -
extensions/AMenuManager/amm_install.class.inc.php
r5545 r8962 3 3 Plugin : Advanced Menu Manager 4 4 Author : Grum 5 email : grum@ grum.dnsalias.com5 email : grum@piwigo.org 6 6 website : http://photos.grum.fr 7 7 PWG user : http://forum.phpwebgallery.net/profile.php?id=3706 … … 21 21 class AMM_install extends AMM_root 22 22 { 23 private $tablesManager; 24 private $exportfile; 25 26 public function AMM_install($prefixeTable, $filelocation) 23 private $tablef; 24 25 public function __construct($prefixeTable, $filelocation) 27 26 { 28 27 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 */ 37 44 public function install() 38 45 { … … 40 47 $this->loadConfig(); 41 48 $this->config['installed']=AMM_VERSION2; 49 $this->config['newInstall']='y'; 42 50 $this->saveConfig(); 43 51 … … 51 59 `position` int(11) NOT NULL default '0', 52 60 `visible` char(1) NOT NULL default 'y', 61 `accessUsers` varchar(1024) NOT NULL, 62 `accessGroups` varchar(1024) NOT NULL, 53 63 PRIMARY KEY (`id`), 54 64 KEY `order_key` (`position`) … … 56 66 57 67 "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, 62 69 `visible` char(1) NOT NULL default 'y', 63 70 `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`) 65 89 )" 90 66 91 ); 67 92 //$table_def array 68 93 $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 70 99 return($result); 71 100 } 72 101 73 102 74 /* 75 76 */103 /** 104 * function for uninstall process 105 */ 77 106 public function uninstall() 78 107 { 79 $this->tablesManager->export($this->exportfile);80 108 $this->deleteConfig(); 81 $this->tablesManager->drop(); 109 $this->tablef->drop(); 110 GPCCore::unregister($this->getPluginName()); 82 111 } 83 112 … … 91 120 $this->udpateTablesDef(); 92 121 122 $this->config['newInstall']='n'; 93 123 $this->config['installed']=AMM_VERSION2; //update the installed release number 94 124 $this->saveConfig(); 125 126 GPCCore::register($this->getPluginName(), AMM_VERSION, AMM_GPC_NEEDED); 95 127 } 96 128 97 129 public function deactivate() 98 130 { 131 $this->initConfig(); 132 $this->loadConfig(); 133 $this->restoreMenuConfig(); 99 134 } 100 135 … … 106 141 protected function udpateTablesDef() 107 142 { 143 global $conf; 144 108 145 /* AMM release earlier than the 2.1.3 uses two parameters to manage the display 109 146 * of the menu items ("amm_sections_modspecials" and "amm_sections_modmenu") 110 147 * 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" 112 149 * 113 150 * This function aim to import the old conf into the new conf property … … 117 154 foreach($this->config['amm_sections_modspecials'] as $key=>$val) 118 155 { 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/"; 120 157 } 121 158 unset($this->config['amm_sections_modspecials']); … … 126 163 foreach($this->config['amm_sections_modmenu'] as $key=>$val) 127 164 { 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/"; 129 166 } 130 167 unset($this->config['amm_sections_modmenu']); … … 140 177 } 141 178 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) 156 316 { 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':'')."', '');"); 158 318 } 159 319 } 160 320 } 161 321 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 162 332 } //class 163 333 -
extensions/AMenuManager/amm_pip.class.inc.php
r5545 r8962 22 22 { 23 23 protected $displayRandomImageBlock=true; 24 protected $registeredBlocks; 25 protected $randomPictProp=null; 26 protected $users; 27 protected $groups; 28 protected $currentBuiltMenu=-1; 24 29 25 30 function AMM_PIP($prefixeTable, $filelocation) … … 28 33 $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles()."2.css"); 29 34 35 $this->users=new GPCUsers(); 36 $this->groups=new GPCGroups(); 37 30 38 $this->loadConfig(); 31 39 $this->initEvents(); … … 33 41 34 42 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 */ 43 46 public function initEvents() 44 47 { 45 //TODELETE: add_event_handler('loc_begin_menubar', array(&$this, 'modify_menu') );46 48 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') ); 49 52 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']) 83 96 ); 84 $block->template = dirname(__FILE__).'/menu_templates/menubar_randompic.tpl'; 97 98 if(count($this->randomPictProp['pictures'])==0) $this->displayRandomImageBlock=false; 85 99 } 86 100 else … … 88 102 $this->displayRandomImageBlock=false; 89 103 } 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 99 146 if($this->config['amm_links_show_icons']=='y') 100 147 { 101 for ($i=0;$i<count($urls);$i++)148 foreach($urls as $key => $url) 102 149 { 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']; 104 151 } 105 152 } 106 153 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'; 109 156 110 157 $block->data = array( … … 114 161 } 115 162 } 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); 121 172 122 173 if(count($sections)) 123 174 { 124 $id _done=array();175 $idDone=array(); 125 176 foreach($sections as $key => $val) 126 177 { 127 if(!isset($id _done[$val['id']]))178 if(!isset($idDone[$val['id']])) 128 179 { 129 if ( ($block = $menu->get_block( 'mbAMM_personalised'.$val['id'] ) ) != null)180 if(($block=$menu->get_block('mbAMM_personalised'.$val['id']))!= null) 130 181 { 131 $block->set_title( $val['title']);182 $block->set_title($val['title']); 132 183 $block->template = dirname(__FILE__).'/menu_templates/menubar_personalised.tpl'; 133 184 $block->data = stripslashes($val['content']); 134 185 } 135 $id _done[$val['id']]="";186 $idDone[$val['id']]=""; 136 187 } 137 188 } 138 189 } 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 146 242 $blocks=Array(); 147 243 148 244 if($menu->is_hidden('mbMenu')) 149 245 { 150 // if block is hidden, make a fake to manage AMM features246 // if block is hidden, make a fake to manage AMM submenu features 151 247 // the fake block isn't displayed 152 248 $blocks['menu']=new DisplayBlock('amm_mbMenu'); … … 160 256 if($menu->is_hidden('mbSpecials')) 161 257 { 162 // if block is hidden, make a fake to manage AMM features258 // if block is hidden, make a fake to manage AMM submenu features 163 259 // the fake block isn't displayed 164 260 $blocks['special']=new DisplayBlock('amm_mbSpecial'); … … 171 267 172 268 $menuItems=array_merge($blocks['menu']->data, $blocks['special']->data); 173 $this->sort SectionsItems();269 $this->sortCoreBlocksItems(); 174 270 175 271 $blocks['menu']->data=Array(); 176 272 $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) 183 276 { 184 277 if(isset($menuItems[$key])) 185 278 { 186 279 $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 191 285 * 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'])) 197 288 { 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]; 199 295 } 200 296 } … … 205 301 206 302 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 209 313 $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']."';"; 212 316 $result=pwg_query($sql); 213 317 if($result) … … 215 319 while($row=pwg_db_fetch_assoc($result)) 216 320 { 217 array_push($returned, $row['group_id']);321 $returned[]=$row['group_id']; 218 322 } 219 323 } … … 221 325 } 222 326 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) 236 415 { 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) "; 240 417 } 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'] 278 435 ); 279 436 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 299 448 300 449 … … 315 464 } 316 465 466 317 467 if($this->displayRandomImageBlock && $page['body_id'] == 'theCategoryPage') 318 468 { … … 320 470 $local_tpl->set_filename('body_page', dirname($this->getFileLocation()).'/menu_templates/menubar_randompic.js.tpl'); 321 471 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); 333 499 } 334 500 -
extensions/AMenuManager/amm_root.class.inc.php
r5545 r8962 17 17 if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); } 18 18 19 include_once(PHPWG_ROOT_PATH.'include/block.class.php'); 19 20 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'); 20 21 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCUsersGroups.class.inc.php'); … … 26 27 protected $css; //the css object 27 28 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') 41 48 ); 49 protected $urlsModes=array(0 => 'new_window', 1 => 'current_window'); 50 51 42 52 43 53 public function __construct($prefixeTable, $filelocation) … … 47 57 parent::__construct($prefixeTable, $filelocation); 48 58 49 $list=array('urls', 'personalised' );59 $list=array('urls', 'personalised', 'personalised_langs', 'blocks'); 50 60 $this->setTablesList($list); 51 61 } … … 58 68 } 59 69 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 */ 65 79 public function initConfig() 66 80 { … … 68 82 'amm_links_show_icons' => 'y', 69 83 'amm_links_title' => array(), 84 'amm_randompicture_preload' => 25, //number preloaded random pictures 70 85 'amm_randompicture_showname' => 'n', //n:no, o:over, u:under 71 86 'amm_randompicture_showcomment' => 'n', //n:no, o:over, u:under … … 73 88 'amm_randompicture_height' => 0, //0: automatic, otherwise it's the fixed height in pixels 74 89 '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 76 95 ); 77 96 … … 99 118 public function initEvents() 100 119 { 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 ) 105 124 { 106 125 $menu = & $menu_ref_arr[0]; 107 if ($menu->get_id() != 'menubar') 108 return; 126 if ($menu->get_id() != 'menubar') return; 127 109 128 $menu->register_block( new RegisteredBlock( 'mbAMM_randompict', 'Random pictures', 'AMM')); 110 129 $menu->register_block( new RegisteredBlock( 'mbAMM_links', 'Links', 'AMM')); 111 130 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']])) 119 138 { 120 139 $menu->register_block( new RegisteredBlock( 'mbAMM_personalised'.$val['id'], $val['title'], 'AMM')); 121 $id _done[$val['id']]="";140 $idDone[$val['id']]=""; 122 141 } 123 142 } 124 143 } 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) 129 182 { 130 183 $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) 133 187 { 134 188 $sql.=" WHERE visible = 'y' "; 135 189 } 136 $sql.=" ORDER BY position ";190 $sql.=" ORDER BY position ASC, id ASC"; 137 191 $result=pwg_query($sql); 138 192 if($result) … … 140 194 while($row=pwg_db_fetch_assoc($result)) 141 195 { 142 $row['label']=stripslashes($row['label']);143 196 $returned[]=$row; 144 197 } … … 147 200 } 148 201 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) 151 301 { 152 302 $returned=0; 153 303 $sql="SELECT count(id) FROM ".$this->tables['urls']; 154 if($only _visible)304 if($onlyVisible) 155 305 { 156 306 $sql.=" WHERE visible = 'y' "; … … 165 315 } 166 316 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) 169 356 { 170 357 global $user; 171 358 172 if($lang=="") 173 { 174 $lang=$user['language']; 175 } 359 if($lang=="") $lang=$user['language']; 176 360 177 361 $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 189 373 $result=pwg_query($sql); 190 374 if($result) … … 198 382 } 199 383 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) 202 652 { 203 653 if($a['container']==$b['container']) … … 209 659 } 210 660 211 protected function sort SectionsItems()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")); 214 664 } 215 665 -
extensions/AMenuManager/amm_version.inc.php
r8810 r8962 15 15 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 16 16 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'); 19 20 ?> -
extensions/AMenuManager/language/en_UK/plugin.lang.php
r6521 r8962 47 47 $lang['g002_apply'] = 'Apply'; 48 48 49 $lang['g002_sectionslist'] = 'Menu blocks';49 $lang['g002_sectionslist'] = 'Menu\'s blocks'; 50 50 51 51 $lang['g002_yesno_y'] = 'Yes'; … … 60 60 $lang['g002_configrandompic'] = 'Random picture settings'; 61 61 $lang['g002_setting_randompic_aboutpicture'] = 'Displayed datas'; 62 $lang['g002_setting_randompic_showname'] = 'Show picture name';63 $lang['g002_setting_randompic_showcomment'] = 'Show pic turecomment';62 $lang['g002_setting_randompic_showname'] = 'Show picture\'s name'; 63 $lang['g002_setting_randompic_showcomment'] = 'Show picure\'s comment'; 64 64 $lang['g002_show_n'] = 'No'; 65 $lang['g002_show_o'] = 'Display abovethe picture';66 $lang['g002_show_u'] = 'Display under th epicture';65 $lang['g002_show_o'] = 'Display over the picture'; 66 $lang['g002_show_u'] = 'Display under thpicture'; 67 67 68 $lang['g002_personalisedlist'] = "List of personalized blocks";68 $lang['g002_personalisedlist'] = "Liste of personalised blocks"; 69 69 $lang['g002_notitle'] = '[No title]'; 70 70 $lang['g002_title'] = 'Title'; … … 75 75 $lang['g002_createofpersonalised'] = 'Create a new personalized block'; 76 76 $lang['g002_editofpersonalised'] = 'Modify a personalized block'; 77 $lang['g002_setting_block_langchoice'] = 'Lang uagechoice';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'; 79 79 $lang['g002_setting_personalised_properties'] = 'Properties'; 80 80 $lang['g002_setting_personalised_nfo'] = 'Description'; … … 84 84 $lang['g002_modmenu'] = '\'menu\' block'; 85 85 $lang['g002_modspecial'] = '\'special\' block'; 86 $lang['g002_labelmenu'] = 'Menu label';86 $lang['g002_labelmenu'] = 'Menu\'s label'; 87 87 88 88 $lang['g002_setting_randompic_periodicchange'] = "Periodic change of the image"; … … 100 100 $lang['g002_click_to_manage_rights'] = "Rights management"; 101 101 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 ⇒ menu"; 121 $lang['g002_setting_albums_menus'] = "Albums to convert to menu"; 122 102 123 ?> -
extensions/AMenuManager/language/fr_FR/plugin.lang.php
r5545 r8962 13 13 $lang['g002_personnalblock'] = 'Menu personnalisé'; 14 14 15 $lang['g002_setmenu_nfo'] = 'Gestion de l\'affichage des sections affichées dans lemenu';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'] = ' Sectionpermettant 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é'; 19 19 20 20 … … 43 43 44 44 $lang['g002_setting_block_menu'] = 'Intégration dans le menu'; 45 $lang['g002_setting_block_active'] = 'Afficher l a sectiondans le menu';46 $lang['g002_setting_block_title'] = 'Titre d e la sectiondans 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'; 47 47 $lang['g002_apply'] = 'Appliquer'; 48 48 49 $lang['g002_sectionslist'] = ' Sections du menu';49 $lang['g002_sectionslist'] = 'Blocks du menu'; 50 50 51 51 $lang['g002_yesno_y'] = 'Oui'; … … 58 58 $lang['g002_translate'] = 'Traduire avec Google Translate'; 59 59 60 $lang['g002_configrandompic'] = 'Configuration de l\'image aléatoire';61 60 $lang['g002_setting_randompic_aboutpicture'] = 'Données affichées'; 62 61 $lang['g002_setting_randompic_showname'] = 'Afficher le nom de la photo'; … … 66 65 $lang['g002_show_u'] = 'Afficher en-dessous de la photo'; 67 66 68 $lang['g002_personalisedlist'] = "Liste des sections personnalisées";67 $lang['g002_personalisedlist'] = "Liste des blocks personnalisés"; 69 68 $lang['g002_notitle'] = '[Pas de titre]'; 70 69 $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 un e section';75 $lang['g002_createofpersonalised'] = 'Ajout d\'un e section personnalisée';76 $lang['g002_editofpersonalised'] = 'Modification d\'un e 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é'; 77 76 $lang['g002_setting_block_langchoice'] = 'Choix de la langue'; 78 $lang['g002_setting_personalised_content'] = 'Contenu d e la section';77 $lang['g002_setting_personalised_content'] = 'Contenu du block'; 79 78 $lang['g002_setting_personalised_properties'] = 'Propriétés'; 80 79 $lang['g002_setting_personalised_nfo'] = 'Description'; … … 82 81 $lang['g002_all_languages'] = "Toutes langues"; 83 82 84 $lang['g002_modspecial'] = ' Section\'speciale\'';85 $lang['g002_modmenu'] = ' Section\'menu\'';83 $lang['g002_modspecial'] = 'Block \'speciale\''; 84 $lang['g002_modmenu'] = 'Block \'menu\''; 86 85 $lang['g002_labelmenu'] = 'Libellé du menu'; 87 86 … … 101 100 102 101 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 ⇒ menu"; 119 $lang['g002_album'] = "Album ⇒ 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 103 128 ?> -
extensions/AMenuManager/main.inc.php
r8810 r8962 2 2 /* 3 3 Plugin Name: Advanced Menu Manager 4 Version: 2.2.34 Version: 3.0.0 5 5 Description: Gestion avancée du menu / Advanced management of menu 6 6 Plugin URI: http://piwigo.org … … 23 23 | release | date | 24 24 | 2.0.0b | 2008/07/27 | * initial release with own blocks classes 25 | | | 25 26 | 2.0.0 | 2008/10/23 | * first release for piwigo's blocks classes 27 | | | 26 28 | 2.1.0 | 2009/07/26 | * add a functionality : random image can be changed 27 29 | | | every x seconds (from 0.5 to 60) 30 | | | 28 31 | | | * bug resolved : random image block is displayed only 29 32 | | | if user have accessibility to more than 0 images … … 32 35 | | | (cf. post:107877 on french forum) 33 36 | | | (cf. topic:14374 on french forum) 37 | | | 34 38 | 2.1.1 | 2009/07/27 | * random picture is preloaded before the first ajax 35 39 | | | call assuming the display of a thumbnail even if 36 40 | | | javascript is disabled on the browser 37 41 | | | (cf. post:116807 on french forum) 42 | | | 38 43 | | | * give the possibility to choose between an automatic 39 44 | | | and a fixed height for the block menu 40 45 | | | (cf. post:116804 on french forum) 46 | | | 41 47 | | | * compatibility with Sylvia theme 42 48 | | | (cf. post:116800 on french forum) 49 | | | 43 50 | 2.1.2 | 2009/11/16 | * adding new translations 44 51 | | | - es_ES 45 52 | | | - hu_HU (thx to sámli) 53 | | | 46 54 | 2.1.3 | 2009/11/24 | * mantis: feature 1285 47 55 | | | move the js for "random image" in the the footer 48 56 | | | (having the js inside the <dl> tag was not w3c 49 57 | | | compliant) 58 | | | 50 59 | | | * mantis: feature 1132 51 60 | | | Allowing order management for items in Piwigo's core 52 61 | | | blocks 62 | | | 53 63 | | | * mantis: feature 1133 54 64 | | | Allowing to group content from Piwigo's core blocks 65 | | | 55 66 | | | * mantis: feature 1278 56 67 | | | Allowing to manage access to menu items with a right 57 68 | | | management system 69 | | | 58 70 | | | * mantis: feature 1100 59 71 | | | Random picture : compatibility with theme 'montblanc' 72 | | | 60 73 | 2.1.4 | 2009/11/29 | * mantis: feature 1299 61 74 | | | Allows to manage access for the 'Admin' users 75 | | | 62 76 | | | * mantis: feature 1298 63 77 | | | Users 'Webmaster' aren't managed 78 | | | 64 79 | | | * mantis: feature 1297 65 80 | | | AMM don't works properly if a block 'menu' or 66 81 | | | 'specials' is hidden 82 | | | 67 83 | 2.1.5 | 2009/12/15 | * mantis: feature 1331 68 84 | | | JS code used to manage the random picture is always 69 85 | | | loaded even if there is no menubar 86 | | | 70 87 | | | * adding new translations 71 88 | | | - zh_CN (thx mzs777) 89 | | | 72 90 | | | * update translations 73 91 | | | - hu_HU (thx to sámli) 92 | | | 74 93 | 2.1.6 | 2009/12/19 | * mantis: feature 1336 75 94 | | | Error message about an undefined var 'tabsheet' on 76 95 | | | the admin panel 96 | | | 77 97 | 2.2.0 | 2010/03/28 | * updated for Piwigo 2.1 compatibility 98 | | | 78 99 | | | * mantis: feature 1384 79 100 | | | Problem of length of title field in the custom menu 80 101 | | | module 102 | | | 81 103 | | | * mantis: bug 1476 82 104 | | | Error message on login screen 105 | | | 83 106 | | | * mantis: bug 1541 84 107 | | | Items order is not respected in admin pages 85 108 | | | 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 87 111 | | | 112 | | | * mantis: feature 1477 113 | | | . Possibility to pre-select the "random images" 88 114 | | | 115 | | | * mantis: bug 1680 116 | | | . Warning if a new lang is added in Piwigo 89 117 | | | 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 90 142 | | | 91 143 | | | -
extensions/AMenuManager/maintain.inc.php
r5545 r8962 14 14 15 15 16 global $gpc _installed, $gpcNeeded, $lang; //needed for plugin manager compatibility16 global $gpcInstalled, $lang; //needed for plugin manager compatibility 17 17 18 18 /* ----------------------------------------------------------------------------- 19 19 AMM needs the Grum Plugin Classe 20 20 ----------------------------------------------------------------------------- */ 21 $gpc_installed=false; 22 $gpcNeeded="3.0.0"; 21 $gpcInstalled=false; 23 22 if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php')) 24 23 { 25 24 @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'); 26 // need GPC release greater or equal than 3. 0.027 if(CommonPlugin::checkGPCRelease(3, 0,0))25 // need GPC release greater or equal than 3.3.3 26 if(CommonPlugin::checkGPCRelease(3,3,3)) 28 27 { 29 28 @include_once("amm_install.class.inc.php"); 30 $gpc _installed=true;29 $gpcInstalled=true; 31 30 } 32 31 } … … 34 33 function gpcMsgError(&$errors) 35 34 { 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); 38 36 if(is_array($errors)) 39 37 { … … 51 49 load_language('plugin.lang', AMM_PATH); 52 50 51 52 53 53 function plugin_install($plugin_id, $plugin_version, &$errors) 54 54 { 55 global $prefixeTable, $gpc _installed, $gpcNeeded;56 if($gpc _installed)55 global $prefixeTable, $gpcInstalled; 56 if($gpcInstalled) 57 57 { 58 //$menu->register('mbAMM_links', 'Links', 0, 'AMM');59 //$menu->register('mbAMM_randompict', 'Random pictures', 0, 'AMM');60 58 $amm=new AMM_install($prefixeTable, __FILE__); 61 59 $result=$amm->install(); 62 GPCCore::register($amm->getPluginName(), AMM_VERSION, $gpcNeeded);63 60 } 64 61 else … … 70 67 function plugin_activate($plugin_id, $plugin_version, &$errors) 71 68 { 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 } 76 75 } 77 76 78 77 function plugin_deactivate($plugin_id) 79 78 { 79 global $prefixeTable, $gpcInstalled; 80 81 if($gpcInstalled) 82 { 83 $amm=new AMM_install($prefixeTable, __FILE__); 84 $amm->deactivate(); 85 } 80 86 } 81 87 82 88 function plugin_uninstall($plugin_id) 83 89 { 84 global $prefixeTable, $gpc _installed;85 if($gpc _installed)90 global $prefixeTable, $gpcInstalled; 91 if($gpcInstalled) 86 92 { 87 93 $amm=new AMM_install($prefixeTable, __FILE__); 88 94 $result=$amm->uninstall(); 89 GPCCore::unregister($amm->getPluginName());90 95 } 91 96 else … … 96 101 97 102 98 99 103 ?> -
extensions/AMenuManager/menu_templates/menubar_links.tpl
r3681 r8962 1 2 1 <!-- links menu bar --> 3 2 {if $block->get_title() !="" } -
extensions/AMenuManager/menu_templates/menubar_personalised.tpl
r3681 r8962 1 2 1 <!-- personalised menu bar --> 3 2 {if $block->get_title() !="" } -
extensions/AMenuManager/menu_templates/menubar_randompic.js.tpl
r4363 r8962 1 1 {literal} 2 2 <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 3 var 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 }; 72 22 </script> 73 23 {/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 3 1 <!-- random picture menu bar --> 4 2 <dt>{$block->get_title()}</dt> 5 6 3 7 4 <dd id="irandompicdd" class="randompicdd"> 8 5 <div id="irandompicinner" class="illustration"> 9 6 <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> 11 14 </div> 12 15 </div>
Note: See TracChangeset
for help on using the changeset viewer.