Changeset 21212 for extensions/Back2Front/Back2Front.php
- Timestamp:
- Mar 5, 2013, 4:53:11 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Back2Front/Back2Front.php
r14963 r21212 7 7 * Add verso link on picture page 8 8 */ 9 function Back2Front_picture_content($content, $ image)9 function Back2Front_picture_content($content, $element_info) 10 10 { 11 11 global $template, $user, $conf; … … 13 13 /* search for a verso picture */ 14 14 $query = " 15 SELECT 16 i.id, 17 i.path, 18 i.has_high, 19 i.width, 20 i.height 15 SELECT i.* 21 16 FROM ".IMAGES_TABLE." as i 22 17 INNER JOIN ".B2F_TABLE." as v 23 18 ON i.id = v.verso_id 24 WHERE 25 v.image_id = ".$image['id']." 19 AND v.image_id = ".$element_info['id']." 26 20 ;"; 27 21 $result = pwg_query($query); … … 31 25 $verso = pwg_db_fetch_assoc($result); 32 26 $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]; 33 33 34 34 /* websize picture */ 35 35 $template->assign(array( 36 36 'B2F_PATH' => B2F_PATH, 37 ' VERSO_URL' => $verso['path'],37 'verso' => $verso, 38 38 )); 39 39 … … 41 41 if (is_admin()) 42 42 { 43 $template->assign('VERSO_U_ADMIN', get_root_url().'admin.php?page=p icture_modify&image_id='.$verso['id']);43 $template->assign('VERSO_U_ADMIN', get_root_url().'admin.php?page=photo-'.$verso['id']); 44 44 $template->set_filename('B2F_admin_button', dirname(__FILE__).'/template/admin_button.tpl'); 45 45 $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));52 46 } 53 47 … … 80 74 $conf['back2front'][4] = array(l10n('See back'), l10n('See front')); 81 75 } 76 77 if ($conf['back2front'][2] == 'fade' and $conf['back2front'][3] == 'bottom') 78 { 79 $conf['back2front'][3] = 'top'; 80 } 81 82 82 83 83 /* template & output */ … … 116 116 global $page, $template, $conf; 117 117 118 if ($page['page'] != 'picture_modify') return; 118 if ($page['page'] != 'photo') return; 119 if (isset($_GET['tab']) && $_GET['tab']!='properties') return; 120 121 119 122 $conf['back2front'] = explode(',',$conf['back2front']); 120 123 … … 164 167 { 165 168 $recto_current_verso['id'] = $all_recto_verso[$_POST['b2f_front_id']]; 166 $recto_current_verso['link'] = get_root_url().'admin.php?page=p icture_modify&image_id='.$recto_current_verso['id'];169 $recto_current_verso['link'] = get_root_url().'admin.php?page=photo-'.$recto_current_verso['id']; 167 170 array_push( 168 171 $page['errors'], … … 236 239 237 240 $verso['id'] = $_POST['b2f_front_id']; 238 $verso['link'] = get_root_url().'admin.php?page=p icture_modify&image_id='.$verso['id'];241 $verso['link'] = get_root_url().'admin.php?page=photo-'.$verso['id']; 239 242 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>'))); 240 243 } … … 300 303 $template->assign(array( 301 304 'B2F_VERSO_ID' => $item['verso_id'], 302 'B2F_VERSO_URL' => get_root_url().'admin.php?page=p icture_modify&image_id='.$item['verso_id'],305 'B2F_VERSO_URL' => get_root_url().'admin.php?page=photo-'.$item['verso_id'], 303 306 )); 304 307 } … … 312 315 function Back2front_picture_modify_prefilter($content, &$smarty) 313 316 { 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'); 316 319 return str_replace($search, $replacement, $content); 317 320 } … … 321 324 * Add mark on thumbnails list 322 325 */ 323 function Back2Front_thumbnails($tpl_thumbnails_var , $pictures)326 function Back2Front_thumbnails($tpl_thumbnails_var) 324 327 { 325 global $conf ;328 global $conf, $selection; 326 329 327 330 $conf['back2front'] = explode(',',$conf['back2front']); 328 331 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; 336 333 337 334 /* has the pictures a verso ? */ 338 $query = "SELECT image_id , verso_id335 $query = "SELECT image_id 339 336 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(); 344 341 345 342 foreach($tpl_thumbnails_var as &$tpl_var) 346 343 { 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 :').'"/>'; 350 347 } 351 348 }
Note: See TracChangeset
for help on using the changeset viewer.