Last change
on this file since 10852 was
10852,
checked in by mistic100, 13 years ago
|
improve process, add options for link effect
|
File size:
1.3 KB
|
Line | |
---|
1 | <?php |
---|
2 | /* $item = array('verso_id', 'categories'); */ |
---|
3 | function back2front_restaure_categories($item) |
---|
4 | { |
---|
5 | global $conf; |
---|
6 | |
---|
7 | /* catch current verso categories */ |
---|
8 | $versos_infos = pwg_query("SELECT category_id FROM ".IMAGE_CATEGORY_TABLE." WHERE image_id = ".$item['verso_id'].";"); |
---|
9 | $item['current_verso_cats'] = array(); |
---|
10 | while (list($verso_cat) = pwg_db_fetch_row($versos_infos)) |
---|
11 | { |
---|
12 | $item['current_verso_cats'][] = $verso_cat; |
---|
13 | } |
---|
14 | |
---|
15 | /* if verso 'versos' cat only */ |
---|
16 | if (count($item['current_verso_cats']) == 1 AND $item['current_verso_cats'][0] == $conf['back2front'][0]) |
---|
17 | { |
---|
18 | foreach (explode(',',$item['categories']) as $cat) |
---|
19 | { |
---|
20 | $datas[] = array( |
---|
21 | 'image_id' => $item['verso_id'], |
---|
22 | 'category_id' => $cat, |
---|
23 | ); |
---|
24 | } |
---|
25 | } |
---|
26 | |
---|
27 | if (isset($datas)) |
---|
28 | { |
---|
29 | mass_inserts( |
---|
30 | IMAGE_CATEGORY_TABLE, |
---|
31 | array('image_id', 'category_id'), |
---|
32 | $datas |
---|
33 | ); |
---|
34 | } |
---|
35 | |
---|
36 | pwg_query("DELETE FROM ".IMAGE_CATEGORY_TABLE." |
---|
37 | WHERE image_id = ".$item['verso_id']." AND category_id = ".$conf['back2front'][0].";"); |
---|
38 | } |
---|
39 | |
---|
40 | function picture_exists($id) |
---|
41 | { |
---|
42 | if (!preg_match('#([0-9]{1,})#', $id) OR $id == '0') return false; |
---|
43 | |
---|
44 | $query = "SELECT id FROM ".IMAGES_TABLE." WHERE id = ".$id.";"; |
---|
45 | $result = pwg_query($query); |
---|
46 | |
---|
47 | if (pwg_db_num_rows($result)) return true; |
---|
48 | else return false; |
---|
49 | } |
---|
50 | |
---|
51 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.