Changeset 9272


Ignore:
Timestamp:
02/18/11 11:53:06 (9 years ago)
Author:
patdenice
Message:

New functionalities

Location:
extensions/AdditionalPages
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • extensions/AdditionalPages/additional_page.php

    r9270 r9272  
    66 
    77$page['section'] = 'additional_page'; 
    8 $identifier = $page['is_homepage'] ? $conf['additional_pages']['homepage'] : $tokens[1]; 
     8$identifier = $page['ap_homepage'] ? $conf['additional_pages']['homepage'] : $tokens[1]; 
    99 
    1010load_language('plugin.lang.php', AP_PATH); 
     
    2525if (empty($row)) 
    2626{ 
    27   if ($page['is_homepage']) return; 
     27  if ($page['ap_homepage']) return; 
    2828  page_not_found('Requested page does not exist'); 
    2929} 
    3030 
    31 if (is_numeric($identifier) and !empty($row['permalink']) and !$page['is_homepage']) 
     31if (is_numeric($identifier) and !empty($row['permalink']) and !$page['ap_homepage']) 
    3232{ 
    3333  redirect(make_index_url().'/page/' . $row['permalink']); 
     34} 
     35 
     36if (!$page['ap_homepage'] and $row['id'] == $conf['additional_pages']['homepage']) 
     37{ 
     38  redirect(make_index_url()); 
    3439} 
    3540 
     
    4853  if (!is_admin() and $conf['additional_pages']['user_perm'] and !in_array($user['status'], $authorized_users)) 
    4954  { 
    50     if ($page['is_homepage']) return; 
     55    if ($page['ap_homepage']) return; 
    5156        page_forbidden(l10n('You are not authorized to access the requested page')); 
    5257  } 
     
    6267  if (!is_admin() and $conf['additional_pages']['group_perm'] and empty($array)) 
    6368  { 
    64     if ($page['is_homepage']) return; 
     69    if ($page['ap_homepage']) return; 
    6570        page_forbidden(l10n('You are not authorized to access the requested page')); 
    6671  } 
     
    8590  ); 
    8691 
    87   if ($conf['additional_pages']['show_home']) 
     92  if ($conf['additional_pages']['show_home'] and !$page['ap_homepage']) 
    8893  { 
    8994    $template->assign('PLUGIN_INDEX_ACTIONS' , ' 
    90       <li><a href="'.make_index_url().'/categories" title="' . l10n('return to homepage') . '"> 
     95      <li><a href="'.make_index_url().'" title="' . l10n('return to homepage') . '"> 
    9196        <img src="' . $template->get_themeconf('icon_dir') . '/home.png" class="button" alt="' . l10n('home') . '"/></a> 
    9297      </li>'); 
  • extensions/AdditionalPages/admin/add_page.inc.php

    r9270 r9272  
    8383    { 
    8484      $conf['additional_pages']['homepage'] = isset($_POST['homepage']) ? $edited_page['id'] : null; 
    85       pwg_query('UPDATE '.CONFIG_TABLE.' SET value = "'.addslashes(serialize($conf['additional_pages'])).'" WHERE param = "additional_pages";'); 
     85      conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($conf['additional_pages']))); 
    8686    } 
    8787 
  • extensions/AdditionalPages/admin/admin.php

    r9270 r9272  
    1515$page_exist = array_from_query($query, 'id'); 
    1616 
    17 if (!isset($_GET['tab'])) 
     17$page['tab'] = isset($_GET['tab']) ? $_GET['tab'] : 'manage'; 
     18 
     19if (!$page_exist and $page['tab'] == 'manage') 
    1820{ 
    19   $page['tab'] = $page_exist ? 'manage' : 'add_page'; 
    20 } 
    21 else 
    22 { 
    23   $page['tab'] = $_GET['tab']; 
     21  redirect($my_base_url.'&amp;tab=add_page'); 
    2422} 
    2523 
  • extensions/AdditionalPages/admin/config.inc.php

    r9263 r9272  
    22 
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 
     4 
     5$mb_conf = @unserialize($conf['blk_menubar']); 
    46 
    57// Enregistrement de la configuration 
     
    810  $params = array('show_home', 'group_perm', 'user_perm'); 
    911 
    10   $new_conf = array(); 
    1112  foreach ($params as $param) 
    1213  { 
    13     $new_conf[$param] = isset($_POST[$param]); 
     14    $conf['additional_pages'][$param] = isset($_POST[$param]); 
    1415  } 
    1516 
    16   $new_conf['languages'] = array(); 
     17  $conf['additional_pages']['languages'] = array(); 
    1718        foreach($_POST['menu_lang'] as $language_code => $name) 
    1819  { 
    1920                if (!empty($name)) 
    20       $new_conf['languages'][$language_code] = $name; 
     21      $conf['additional_pages']['languages'][$language_code] = $name; 
    2122        } 
    2223 
    23   $new_conf['homepage'] = $conf['additional_pages']['homepage']; 
     24  conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($conf['additional_pages']))); 
    2425 
    25     $query = ' 
    26 UPDATE ' . CONFIG_TABLE . ' 
    27   SET value="'.addslashes(serialize($new_conf)).'" 
    28   WHERE param="additional_pages" 
    29   LIMIT 1'; 
    30     pwg_query($query); 
    31     array_push($page['infos'], l10n('ap_conf_saved')); 
    32     $conf['additional_pages'] = $new_conf; 
     26  if (isset($_POST['show_menu']) xor (!isset($mb_conf['mbAdditionalPages']) or $mb_conf['mbAdditionalPages'] == abs($mb_conf['mbAdditionalPages']))) 
     27  { 
     28    if (!isset($mb_conf['mbAdditionalPages'])) 
     29    { 
     30      $last = @abs(end($mb_conf)); 
     31      $mb_conf['mbAdditionalPages'] = $last + 50; 
     32    } 
     33    $mb_conf['mbAdditionalPages'] = (isset($_POST['show_menu']) ? +1 : -1) * abs($mb_conf['mbAdditionalPages']); 
     34    conf_update_param('blk_menubar', pwg_db_real_escape_string(serialize($mb_conf))); 
     35  } 
     36 
     37  array_push($page['infos'], l10n('ap_conf_saved')); 
    3338} 
    3439 
     
    4853$template->assign('ap_conf', $conf['additional_pages']); 
    4954 
     55if (!isset($mb_conf['mbAdditionalPages']) or $mb_conf['mbAdditionalPages'] == abs($mb_conf['mbAdditionalPages'])) 
     56{ 
     57  $template->assign('SHOW_MENU', true); 
     58} 
     59 
    5060$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/config.tpl')); 
    5161$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); 
  • extensions/AdditionalPages/admin/edit_page.inc.php

    r9270 r9272  
    1616  { 
    1717    $conf['additional_pages']['homepage'] = null; 
    18     pwg_query('UPDATE '.CONFIG_TABLE.' SET value = "'.addslashes(serialize($conf['additional_pages'])).'" WHERE param = "additional_pages";'); 
     18    conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($conf['additional_pages']))); 
    1919  } 
    2020  redirect($my_base_url.'&page_deleted='); 
  • extensions/AdditionalPages/admin/template/config.tpl

    r9262 r9272  
    77        <legend>{'ap_config'|@translate}</legend> 
    88        <table> 
    9                 <tr> 
    10                         <td colspan="3"><input type="checkbox" name="show_home" value="on" {if $ap_conf.show_home}checked="checked"{/if}/> {'ap_show_home'|@translate}</td> 
    11                 </tr> 
    12                 <tr> 
    13                         <td colspan="3"><br><hr><br></td> 
    14                 </tr> 
    159                <tr> 
    1610                        <td colspan="3">{'ap_perm'|@translate}</td> 
     
    2519                        <td colspan="3"><br><hr><br></td> 
    2620                </tr> 
    27                 <tr> 
     21    <tr> 
     22                        <td colspan="3"><input type="checkbox" name="show_home" value="on" {if $ap_conf.show_home}checked="checked"{/if}/> {'ap_show_home'|@translate}</td> 
     23                </tr> 
     24    <tr> 
     25                        <td colspan="3"><input type="checkbox" name="show_menu" value="on" {if isset($SHOW_MENU)}checked="checked"{/if}/> {'ap_show_menu'|@translate}</td> 
     26                </tr> 
     27                <tr class="menu_languages"> 
    2828                        <td><br>{'ap_menu_name'|@translate} : &nbsp;&nbsp;</td> 
    2929                        <td><br>{'Default'|@translate}&nbsp;&nbsp;</td> 
     
    3131                </tr> 
    3232                {foreach from=$language item=lang} 
    33                 <tr> 
     33                <tr class="menu_languages"> 
    3434                        <td></td> 
    3535                        <td>{$lang.LANGUAGE_NAME}&nbsp;&nbsp;</td> 
     
    4747        <p><a href="{$convert_bbcode.PATH}">{'ap_parse_bbcode'|@translate}</a></p> 
    4848{/if} 
     49 
     50<script type="text/javascript"> 
     51jQuery().ready( function () {ldelim} 
     52  jQuery("input[name='show_menu']").click( function() {ldelim} 
     53    if (this.checked) 
     54      jQuery('.menu_languages').show(); 
     55    else 
     56      jQuery('.menu_languages').hide(); 
     57  }); 
     58}); 
     59if (!jQuery("input[name='show_menu']").attr('checked')) 
     60  jQuery('.menu_languages').hide(); 
     61</script> 
  • extensions/AdditionalPages/admin/upgrade_from_21.php

    r9270 r9272  
    1919SELECT id, pos, title, lang 
    2020FROM '.$prefixeTable.'additionalpages 
    21 ORDER BY pos ASC, id ASC 
     21ORDER BY pos ASC 
    2222;'; 
    2323$result = pwg_query($query); 
     
    4343  $position = $row['pos']; 
    4444  if ($row['pos'] === '0') 
    45     $position = '-1'; 
     45    $position = '-100'; 
    4646  elseif (empty($row['pos'])) 
    4747    $position = '0'; 
     
    6161} 
    6262 
     63load_conf_from_db('param = "additional_pages"'); 
    6364$old_conf = explode ("," , $conf['additional_pages']); 
     65 
     66if ($old_conf[1] == 'off') 
     67{ 
     68  $mb_conf = @unserialize($conf['blk_menubar']); 
     69  if (!isset($mb_conf['mbAdditionalPages'])) 
     70  { 
     71    $last = @abs(end($mb_conf)); 
     72    $mb_conf['mbAdditionalPages'] = $last + 50; 
     73  } 
     74  $mb_conf['mbAdditionalPages'] = -1 * abs($mb_conf['mbAdditionalPages']); 
     75  conf_update_param('blk_menubar', pwg_db_real_escape_string(serialize($mb_conf))); 
     76} 
    6477 
    6578$new_conf = array( 
     
    8194$conf['additional_pages'] = $new_conf; 
    8295 
    83 $query = ' 
    84 UPDATE '.CONFIG_TABLE.' 
    85 SET value = "'.addslashes(serialize($new_conf)).'" 
    86 WHERE param = "additional_pages" 
    87 ;'; 
    88 pwg_query($query); 
     96conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($new_conf))); 
    8997 
    9098?> 
  • extensions/AdditionalPages/index_menu.php

    r9262 r9272  
    6565          (!$conf['additional_pages']['user_perm'] or empty($row['users']) or in_array($user['status'], $authorized_users)))) 
    6666        { 
     67          $url = make_index_url(); 
     68          if ($row['id'] != $conf['additional_pages']['homepage']) 
     69          { 
     70            $url .= '/page/'.(isset($row['permalink']) ? $row['permalink'] : $row['id']); 
     71          } 
    6772          array_push($data, array( 
    68             'URL' => make_index_url().'/page/'.(isset($row['permalink']) ? $row['permalink'] : $row['id']), 
     73            'URL' => $url, 
    6974            'LABEL' => $row['title'])); 
    7075        } 
  • extensions/AdditionalPages/main.inc.php

    r9262 r9272  
    3434  global $tokens, $conf, $page; 
    3535 
    36   $page['is_homepage'] = (count($tokens) == 1 and empty($tokens[0])); 
     36  $page['ap_homepage'] = (count($tokens) == 1 and empty($tokens[0])); 
    3737 
    38   if (($tokens[0] == 'page' and !empty($tokens[1])) or ($page['is_homepage'] and !is_null($conf['additional_pages']['homepage']))) 
     38  if (($tokens[0] == 'page' and !empty($tokens[1])) or ($page['ap_homepage'] and !is_null($conf['additional_pages']['homepage']))) 
    3939    include(AP_PATH . 'additional_page.php'); 
    4040 
  • extensions/AdditionalPages/maintain.inc.php

    r9270 r9272  
    1818groups VARCHAR( 255 ) NULL DEFAULT NULL , 
    1919permalink VARCHAR( 64 ) NULL DEFAULT NULL , 
    20 standalone ENUM( "true", "false" ) NOT NULL DEFAULT "false" 
     20standalone ENUM( "true", "false" ) NOT NULL DEFAULT "false" , 
    2121PRIMARY KEY (id) , 
    2222INDEX (pos) , 
     
    3535      'homepage' => null, 
    3636    ); 
     37 
    3738    $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) 
    38 VALUES ("additional_pages" , "'.addslashes(serialize($config)).'" , "Additional Pages config configuration");'; 
     39VALUES ("additional_pages" , "'.pwg_db_real_escape_string(serialize($config)).'" , "Additional Pages config configuration");'; 
    3940    pwg_query($query); 
    4041  } 
Note: See TracChangeset for help on using the changeset viewer.