Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

+141 -6
View File
@@ -1,13 +1,12 @@
<?php
/**
* @brief View Blog Entry Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Blog
* @since 03 Mar 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\blog\modules\front\blogs;
@@ -105,8 +104,144 @@ class _entry extends \IPS\Content\Controller
/* Online User Location */
\IPS\Session::i()->setLocation( $this->entry->url(), $this->entry->onlineListPermissions(), 'loc_blog_viewing_entry', array( $this->entry->name => FALSE ) );
/* Add JSON-ld output */
\IPS\Output::i()->jsonLd['blog'] = array(
'@context' => "http://schema.org",
'@type' => "Blog",
'url' => (string) $this->entry->container()->url(),
'name' => htmlspecialchars( $this->entry->container()->_title, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'description' => strip_tags( $this->entry->container()->description ),
'commentCount' => $this->entry->container()->_comments,
'interactionStatistic' => array(
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/ViewAction",
'userInteractionCount' => $this->entry->container()->num_views
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/FollowAction",
'userInteractionCount' => \IPS\blog\Entry::containerFollowerCount( $this->entry->container() )
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/CommentAction",
'userInteractionCount' => $this->entry->container()->_comments
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/WriteAction",
'userInteractionCount' => $this->entry->container()->_items
)
),
'blogPost' => array(
'@context' => "http://schema.org",
'@type' => "BlogPosting",
'url' => (string) $this->entry->url(),
'mainEntityOfPage' => (string) $this->entry->url(),
'name' => htmlspecialchars( $this->entry->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'headline' => htmlspecialchars( $this->entry->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'articleBody' => strip_tags( $this->entry->truncated() ),
'commentCount' => $this->entry->mapped('num_comments'),
'dateCreated' => \IPS\DateTime::ts( $this->entry->date )->format( \IPS\DateTime::ISO8601 ),
'datePublished' => \IPS\DateTime::ts( $this->entry->publish_date )->format( \IPS\DateTime::ISO8601 ),
'author' => array(
'@type' => 'Person',
'name' => htmlspecialchars( \IPS\Member::load( $this->entry->mapped('author') )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'url' => (string) \IPS\Member::load( $this->entry->mapped('author') )->url(),
'image' => \IPS\Member::load( $this->entry->mapped('author') )->get_photo()
),
'publisher' => array(
'@type' => 'Organization',
'name' => htmlspecialchars( \IPS\Member::load( $this->entry->mapped('author') )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'url' => (string) \IPS\Member::load( $this->entry->mapped('author') )->url(),
'image' => \IPS\Member::load( $this->entry->mapped('author') )->get_photo(),
'logo' => array(
'@type' => 'ImageObject',
'url' => \IPS\Member::load( $this->entry->mapped('author') )->get_photo(),
)
),
'interactionStatistic' => array(
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/ViewAction",
'userInteractionCount' => $this->entry->views
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/FollowAction",
'userInteractionCount' => \IPS\blog\Entry::containerFollowerCount( $this->entry->container() )
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/CommentAction",
'userInteractionCount' => $this->entry->mapped('num_comments')
)
)
)
);
if( $this->entry->container()->coverPhoto()->file )
{
\IPS\Output::i()->jsonLd['blog']['image'] = (string) $this->entry->container()->coverPhoto()->file->url;
}
if( $this->entry->container()->member_id )
{
\IPS\Output::i()->jsonLd['blog']['author'] = array(
'@type' => 'Person',
'name' => htmlspecialchars( \IPS\Member::load( $this->entry->container()->member_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'url' => (string) \IPS\Member::load( $this->entry->container()->member_id )->url(),
'image' => \IPS\Member::load( $this->entry->container()->member_id )->get_photo()
);
}
if( $this->entry->edit_time )
{
\IPS\Output::i()->jsonLd['blog']['blogPost']['dateModified'] = \IPS\DateTime::ts( $this->entry->edit_time )->format( \IPS\DateTime::ISO8601 );
}
else
{
\IPS\Output::i()->jsonLd['blog']['blogPost']['dateModified'] = \IPS\DateTime::ts( $this->entry->publish_date ?: $this->entry->date )->format( \IPS\DateTime::ISO8601 );
}
$file = NULL;
if( $this->entry->image )
{
$file = \IPS\File::get( 'blog_Blogs', $this->entry->image );
}
elseif( $this->entry->coverPhoto()->file )
{
$file = $this->entry->coverPhoto()->file;
}
elseif( $this->entry->container()->coverPhoto()->file )
{
$file = $this->entry->container()->coverPhoto()->file;
}
if( $file !== NULL )
{
try
{
$dimensions = $file->getImageDimensions();
\IPS\Output::i()->jsonLd['blog']['blogPost']['image'] = array(
'@type' => 'ImageObject',
'url' => (string) $file->url,
'width' => $dimensions[0],
'height' => $dimensions[1]
);
}
/* File does not exist */
catch( \RuntimeException $e ) {}
}
/* Display */
if( \IPS\Settings::i()->blog_enable_sidebar and $this->entry->container()->sidebar )
{
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate('view')->blogSidebar( $this->entry->container()->sidebar );
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->entry( $this->entry, $previous, $next );
}
}