[4055] | 1 | <?php |
---|
[4125] | 2 | if (defined('PHPWG_ROOT_PATH')) return; /* Avoid direct usage under Piwigo */ |
---|
| 3 | if (!defined('PWGP_NAME')) return; /* Avoid unpredicted access */ |
---|
[4055] | 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']); |
---|
[4314] | 20 | $options .= '&per_page=' . $number; |
---|
[4055] | 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 | |
---|
[4101] | 27 | $PiwigoPress_divclass = empty($gallery['divclass']) ? '' : (' class="' . $gallery['divclass'] .'"'); |
---|
| 28 | $PiwigoPress_class = empty($gallery['class']) ? '' : (' class="' . $gallery['class'] .'"'); |
---|
[4055] | 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; |
---|
[4125] | 41 | if (!function_exists('pwg_get_contents')) include 'PiwigoPress_get.php'; |
---|
[4055] | 42 | |
---|
| 43 | if ($thumbnail == 'true') { |
---|
| 44 | // Make the Piwigo link |
---|
[4125] | 45 | $response = pwg_get_contents( $piwigo_url |
---|
[4055] | 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) { |
---|
[4101] | 52 | echo '<div' . $PiwigoPress_divclass . '><a title="' . htmlspecialchars($picture['name']) . '" href="' |
---|
[4055] | 53 | . $piwigo_url . 'picture.php?/' . $picture['id'] . '"><img ' |
---|
[4101] | 54 | . $PiwigoPress_class . ' src="' . $picture['tn_url'] . '" alt="" /></a></div>'; |
---|
[4055] | 55 | } |
---|
| 56 | } |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | if ($mbcategories == 'true') { |
---|
| 60 | // Make the Piwigo category list |
---|
[4125] | 61 | $response = pwg_get_contents( $piwigo_url |
---|
[4055] | 62 | . 'ws.php?method=pwg.categories.getList&format=php&public=true'); |
---|
| 63 | $cats = unserialize($response); |
---|
| 64 | if ($cats["stat"] == 'ok') { |
---|
[4073] | 65 | echo '<ul style="clear: both;"><li>' . __('Pictures categories','pwg') . '<ul>'; |
---|
[4055] | 66 | foreach ($cats["result"]["categories"] as $cat) { |
---|
[4216] | 67 | echo '<li><a title="' . $cat['name'] . '" href="' . $piwigo_url . 'index.php?category/' . $cat['id'] . '">' . $cat['name'] . '</a></li>'."\r\n"; |
---|
[4055] | 68 | } |
---|
[4216] | 69 | echo '</ul></li></ul>'."\r\n"; |
---|
[4055] | 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') |
---|
[4216] | 78 | echo '<li><a title="' . __('Most visited','pwg') . '" href="' . $piwigo_url . 'index.php?most_visited' . '">' . __('Most visited','pwg') . '</a></li>'."\r\n"; |
---|
[4055] | 79 | |
---|
| 80 | if ($best_rated == 'true') |
---|
[4216] | 81 | echo '<li><a title="' . __('Best rated','pwg') . '" href="' . $piwigo_url . 'index.php?best_rated' . '">' . __('Best rated','pwg') . '</a></li>'."\r\n"; |
---|
[4055] | 82 | |
---|
| 83 | if ($most_commented == 'true') |
---|
[4216] | 84 | echo '<li><a title="' . __('Most commented','pwg') . '" href="' . $piwigo_url . 'index.php?most_commented' . '">' . __('Most commented','pwg') . '</a></li>'."\r\n"; |
---|
[4055] | 85 | |
---|
| 86 | if ($random == 'true') |
---|
[4216] | 87 | echo '<li><a title="' . __('Random','pwg') . '" href="' . $piwigo_url . 'random.php' . '">' . __('Random','pwg') . '</a></li>'."\r\n"; |
---|
[4055] | 88 | |
---|
| 89 | if ($recent_pics == 'true') |
---|
[4216] | 90 | echo '<li><a title="' . __('Recent pics','pwg') . '" href="' . $piwigo_url . 'index.php?recent_pics' . '">' . __('Recent pics','pwg') . '</a></li>'."\r\n"; |
---|
[4055] | 91 | |
---|
| 92 | if ($calendar == 'true') |
---|
[4216] | 93 | echo '<li><a title="' . __('Calendar','pwg') . '" href="' . $piwigo_url . 'index.php?created-monthly-calendar' . '">' . __('Calendar','pwg') . '</a></li>'."\r\n"; |
---|
[4055] | 94 | |
---|
| 95 | if ($tags == 'true') |
---|
[4216] | 96 | echo '<li><a title="' . __('Tags','pwg') . '" href="' . $piwigo_url . 'tags.php' . '">' . __('Tags','pwg') . '</a></li>'."\r\n"; |
---|
[4055] | 97 | |
---|
| 98 | if ($comments == 'true') |
---|
[4216] | 99 | echo '<li><a title="' . __('Comments','pwg') . '" href="' . $piwigo_url . 'comments.php' . '">' . __('Comments','pwg') . '</a></li>'."\r\n"; |
---|
[4055] | 100 | |
---|
| 101 | |
---|
| 102 | if ($most_visited == 'true' or $best_rated == 'true' or |
---|
| 103 | $most_commented == 'true' or $random == 'true' or $recent_pics == 'true' or |
---|
[4216] | 104 | $calendar == 'true' or $tags == 'true' or $comments == 'true') echo '</ul>'."\r\n"; |
---|
[4055] | 105 | |
---|
| 106 | echo $after_widget; |
---|
| 107 | |
---|
| 108 | ?> |
---|