Changeset 16301


Ignore:
Timestamp:
Jul 2, 2012, 10:52:52 PM (12 years ago)
Author:
rvelices
Message:

rv_sitemap add urls to picture pages

Location:
extensions/rv_sitemap
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/rv_sitemap/changelog.txt

    r16005 r16301  
     12.4.b
     2        - urls for picture pages
     3        - extended as images sitemap
     4
    152.4.a
    26        - compatible piwigo 2.4
  • 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  );
  • extensions/rv_sitemap/sitemap.tpl

    r12431 r16301  
    4848</fieldset>
    4949
     50<fieldset>
     51<legend>{'Recent photos'|@translate}</legend>
     52<input type="input" size="4" name="photo_count" value="{$PHOTO_COUNT}"/>
     53</fieldset>
     54
    5055
    5156<p>
  • extensions/rv_sitemap/sitemap.xsl

    r3417 r16301  
    22<xsl:stylesheet version="2.0"
    33                xmlns:html="http://www.w3.org/TR/REC-html40"
     4                                xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
    45                xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
    56                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     
    1011                                <title>XML Sitemap</title>
    1112                                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     13                                <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
     14                                <!-- <script type="text/javascript" src="jquery.tablesorter.min.js"></script>
     15                                <script type="text/javascript"><![CDATA[
     16                                        $(document).ready(function() {
     17                                        $("#sitemap").tablesorter( { widgets: ['zebra'] } );
     18                                        });
     19                                ]]></script> -->
    1220                                <style type="text/css">
    1321                                        body {
    14                                                 font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana;
    15                                                 font-size:13px;
     22                                                font-family: Helvetica, Arial, sans-serif;
     23                                                font-size: 13px;
     24                                                color: #545353;
    1625                                        }
    17                                        
    18                                         #intro {
    19                                                 border:1px black solid;
    20                                                 padding:5px 13px 5px 13px;
    21                                                 margin:10px;
     26                                        table {
     27                                                border: none;
     28                                                border-collapse: collapse;
    2229                                        }
    23                                        
    24                                         #intro p {
    25                                                 line-height:    16.8667px;
     30                                        #sitemap tr.odd {
     31                                                background-color: #eee;
    2632                                        }
    27                                        
     33                                        #sitemap tbody tr:hover {
     34                                                background-color: #ccc;
     35                                        }
     36                                        #sitemap tbody tr:hover td, #sitemap tbody tr:hover td a {
     37                                                color: #000;
     38                                        }
     39                                        #content {
     40                                                margin: 0 auto;
     41                                                width: 1000px;
     42                                        }
     43                                        .expl {
     44                                                margin: 10px 3px;
     45                                                line-height: 1.3em;
     46                                        }
     47                                        .expl a {
     48                                                color: #da3114;
     49                                                font-weight: bold;
     50                                        }
     51                                        a {
     52                                                color: #000;
     53                                                text-decoration: none;
     54                                        }
     55                                        a:visited {
     56                                                color: #777;
     57                                        }
     58                                        a:hover {
     59                                                text-decoration: underline;
     60                                        }
    2861                                        td {
    2962                                                font-size:11px;
    3063                                        }
    31                                        
    3264                                        th {
    3365                                                text-align:left;
     
    3567                                                font-size:11px;
    3668                                        }
    37                                        
    38                                         tr.high {
    39                                                 background-color:whitesmoke;
    40                                         }
    41                                        
    42                                         #footer {
    43                                                 padding:2px;
    44                                                 margin:10px;
    45                                                 font-size:8pt;
    46                                                 color:gray;
    47                                         }
    48                                        
    49                                         #footer a {
    50                                                 color:gray;
    51                                         }
    52                                        
    53                                         a {
    54                                                 color:black;
     69                                        thead th {
     70                                                border-bottom: 1px solid #000;
     71                                                cursor: pointer;
    5572                                        }
    5673                                </style>
    5774                        </head>
    5875                        <body>
    59                                 <h1>XML Sitemap</h1>
    60                                 <div id="intro">
    61                                         <p>
    62                                                 This is a XML Sitemap which is supposed to be processed by search engines like <a href="http://www.google.com">Google</a>, <a href="http://search.msn.com">MSN Search</a> and <a href="http://www.yahoo.com">YAHOO</a>.<br />
    63                                                 You can find more information about XML sitemaps on <a href="http://sitemaps.org">sitemaps.org</a> and Google's <a href="http://code.google.com/sm_thirdparty.html">list of sitemap programs</a>.
     76                                <div id="content">
     77                                        <h1>XML Sitemap</h1>
     78                                        <p class="expl">
     79                                                Generated by <a href="http://yoast.com/">Yoast</a>'s WordPress SEO plugin, this is an XML Sitemap, meant for consumption by search engines.
    6480                                        </p>
    65                                 </div>
    66                                 <div id="content">
    67                                         <table cellpadding="5">
    68                                                 <tr style="border-bottom:1px black solid;">
    69                                                         <th>URL</th>
    70                                                         <th>Priority</th>
    71                                                         <th>Change Frequency</th>
    72                                                         <th>LastChange</th>
    73                                                 </tr>
    74                                                 <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
    75                                                 <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
    76                                                 <xsl:for-each select="sitemap:urlset/sitemap:url">
     81                                        <p class="expl">
     82                                                You can find more information about XML sitemaps on <a href="http://sitemaps.org">sitemaps.org</a>.
     83                                        </p>
     84                                        <p class="expl">
     85                                                This sitemap contains <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> URLs.
     86                                        </p>                   
     87                                        <table id="sitemap" cellpadding="3">
     88                                                <thead>
    7789                                                        <tr>
    78                                                                 <xsl:if test="position() mod 2 != 1">
    79                                                                         <xsl:attribute  name="class">high</xsl:attribute>
    80                                                                 </xsl:if>
    81                                                                 <td>
    82                                                                         <xsl:variable name="itemURL">
    83                                                                                 <xsl:value-of select="sitemap:loc"/>
    84                                                                         </xsl:variable>
    85                                                                         <a href="{$itemURL}">
    86                                                                                 <xsl:value-of select="sitemap:loc"/>
    87                                                                         </a>
    88                                                                 </td>
    89                                                                 <td>
    90                                                                         <xsl:value-of select="concat(sitemap:priority*100,'%')"/>
    91                                                                 </td>
    92                                                                 <td>
    93                                                                         <xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/>
    94                                                                 </td>
    95                                                                 <td>
    96                                                                         <xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/>
    97                                                                 </td>
     90                                                                <th width="75%">URL</th>
     91                                                                <th width="5%">Priority</th>
     92                                                                <th width="5%">Images</th>
     93                                                                <th width="5%">Change Freq.</th>
     94                                                                <th width="10%">Last Change</th>
    9895                                                        </tr>
    99                                                 </xsl:for-each>
     96                                                </thead>
     97                                                <tbody>
     98                                                        <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
     99                                                        <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
     100                                                        <xsl:for-each select="sitemap:urlset/sitemap:url">
     101                                                                <tr>
     102                                                                        <td>
     103                                                                                <xsl:variable name="itemURL">
     104                                                                                        <xsl:value-of select="sitemap:loc"/>
     105                                                                                </xsl:variable>
     106                                                                                <a href="{$itemURL}">
     107                                                                                        <xsl:value-of select="sitemap:loc"/>
     108                                                                                </a>
     109                                                                        </td>
     110                                                                        <td>
     111                                                                                <xsl:value-of select="concat(sitemap:priority*100,'%')"/>
     112                                                                        </td>
     113                                                                        <td>
     114                                                                                <xsl:value-of select="count(image:image)"/>
     115                                                                        </td>
     116                                                                        <td>
     117                                                                                <xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/>
     118                                                                        </td>
     119                                                                        <td>
     120                                                                                <xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/>
     121                                                                        </td>
     122                                                                </tr>
     123                                                        </xsl:for-each>
     124                                                </tbody>
    100125                                        </table>
    101126                                </div>
Note: See TracChangeset for help on using the changeset viewer.