Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
@@ -75,7 +75,12 @@ class _Image extends \IPS\Content\Item implements
|
||||
* @brief Comment Class
|
||||
*/
|
||||
public static $commentClass = 'IPS\gallery\Image\Comment';
|
||||
|
||||
|
||||
/**
|
||||
* @brief Review Class
|
||||
*/
|
||||
public static $reviewClass = 'IPS\gallery\Image\Review';
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
*/
|
||||
@@ -102,6 +107,9 @@ class _Image extends \IPS\Content\Item implements
|
||||
'rating_average' => 'rating',
|
||||
'rating_total' => 'ratings_total',
|
||||
'rating_hits' => 'ratings_count',
|
||||
'num_reviews' => 'reviews',
|
||||
'unapproved_reviews' => 'unapproved_reviews',
|
||||
'hidden_reviews' => 'hidden_reviews',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -128,6 +136,55 @@ class _Image extends \IPS\Content\Item implements
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
public static $hideLogKey = 'gallery-image';
|
||||
|
||||
/**
|
||||
* Columns needed to query for search result / stream view
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function basicDataColumns()
|
||||
{
|
||||
$return = parent::basicDataColumns();
|
||||
$return[] = 'image_medium_file_name';
|
||||
$return[] = 'image_masked_file_name';
|
||||
$return[] = 'image_original_file_name';
|
||||
$return[] = 'image_album_id';
|
||||
$return[] = 'image_copyright';
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query to get additional data for search result / stream view
|
||||
*
|
||||
* @param array $items Item data (will be an array containing values from basicDataColumns())
|
||||
* @return array
|
||||
*/
|
||||
public static function searchResultExtraData( $items )
|
||||
{
|
||||
$albumIds = array();
|
||||
foreach ( $items as $itemData )
|
||||
{
|
||||
if ( $itemData['image_album_id'] )
|
||||
{
|
||||
$albumIds[ $itemData['image_id'] ] = $itemData['image_album_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $albumIds ) )
|
||||
{
|
||||
$return = array();
|
||||
$albumData = iterator_to_array( \IPS\Db::i()->select( array( 'album_id', 'album_name', 'album_name_seo' ), 'gallery_albums', \IPS\Db::i()->in( 'album_id', $albumIds ) )->setKeyField( 'album_id' ) );
|
||||
|
||||
foreach ( $albumIds as $imageId => $albumId )
|
||||
{
|
||||
$return[ $imageId ] = $albumData[ $albumId ];
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the meta data
|
||||
@@ -199,7 +256,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
{
|
||||
$bits = explode( '/', $length );
|
||||
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'gallery_focal_length_mm', FALSE, array( 'sprintf' => array( round( $bits[0] / $bits[1], 1 ) ) ) );
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'gallery_focal_length_mm', FALSE, array( 'sprintf' => array( ( $bits[1] > 0 ) ? round( $bits[0] / $bits[1], 1 ) : $bits[0] ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -269,29 +326,21 @@ class _Image extends \IPS\Content\Item implements
|
||||
* @brief Cached URLs
|
||||
*/
|
||||
protected $_url = array();
|
||||
|
||||
/**
|
||||
* Get URL
|
||||
*
|
||||
* @param string|NULL $action Action
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function url( $action=NULL )
|
||||
{
|
||||
$_key = md5( $action );
|
||||
|
||||
if( !isset( $this->_url[ $_key ] ) )
|
||||
{
|
||||
$this->_url[ $_key ] = \IPS\Http\Url::internal( "app=gallery&module=gallery&controller=view&id={$this->id}", 'front', 'gallery_image', $this->caption_seo );
|
||||
|
||||
if ( $action )
|
||||
{
|
||||
$this->_url[ $_key ] = $this->_url[ $_key ]->setQueryString( 'do', $action );
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_url[ $_key ];
|
||||
}
|
||||
/**
|
||||
* @brief URL Base
|
||||
*/
|
||||
public static $urlBase = 'app=gallery&module=gallery&controller=view&id=';
|
||||
|
||||
/**
|
||||
* @brief URL Base
|
||||
*/
|
||||
public static $urlTemplate = 'gallery_image';
|
||||
|
||||
/**
|
||||
* @brief SEO Title Column
|
||||
*/
|
||||
public static $seoTitleColumn = 'caption_seo';
|
||||
|
||||
/**
|
||||
* Return selection of image data as a JSON-encoded string (used for patchwork)
|
||||
@@ -412,16 +461,16 @@ class _Image extends \IPS\Content\Item implements
|
||||
'medium' => array( $this->_data['medium_file_name'] ? (string) \IPS\File::get( 'gallery_Images', $this->_data['medium_file_name'] )->url : null, $imageSizes['medium'][0], $imageSizes['medium'][1] )
|
||||
),
|
||||
/* We do not use ENT_QUOTES as this replaces " to " which browsers turn back into " again which breaks the JSON string as it needs to be \", single quotes break the data-attribute='' boundaries */
|
||||
'caption' => str_replace( "'", "&pos;", htmlentities( $this->_data['caption'], \IPS\HTMLENTITIES, 'UTF-8', FALSE ) ),
|
||||
'caption' => str_replace( "'", "'", htmlspecialchars( $this->_data['caption'], \IPS\HTMLENTITIES, 'UTF-8', FALSE ) ),
|
||||
'date' => \IPS\DateTime::ts( $this->mapped('date') )->relative(),
|
||||
'hasState' => count( $state ) ? TRUE : FALSE,
|
||||
'state' => $state,
|
||||
'container' => ( $this->directContainer() instanceof \IPS\gallery\Category ) ? \IPS\Member::loggedIn()->language()->addToStack( "gallery_category_{$this->directContainer()->_id}", FALSE, array( 'json' => TRUE, 'escape' => TRUE ) ) : mb_substr( json_encode( str_replace( "'", "&pos;", htmlentities( $this->directContainer()->_title, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) ) ), 1, -1 ),
|
||||
'container' => ( $this->directContainer() instanceof \IPS\gallery\Category ) ? \IPS\Member::loggedIn()->language()->addToStack( "gallery_category_{$this->directContainer()->_id}", FALSE, array( 'json' => TRUE, 'escape' => TRUE ) ) : mb_substr( json_encode( str_replace( "'", "&pos;", htmlspecialchars( $this->directContainer()->_title, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) ) ), 1, -1 ),
|
||||
'id' => $this->_data['id'],
|
||||
'url' => (string) $this->url(),
|
||||
'author' => array(
|
||||
'photo' => (string) $this->author()->photo,
|
||||
'name' => str_replace( "'", "&pos;", htmlentities( $this->author()->name, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) )
|
||||
'name' => str_replace( "'", "&pos;", htmlspecialchars( $this->author()->name, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) )
|
||||
),
|
||||
'modActions' => $modActions,
|
||||
'modStates' => $modStates,
|
||||
@@ -473,6 +522,57 @@ class _Image extends \IPS\Content\Item implements
|
||||
return array( \IPS\Theme::i()->getTemplate( 'browse', 'gallery' ), 'tableRowsRows' );
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML to manage an item's follows
|
||||
*
|
||||
* @return callable
|
||||
*/
|
||||
public static function manageFollowRows()
|
||||
{
|
||||
return array( \IPS\Theme::i()->getTemplate( 'global', 'gallery', 'front' ), 'manageFollowRow' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available comment/review tabs
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function commentReviewTabs()
|
||||
{
|
||||
$tabs = array();
|
||||
|
||||
if ( $this->directContainer()->allow_reviews )
|
||||
{
|
||||
$tabs['reviews'] = \IPS\Member::loggedIn()->language()->pluralize( \IPS\Member::loggedIn()->language()->get( 'image_review_count' ), array( $this->mapped('num_reviews') ) );
|
||||
}
|
||||
if ( $this->directContainer()->allow_comments )
|
||||
{
|
||||
$tabs['comments'] = \IPS\Member::loggedIn()->language()->pluralize( \IPS\Member::loggedIn()->language()->get( 'image_comment_count' ), array( $this->mapped('num_comments') ) );
|
||||
}
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment/review output
|
||||
*
|
||||
* @param string $tab Active tab
|
||||
* @return string
|
||||
*/
|
||||
public function commentReviews( $tab )
|
||||
{
|
||||
if ( $tab === 'reviews' )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('view')->reviews( $this );
|
||||
}
|
||||
elseif( $tab === 'comments' )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('view')->comments( $this );
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the album node if the image belongs to an album, otherwise return the category
|
||||
*
|
||||
@@ -1292,6 +1392,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
{
|
||||
$this->gps_show = $values['map_enabled'];
|
||||
$this->save();
|
||||
\IPS\Output::i()->redirect( $this->url() );
|
||||
}
|
||||
|
||||
return $form;
|
||||
@@ -1397,6 +1498,50 @@ class _Image extends \IPS\Content\Item implements
|
||||
$category->setLastImage();
|
||||
$category->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get snippet HTML for search result display
|
||||
*
|
||||
* @param array $indexData Data from the search index
|
||||
* @param array $authorData Basic data about the author. Only includes columns returned by \IPS\Member::columnsForPhoto()
|
||||
* @param array $itemData Basic data about the item. Only includes columns returned by item::basicDataColumns()
|
||||
* @param array|NULL $containerData Basic data about the author. Only includes columns returned by container::basicDataColumns()
|
||||
* @param array $reputationData Array of people who have given reputation and the reputation they gave
|
||||
* @param int|NULL $reviewRating If this is a review, the rating
|
||||
* @param string $view 'expanded' or 'condensed'
|
||||
* @return callable
|
||||
*/
|
||||
public static function searchResultSnippet( array $indexData, array $authorData, array $itemData, array $containerData = NULL, array $reputationData, $reviewRating, $view )
|
||||
{
|
||||
$image = $itemData['image_medium_file_name'] ?: $itemData['image_masked_file_name'];
|
||||
$url = \IPS\Http\Url::internal( static::$urlBase . $indexData['index_item_id'], 'front', static::$urlTemplate, \IPS\Http\Url::seoTitle( $indexData['index_title'] ?: $itemData[ static::$databasePrefix . static::$databaseColumnMap['title'] ] ) );
|
||||
|
||||
$albumData = isset( $itemData['extra'] ) ? $itemData['extra'] : NULL;
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'gallery', 'front' )->searchResultImageSnippet( $indexData, $itemData, $albumData, $image, $url, $view == 'condensed' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Are comments supported by this class?
|
||||
*
|
||||
* @param \IPS\Member\NULL $member The member to check for or NULL fto not check permission
|
||||
* @return int
|
||||
*/
|
||||
public static function supportsComments( \IPS\Member $member = NULL )
|
||||
{
|
||||
return parent::supportsComments() and ( !$member or \IPS\gallery\Category::countWhere( 'read', $member, array( 'category_allow_comments=1' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Are reviews supported by this class?
|
||||
*
|
||||
* @param \IPS\Member\NULL $member The member to check for or NULL to not check permission
|
||||
* @return int
|
||||
*/
|
||||
public static function supportsReviews( \IPS\Member $member = NULL )
|
||||
{
|
||||
return parent::supportsReviews() and ( !$member or \IPS\gallery\Category::countWhere( 'read', $member, array( 'category_allow_reviews=1' ) ) );
|
||||
}
|
||||
|
||||
/* !Tags */
|
||||
|
||||
@@ -1657,15 +1802,15 @@ class _Image extends \IPS\Content\Item implements
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional WHERE clauses for New Content view
|
||||
* Additional WHERE clauses for Follow view
|
||||
*
|
||||
* @param bool $joinContainer If true, will join container data (set to TRUE if your $where clause depends on this data)
|
||||
* @param array $joins Other joins
|
||||
* @return array
|
||||
*/
|
||||
public static function vncWhere( &$joinContainer, &$joins )
|
||||
public static function followWhere( &$joinContainer, &$joins )
|
||||
{
|
||||
return array_merge( parent::vncWhere( $joinContainer, $joins ), array( static::getItemsWithPermissionWhere( array(), \IPS\Member::loggedIn(), $joins ) ) );
|
||||
return array_merge( parent::followWhere( $joinContainer, $joins ), array( static::getItemsWithPermissionWhere( array(), \IPS\Member::loggedIn(), $joins ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1690,7 +1835,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
$count = static::getItemsWithPermission( array( array( 'gallery_images.image_category_id=?', $container->_id ) ), NULL, 1, 'read', NULL, 0, NULL, FALSE, FALSE, FALSE, TRUE );
|
||||
|
||||
$_key = md5( get_class( $container ) . $container->_id );
|
||||
static::$itemCounts[ $_key ][ $container->_id ] = $count['cnt'];
|
||||
static::$itemCounts[ $_key ][ $container->_id ] = $count;
|
||||
|
||||
return parent::contentCount( $container, $includeItems, $includeComments, $includeReviews, $depth );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user