/** 
  *	Generates the widget that displays the themes as a list of links.
  *
  *	@author		Nate Jacobs
  *	@since		0.1
  *
  *	@param		array
  *	@param		array
  */
 public function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     //call functions class and use get method to retrieve list of themes
     $brickset = new BricksetAPISearch();
     $themes = $brickset->get_themes();
     // check for errors
     if (is_wp_error($brickset)) {
         echo $brickset->get_error_message();
     } else {
         foreach ($themes as $theme) {
             echo "<a href='http://www.brickset.com/browse/themes/?theme={$theme->theme}'>" . $theme->theme . '</a>';
             echo '<br>';
         }
         echo $after_widget;
     }
 }
 /** 
  *	Generates the widget that displays the set details.
  *
  *	@author		Nate Jacobs
  *	@date		6/9/13
  *	@since		1.0
  *
  *	@param		array
  *	@param		array
  */
 public function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['set_number']);
     echo $before_widget;
     if ($title) {
         echo $before_title . 'Set Number: ' . $title . $after_title;
     }
     //call functions class and use get method to retrieve list of themes
     $brickset = new BricksetAPISearch();
     $set = $brickset->get_by_number($instance['set_number']);
     // check for errors
     if (is_wp_error($brickset)) {
         echo $brickset->get_error_message();
     } else {
         global $brickset_api_utilities;
         $settings = $brickset_api_utilities->get_settings_rules();
         $number = '';
         $numberVariant = '';
         foreach ($set as $result) {
             $number = sanitize_text_field($result->number);
             $numberVariant = sanitize_text_field($result->numberVariant);
             if (true === $settings['bricklink']) {
                 $bricklink = '<strong>' . __('BrickLink', 'bs_api') . ': </strong><a href=http://www.bricklink.com/catalogItem.asp?S=' . $number . '-' . $numberVariant . '>BrickLink</a><br><hr>';
             } elseif (false === $settings['bricklink']) {
                 $bricklink = '';
             }
             if (empty($result->{$settings}['currency_key']) && 'unk' === $settings['currency_unknown']) {
                 $result->{$settings}['currency_key'] = __(' Unknown', 'bs_api');
             }
             if (empty($result->{$settings}['currency_key']) && 'us' === $settings['currency_unknown']) {
                 $settings['currency'] = 'US';
                 $settings['currency_key'] = 'USRetailPrice';
                 $settings['currency_symbol'] = '&#36;';
             }
             echo '<img src="' . $result->imageURL . '"><br>';
             echo '<strong>' . __('Set Name', 'bs_api') . ': </strong>' . sanitize_text_field($result->setName) . '<br>';
             echo '<strong>' . __('Set Number', 'bs_api') . ': </strong>' . $number . '-' . $numberVariant . '<br>';
             echo '<strong>' . __('Year', 'bs_api') . ': </strong>' . sanitize_text_field($result->year) . '<br>';
             echo '<strong>' . __('Theme', 'bs_api') . ': </strong>' . sanitize_text_field($result->theme) . '<br>';
             echo '<strong>' . __('Subtheme', 'bs_api') . ': </strong>' . sanitize_text_field($result->subtheme) . '<br>';
             echo '<strong>' . sprintf(__('%s Retail Price', 'bs_api'), $settings['currency']) . ': </strong>' . $settings['currency_symbol'] . sanitize_text_field($result->{$settings}['currency_key']) . '<br>';
             echo '<strong>' . __('Pieces', 'bs_api') . ': </strong>' . sanitize_text_field($result->pieces) . '<br>';
             echo '<strong>' . __('Minifigs', 'bs_api') . ': </strong>' . sanitize_text_field($result->minifigs) . '<br>';
             echo '<strong>' . __('Set Guide', 'bs_api') . ': </strong><a href=' . esc_url($result->bricksetURL) . '>Brickset</a><br>';
             echo $bricklink;
         }
         echo $after_widget;
     }
 }
 /** 
  *	My Owned
  *
  *	Returns a table with the post authors owned sets
  *	Not functional yet.
  *
  *	@author		Nate Jacobs
  *	@date		2/16/13
  *	@since		1.0
  */
 public function my_owned()
 {
     global $post;
     $user_id = $post->post_author;
     parent::get_owned($user_id);
     $return = '<h2>My Set List</h2>';
     $return .= '<table><th>Image</th><th>Set Name</th><th>Set Number</th><th>Pieces</th><th>Quantity</th>';
     foreach ($this->results as $result) {
         $return .= '<tr>';
         $return .= '<td><img src="' . $result->thumbnailURL . '"></td>';
         $return .= '<td>' . $result->setName . '</td>';
         $return .= '<td>' . $result->number . '</td>';
         $return .= '<td>' . $result->pieces . '</td>';
         $return .= '<td>' . $result->qtyOwned . '</td>';
         $return .= '</tr>';
     }
     $return .= '</table>';
     return $return;
 }
 /** 
  *	Generates the widget that displays a count of total owned minifigs.
  *
  *	@author		Nate Jacobs
  *	@date		9/12/13
  *	@since		1.4
  *
  *	@param		array
  *	@param		array
  */
 public function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     //call functions class and use get method to retrieve list of minifigs
     $brickset = new BricksetAPISearch();
     $minifigs = $brickset->get_minifig_collection((int) $instance['user_id'], array('owned' => true));
     $user = get_userdata((int) $instance['user_id']);
     // check for errors
     if (is_wp_error($brickset)) {
         echo $brickset->get_error_message();
     } else {
         $count = 0;
         foreach ($minifigs as $minifig) {
             $count += $minifig->ownedTotal;
         }
         echo $user->display_name . ' - ' . $count;
         echo $after_widget;
     }
 }
 /** 
  *	Generates the widget that displays the themes as a list of links.
  *
  *	@author		Nate Jacobs
  *	@date		09/13/13
  *	@since		1.4
  *
  *	@param		array
  *	@param		array
  */
 public function widget($args, $instance)
 {
     extract($args);
     $themeName = apply_filters('widget_title', $instance['themeName']);
     echo $before_widget;
     if ($themeName) {
         echo $before_title . $themeName . ' - ' . __(' Years Available', 'bs_api') . $after_title;
     }
     //call functions class and use get method to retrieve list of years the theme was available
     $brickset = new BricksetAPISearch();
     $years = $brickset->get_theme_years($themeName);
     // check for errors
     if (is_wp_error($brickset)) {
         echo $brickset->get_error_message();
     } else {
         foreach ($years as $year) {
             $url = "http://brickset.com/browse/years/?year={$year->year}&Theme=" . urlencode($year->theme);
             echo __('Year', 'bs_api') . ': ' . $year->year;
             echo '<br>';
             echo __('Number of Sets', 'bs_api') . ': <a href=' . $url . '>' . $year->setCount . '</a>';
             echo '<hr>';
         }
         echo $after_widget;
     }
 }
