Changeset 23583


Ignore:
Timestamp:
Jun 27, 2013, 12:47:39 AM (11 years ago)
Author:
plg
Message:

ability to say if elements must be added on gallery, or admin, or both

Location:
extensions/add_head_element
Files:
3 edited
2 moved

Legend:

Unmodified
Added
Removed
  • extensions/add_head_element/admin.php

    r23582 r23583  
    1313//-------------------------------------------------------- sections definitions
    1414
    15 // Gestion des onglets
    16 if (!isset($_GET['tab']))
    17     $page['tab'] = 'Management';
    18 else
    19     $page['tab'] = $_GET['tab'];
    20 
    2115$tabsheet = new tabsheet();
    22 $tabsheet->add('Management',
    23                l10n('Management'),
    24                $my_base_url.'&tab=Management');
    25 $tabsheet->select($page['tab']);
     16$tabsheet->add('Management', l10n('Management'), '');
     17$tabsheet->select('Management');
    2618$tabsheet->assign();
    2719
    28 switch ($page['tab'])
     20if (isset($conf['add_head_element_apply_on']))
    2921{
    30   case 'Management':
    31 global $template, $conf;
    32    
    33   $template->assign(
    34     'gestA',
    35     array('AHEBASE' => $conf['add_head_element'],));
     22  $conf['add_head_element_apply_on'] = explode(',', $conf['add_head_element_apply_on']);
     23}
     24else
     25{
     26  $conf['add_head_element_apply_on'] = array('gallery', 'admin');
     27}
     28
     29$template->assign(
     30  array(
     31    'AHEBASE' => $conf['add_head_element'],
     32    'gallery' => in_array('gallery', $conf['add_head_element_apply_on']),
     33    'admin' => in_array('admin', $conf['add_head_element_apply_on']),
     34    )
     35  );
    3636
    3737if (isset($_POST['submitahe']))
    38         {
     38{
    3939  conf_update_param('add_head_element', $_POST['ahe']);
     40
     41  $conf['add_head_element_apply_on'] = array();
     42 
     43  if (!empty($_POST['apply_on_gallery']))
     44  {
     45    $conf['add_head_element_apply_on'][] = 'gallery';
     46  }
     47 
     48  if (!empty($_POST['apply_on_admin']))
     49  {
     50    $conf['add_head_element_apply_on'][] = 'admin';
     51  }
     52
     53  conf_update_param('add_head_element_apply_on', implode(',', $conf['add_head_element_apply_on']));
     54 
    4055  $template->assign(
    41     'gestA',
    42     array('AHEBASE' => stripslashes($_POST['ahe']),));
    43         }
    44  break;
    45 }
     56    array(
     57      'AHEBASE' => stripslashes($_POST['ahe']),
     58      'gallery' => in_array('gallery', $conf['add_head_element_apply_on']),
     59      'admin' => in_array('admin', $conf['add_head_element_apply_on']),
     60      )
     61    );
     62}
    4663
    4764$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl'));
  • extensions/add_head_element/admin.tpl

    r23582 r23583  
     1{html_style}{literal}
     2form p {text-align:left;margin:0 0 1.5em 1.5em;line-height:20px;}
     3{/literal}{/html_style}
     4
    15<div class="titrePage">
    26  <h2>{'ahe_h2'|@translate}</h2>
    37</div>
    4 <div id="configContent">
    5 {if isset ($gestA)}
    6         <form method="post" >
    7          <fieldset id="mainConf">
    8                         <span class="property">
    9                                 <label for="aheperso">{'ahe_perso'|@translate}</label><br><br>
    10                         </span>
    11                         <textarea rows="5" cols="50" class="description" name="ahe" id="ahe">{$gestA.AHEBASE}</textarea>
     8
     9<form method="post">
     10  <p>
     11    <strong>{'ahe_perso'|@translate}</strong><br>
     12    <textarea rows="5" cols="50" class="description" name="ahe" id="ahe">{$AHEBASE}</textarea>
     13  </p>
     14
     15  <p>
     16    <strong>{'Apply on'|@translate}</strong><br>
     17    <label><input type="checkbox" name="apply_on_gallery"{if $gallery} checked="checked"{/if}> {'Gallery'|@translate}</label>
     18    <label><input type="checkbox" name="apply_on_admin"{if $admin} checked="checked"{/if}> {'Administration'|@translate}</label>
     19  </p>
     20
    1221  <p>
    1322    <input class="submit" type="submit" name="submitahe" value="{'Submit'|@translate}">
    14     <input class="submit" type="reset" name="reset" value="{'Reset'|@translate}">
    1523  </p>
    16         </form>
    17 {/if}
    18 </div>
     24</form>
  • extensions/add_head_element/language/en_UK/plugin.lang.php

    r12496 r23583  
    44//Tab Management
    55$lang['Management'] = 'Management';
    6 $lang['ahe_perso'] = 'add < head > element';
    7 
     6$lang['ahe_perso'] = 'Add elements in < head > HTML section';
     7$lang['Apply on'] = 'Apply on';
     8$lang['Gallery'] = 'Gallery';
    89?>
  • extensions/add_head_element/language/fr_FR/plugin.lang.php

    r12496 r23583  
    55$lang['Management'] = 'Gestion';
    66$lang['ahe_perso'] = 'Ajout d\'éléments dans les balise < head >';
    7 
    8 
     7$lang['Apply on'] = 'Appliquer sur';
     8$lang['Gallery'] = 'Galerie';
    99?>
  • extensions/add_head_element/main.inc.php

    r14969 r23583  
    1919function AHE_admin_menu($menu)
    2020{
    21   array_push($menu, array(
    22         'NAME' => 'Add < head > element',
    23     'URL' => get_admin_plugin_menu_link(AHE_PATH . 'admin/admin.php')));
     21  array_push(
     22    $menu,
     23    array(
     24      'NAME' => 'Add < head > element',
     25      'URL' => get_root_url().'admin.php?page=plugin-add_head_element'
     26      )
     27    );
     28 
    2429  return $menu;
    2530}
     
    3136function AHE1()
    3237{
     38  global $template,$conf;
    3339
    34 global $template,$conf;
     40  if (isset($conf['add_head_element_apply_on']))
     41  {
     42    if (!is_array($conf['add_head_element_apply_on']))
     43    {
     44      $conf['add_head_element_apply_on'] = explode(',', $conf['add_head_element_apply_on']);
     45    }
    3546
     47    if (defined('IN_ADMIN') and IN_ADMIN)
     48    {
     49      // we are in the administration
     50      if (!in_array('admin', $conf['add_head_element_apply_on']))
     51      {
     52        return;
     53      }
     54    }
     55    else
     56    {
     57      // we are in the gallery
     58      if (!in_array('gallery', $conf['add_head_element_apply_on']))
     59      {
     60        return;
     61      }
     62    }
     63   
     64  }
     65 
    3666        if (!empty($conf['add_head_element']))
    3767        {
    3868    $template->append('head_elements', $conf['add_head_element']);
    3969        }
    40  }
     70}
    4171?>
Note: See TracChangeset for help on using the changeset viewer.