Changeset 23177 for extensions/Back2Front
- Timestamp:
- Jun 13, 2013, 2:01:34 PM (11 years ago)
- Location:
- extensions/Back2Front
- Files:
-
- 3 added
- 6 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/Back2Front/admin.php
r12361 r23177 3 3 4 4 global $conf, $template; 5 load_language('plugin.lang', B2F_PATH);6 $conf['back2front'] = explode(',', $conf['back2front']);7 5 8 include_once(B2F_PATH .'functions.inc.php');6 include_once(B2F_PATH . 'include/functions.inc.php'); 9 7 10 8 // Enregistrement de la configuration … … 12 10 { 13 11 $conf['back2front'] = array( 14 $conf['back2front'][0],15 $_POST['switch_mode'],16 $_POST['transition'],17 $_POST['position'],18 serialize(stripslashes_deep(str_replace(array("'",'"',','), null, $_POST['link_name']))),19 isset($_POST['show_thumbnail']),20 );12 'versos_cat' => $conf['back2front']['versos_cat'], 13 'switch_mode' => $_POST['switch_mode'], 14 'transition' => $_POST['transition'], 15 'position' => $_POST['position'], 16 'link_name' => stripslashes_deep($_POST['link_name']), 17 'show_thumbnail' => isset($_POST['show_thumbnail']), 18 ); 21 19 22 conf_update_param('back2front', implode (',',$conf['back2front']));20 conf_update_param('back2front', serialize($conf['back2front'])); 23 21 array_push($page['infos'], l10n('Information data registered in database')); 24 22 } 25 23 26 24 // Gestion des langues pour le bloc menu 27 $conf['back2front'][4] = unserialize($conf['back2front'][4]);28 25 $template->append('link_name', array( 29 26 'LANGUAGE_NAME' => l10n('Default'), 30 27 'LANGUAGE_CODE' => 'default', 31 'VALUE' => @$conf['back2front'][ 4]['default'],32 ) 33 ); 28 'VALUE' => @$conf['back2front']['link_name']['default'], 29 )); 30 34 31 foreach (get_languages() as $language_code => $language_name) 35 32 { … … 37 34 'LANGUAGE_NAME' => $language_name, 38 35 'LANGUAGE_CODE' => $language_code, 39 'VALUE' => isset($conf['back2front'][4][$language_code]) ? $conf['back2front'][4][$language_code] : '', 40 ) 41 ); 36 'VALUE' => @$conf['back2front']['link_name'][$language_code], 37 )); 42 38 } 43 39 44 40 $template->assign(array( 45 41 'B2F_PATH' => B2F_PATH, 46 'SWITCH_MODE' => $conf['back2front'][ 1],47 'TRANSITION' => $conf['back2front'][ 2],48 'POSITION' => $conf['back2front'][ 3],49 'SHOW_THUMBNAIL' => $conf['back2front'][ 5],50 ));42 'SWITCH_MODE' => $conf['back2front']['switch_mode'], 43 'TRANSITION' => $conf['back2front']['transition'], 44 'POSITION' => $conf['back2front']['position'], 45 'SHOW_THUMBNAIL' => $conf['back2front']['show_thumbnail'], 46 )); 51 47 52 $template->set_filename('back2front_conf', dirname(__FILE__).'/template/admin.tpl');48 $template->set_filename('back2front_conf', realpath(B2F_PATH.'template/admin.tpl')); 53 49 $template->assign_var_from_handle('ADMIN_CONTENT', 'back2front_conf'); 54 50 -
extensions/Back2Front/include/Back2Front.php
r23167 r23177 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 3 4 include_once(B2F_PATH.' functions.inc.php');4 include_once(B2F_PATH.'include/functions.inc.php'); 5 5 6 6 /* 7 7 * Add verso link on picture page 8 8 */ 9 function Back2Front_picture_content($content, $element_info)9 function back2front_picture_content($content, $element_info) 10 10 { 11 11 global $template, $user, $conf; 12 12 13 13 /* search for a verso picture */ 14 $query = "15 16 FROM ".IMAGES_TABLE."as i17 INNER JOIN ".B2F_TABLE."as v18 19 AND v.image_id = ".$element_info['id']."20 ;";14 $query = ' 15 SELECT i.* 16 FROM '.IMAGES_TABLE.' as i 17 INNER JOIN '.B2F_TABLE.' as v 18 ON i.id = v.verso_id 19 AND v.image_id = '.$element_info['id'].' 20 ;'; 21 21 $result = pwg_query($query); 22 22 … … 24 24 { 25 25 $verso = pwg_db_fetch_assoc($result); 26 $conf['back2front'] = explode(',',$conf['back2front']);27 26 $deriv_type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']); 28 27 … … 42 41 { 43 42 $template->assign('VERSO_U_ADMIN', get_root_url().'admin.php?page=photo-'.$verso['id']); 44 $template->set_filename('B2F_admin_button', dirname(__FILE__).'/template/admin_button.tpl');43 $template->set_filename('B2F_admin_button', realpath(B2F_PATH.'template/admin_button.tpl')); 45 44 $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('B2F_admin_button', true)); 46 45 } 47 46 48 47 /* link name */ 49 $conf['back2front'][4] = unserialize($conf['back2front'][4]); 50 if (!empty($conf['back2front'][4][$user['language']])) 51 { 52 if (strpos($conf['back2front'][4][$user['language']], '|') !== false) 53 { 54 $conf['back2front'][4] = explode('|', $conf['back2front'][4][$user['language']]); 48 if (!empty($conf['back2front']['link_name'][$user['language']])) 49 { 50 if (strpos($conf['back2front']['link_name'][$user['language']], '|') !== false) 51 { 52 $conf['back2front']['link_name'] = explode('|', $conf['back2front']['link_name'][$user['language']]); 55 53 } 56 54 else 57 55 { 58 $conf['back2front'][ 4] = array($conf['back2front'][4][$user['language']], $conf['back2front'][4][$user['language']]);59 } 60 } 61 else if (!empty($conf['back2front'][ 4]['default']))62 { 63 if (strpos($conf['back2front'][ 4]['default'], '|') != false)64 { 65 $conf['back2front'][ 4] = explode('|', $conf['back2front'][4]['default']);56 $conf['back2front']['link_name'] = array_fill(0, 2, $conf['back2front']['link_name'][$user['language']]); 57 } 58 } 59 else if (!empty($conf['back2front']['link_name']['default'])) 60 { 61 if (strpos($conf['back2front']['link_name']['default'], '|') != false) 62 { 63 $conf['back2front']['link_name'] = explode('|', $conf['back2front']['link_name']['default']); 66 64 } 67 65 else 68 66 { 69 $conf['back2front'][ 4] = array($conf['back2front'][4]['default'], $conf['back2front'][4]['default']);67 $conf['back2front']['link_name'] = array_fill(0, 2, $conf['back2front']['link_name']['default']); 70 68 } 71 69 } 72 70 else 73 71 { 74 $conf['back2front'][ 4] = array(l10n('See back'), l10n('See front'));75 } 76 77 if ($conf['back2front'][ 2] == 'fade' and $conf['back2front'][3] =='bottom')78 { 79 $conf['back2front'][ 3] = 'top';72 $conf['back2front']['link_name'] = array(l10n('See back'), l10n('See front')); 73 } 74 75 if ($conf['back2front']['transition'] == 'fade' && $conf['back2front']['position'] == 'bottom') 76 { 77 $conf['back2front']['position'] = 'top'; 80 78 } 81 79 82 80 83 81 /* template & output */ 84 $template->set_filename('B2F_picture_content', dirname(__FILE__).'/template/picture_content.tpl');82 $template->set_filename('B2F_picture_content', realpath(B2F_PATH.'template/picture_content.tpl')); 85 83 $template->assign(array( 86 'b2f_switch_mode' => $conf['back2front'][ 1],87 'b2f_transition' => $conf['back2front'][ 2],88 'b2f_position' => $conf['back2front'][ 3],89 'b2f_see_back' => $conf['back2front'][ 4][0],90 'b2f_see_front' => $conf['back2front'][ 4][1],84 'b2f_switch_mode' => $conf['back2front']['switch_mode'], 85 'b2f_transition' => $conf['back2front']['transition'], 86 'b2f_position' => $conf['back2front']['position'], 87 'b2f_see_back' => $conf['back2front']['link_name'][0], 88 'b2f_see_front' => $conf['back2front']['link_name'][1], 91 89 )); 92 90 93 switch ($conf['back2front'][ 3])91 switch ($conf['back2front']['position']) 94 92 { 95 93 case 'toolbar': … … 97 95 break; 98 96 case 'top': 99 return$template->parse('B2F_picture_content', true)."\n".$content;97 $content = $template->parse('B2F_picture_content', true)."\n".$content; 100 98 break; 101 99 case 'bottom': 102 return$content."\n".$template->parse('B2F_picture_content', true);100 $content = $content."\n".$template->parse('B2F_picture_content', true); 103 101 break; 104 102 } … … 112 110 * Add field on picture modify page 113 111 */ 114 function Back2Front_picture_modify()112 function back2front_picture_modify() 115 113 { 116 114 global $page, $template, $conf; … … 118 116 if ($page['page'] != 'photo') return; 119 117 if (isset($_GET['tab']) && $_GET['tab']!='properties') return; 120 121 122 $conf['back2front'] = explode(',',$conf['back2front']);123 118 124 119 /* SAVE VALUES */ … … 126 121 { 127 122 /* catch all verso and recto ids and original categories */ 128 $query = "SELECT image_id, verso_id, categories 129 FROM ".B2F_TABLE.";"; 130 $rectos = array_from_query($query, 'image_id'); 131 $versos = array_from_query($query, 'verso_id'); 132 $cats = array_from_query($query, 'categories'); 123 $query = 'SELECT * FROM '.B2F_TABLE.';'; 124 $result = pwg_query($query); 125 126 $rectos = $versos = $cats = array(); 127 while ($row = pwg_db_fetch_assoc($result)) 128 { 129 $rectos[] = $row['image_id']; 130 $versos[] = $row['verso_id']; 131 $cats[] = $row['categories']; 132 } 133 133 134 134 if (count($rectos) != 0) … … 140 140 { 141 141 $all_recto_verso = array(0=>0); 142 $verso_cats = array(0=> NULL);142 $verso_cats = array(0=>null); 143 143 } 144 144 unset($rectos, $versos, $cats); … … 150 150 if (!picture_exists($_POST['b2f_front_id'])) 151 151 { 152 array_push( 153 $page['errors'], 154 sprintf( 155 l10n('Unknown id %d for frontside picture'), 156 $_POST['b2f_front_id'] 157 ) 158 ); 152 array_push($page['errors'], sprintf( 153 l10n('Unknown id %d for frontside picture'), 154 $_POST['b2f_front_id'] 155 )); 159 156 } 160 157 /* verso same as recto */ … … 164 161 } 165 162 /* recto has already a verso */ 166 else if (in_array($_POST['b2f_front_id'], array_keys($all_recto_verso)) AND $all_recto_verso[$_POST['b2f_front_id']] != $_GET['image_id']) 167 { 168 $recto_current_verso['id'] = $all_recto_verso[$_POST['b2f_front_id']]; 169 $recto_current_verso['link'] = get_root_url().'admin.php?page=photo-'.$recto_current_verso['id']; 170 array_push( 171 $page['errors'], 172 sprintf( 173 l10n('The picture n°%d has already a backside : %s'), 174 $_POST['b2f_front_id'], 175 '<a href="'.$recto_current_verso['link'].'">'.$recto_current_verso['id'].'</a>' 176 ) 177 ); 163 else if (in_array($_POST['b2f_front_id'], array_keys($all_recto_verso)) && $all_recto_verso[$_POST['b2f_front_id']] != $_GET['image_id']) 164 { 165 $recto_current_verso['id'] = $all_recto_verso[$_POST['b2f_front_id']]; 166 $recto_current_verso['link'] = get_root_url().'admin.php?page=photo-'.$recto_current_verso['id']; 167 168 array_push($page['errors'], sprintf( 169 l10n('The picture n°%d has already a backside : %s'), 170 $_POST['b2f_front_id'], 171 '<a href="'.$recto_current_verso['link'].'">'.$recto_current_verso['id'].'</a>' 172 )); 178 173 } 179 174 /* recto is already a verso */ 180 175 else if (in_array($_POST['b2f_front_id'], array_values($all_recto_verso))) 181 176 { 182 $recto_is_verso['id'] = $_POST['b2f_front_id']; 183 $recto_is_verso['link'] = get_root_url().'admin.php?page=picture_modify&image_id='.$recto_is_verso['id']; 184 array_push( 185 $page['errors'], 186 sprintf( 187 l10n('The picture n°%s is already a backside'), 188 '<a href="'.$recto_is_verso['link'].'">'.$recto_is_verso['id'].'</a>' 189 ) 190 ); 177 $recto_is_verso['id'] = $_POST['b2f_front_id']; 178 $recto_is_verso['link'] = get_root_url().'admin.php?page=picture_modify&image_id='.$recto_is_verso['id']; 179 180 array_push($page['errors'], sprintf( 181 l10n('The picture n°%s is already a backside'), 182 '<a href="'.$recto_is_verso['link'].'">'.$recto_is_verso['id'].'</a>' 183 )); 191 184 } 192 185 /* everything is fine */ … … 194 187 { 195 188 // move the verso - if first save 196 if (isset($_POST['b2f_move_verso']) AND (!array_key_exists($_GET['image_id'], $verso_cats) OR $verso_cats[$_GET['image_id']] == NULL))189 if (isset($_POST['b2f_move_verso']) && (!array_key_exists($_GET['image_id'], $verso_cats) || $verso_cats[$_GET['image_id']] == null)) 197 190 { 198 191 // get current categories 199 $query = "SELECT category_id FROM ".IMAGE_CATEGORY_TABLE." WHERE image_id = ".$_GET['image_id'].";";192 $query = 'SELECT category_id FROM '.IMAGE_CATEGORY_TABLE.' WHERE image_id = '.$_GET['image_id'].';'; 200 193 $verso_categories = array_from_query($query, 'category_id'); 201 194 202 pwg_query("DELETE FROM ".IMAGE_CATEGORY_TABLE." 203 WHERE image_id = ".$_GET['image_id'].";"); 204 pwg_query("INSERT INTO ".IMAGE_CATEGORY_TABLE."(image_id, category_id) 205 VALUES(".$_GET['image_id'].", ".$conf['back2front'][0].");"); 195 pwg_query('DELETE FROM '.IMAGE_CATEGORY_TABLE.' WHERE image_id = '.$_GET['image_id'].';'); 196 pwg_query('INSERT INTO '.IMAGE_CATEGORY_TABLE.'(image_id, category_id) VALUES('.$_GET['image_id'].', '.$conf['back2front']['versos_cat'].');'); 206 197 207 198 // random representant for each categories … … 212 203 } 213 204 // restore the verso - if precedently moved 214 else if (!isset($_POST['b2f_move_verso']) AND array_key_exists($_GET['image_id'], $verso_cats) AND $verso_cats[$_GET['image_id']] != NULL)205 else if (!isset($_POST['b2f_move_verso']) && array_key_exists($_GET['image_id'], $verso_cats) && $verso_cats[$_GET['image_id']] != null) 215 206 { 216 207 $item['verso_id'] = $_GET['image_id']; … … 229 220 230 221 // insert or update verso associations 231 pwg_query("INSERT INTO ".B2F_TABLE." 232 VALUES(".$_POST['b2f_front_id'].", ".$_GET['image_id'].", '".$verso_categories."') 233 ON DUPLICATE KEY UPDATE image_id = ".$_POST['b2f_front_id'].", categories = '".$verso_categories."';"); 234 222 $query = ' 223 INSERT INTO '.B2F_TABLE.' 224 VALUES( 225 '.$_POST['b2f_front_id'].', 226 '.$_GET['image_id'].', 227 "'.$verso_categories.'" 228 ) 229 ON DUPLICATE KEY UPDATE 230 image_id = '.$_POST['b2f_front_id'].', 231 categories = "'.$verso_categories.'" 232 ;'; 233 pwg_query($query); 234 235 235 $template->assign(array( 236 236 'B2F_IS_VERSO' => 'checked="checked"', … … 240 240 $verso['id'] = $_POST['b2f_front_id']; 241 241 $verso['link'] = get_root_url().'admin.php?page=photo-'.$verso['id']; 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>'))); 242 243 array_push($page['infos'], sprintf( 244 l10n('This picture is now the backside of the picture n°%s'), 245 '<a href="'.$verso['link'].'">'.$verso['id'].'</a>' 246 )); 243 247 } 244 248 } … … 247 251 { 248 252 /* search if it was a verso */ 249 $query = "SELECT categories 250 FROM ".B2F_TABLE." 251 WHERE verso_id = ".$_GET['image_id'].";"; 253 $query = ' 254 SELECT categories 255 FROM '.B2F_TABLE.' 256 WHERE verso_id = '.$_GET['image_id'].' 257 ;'; 252 258 $result = pwg_query($query); 253 259 254 /* it must be restored to its original categories (see criteria on maintain.inc)*/260 /* it must be restored to its original categories */ 255 261 if (pwg_db_num_rows($result)) 256 262 { 257 263 $item['verso_id'] = $_GET['image_id']; 258 264 list($item['categories']) = pwg_db_fetch_row($result); 265 259 266 back2front_restaure_categories($item); 260 261 pwg_query("DELETE FROM ".B2F_TABLE." 262 WHERE verso_id = ".$_GET['image_id'].";"); 263 267 pwg_query('DELETE FROM '.B2F_TABLE.' WHERE verso_id = '.$_GET['image_id'].';'); 264 268 array_push($page['infos'], l10n('This picture is no longer a backside')); 265 269 } … … 273 277 274 278 /* is the picture a verso ? */ 275 $query = "276 277 FROM ".B2F_TABLE."278 WHERE verso_id = ".$_GET['image_id']."279 ;";279 $query = ' 280 SELECT image_id, categories 281 FROM '.B2F_TABLE.' 282 WHERE verso_id = '.$_GET['image_id'].' 283 ;'; 280 284 $result = pwg_query($query); 281 285 … … 283 287 { 284 288 list($recto_id, $cats) = pwg_db_fetch_row($result); 289 285 290 $template->assign(array( 286 291 'B2F_IS_VERSO' => 'checked="checked"', … … 292 297 else 293 298 { 294 $query = "SELECT verso_id 295 FROM ".B2F_TABLE." 296 WHERE image_id = ".$_GET['image_id'].";"; 299 $query = ' 300 SELECT verso_id 301 FROM '.B2F_TABLE.' 302 WHERE image_id = '.$_GET['image_id'].' 303 ;'; 297 304 $result = pwg_query($query); 298 305 … … 309 316 } 310 317 311 $template->set_prefilter('picture_modify', ' Back2front_picture_modify_prefilter');318 $template->set_prefilter('picture_modify', 'back2front_picture_modify_prefilter'); 312 319 } 313 320 314 321 315 function Back2front_picture_modify_prefilter($content, &$smarty)322 function back2front_picture_modify_prefilter($content, &$smarty) 316 323 { 317 324 $search = '</form>'; … … 324 331 * Add mark on thumbnails list 325 332 */ 326 function Back2Front_thumbnails($tpl_thumbnails_var)333 function back2front_thumbnails($tpl_thumbnails_var) 327 334 { 328 335 global $conf, $selection; 329 336 330 $conf['back2front'] = explode(',',$conf['back2front']); 331 if (!$conf['back2front'][5]) return $tpl_thumbnails_var; 337 if (!$conf['back2front']['show_thumbnail']) return $tpl_thumbnails_var; 332 338 if (empty($tpl_thumbnails_var)) return $tpl_thumbnails_var; 333 339 334 340 /* has the pictures a verso ? */ 335 $query = "SELECT image_id 336 FROM ".B2F_TABLE." 337 WHERE image_id IN(".implode(',', $selection).");"; 341 $query = ' 342 SELECT image_id 343 FROM '.B2F_TABLE.' 344 WHERE image_id IN('.implode(',', $selection).') 345 ;'; 338 346 $ids = array_from_query($query, 'image_id'); 339 347 -
extensions/Back2Front/include/functions.inc.php
r23167 r23177 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 3 4 /* $item = array('verso_id', 'categories'); */ 4 /* 5 * restore verso to its original categories 6 * criterias : 7 * - verso 'versos' cat only => restore verso to original categories 8 * - otherwise nothing is changed 9 * 10 * $item = array('verso_id', 'categories'); 11 */ 5 12 function back2front_restaure_categories($item) 6 13 { 7 14 global $conf; 8 15 9 16 /* catch current verso categories */ 10 $versos_infos = pwg_query("SELECT category_id FROM ".IMAGE_CATEGORY_TABLE." WHERE image_id = ".$item['verso_id'].";"); 11 $item['current_verso_cats'] = array(); 12 while (list($verso_cat) = pwg_db_fetch_row($versos_infos)) 13 { 14 $item['current_verso_cats'][] = $verso_cat; 15 } 17 $query = 'SELECT DISTINCT category_id FROM '.IMAGE_CATEGORY_TABLE.' WHERE image_id = '.$item['verso_id'].';'; 18 $item['current_verso_cats'] = array_from_query($query, 'category_id'); 16 19 17 20 /* if verso 'versos' cat only */ 18 if (count($item['current_verso_cats']) == 1 AND $item['current_verso_cats'][0] == $conf['back2front'][0])21 if (count($item['current_verso_cats']) == 1 && $item['current_verso_cats'][0] == $conf['back2front']['versos_cat']) 19 22 { 20 23 foreach (explode(',',$item['categories']) as $cat) … … 36 39 } 37 40 38 pwg_query("DELETE FROM ".IMAGE_CATEGORY_TABLE." 39 WHERE image_id = ".$item['verso_id']." AND category_id = ".$conf['back2front'][0].";"); 41 $query = ' 42 DELETE FROM '.IMAGE_CATEGORY_TABLE.' 43 WHERE image_id = '.$item['verso_id'].' 44 AND category_id = '.$conf['back2front']['versos_cat'].' 45 ;'; 46 pwg_query($query); 47 } 48 49 function back2front_check_storage() 50 { 51 global $conf; 52 53 if ($conf['back2front']['versos_cat'] != 0) 54 { 55 $query = ' 56 SELECT COUNT(*) FROM '.CATEGORIES_TABLE.' 57 WHERE id = '.$conf['back2front']['versos_cat'].' 58 AND name = "Back2Front private album" 59 ;'; 60 $result = pwg_query($query); 61 62 if (pwg_db_num_rows($result)) 63 { 64 return; 65 } 66 } 67 68 $versos_cat = create_virtual_category('Back2Front private album'); 69 $versos_cat = array( 70 'id' => $versos_cat['id'], 71 'comment' => 'Used by Back2Front to store backsides.', 72 'status' => 'private', 73 'visible' => 'false', 74 'commentable' => 'false', 75 ); 76 77 mass_updates( 78 CATEGORIES_TABLE, 79 array( 80 'primary' => array('id'), 81 'update' => array_diff(array_keys($versos_cat), array('id')) 82 ), 83 array($versos_cat) 84 ); 85 86 $conf['back2front']['versos_cat'] = $versos_cat['id']; 87 conf_update_param('back2front', serialize($conf['back2front'])); 40 88 } 41 89 42 90 function picture_exists($id) 43 91 { 44 if (!preg_match('#([0-9]{1,})#', $id) OR$id == '0') return false;92 if (!preg_match('#([0-9]{1,})#', $id) || $id == '0') return false; 45 93 46 94 $query = "SELECT id FROM ".IMAGES_TABLE." WHERE id = ".$id.";"; -
extensions/Back2Front/language/en_UK/plugin.lang.php
r21335 r23177 22 22 $lang['...of the picture n°'] = '...of the picture n°'; 23 23 $lang['Backside management'] = 'Backside management'; 24 $lang[' Move backside to private album'] = 'Move backside to private album';24 $lang['Hide backside from albums'] = 'Hide backside from albums'; 25 25 $lang['This picture has a backside :'] = 'This picture has a backside: '; 26 26 -
extensions/Back2Front/language/fr_FR/plugin.lang.php
r12361 r23177 22 22 $lang['...of the picture n°'] = '...de l\'image n°'; 23 23 $lang['Backside management'] = 'Gestion des recto-verso'; 24 $lang[' Move backside to private album'] = 'Déplacer le verso vers un album privé';24 $lang['Hide backside from albums'] = 'Masquer le verso dans les albums'; 25 25 $lang['This picture has a backside :'] = 'Cette image a un verso : '; 26 26 -
extensions/Back2Front/main.inc.php
r21213 r23177 12 12 global $prefixeTable; 13 13 14 define ('B2F_DIR', basename(dirname(__FILE__)));15 define('B2F_PATH', PHPWG_PLUGINS_PATH . B2F_ DIR. '/');14 defined('B2F_ID') or define('B2F_ID', basename(dirname(__FILE__))); 15 define('B2F_PATH', PHPWG_PLUGINS_PATH . B2F_ID . '/'); 16 16 define('B2F_TABLE', $prefixeTable . 'image_verso'); 17 define('B2F_ADMIN', get_root_url() . 'admin.php?page=plugin-' . B2F_ID); 18 define('B2F_VERSION', 'auto'); 17 19 18 include_once(B2F_PATH . ' Back2Front.php');20 include_once(B2F_PATH . 'include/Back2Front.php'); 19 21 20 add_event_handler('init', ' Back2Front_init');22 add_event_handler('init', 'back2front_init'); 21 23 22 function Back2Front_init()24 function back2front_init() 23 25 { 26 global $conf, $pwg_loaded_plugins; 27 28 if ( 29 B2F_VERSION == 'auto' or 30 $pwg_loaded_plugins[B2F_ID]['version'] == 'auto' or 31 version_compare($pwg_loaded_plugins[B2F_ID]['version'], B2F_VERSION, '<') 32 ) 33 { 34 include_once(B2F_PATH . 'include/install.inc.php'); 35 back2front_install(); 36 37 if ( $pwg_loaded_plugins[B2F_ID]['version'] != 'auto' and B2F_VERSION != 'auto' ) 38 { 39 $query = ' 40 UPDATE '. PLUGINS_TABLE .' 41 SET version = "'. B2F_VERSION .'" 42 WHERE id = "'. B2F_ID .'"'; 43 pwg_query($query); 44 45 $pwg_loaded_plugins[B2F_ID]['version'] = B2F_VERSION; 46 47 if (defined('IN_ADMIN')) 48 { 49 $_SESSION['page_infos'][] = 'Back2Front updated to version '. B2F_VERSION; 50 } 51 } 52 } 53 54 $conf['back2front'] = unserialize($conf['back2front']); 24 55 load_language('plugin.lang', B2F_PATH); 25 56 } … … 27 58 if (script_basename() == 'picture') 28 59 { 29 add_event_handler('render_element_content', ' Back2Front_picture_content', EVENT_HANDLER_PRIORITY_NEUTRAL+20, 2);60 add_event_handler('render_element_content', 'back2front_picture_content', EVENT_HANDLER_PRIORITY_NEUTRAL+20, 2); 30 61 } 31 62 32 63 if (script_basename() == 'index') 33 64 { 34 add_event_handler('loc_end_index_thumbnails', ' Back2Front_thumbnails');65 add_event_handler('loc_end_index_thumbnails', 'back2front_thumbnails'); 35 66 } 36 67 37 68 if (script_basename() == 'admin') 38 69 { 39 add_event_handler('loc_begin_admin_page', ' Back2Front_picture_modify');70 add_event_handler('loc_begin_admin_page', 'back2front_picture_modify'); 40 71 41 add_event_handler('get_admin_plugin_menu_links', ' Back2Front_admin_menu');42 function Back2Front_admin_menu($menu)72 add_event_handler('get_admin_plugin_menu_links', 'back2front_admin_menu'); 73 function back2front_admin_menu($menu) 43 74 { 44 75 array_push($menu, array( 45 76 'NAME' => 'Back2Front', 46 'URL' => get_root_url().'admin.php?page=plugin-' . B2F_DIR)); 77 'URL' => B2F_ADMIN, 78 )); 47 79 return $menu; 48 80 } -
extensions/Back2Front/maintain.inc.php
r12648 r23177 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 3 4 include_once(PHPWG_PLUGINS_PATH.'Back2Front/functions.inc.php'); 4 defined('B2F_ID') or define('B2F_ID', basename(dirname(__FILE__))); 5 include_once(PHPWG_PLUGINS_PATH . B2F_ID . '/include/install.inc.php'); 6 include_once(PHPWG_PLUGINS_PATH . B2F_ID . '/include/functions.inc.php'); 5 7 6 8 function plugin_install() 7 9 { 8 global $prefixeTable; 9 10 /* create table for recto/verso pairs | stores original verso categories */ 11 pwg_query("CREATE TABLE IF NOT EXISTS `" . $prefixeTable . "image_verso` ( 12 `image_id` mediumint(8) unsigned NOT NULL DEFAULT '0', 13 `verso_id` mediumint(8) unsigned NOT NULL DEFAULT '0', 14 `categories` varchar(128) NULL, 15 PRIMARY KEY (`image_id`), 16 UNIQUE KEY (`verso_id`) 17 ) DEFAULT CHARSET=utf8;"); 10 back2front_install(); 18 11 19 /* create a virtual category to store versos */ 20 $versos_cat = create_virtual_category('Back2Front private album'); 21 $versos_cat = array( 22 'id' => $versos_cat['id'], 23 'comment' => 'Used by Back2Front to store backsides.', 24 'status' => 'private', 25 'visible' => 'false', 26 'commentable' => 'false', 27 ); 28 mass_updates( 29 CATEGORIES_TABLE, 30 array( 31 'primary' => array('id'), 32 'update' => array_diff(array_keys($versos_cat), array('id')) 33 ), 34 array($versos_cat) 35 ); 36 37 /* config parameter */ 38 pwg_query("INSERT INTO `" . CONFIG_TABLE . "` 39 VALUES ('back2front', '".$versos_cat['id'].",click,none,top,".serialize(array('default'=>null)).",1', 'Configuration for Back2Front plugin');"); 12 define('back2front_installed', true); 40 13 } 41 14 42 15 function plugin_activate() 43 16 { 44 global $conf; 45 46 47 $conf['back2front'] = explode(',', $conf['back2front']); 48 49 if (!isset($conf['back2front'][3])) 17 if (!defined('back2front_installed')) 50 18 { 51 $conf['back2front'][3] = 'top'; 52 $conf['back2front'][4] = serialize(array('default'=>null)); 19 back2front_install(); 53 20 } 54 if (!isset($conf['back2front'][5]))55 {56 $conf['back2front'][5] = true;57 }58 59 conf_update_param('back2front', implode (',', $conf['back2front']));60 21 } 61 22 62 23 63 function plugin_uninstall() { 24 function plugin_uninstall() 25 { 64 26 global $conf, $prefixeTable; 65 27 66 $conf['back2front'] = explode(',',$conf['back2front']);28 $conf['back2front'] = unserialize($conf['back2front']); 67 29 68 /* versos must be restored to their original categories69 criterias :70 - verso 'versos' cat only => restore verso to original categories71 - otherwise nothing is changed72 */73 74 30 $query = "SELECT * FROM `" . $prefixeTable . "image_verso`;"; 75 31 $images_versos = pwg_query($query); … … 82 38 pwg_query("DROP TABLE `" . $prefixeTable . "image_verso`;"); 83 39 pwg_query("DELETE FROM `" . CONFIG_TABLE . "` WHERE param = 'back2front';"); 84 pwg_query("DELETE FROM `" . CATEGORIES_TABLE ."`WHERE id = ".$conf['back2front'][ 0].";");40 pwg_query("DELETE FROM `" . CATEGORIES_TABLE ."`WHERE id = ".$conf['back2front']['versos_cat'].";"); 85 41 86 / * rebuild categories cache */42 // rebuild categories cache 87 43 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 88 44 invalidate_user_cache(true); -
extensions/Back2Front/template/picture_modify.tpl
r21212 r23177 33 33 34 34 <tr class="frontside_param" {if !isset($B2F_IS_VERSO)}style="display:none;"{/if}> 35 <td><b>{' Move backside to private album'|@translate}</b></td>35 <td><b>{'Hide backside from albums'|@translate}</b></td> 36 36 <td><input type="checkbox" name="b2f_move_verso" {$B2F_MOVE_VERSO}></td> 37 37 </tr>
Note: See TracChangeset
for help on using the changeset viewer.