Changeset 21212


Ignore:
Timestamp:
Mar 5, 2013, 4:53:11 PM (8 years ago)
Author:
mistic100
Message:

update for Piwigo 2.5, multisize is disabled for photos with verso

Location:
extensions/Back2Front
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/Back2Front/Back2Front.php

    r14963 r21212  
    77 * Add verso link on picture page
    88 */
    9 function Back2Front_picture_content($content, $image)
     9function Back2Front_picture_content($content, $element_info)
    1010{
    1111  global $template, $user, $conf;
     
    1313  /* search for a verso picture */
    1414  $query = "
    15     SELECT
    16       i.id,
    17       i.path,
    18       i.has_high,
    19       i.width,
    20       i.height
     15    SELECT i.*
    2116    FROM ".IMAGES_TABLE." as i
    2217      INNER JOIN ".B2F_TABLE." as v
    2318      ON i.id = v.verso_id
    24     WHERE
    25       v.image_id = ".$image['id']."
     19      AND v.image_id = ".$element_info['id']."
    2620  ;";
    2721  $result = pwg_query($query);
     
    3125    $verso = pwg_db_fetch_assoc($result);
    3226    $conf['back2front'] = explode(',',$conf['back2front']);
     27    $deriv_type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']);
     28   
     29    $verso['src_image'] = new SrcImage($verso);
     30    $verso['derivatives'] = DerivativeImage::get_all($verso['src_image']);
     31    $verso['element_path'] = get_element_path($verso);
     32    $verso['selected_derivative'] = $verso['derivatives'][$deriv_type];
    3333   
    3434    /* websize picture */
    3535    $template->assign(array(
    3636      'B2F_PATH' => B2F_PATH,
    37       'VERSO_URL' => $verso['path'],
     37      'verso' => $verso,
    3838      ));
    3939   
     
    4141    if (is_admin())
    4242    {
    43       $template->assign('VERSO_U_ADMIN', get_root_url().'admin.php?page=picture_modify&image_id='.$verso['id']);
     43      $template->assign('VERSO_U_ADMIN', get_root_url().'admin.php?page=photo-'.$verso['id']);
    4444      $template->set_filename('B2F_admin_button', dirname(__FILE__).'/template/admin_button.tpl');
    4545      $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('B2F_admin_button', true));
    46     }
    47 
    48     /* high picture */
    49     if ($verso['has_high'])
    50     {
    51       $template->assign('VERSO_HD', get_high_url($verso));
    5246    }
    5347   
     
    8074      $conf['back2front'][4] = array(l10n('See back'), l10n('See front'));
    8175    }
     76   
     77    if ($conf['back2front'][2] == 'fade' and $conf['back2front'][3] ==  'bottom')
     78    {
     79      $conf['back2front'][3] = 'top';
     80    }
     81   
    8282
    8383    /* template & output */
     
    116116  global $page, $template, $conf;
    117117 
    118   if ($page['page'] != 'picture_modify') return;
     118  if ($page['page'] != 'photo') return;
     119  if (isset($_GET['tab']) && $_GET['tab']!='properties') return;
     120 
     121 
    119122  $conf['back2front'] = explode(',',$conf['back2front']);
    120123 
     
    164167      {
    165168          $recto_current_verso['id'] = $all_recto_verso[$_POST['b2f_front_id']];
    166           $recto_current_verso['link'] = get_root_url().'admin.php?page=picture_modify&image_id='.$recto_current_verso['id'];
     169          $recto_current_verso['link'] = get_root_url().'admin.php?page=photo-'.$recto_current_verso['id'];
    167170          array_push(
    168171            $page['errors'],
     
    236239       
    237240        $verso['id'] = $_POST['b2f_front_id'];
    238         $verso['link'] = get_root_url().'admin.php?page=picture_modify&image_id='.$verso['id'];
     241        $verso['link'] = get_root_url().'admin.php?page=photo-'.$verso['id'];
    239242        array_push($page['infos'], l10n_args(get_l10n_args('This picture is now the backside of the picture n°%s', '<a href="'.$verso['link'].'">'.$verso['id'].'</a>')));
    240243      }
     
    300303        $template->assign(array(
    301304          'B2F_VERSO_ID' => $item['verso_id'],
    302           'B2F_VERSO_URL' => get_root_url().'admin.php?page=picture_modify&amp;image_id='.$item['verso_id'],
     305          'B2F_VERSO_URL' => get_root_url().'admin.php?page=photo-'.$item['verso_id'],
    303306        ));
    304307      }
     
    312315function Back2front_picture_modify_prefilter($content, &$smarty)
    313316{
    314   $search = '<form id="associations"';
    315   $replacement = file_get_contents(B2F_PATH.'template/picture_modify.tpl')."\n".$search;
     317  $search = '</form>';
     318  $replacement = $search."\n\n".file_get_contents(B2F_PATH.'template/picture_modify.tpl');
    316319  return str_replace($search, $replacement, $content);
    317320}
     
    321324 * Add mark on thumbnails list
    322325 */
    323 function Back2Front_thumbnails($tpl_thumbnails_var, $pictures)
     326function Back2Front_thumbnails($tpl_thumbnails_var)
    324327{
    325   global $conf;
     328  global $conf, $selection;
    326329 
    327330  $conf['back2front'] = explode(',',$conf['back2front']);
    328331  if (!$conf['back2front'][5]) return $tpl_thumbnails_var;
    329   if (empty($pictures)) return $tpl_thumbnails_var;
    330  
    331   $ids = array();
    332   foreach ($pictures as $row)
    333   {
    334     array_push($ids, $row['id']);
    335   }
     332  if (empty($tpl_thumbnails_var)) return $tpl_thumbnails_var;
    336333   
    337334  /* has the pictures a verso ? */
    338   $query = "SELECT image_id, verso_id
     335  $query = "SELECT image_id
    339336    FROM ".B2F_TABLE."
    340     WHERE image_id IN(".implode(',', $ids).");";
    341   $result = hash_from_query($query, 'image_id');
    342  
    343   $ids = array_keys($result);
     337    WHERE image_id IN(".implode(',', $selection).");";
     338  $ids = array_from_query($query, 'image_id');
     339 
     340  $root_path = get_absolute_root_url();
    344341 
    345342  foreach($tpl_thumbnails_var as &$tpl_var)
    346343  {
    347     if (in_array($tpl_var['ID'], $ids))
    348     {
    349       $tpl_var['NAME'].= ' <img class="has_verso" src="'.B2F_PATH.'template/rotate_1.png" title="'.l10n('This picture has a backside :').'"/>';
     344    if (in_array($tpl_var['id'], $ids))
     345    {
     346      $tpl_var['NAME'].= ' <img class="has_verso" src="'.$root_path.B2F_PATH.'template/rotate_1.png" title="'.l10n('This picture has a backside :').'"/>';
    350347    }
    351348  }
  • extensions/Back2Front/main.inc.php

    r12361 r21212  
    2121if (script_basename() == 'picture')
    2222{
    23   add_event_handler('render_element_content', 'Back2Front_picture_content', 99, 2);
     23  add_event_handler('render_element_content', 'Back2Front_picture_content', EVENT_HANDLER_PRIORITY_NEUTRAL+20, 2);
    2424}
    2525
    2626if (script_basename() == 'index')
    2727{
    28   add_event_handler('loc_end_index_thumbnails', 'Back2Front_thumbnails', 99, 2);
     28  add_event_handler('loc_end_index_thumbnails', 'Back2Front_thumbnails');
    2929}
    3030
  • extensions/Back2Front/template/admin_button.tpl

    r12361 r21212  
    1 {strip}<a href="{$VERSO_U_ADMIN}" title="{'Modify backside information'|@translate}" class="pwg-state-default pwg-button" rel="nofollow">
    2   <img src="{$B2F_PATH}template/rotate_edit.png"/><span class="pwg-button-text">{'edit'|@translate}</span>
    3 </a>{/strip}
     1{strip}{if isset($VERSO_U_ADMIN)}
     2        <a href="{$VERSO_U_ADMIN}" title="{'Modify backside information'|@translate}" class="pwg-state-default pwg-button" rel="nofollow">
     3                <span class="pwg-icon pwg-icon-edit"> </span><span class="pwg-button-text">{'Edit'|@translate}</span>
     4        </a>
     5{/if}{/strip}
  • extensions/Back2Front/template/picture_content.tpl

    r12363 r21212  
    11{combine_css path=$B2F_PATH|@cat:"template/style.css"}
    2 {combine_script id="jquery" load="header" path = "themes/default/js/jquery.min.js"}
     2
     3{if !$verso.selected_derivative->is_cached() && $current.selected_derivative->is_cached}
     4{combine_script id='jquery.ajaxmanager' path='themes/default/js/plugins/jquery.ajaxmanager.js' load='footer'}
     5{combine_script id='thumbnails.loader' path='themes/default/js/thumbnails.loader.js' require='jquery.ajaxmanager' load='footer'}
     6{footer_script}var error_icon = "{$ROOT_URL}{$themeconf.icon_dir}/errors_small.png"{/footer_script}
     7{/if}
     8
     9
     10{if $b2f_position != "toolbar"}<div>{/if}
     11<a class="reverse" data-what="front" rel="nofollow" class="pwg-state-default pwg-button" title="{$b2f_see_back}" {if $b2f_position == "toolbar"}style="border:none !important;"{/if}>
     12  <img src="{$ROOT_URL}{$B2F_PATH}template/rotate_1.png"/> {$b2f_see_back}
     13</a>
     14{if $b2f_position != "toolbar"}</div>{/if}
     15
     16<img {if $verso.selected_derivative->is_cached()}src="{$verso.selected_derivative->get_url()}" {$verso.selected_derivative->get_size_htm()}{else}src="{$ROOT_URL}{$themeconf.img_dir}/ajax_loader.gif" data-src="{$verso.selected_derivative->get_url()}"{/if} alt="{$ALT_IMG}" id="theVersoImage" usemap="#map{$current.selected_derivative->get_type()}" title="{if isset($COMMENT_IMG)}{$COMMENT_IMG|@strip_tags:false|@replace:'"':' '}{else}{$current.TITLE|@replace:'"':' '} - {$ALT_IMG}{/if}">
     17
    318
    419{footer_script require="jquery"}
    5 jQuery(document).ready(function () {ldelim}
     20jQuery("#derivativeSwitchLink").hide();
     21jQuery(".reverse").css("display", "inline-block");
     22jQuery("img#theVersoImage").insertAfter(jQuery("img#theMainImage"));
    623
    7 {if $b2f_switch_mode == 'click'}
    8   jQuery('.reverse').click(function() {ldelim}
    9     if (jQuery(this).attr('rel') == 'front') {ldelim}
     24{if $b2f_switch_mode == "click"}
     25  jQuery(".reverse").click(function() {ldelim}
     26    if (jQuery(this).data("what") == "front") {ldelim}
    1027{else}
    11   jQuery('.reverse').hover(function() {ldelim}
     28  jQuery(".reverse").hover(function() {ldelim}
    1229{/if}
    1330
    14       /* picture switch */
    15     {if $b2f_transition == 'fade'}
    16       jQuery('img#theMainImage').animate({ldelim}
    17         opacity:0
    18       }, 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         });
    23         jQuery(this).animate({ldelim}
    24           opacity:1
    25         }, 400);
     31      $("img#theVersoImage").hide();
     32     
     33    {if $b2f_transition == "fade"}
     34      $("img#theMainImage").fadeOut(400, function() {ldelim}
     35        $("img#theVersoImage").fadeIn(400);
    2636      });
    2737    {else}
    28       jQuery('img#theMainImage').attr({ldelim}
    29         src: '{$VERSO_URL}',
    30         style: 'max-width:{$WIDTH_IMG}px;max-height:{$HEIGHT_IMG}px;',
    31       });
     38      $("img#theMainImage").hide();
     39      $("img#theVersoImage").show();
    3240    {/if}
    3341   
    34     {if $b2f_switch_mode == 'click'}
    35       /* hd link */
    36       {if isset($VERSO_HD)}
    37       jQuery('img#theMainImage').parent('a').attr({ldelim}
    38         href: "javascript:phpWGOpenWindow('{$VERSO_HD}','{$high.UUID}','scrollbars=yes,toolbar=no,status=no,resizable=yes')"
    39       });
    40       {/if}
    41    
    42       /* B2F link content */
    43       jQuery(this).html('<img src="{$B2F_PATH}template/rotate_2.png"/> {$b2f_see_front}');
    44       jQuery(this).attr('rel', 'back');
    45     {/if}
    46      
    47 {if $b2f_switch_mode == 'click'}
    48     } else if (jQuery(this).attr('rel') == 'back') {ldelim}
     42      $(this).data("what", "back");
     43      $(this).html('<img src="{$ROOT_URL}{$B2F_PATH}template/rotate_2.png"/> {$b2f_see_front}');
     44
     45{if $b2f_switch_mode == "click"}
     46    } else if (jQuery(this).data("what") == "back") {ldelim}
    4947{else}
    5048  }, function() {ldelim}
    5149{/if}
    52 
    53       /* picture switch */
    54     {if $b2f_transition == 'fade'}
    55       jQuery('img#theMainImage').animate({ldelim}
    56         opacity:0
    57       }, 400, function() {ldelim}
    58         jQuery(this).attr({ldelim}
    59           src: '{$SRC_IMG}',
    60           style: 'width:{$WIDTH_IMG}px;height:{$HEIGHT_IMG}px;',
    61         });
    62         jQuery(this).animate({ldelim}
    63           opacity:1
    64         }, 400);
     50   
     51      $("img#theMainImage").hide();
     52   
     53    {if $b2f_transition == "fade"}
     54      $("img#theVersoImage").fadeOut(400, function() {ldelim}
     55        $("img#theMainImage").fadeIn(400);
    6556      });
    6657    {else}
    67       jQuery('img#theMainImage').attr({ldelim}
    68         src: '{$SRC_IMG}',
    69         style: 'width:{$WIDTH_IMG}px;height:{$HEIGHT_IMG}px;',
    70       });
     58      $("img#theVersoImage").hide();
     59      $("img#theMainImage").show();
    7160    {/if}
    72      
    73     {if $b2f_switch_mode == 'click'}
    74       /* hd link */
    75       {if isset($high.U_HIGH)}
    76       jQuery('img#theMainImage').parent('a').attr({ldelim}
    77         href: "javascript:phpWGOpenWindow('{$high.U_HIGH}','{$high.UUID}','scrollbars=yes,toolbar=no,status=no,resizable=yes')"
    78       });
    79       {/if}
    80      
    81       /* B2F link content */
    82       jQuery(this).html('<img src="{$B2F_PATH}template/rotate_1.png"/> {$b2f_see_back}');
    83       jQuery(this).attr('rel', 'front');
    84     {/if}
    85      
    86 {if $b2f_switch_mode == 'click'}
     61   
     62      $(this).data("what", "front");
     63      $(this).html('<img src="{$ROOT_URL}{$B2F_PATH}template/rotate_1.png"/> {$b2f_see_back}');
     64
     65{if $b2f_switch_mode == "click"}
    8766    }
    8867  });
     
    9069  });
    9170{/if}
    92 
    93 });
    9471{/footer_script}
    95 
    96 <img src="{$VERSO_URL}" style="display:none;"/> {* <!-- force preload the verso --> *}
    97 
    98 {if $b2f_position != 'toolbar'}<div>{/if}
    99 <a class="reverse" rel="front" class="pwg-state-default pwg-button" title="{$b2f_see_back}" {if $b2f_position == 'toolbar'}style="border:none !important;"{/if}
    100   {if $b2f_switch_mode == 'hover' and isset($VERSO_HD)}href="javascript:phpWGOpenWindow('{$VERSO_HD}','{$high.UUID}','scrollbars=yes,toolbar=no,status=no,resizable=yes')"{/if}>
    101   <img src="{$B2F_PATH}template/rotate_1.png"/> {$b2f_see_back}
    102 </a>
    103 {if $b2f_position != 'toolbar'}</div>{/if}
  • extensions/Back2Front/template/picture_modify.tpl

    r10852 r21212  
    1717      <tr>
    1818        <td><b>{'This picture has a backside :'|@translate}</b></td>
    19         <td><a href="{$B2F_VERSO_URL}">{$B2F_VERSO_ID}</a></td>
     19        <td><a href="{$B2F_VERSO_URL}">#{$B2F_VERSO_ID}</a></td>
    2020      </tr>
    2121    </table>
  • extensions/Back2Front/template/style.css

    r12361 r21212  
    11a.reverse {
    2   display:inline-block;
     2  display:none;
    33  border:1px solid #666 !important;
    44  padding:5px 5px;
    55  margin-bottom:10px;
    66  font-size:15px;
    7   font-style:italic; 
     7  font-style:italic;
     8  cursor:pointer;
    89}
    910a.reverse img {
    1011  vertical-align:top;
    1112}
     13
     14#theVersoImage {
     15  display:none;
     16}
     17
     18
    1219.lang_help {
    1320  display:inline-block;
Note: See TracChangeset for help on using the changeset viewer.