Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

@@ -2,9 +2,9 @@
/**
* @brief Category Node
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Gallery
* @since 04 Mar 2014
* @version SVN_VERSION_NUMBER
@@ -127,11 +127,11 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
{
if( !$this->_data['name_seo'] )
{
$this->name_seo = \IPS\Http\Url::seoTitle( \IPS\Lang::load( \IPS\Lang::defaultLanguage() )->get( 'gallery_category_' . $this->id ) );
$this->name_seo = \IPS\Http\Url\Friendly::seoTitle( \IPS\Lang::load( \IPS\Lang::defaultLanguage() )->get( 'gallery_category_' . $this->id ) );
$this->save();
}
return $this->_data['name_seo'] ?: \IPS\Http\Url::seoTitle( \IPS\Lang::load( \IPS\Lang::defaultLanguage() )->get( 'gallery_category_' . $this->id ) );
return $this->_data['name_seo'] ?: \IPS\Http\Url\Friendly::seoTitle( \IPS\Lang::load( \IPS\Lang::defaultLanguage() )->get( 'gallery_category_' . $this->id ) );
}
/**
@@ -173,7 +173,14 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
*/
protected function get__comments()
{
return $this->count_comments;
$comments = $this->count_comments;
foreach( $this->children() as $child )
{
$comments += $child->count_comments;
}
return $comments;
}
/**
@@ -279,7 +286,8 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
return !isset( \IPS\Request::i()->id ) or ( $node->id != \IPS\Request::i()->id and !$node->isChildOf( $node::load( \IPS\Request::i()->id ) ) );
}
) ) );
$form->add( new \IPS\Helpers\Form\Select( 'category_sort_options', $this->sort_options ?: 'updated', FALSE, array( 'options' => array( 'updated' => 'sort_updated', 'rating' => 'sort_rating', 'num_comments' => 'sort_num_comments' ) ), NULL, NULL, NULL, 'category_sort_options' ) );
$sortoptions = array( 'album_last_img_date' => 'sort_updated', 'album_name' => 'sort_title', 'album_rating_aggregate' => 'sort_rating', 'album_count_comments' => 'sort_num_comments', 'album_count_images' => 'sort_count_imgs' );
$form->add( new \IPS\Helpers\Form\Select( 'category_sort_options', $this->sort_options ?: 'updated', FALSE, array( 'options' => $sortoptions ), NULL, NULL, NULL, 'category_sort_options' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'category_allow_albums', $this->id ? $this->allow_albums : TRUE, FALSE ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'category_approve_img', $this->approve_img, FALSE ) );
@@ -366,29 +374,29 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
if( isset( $values['category_name'] ) )
{
\IPS\Lang::saveCustom( 'gallery', "gallery_category_{$this->id}", $values['category_name'] );
$values['name_seo'] = \IPS\Http\Url::seoTitle( $values['category_name'][ \IPS\Lang::defaultLanguage() ] );
$values['name_seo'] = \IPS\Http\Url\Friendly::seoTitle( $values['category_name'][ \IPS\Lang::defaultLanguage() ] );
unset( $values['category_name'] );
}
if( isset( $values['category_description'] ) )
if( array_key_exists( 'category_description', $values ) )
{
\IPS\Lang::saveCustom( 'gallery', "gallery_category_{$this->id}_desc", $values['category_description'] );
unset( $values['category_description'] );
}
if( isset( $values['category_rules_title'] ) )
if( array_key_exists( 'category_rules_title', $values ) )
{
\IPS\Lang::saveCustom( 'gallery', "gallery_category_{$this->id}_rulestitle", $values['category_rules_title'] );
unset( $values['category_rules_title'] );
}
if( isset( $values['category_rules_text'] ) )
if( array_key_exists( 'category_rules_text', $values ) )
{
\IPS\Lang::saveCustom( 'gallery', "gallery_category_{$this->id}_rules", $values['category_rules_text'] );
unset( $values['category_rules_text'] );
}
if( isset( $values['category_permission_custom_error'] ) )
if( array_key_exists( 'category_permission_custom_error', $values ) )
{
\IPS\Lang::saveCustom( 'gallery', "gallery_category_{$this->id}_permerror", $values['category_permission_custom_error'] );
unset( $values['category_permission_custom_error'] );
@@ -400,6 +408,12 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
$values['category_parent_id'] = $values['category_parent_id'] ? intval( $values['category_parent_id']->id ) : 0;
}
/* Cannot be null */
if( !isset( $values['category_approve_com'] ) )
{
$values['category_approve_com'] = 0;
}
/* Send to parent */
return $values;
}
@@ -433,13 +447,17 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
{
if ( \IPS\Member::loggedIn()->language()->checkKeyExists( "gallery_category_{$this->id}_permerror" ) )
{
$message = \IPS\Member::loggedIn()->language()->addToStack( "gallery_category_{$this->id}_permerror" );
if ( $message and $message != '<p></p>' )
try
{
return $message;
$message = trim( \IPS\Member::loggedIn()->language()->get( "gallery_category_{$this->id}_permerror" ) );
if ( !empty( $message ) AND ( $message != '<p></p>' ) )
{
return $message;
}
}
catch ( \Exception $e ) {}
}
return 'node_error_no_perm';
}
@@ -450,27 +468,42 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
*/
public function lastImage()
{
$latestImage = NULL;
$latestImageData = $this->getLatestImageId();
$latestImage = NULL;
if( $this->last_img_id )
if( $latestImageData !== NULL )
{
try
{
$latestImage = \IPS\gallery\Image::load( $this->last_img_id );
}
catch ( \OutOfRangeException $e )
{
$latestImage = NULL;
$latestImage = \IPS\gallery\Image::load( $latestImageData['id'] );
}
catch( \OutOfRangeException $e ){}
}
return $latestImage;
}
/**
* Retrieve the latest image ID in categories and children categories
*
* @return array|NULL
*/
protected function getLatestImageId()
{
$latestImage = NULL;
if ( $this->last_img_id )
{
$latestImage = array( 'id' => $this->last_img_id, 'date' => $this->last_img_date );
}
foreach( $this->children() as $child )
{
$childLatest = $child->lastImage();
$childLatest = $child->getLatestImageId();
if( $childLatest !== NULL AND ( $latestImage === NULL OR $childLatest->date > $latestImage->date ) )
if( $childLatest !== NULL AND ( $latestImage === NULL OR $childLatest['date'] > $latestImage['date'] ) )
{
$latestImage = $childLatest;
$latestImage = $childLatest;
}
}
@@ -532,6 +565,8 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
$this->last_img_id = $image->id;
$this->last_img_date = $image->date;
$this->resetCommentCounts();
if( $image->album_id )
{
$album = \IPS\gallery\Album::load( $image->album_id );
@@ -564,6 +599,11 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
*/
public function coverPhoto( $size='thumb' )
{
if ( !$this->can( 'read' ) )
{
return NULL;
}
$property = $size . "_file_name";
if( !$this->cover_img_id )
@@ -604,7 +644,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
*/
public static function loadFromUrl( \IPS\Http\Url $url )
{
$qs = array_merge( $url->queryString, $url->getFriendlyUrlData() );
$qs = array_merge( $url->queryString, $url->hiddenQueryString );
if ( isset( $qs['category'] ) )
{
@@ -630,6 +670,22 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
{
return (bool) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_albums', array( 'album_category_id=?', $this->id ) )->first();
}
/**
* Should we show the form to delete or move content?
*
* @return bool
*/
public function showDeleteOrMoveForm()
{
/* Do we have any albums? */
if( $this->hasAlbums() )
{
return TRUE;
}
return parent::showDeleteOrMoveForm();
}
/**
* Form to delete or move content
@@ -740,6 +796,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
$this->public_albums = 0;
$this->nonpublic_albums = 0;
$this->cover_img_id = 0;
$oldId = $this->id;