Ignore:
Timestamp:
10/06/11 13:45:36 (8 years ago)
Author:
mistic100
Message:

remove a prefilter for a better integration, add an option to display a mark on thumbnails list

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Back2Front/Back2Front.php

    r11599 r12361  
    88 */ 
    99function Back2Front_picture_content($content, $image) 
    10  { 
     10{ 
    1111  global $template, $user, $conf; 
    1212 
     
    3333     
    3434    /* websize picture */ 
    35     $template->assign('VERSO_URL', $verso['path']); 
     35    $template->assign(array( 
     36      'B2F_PATH' => B2F_PATH, 
     37      'VERSO_URL' => $verso['path'], 
     38      )); 
    3639     
    3740    /* admin link */ 
     
    7982 
    8083    /* template & output */ 
    81     $template->set_filenames(array('B2F_picture_content' => dirname(__FILE__).'/template/picture_content.tpl') );     
     84    $template->set_filename('B2F_picture_content', dirname(__FILE__).'/template/picture_content.tpl');     
    8285    $template->assign(array( 
    83       'B2F_PATH' => B2F_PATH, 
    8486      'b2f_switch_mode' => $conf['back2front'][1], 
    8587      'b2f_transition' => $conf['back2front'][2], 
     
    9294    { 
    9395      case 'toolbar': 
    94         $template->set_prefilter('picture', 'Back2Front_toolbar_prefilter');   
     96        $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('B2F_picture_content', true)); 
    9597        break; 
    9698      case 'top': 
     
    104106   
    105107  return $content; 
    106 } 
    107  
    108 function 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); 
    113108} 
    114109 
     
    322317} 
    323318 
     319 
     320/* 
     321 * Add mark on thumbnails list 
     322 */ 
     323function Back2Front_thumbnails($tpl_thumbnails_var, $pictures) 
     324{ 
     325  global $conf; 
     326   
     327  $conf['back2front'] = explode(',',$conf['back2front']); 
     328  if (!$conf['back2front'][5]) return $tpl_thumbnails_var; 
     329   
     330  $ids = array(); 
     331  foreach ($pictures as $row) 
     332  { 
     333    array_push($ids, $row['id']); 
     334  } 
     335     
     336  /* has the pictures a verso ? */ 
     337  $query = "SELECT image_id, verso_id 
     338    FROM ".B2F_TABLE." 
     339    WHERE image_id IN(".implode(',', $ids).");"; 
     340  $result = hash_from_query($query, 'image_id'); 
     341   
     342  $ids = array_keys($result); 
     343   
     344  foreach($tpl_thumbnails_var as &$tpl_var) 
     345  { 
     346    if (in_array($tpl_var['ID'], $ids)) 
     347    { 
     348      $tpl_var['NAME'].= ' <img class="has_verso" src="'.B2F_PATH.'template/rotate_1.png" title="'.l10n('This picture has a backside :').'"/>'; 
     349    } 
     350  } 
     351   
     352  return $tpl_thumbnails_var; 
     353} 
     354 
    324355?> 
Note: See TracChangeset for help on using the changeset viewer.