Version 4.7.8
This commit is contained in:
1 parent
7b7404e741
commit
fd22d99e69
688 files changed
+19814
-10890
No files matched your search
@@ -80,6 +80,18 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
*/
|
||||
public static $contentItemClass = 'IPS\gallery\Image';
|
||||
|
||||
/* These are required to be declared here as well as the asItem class for embeds.
|
||||
|
||||
/**
|
||||
* @brief Review Class
|
||||
*/
|
||||
public static $reviewClass = 'IPS\gallery\Album\Review';
|
||||
|
||||
/**
|
||||
* @brief Comment Class
|
||||
*/
|
||||
public static $commentClass = 'IPS\gallery\Album\Comment';
|
||||
|
||||
/**
|
||||
* @brief [Node] If the node can be "owned", the owner "type" (typically "member" or "group") and the associated database column
|
||||
*/
|
||||
@@ -473,13 +485,28 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
*/
|
||||
public static function formFields( \IPS\gallery\Album $album = NULL, $forOther = FALSE, $required = TRUE )
|
||||
{
|
||||
/* Save my sanity here.... load the category if we have one */
|
||||
$category = NULL;
|
||||
if( $album AND $album->category_id )
|
||||
{
|
||||
$category = $album->category();
|
||||
}
|
||||
elseif( !$album AND ( isset( \IPS\Request::i()->chosenCategory ) or isset( \IPS\Request::i()->category ) ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$category = \IPS\gallery\Category::load( (int)\IPS\Request::i()->chosenCategory ?: \IPS\Request::i()->category );
|
||||
}
|
||||
catch( \OutOfRangeException $e ){}
|
||||
}
|
||||
|
||||
$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 ) );
|
||||
|
||||
$return[] = new \IPS\Helpers\Form\Node( 'album_category', ( $album and $album->category_id ) ? \IPS\gallery\Category::load( $album->category_id ) : NULL, $required ?: NULL, array(
|
||||
$return[] = new \IPS\Helpers\Form\Node( 'album_category', $category ? $category->id : NULL, $required ?: NULL, array(
|
||||
'class' => 'IPS\gallery\Category',
|
||||
'disabled' => false,
|
||||
'permissionCheck' => function( $node )
|
||||
@@ -541,19 +568,9 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
);
|
||||
|
||||
/* Is the category in a club */
|
||||
if( $album AND $album->category_id )
|
||||
if( $category !== NULL AND $club = $category->club() )
|
||||
{
|
||||
if( $album->category()->club() )
|
||||
{
|
||||
$submitTypes[ static::AUTH_SUBMIT_CLUB ] = 'album_submittype_club';
|
||||
}
|
||||
}
|
||||
elseif( !$album AND ( isset( \IPS\Request::i()->chosenCategory ) or isset( \IPS\Request::i()->category ) ) )
|
||||
{
|
||||
if( \IPS\gallery\Category::load( (int) \IPS\Request::i()->chosenCategory ?: \IPS\Request::i()->category )->club() )
|
||||
{
|
||||
$submitTypes[ static::AUTH_SUBMIT_CLUB ] = 'album_submittype_club';
|
||||
}
|
||||
$submitTypes[ static::AUTH_SUBMIT_CLUB ] = 'album_submittype_club';
|
||||
}
|
||||
|
||||
$return[] = new \IPS\Helpers\Form\Radio( 'album_submit_type', ( $album and $album->submit_type ) ? $album->submit_type : static::AUTH_SUBMIT_OWNER, FALSE, array( 'options' => $submitTypes, 'toggles' => array( static::AUTH_SUBMIT_MEMBERS => array( 'album_submit_access_members' ), static::AUTH_SUBMIT_GROUPS => array( 'album_submit_access_groups' ) ) ), NULL, NULL, NULL, 'album_submit_type' );
|
||||
@@ -561,25 +578,25 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
$return[] = new \IPS\Helpers\Form\SocialGroup( 'album_submit_access_members', ( $album AND $album->submit_type == static::AUTH_SUBMIT_MEMBERS ) ? (int) $album->submit_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_submit_access_members' );
|
||||
$groups = array_combine( array_keys( \IPS\Member\Group::groups( TRUE, FALSE ) ), array_map( function( $_group ) { return (string) $_group; }, \IPS\Member\Group::groups( TRUE, FALSE ) ) );
|
||||
$return[] = new \IPS\Helpers\Form\CheckboxSet( 'album_submit_access_groups', ( $album and $album->submit_type == static::AUTH_SUBMIT_GROUPS ) ? explode( ',', $album->submit_access ) : NULL, FALSE, array( 'options' => $groups, 'multiple' => true ), NULL, NULL, NULL, 'album_submit_access_groups' );
|
||||
|
||||
$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' => 'album_sort_caption', '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\Select( 'album_sort_options', ( ( $album and $album->sort_options ) ? $album->sort_options : ( ( $category AND $category->sort_options_img ) ? $category->sort_options_img : 'updated' ) ), FALSE, array( 'options' => array( 'updated' => 'sort_updated', 'last_comment' => 'sort_last_comment', 'title' => 'album_sort_caption', '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_rating', $album ? $album->allow_rating : TRUE, FALSE );
|
||||
|
||||
if( ( ( $album and $album->category_id ) and ( \IPS\gallery\Category::load( $album->category_id )->allow_comments ) ) or ( ( isset( \IPS\Request::i()->chosenCategory ) or isset( \IPS\Request::i()->category ) ) and \IPS\gallery\Category::load( (int) \IPS\Request::i()->chosenCategory ?: \IPS\Request::i()->category )->allow_comments ) )
|
||||
if( $category AND $category->allow_comments )
|
||||
{
|
||||
$return[] = new \IPS\Helpers\Form\YesNo('album_allow_comments', $album ? $album->allow_comments : TRUE, FALSE);
|
||||
}
|
||||
if( ( ( $album and $album->category_id ) and ( \IPS\gallery\Category::load( $album->category_id )->allow_reviews ) ) or ( ( isset( \IPS\Request::i()->chosenCategory ) or isset( \IPS\Request::i()->category ) ) and \IPS\gallery\Category::load( (int) \IPS\Request::i()->chosenCategory ?: \IPS\Request::i()->category )->allow_reviews ) )
|
||||
if( $category AND $category->allow_reviews )
|
||||
{
|
||||
$return[] = new \IPS\Helpers\Form\YesNo('album_allow_reviews', $album ? $album->allow_reviews : TRUE, FALSE);
|
||||
}
|
||||
|
||||
if( ( ( $album and $album->category_id ) and ( \IPS\gallery\Category::load( $album->category_id )->allow_comments ) ) or ( ( isset( \IPS\Request::i()->chosenCategory ) or isset( \IPS\Request::i()->category ) ) and \IPS\gallery\Category::load( (int) \IPS\Request::i()->chosenCategory ?: \IPS\Request::i()->category )->allow_comments ) )
|
||||
if( $category AND $category->allow_comments )
|
||||
{
|
||||
$return[] = new \IPS\Helpers\Form\YesNo('album_use_comments', $album ? $album->use_comments : TRUE, FALSE );
|
||||
}
|
||||
if( ( ( $album and $album->category_id ) and ( \IPS\gallery\Category::load( $album->category_id )->allow_reviews ) ) or ( ( isset( \IPS\Request::i()->chosenCategory ) or isset( \IPS\Request::i()->category ) ) and \IPS\gallery\Category::load( (int) \IPS\Request::i()->chosenCategory ?: \IPS\Request::i()->category )->allow_reviews ) )
|
||||
if( $category AND $category->allow_reviews )
|
||||
{
|
||||
$return[] = new \IPS\Helpers\Form\YesNo('album_use_reviews', $album ? $album->use_reviews : TRUE, FALSE );
|
||||
}
|
||||
@@ -1160,16 +1177,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
{
|
||||
if( $this->coverPhoto === NULL )
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->coverPhoto = \IPS\gallery\Image::load( $this->cover_img_id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
/* Cover photo isn't valid, reset album automatically */
|
||||
$this->cover_img_id = 0;
|
||||
$this->save();
|
||||
}
|
||||
$this->coverPhoto = $this->coverPhotoObject();
|
||||
}
|
||||
|
||||
if( $this->coverPhoto !== NULL )
|
||||
@@ -1186,6 +1194,44 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a cover photo object
|
||||
*
|
||||
* @return \IPS\gallery\Image|null
|
||||
*/
|
||||
public function coverPhotoObject()
|
||||
{
|
||||
/* If we have an explicit cover photo set, make sure it's valid and load/cache it */
|
||||
if( $this->cover_img_id )
|
||||
{
|
||||
if( $this->coverPhoto === NULL )
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->coverPhoto = \IPS\gallery\Image::load( $this->cover_img_id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
/* Cover photo isn't valid, reset album automatically */
|
||||
$this->cover_img_id = 0;
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( $this->coverPhoto !== NULL )
|
||||
{
|
||||
return $this->coverPhoto;
|
||||
}
|
||||
|
||||
if( $lastImage = $this->lastImage() AND !$lastImage->media )
|
||||
{
|
||||
return $lastImage;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load record based on a URL
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user