Changeset 2488 for trunk/plugins


Ignore:
Timestamp:
Aug 28, 2008, 2:32:39 AM (16 years ago)
Author:
rvelices
Message:
  • based on test_menu by grum (thanks to you) - integration of dynamic menu bar to pwg
  • the menubar is composed now of dynamic blocks that can be ordered/hidden
  • plugins can add their own blocks
Location:
trunk/plugins
Files:
1 deleted
12 edited

Legend:

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

    r2468 r2488  
    6767    <table class="formtable">
    6868      <tr>
    69         <td>{'g002_setting_block_active'|@translate}</td>
    70         <td>
    71           <select name="famm_links_active" id="iamm_links_active">
    72             {html_options values=$datas.yesno_values output=$datas.yesno_labels selected=$datas.active_selected}
    73           </select>
    74         </td>
    75       </tr>
    76 
    77       <tr>
    7869        <td>{'g002_setting_block_title'|@translate}</td>
    7970        <td>
  • trunk/plugins/AMenuManager/admin/amm_randompicconfig.tpl

    r2468 r2488  
    6767    <table class="formtable">
    6868      <tr>
    69         <td>{'g002_setting_block_active'|@translate}</td>
    70         <td>
    71           <select name="famm_randompicture_active" id="iamm_randompicture_active">
    72             {html_options values=$datas.yesno_values output=$datas.yesno_labels selected=$datas.active_selected}
    73           </select>
    74         </td>
    75       </tr>
    76 
    77       <tr>
    7869        <td>{'g002_setting_block_title'|@translate}</td>
    7970        <td>
  • trunk/plugins/AMenuManager/amm_aim.class.inc.php

    r2466 r2488  
    3131  function init_events()
    3232  {
     33    parent::init_events();
    3334    add_event_handler('get_admin_plugin_menu_links', array(&$this, 'plugin_admin_menu') );
    3435  }
  • trunk/plugins/AMenuManager/amm_aip.class.inc.php

    r2468 r2488  
    190190  public function init_events()
    191191  {
    192     add_event_handler('menubar_file', array(&$this, 'plugin_public_menu') );
    193192    add_event_handler('loc_end_page_header', array(&$this->css, 'apply_CSS'));
    194193  }
     
    238237
    239238        case 'setmenu_modspecial_sections_list':
    240           $result=$this->ajax_amm_setmenu_mod_section_list('amm_sections_modspecial');
     239          $result=$this->ajax_amm_setmenu_mod_section_list('amm_sections_modspecials');
    241240          break;
    242241        case 'setmenu_modspecial_sections_showhide':
    243           $result=$this->ajax_amm_setmenu_mod_section_showhide('amm_sections_modspecial', $_REQUEST['fItem']);
     242          $result=$this->ajax_amm_setmenu_mod_section_showhide('amm_sections_modspecials', $_REQUEST['fItem']);
    244243          break;
    245244
     
    326325      'AMM_AJAX_URL_LIST' => $this->page_link."&ajaxfct=",
    327326      'show_icons_selected' => $this->my_config['amm_links_show_icons'],
    328       'active_selected' => $this->my_config['amm_links_active'],
    329327      'lang_selected' => $user['language'],
    330328      'fromlang' => substr($user['language'],0,2)
     
    460458  {
    461459    $this->my_config['amm_links_show_icons']=$_POST['famm_links_show_icons'];
    462     $this->my_config['amm_links_active']=$_POST['famm_links_active'];
    463460    $languages=get_languages();
    464461    foreach($languages as $key => $val)
     
    474471  protected function action_randompic_modify_config()
    475472  {
    476     $this->my_config['amm_randompicture_active']=$_POST['famm_randompicture_active'];
    477473    $this->my_config['amm_randompicture_showname']=$_POST['famm_randompicture_showname'];
    478474    $this->my_config['amm_randompicture_showcomment']=$_POST['famm_randompicture_showcomment'];
     
    542538    $template_datas=array(
    543539      'lnk_list' => $this->page_link.'&amp;fAMM_tabsheet=links',
    544       'active_selected' => $this->my_config['amm_randompicture_active'],
    545540      'showname_selected' => $this->my_config['amm_randompicture_showname'],
    546541      'showcomment_selected' => $this->my_config['amm_randompicture_showcomment'],
     
    703698  protected function action_create_modify_personalised()
    704699  {
    705     global $menu, $user;
     700    global $user;
    706701
    707702    if($_POST['famm_modeedit']=='create')
     
    734729      }
    735730    }
    736 
    737     if($_POST['famm_modeedit']=='create')
    738     {
    739       $menu->register('mbAMM_personalised'.$id, ($_POST['famm_personalised_nfo']=='')?$_POST['famm_personalised_title_'.$user['language']]:$_POST['famm_personalised_nfo'], 0, 'AMM');
    740     }
    741 
    742 
    743 
    744731  }
    745732
     
    813800  {
    814801    $numurl=$this->get_count_url();
    815     $sql="INSERT INTO ".$this->tables['urls']." (id, label, url, mode, icon, position, visible)
    816           VALUES ('', '".$datas['label']."', '".$datas['url']."', '".$datas['mode']."',
     802    $sql="INSERT INTO ".$this->tables['urls']." (label, url, mode, icon, position, visible)
     803          VALUES ('".$datas['label']."', '".$datas['url']."', '".$datas['mode']."',
    817804                  '".$datas['icon']."', '".$numurl."', '".$datas['visible']."')";
    818805    return(pwg_query($sql));
     
    10541041  private function ajax_amm_personalised_delete($sectionid)
    10551042  {
    1056     global $menu;
    1057 
    10581043    if(!$this->adviser_abort())
    10591044    {
    10601045      $this->delete_personalised($sectionid);
    1061       $menu->unregister('mbAMM_personalised'.$sectionid);
    10621046    }
    10631047    return($this->ajax_amm_personalised_list());
  • trunk/plugins/AMenuManager/amm_install.class.inc.php

    r2468 r2488  
    4848  PRIMARY KEY  (`id`),
    4949  KEY `order_key` (`position`)
    50 ) ENGINE=MyISAM DEFAULT CHARSET=latin1",
     50)",
    5151
    5252"CREATE TABLE  `".$this->tables['personalised']."` (
     
    5858  `nfo` varchar(25) NOT NULL default '',
    5959  PRIMARY KEY  (`id`,`lang`)
    60 ) ENGINE=MyISAM DEFAULT CHARSET=latin1"
     60)"
    6161);
    6262      //$table_def array
    63 
     63      $tables_def = create_table_add_character_set($tables_def);
    6464      $result=$this->tablef->create_tables($tables_def);
    6565      return($result);
  • trunk/plugins/AMenuManager/amm_pip.class.inc.php

    r2468 r2488  
    3939  public function init_events()
    4040  {
    41     add_event_handler('loc_begin_menubar', array(&$this, 'modify_menu') );
     41    //TODELETE: add_event_handler('loc_begin_menubar', array(&$this, 'modify_menu') );
     42    parent::init_events();
     43    add_event_handler('blockmanager_apply', array(&$this, 'blockmanager_apply') );
    4244  }
    4345
    44   /* ---------------------------------------------------------------------------
    45   protected classe functions
    46   --------------------------------------------------------------------------- */
    47   public function modify_menu()
     46  public function blockmanager_apply( $menu_ref_arr )
    4847  {
    49     global $menu, $user;
    50 
    51 
    52     /*
    53       Add a new section (links)
    54     */
    55     $urls=$this->get_urls(true);
    56     if(($this->my_config['amm_links_active']=='y')and(count($urls)>0))
    57     {
    58       if($this->my_config['amm_links_show_icons']=='y')
    59       {
    60         for($i=0;$i<count($urls);$i++)
    61         {
    62           $urls[$i]['icon']=AMM_PATH."links_pictures/".$urls[$i]['icon'];
    63         }
    64       }
    65 
    66       $section = new Section('mbAMM_links', base64_decode($this->my_config['amm_links_title'][$user['language']]), dirname(__FILE__).'/menu_templates/menubar_links.tpl');
    67       $section->set_items(array(
    68         'LINKS' => $urls,
    69         'icons' => $this->my_config['amm_links_show_icons']
    70       ));
    71       $menu->add($section->get());
    72     }
    73 
     48    $menu = & $menu_ref_arr[0];
    7449
    7550    /*
    7651      Add a new random picture section
    7752    */
    78     if($this->my_config['amm_randompicture_active']=='y')
     53    if ( ($block = $menu->get_block( 'mbAMM_randompict' ) ) != null )
    7954    {
    8055      $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
     
    9671          'permalink' => $nfo['permalink']
    9772        );
    98 
    99         $section = new Section('mbAMM_randompict', base64_decode($this->my_config['amm_randompicture_title'][$user['language']]), dirname(__FILE__).'/menu_templates/menubar_randompic.tpl');
    100         $section->set_items(array(
     73        global $user;
     74        $block->set_title(  base64_decode($this->my_config['amm_randompicture_title'][$user['language']]) );
     75        $block->template = dirname(__FILE__).'/menu_templates/menubar_randompic.tpl';
     76        $block->data = array(
    10177          'LINK' => make_picture_url($nfo),
    10278          'IMG' => get_thumbnail_url($nfo),
     
    10581          'SHOWNAME' => $this->my_config['amm_randompicture_showname'],
    10682          'SHOWCOMMENT' => $this->my_config['amm_randompicture_showcomment']
    107         ));
    108         $menu->add($section->get());
     83        );
     84      }
     85    }
     86
     87    /*
     88      Add a new section (links)
     89    */
     90    if ( ($block = $menu->get_block( 'mbAMM_links' ) ) != null )
     91    {
     92      $urls=$this->get_urls(true);
     93      if ( count($urls)>0 )
     94      {
     95        if($this->my_config['amm_links_show_icons']=='y')
     96        {
     97          for($i=0;$i<count($urls);$i++)
     98          {
     99            $urls[$i]['icon']=get_root_url().'plugins/'.AMM_DIR."/links_pictures/".$urls[$i]['icon'];
     100          }
     101        }
     102       
     103        $block->set_title( base64_decode($this->my_config['amm_links_title'][$user['language']]) );
     104        $block->template = dirname(__FILE__).'/menu_templates/menubar_links.tpl';
     105
     106        $block->data = array(
     107          'LINKS' => $urls,
     108          'icons' => $this->my_config['amm_links_show_icons']
     109        );
    109110      }
    110111    }
     
    122123        if(!isset($id_done[$val['id']]))
    123124        {
    124           $section = new Section('mbAMM_personalised'.$val['id'], $val['title'], dirname(__FILE__).'/menu_templates/menubar_personalised.tpl');
    125           $section->set_items(array(
    126             'CONTENT' => stripslashes($val['content'])));
    127           $menu->add($section->get());
    128 
     125          if ( ($block = $menu->get_block( 'mbAMM_personalised'.$val['id'] ) ) != null )
     126          {
     127            $block->set_title( $val['title'] );
     128            $block->template = dirname(__FILE__).'/menu_templates/menubar_personalised.tpl';
     129            $block->data = stripslashes($val['content']);
     130          }
    129131          $id_done[$val['id']]="";
    130132        }
    131       }
    132     }
    133 
    134 
    135     /*
    136       Hide sections
    137     */
    138     foreach($this->my_config['amm_sections_visible'] as $key => $val)
    139     {
    140       if($val=='n')
    141       {
    142         $menu->remove($key);
    143133      }
    144134    }
     
    147137      hide items from special & menu sections
    148138    */
    149     foreach(array('mbMenu' => 'amm_sections_modmenu', 'mbSpecial' =>'amm_sections_modspecial') as $key0 => $val0)
     139    foreach(array('mbMenu' => 'amm_sections_modmenu', 'mbSpecials' =>'amm_sections_modspecials') as $key0 => $val0)
    150140    {
    151       $section_menu=$menu->section($key0);
    152       foreach($this->my_config[$val0] as $key => $val)
     141      if ( ($block = $menu->get_block( $key0 ) ) != null )
    153142      {
    154         if($val=='n')
     143        foreach($this->my_config[$val0] as $key => $val)
    155144        {
    156           unset($section_menu['ITEMS'][$key]);
     145          if($val=='n')
     146          {
     147            unset( $block->data[$key] );
     148          }
    157149        }
    158150      }
    159       $menu->replace($section_menu);
    160151    }
    161 
    162   }
    163 
     152        }
    164153
    165154} // AMM_PIP class
  • trunk/plugins/AMenuManager/amm_root.class.inc.php

    r2468 r2488  
    3838  public function init_config()
    3939  {
    40     global $menu;
    41 
    4240    $this->my_config=array(
    4341      'amm_links_show_icons' => 'y',
    44       'amm_links_active' => 'y',
    4542      'amm_links_title' => array(),
    46       'amm_sections_visible' => array(),
    47       'amm_randompicture_active' => 'n',
    4843      'amm_randompicture_showname' => 'n',     //n:no, o:over, u:under
    4944      'amm_randompicture_showcomment' => 'n',   //n:no, o:over, u:under
    5045      'amm_randompicture_title' => array(),
    51       'amm_sections_modspecial' => array(
    52         'favorite_cat' => 'y',
    53         'most_visited_cat' => 'y',
    54         'best_rated_cat' => 'y',
    55         'random_cat' => 'y',
    56         'recent_pics_cat' => 'y',
    57         'recent_cats_cat' => 'y',
     46      'amm_sections_modspecials' => array(
     47        'favorites' => 'y',
     48        'most_visited' => 'y',
     49        'best_rated' => 'y',
     50        'random' => 'y',
     51        'recent_pics' => 'y',
     52        'recent_cats' => 'y',
    5853        'calendar' => 'y'
    5954      ),
    6055      'amm_sections_modmenu' => array(
    6156        'qsearch' => 'y',
    62         'Tags' => 'y',
    63         'Search' => 'y',
     57        'tags' => 'y',
     58        'search' => 'y',
    6459        'comments' => 'y',
    65         'About' => 'y',
    66         'Notification' => 'y'
     60        'about' => 'y',
     61        'notification' => 'y'
    6762      )
    6863    );
     
    8378    }
    8479
    85     $sections=$menu->registered();
    86     foreach($sections as $key => $val)
    87     {
    88       $this->my_config['amm_sections_visible'][$key]='y';
    89     }
    9080  }
    9181
    9282  public function load_config()
    9383  {
    94     global $menu;
     84    parent::load_config();
     85  }
    9586
    96     parent::load_config();
     87  public function init_events()
     88  {
     89    add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') );
     90  }
    9791
    98     $sections=$menu->registered();
    99     foreach($sections as $key => $val)
     92  public function register_blocks( $menu_ref_arr )
     93  {
     94    $menu = & $menu_ref_arr[0];
     95    if ($menu->get_id() != 'menubar')
     96      return;
     97    $menu->register_block( new RegisteredBlock( 'mbAMM_randompict', 'Random pictures', 'AMM'));
     98    $menu->register_block( new RegisteredBlock( 'mbAMM_links', 'Links', 'AMM'));
     99
     100    $sections=$this->get_sections(true);
     101    if(count($sections))
    100102    {
    101       if(!isset($this->my_config['amm_sections_visible'][$key]))
     103      $id_done=array();
     104      foreach($sections as $key => $val)
    102105      {
    103         $this->my_config['amm_sections_visible'][$key]='y';
     106        if(!isset($id_done[$val['id']]))
     107        {
     108          $menu->register_block( new RegisteredBlock( 'mbAMM_personalised'.$val['id'], $val['title'], 'AMM'));
     109          $id_done[$val['id']]="";
     110        }
    104111      }
    105112    }
    106    
    107113  }
    108114
  • trunk/plugins/AMenuManager/main.inc.php

    r2466 r2488  
    4444define('AMM_VERSION' , '1.0.0'); // => ne pas oublier la version dans l'entête !!
    4545
    46 global $prefixeTable, $menu;
     46global $prefixeTable;
    4747
    48 if(basename($_SERVER["PHP_SELF"])=='admin.php')
     48if(defined('IN_ADMIN'))
    4949{
    5050  //AMM admin part loaded and active only if in admin page
  • trunk/plugins/AMenuManager/maintain.inc.php

    r2466 r2488  
    66ini_set('display_errors', true);
    77
    8 define('AMM_DIR' , basename(dirname(__FILE__)));
    9 define('AMM_PATH' , PHPWG_PLUGINS_PATH . AMM_DIR . '/');
     8defined('AMM_DIR') || define('AMM_DIR' , basename(dirname(__FILE__)));
     9defined('AMM_PATH') || define('AMM_PATH' , PHPWG_PLUGINS_PATH . AMM_DIR . '/');
    1010@include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/tables.class.inc.php');
    1111
     
    2424function plugin_install($plugin_id, $plugin_version, &$errors)
    2525{
    26   global $prefixeTable, $gpc_installed, $menu;
     26  global $prefixeTable, $gpc_installed;
    2727  if($gpc_installed)
    2828  {
    29     $menu->register('mbAMM_links', 'Links', 0, 'AMM');
    30     $menu->register('mbAMM_randompict', 'Random pictures', 0, 'AMM');
     29    //$menu->register('mbAMM_links', 'Links', 0, 'AMM');
     30    //$menu->register('mbAMM_randompict', 'Random pictures', 0, 'AMM');
    3131    $amm=new AMM_install($prefixeTable, __FILE__);
    3232    $result=$amm->install();
     
    4848function plugin_uninstall($plugin_id)
    4949{
    50   global $prefixeTable, $gpc_installed, $menu;
    51   if($gpc_installed)
    52   {
    53     $menu->unregister('mbAMM_links');
    54     $menu->unregister('mbAMM_randompict');
    55     $amm=new AMM_install($prefixeTable, __FILE__);
    56     $result=$amm->uninstall();
    57   }
    58   else
    59   {
    60     array_push($errors, l10n('Grum Plugin Classes is not installed'));
    61   }
     50  global $prefixeTable;
     51  $amm=new AMM_install($prefixeTable, __FILE__);
     52  $result=$amm->uninstall();
    6253}
    6354
  • trunk/plugins/AMenuManager/menu_templates/menubar_links.tpl

    r2469 r2488  
    11
    22<!-- links menu bar -->
    3 {if $section.NAME!=""}
    4   <dt>{$section.NAME|@translate}</dt>
     3{if $block->get_title() !="" }
     4  <dt>{$block->get_title()}</dt>
    55{/if}
    66<dd>
    7   <ul {if $section.ITEMS.icons=='y'}style="padding-left:4px;list-style:none;"{/if}>
    8     {foreach from=$section.ITEMS.LINKS item=link}
     7  <ul {if $block->data.icons=='y'}style="padding-left:4px;list-style:none;"{/if}>
     8    {foreach from=$block->data.LINKS item=link}
    99      <li>
    10         {if $section.ITEMS.icons=='y'}<img src='{$link.icon}' style="position:relative;top:3px;"/>{/if}
     10        {if $block->data.icons=='y'}<img src='{$link.icon}' style="position:relative;top:3px;"/>{/if}
    1111        <a href="{$link.url}"
    1212          {if $link.mode == 0} target = '_blank' {/if}>{$link.label}</a>
  • trunk/plugins/AMenuManager/menu_templates/menubar_personalised.tpl

    r2468 r2488  
    11
    22<!-- personalised menu bar -->
    3 {if $section.NAME!=""}
    4   <dt>{$section.NAME|@translate}</dt>
     3{if $block->get_title() !="" }
     4  <dt>{$block->get_title()}</dt>
    55{/if}
    66<dd>
    7     {if $section.ITEMS.CONTENT!=""}{$section.ITEMS.CONTENT}{/if}
     7    {$block->data}
    88</dd>
  • trunk/plugins/AMenuManager/menu_templates/menubar_randompic.tpl

    r2468 r2488  
    11
    22<!-- random picture menu bar -->
    3 {if $section.NAME!=""}
    4   <dt>{$section.NAME|@translate}</dt>
    5 {/if}
     3<dt>{$block->get_title()}</dt>
    64<dd>
    75  <div class="illustration" style="text-align:center;padding:5px;font-size:85%;">
    8     {if $section.ITEMS.IMGNAME!="" and $section.ITEMS.SHOWNAME=="o"}{$section.ITEMS.IMGNAME}<br/>{/if}
    9     {if $section.ITEMS.IMGCOMMENT!="" and $section.ITEMS.SHOWCOMMENT=="o"}{$section.ITEMS.IMGCOMMENT}<br/>{/if}
    10     <a href="{$section.ITEMS.LINK}"><img src="{$section.ITEMS.IMG}"/></a>
    11     {if $section.ITEMS.IMGNAME!="" and $section.ITEMS.SHOWNAME=="u"}<br/>{$section.ITEMS.IMGNAME}{/if}
    12     {if $section.ITEMS.IMGCOMMENT!="" and $section.ITEMS.SHOWCOMMENT=="u"}<br/>{$section.ITEMS.IMGCOMMENT}{/if}
     6    {if $block->data.IMGNAME!="" and $block->data.SHOWNAME=="o"}{$block->data.IMGNAME}<br/>{/if}
     7    {if $block->data.IMGCOMMENT!="" and $block->data.SHOWCOMMENT=="o"}{$block->data.IMGCOMMENT}<br/>{/if}
     8    <a href="{$block->data.LINK}"><img src="{$block->data.IMG}"/></a>
     9    {if $block->data.IMGNAME!="" and $block->data.SHOWNAME=="u"}<br/>{$block->data.IMGNAME}{/if}
     10    {if $block->data.IMGCOMMENT!="" and $block->data.SHOWCOMMENT=="u"}<br/>{$block->data.IMGCOMMENT}{/if}
    1311  </div>
    1412</dd>
Note: See TracChangeset for help on using the changeset viewer.