Ignore:
Timestamp:
Jul 26, 2012, 7:27:33 PM (8 years ago)
Author:
rvelices
Message:

rv_sitemap: ability to select which derivatives to include in the sitemap

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/rv_sitemap/sitemap.php

    r16940 r17144  
    226226  }
    227227
     228        $selected_derivatives = array();
    228229  if ($photo_count > 0)
    229230  {
     231                if (isset($_POST['selected_derivatives']))
     232                        $selected_derivatives = $_POST['selected_derivatives'];
     233
     234                foreach($selected_derivatives as $type)
     235                        $selected_derivatives_params[] = ImageStdParams::get_by_type($type);
     236
    230237    $query = 'SELECT DISTINCT i.* FROM '.IMAGES_TABLE.' i
    231238  INNER JOIN '.IMAGE_CATEGORY_TABLE.' on i.id=image_id
     
    242249      $src_image = new SrcImage($row);
    243250      $images_xml = '';
    244       foreach( array(IMG_THUMB, $conf['derivative_default_size']) as $derivative_type)
     251                        $done_iurls=array();
     252                        foreach( $selected_derivatives_params as $params )
    245253      {
    246         $deriv_url = DerivativeImage::url($derivative_type, $src_image);
    247         $images_xml .= '<image:image><image:loc>'.$deriv_url.'</image:loc></image:image>';
     254        $deriv_url = DerivativeImage::url($params, $src_image);
     255                                if (!isset($done_iurls[$deriv_url]))
     256                                {
     257                                        $done_iurls[$deriv_url] = 1;
     258                                        $images_xml .= '<image:image><image:loc>'.$deriv_url.'</image:loc></image:image>';
     259                                }
    248260      }
    249261      add_url($url, $row['date_available'], null, null, $images_xml);
     
    279291  $freq_tags = 'monthly';
    280292  $photo_count = 0;
     293        $selected_derivatives = array();
    281294
    282295  $conf_file_name = sitemaps_get_config_file_name();
     
    353366$template->assign('frequenciesT', $frequenciesT);
    354367
     368$available_derivatives = array();
     369foreach(array_keys(ImageStdParams::get_defined_type_map()) as $type)
     370{
     371        $available_derivatives[$type] = l10n($type);
     372}
     373$template->assign( array('available_derivatives'=>$available_derivatives, 'selected_derivatives' => $selected_derivatives));
     374
    355375$template->set_filename('sitemap', dirname(__FILE__).'/sitemap.tpl');
    356376$template->assign_var_from_handle('ADMIN_CONTENT', 'sitemap');
Note: See TracChangeset for help on using the changeset viewer.