Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

+56 -5
View File
@@ -114,9 +114,10 @@ class _Sitemap
* @param string $filename Filename
* @param array $entries The entries to add. Each entry should be an array with at least the key 'url'. Optional keys 'lastmod', 'priority' and 'changefreq' are also supported.
* @param int $lastId The last ID we built. This is used for content items to allow us to more efficiently fetch the next batch of items to build.
* @param array $namespaces Array of additional namespaces to define
* @return void
*/
public function buildSitemapFile( $filename, $entries, $lastId=0 )
public function buildSitemapFile( $filename, $entries, $lastId=0, $namespaces=array() )
{
/* Start XML Document, set encoding, and create the namespaced index element */
$xmlWriter = new \XMLWriter();
@@ -126,6 +127,16 @@ class _Sitemap
$xmlWriter->startDocument( '1.0', 'UTF-8' );
$xmlWriter->startElementNS( NULL, 'urlset', "http://www.sitemaps.org/schemas/sitemap/0.9" );
if( count( $namespaces ) )
{
foreach( $namespaces as $prefix => $urn )
{
$xmlWriter->writeAttributeNS( 'xmlns', $prefix, NULL, $urn );
}
}
$defaultLanguage = \IPS\Lang::load( \IPS\Lang::defaultLanguage() );
if( count( $entries ) )
{
foreach( $entries as $entry )
@@ -139,7 +150,7 @@ class _Sitemap
if( isset( $entry['lastmod'] ) AND $entry['lastmod'] )
{
$xmlWriter->startElement( 'lastmod' );
$xmlWriter->text( \IPS\DateTime::ts( $entry['lastmod'] )->format('c') );
$xmlWriter->text( ( $entry['lastmod'] instanceof \IPS\DateTime ) ? $entry['lastmod']->format( 'c', $defaultLanguage ) : \IPS\DateTime::ts( $entry['lastmod'] )->format( 'c', $defaultLanguage ) );
$xmlWriter->endElement();
}
@@ -157,6 +168,48 @@ class _Sitemap
$xmlWriter->endElement();
}
if( count( $namespaces ) )
{
foreach( $entry as $key => $value )
{
foreach( $namespaces as $prefix => $urn )
{
if( mb_strpos( $key, $prefix . ':' ) === 0 )
{
$pieces = explode( ':', $key );
$xmlWriter->startElementNS( $pieces[0], $pieces[1], NULL );
foreach( $value as $k => $v )
{
$pieces = explode( ':', $k );
$xmlWriter->startElementNS( $pieces[0], $pieces[1], NULL );
if( is_array( $v ) )
{
foreach( $v as $index => $value )
{
if( $index !== 0 )
{
$xmlWriter->writeAttribute( $index, $value );
}
}
$xmlWriter->text( $v[0] );
}
else
{
$xmlWriter->text( $v );
}
$xmlWriter->endElement();
}
$xmlWriter->endElement();
}
}
}
}
$xmlWriter->endElement();
}
@@ -195,9 +248,7 @@ class _Sitemap
}
/* Update last ping time before the requests are made so if they time out, it won't attempt to try again for 24 hrs */
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => time() ), array( 'conf_key=?', 'sitemap_last_ping' ) );
\IPS\Settings::i()->sitemap_last_ping = time();
unset( \IPS\Data\Store::i()->settings );
\IPS\Settings::i()->changeValues( array( 'sitemap_last_ping' => time() ) );
/* Ping Google */
$response = \IPS\Http\Url::external( "http://www.google.com/webmasters/tools/ping?sitemap=" . urlencode( $this->sitemapUrl ) )->request()->get();