1 | <?php |
---|
2 | if (defined('PHPWG_ROOT_PATH')) return; /* Avoid direct usage under Piwigo */ |
---|
3 | if (!defined('PWGP_NAME')) return; /* Avoid unpredicted access */ |
---|
4 | |
---|
5 | global $wpdb; /* Need for recent thumbnail access */ |
---|
6 | extract($args); |
---|
7 | |
---|
8 | $title = apply_filters('widget_title', empty($gallery['title']) ? ' ' : $gallery['title']); |
---|
9 | if ( $title ) $title = $before_title . $title . $after_title; |
---|
10 | |
---|
11 | $piwigo = empty($gallery['piwigo']) ? '' : $gallery['piwigo']; |
---|
12 | $piwigo_url = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $piwigo ; |
---|
13 | if (!empty($gallery['external'])) $piwigo_url = $gallery['external']; |
---|
14 | if (substr($piwigo_url,-1)!='/') $piwigo_url .= '/'; |
---|
15 | |
---|
16 | $thumbnail = empty($gallery['thumbnail']) ? '' : $gallery['thumbnail']; |
---|
17 | |
---|
18 | $options = ''; |
---|
19 | $number = empty($gallery['number']) ? 1 : intval($gallery['number']); |
---|
20 | $options .= '&per_page=' . $number; |
---|
21 | if (!empty($gallery['category'])) $options .= '&cat_id=' . intval($gallery['category']); |
---|
22 | $from = empty($gallery['from']) ? '12' : intval($gallery['from']); |
---|
23 | $r = (array) $wpdb->get_results('SELECT date_sub( date( now( ) ) , INTERVAL ' . $from . ' MONTH ) as begin'); |
---|
24 | $from = $r[0]->begin; |
---|
25 | if (!empty($gallery['from'])) $options .= '&f_min_date_created=' . $from; |
---|
26 | |
---|
27 | $PiwigoPress_divclass = empty($gallery['divclass']) ? '' : (' class="' . $gallery['divclass'] .'"'); |
---|
28 | $PiwigoPress_class = empty($gallery['class']) ? '' : (' class="' . $gallery['class'] .'"'); |
---|
29 | $mbcategories = empty($gallery['mbcategories']) ? '' : $gallery['mbcategories']; |
---|
30 | $most_visited = empty($gallery['most_visited']) ? '' : $gallery['most_visited']; |
---|
31 | $best_rated = empty($gallery['best_rated']) ? '' : $gallery['best_rated']; |
---|
32 | $most_commented = empty($gallery['most_commented']) ? '' : $gallery['most_commented']; |
---|
33 | $random = empty($gallery['random']) ? '' : $gallery['random']; |
---|
34 | $recent_pics = empty($gallery['recent_pics']) ? '' : $gallery['recent_pics']; |
---|
35 | $calendar = empty($gallery['calendar']) ? '' : $gallery['calendar']; |
---|
36 | $tags = empty($gallery['tags']) ? '' : $gallery['tags']; |
---|
37 | $comments = empty($gallery['comments']) ? '' : $gallery['comments']; |
---|
38 | |
---|
39 | echo $before_widget; |
---|
40 | echo $title; |
---|
41 | if (!function_exists('pwg_get_contents')) include 'PiwigoPress_get.php'; |
---|
42 | |
---|
43 | if ($thumbnail == 'true') { |
---|
44 | // Make the Piwigo link |
---|
45 | $response = pwg_get_contents( $piwigo_url |
---|
46 | . 'ws.php?method=pwg.categories.getImages&format=php' |
---|
47 | . $options . '&recursive=true&order=random&f_with_thumbnail=true'); |
---|
48 | $thumbc = unserialize($response); |
---|
49 | if ($thumbc["stat"] == 'ok') { |
---|
50 | $pictures = $thumbc["result"]["images"]["_content"]; |
---|
51 | foreach ($pictures as $picture) { |
---|
52 | echo '<div' . $PiwigoPress_divclass . '><a title="' . htmlspecialchars($picture['name']) . '" href="' |
---|
53 | . $piwigo_url . 'picture.php?/' . $picture['id'] . '"><img ' |
---|
54 | . $PiwigoPress_class . ' src="' . $picture['tn_url'] . '" alt="" /></a></div>'; |
---|
55 | } |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | if ($mbcategories == 'true') { |
---|
60 | // Make the Piwigo category list |
---|
61 | $response = pwg_get_contents( $piwigo_url |
---|
62 | . 'ws.php?method=pwg.categories.getList&format=php&public=true'); |
---|
63 | $cats = unserialize($response); |
---|
64 | if ($cats["stat"] == 'ok') { |
---|
65 | echo '<ul style="clear: both;"><li>' . __('Pictures categories','pwg') . '<ul>'; |
---|
66 | foreach ($cats["result"]["categories"] as $cat) { |
---|
67 | echo '<li><a title="' . $cat['name'] . '" href="' . $piwigo_url . 'index.php?category/' . $cat['id'] . '">' . $cat['name'] . '</a></li>'."\r\n"; |
---|
68 | } |
---|
69 | echo '</ul></li></ul>'."\r\n"; |
---|
70 | } |
---|
71 | } |
---|
72 | |
---|
73 | if ($most_visited == 'true' or $best_rated == 'true' or |
---|
74 | $most_commented == 'true' or $random == 'true' or $recent_pics == 'true' or |
---|
75 | $calendar == 'true' or $tags == 'true' or $comments == 'true') echo '<ul style="clear: both;">'; |
---|
76 | |
---|
77 | if ($most_visited == 'true') |
---|
78 | echo '<li><a title="' . __('Most visited','pwg') . '" href="' . $piwigo_url . 'index.php?most_visited' . '">' . __('Most visited','pwg') . '</a></li>'."\r\n"; |
---|
79 | |
---|
80 | if ($best_rated == 'true') |
---|
81 | echo '<li><a title="' . __('Best rated','pwg') . '" href="' . $piwigo_url . 'index.php?best_rated' . '">' . __('Best rated','pwg') . '</a></li>'."\r\n"; |
---|
82 | |
---|
83 | if ($most_commented == 'true') |
---|
84 | echo '<li><a title="' . __('Most commented','pwg') . '" href="' . $piwigo_url . 'index.php?most_commented' . '">' . __('Most commented','pwg') . '</a></li>'."\r\n"; |
---|
85 | |
---|
86 | if ($random == 'true') |
---|
87 | echo '<li><a title="' . __('Random','pwg') . '" href="' . $piwigo_url . 'random.php' . '">' . __('Random','pwg') . '</a></li>'."\r\n"; |
---|
88 | |
---|
89 | if ($recent_pics == 'true') |
---|
90 | echo '<li><a title="' . __('Recent pics','pwg') . '" href="' . $piwigo_url . 'index.php?recent_pics' . '">' . __('Recent pics','pwg') . '</a></li>'."\r\n"; |
---|
91 | |
---|
92 | if ($calendar == 'true') |
---|
93 | echo '<li><a title="' . __('Calendar','pwg') . '" href="' . $piwigo_url . 'index.php?created-monthly-calendar' . '">' . __('Calendar','pwg') . '</a></li>'."\r\n"; |
---|
94 | |
---|
95 | if ($tags == 'true') |
---|
96 | echo '<li><a title="' . __('Tags','pwg') . '" href="' . $piwigo_url . 'tags.php' . '">' . __('Tags','pwg') . '</a></li>'."\r\n"; |
---|
97 | |
---|
98 | if ($comments == 'true') |
---|
99 | echo '<li><a title="' . __('Comments','pwg') . '" href="' . $piwigo_url . 'comments.php' . '">' . __('Comments','pwg') . '</a></li>'."\r\n"; |
---|
100 | |
---|
101 | |
---|
102 | if ($most_visited == 'true' or $best_rated == 'true' or |
---|
103 | $most_commented == 'true' or $random == 'true' or $recent_pics == 'true' or |
---|
104 | $calendar == 'true' or $tags == 'true' or $comments == 'true') echo '</ul>'."\r\n"; |
---|
105 | |
---|
106 | echo $after_widget; |
---|
107 | |
---|
108 | ?> |
---|