Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
@@ -244,6 +244,16 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
return $this->count_comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of content reviews
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get__reviews()
|
||||
{
|
||||
return $this->count_reviews;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of unapproved content items
|
||||
*
|
||||
@@ -253,6 +263,16 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
{
|
||||
return $this->count_imgs_hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of unapproved content reviews
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get__unapprovedReviews()
|
||||
{
|
||||
return $this->count_reviews_hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of unapproved content comments
|
||||
@@ -288,7 +308,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
/**
|
||||
* Set number of items
|
||||
*
|
||||
* @param int $val Comments
|
||||
* @param int $val Comments
|
||||
* @return void
|
||||
*/
|
||||
protected function set__comments( $val )
|
||||
@@ -296,6 +316,17 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
$this->count_comments = (int) $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set number of items
|
||||
*
|
||||
* @param int $val Reviews
|
||||
* @return void
|
||||
*/
|
||||
protected function set__reviews( $val )
|
||||
{
|
||||
$this->count_reviews = (int) $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of unapproved content items
|
||||
*
|
||||
@@ -317,6 +348,17 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
{
|
||||
$this->count_comments_hidden = $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of unapproved content reviews
|
||||
*
|
||||
* @param int $val Unapproved Reviews
|
||||
* @return void
|
||||
*/
|
||||
protected function set__unapprovedReviews( $val )
|
||||
{
|
||||
$this->count_reviews_hidden = $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Add/Edit Form
|
||||
@@ -345,8 +387,9 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
$return = array();
|
||||
|
||||
$return[] = new \IPS\Helpers\Form\Text( 'album_name', $album ? $album->name : '', $required ?: NULL );
|
||||
$return[] = new \IPS\Helpers\Form\Editor( 'album_description', $album ? $album->description : '', FALSE, array( 'app' => 'gallery', 'key' => 'Albums', 'autoSaveKey' => ( $album ? "gallery_album_{$album->id}_desc" : "gallery-new-album" ), 'attachIds' => $album ? array( $album->id, NULL, 'description' ) : NULL, 'minimize' => 'cdesc_placeholder' ) );
|
||||
|
||||
$return[] = new \IPS\Helpers\Form\Editor( 'album_description', $album ? $album->description : '', FALSE, array( 'app' => 'gallery', 'key' => 'Albums', 'autoSaveKey' => ( $album ? "gallery_album_{$album->id}_desc" : "gallery-new-album" ), 'attachIds' => $album ? array( $album->id, NULL, 'description' ) : NULL, 'minimize' => 'cdesc_placeholder' ) );
|
||||
|
||||
$return[] = new \IPS\Helpers\Form\Node( 'album_category', ( $album and $album->category_id ) ? \IPS\gallery\Category::load( $album->category_id ) : NULL, $required ?: NULL, array(
|
||||
'class' => 'IPS\gallery\Category',
|
||||
'disabled' => false,
|
||||
@@ -395,11 +438,12 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
{
|
||||
$return[] = new \IPS\Helpers\Form\SocialGroup( 'album_allowed_access', $album ? $album->allowed_access : NULL, FALSE, array( 'owner' => $album ? \IPS\Member::load( $album->owner_id ) : ( \IPS\Request::i()->album_owner ? \IPS\Member::load( \IPS\Request::i()->album_owner, 'name' ) : \IPS\Member::loggedIn() ) ), NULL, NULL, NULL, 'album_allowed_access' );
|
||||
}
|
||||
|
||||
$return[] = new \IPS\Helpers\Form\Select( 'album_sort_options', ( $album and $album->sort_options ) ? $album->sort_options : 'updated', FALSE, array( 'options' => array( 'updated' => 'sort_updated', 'rating' => 'sort_rating', 'num_comments' => 'sort_num_comments' ) ), NULL, NULL, NULL, 'album_sort_options' );
|
||||
|
||||
$return[] = new \IPS\Helpers\Form\Select( 'album_sort_options', ( $album and $album->sort_options ) ? $album->sort_options : 'updated', FALSE, array( 'options' => array( 'updated' => 'sort_updated', 'last_comment' => 'sort_last_comment', 'title' => 'sort_title', 'rating' => 'sort_rating', 'date' => 'sort_date', 'num_comments' => 'sort_num_comments', 'num_reviews' => 'sort_num_reviews', 'views' => 'sort_views' ) ), NULL, NULL, NULL, 'album_sort_options' );
|
||||
|
||||
$return[] = new \IPS\Helpers\Form\YesNo( 'album_allow_comments', $album ? $album->allow_comments : TRUE, FALSE );
|
||||
$return[] = new \IPS\Helpers\Form\YesNo( 'album_allow_rating', $album ? $album->allow_rating : TRUE, FALSE );
|
||||
$return[] = new \IPS\Helpers\Form\YesNo( 'album_allow_reviews', $album ? $album->allow_reviews : TRUE, FALSE );
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -480,6 +524,10 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
$values['owner_id'] = ( $values['album_owner'] instanceof \IPS\Member ) ? $values['album_owner']->member_id : $values['album_owner'];
|
||||
unset( $values['album_owner'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$values['owner_id'] = \IPS\Member::loggedIn()->member_id;
|
||||
}
|
||||
|
||||
/* Send to parent */
|
||||
return $values;
|
||||
@@ -571,21 +619,21 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
* @brief Cached URL
|
||||
*/
|
||||
protected $_url = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Get URL
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @brief URL Base
|
||||
*/
|
||||
public function url()
|
||||
{
|
||||
if( $this->_url === NULL )
|
||||
{
|
||||
$this->_url = \IPS\Http\Url::internal( "app=gallery&module=gallery&controller=browse&album={$this->_id}", 'front', 'gallery_album', $this->name_seo );
|
||||
}
|
||||
|
||||
return $this->_url;
|
||||
}
|
||||
public static $urlBase = 'app=gallery&module=gallery&controller=browse&album=';
|
||||
|
||||
/**
|
||||
* @brief URL Base
|
||||
*/
|
||||
public static $urlTemplate = 'gallery_album';
|
||||
|
||||
/**
|
||||
* @brief SEO Title Column
|
||||
*/
|
||||
public static $seoTitleColumn = 'name_seo';
|
||||
|
||||
/**
|
||||
* Get latest image information
|
||||
@@ -621,6 +669,18 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
$this->setLastImage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set last review
|
||||
*
|
||||
* @param \IPS\Content\Review|NULL $review The latest review or NULL to work it out
|
||||
* @return int
|
||||
* @note We actually want to set the last image info, not the last review, so we ignore $review
|
||||
*/
|
||||
public function setLastReview( \IPS\Content\Review $review=NULL )
|
||||
{
|
||||
$this->setLastImage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set last image data
|
||||
*
|
||||
@@ -632,7 +692,9 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
{
|
||||
/* Figure out our latest images in this album */
|
||||
$_latestImages = array();
|
||||
|
||||
|
||||
$this->last_img_date = 0;
|
||||
$this->last_img_id = 0;
|
||||
foreach( \IPS\Db::i()->select( '*', 'gallery_images', array( 'image_album_id=? AND image_approved=1', $this->id ), 'image_date DESC', array( 0, 20 ) ) as $image )
|
||||
{
|
||||
if( $image['image_date'] > $this->last_img_date )
|
||||
@@ -652,6 +714,10 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
|
||||
$this->_comments = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_comments', array( 'gallery_images.image_album_id=? AND comment_approved=1', $this->id ) )->join( 'gallery_images', 'image_id=comment_img_id' )->first();
|
||||
$this->_unapprovedComments = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_comments', array( 'gallery_images.image_album_id=? AND comment_approved=0', $this->id ) )->join( 'gallery_images', 'image_id=comment_img_id' )->first();
|
||||
|
||||
$this->_reviews = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_reviews', array( 'gallery_images.image_album_id=? AND review_approved=1', $this->id ) )->join( 'gallery_images', 'image_id=review_image_id' )->first();
|
||||
$this->_unapprovedReviews = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_reviews', array( 'gallery_images.image_album_id=? AND review_approved=0', $this->id ) )->join( 'gallery_images', 'image_id=review_image_id' )->first();
|
||||
|
||||
$this->save();
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,8 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
'read' => 2,
|
||||
'add' => 3,
|
||||
'reply' => 4,
|
||||
'rate' => 5
|
||||
'rate' => 5,
|
||||
'review' => 6,
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -291,6 +292,8 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_allow_comments', $this->id ? $this->allow_comments : TRUE, FALSE, array( 'togglesOn' => array( 'category_approve_com' ) ), NULL, NULL, NULL, 'category_allow_comments' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_approve_com', $this->approve_com, FALSE, array(), NULL, NULL, NULL, 'category_approve_com' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'gcategory_allow_rating', $this->id ? $this->allow_rating : TRUE, FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_allow_reviews', $this->id ? $this->allow_reviews : FALSE, FALSE, array( 'togglesOn' => array( 'category_review_moderate' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_review_moderate', $this->id ? $this->review_moderate : FALSE, FALSE, array(), NULL, NULL, NULL, 'category_review_moderate' ) );
|
||||
|
||||
if ( \IPS\Settings::i()->tags_enabled )
|
||||
{
|
||||
@@ -405,21 +408,21 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
* @brief Cached URL
|
||||
*/
|
||||
protected $_url = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Get URL
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @brief URL Base
|
||||
*/
|
||||
public function url()
|
||||
{
|
||||
if( $this->_url === NULL )
|
||||
{
|
||||
$this->_url = \IPS\Http\Url::internal( "app=gallery&module=gallery&controller=browse&category={$this->_id}", 'front', 'gallery_category', $this->name_seo );
|
||||
}
|
||||
|
||||
return $this->_url;
|
||||
}
|
||||
public static $urlBase = 'app=gallery&module=gallery&controller=browse&category=';
|
||||
|
||||
/**
|
||||
* @brief URL Base
|
||||
*/
|
||||
public static $urlTemplate = 'gallery_category';
|
||||
|
||||
/**
|
||||
* @brief SEO Title Column
|
||||
*/
|
||||
public static $seoTitleColumn = 'name_seo';
|
||||
|
||||
/**
|
||||
* Get "No Permission" error message
|
||||
|
||||
@@ -134,4 +134,24 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
\IPS\gallery\Album::load( $item->album_id )->setLastComment();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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( \IPS\gallery\Image::$urlBase . $indexData['index_item_id'], 'front', \IPS\gallery\Image::$urlTemplate, \IPS\Http\Url::seoTitle( $indexData['index_title'] ?: $itemData[ \IPS\gallery\Image::$databasePrefix . \IPS\gallery\Image::$databaseColumnMap['title'] ] ) );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'gallery', 'front' )->searchResultCommentSnippet( $indexData, $itemData, $image, $url, $reviewRating, $view == 'condensed' );
|
||||
}
|
||||
}
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Image Review Model
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Gallery
|
||||
* @since 18 Aug 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\Image;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Image Review Model
|
||||
*/
|
||||
class _Review extends \IPS\Content\Review implements \IPS\Content\EditHistory, \IPS\Content\ReportCenter, \IPS\Content\Hideable, \IPS\Content\Reputation, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
{
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
|
||||
/**
|
||||
* @brief [Content\Comment] Item Class
|
||||
*/
|
||||
public static $itemClass = 'IPS\gallery\Image';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'gallery_reviews';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'review_';
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
'item' => 'image_id',
|
||||
'author' => 'author',
|
||||
'author_name' => 'author_name',
|
||||
'content' => 'content',
|
||||
'date' => 'date',
|
||||
'ip_address' => 'ip_address',
|
||||
'edit_time' => 'edit_time',
|
||||
'edit_member_name' => 'edit_member_name',
|
||||
'edit_show' => 'edit_show',
|
||||
'rating' => 'rating',
|
||||
'votes_total' => 'votes_total',
|
||||
'votes_helpful' => 'votes_helpful',
|
||||
'votes_data' => 'votes_data',
|
||||
'approved' => 'approved',
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $application = 'gallery';
|
||||
|
||||
/**
|
||||
* @brief Title
|
||||
*/
|
||||
public static $title = 'gallery_image_review';
|
||||
|
||||
/**
|
||||
* @brief Icon
|
||||
*/
|
||||
public static $icon = 'camera';
|
||||
|
||||
/**
|
||||
* @brief Reputation Type
|
||||
*/
|
||||
public static $reputationType = 'review_id';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
public static $hideLogKey = 'gallery-image-review';
|
||||
|
||||
/**
|
||||
* Get URL for doing stuff
|
||||
*
|
||||
* @param string|NULL $action Action
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function url( $action=NULL )
|
||||
{
|
||||
return parent::url( $action )->setQueryString( 'tab', 'reviews' );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 )
|
||||
{
|
||||
return \IPS\gallery\Image\Comment::searchResultSnippet( $indexData, $authorData, $itemData, $containerData, $reputationData, $reviewRating, $view );
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,7 @@ class _Table extends \IPS\Helpers\Table\Content
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'move_to_category', NULL, FALSE, array( 'class' => 'IPS\\gallery\\Category', 'url' => \IPS\Request::i()->url()->setQueryString( 'modaction', 'move' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'move_to_album', NULL, FALSE, array(
|
||||
'class' => 'IPS\\gallery\\Album',
|
||||
'forceOwner' => FALSE,
|
||||
'url' => \IPS\Request::i()->url()->setQueryString( 'modaction', 'move' ),
|
||||
'permissionCheck' => function( $node )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user