Changeset 9350


Ignore:
Timestamp:
02/22/11 15:50:46 (9 years ago)
Author:
patdenice
Message:

Extended description now work on page title.
Language restriction is now optionnal.

Location:
extensions/AdditionalPages
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • extensions/AdditionalPages/additional_page.php

    r9345 r9350  
    2929$identifier = $page['ap_homepage'] ? $conf['AP']['homepage'] : $tokens[1]; 
    3030 
    31 if (function_exists('get_extended_desc')) 
    32   add_event_handler('AP_render_content', 'get_extended_desc'); 
    33  
    3431// Retrieve page data 
    35 $query = 'SELECT id, title , content, users, groups, level, permalink, standalone 
     32$query = 'SELECT id, title, lang, content, users, groups, level, permalink, standalone 
    3633FROM ' . ADD_PAGES_TABLE . ' 
    3734'; 
     
    5855if (!is_admin() or (!is_admin() xor $page['ap_homepage'])) 
    5956{ 
     57  // authorized language 
     58  if (!empty($row['lang']) and $row['lang'] != $user['language']) 
     59  { 
     60    if ($page['ap_homepage'] and check_random_index_redirect()) return; 
     61    page_forbidden(l10n('You are not authorized to access the requested page'), make_index_url()); 
     62  } 
     63 
    6064  // authorized level 
    6165  if ($user['level'] < $row['level']) 
    6266  { 
    6367    if ($page['ap_homepage'] and check_random_index_redirect()) return; 
    64     page_forbidden(l10n('You are not authorized to access the requested page')); 
     68    page_forbidden(l10n('You are not authorized to access the requested page'), make_index_url()); 
    6569  } 
    6670 
     
    7276    { 
    7377      if ($page['ap_homepage'] and check_random_index_redirect()) return; 
    74       page_forbidden(l10n('You are not authorized to access the requested page')); 
     78      page_forbidden(l10n('You are not authorized to access the requested page'), make_index_url()); 
    7579    } 
    7680  } 
     
    8892    { 
    8993      if ($page['ap_homepage'] and check_random_index_redirect()) return; 
    90       page_forbidden(l10n('You are not authorized to access the requested page')); 
     94      page_forbidden(l10n('You are not authorized to access the requested page'), make_index_url()); 
    9195    } 
    9296  } 
     
    106110  'id' => $row['id'], 
    107111  'permalink' => @$row['permalink'], 
    108   'title' => trigger_event('AP_render_content', $row['title']), 
     112  'title' => trigger_event('AP_render_title', $row['title']), 
    109113  'content' => trigger_event('AP_render_content', $row['content']), 
    110114); 
  • extensions/AdditionalPages/admin/add_page.inc.php

    r9323 r9350  
    1313    'title'      => '', 
    1414    'permalink'  => '', 
     15    'lang'       => 'ALL', 
    1516    'homepage'   => false, 
    1617    'standalone' => false, 
     
    5152  } 
    5253 
    53   $language = $_POST['lang'] != 'ALL' ? '"'.$_POST['lang'].'"' : 'NULL'; 
     54  $language = (empty($_POST['lang']) or $_POST['lang'] == 'ALL') ? 'NULL' : '"'.$_POST['lang'].'"'; 
    5455  $group_access = !empty($_POST['groups']) ? '"'.implode(',', $_POST['groups']).'"' : 'NULL'; 
    5556  $standalone = isset($_POST['standalone']) ? '"true"' : '"false"'; 
     
    114115    mkgetdir($conf['local_data_dir'].'/additional_pages_backup', MKGETDIR_PROTECT_HTACCESS&~MKGETDIR_DIE_ON_ERROR); 
    115116    $sav_file = @fopen($conf['local_data_dir'].'/additional_pages_backup/' . $edited_page['id'] . '.txt', "w"); 
    116     @fwrite($sav_file, "Title: ".$_POST['title']."\nPermalink: ".$_POST['permalink']."\nLanguage: ".$_POST['lang']."\n\n" . $_POST['ap_content']); 
     117    @fwrite($sav_file, "Title: ".stripslashes($_POST['title'])."\nPermalink: ".stripslashes($_POST['permalink'])."\n\n".stripslashes($_POST['ap_content'])); 
    117118    @fclose($sav_file); 
    118119 
     
    127128  $edited_page['title'] = stripslashes($_POST['title']); 
    128129  $edited_page['permalink'] = stripslashes($_POST['permalink']); 
    129   $edited_page['lang'] = $_POST['lang']; 
    130130  $edited_page['content'] = stripslashes($_POST['ap_content']); 
     131  $edited_page['lang'] = !empty($_POST['lang']) ? $_POST['lang'] : 'ALL'; 
    131132  $edited_page['groups'] = !empty($_POST['groups']) ? $_POST['groups'] : array(); 
    132133  $edited_page['users'] = !empty($_POST['users']) ? $_POST['users'] :  array(); 
     
    137138 
    138139// Language options 
    139 $options['ALL'] = l10n('ap_all_lang'); 
    140 $selected = 'ALL'; 
    141 foreach (get_languages() as $language_code => $language_name) 
    142 { 
    143   $options[$language_code] = $language_name; 
    144   if (isset($edited_page['lang']) and $edited_page['lang'] == $language_code) 
    145   { 
    146     $selected = $language_code; 
    147   } 
    148 } 
    149 $template->assign('lang', array( 
    150   'OPTIONS' => $options, 
    151   'SELECTED' => $selected)); 
     140if ($conf['AP']['language_perm']) 
     141{ 
     142  $languages = get_languages(); 
     143  $options = array('ALL' => l10n('ap_all_lang')); 
     144  foreach ($languages as $language_code => $language_name) 
     145  { 
     146    $options[$language_code] = $language_name; 
     147  } 
     148  $template->assign(array( 
     149    'lang' => $options, 
     150    'selected_lang' => $edited_page['lang'], 
     151    ) 
     152  ); 
     153} 
    152154 
    153155// Groups options 
  • extensions/AdditionalPages/admin/config.inc.php

    r9345 r9350  
    2525    pwg_query('UPDATE '.ADD_PAGES_TABLE.' SET groups = NULL;'); 
    2626  } 
     27  if ($conf['AP']['language_perm'] and !isset($_POST['language_perm'])) 
     28  { 
     29    pwg_query('UPDATE '.ADD_PAGES_TABLE.' SET lang = NULL;'); 
     30  } 
    2731 
    28   $params = array('show_home', 'group_perm', 'user_perm', 'level_perm'); 
     32  $params = array('show_home', 'group_perm', 'user_perm', 'level_perm', 'language_perm'); 
    2933 
    3034  foreach ($params as $param) 
  • extensions/AdditionalPages/admin/edit_page.inc.php

    r9323 r9350  
    3434$edited_page['groups'] = !empty($edited_page['groups']) ? explode(',', $edited_page['groups']) : array(); 
    3535$edited_page['homepage'] = $conf['AP']['homepage'] == $edited_page['id']; 
    36 $edited_page['standalone'] = ($edited_page['standalone'] == 'true'); 
     36$edited_page['standalone'] = $edited_page['standalone'] == 'true'; 
    3737 
    3838$template->assign('delete', true); 
  • extensions/AdditionalPages/admin/manage.inc.php

    r9323 r9350  
    2929} 
    3030 
     31if (defined('EXTENDED_DESC_PATH')) 
     32{ 
     33  add_event_handler('AP_render_title', 'get_user_language_desc'); 
     34} 
     35 
    3136$languages = get_languages(); 
    3237 
     
    4348  $row['U_DELETE'] = PHPWG_ROOT_PATH.'admin.php?page=plugin&amp;section='.AP_DIR.'%2Fadmin%2Fadmin.php&amp;tab=edit_page&amp;edit='.$row['id'].'&amp;delete='; 
    4449 
     50  $row['title'] = trigger_event('AP_render_title', $row['title']); 
    4551  $row['language'] = @$languages[$row['lang']]; 
    4652 
  • extensions/AdditionalPages/admin/template/add_page.tpl

    r9312 r9350  
    4343    </li> 
    4444 
     45    {if isset($lang)} 
    4546    <li> 
    4647      <span class="property"> 
    4748        <label for="lang">{'ap_page_lang'|@translate}</label> 
    4849      </span> 
    49       {html_options name=lang id=lang options=$lang.OPTIONS selected=$lang.SELECTED} 
     50      {html_options name=lang id=lang options=$lang selected=$selected_lang} 
    5051    </li> 
     52    {/if} 
    5153 
    5254    <li style="margin-top:15px;"> 
  • extensions/AdditionalPages/admin/template/config.tpl

    r9345 r9350  
    5656      </label> 
    5757    </li> 
     58 
     59    <li> 
     60      <label> 
     61        <span class="property">{'ap_language_perm'|@translate}</span> 
     62        <input type="checkbox" name="language_perm" id="language_perm" value="on" {if $ap_conf.language_perm}checked="checked"{/if}/> 
     63      </label> 
     64    </li> 
    5865  </ul> 
    5966</fieldset> 
  • extensions/AdditionalPages/admin/upgrade.inc.php

    r9323 r9350  
    133133} 
    134134 
     135if (!isset($conf['AP']['language_perm'])) 
     136{ 
     137  $query = ' 
     138SELECT id 
     139FROM '.$prefixeTable.'additionalpages 
     140WHERE lang IS NOT NULL 
     141;'; 
     142  $ids = array_from_query($query, 'id'); 
     143 
     144  $conf['AP']['language_perm'] = !empty($ids); 
     145 
     146  conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($conf['AP'])));   
     147} 
     148 
    135149?> 
  • extensions/AdditionalPages/language/ar_SA/plugin.lang.php

    r9310 r9350  
    4646/*TODO*/$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
    4747/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
     48/*TODO*/$lang['ap_language_perm'] = 'by language'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/language/cs_CZ/plugin.lang.php

    r9310 r9350  
    4646/*TODO*/$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
    4747/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
     48/*TODO*/$lang['ap_language_perm'] = 'by language'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/language/de_DE/plugin.lang.php

    r9310 r9350  
    4646/*TODO*/$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
    4747/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
     48/*TODO*/$lang['ap_language_perm'] = 'by language'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/language/en_UK/plugin.lang.php

    r9310 r9350  
    4646$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
    4747$lang['ap_level_perm'] = 'by privacy level'; 
     48$lang['ap_language_perm'] = 'by language'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/language/es_ES/plugin.lang.php

    r9320 r9350  
    4646$lang['ap_permalink_already_used'] = 'El enlace permanente% s ya está siendo utilizado por la página% s'; 
    4747$lang['ap_level_perm'] = 'por nivel de confidencialidad'; 
     48/*TODO*/$lang['ap_language_perm'] = 'by language'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/language/fr_FR/plugin.lang.php

    r9310 r9350  
    4646$lang['ap_permalink_already_used'] = 'Le lien permanent %s est déja utilisé par la page %s'; 
    4747$lang['ap_level_perm'] = 'par niveau de confidentialité'; 
     48$lang['ap_language_perm'] = 'par langue'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/language/hu_HU/plugin.lang.php

    r9310 r9350  
    4646/*TODO*/$lang['ap_permalink_already_used'] = 'Permalink %s is already used by page %s'; 
    4747/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
     48/*TODO*/$lang['ap_language_perm'] = 'by language'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/language/it_IT/plugin.lang.php

    r9310 r9350  
    4646$lang['ap_permalink_already_used'] = 'Permalink %s è già utilizzato da pagina %s'; 
    4747/*TODO*/$lang['ap_level_perm'] = 'by privacy level'; 
    48  
     48/*TODO*/$lang['ap_language_perm'] = 'by language'; 
    4949 
    5050?> 
  • extensions/AdditionalPages/language/lv_LV/plugin.lang.php

    r9340 r9350  
    4646$lang['ap_permalink_already_used'] = 'Pastāvīgo saiti %s jau lieto %s lapa'; 
    4747$lang['ap_level_perm'] = 'ar konfidencialitātes līmeni'; 
     48/*TODO*/$lang['ap_language_perm'] = 'by language'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/language/nl_NL/plugin.lang.php

    r9321 r9350  
    4646$lang['ap_permalink_already_used'] = 'De permalink %s wordt al gebruikt door pagina %s'; 
    4747$lang['ap_level_perm'] = 'op privacy nivo'; 
     48/*TODO*/$lang['ap_language_perm'] = 'by language'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/language/no_NO/plugin.lang.php

    r9346 r9350  
    4646$lang['ap_permalink_already_used'] = 'Permalink %s er allerede I bruk av side %s'; 
    4747$lang['ap_level_perm'] = 'av privat nivå'; 
     48/*TODO*/$lang['ap_language_perm'] = 'by language'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/language/pl_PL/plugin.lang.php

    r9328 r9350  
    4646$lang['ap_permalink_already_used'] = 'Link permanentny %s jest już używane przez stronę %s'; 
    4747$lang['ap_level_perm'] = 'po poziomie prywatności'; 
     48/*TODO*/$lang['ap_language_perm'] = 'by language'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/language/ru_RU/plugin.lang.php

    r9318 r9350  
    4646$lang['ap_permalink_already_used'] = 'Постоянная ссылка %s уже используется страницей %s'; 
    4747$lang['ap_level_perm'] = 'по уровню доступа'; 
     48/*TODO*/$lang['ap_language_perm'] = 'by language'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/language/sk_SK/plugin.lang.php

    r9344 r9350  
    4646$lang['ap_permalink_already_used'] = 'Trvalý link %s je stále používaný stránkou %s';  
    4747$lang['ap_level_perm'] = 'pri súkromnej úrovni'; 
     48/*TODO*/$lang['ap_language_perm'] = 'by language'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/language/sv_SE/plugin.lang.php

    r9327 r9350  
    4646$lang['ap_permalink_already_used'] = 'Permalänk %s används redan av sidan %s'; 
    4747$lang['ap_level_perm'] = 'enligt säkerhets nivå'; 
     48/*TODO*/$lang['ap_language_perm'] = 'by language'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/language/tr_TR/plugin.lang.php

    r9322 r9350  
    4646$lang['ap_permalink_already_used'] = 'Kalıcı bağlantı %s zaten sayfa %s tarafından kullanılıyor'; 
    4747$lang['ap_level_perm'] = 'gizlilik seviyesine göre'; 
     48/*TODO*/$lang['ap_language_perm'] = 'by language'; 
    4849 
    4950?> 
  • extensions/AdditionalPages/main.inc.php

    r9345 r9350  
    2020 
    2121// Need upgrade? 
    22 if (!isset($conf['AP']['level_perm'])) 
     22if (!isset($conf['AP']['language_perm'])) 
    2323  include(AP_PATH.'admin/upgrade.inc.php'); 
    2424 
     
    4343{ 
    4444  global $tokens, $conf, $page; 
     45 
     46  if (defined('EXTENDED_DESC_PATH')) 
     47  { 
     48    add_event_handler('AP_render_content', 'get_extended_desc'); 
     49    add_event_handler('AP_render_title', 'get_user_language_desc'); 
     50  } 
    4551 
    4652  $page['ap_homepage'] = (count($tokens) == 1 and empty($tokens[0])); 
     
    8591    { 
    8692      $url = make_index_url().'/page/'.(isset($row['permalink']) ? $row['permalink'] : $row['id']); 
    87       array_push($data, array('URL' => $url, 'LABEL' => $row['title'])); 
     93      array_push($data, array('URL' => $url, 'LABEL' => trigger_event('AP_render_title', $row['title']))); 
    8894    } 
    8995 
  • extensions/AdditionalPages/maintain.inc.php

    r9345 r9350  
    3939      'group_perm' => false, 
    4040      'user_perm' => false, 
     41      'language_perm' => false, 
    4142      'homepage' => null, 
    4243    ); 
Note: See TracChangeset for help on using the changeset viewer.