Ignore:
Timestamp:
07/02/12 22:52:52 (7 years ago)
Author:
rvelices
Message:

rv_sitemap add urls to picture pages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/rv_sitemap/sitemap.php

    r13075 r16301  
    2020  out_xml('<?xml version="1.0" encoding="UTF-8"?'.'> 
    2121<?xml-stylesheet type="text/xsl" href="'.get_root_url().'plugins/'.basename(dirname(__FILE__)).'/sitemap.xsl"?'.'> 
    22 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">', $gzip ); 
     22<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">', $gzip ); 
    2323} 
    2424 
     
    3939} 
    4040 
    41 function add_url($url, $lastmod=null, $changefreq=null, $priority=null) 
     41function add_url($url, $lastmod=null, $changefreq=null, $priority=null, $images_xml=null) 
    4242{ 
    4343  $xml= 
     
    6363 <priority>'.$priority.'</priority>'; 
    6464 
     65  if ( isset($images_xml) ) 
     66    $xml .= "\n".$images_xml; 
     67   
    6568  $xml .= ' 
    6669</url>'; 
     
    123126while ($row = mysql_fetch_assoc($result)) 
    124127{ 
    125   array_push($categories, $row); 
     128  $categories[] = $row; 
    126129} 
    127130usort($categories, 'global_rank_compare'); 
     
    129132$tags = get_available_tags(); 
    130133usort($tags, 'name_compare'); 
    131  
    132 // END AS GUEST 
    133 $user = $save_user; 
    134134 
    135135if ( isset($_POST['submit']) ) 
     
    163163  $freq_tags = $_POST['freq_tags']; 
    164164 
     165  $photo_count = intval($_POST['photo_count']); 
     166   
    165167  set_make_full_url(); 
    166168 
     
    223225    } 
    224226  } 
     227   
     228  if ($photo_count > 0) 
     229  { 
     230    $query = 'SELECT DISTINCT i.* FROM '.IMAGES_TABLE.' i 
     231  INNER JOIN '.IMAGE_CATEGORY_TABLE.' on i.id=image_id  
     232'.get_sql_condition_FandF( array('forbidden_categories' => 'category_id', 'forbidden_images'=>'i.id'), 'WHERE ' ).' 
     233  ORDER BY date_available DESC 
     234  LIMIT '.$photo_count; 
     235    $result = pwg_query($query); 
     236    while ($row = mysql_fetch_assoc($result)) 
     237    { 
     238      $url = make_picture_url( array( 
     239        'image_id' => $row['id'], 
     240        'image_file' => $row['file'], 
     241        ) ); 
     242      $src_image = new SrcImage($row); 
     243      $images_xml = ''; 
     244      foreach( array(IMG_THUMB, $conf['derivative_default_size']) as $derivative_type) 
     245      { 
     246        $deriv_url = DerivativeImage::url($derivative_type, $src_image); 
     247        $images_xml .= '<image:image><image:loc>'.$deriv_url.'</image:loc></image:image>'; 
     248      } 
     249      add_url($url, $row['date_available'], null, null, $images_xml); 
     250    } 
     251  } 
    225252  unset_make_full_url(); 
    226253  end_xml($gzip); 
     
    237264  $x = compact( 'filename', 'selected_tag_urls', 'prio_tags', 'freq_tags', 
    238265  'selected_categories', 'prio_categories', 'freq_categories', 
    239   'selected_specials' ); 
     266  'selected_specials', 'photo_count' ); 
    240267  $file = fopen( sitemaps_get_config_file_name(), 'w' ); 
    241268  fwrite($file, serialize($x) ); 
     
    251278  $freq_categories = 'monthly'; 
    252279  $freq_tags = 'monthly'; 
     280  $photo_count = 0; 
    253281   
    254282  $conf_file_name = sitemaps_get_config_file_name(); 
     
    281309} 
    282310 
     311// END AS GUEST 
     312$user = $save_user; 
     313 
    283314 
    284315$template->assign( array( 
     
    288319  'PRIO_CATEGORIES' => $prio_categories, 
    289320  'PRIO_TAGS' => $prio_tags, 
     321  'PHOTO_COUNT' => $photo_count, 
    290322    ) 
    291323  ); 
Note: See TracChangeset for help on using the changeset viewer.