Changeset 4382

Show
Ignore:
Timestamp:
11/28/09 19:20:01 (4 years ago)
Author:
grum
Message:

<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:9pt;font-family:Sans Serif">
<p>[AMM] allow to group and reorder menu items (mantis 1132,1133)</p>
</body></html>

Location:
extensions/AMenuManager
Files:
6 modified

Legend:

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

    r3681 r4382  
     1{known_script id="jquery.ui" src=$ROOT_URL|@cat:"template-common/lib/ui/ui.core.packed.js"} 
     2{known_script id="jquery.ui.sortable" src=$ROOT_URL|@cat:"template-common/lib/ui/ui.sortable.packed.js"} 
     3 
     4<div id="containerMenu"> 
     5  {foreach from=$sections item=section} 
     6  <div id="containerMenu_{$section}" class="containerMenuSection"> 
     7    <h3>{$section}</h3> 
     8    <ul class="connectedSortable categoryUl" id="menu_{$section}"> 
     9    {foreach from=$items item=data key=id} 
     10      {if $data.container==$section} 
     11        <li class="categoryLi menuItem {if $id=='qsearch'}menuItemDisabled{/if}" id="i{$id}"> 
     12          <img src="{$themeconf.admin_icon_dir}/cat_move.png" class="button drag_button" alt="{'Drag to re-order'|@translate}" title="{'Drag to re-order'|@translate}"/> 
     13          {$data.translation|@translate} 
     14        </li> 
     15      {/if} 
     16    {/foreach} 
     17    </ul> 
     18  </div> 
     19  {/foreach} 
     20 
     21  <input type="button" value="{'cancel'|@translate}" onclick="resetMenu('cancel');"/> 
     22  <input type="button" value="{'piwigo_default'|@translate}" onclick="resetMenu('default');"/> 
     23  <p><input type="button" value="{'apply_changes'|@translate}" onclick="submitChanges();"></p> 
     24  <form id="submitForm" method="POST" action=""> 
     25    <input type="hidden" name="fList" id="iList" value=""/> 
     26  </form> 
     27</div> 
     28 
     29 
     30 
     31 
    132{literal} 
    233<script type="text/javascript"> 
    334 
    4   function load_list(do_action, item, position) 
     35  var resetValues = new Array(new Array(), new Array()); 
     36 
     37  {/literal} 
     38 
     39  // initialization for cancel et reset functions 
     40  {foreach from=$defaultValues item=value key=id} 
     41    resetValues[0].push( {literal} { {/literal} id:"{$id}", section:"{$value.container}", order:{$value.order}  {literal} } {/literal} ); 
     42  {/foreach} 
     43  {foreach from=$items item=value key=id} 
     44    resetValues[1].push( {literal} { {/literal} id:"{$id}", section:"{$value.container}", order:{$value.order}  {literal} } {/literal} ); 
     45  {/foreach} 
     46  {literal} 
     47 
     48  $("#containerMenu").sortable( 
     49    { 
     50      connectWith: '.connectedSortable', 
     51      cursor: 'move', 
     52      opacity:0.6, 
     53      items: 'li:not(.menuItemDisabled)', 
     54      tolerance:'pointer' 
     55    } 
     56  ); 
     57 
     58  function resetMenu(mode) 
    559  { 
    6     /* 
    7       do_action 
    8         'list' : just load list 
    9         'permut' : permut items in list 
    10         'delete' : delete the item in list 
    11     */ 
    12     var doc = document.getElementById("isections"); 
     60    (mode=='default')?key=0:key=1; 
    1361 
    14     action_todo=''; 
    15     if(do_action=='position') 
     62    for(i=0;i<resetValues[key].length;i++) 
    1663    { 
    17       action_todo='sections_position&fItem='+item+'&fPosition='+position; 
     64      $("#menu_"+resetValues[key][i].section).get(0).appendChild($("#i"+resetValues[key][i].id).get(0)); 
    1865    } 
    19     else if(do_action=='showhide') 
     66  } 
     67 
     68  function submitChanges() 
     69  { 
     70    datas=""; 
     71 
     72    items=$("#menu_menu").children(); 
     73    for(i=0;i<items.length;i++) 
    2074    { 
    21       action_todo='sections_showhide&fItem='+item; 
    22     } 
    23     else 
    24     { 
    25       action_todo='sections_list'; 
     75      datas+=items.get(i).id.substr(1)+",menu,"+i+",();"; 
    2676    } 
    2777 
    28     if(action_todo!='') 
     78    items=$("#menu_special").children(); 
     79    for(i=0;i<items.length;i++) 
    2980    { 
    30       http_request=create_httpobject('get', '', '{/literal}{$datas.AMM_AJAX_URL_LIST}{literal}'+action_todo, false); 
    31       http_request.send(null); 
    32       doc.innerHTML=http_request.responseText; 
     81      datas+=items.get(i).id.substr(1)+",special,"+i+",();"; 
    3382    } 
     83 
     84    $("#iList").val(datas); 
     85    $("#submitForm").get(0).submit(); 
    3486  } 
    3587 
    3688</script> 
    3789{/literal} 
    38  
    39  
    40 <h3> 
    41 {foreach from=$datas.LIST item=data} 
    42   {$data.separator} 
    43   {if $data.link!=''} 
    44     <span style="font-weight:normal"><a href="{$data.link}" title="{$data.label|@translate}"> 
    45   {/if} 
    46   {$data.label|@translate} 
    47   {if $data.link!=''} 
    48     </a></span> 
    49   {/if} 
    50 {/foreach} 
    51 </h3> 
    52  
    53 <div id="isections"></div> 
    54  
    55  
    56 <script type="text/javascript"> 
    57   load_list('list', 0, 0); 
    58 </script> 
  • extensions/AMenuManager/amm.css

    r3681 r4382  
    44table.littlefont td { text-align:left; padding:0px;padding-left:3px;padding-right:3px; } 
    55 
     6.containerMenuSection { width:250px;  margin:auto; padding:10px; } 
     7li.menuItem { padding:4px; width:230px; cursor:move;} 
     8li.menuItemDisabled { cursor:defaut;} 
  • extensions/AMenuManager/amm_aip.class.inc.php

    r3690 r4382  
    44  Author     : Grum 
    55    email    : grum@grum.dnsalias.com 
    6     website  : http://photos.grum.dnsalias.com 
     6    website  : http://photos.grum.fr 
    77    PWG user : http://forum.phpwebgallery.net/profile.php?id=3706 
    88 
     
    1717 
    1818include_once(PHPWG_PLUGINS_PATH.'AMenuManager/amm_root.class.inc.php'); 
     19include_once(PHPWG_ROOT_PATH.'include/block.class.php'); 
    1920include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 
    2021include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/ajax.class.inc.php'); 
     
    2728  protected $tabsheet; 
    2829  protected $ajax; 
     30  protected $sectionsId=array('menu', 'special'); 
    2931 
    3032  protected $urls_modes=array(0 => 'new_window', 1 => 'current_window'); 
     
    6567  public function manage() 
    6668  { 
    67     global $template; 
    68  
    69 global $page; 
     69    global $template, $page; 
    7070 
    7171    $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/amm_admin.tpl"); 
     
    176176    { 
    177177      $page_nfo=l10n('g002_setmenu_nfo'); 
    178       $this->display_sections_list_page($_REQUEST['action']); 
     178      $this->display_sections_page(); 
    179179    } 
    180180 
     
    221221          break; 
    222222 
     223/* 
    223224        case 'setmenu_modmenu_sections_list': 
    224225          $result=$this->ajax_amm_setmenu_mod_section_list('amm_sections_modmenu'); 
     
    234235          $result=$this->ajax_amm_setmenu_mod_section_showhide('amm_sections_modspecials', $_REQUEST['fItem']); 
    235236          break; 
     237*/ 
    236238 
    237239        case 'personalised_list': 
     
    484486    manage display for sections table page 
    485487  */ 
    486   private function display_sections_list_page($action) 
    487   { 
    488     global $template, $user; 
    489     $template->set_filename('body_page', 
    490                             dirname($this->filelocation).'/admin/amm_sections.tpl'); 
    491  
    492     switch($action) 
    493     { 
    494       case 'modmenu': 
    495         $tmp_list=array( 
    496           array('separator' => '', 'link' => '', 'label' => 'g002_modmenu'), 
    497           array('separator' => ' / ', 'link' => $this->page_link.'&amp;fAMM_tabsheet=setmenu&amp;action=modspecial', 'label' => 'g002_modspecial') 
    498         ); 
    499         break; 
    500       case 'modspecial': 
    501         $tmp_list=array( 
    502           array('separator' => '', 'link' => $this->page_link.'&amp;fAMM_tabsheet=setmenu&amp;action=modmenu', 'label' => 'g002_modmenu'), 
    503           array('separator' => ' / ', 'link' => '', 'label' => 'g002_modspecial') 
    504         ); 
    505         break; 
    506     } 
    507  
    508     $template_datas=array( 
    509       'AMM_AJAX_URL_LIST' => $this->page_link."&ajaxfct=setmenu_".$action."_", 
    510       'LIST' => $tmp_list 
    511     ); 
    512  
    513     $template->assign("datas", $template_datas); 
     488  private function display_sections_page() 
     489  { 
     490    global $template, $user, $page; 
     491    $template->set_filename('body_page', dirname($this->filelocation).'/admin/amm_sections.tpl'); 
     492 
     493    if(isset($_POST['fList']) && !$this->adviser_abort()) 
     494    { 
     495      /* the returned information in the fList form element are 
     496       *  a list of ecah item, separate with a ";" 
     497       *  each item have properties separated by a "," 
     498       *   id, container, order, visibility 
     499      */ 
     500      $items=explode(";",$_POST['fList']); 
     501      for($i=0;$i<count($items)-1;$i++) 
     502      { 
     503        $properties=explode(",", $items[$i]); 
     504        $this->my_config['amm_sections_items'][$properties[0]]['container']=$properties[1]; 
     505        $this->my_config['amm_sections_items'][$properties[0]]['order']=$properties[2]; 
     506        $this->my_config['amm_sections_items'][$properties[0]]['visibility']=$properties[3]; 
     507      } 
     508      $this->sortSectionsItems(); 
     509      if($this->save_config()) 
     510      { 
     511        array_push($page['infos'], l10n('AMM_config_saved')); 
     512      } 
     513      else 
     514      { 
     515        array_push($page['errors'], l10n('AMM_adviser_not_authorized')); 
     516      } 
     517    } 
     518 
     519    $template->assign("sections", $this->sectionsId); 
     520    $template->assign("defaultValues", $this->defaultMenus); 
     521    $template->assign("items", $this->my_config['amm_sections_items']); 
    514522    $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page'); 
    515523  } 
     
    990998 
    991999 
    992  
     1000/* 
     1001 * 
    9931002  // return a html formatted list of special menu sections items 
    9941003  private function ajax_amm_setmenu_mod_section_list($menuname) 
    9951004  { 
    996     $labels=array( 
    997       'amm_sections_modspecials' => array( 
    998           'favorites' => 'favorite_cat', 
    999           'most_visited' => 'most_visited_cat', 
    1000           'best_rated' => 'best_rated_cat', 
    1001           'random' => 'random_cat', 
    1002           'recent_pics' => 'recent_pics_cat', 
    1003           'recent_cats' => 'recent_cats_cat', 
    1004           'calendar' => 'calendar'        ), 
    1005       'amm_sections_modmenu' => array( 
    1006           'qsearch' => 'qsearch', 
    1007           'tags' => 'Tags', 
    1008           'search' => 'Search', 
    1009           'comments' => 'comments', 
    1010           'about' => 'About', 
    1011           'rss' => 'Notification' 
    1012         ) 
    1013     ); 
     1005 
    10141006 
    10151007 
     
    10451037    return($this->ajax_amm_setmenu_mod_section_list($menuname)); 
    10461038  } 
     1039  * */ 
     1040 
    10471041 
    10481042} // AMM_AIP class 
  • extensions/AMenuManager/amm_pip.class.inc.php

    r4363 r4382  
    2222{ 
    2323  protected $ajax; 
     24  protected $displayRandomImageBlock=true; 
    2425 
    2526  function AMM_PIP($prefixeTable, $filelocation) 
     
    6869  public function blockmanager_apply( $menu_ref_arr ) 
    6970  { 
    70     global $user; 
     71    global $user, $page; 
    7172    $menu = & $menu_ref_arr[0]; 
    7273 
    73 global $page; 
    7474 
    7575    /* 
     
    8585      ); 
    8686      $block->template = dirname(__FILE__).'/menu_templates/menubar_randompic.tpl'; 
     87    } 
     88    else 
     89    { 
     90      $this->displayRandomImageBlock=false; 
    8791    } 
    8892 
     
    136140    } 
    137141 
     142 
    138143    /* 
    139144      hide items from special & menu sections 
    140145    */ 
    141     foreach(array('mbMenu' => 'amm_sections_modmenu', 'mbSpecials' =>'amm_sections_modspecials') as $key0 => $val0) 
    142     { 
    143       if ( ($block = $menu->get_block( $key0 ) ) != null ) 
    144       { 
    145         foreach($this->my_config[$val0] as $key => $val) 
    146         { 
    147           if($val=='n') 
    148           { 
    149             unset( $block->data[$key] ); 
    150           } 
    151         } 
    152       } 
    153     } 
    154 } 
     146    $blocks=Array(); 
     147    $blocks['menu']=$menu->get_block('mbMenu'); 
     148    $blocks['special']=$menu->get_block('mbSpecials'); 
     149 
     150    $menuItems=array_merge($blocks['menu']->data, $blocks['special']->data); 
     151    $this->sortSectionsItems(); 
     152 
     153    $blocks['menu']->data=Array(); 
     154    $blocks['special']->data=Array(); 
     155 
     156    foreach($this->my_config['amm_sections_items'] as $key => $val) 
     157    { 
     158      if(isset($menuItems[$key])) 
     159      { 
     160        $blocks[$val['container']]->data[$key]=$menuItems[$key]; 
     161      } 
     162    } 
     163    if(count($blocks['menu']->data)==0) $menu->hide_block('mbMenu'); 
     164    if(count($blocks['special']->data)==0) $menu->hide_block('mbSpecials'); 
     165  } 
    155166 
    156167  /* 
     
    236247    global $user, $template; 
    237248 
    238     $menu = new BlockManager("menubar"); 
    239     $menu->load_registered_blocks(); 
    240     $menu->prepare_display(); 
    241  
    242     if ( ( ($block = $menu->get_block( 'mbAMM_randompict' ) ) != null ) && ($user['nb_total_images'] > 0) ) 
     249    if($this->displayRandomImageBlock) 
    243250    { 
    244251      $local_tpl = new Template(AMM_PATH."admin/", ""); 
  • extensions/AMenuManager/amm_root.class.inc.php

    r3690 r4382  
    44  Author     : Grum 
    55    email    : grum@grum.fr 
    6     website  : http://photos.fr 
     6    website  : http://photos.grum.fr 
    77    PWG user : http://forum.piwigo.org/profile.php?id=3706 
    88 
     
    1111  See main.inc.php for release information 
    1212 
    13   AMM_root : root classe for plugin 
     13  AMM_root : root class for plugin 
    1414 
    1515  --------------------------------------------------------------------------- */ 
     
    1919include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/common_plugin.class.inc.php'); 
    2020include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/css.class.inc.php'); 
     21 
    2122 
    2223class AMM_root extends common_plugin 
    2324{ 
    2425  protected $css;   //the css object 
     26  protected $defaultMenus = array( 
     27    'favorites' => array('container' => 'special', 'visibility' => '', 'order' => 0, 'translation' => 'favorite_cat'), 
     28    'most_visited' => array('container' => 'special', 'visibility' => '', 'order' => 1, 'translation' => 'most_visited_cat'), 
     29    'best_rated' => array('container' => 'special', 'visibility' => '', 'order' => 2, 'translation' => 'best_rated_cat'), 
     30    'random' => array('container' => 'special', 'visibility' => '', 'order' => 3, 'translation' => 'random_cat'), 
     31    'recent_pics' => array('container' => 'special', 'visibility' => '', 'order' => 4, 'translation' => 'recent_pics_cat'), 
     32    'recent_cats' => array('container' => 'special', 'visibility' => '', 'order' => 5, 'translation' => 'recent_cats_cat'), 
     33    'calendar' => array('container' => 'special', 'visibility' => '', 'order' => 6, 'translation' => 'calendar'), 
     34    'qsearch' => array('container' => 'menu', 'visibility' => '', 'order' => 0, 'translation' => 'qsearch'), 
     35    'tags' => array('container' => 'menu', 'visibility' => '', 'order' => 1, 'translation' => 'Tags'), 
     36    'search' => array('container' => 'menu', 'visibility' => '', 'order' => 2, 'translation' => 'Search'), 
     37    'comments' => array('container' => 'menu', 'visibility' => '', 'order' => 3, 'translation' => 'comments'), 
     38    'about' => array('container' => 'menu', 'visibility' => '', 'order' => 4, 'translation' => 'About'), 
     39    'rss' => array('container' => 'menu', 'visibility' => '', 'order' => 5, 'translation' => 'Notification') 
     40  ); 
    2541 
    2642  function AMM_root($prefixeTable, $filelocation) 
     
    4965      'amm_randompicture_height' => 0,           //0: automatic, otherwise it's the fixed height in pixels 
    5066      'amm_randompicture_title' => array(), 
    51       'amm_sections_modspecials' => array( 
    52         'favorites' => 'y', 
    53         'most_visited' => 'y', 
    54         'best_rated' => 'y', 
    55         'random' => 'y', 
    56         'recent_pics' => 'y', 
    57         'recent_cats' => 'y', 
    58         'calendar' => 'y' 
    59       ), 
    60       'amm_sections_modmenu' => array( 
    61         'qsearch' => 'y', 
    62         'tags' => 'y', 
    63         'search' => 'y', 
    64         'comments' => 'y', 
    65         'about' => 'y', 
    66         'rss' => 'y' 
    67       ) 
     67      'amm_sections_items' => $this->defaultMenus 
    6868    ); 
    6969 
     
    191191 
    192192 
     193  protected function sortSectionsItemsCompare($a, $b) 
     194  { 
     195    if($a['container']==$b['container']) 
     196    { 
     197      if($a['order']==$b['order']) return(0); 
     198      return(($a['order']<$b['order'])?-1:1); 
     199    } 
     200    else return(($a['container']<$b['container'])?-1:1); 
     201  } 
     202 
     203  protected function sortSectionsItems() 
     204  { 
     205    uasort($this->my_config['amm_sections_items'], array($this, "sortSectionsItemsCompare")); 
     206  } 
    193207 
    194208} // amm_root  class 
    195209 
    196210 
     211 
    197212?> 
  • extensions/AMenuManager/main.inc.php

    r4363 r4382  
    1313  Author     : Grum 
    1414    email    : grum@grum.fr 
    15     website  : http://photos.fr 
     15    website  : http://photos.grum.fr 
    1616    PWG user : http://forum.piwigo.org/profile.php?id=3706 
    1717 
     
    4444|         |            |    - es_ES 
    4545|         |            |    - hu_HU (thx to sámli) 
    46 | 2.1.3   | 2009/11/24 | * move the js for "random image" in the the footer 
     46| 2.1.3   | 2009/11/24 | * mantis:1285 
     47|         |            |   move the js for "random image" in the the footer 
    4748|         |            |   (having the js inside the <dl> tag was not w3c 
    4849|         |            |   compliant) 
     50|         |            | * mantis:1132 
     51|         |            |   Allowing order management for items in Piwigo's core blocks 
     52|         |            | * mantis:1133 
     53|         |            |   Allowing to group content from Piwigo's core blocks 
     54|         |            | 
     55|         |            | 
     56|         |            | 
     57|         |            | 
     58|         |            | 
     59|         |            | 
     60|         |            | 
     61|         |            | 
    4962|         |            | 
    5063