Ignore:
Timestamp:
Feb 17, 2011, 4:27:09 PM (13 years ago)
Author:
patdenice
Message:

New administration pannel for additional pages.
Better url.
Add permalinks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/AdditionalPages/index_menu.php

    r6227 r9261  
    1111  if ($menu->get_id() != 'menubar')
    1212    return;
    13   $menu->register_block( new RegisteredBlock( 'mbAdditionalPages', 'Additional Pages', 'AP'));
     13  $menu->register_block( new RegisteredBlock( 'mbAdditionalPages', 'Additional Pages', 'P@t'));
    1414}
    1515
     
    1717{
    1818  global $template, $conf, $user, $lang;
    19 
    20   $ap_conf = explode ("," , $conf['additional_pages']);
    2119
    2220  $menu = & $menu_ref_arr[0];
     
    2725
    2826    load_language('plugin.lang', AP_PATH);
    29    
    30     // Gestion des langues pour le nom du menu
    31     $languages = explode('/', $ap_conf[0]);
    32     foreach($languages as $language)
    33     {
    34       $array = explode(':', $language);
    35       if (!isset($array[1])) $menu_langs['default'] = $array[0];
    36       else $menu_langs[$array[0]] = $array[1];
    37     }
    3827
    3928    $data = array();
    4029
    41     if (is_admin())
    42     {
    43       array_push($data, array(
    44         'URL' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . AP_DIR . '%2Fadmin%2Fadd_page.php',
    45         'LABEL' => l10n('ap_add_page')));
    46       $clauses = '';
    47     }
    48     else
    49     {
    50       $clauses = 'WHERE (lang = "' . $user['language'] . '" OR lang = "ALL")';
    51     }
    52  
    5330    // Recupération des groupes de l'utilisateur
    5431    $q = 'SELECT group_id FROM ' . USER_GROUP_TABLE . ' WHERE user_id = ' . $user['id'] . ';';
     
    6138 
    6239    // Récupération des pages
    63     $q = 'SELECT id , pos , title
     40    $q = 'SELECT id, pos, title, users, groups, permalink
    6441FROM ' . ADD_PAGES_TABLE . '
    65 ' . $clauses . '
    66 ORDER BY pos ASC;';
     42WHERE (lang = "' . $user['language'] . '" OR lang IS NULL)
     43  AND pos > 0
     44ORDER BY pos ASC, id ASC
     45;';
    6746    $result = pwg_query($q);
    6847
     
    7150      if ($row['pos'] != '0' or is_admin())
    7251      {
    73         if (strpos($row['title'] , '/user_id='))
     52        $authorized_users = array();
     53        $authorized_groups = array();
     54        if (!empty($row['users']))
    7455        {
    75           $array = explode('/user_id=' , $row['title']);
    76           $row['title'] = $array[0];
    77           $authorized_users = explode(',', $array[1]);
     56          $authorized_users = explode(',', $row['users']);
    7857        }
    79         if (strpos($row['title'] , '/group_id='))
     58        if (!empty($row['groups']))
    8059        {
    81           $array = explode('/group_id=' , $row['title']);
    82           $row['title'] = $array[0];
    83           $auth = explode(',', $array[1]);
     60          $auth = explode(',', $row['groups']);
    8461          $authorized_groups = array_intersect($groups, $auth);
    8562        }
    86         if (is_admin() and isset($ap_conf[3]) and $ap_conf[3] == 'on')
    87         {
    88           $row['title'] .= '</a> --- <a href=' . PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . AP_DIR . '%2Fadmin%2Fadd_page.php&amp;edit=' . $row['id'] . '>[edit]';
    89         }
    9063        if (is_admin() or (
    91           (isset($ap_conf[6]) and $ap_conf[6] == 'off' or !isset($authorized_groups) or !empty($authorized_groups)) and
    92           (isset($ap_conf[7]) and $ap_conf[7] == 'off' or !isset($authorized_users) or in_array($user['status'], $authorized_users))))
     64          (!$conf['additional_pages']['group_perm'] or empty($row['groups']) or !empty($authorized_groups)) and
     65          (!$conf['additional_pages']['user_perm'] or empty($row['users']) or in_array($user['status'], $authorized_users))))
    9366        {
    9467          array_push($data, array(
    95             'URL' => PHPWG_ROOT_PATH . 'index.php?/additional_page/' . $row['id'],
     68            'URL' => make_index_url().'/page/'.(isset($row['permalink']) ? $row['permalink'] : $row['id']),
    9669            'LABEL' => $row['title']));
    9770        }
     
    10376    if (!empty($data))
    10477    {
    105       $block->set_title(isset($menu_langs[$user['language']]) ? $menu_langs[$user['language']] : $menu_langs['default']);
     78      $block->set_title(
     79        isset($conf['additional_pages']['languages'][$user['language']]) ?
     80          $conf['additional_pages']['languages'][$user['language']] :
     81          @$conf['additional_pages']['languages']['default']
     82        );
    10683      $block->template = 'AdditionalPages_menu.tpl';
    10784      $block->data = $data;
Note: See TracChangeset for help on using the changeset viewer.