Ignore:
Timestamp:
Nov 24, 2013, 6:09:57 PM (10 years ago)
Author:
mistic100
Message:

very big update for Piwigo 2.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserCollections/include/events.inc.php

    r24421 r25678  
    1212  if ($tokens[0] == 'collections')
    1313  {
    14     add_event_handler('loc_begin_page_header', 'user_collections_page_header');
    15    
    1614    $page['section'] = 'collections';
    1715    $page['title'] = l10n('Collections');
    18    
     16    $page['body_id'] = 'theCollectionPage';
     17    $page['is_external'] = true;
     18    $page['is_homepage'] = false;
     19
    1920    $page['section_title'] = '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator'];
    20     if (is_a_guest()) $page['section_title'].= l10n('Collections');
    21     else $page['section_title'].= '<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>';
    22    
     21    if (is_a_guest())
     22    {
     23      $page['section_title'].= l10n('Collections');
     24    }
     25    else
     26    {
     27      $page['section_title'].= '<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>';
     28    }
     29
     30    $page['sub_section'] = 'list';
    2331    if (in_array(@$tokens[1], array('edit','view','list')))
    2432    {
    2533      $page['sub_section'] = $tokens[1];
    26       if ($tokens[1]=='edit' && isset($conf['GThumb']) && is_array($conf['GThumb']))
    27       {
    28         $conf['GThumb']['big_thumb'] = false; // big thumb is buggy with removes
    29       }
    30     }
    31     else
    32     {
    33       $page['sub_section'] = 'list';
    34     }
    35    
     34    }
     35
     36    if ($page['sub_section']=='edit' && isset($conf['GThumb']) && is_array($conf['GThumb']))
     37    {
     38      $conf['GThumb']['big_thumb'] = false; // big thumb is buggy with removes
     39    }
     40
    3641    if (!empty($tokens[2]))
    3742    {
     
    3944    }
    4045  }
    41 }
    42 
    43 function user_collections_page_header()
    44 {
    45   global $page;
    46   $page['body_id'] = 'theCollectionPage';
    47 }
    48 
    49 function uc_anti_lightbox($tpl_thumbnails_var)
    50 {
    51   global $template, $page;
    52  
    53   if ($page['section'] == 'collections' && !empty($template->css_by_priority[0]))
    54   {
    55     foreach ($template->css_by_priority[0] as $file)
    56     {
    57       if (strpos($file[0], 'colorbox.css') !== false)
    58       {
    59         $template->assign('UC_NO_LIGHTBOX', true);
    60         break;
    61       }
    62     }
    63   }
    64  
    65   return $tpl_thumbnails_var;
    6646}
    6747
     
    7353  if (isset($page['section']) and $page['section'] == 'collections')
    7454  {
    75     include(USER_COLLEC_PATH . '/include/collections.inc.php');
    76   }
    77  
     55    include(USER_COLLEC_PATH . 'include/collections.inc.php');
     56  }
     57
    7858  if (!is_a_guest() && count($page['items']))
    7959  {
     
    9171{
    9272  if (is_a_guest()) return $tpl_thumbnails_var;
    93  
     73
    9474  global $page, $template, $user;
    95  
     75
    9676  // the content is different on collection edition page and no button on batch downloader set edition page
    97   if ( empty($pictures) or (@$page['section'] == 'collections' and @$page['sub_section']=='edit') or @$page['section'] == 'download')
     77  if (empty($pictures) or (@$page['section'] == 'collections' and @$page['sub_section']=='edit') or @$page['section'] == 'download')
    9878  {
    9979    return $tpl_thumbnails_var;
    10080  }
    101  
     81
    10282  $image_ids = array_map(create_function('$i', 'return $i["id"];'), $pictures);
    103  
     83
    10484  // get collections for each picture
    10585  $query = '
     
    11797;';
    11898  $image_collections = simple_hash_from_query($query, 'image_id', 'col_ids');
    119  
     99
    120100  foreach ($tpl_thumbnails_var as &$thumbnail)
    121101  {
     
    123103  }
    124104  unset($thumbnail);
    125  
     105
    126106  // get all collections
    127107  $query = '
     
    132112;';
    133113  $collections = hash_from_query($query, 'id');
    134  
     114
    135115  foreach ($collections as &$col)
    136116  {
    137     $col["name"] = trigger_event("render_category_name", $col["name"]);
     117    $col["name"] = trigger_change('render_category_name', $col["name"]);
    138118  }
    139119  unset($col);
    140  
     120
    141121  $template->assign(array(
    142122    'COLLECTIONS' => $collections,
    143123    'USER_COLLEC_PATH' => USER_COLLEC_PATH,
    144124    ));
    145  
     125
    146126  // thumbnails buttons
    147127  $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_button');
    148  
     128
    149129  return $tpl_thumbnails_var;
    150130}
     
    162142{/if}
    163143</a>{/strip}';
    164  
     144
    165145  return preg_replace($search, $replace, $content);
    166146}
     
    173153function user_collections_picture_page()
    174154{
    175   if (is_a_guest()) return;
    176  
     155  if (is_a_guest())
     156  {
     157    return;
     158  }
     159
    177160  global $template, $picture, $user;
    178  
     161
    179162  // get collections for this picture
    180163  $query = '
     
    190173;';
    191174  list($image_collections) = pwg_db_fetch_row(pwg_query($query));
    192  
     175
    193176  // get all collections
    194177  $query = '
     
    199182;';
    200183  $collections = hash_from_query($query, 'id');
    201  
     184
    202185  foreach ($collections as &$col)
    203186  {
    204     $col["name"] = trigger_event("render_category_name", $col["name"]);
     187    $col["name"] = trigger_change('render_category_name', $col["name"]);
    205188  }
    206189  unset($col);
    207  
     190
    208191  $template->assign(array(
    209192    'CURRENT_COLLECTIONS' => $image_collections,
     
    213196    'IN_PICTURE' => true,
    214197    ));
    215  
     198
    216199  // toolbar button
    217200  $template->set_filename('usercol_button', realpath(USER_COLLEC_PATH.'template/picture_button.tpl'));
     
    227210function user_collections_add_menublock($menu_ref_arr)
    228211{
    229   if (is_a_guest()) return;
    230  
    231212  $menu = &$menu_ref_arr[0];
    232   if ($menu->get_id() != 'menubar') return;
    233    
     213  if (is_a_guest() || $menu->get_id() != 'menubar')
     214  {
     215    return;
     216  }
     217
    234218  $menu->register_block(new RegisteredBlock('mbUserCollection', l10n('Collections'), 'UserCollection'));
    235219}
     
    239223{
    240224  $max = 6;
    241  
     225
    242226  global $template, $page, $conf, $user;
    243227  $menu = &$menu_ref_arr[0];
    244  
     228
    245229  if (($block = $menu->get_block('mbUserCollection')) != null)
    246230  {
     
    252236;';
    253237    $collections = array_values(hash_from_query($query, 'id'));
    254    
     238
    255239    $data['collections'] = array();
    256240    for ($i=0; $i<$max && $i<count($collections); $i++)
    257241    {
    258       $collections[$i]['name'] = trigger_event('render_category_name', $collections[$i]['name']);
     242      $collections[$i]['name'] = trigger_change('render_category_name', $collections[$i]['name']);
    259243      $collections[$i]['u_edit'] = USER_COLLEC_PUBLIC.'edit/'.$collections[$i]['id'];
    260244      $data['collections'][] = $collections[$i];
    261245    }
    262    
     246
    263247    $data['NB_COL'] = count($collections);
    264248    if ($data['NB_COL'] > $max)
     
    266250      $data['MORE'] = count($collections)-$max;
    267251    }
    268    
     252
    269253    $data['U_LIST'] = USER_COLLEC_PUBLIC;
    270    
     254
    271255    $block->set_title('<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>');
    272256    $block->template = realpath(USER_COLLEC_PATH . 'template/menublock.tpl');
     
    274258  }
    275259}
    276 
    277 ?>
Note: See TracChangeset for help on using the changeset viewer.