Exemplo n.º 6
0
 /** 
  *	Takes a theme name from the Brickset URL and displays information about all the sets in that theme in a table
  *
  *	@author		Nate Jacobs
  *	@date		3/10/13
  *	@since		1.0
  *
  *	@param		string	the theme to display
  */
 public function oembed_theme($theme)
 {
     // Call the API function
     $brickset = parent::get_by_theme($theme);
     // Build the Oembed class
     $response = new stdClass();
     $response->type = 'rich';
     $response->width = '10';
     $response->height = '10';
     $response->version = '1.0';
     $response->title = 'Theme List';
     $response->html = '<div class="brickset-oembed-theme">';
     // Check for errors
     if (is_wp_error($brickset)) {
         $response->html .= '<p>' . $brickset->get_error_message() . '</p>';
     } else {
         // Loop through and display the info about the sets in the theme
         $response->html .= '<table class="brickset-theme-sets"><th>' . __('Image', 'bs_api') . '</th><th>' . __('Set Name', 'bs_api') . '</th><th>' . __('Set Number', 'bs_api') . '</th><th>' . __('Year', 'bs_api') . '</th><th>' . __('Pieces', 'bs_api') . '</th>';
         foreach ($brickset as $updated) {
             $response->html .= '<tr>';
             $response->html .= '<td><img src="' . $updated->thumbnailURL . '"></td>';
             $response->html .= '<td>' . $updated->setName . '</td>';
             $response->html .= '<td>' . $updated->number . '-' . $updated->numberVariant . '</td>';
             $response->html .= '<td>' . $updated->year . '</td>';
             $response->html .= '<td>' . $updated->pieces . '</td>';
             $response->html .= '</tr>';
         }
         $response->html .= '</table>';
     }
     $response->html .= '</div>';
     header('Content-Type: application/json');
     echo json_encode($response);
     die;
 }