Changeset 9982 for extensions/rightClick


Ignore:
Timestamp:
Apr 2, 2011, 12:55:56 PM (13 years ago)
Author:
patdenice
Message:

Compatible with piwigo 2.2.x

Location:
extensions/rightClick
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/rightClick/main.inc.php

    r6515 r9982  
    1313define('RIGHTCK_PATH' , PHPWG_PLUGINS_PATH . RIGHTCK_DIR . '/');
    1414define('RIGHTCK_VER' , '2.1.b');
    15 include_once( RIGHTCK_PATH . 'rightClick_protect.php');
     15
     16if ( !function_exists( 'rightClick_protect' ) )
     17{
     18        if ( defined('IN_ADMIN') and IN_ADMIN ) return false;
     19
     20        add_event_handler('loc_after_page_header', 'rightClick_protect', 20);
     21
     22        function  rightClick_protect()
     23  {
     24                global $template, $user, $conf;
     25                if (!isset($conf['rightClick_level']))
     26      $Maxlvl = max($conf['available_permission_levels']);
     27                else
     28      $Maxlvl = $conf['rightClick_level'];
     29
     30                if ($user['level'] >= $Maxlvl) return;
     31
     32                $default = array( '#theImage img', '#akPicture', '#colorbox', '#sb-container', );
     33                if (!isset($conf['rightClick_selectors']))
     34      $conf['rightClick_selectors'] = array();
     35
     36                $conf['rightClick_selectors'] = array_unique( array_merge($default, $conf['rightClick_selectors']) );
     37               
     38                $template->set_filenames(array(
     39                'rightClick_protect' => dirname(__FILE__) . '/template/rightClick_protect.tpl',
     40                ));
     41                $Path = embellish_url($template->get_template_vars('ROOT_URL').RIGHTCK_PATH);
     42                $protect = array(
     43                        'Dir'                           => RIGHTCK_DIR,
     44                        'Path'                          => $Path,
     45                        'Version'                       => RIGHTCK_VER,
     46                        'Selectors'                     => $conf['rightClick_selectors'],
     47                        );
     48                $template->assign( array( 'RIGHTCK' => $protect ) );
     49                $template->parse('rightClick_protect');
     50        }
     51}
    1652?>
  • extensions/rightClick/template/rightClick_protect.tpl

    r6515 r9982  
    1 {known_script id="jquery" src=$ROOT_URL|cat:"themes/default/js/jquery.packed.js"}
    2 {html_head}
     1{footer_script require="jquery"}
    32<!-- Protected images by the "rightClick" plugin (version {$RIGHTCK.Version}): {$RIGHTCK.Dir}/template/rightClick_protect.tpl -->
    4 <script type="text/javascript">
    5 jQuery(document).ready(function($) {ldelim}
    6 {foreach item=selector from=$RIGHTCK.Selectors name=select}
    7         $('{$selector}').each( function() {ldelim}
    8                 $(this)[0].oncontextmenu = function() {ldelim}
     3jQuery(document).ready(function() {ldelim}
     4        jQuery('{','|@implode:$RIGHTCK.Selectors}').each( function() {ldelim}
     5                jQuery(this)[0].oncontextmenu = function() {ldelim}
    96                        return false;
    107                }
    118        });     
    12 {/foreach}
    139});
    14 </script> 
    15 {/html_head}
     10{/footer_script}
Note: See TracChangeset for help on using the changeset viewer.