Changeset 9782


Ignore:
Timestamp:
Mar 19, 2011, 10:41:40 PM (10 years ago)
Author:
mistic100
Message:

[extensions] Front2Back

  • compatibility with 2.2.0
  • jQuery method for swap
  • localisation
Location:
extensions/Front2Back
Files:
13 added
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/Front2Back/Front2Back.css

    r3339 r9782  
    1 /* Front2Back Style ----------------------------------------------------------------------*/
    2 /*CSS Popup Image Viewer:  Adapted to PWG */
    3 /*Credits: Dynamic Drive CSS Library */
    4 /*URL: http://www.dynamicdrive.com/style/ */
    5 
    6 .reverse { position: relative; z-index: 0; }
    7 .reverse:hover{ background-color: transparent; z-index: 50; }
    8 
    9 .reverse span { /* enlarged image*/
    10   position: absolute; visibility: hidden; text-decoration: none; }
    11 
    12 .reverse:hover span { /* enlarged image on hover*/ visibility: visible; }
    13 
    14 .reverse span, .reverse span img{ /* enlarged image*/
    15   border-width: 0; padding: 0px; background-color: transparent !important; }
     1a.reverse {
     2        display:inline-block;
     3        border:1px solid #666 !important;
     4        padding:3px 5px;
     5        margin-bottom:10px;
     6        font-size:15px;
     7        font-style:italic;     
     8}
     9a.reverse img {
     10        vertical-align:top;
     11}
  • extensions/Front2Back/Front2Back.php

    r3339 r9782  
    11<?php
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    3 add_event_handler('render_element_content',
    4     array('Front2Back', 'Front2Back_content'), 99, 2 );
    53
    6 class Front2Back
     4function Front2Back_content($content, $image)
    75{
    8   function Front2Back_content($content, $image)
    9   {
    10     global $template, $lang, $user, $conf;
    11     /* Default values */
    12     if (!isset($lang['Front2Back'])) $lang['Front2Back'] = 'See back';
    13     if (!isset($conf['Front2Back_dir'])) $conf['Front2Back_dir'] = 'verso/';
    14     if (!isset($conf['Front2Back_vshift'])) $conf['Front2Back_vshift']= 16;
    15     if (!isset($conf['Front2Back_hshift'])) $conf['Front2Back_hshift']= -28;
    16     if (!isset($conf['Front2Back_parent'])) $conf['Front2Back_parent']= 'thumbnail/';
    17     if (!isset($conf['Front2Back_path'])) $conf['Front2Back_inside']= true;
    18       else $conf['Front2Back_inside']= false;
    19    
    20     /* Build reversal parms and filename */
    21     if ( $conf['Front2Back_inside'] ) {
    22       $verso = substr( $image['path'],
    23                 0, strrpos( $image['path'], '/' )+1 )
    24                 . $conf['Front2Back_parent'] . $conf['Front2Back_dir'];
    25     }
    26     else {  /* example:
    27       $conf['Front2Back_path'] = PHPWG_ROOT_PATH;
    28       $conf['Front2Back_parent'] = 'front2back/';
    29       $conf['Front2Back_dir'] = '';
    30       */
    31       $verso = $conf['Front2Back_path']
    32                 . $conf['Front2Back_parent'] . $conf['Front2Back_dir'];
    33     }
    34     $verso.= $image['file'];
    35     $height = @$image['scaled_height'];
    36     $width = @$image['scaled_width'];
    37     $shift_left = (int) ($width / 2) + $conf['Front2Back_hshift'];
    38     $shift_up = $height  + $conf['Front2Back_vshift'];
    39     $rotat = substr($verso,0,-4).'-r'.substr($verso,-4); // extension .jpg 4car.
    40     $template->set_filenames(
    41       array('Front2Back' => dirname(__FILE__) . '/Front2Back.tpl') );
     6        global $template, $conf;
     7       
     8        /* Default values */
     9        if (!isset($conf['Front2Back_dir'])) $conf['Front2Back_dir'] = 'verso/';
     10        if (!isset($conf['Front2Back_parent'])) $conf['Front2Back_parent'] = 'thumbnail/';
     11        if (!isset($conf['Front2Back_hd_parent'])) $conf['Front2Back_hd_parent'] = 'pwg_high/';
     12        if (!isset($conf['Front2Back_path']))
     13                $conf['Front2Back_inside']= true;
     14        else
     15                $conf['Front2Back_inside']= false;
    4216
    43     $template->assign(array('F2B_PATH' => F2B_PATH));
    44     if (is_file($verso)) {
    45       $template->assign(
    46         'verso',
    47          array(
    48            'VERSO_URL' => $verso,
    49            'WIDTH_IMG' => $width,
    50            'HEIGHT_IMG' => $height,
    51            'HSHIFT_IMG' => $shift_left,
    52            'VSHIFT_IMG' => $shift_up,
    53          )
    54        );
    55     }
    56     elseif (is_file($rotat)) {           /* Is there a rotated file ? */
    57       $shift_left = (int) ($height / 2) + $conf['Front2Back_hshift'];   
    58       $template->assign(
    59         'verso',
    60          array(
    61            'VERSO_URL' => $rotat,
    62            'WIDTH_IMG' => $height, /* Swap width/height */
    63            'HEIGHT_IMG' => $width, /*   ""        ""    */
    64            'HSHIFT_IMG' => $shift_left,
    65            'VSHIFT_IMG' => $shift_up,
    66          )
    67        );
    68     }
    69     else return $content;
    70     return $content . $template->parse('Front2Back', true);   
    71   } 
    72 }
     17        /* dirs and files */
     18        if ( $conf['Front2Back_inside'] ) {
     19                $verso_dir = str_replace($image['file'], null, $image['path']) . $conf['Front2Back_parent'] . $conf['Front2Back_dir'];
     20                $hd_dir = str_replace($image['file'], null, $image['path']) . $conf['Front2Back_hd_parent'] . $conf['Front2Back_dir'];
     21        } else {
     22                $verso_dir = $conf['Front2Back_path'] . $conf['Front2Back_parent'] . $conf['Front2Back_dir'];
     23                $hd_dir = $conf['Front2Back_path'] . $conf['Front2Back_hd_parent'] . $conf['Front2Back_dir'];
     24        }
     25        $rotat_file = substr($image['file'],0,-4).'-r'.substr($image['file'],-4);
     26
     27        $template->set_filenames(array('Front2Back' => dirname(__FILE__) . '/Front2Back.tpl') );
     28        $template->assign('F2B_PATH', F2B_PATH);
     29
     30        /* Is there a verso file ? */
     31        if (is_file($verso_dir.$image['file']))
     32        {
     33                $template->assign('VERSO_URL', $verso_dir.$image['file']);
     34
     35                if (is_file($hd_dir.$image['file'])) {
     36                        $template->assign('VERSO_HD', $hd_dir.$image['file']);
     37                }
     38        }
     39        /* useless section, just for retrocompatibility */
     40        else if (is_file($verso_dir.$rotat_file))
     41        {           
     42                $template->assign('VERSO_URL', $verso_dir.$rotat_file);
     43               
     44                if (is_file($hd_dir.$rotat_file)) {
     45                        $template->assign('VERSO_HD', $hd_dir.$rotat_file);
     46                }
     47        }
     48        /* otherwise */
     49        else
     50        {
     51                return $content;
     52        }
     53       
     54        return $content . $template->parse('Front2Back', true);   
     55
     56
    7357?>
  • extensions/Front2Back/Front2Back.tpl

    r3339 r9782  
    1 {html_head}
    2 <link rel="stylesheet" type="text/css" href="{$F2B_PATH|@cat:'Front2Back.css'}">
    3 {/html_head}
    4 <br />
    5 <a class="reverse" href="#">
    6   {'Front2Back'|@translate}
    7   <span style="top: -{$verso.VSHIFT_IMG}px; left: -{$verso.HSHIFT_IMG}px;">
    8     <img src="{$verso.VERSO_URL}"
    9           style="width:{$verso.WIDTH_IMG}px;height:{$verso.HEIGHT_IMG}px;"
    10           alt="Verso" />
    11     <br />
    12     <!--
    13     Dynamic Drive
    14     <img src="http://www.dynamicdrive.com/cssexamples/media/dynamicdrive.gif" />
    15     -->
    16   </span>
     1{combine_script id="jquery"}
     2{combine_css path=$F2B_PATH|@cat:"Front2Back.css"}
     3
     4{footer_script require="jquery"}
     5        jQuery('.reverse').click(function() {ldelim}
     6                if (jQuery(this).attr('name') == 'front') {ldelim}
     7                        /* picture attributes */
     8                        jQuery('#theImage img:first-child').attr({ldelim}
     9                                src: '{$VERSO_URL}',
     10                                style: 'width:;height:;',
     11                        });
     12                       
     13                        /* hd link atributes */
     14                        {if isset($VERSO_HD)}
     15                        jQuery('#theImage a:first-child').attr({ldelim}
     16                                href: "javascript:phpWGOpenWindow('{$VERSO_HD}','{$high.UUID}','scrollbars=yes,toolbar=no,status=no,resizable=yes')"
     17                        });
     18                        {/if}
     19                       
     20                        /* f2b link content */
     21                        jQuery(this).html('<img src="{$F2B_PATH}rotate_2.png"/> {'Front2Back_front'|@translate}');
     22                        jQuery(this).attr('name', 'back');
     23                       
     24                } else if (jQuery(this).attr('name') == 'back') {ldelim}
     25                        jQuery('#theImage img:first-child').attr({ldelim}
     26                                src: '{$SRC_IMG}',
     27                                style: 'width:{$WIDTH_IMG}px;height:{$HEIGHT_IMG}px;',
     28                        });
     29                       
     30                        {if isset($VERSO_HD)}
     31                        jQuery('#theImage a:first-child').attr({ldelim}
     32                                href: "javascript:phpWGOpenWindow('{$high.U_HIGH}','{$high.UUID}','scrollbars=yes,toolbar=no,status=no,resizable=yes')')"
     33                        });
     34                        {/if}
     35                       
     36                        jQuery(this).html('<img src="{$F2B_PATH}rotate_1.png"/> {'Front2Back_back'|@translate}');
     37                        jQuery(this).attr('name', 'front');
     38                }
     39        });
     40{/footer_script}
     41
     42<a class="reverse" name="front">
     43        <img src="{$F2B_PATH}rotate_1.png"/>
     44        {'Front2Back_back'|@translate}
    1745</a>
    18 <div style="clear: both;"></div>
  • extensions/Front2Back/main.inc.php

    r3339 r9782  
    1 <?php /*
     1<?php
     2/*
    23Plugin Name: Front2Back
    3 Version: 2.0.a
    4 Description: Postcards back display if there is. / Verso d'une carte.
     4Version: 2.2.0
     5Description: Add a link on picture's page to show a alternative version of the pic (for postcards for example)
    56Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=183
    6 Author: VDigital (PhpWebGallery team)
    7 Author URI: http://www.phpwebgallery.net
    8 */
    9 
    10 /* Synopsis
    11 1 - If same name file exists in ./thumbnail/verso/ or ...
    12 2 - A link is displayed
    13 3 - OnMouseOver Front2Back replace the original picture
    14 
    15 Localisation of Front2Back, just add:
    16 $lang['Front2Back'] = 'See back';
    17 in your ./language/xxxx/local.lang.php
    18 
    19 Requirements/recommendations:
    20 1 - Backsize = Frontsize
    21 2 - Profile displayed sizes are Null or > Backsided pictures sizes
    22 3 - Metadata are synchronized
    23 
    24 */
    25 /*
    26 History
    27   2008-10-30 2.0.a (stable)
    28              Smarty version for Piwigo (Don't use it with PhpWebGallery 1.7.x)
    29   2007-11-07 Add -r to back filenames if your picture are portrait in one side
    30              and landscape in the other one. 
    31   2007-10-10 Additional and optionnal parameters
    32      $conf['Front2Back_path'] real path if you want them outside ./galleries/
    33        Warning: if F2B_path is set then directory tree will not reminded !
    34      $conf['Front2Back_parent'] can be set to 'thumbnail/' or 'pwg_high/'
    35      
    36   2007-10-08 Conflict with PY GVideo solved
    37      (render_element_content usage error: No residual impact)
    38   2007-10-07 First release
     7Author: VDigital & Mistic
    398*/
    409
    4110if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    42 define('F2B_DIR' , basename(dirname(__FILE__)));
    43 define('F2B_PATH' , PHPWG_PLUGINS_PATH . F2B_DIR . '/');
    44 include_once( F2B_PATH . 'Front2Back.php');
     11
     12define('F2B_DIR', basename(dirname(__FILE__)));
     13define('F2B_PATH', PHPWG_PLUGINS_PATH . F2B_DIR . '/');
     14
     15load_language('plugin.lang', F2B_PATH);
     16include_once(F2B_PATH . 'Front2Back.php');
     17add_event_handler('render_element_content', 'Front2Back_content', 99, 2);
     18       
    4519?>
Note: See TracChangeset for help on using the changeset viewer.