Changeset 4039 for extensions
- Timestamp:
- Oct 15, 2009, 12:20:17 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Public_Piwigo_WordPress_Widget/Public_WP_Piwigo_Widget.php
r4031 r4039 20 20 21 21 function widget($args, $gallery){ 22 global $wpdb; 22 23 extract($args); 23 24 $title = apply_filters('widget_title', empty($gallery['title']) ? ' ' : $gallery['title']); … … 29 30 if (!empty($gallery['category'])) $options = '&cat_id=' . intval($gallery['category']); 30 31 32 $from = empty($gallery['from']) ? '12' : intval($gallery['from']); 33 $r = (array) $wpdb->get_results('SELECT date_sub( date( now( ) ) , INTERVAL ' . $from . ' MONTH ) as begin'); 34 $from = $r[0]->begin; 35 if (!empty($gallery['from'])) $options .= '&f_min_date_created=' . $from; 36 37 $divclass = empty($gallery['divclass']) ? '' : ' class="' . $gallery['divclass'] .'"'; 38 $class = empty($gallery['class']) ? '' : ' class="' . $gallery['class'] .'"'; 39 31 40 echo $before_widget; 32 41 if ( $title ) echo $before_title . $title . $after_title; 33 42 34 43 # Make the Piwigo link 35 $response = file_get_contents( $piwigo_url . 'ws.php?method=pwg.categories.getImages&format=php '44 $response = file_get_contents( $piwigo_url . 'ws.php?method=pwg.categories.getImages&format=php&per_page=1' 36 45 . $options . '&recursive=true&order=random&f_with_thumbnail=true'); 37 46 $thumbc = unserialize($response); 38 47 if ($thumbc["stat"] == 'ok') { 39 48 $picture = $thumbc["result"]["images"]["_content"][0]; 40 echo '<a title="' . $title . '" href="' . $piwigo_url . 'picture.php?/' . $picture['id'] . '"><img src="' . $picture['tn_url'] . '" alt="" /></a>'; 49 echo '<div' . $divclass . '><a title="' . $title . '" href="' . $piwigo_url . 'picture.php?/' . $picture['id'] . '"><img ' 50 . $class . ' src="' . $picture['tn_url'] . '" alt="" /></a></div>'; 41 51 } 42 52 … … 49 59 $gallery['piwigo'] = strip_tags(stripslashes($new_gallery['piwigo'])); 50 60 $gallery['external'] = strip_tags(stripslashes($new_gallery['external'])); 51 $gallery['category'] = strip_tags(stripslashes($new_gallery['category'])); 61 $gallery['category'] = intval(strip_tags(stripslashes($new_gallery['category']))); 62 $gallery['from'] = intval(strip_tags(stripslashes($new_gallery['from']))); 63 $gallery['divclass'] = strip_tags(stripslashes($new_gallery['divclass'])); 64 $gallery['class'] = strip_tags(stripslashes($new_gallery['class'])); 52 65 53 66 return $gallery; … … 57 70 //Defaults 58 71 $gallery = wp_parse_args( (array) $gallery, array('title'=>__('Random picture'), 59 'piwigo'=>'piwigo', 'external'=>'', 'category'=>0, ) );72 'piwigo'=>'piwigo', 'external'=>'', 'category'=>0, 'from'=> 12, 'divclass'=>'', 'class'=>'', ) ); 60 73 61 74 $title = htmlspecialchars($gallery['title']); … … 63 76 $external = htmlspecialchars($gallery['external']); 64 77 $category = intval($gallery['category']); 78 $from = intval($gallery['from']); 79 $divclass = htmlspecialchars($gallery['divclass']); 80 $class = htmlspecialchars($gallery['class']); 65 81 66 82 # Options … … 72 88 . ' <input style="width: 200px;" id="' . $this->get_field_id('piwigo') . '" name="' . $this->get_field_name('piwigo') 73 89 . '" type="text" value="' . $piwigo . '" /></label></p>'; 90 # Optional parameters 91 echo '<h5>' . __('Piwigo optional parameters') . '</h5>'; 74 92 # External website 75 echo '<p style="text-align:right;"><label for="' . $this->get_field_name('external') . '">' . __(' OptionalPiwigo gallery URL (external):')93 echo '<p style="text-align:right;"><label for="' . $this->get_field_name('external') . '">' . __('Piwigo gallery URL (external):') 76 94 . ' <input style="width: 200px;" id="' . $this->get_field_id('external') . '" name="' . $this->get_field_name('external') 77 95 . '" type="text" value="' . $external . '" /></label></p>'; 78 96 # Category 79 echo '<p style="text-align:right;"><label for="' . $this->get_field_name('category') . '">' . __(' Select a category id (empty =all):')97 echo '<p style="text-align:right;"><label for="' . $this->get_field_name('category') . '">' . __('Piwigo category id (0=all):') 80 98 . ' <input style="width: 200px;" id="' . $this->get_field_id('category') . '" name="' . $this->get_field_name('category') 81 99 . '" type="text" value="' . $category . '" /></label></p>'; 82 } 100 # from 101 echo '<p style="text-align:right;"><label for="' . $this->get_field_name('from') . '">' . __('for X months (empty=all):') 102 . ' <input style="width: 200px;" id="' . $this->get_field_id('from') . '" name="' . $this->get_field_name('from') 103 . '" type="text" value="' . $from . '" /></label></p>'; 104 # divclass 105 echo '<p style="text-align:right;"><label for="' . $this->get_field_name('divclass') . '">' . __('CSS DIV class:') 106 . ' <input style="width: 200px;" id="' . $this->get_field_id('divclass') . '" name="' . $this->get_field_name('divclass') 107 . '" type="text" value="' . $divclass . '" /></label></p>'; 108 # class 109 echo '<p style="text-align:right;"><label for="' . $this->get_field_name('class') . '">' . __('CSS IMG class:') 110 . ' <input style="width: 200px;" id="' . $this->get_field_id('class') . '" name="' . $this->get_field_name('class') 111 . '" type="text" value="' . $class . '" /></label></p>'; 112 } 83 113 84 114 }
Note: See TracChangeset
for help on using the changeset viewer.