Version 4.3.6

This commit is contained in:
Neo committed 2025-12-19 05:49:12 -08:00
1 parent fe1acf984a
commit 1a0c7fd3c2
609 files changed
+14707 -5726

No files matched your search

+58 -27
View File
@@ -356,7 +356,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
throw new \OutofRangeException('object_not_valid');
}
/**
* Get the number and indefinite article for replies/children where applicable
*
@@ -364,7 +364,19 @@ class _Promote extends \IPS\Patterns\ActiveRecord
*/
public function get_objectDataCount()
{
$object = $this->object();
return $this->objectDataCount( NULL );
}
/**
* Get the number and indefinite article for replies/children where applicable
*
* @param \IPS\Lang|null $language Language to use (or NULL for currently logged in member's language)
* @return array|null
*/
public function objectDataCount( $language=NULL )
{
$language = $language ?: \IPS\Member::loggedIn()->language();
$object = $this->object();
if ( $object instanceof \IPS\Content\Item )
{
@@ -383,14 +395,14 @@ class _Promote extends \IPS\Patterns\ActiveRecord
$count--;
}
return array( 'count' => $count, 'words' => \IPS\Member::loggedIn()->language()->addToStack( 'num_replies', NULL, array( 'pluralize' => array( $count ) ) ) );
return array( 'count' => $count, 'words' => $language->addToStack( 'num_replies', NULL, array( 'pluralize' => array( $count ) ) ) );
}
if ( $object::supportsReviews( NULL, $container ) )
{
$count = $object->mapped('num_reviews');
return array( 'count' => $count, 'words' => \IPS\Member::loggedIn()->language()->addToStack( 'num_reviews', NULL, array( 'pluralize' => array( $count ) ) ) );
return array( 'count' => $count, 'words' => $language->addToStack( 'num_reviews', NULL, array( 'pluralize' => array( $count ) ) ) );
}
/* Valid object, but there isn't any date data available */
@@ -406,7 +418,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
{
$count = $object->_items;
return array( 'count' => $count, 'words' => \IPS\Member::loggedIn()->language()->addToStack( $object->_countLanguageString, NULL, array( 'pluralize' => array( $count ) ) ) );
return array( 'count' => $count, 'words' => $language->addToStack( $object->_countLanguageString, NULL, array( 'pluralize' => array( $count ) ) ) );
}
return NULL;
@@ -452,7 +464,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
else
{
return $plaintextLanguage->addToStack( 'promote_metadescription_container_nolink', NULL, array(
'sprintf' => array( $object->indefiniteArticle( $plaintextLanguage ), $container->_title, $author->name, $this->objectDatePosted->relative( \IPS\DateTime::RELATIVE_FORMAT_NORMAL, $plaintextLanguage ) ),
'sprintf' => array( $object->indefiniteArticle( $plaintextLanguage ), $container->getTitleForLanguage( $plaintextLanguage ), $author->name, $this->objectDatePosted->relative( \IPS\DateTime::RELATIVE_FORMAT_NORMAL, $plaintextLanguage ) ),
) );
}
}
@@ -501,7 +513,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
else
{
return $plaintextLanguage->addToStack( 'promote_metadescription_node_nolink', NULL, array(
'sprintf' => array( $object->_title, $author->name )
'sprintf' => array( $object->getTitleForLanguage( $plaintextLanguage ), $author->name )
) );
}
}
@@ -512,7 +524,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
/**
* Get reactions class for this object
*
* @return array|null
* @return \IPS\Content\Reactable|null
*/
public function get_objectReactionClass()
{
@@ -655,7 +667,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
public function imageObjects()
{
$photos = array();
if ( count( $this->images ) )
if ( \count( $this->images ) )
{
foreach( $this->images as $image )
{
@@ -666,7 +678,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
}
}
if ( count( $this->media ) )
if ( \count( $this->media ) )
{
foreach( $this->media as $media )
{
@@ -674,7 +686,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
}
}
return ( count( $photos ) ) ? $photos : NULL;
return ( \count( $photos ) ) ? $photos : NULL;
}
/**
@@ -726,7 +738,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
* Shorten URL.
*
* @param string $service Service key, (such as facebook or twitter)
* @returns boolean
* @return boolean
*/
public function serviceFailed( $service )
{
@@ -772,12 +784,12 @@ class _Promote extends \IPS\Patterns\ActiveRecord
$allText[ $service ] = $text;
$this->text = $allText;
}
/**
* Return the published URL for this post
*
* @param string $service Service key, (such as facebook or twitter)
* @returns string|NULL
* @param string $service Service key, (such as facebook or twitter)
* @return string|NULL
*/
public function getPublishedUrl( $service )
{
@@ -822,7 +834,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
return NULL;
}
return count( $responses ) ? $responses : NULL;
return \count( $responses ) ? $responses : NULL;
}
/**
@@ -842,7 +854,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
}
}
return count( $this->history[ $this->id ] ) ? $this->history[ $this->id ] : NULL;
return \count( $this->history[ $this->id ] ) ? $this->history[ $this->id ] : NULL;
}
/**
@@ -920,6 +932,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
* @param object $object Object (node or content item)
* @param NULL|\IPS\Member $member Member object or NULL for current member
* @return boolean
* @throws \OutOfRangeException
*/
public static function objectCanView( $object, $member=NULL )
{
@@ -934,7 +947,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
return $object->can( 'view', $member );
}
throw new \OutofRangeException('object_not_valid');
throw new \OutOfRangeException('object_not_valid');
}
/**
@@ -964,7 +977,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
}
}
return count( $groups ) ? $groups : NULL;
return \count( $groups ) ? $groups : NULL;
}
/**
@@ -1080,7 +1093,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
* @param integer $id Item ID
* @param boolean $sent Only look for sent items
* @param boolean $futureScheduled Only look for future scheduled items
* @return \IPS\core\Promote item
* @return static Item
*/
public static function loadByClassAndId( $class, $id, $sent=FALSE, $futureScheduled=FALSE )
{
@@ -1126,7 +1139,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
* We only have bit.ly as a shortener at the moment.
*
* @param string $longUrl The original URL
* @returns string NULL if no shortnener available or it fails
* @return string NULL if no shortnener available or it fails
* @throws \RuntimeException if shortener fails
* @throws \UnderflowException if no shortener available
*/
@@ -1154,7 +1167,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
throw new \RuntimeException;
}
}
/**
* Get the next auto schedule timestamp
*
@@ -1195,10 +1208,28 @@ class _Promote extends \IPS\Patterns\ActiveRecord
/* Still here? Then pick the earliest time for the next day */
if ( $time === NULL )
{
$firstTime = array_shift( $times );
list( $h, $m ) = explode( ':', $firstTime );
$time = $current->add( new \DateInterval( 'P1D' ) )->setTime( $h, $m );
while( $time === NULL )
{
/* Set to midnight of current day */
$current->setTime( 0, 0 );
/* We need to clone otherwise $test is always the same as $current */
$test = clone $current;
foreach( $times as $entry )
{
list( $h, $m ) = explode( ':', $entry );
$test->setTime( $h, $m );
if ( ( $test->getTimeStamp() > time() ) and ( $current->getTimeStamp() <= $test->getTimeStamp() ) )
{
$time = $test;
break;
}
}
/* Still here? */
$current->add( new \DateInterval( 'P1D' ) );
}
}
return $time;
@@ -1288,7 +1319,7 @@ class _Promote extends \IPS\Patterns\ActiveRecord
}
}
return count( $services ) ? $services : NULL;
return \count( $services ) ? $services : NULL;
}
/**