Changeset 11219 for extensions


Ignore:
Timestamp:
Jun 3, 2011, 6:09:08 PM (13 years ago)
Author:
mistic100
Message:

add some options, better intégration

Location:
extensions/Back2Front
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • extensions/Back2Front/Back2Front.php

    r10981 r11219  
    3232    $conf['back2front'] = explode(',',$conf['back2front']);
    3333   
    34     // calculation of width and height
    35     include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
    36    
    37     if (!empty($verso['width']))
    38     {
    39       list(
    40         $verso['scaled_width'],
    41         $verso['scaled_height']
    42         ) = get_picture_size(
    43           $verso['width'],
    44           $verso['height'],
    45           @$user['maxwidth'],
    46           @$user['maxheight']
    47         );
    48     }
    49 
    5034    /* websize picture */
    51     $template->assign(array(
    52       'VERSO_URL' => $verso['path'],
    53       'VERSO_WIDTH' => $verso['scaled_width'],
    54       'VERSO_HEIGHT' => $verso['scaled_height'],
    55       'b2f_switch_mode' => $conf['back2front'][1],
    56       'b2f_transition' => $conf['back2front'][2],
    57     ));
     35    $template->assign('VERSO_URL', $verso['path']);
    5836   
    5937    /* admin link */
     
    7048      $template->assign('VERSO_HD', get_high_url($verso));
    7149    }
     50   
     51    /* link name */
     52    $conf['back2front'][4] = unserialize($conf['back2front'][4]);
     53    if (!empty($conf['back2front'][4][$user['language']]))
     54    {
     55      if (strpos($conf['back2front'][4][$user['language']], '|') !== false)
     56      {
     57        $conf['back2front'][4] = explode('|', $conf['back2front'][4][$user['language']]);
     58      }
     59      else
     60      {
     61        $conf['back2front'][4] = array($conf['back2front'][4][$user['language']], $conf['back2front'][4][$user['language']]);
     62      }
     63    }
     64    else if (!empty($conf['back2front'][4]['default']))
     65    {
     66      if (strpos($conf['back2front'][4]['default'], '|') != false)
     67      {
     68        $conf['back2front'][4] = explode('|', $conf['back2front'][4]['default']);
     69      }
     70      else
     71      {
     72        $conf['back2front'][4] = array($conf['back2front'][4]['default'], $conf['back2front'][4]['default']);
     73      }
     74    }
     75    else
     76    {
     77      $conf['back2front'][4] = array(l10n('See back'), l10n('See front'));
     78    }
    7279
    7380    /* template & output */
    74     $template->set_filenames(array('B2F_picture_content' => dirname(__FILE__).'/template/picture_content.tpl') );
    75     $template->assign('B2F_PATH', B2F_PATH);
    76    
    77     return $template->parse('B2F_picture_content', true).$content; 
     81    $template->set_filenames(array('B2F_picture_content' => dirname(__FILE__).'/template/picture_content.tpl') );   
     82    $template->assign(array(
     83      'B2F_PATH' => B2F_PATH,
     84      'b2f_switch_mode' => $conf['back2front'][1],
     85      'b2f_transition' => $conf['back2front'][2],
     86      'b2f_position' => $conf['back2front'][3],
     87      'b2f_see_back' => $conf['back2front'][4][0],
     88      'b2f_see_front' => $conf['back2front'][4][1],
     89    ));
     90   
     91    switch ($conf['back2front'][3])
     92    {
     93      case 'toolbar':
     94        $template->set_prefilter('picture', 'Back2Front_toolbar_prefilter'); 
     95        break;
     96      case 'top':
     97        return $template->parse('B2F_picture_content', true)."\n".$content;
     98        break;
     99      case 'bottom':
     100        return $content."\n".$template->parse('B2F_picture_content', true);
     101        break;
     102    }   
    78103  }
    79   else
    80   {
    81     return $content;
    82   }
     104 
     105  return $content;
     106}
     107
     108function Back2Front_toolbar_prefilter($content, &$smarty)
     109{
     110  $search = '{/if}{/strip}{*caddie management END*}';
     111  $replacement = $search."\n".file_get_contents(B2F_PATH.'template/picture_content.tpl');
     112  return str_replace($search, $replacement, $content);
    83113}
    84114
     
    87117 * Add field on picture modify page
    88118 */
    89 function Back2Front_picture_modify($menu)
     119function Back2Front_picture_modify()
    90120{
    91121  global $page, $template, $conf;
    92122 
    93   if ($page['page'] != 'picture_modify') return $menu;
     123  if ($page['page'] != 'picture_modify') return;
    94124  $conf['back2front'] = explode(',',$conf['back2front']);
    95125 
     
    267297 
    268298  $template->set_prefilter('picture_modify', 'Back2front_picture_modify_prefilter');
    269  
    270   return $menu;
    271299}
    272300
  • extensions/Back2Front/admin.php

    r10981 r11219  
    66$conf['back2front'] = explode(',', $conf['back2front']);
    77
     8include_once(B2F_PATH.'functions.inc.php');
     9
    810// Enregistrement de la configuration
    911if (isset($_POST['submit']))
     
    1214    $conf['back2front'][0],
    1315    $_POST['switch_mode'],
    14     $_POST['transition']
     16    $_POST['transition'],
     17    $_POST['position'],
     18    serialize(stripslashes_deep(str_replace(array("'",'"',','), null, $_POST['link_name']))),
    1519  );
    1620       
     
    1923}
    2024
     25// Gestion des langues pour le bloc menu
     26$conf['back2front'][4] = unserialize($conf['back2front'][4]);
     27$template->append('link_name', array(
     28  'LANGUAGE_NAME' => l10n('Default'),
     29  'LANGUAGE_CODE' => 'default',
     30  'VALUE' => @$conf['back2front'][4]['default'],
     31  )
     32);
     33foreach (get_languages() as $language_code => $language_name)
     34{
     35        $template->append('link_name', array(
     36    'LANGUAGE_NAME' => $language_name,
     37    'LANGUAGE_CODE' => $language_code,
     38    'VALUE' => isset($conf['back2front'][4][$language_code]) ? $conf['back2front'][4][$language_code] : '',
     39    )
     40  );
     41}
     42
    2143$template->assign(array(
     44  'B2F_PATH' => B2F_PATH,
    2245        'SWITCH_MODE' => $conf['back2front'][1],
    2346        'TRANSITION' => $conf['back2front'][2],
     47  'POSITION' => $conf['back2front'][3],
    2448));
    2549       
  • extensions/Back2Front/functions.inc.php

    r10981 r11219  
    5151}
    5252
     53if (!function_exists('stripslashes_deep'))
     54{
     55  function stripslashes_deep($value)
     56  {
     57    return is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
     58  }
     59}
     60
    5361?>
  • extensions/Back2Front/main.inc.php

    r10852 r11219  
    2626if (script_basename() == 'admin')
    2727{
    28   add_event_handler('get_admin_plugin_menu_links', 'Back2Front_picture_modify');
    29   // add_event_handler('loc_begin_admin_page', 'Back2Front_picture_modify'); /* for Piwigo 2.2.2 */
     28  add_event_handler('loc_begin_admin_page', 'Back2Front_picture_modify');
    3029 
    3130        add_event_handler('get_admin_plugin_menu_links', 'Back2Front_admin_menu');
  • extensions/Back2Front/maintain.inc.php

    r10852 r11219  
    3939}
    4040
     41function plugin_activate()
     42{
     43  global $conf;
     44
     45  if (!isset($conf['back2front'])) {
     46    pwg_query("INSERT INTO `" . CONFIG_TABLE . "`
     47      VALUES ('back2front', '".$versos_cat['id'].",click,none', 'Configuration for Back2Front plugin');");
     48  } else {
     49    $conf['back2front'] = explode(',', $conf['back2front']);
     50    if (!isset($conf['back2front'][3])) {
     51      $conf['back2front'][3] = 'top';
     52      $conf['back2front'][4] = serialize(array('default'=>null));
     53      conf_update_param('back2front', implode (',', $conf['back2front']));
     54    }
     55  }
     56}
     57
     58
    4159function plugin_uninstall() {
    4260        global $conf, $prefixeTable;
  • extensions/Back2Front/template/admin.tpl

    r10852 r11219  
     1{combine_css path=$B2F_PATH|@cat:"template/style.css"}
     2{if $themeconf.id == roma}<style type="text/css">.lang_help {ldelim} background-color:#464646; }</style>{/if}
     3
     4{footer_script require='jquery'}{literal}
     5jQuery().ready( function () {
     6  jQuery('select[name="lang_desc_select"]').change(function () {
     7    jQuery('[id^="link_name"]').hide();
     8    jQuery("#link_name_"+this.options[this.selectedIndex].value).show();
     9  });
     10  jQuery('[id^="link_name_"]').keyup(function () {
     11    arr = jQuery(this).attr("id").split("link_name_");
     12    id = arr[1];
     13    opt = jQuery('select[name="lang_desc_select"] option[id="opt_'+id+'"]');
     14    if (this.value != '')
     15      opt.html(opt.html().replace("\u2718", "\u2714"));
     16    else
     17      opt.html(opt.html().replace("\u2714", "\u2718"));
     18  });
     19});
     20
     21jQuery('.lang_help').tipTip();
     22{/literal}{/footer_script}
     23
    124<div class="titrePage">
    225        <h2>Back2Front</h2>
     
    730                <legend>{'Display'|@translate}</legend>   
    831                <ul>                   
     32      <li>
     33        <span class="property">{'Link position'|@translate}</span>
     34        <label><input type="radio" name="position" value="top" {if $POSITION == 'top'}checked="checked"{/if}/> {'Top'|@translate}</label>
     35        <label><input type="radio" name="position" value="bottom" {if $POSITION == 'bottom'}checked="checked"{/if}/> {'Bottom'|@translate}</label>
     36        <label><input type="radio" name="position" value="toolbar" {if $POSITION == 'toolbar'}checked="checked"{/if}/> {'Toolbar'|@translate}</label>
     37      </li>
    938                        <li>
    1039                                <span class="property">{'Switch mode'|@translate}</span>
     
    1645                                <label><input type="radio" name="transition" value="none" {if $TRANSITION == 'none'}checked="checked"{/if}/> {'None'|@translate}</label>
    1746                                <label><input type="radio" name="transition" value="fade" {if $TRANSITION == 'fade'}checked="checked"{/if}/> {'Fade'|@translate}</label>
    18                         </li>           
     47                        </li>   
     48
     49      <li>
     50        <span class="property">{'Link name'|@translate}</span>
     51        <select name="lang_desc_select">
     52          {foreach from=$link_name item=lang}
     53            <option value="{$lang.LANGUAGE_CODE}" id="opt_{$lang.LANGUAGE_CODE}">{if empty($lang.VALUE)}&#x2718;{else}&#x2714;{/if} &nbsp;{$lang.LANGUAGE_NAME}</option>
     54          {/foreach}
     55        </select>
     56        {foreach from=$link_name item=lang}
     57          <input type="text" size="30" name="link_name[{$lang.LANGUAGE_CODE}]" id="link_name_{$lang.LANGUAGE_CODE}" value="{$lang.VALUE}" style="{if $lang.LANGUAGE_CODE != 'default'}display:none; {/if}margin-left:10px;">
     58        {/foreach}
     59
     60        <a class="lang_help" title="{'Seperate the two labels with the | symbol. Leave blank to use default translation.'|@translate}">i</a>
     61      </li>     
    1962                </ul>
    2063        </fieldset>
  • extensions/Back2Front/template/picture_content.tpl

    r10852 r11219  
    11{combine_css path=$B2F_PATH|@cat:"template/style.css"}
     2{combine_script id="jquery" load="header" path = "themes/default/js/jquery.min.js"}
    23
    34{footer_script require="jquery"}
     
    1617        opacity:0
    1718      }, 400, function() {ldelim}
     19        jQuery(this).attr({ldelim}
     20          src: '{$VERSO_URL}',
     21          style: 'max-width:{$WIDTH_IMG}px;max-height:{$HEIGHT_IMG}px;',
     22        });
    1823        jQuery(this).animate({ldelim}
    19           width:'{$VERSO_WIDTH}px',
    20           height:'{$VERSO_HEIGHT}px'
    21         }, 200, function() {ldelim}
    22             jQuery(this).attr('src', '{$VERSO_URL}');
    23             jQuery(this).animate({ldelim}
    24               opacity:1
    25             }, 400);
    26         });
     24          opacity:1
     25        }, 400);
    2726      });
    2827    {else}
    2928      jQuery('img[alt="{$ALT_IMG}"]').attr({ldelim}
    3029        src: '{$VERSO_URL}',
    31         style: 'width:{$VERSO_WIDTH}px;height:{$VERSO_HEIGHT}px;',
     30        style: 'max-width:{$WIDTH_IMG}px;max-height:{$HEIGHT_IMG}px;',
    3231      });
    3332    {/if}
     
    4241   
    4342      /* B2F link content */
    44       jQuery(this).html('<img src="{$B2F_PATH}template/rotate_2.png"/> {'See front'|@translate}');
     43      jQuery(this).html('<img src="{$B2F_PATH}template/rotate_2.png"/> {$b2f_see_front}');
    4544      jQuery(this).attr('rel', 'back');
    4645    {/if}
     
    5251{/if}
    5352
     53      /* picture switch */
    5454    {if $b2f_transition == 'fade'}
    5555      jQuery('img[alt="{$ALT_IMG}"]').animate({ldelim}
    5656        opacity:0
    5757      }, 400, function() {ldelim}
     58        jQuery(this).attr({ldelim}
     59          src: '{$SRC_IMG}',
     60          style: 'width:{$WIDTH_IMG}px;height:{$HEIGHT_IMG}px;',
     61        });
    5862        jQuery(this).animate({ldelim}
    59           width:'{$WIDTH_IMG}px',
    60           height:'{$HEIGHT_IMG}px'
    61         }, 200, function() {ldelim}
    62             jQuery(this).attr('src', '{$SRC_IMG}');
    63             jQuery(this).animate({ldelim}
    64               opacity:1
    65             }, 400);
    66         });
     63          opacity:1
     64        }, 400);
    6765      });
    6866    {else}
     
    7472     
    7573    {if $b2f_switch_mode == 'click'}
     74      /* hd link */
    7675      {if isset($high.U_HIGH)}
    7776      jQuery('img[alt="{$ALT_IMG}"]').parent().attr({ldelim}
     
    8079      {/if}
    8180     
    82       jQuery(this).html('<img src="{$B2F_PATH}template/rotate_1.png"/> {'See back'|@translate}');
     81      /* B2F link content */
     82      jQuery(this).html('<img src="{$B2F_PATH}template/rotate_1.png"/> {$b2f_see_back}');
    8383      jQuery(this).attr('rel', 'front');
    8484    {/if}
     
    9494{/footer_script}
    9595
    96 <img src="{$VERSO_URL}" style="display:none;"> {* <!-- force preload the verso --> *}
     96<img src="{$VERSO_URL}" style="display:none;"/> {* <!-- force preload the verso --> *}
    9797
    98 <a class="reverse" rel="front" name="verso-link" {if $b2f_switch_mode == 'hover'}href="javascript:phpWGOpenWindow('{$VERSO_HD}','{$high.UUID}','scrollbars=yes,toolbar=no,status=no,resizable=yes')"{/if}>
    99   <img src="{$B2F_PATH}template/rotate_1.png"/> {'See back'|@translate}
     98{if $b2f_position != 'toolbar'}<div>{/if}
     99<a class="reverse" rel="front" {if $b2f_position == 'toolbar'}style="border:none !important;"{/if} {if $b2f_switch_mode == 'hover'}href="javascript:phpWGOpenWindow('{$VERSO_HD}','{$high.UUID}','scrollbars=yes,toolbar=no,status=no,resizable=yes')"{/if}>
     100  <img src="{$B2F_PATH}template/rotate_1.png"/> {$b2f_see_back}
    100101</a>
    101 <br/>
     102{if $b2f_position != 'toolbar'}</div>{/if}
  • extensions/Back2Front/template/style.css

    r10852 r11219  
    55  margin-bottom:10px;
    66  font-size:15px;
    7   font-style:italic;   
    8   height:1em;
     7  font-style:italic; 
    98}
    109a.reverse img {
    11   margin:0 !important;
    1210  vertical-align:top;
    13   border:none !important;
    1411}
     12.lang_help {
     13  display:inline-block;
     14  width:16px;
     15  text-align:center;
     16  vertical-align:middle;
     17  font-style:italic;
     18  font-family:"Georgia",serif;
     19  background-color:#999;
     20  margin-left:15px;
     21  color:#fff;
     22  font-size:0.9em;
     23  line-height:1.4em;
     24  border-radius:7px;
     25  -moz-border-radius:7px;
     26}
     27.lang_help:hover {
     28  background-color:#333;
     29  border:none;
     30  color:#fff;
     31}
Note: See TracChangeset for help on using the changeset viewer.