Changeset 9261


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

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

Location:
extensions/AdditionalPages
Files:
8 added
2 deleted
16 edited
1 moved

Legend:

Unmodified
Added
Removed
  • extensions/AdditionalPages/additional_page.php

    r8132 r9261  
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44
    5 global $template, $conf, $user;
     5global $template, $user;
     6
     7$page['section'] = 'additional_page';
     8$identifier = $page['is_homepage'] ? $conf['additional_pages']['homepage'] : $tokens[1];
    69
    710load_language('plugin.lang.php', AP_PATH);
    811
    9 $ap_id = explode('additional_page/' , $_SERVER['REQUEST_URI']);
    10 $ap_id = explode('&' , $ap_id[1]);
    11 $ap_conf = explode ("," , $conf['additional_pages']);
     12if (function_exists('get_extended_desc'))
     13  add_event_handler('AP_render_content', 'get_extended_desc');
    1214
    1315// Récupération des données de la page
    14 $q = 'SELECT title , pos , text
     16$query = 'SELECT id, title , content, users, groups, permalink
    1517FROM ' . ADD_PAGES_TABLE . '
    16 WHERE id = ' . $ap_id[0] . ';';
    17 $result = mysql_fetch_assoc(pwg_query($q));
     18';
     19$query .= is_numeric($identifier) ?
     20  'WHERE id = '.$identifier.';' :
     21  'WHERE permalink = "'.$identifier.'";';
    1822
    19 if (empty($result))
     23$row = mysql_fetch_assoc(pwg_query($query));
     24
     25if (empty($row))
    2026{
    21   page_not_found('This page does not exist', 'index.php?');
     27  if ($page['is_homepage']) return;
     28  page_not_found('Requested page does not exist');
    2229}
    2330
     31if (is_numeric($identifier) and !empty($row['permalink']) and !$page['is_homepage'])
     32{
     33  redirect(make_index_url().'/page/' . $row['permalink']);
     34}
     35
     36$page['additional_page'] = array(
     37  'id' => $row['id'],
     38  'permalink' => @$row['permalink'],
     39  'title' => trigger_event('AP_render_content', $row['title']),
     40  'content' => trigger_event('AP_render_content', $row['content']),
     41);
     42
    2443// Utilisateurs autorisés
    25 if (strpos($result['title'] , 'user_id='))
     44if (!empty($row['users']))
    2645{
    27   $array = explode('/user_id=' , $result['title']);
    28   $result['title'] = $array[0];
    29   $authorized_users = explode(',', $array[1]);
    30   if (!is_admin() and $ap_conf[7] == 'on' and !in_array($user['status'], $authorized_users))
     46  $authorized_users = explode(',', $row['users']);
     47  if (!is_admin() and $conf['additional_pages']['user_perm'] and !in_array($user['status'], $authorized_users))
    3148  {
    32         page_not_found('User not allowed', 'index.php?');
     49    if ($page['is_homepage']) return;
     50        page_forbidden(l10n('You are not authorized to access the requested page'));
    3351  }
    3452}
    3553
    3654// Groupe autorisé
    37 if (strpos($result['title'] , 'group_id='))
     55if (!empty($row['groups']))
    3856{
    39   $array = explode('/group_id=' , $result['title']);
    40   $result['title'] = $array[0];
    41   $authorized_groups = $array[1];
    42 
    4357  $q = 'SELECT *
    4458FROM ' . USER_GROUP_TABLE . '
    45 WHERE user_id = ' . $user['id'] . ' AND group_id IN (' . $authorized_groups . ');';
     59WHERE user_id = ' . $user['id'] . ' AND group_id IN (' . $row['groups'] . ');';
    4660  $array = mysql_fetch_array(pwg_query($q));
    47   if (!is_admin() and $ap_conf[6] == 'on' and empty($array))
     61  if (!is_admin() and $conf['additional_pages']['group_perm'] and empty($array))
    4862  {
    49         page_not_found('User not allowed', 'index.php?');
     63    if ($page['is_homepage']) return;
     64        page_forbidden(l10n('You are not authorized to access the requested page'));
    5065  }
    5166}
    5267
    53 // Envoi de la page
    54 // Extended description
    55 if (function_exists('get_extended_desc'))
    56   add_event_handler('AP_render_content', 'get_extended_desc');
     68add_event_handler('loc_end_index', 'ap_set_index');
    5769
    58 $template->assign(array(
    59   'TITLE' => trigger_event('AP_render_content', $result['title']),
    60   'PLUGIN_INDEX_CONTENT_BEGIN' => trigger_event('AP_render_content', $result['text'])));
    61 if (isset($ap_conf[2]) and $ap_conf[2] == 'on')
     70function ap_set_index()
    6271{
    63   $template->assign('PLUGIN_INDEX_ACTIONS' , '
    64     <li><a href="' . make_index_url() . '" title="' . l10n('return to homepage') . '">
    65       <img src="' . $template->get_themeconf('icon_dir') . '/home.png" class="button" alt="' . l10n('home') . '"/></a>
    66     </li>');
    67 }
    68 if (is_admin())
    69 {
    70   $template->assign('U_EDIT', PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . AP_DIR . '%2Fadmin%2Fadd_page.php&amp;edit=' . $ap_id[0]);
     72  global $template, $page, $conf;
     73
     74  $template->assign(array(
     75    'TITLE' => $page['additional_page']['title'],
     76    'PLUGIN_INDEX_CONTENT_BEGIN' => $page['additional_page']['content'],
     77    )
     78  );
     79
     80  if ($conf['additional_pages']['show_home'])
     81  {
     82    $template->assign('PLUGIN_INDEX_ACTIONS' , '
     83      <li><a href="'.make_index_url().'" title="' . l10n('return to homepage') . '">
     84        <img src="' . $template->get_themeconf('icon_dir') . '/home.png" class="button" alt="' . l10n('home') . '"/></a>
     85      </li>');
     86  }
     87  if (is_admin())
     88  {
     89    $template->assign('U_EDIT', PHPWG_ROOT_PATH.'admin.php?page=plugin&amp;section='.AP_DIR.'%2Fadmin%2Fadmin.php&amp;tab=edit_page&amp;edit='.$page['additional_page']['id'].'&amp;redirect=true');
     90  }
     91  $template->clear_assign(array('U_MODE_POSTED', 'U_MODE_CREATED'));
    7192}
    7293
    73 $template->clear_assign(array('U_MODE_POSTED', 'U_MODE_CREATED'));
    74 
    7594?>
  • extensions/AdditionalPages/admin/add_page.inc.php

    r8131 r9261  
    22
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    4 load_language('plugin.lang', AP_PATH);
    5 $ap_conf = explode(',' , $conf['additional_pages']);
     4
    65$edited_page = array();
     6$edited_page['id'] = 0;
     7$edited_page['homepage'] = false;
    78$page_title = l10n('ap_create');
    89
    9 if (isset($_GET['saved']) and isset($_GET['edit']))
    10 {
    11         array_push($page['infos'], sprintf(l10n('ap_saved_page') , $_GET['edit']));
    12 }
    13 
    14 // Suppression
    15 if (isset($_POST['delete']) and isset($_GET['edit']))
    16 {
    17         pwg_query('DELETE FROM ' . ADD_PAGES_TABLE . ' WHERE id = ' . $_GET['edit'] . ';');
    18   array_push($page['infos'], l10n('ap_deleted_page'));
    19   @unlink(AP_PATH . 'backup/' . $_GET['edit'] . '.txt');
    20   return;
    21 }
    22 
    23 // Enregistrement
    24 if (isset($_POST['save']))
    25 {
    26   $group_access = (!empty($_POST['groups']) ? implode(',', $_POST['groups']) : '');
    27   $user_access = (!empty($_POST['users']) ? implode(',', $_POST['users']) : '');
    28   if (empty($_POST['name']))
    29   {
    30     array_push($page['errors'], l10n('ap_no_name'));
    31     $edited_page['title'] = '';
    32     $edited_page['pos'] = $_POST['pos'];
    33     $edited_page['text'] = stripslashes($_POST['ap_content']);
    34     $edited_page['group'] = (!empty($_POST['groups']) ? $_POST['groups'] : array());
    35     $edited_page['user'] = (!empty($_POST['users']) ? $_POST['users'] :  array());
    36   }
    37   else
    38   {
    39     $PageTitle = $_POST['name'];
    40     if (!empty($group_access))
    41     {
    42       $PageTitle .= '/group_id=' . $group_access ;
    43     }
    44     if ($ap_conf[7] == 'on')
    45     {
    46       $PageTitle .= '/user_id=' . $user_access ;
    47     }
    48     if (isset($_GET['edit']))
    49     {
    50       $next_element_id = $_GET['edit'];
    51       pwg_query('DELETE FROM ' . ADD_PAGES_TABLE . ' WHERE id = ' . $_GET['edit'] . ';');
    52     }
    53     else
    54     {
    55       $q = 'SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id  FROM ' . ADD_PAGES_TABLE . ' ;';
    56       list($next_element_id) = mysql_fetch_array(pwg_query($q));
    57     }
    58     if ($_POST['pos'] == '') $_POST['pos'] = 'NULL';
    59     $q = 'INSERT INTO ' . ADD_PAGES_TABLE . ' ( id , pos , lang , title , text )
    60 VALUES (' . $next_element_id . ' , ' . $_POST['pos'] . ' , "' . $_POST['lang'] . '" , "' . $PageTitle . '" , "' . $_POST['ap_content'] . '");';
    61     pwg_query($q);
    62 
    63     // Enregistrement du fichier de sauvegarde
    64     $sav_file = @fopen(AP_PATH . 'backup/' . $next_element_id . '.txt', "w");
    65     @fwrite($sav_file, "Title: " . $_POST['name'] . "
    66 Position: " . $_POST['pos'] . "
    67 Language: " . $_POST['lang'] . "
    68 
    69 " . $_POST['ap_content']);
    70     @fclose($sav_file);
    71 
    72     if (isset($ap_conf[4]) and $ap_conf[4] == 'on')
    73     {
    74       redirect(get_root_url() . 'index.php?/additional_page/' . $next_element_id);
    75     }
    76     else
    77     {
    78       redirect(get_root_url() . 'admin.php?page=plugin&section=' . AP_DIR . '%2Fadmin%2Fadd_page.php&saved=1&edit=' . $next_element_id);
    79     }
    80   }
    81 }
    82 
    83 // Chargement des données
    84 if (isset($_GET['edit']))
    85 {
    86   $q = 'SELECT id , pos , lang , title , text
    87 FROM ' . ADD_PAGES_TABLE . '
    88 WHERE id = ' . $_GET['edit'] . ';';
    89   $edited_page = mysql_fetch_assoc(pwg_query($q));
    90   $page_title = l10n('ap_modify');
    91   // Utilisateurs autorisés
    92   if (strpos($edited_page['title'] , '/user_id='))
    93   {
    94     $array = explode('/user_id=' , $edited_page['title']);
    95     $edited_page['title'] = $array[0];
    96     $edited_page['user'] = explode(',', $array[1]);
    97   }
    98   // Groupes autorisés
    99   if (strpos($edited_page['title'] , '/group_id='))
    100   {
    101     $array = explode('/group_id=' , $edited_page['title']);
    102     $edited_page['title'] = $array[0];
    103     $edited_page['group'] = explode(',', $array[1]);
    104   }
    105   // Lien de suppression
    106   $template->assign('delete', true);
    107 }
    108 
    109 // Selection des langues
    110 $options['ALL'] = l10n('ap_all_lang');
    111 $selected = 'ALL';
    112 foreach (get_languages() as $language_code => $language_name)
    113 {
    114   $options[$language_code] = $language_name;
    115   if (isset($edited_page['lang']) and $edited_page['lang'] == $language_code)
    116   {
    117     $selected = $language_code;
    118   }
    119 }
    120 $template->assign('lang', array(
    121   'OPTIONS' => $options,
    122   'SELECTED' => $selected));
    123 
    124 // Selection des groupes
    125 if (isset($ap_conf[6]) and $ap_conf[6] == 'on')
    126 {
    127         include_once(AP_PATH . 'admin/functions_groups.php');
    128         $template->assign('GROUPSELECTION', get_html_groups_selection(get_all_groups(), 'groups', (!empty($edited_page['group']) ? $edited_page['group'] : array())));
    129 }
    130 
    131 // Selection des utilisateurs
    132 if (isset($ap_conf[7]) and $ap_conf[7] == 'on')
    133 {
    134         $selected_users = (isset($edited_page['user']) ? $edited_page['user'] : array('guest', 'generic', 'normal'));
    135         $template->assign('user_perm', array(
    136     'GUEST' => (in_array('guest', $selected_users) ? 'checked="checked"' : ''),
    137                 'GENERIC' => (in_array('generic', $selected_users) ? 'checked="checked"' : ''),
    138                 'NORMAL' => (in_array('normal', $selected_users) ? 'checked="checked"' : '')));
    139 }
    140 
    141 // Chargement des données pour l'édition
    142 if (!empty($edited_page))
    143 {
    144   $template->assign(array(
    145     'NAME' => $edited_page['title'],
    146     'POS' => $edited_page['pos'],
    147     'CONTENT' => $edited_page['text']));
    148 }
    149 
    150 // Parametrage du template
    151 $template->assign('AP_TITLE', $page_title);
    152 
    153 $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/add_page.tpl');
    154 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
     10include(AP_PATH.'admin/page_form.inc.php');
    15511
    15612?>
  • extensions/AdditionalPages/admin/admin.php

    r3609 r9261  
    44load_language('plugin.lang', AP_PATH);
    55
    6 global $conf, $template, $lang;
     6global $conf, $template;
    77
    8 $ap_conf = explode ("," , $conf['additional_pages']);
     8include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
     9$my_base_url = get_admin_plugin_menu_link(__FILE__);
    910
    10 // Enregistrement de la configuration
    11 if (isset($_POST['submit']))
     11if (!isset($_GET['tab']))
     12  $page['tab'] = 'manage';
     13else
     14  $page['tab'] = $_GET['tab'];
     15
     16include(AP_PATH.'admin/'.$page['tab'].'.inc.php');
     17
     18$tabsheet = new tabsheet();
     19$tabsheet->add('manage', l10n('Manage'), $my_base_url.'&amp;tab=manage');
     20$tabsheet->add('add_page', l10n('ap_add_page'), $my_base_url.'&amp;tab=add_page');
     21$tabsheet->add('config', l10n('Configuration'), $my_base_url.'&amp;tab=config');
     22if ($page['tab'] == 'edit_page')
    1223{
    13         foreach($_POST['menu_lang'] as $language_code => $name)
    14   {
    15                 if ($language_code == 'default') $save_languages[] = $name;
    16                 elseif (!empty($name)) $save_languages[] = $language_code . ':' . $name;
    17         }
    18         $languages = implode('/', $save_languages);
    19     if (!isset($_POST['show_menu']))
    20         $_POST['show_menu'] = 'off';
    21     if (!isset($_POST['show_home']))
    22         $_POST['show_home'] = 'off';
    23     if (!isset($_POST['show_edit']))
    24         $_POST['show_edit'] = 'off';
    25     if (!isset($_POST['redirect']))
    26         $_POST['redirect'] = 'off';
    27     if (!isset($_POST['group_perm']))
    28         $_POST['group_perm'] = 'off';
    29     if (!isset($_POST['user_perm']))
    30         $_POST['user_perm'] = 'off';
    31     $ap_conf = array($languages,
    32         $_POST['show_menu'],
    33         $_POST['show_home'],
    34         $_POST['show_edit'],
    35         $_POST['redirect'],
    36         $ap_conf[5], //Ancien emplacement du bbcode
    37         $_POST['group_perm'],
    38         $_POST['user_perm']);
    39     $query = '
    40 UPDATE ' . CONFIG_TABLE . '
    41   SET value="' . implode ("," , $ap_conf) . '"
    42   WHERE param="additional_pages"
    43   LIMIT 1';
    44     pwg_query($query);
    45     array_push($page['infos'], l10n('ap_conf_saved'));
     24  $tabsheet->add('edit_page', l10n('ap_edit_page'), $my_base_url.'&amp;tab=edit_page');
    4625}
    47 
    48 // Gestion des langues pour le bloc menu
    49 $languages = explode('/', $ap_conf[0]);
    50 foreach($languages as $language)
    51 {
    52         $array = explode(':', $language);
    53         if (!isset($array[1])) $menu_langs['default'] = $array[0];
    54         else $menu_langs[$array[0]] = $array[1];
    55 }
    56 
    57 $template->assign('LANG_DEFAULT_VALUE', $menu_langs['default']);
    58 foreach (get_languages() as $language_code => $language_name)
    59 {
    60         $template->append('language', array(
    61     'LANGUAGE_NAME' => $language_name,
    62     'LANGUAGE_CODE' => $language_code,
    63     'VALUE' => (isset($menu_langs[$language_code]) ? $menu_langs[$language_code] : '')));
    64 }
    65 
    66 // Parametrage du template
    67 $template->assign(array(
    68   'MENU_NAME' => $ap_conf[0],
    69   'SHOW_MENU' => (isset($ap_conf[1]) and $ap_conf[1] == 'on') ? 'checked="checked"' : '',
    70   'SHOW_HOME' => (isset($ap_conf[2]) and $ap_conf[2] == 'on') ? 'checked="checked"' : '',
    71   'SHOW_EDIT' => (isset($ap_conf[3]) and $ap_conf[3] == 'on') ? 'checked="checked"' : '',
    72   'REDIRECT' => (isset($ap_conf[4]) and $ap_conf[4] == 'on') ? 'checked="checked"' : '',
    73   'GROUP_PERM' => (isset($ap_conf[6]) and $ap_conf[6] == 'on') ? 'checked="checked"' : '',
    74   'USER_PERM' => (isset($ap_conf[7]) and $ap_conf[7] == 'on') ? 'checked="checked"' : ''));
    75                
    76 // Lien de conversion bbcode
    77 if (isset($ap_conf[5]) and $ap_conf[5] == 'on')
    78 {
    79         $template->assign('convert_bbcode', array('PATH' => get_admin_plugin_menu_link(AP_PATH . 'admin/parse_bbcode.php')));
    80 }
    81 
    82 $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl'));
    83 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
     26$tabsheet->select($page['tab']);
     27$tabsheet->assign();
    8428
    8529?>
  • 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&amp;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;
  • extensions/AdditionalPages/language/cs_CZ/plugin.lang.php

    r7127 r9261  
    44
    55$lang['ap_create'] = 'Přidat novou stránku';
    6 $lang['ap_deleted_page'] = 'Stránka byla smazána. (<a href="' .PHPWG_ROOT_PATH . '">zpět domů</a>)';
     6$lang['ap_deleted_page'] = 'Stránka byla smazána.';
    77$lang['ap_no_name'] = 'Je nutné vyplnit jméno.';
    8 $lang['ap_saved_page'] = 'Stránka byla uložena (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">zobrazit stránku</a>)';
     8$lang['ap_saved_page'] = 'Stránka byla uložena';
    99$lang['ap_modify'] = 'Upravit stránku';
    1010$lang['ap_all_lang'] = 'Všechny';
     
    3939$lang['ap_convert_bbcode_ok'] = 'Převod proběhl v pořádku.';
    4040
     41/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
     42/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
     43
    4144?>
  • extensions/AdditionalPages/language/de_DE/plugin.lang.php

    r3691 r9261  
    44
    55$lang['ap_create'] = 'Neue Seite hinzufügen';
    6 $lang['ap_deleted_page'] = 'Seite gelöscht (<a href="' .PHPWG_ROOT_PATH . '">zurück zur Startseite</a>)';
     6$lang['ap_deleted_page'] = 'Seite gelöscht';
    77$lang['ap_no_name'] = 'Es wurde kein Name vergeben.';
    8 $lang['ap_saved_page'] = 'Seite gespeichert (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">Seite anzeigen</a>)';
     8$lang['ap_saved_page'] = 'Seite gespeichert';
    99$lang['ap_modify'] = 'Neue Seite bearbeiten';
    1010$lang['ap_all_lang'] = 'Alle';
     
    3939$lang['ap_convert_bbcode_ok'] = 'Konvertierung abgeschlossen.';
    4040
     41/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
     42/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
     43
    4144?>
  • extensions/AdditionalPages/language/en_UK/plugin.lang.php

    r3609 r9261  
    44
    55$lang['ap_create'] = 'Create new additional page';
    6 $lang['ap_deleted_page'] = 'Page deleted (<a href="' .PHPWG_ROOT_PATH . '">back to home</a>)';
     6$lang['ap_deleted_page'] = 'Page deleted';
    77$lang['ap_no_name'] = 'You do not fill name field.';
    8 $lang['ap_saved_page'] = 'Page saved (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">see the page</a>)';
     8$lang['ap_saved_page'] = 'Page saved';
    99$lang['ap_modify'] = 'Modify the additional page';
    1010$lang['ap_all_lang'] = 'All';
     
    3939$lang['ap_convert_bbcode_ok'] = 'Conversion effectuée.';
    4040
     41$lang['ap_edit_page'] = 'Edit a page';
     42$lang['ap_set_as_homepage'] = 'Set as Homepage';
     43
    4144?>
  • extensions/AdditionalPages/language/es_ES/plugin.lang.php

    r5772 r9261  
    44
    55$lang['ap_create'] = 'Crear una nueva página adiciónal';
    6 $lang['ap_deleted_page'] = 'Página eliminada (<a href="' .PHPWG_ROOT_PATH . '">volver al inicio</a>)';
     6$lang['ap_deleted_page'] = 'Página eliminada';
    77$lang['ap_no_name'] = 'Usted no indicó el nombre.';
    8 $lang['ap_saved_page'] = 'Página registrada (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">Ver la página</a>)';
     8$lang['ap_saved_page'] = 'Página registrada';
    99$lang['ap_modify'] = 'Modificar la página adiciónal';
    1010$lang['ap_all_lang'] = 'Todas';
     
    3939$lang['ap_convert_bbcode_ok'] = 'Conversión efectuada.';
    4040
     41/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
     42/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
     43
    4144?>
  • extensions/AdditionalPages/language/fr_FR/plugin.lang.php

    r3609 r9261  
    44
    55$lang['ap_create'] = 'Créer une nouvelle page additionelle';
    6 $lang['ap_deleted_page'] = 'Page supprimée (<a href="' .PHPWG_ROOT_PATH . '">retour à l\'accueil</a>)';
     6$lang['ap_deleted_page'] = 'Page supprimée';
    77$lang['ap_no_name'] = 'Vous n\'avez pas indiqué le nom.';
    8 $lang['ap_saved_page'] = 'Page enregistrée (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">voir la page</a>)';
     8$lang['ap_saved_page'] = 'Page enregistrée';
    99$lang['ap_modify'] = 'Modifier la page additionelle';
    1010$lang['ap_all_lang'] = 'Toutes';
     
    3838$lang['ap_parse_bbcode'] = 'Convertir les pages déjà écrites avec le BBCode';
    3939$lang['ap_convert_bbcode_ok'] = 'Conversion effectuée.';
     40
     41$lang['ap_edit_page'] = 'Editer une page';
     42$lang['ap_set_as_homepage'] = 'Définir comme page d\'accueil';
     43
    4044?>
  • extensions/AdditionalPages/language/hu_HU/plugin.lang.php

    r4248 r9261  
    44
    55$lang['ap_create'] = 'További új oldal létrehozása';
    6 $lang['ap_deleted_page'] = 'Oldal törlése (<a href="' .PHPWG_ROOT_PATH . '">vissza a főoldalra</a>)';
     6$lang['ap_deleted_page'] = 'Oldal törlése';
    77$lang['ap_no_name'] = 'Nem létező mező.';
    8 $lang['ap_saved_page'] = 'Oldal mentve (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">oldal megtekintése</a>)';
     8$lang['ap_saved_page'] = 'Oldal mentve';
    99$lang['ap_modify'] = 'Új oldal módosítása';
    1010$lang['ap_all_lang'] = 'Összes nyelv';
     
    3939$lang['ap_convert_bbcode_ok'] = 'Konvertálás kész.';
    4040
     41/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
     42/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
     43
    4144?>
  • extensions/AdditionalPages/language/it_IT/plugin.lang.php

    r5276 r9261  
    44
    55$lang['ap_create'] = 'Creare una nuova pagina addizionale';
    6 $lang['ap_deleted_page'] = 'Pagina soppressa (<a href="' .PHPWG_ROOT_PATH . '">ritorno alla home page</a>)';
     6$lang['ap_deleted_page'] = 'Pagina soppressa';
    77$lang['ap_no_name'] = 'Dovete indicare un nome.';
    8 $lang['ap_saved_page'] = 'Pagina registrata (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">visualizzare pagina</a>)';
     8$lang['ap_saved_page'] = 'Pagina registrata';
    99$lang['ap_modify'] = 'Modificare la pagina addizionale';
    1010$lang['ap_all_lang'] = 'Tutte';
     
    3838$lang['ap_parse_bbcode'] = 'Convertire le pagini già scritte con BBCode';
    3939$lang['ap_convert_bbcode_ok'] = 'Conversione effettuata.';
     40
     41/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
     42/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
     43
    4044?>
  • extensions/AdditionalPages/language/lv_LV/plugin.lang.php

    r7320 r9261  
    44
    55$lang['ap_create'] = 'Izveidot jaunu papildus lapu';
    6 $lang['ap_deleted_page'] = 'Lapa dzēsta (<a href="' .PHPWG_ROOT_PATH . '">atpakaļ uz sākumu</a>)';
     6$lang['ap_deleted_page'] = 'Lapa dzēsta';
    77$lang['ap_no_name'] = 'Jūs neesat aizpildījis nosaukuma lauku.';
    8 $lang['ap_saved_page'] = 'Lapa saglabāta (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">skatīt lapu</a>)';
     8$lang['ap_saved_page'] = 'Lapa saglabāta';
    99$lang['ap_modify'] = 'Veikt izmaiņas papildus lapā';
    1010$lang['ap_all_lang'] = 'Visas';
     
    3838$lang['ap_parse_bbcode'] = 'Konvertēt BBCode kodā rakstītās lapas';
    3939$lang['ap_convert_bbcode_ok'] = 'Konvertācija veiksmīga.';
     40
     41/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
     42/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
     43
    4044?>
  • extensions/AdditionalPages/language/pl_PL/plugin.lang.php

    r3825 r9261  
    44
    55$lang['ap_create'] = 'Stwórz nową dodatkową stronę';
    6 $lang['ap_deleted_page'] = 'Strona usunięta (<a href="' .PHPWG_ROOT_PATH . '">powrót do głównej</a>)';
     6$lang['ap_deleted_page'] = 'Strona usunięta';
    77$lang['ap_no_name'] = 'Nie wypełniłeś pola nazwy.';
    8 $lang['ap_saved_page'] = 'Strona zapisana (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">zobacz stronę</a>)';
     8$lang['ap_saved_page'] = 'Strona zapisana';
    99$lang['ap_modify'] = 'Modyfikuj dodatkową stronę';
    1010$lang['ap_all_lang'] = 'Wszystkie';
     
    3939$lang['ap_convert_bbcode_ok'] = 'Konwersja aktywna.';
    4040
     41/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
     42/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
     43
    4144?>
  • extensions/AdditionalPages/language/ru_RU/plugin.lang.php

    r7331 r9261  
    44
    55$lang['ap_create'] = 'Создать новую дополнительную сраницу';
    6 $lang['ap_deleted_page'] = 'Страница удалена (<a href="' .PHPWG_ROOT_PATH . '">на главную</a>)';
     6$lang['ap_deleted_page'] = 'Страница удалена';
    77$lang['ap_no_name'] = 'Введите название страницы';
    8 $lang['ap_saved_page'] = 'Cтраница сохранена (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">просмотреть страницу</a>)';
     8$lang['ap_saved_page'] = 'Cтраница сохранена';
    99$lang['ap_modify'] = 'Изменить дополнительную страницу';
    1010$lang['ap_all_lang'] = 'Все';
     
    3939$lang['ap_convert_bbcode_ok'] = 'Конвертирование выполнено';
    4040
     41/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
     42/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
     43
    4144?>
  • extensions/AdditionalPages/language/sk_SK/plugin.lang.php

    r7063 r9261  
    44
    55$lang['ap_create'] = 'Vytvoriť novú prídavnú stránku';
    6 $lang['ap_deleted_page'] = 'Stránka vymazaná (<a href="' .PHPWG_ROOT_PATH . '">späť na úvodnú stránku</a>)';
     6$lang['ap_deleted_page'] = 'Stránka vymazaná';
    77$lang['ap_no_name'] = 'Nevyplnili ste názov.';
    8 $lang['ap_saved_page'] = 'Stránka uložená (<a href="' .PHPWG_ROOT_PATH . 'index.php?/additional_page/%s">pozrieť stránku</a>)';
     8$lang['ap_saved_page'] = 'Stránka uložená';
    99$lang['ap_modify'] = 'Upraviť prídavnú stránku';
    1010$lang['ap_all_lang'] = 'Všetky';
     
    3838$lang['ap_parse_bbcode'] = 'Konvertovať stránky napísané v BBCode';
    3939$lang['ap_convert_bbcode_ok'] = 'Konverzia úspešná.';
     40
     41/*TODO*/$lang['ap_edit_page'] = 'Edit a page';
     42/*TODO*/$lang['ap_set_as_homepage'] = 'Set as Homepage';
     43
    4044?>
  • extensions/AdditionalPages/main.inc.php

    r3825 r9261  
    44Version: auto
    55Description: Add additional pages in menubar.
    6 Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=153
     6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=153
    77Author: P@t
    88Author URI: http://www.gauchon.com
     
    1717define('ADD_PAGES_TABLE' , $prefixeTable . 'additionalpages');
    1818
     19$conf['additional_pages'] = unserialize($conf['additional_pages']);
     20
    1921function additional_pages_admin_menu($menu)
    2022{
     
    2729function section_init_additional_page()
    2830{
    29     global $tokens, $page;
    30     if ($tokens[0] == 'additional_page')
    31       $page['section'] = 'additional_page';
     31  global $tokens, $conf, $page;
     32
     33  $page['is_homepage'] = (count($tokens) == 1 and empty($tokens[0]));
     34
     35  if (($tokens[0] == 'page' and !empty($tokens[1])) or ($page['is_homepage'] and !is_null($conf['additional_pages']['homepage'])))
     36    include(AP_PATH . 'additional_page.php');
     37
     38  if ($tokens[0] == 'additional_page' and !empty($tokens[1]))
     39    redirect(make_index_url().'/page/'.$tokens[1]);
    3240}
    3341
    34 function index_additional_page()
    35 {
    36     global $page;
    37     if (isset($page['section']) and $page['section'] == 'additional_page')
    38       include(AP_PATH . 'additional_page.php');
    39 }
    40 
    41 $ap_conf = explode ("," , $conf['additional_pages']);
    42 if (isset($ap_conf[1]) and $ap_conf[1] == 'on' or is_admin())
    43 {
    44   include(AP_PATH . 'index_menu.php');
    45 }
     42include(AP_PATH . 'index_menu.php');
    4643
    4744add_event_handler('get_admin_plugin_menu_links', 'additional_pages_admin_menu');
    4845add_event_handler('loc_end_section_init', 'section_init_additional_page');
    49 add_event_handler('loc_end_index', 'index_additional_page');
    5046
    5147?>
  • extensions/AdditionalPages/maintain.inc.php

    r3609 r9261  
    1111    $query = 'CREATE TABLE ' . $prefixeTable . 'additionalpages (
    1212id SMALLINT( 5 ) UNSIGNED NOT NULL ,
    13 pos SMALLINT( 5 ) UNSIGNED default NULL ,
    14 lang VARCHAR( 255 ) NOT NULL ,
     13pos SMALLINT( 5 ) NULL default NULL ,
     14lang VARCHAR( 255 ) NULL default NULL ,
    1515title VARCHAR( 255 ) NOT NULL ,
    16 text LONGTEXT NOT NULL ,
     16content LONGTEXT NOT NULL ,
     17permalink VARCHAR( 64 ) NULL DEFAULT NULL ,
    1718PRIMARY KEY (id) ,
    1819INDEX (pos) ,
     
    2425  if (!isset($conf['additional_pages']))
    2526  {
     27    $config = array(
     28      'languages' => array('default' => 'Additional Pages'),
     29      'show_menu' => true,
     30      'show_home' => true,
     31      'redirect' => false,
     32      'group_perm' => false,
     33      'user_perm' => false,
     34      'homepage' => null,
     35    );
    2636    $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
    27 VALUES ("additional_pages" , "Additional Pages,on,on,off,off,,off,off" , "Parametres du plugin Additional Pages");';
     37VALUES ("additional_pages" , "'.addslashes(serialize($config)).'" , "Additional Pages config configuration");';
    2838    pwg_query($query);
    2939  }
     
    5161  {
    5262    upgrade_ap_from_17();
     63  }
     64  $result = array_from_query($query, 'Field');
     65  if (!in_array('permalink', $result))
     66  {
     67    upgrade_ap_from_21();
    5368  }
    5469}
     
    7893}
    7994
     95function upgrade_ap_from_21()
     96{
     97  global $prefixeTable, $conf;
     98
     99  $query = 'ALTER TABLE ' . $prefixeTable . 'additionalpages
     100CHANGE `id` `id` SMALLINT( 5 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
     101CHANGE `pos` `pos` SMALLINT( 5 ) NULL DEFAULT NULL ,
     102CHANGE `lang` `lang` VARCHAR( 255 ) NULL DEFAULT NULL ,
     103CHANGE `text` `content` LONGTEXT NOT NULL ,
     104ADD `users` VARCHAR( 255 ) NULL DEFAULT NULL ,
     105ADD `groups` VARCHAR( 255 ) NULL DEFAULT NULL ,
     106ADD `permalink` VARCHAR( 64 ) NULL DEFAULT NULL;';
     107  pwg_query($query);
     108
     109  $query = '
     110SELECT id, pos, title, lang
     111FROM '.$prefixeTable.'additionalpages
     112ORDER BY pos ASC, id ASC
     113;';
     114  $result = pwg_query($query);
     115  while ($row = mysql_fetch_assoc($result))
     116  {
     117    $title = $row['title'];
     118    $authorized_users = 'NULL';
     119    $authorized_groups = 'NULL';
     120
     121    if (strpos($title , '/user_id='))
     122    {
     123      $array = explode('/user_id=' , $title);
     124      $title = $array[0];
     125      $authorized_users = '"'.$array[1].'"';
     126    }
     127    if (strpos($title , '/group_id='))
     128    {
     129      $array = explode('/group_id=' , $title);
     130      $title = $array[0];
     131      $authorized_groups = '"'.$array[1].'"';
     132    }
     133
     134    $position = $row['pos'];
     135    if ($row['pos'] === '0')
     136      $position = '-1';
     137    elseif (empty($row['pos']))
     138      $position = '0';
     139
     140    $language = $row['lang'] != 'ALL' ? '"'.$row['lang'].'"' : 'NULL';
     141
     142    $query = '
     143UPDATE '.$prefixeTable.'additionalpages
     144  SET title = "'.addslashes($title).'",
     145      pos = '.$position.',
     146      lang = '.$language.',
     147      users = '.$authorized_users.',
     148      groups = '.$authorized_groups.'
     149  WHERE id = '.$row['id'].'
     150;';
     151    pwg_query($query);
     152  }
     153
     154  $old_conf = explode ("," , $conf['additional_pages']);
     155
     156  $new_conf = array(
     157    'show_menu' => @($old_conf[1] == 'on'),
     158    'show_home' => @($old_conf[2] == 'on'),
     159    'redirect' => @($old_conf[4] == 'on'),
     160    'group_perm' => @($old_conf[6] == 'on'),
     161    'user_perm' => @($old_conf[7] == 'on'),
     162    'homepage' => null,
     163    );
     164
     165  $languages = explode('/', $old_conf[0]);
     166  $new_conf['languages'] = array();
     167  foreach($languages as $language)
     168  {
     169    $array = explode(':', $language);
     170    if (!isset($array[1])) $new_conf['languages']['default'] = $array[0];
     171    else $new_conf['languages'][$array[0]] = $array[1];
     172  }
     173
     174  $query = '
     175UPDATE '.CONFIG_TABLE.'
     176  SET value = "'.addslashes(serialize($new_conf)).'"
     177  WHERE param = "additional_pages"
     178;';
     179  pwg_query($query);
     180}
     181
    80182?>
Note: See TracChangeset for help on using the changeset viewer.