Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -76,7 +76,7 @@ class _Rss extends \IPS\Node\Model
|
||||
),
|
||||
'all' => 'foo_manage', // [Optional] The key to use for any restriction not provided in the map (only needed if not providing all 4)
|
||||
'prefix' => 'foo_', // [Optional] Rather than specifying each key in the map, you can specify a prefix, and it will automatically look for restrictions with the key "[prefix]_add/edit/permissions/delete"
|
||||
* @encode
|
||||
* @endcode
|
||||
*/
|
||||
protected static $restrictions = array(
|
||||
'app' => 'core',
|
||||
@@ -98,30 +98,13 @@ class _Rss extends \IPS\Node\Model
|
||||
* @brief SEO Title Column
|
||||
*/
|
||||
public static $seoTitleColumn = 'seo_title';
|
||||
|
||||
|
||||
/**
|
||||
* Load Record
|
||||
*
|
||||
* @see \IPS\Db::build
|
||||
* @param int|string $id ID
|
||||
* @param string $idField The database column that the $id parameter pertains to (NULL will use static::$databaseColumnId)
|
||||
* @param mixed $extraWhereClause Additional where clause(s) (see \IPS\Db::build for details)
|
||||
* @return static
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \OutOfRangeException
|
||||
* @brief [ActiveRecord] Attempt to load from cache
|
||||
* @note If this is set to TRUE you MUST define a getStore() method to return the objects from cache
|
||||
*/
|
||||
public static function load( $id, $idField=NULL, $extraWhereClause=NULL )
|
||||
{
|
||||
$feeds = static::getAllFeeds();
|
||||
|
||||
if ( isset( $feeds[ $id ] ) )
|
||||
{
|
||||
return $feeds[ $id ];
|
||||
}
|
||||
|
||||
return parent::load( $id, $idField, $extraWhereClause );
|
||||
}
|
||||
|
||||
protected static $loadFromCache = TRUE;
|
||||
|
||||
/**
|
||||
* [Node] Add/Edit Form
|
||||
*
|
||||
@@ -156,9 +139,9 @@ class _Rss extends \IPS\Node\Model
|
||||
$options = array( 'togglesOn' => array( 'rss_nodes_' . $class::$title ) );
|
||||
$containerClass = $class::$containerNodeClass;
|
||||
}
|
||||
|
||||
|
||||
\IPS\Member::loggedIn()->language()->words["rss_classes_{$class}"] = \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'rss_classes_' . $class, ( $this->_id ) ? in_array( $class, $this->configuration['classes'] ) : FALSE, FALSE, $options ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'rss_classes_' . $class, ( $this->_id ) ? \in_array( $class, $this->configuration['classes'] ) : FALSE, FALSE, $options ) );
|
||||
|
||||
if ( $containerClass )
|
||||
{
|
||||
@@ -167,7 +150,8 @@ class _Rss extends \IPS\Node\Model
|
||||
'class' => $containerClass,
|
||||
'zeroVal' => 'all',
|
||||
'multiple' => TRUE,
|
||||
'permissionCheck' => function( $val ) { return $val->can( 'view', new \IPS\Member ); }
|
||||
'permissionCheck' => function( $val ) { return $val->can( 'view', new \IPS\Member ); },
|
||||
'forceOwner' => FALSE,
|
||||
), NULL, NULL, NULL, "rss_nodes_{$class::$title}" ) );
|
||||
}
|
||||
}
|
||||
@@ -176,7 +160,7 @@ class _Rss extends \IPS\Node\Model
|
||||
$members = NULL;
|
||||
if ( $this->_id AND isset( $this->configuration['members'] ) )
|
||||
{
|
||||
if ( count( $this->configuration['members'] ) )
|
||||
if ( \count( $this->configuration['members'] ) )
|
||||
{
|
||||
$members = array();
|
||||
foreach( $this->configuration['members'] AS $member )
|
||||
@@ -218,7 +202,7 @@ class _Rss extends \IPS\Node\Model
|
||||
}
|
||||
else if ( mb_substr( $k, 0, 6 ) == 'nodes_' )
|
||||
{
|
||||
if ( is_array( $v ) )
|
||||
if ( \is_array( $v ) )
|
||||
{
|
||||
foreach( $v AS $id => $node )
|
||||
{
|
||||
@@ -251,7 +235,7 @@ class _Rss extends \IPS\Node\Model
|
||||
/* Set the members */
|
||||
if ( array_key_exists( 'rss_members', $values ) )
|
||||
{
|
||||
if ( is_array( $values['rss_members'] ) )
|
||||
if ( \is_array( $values['rss_members'] ) )
|
||||
{
|
||||
foreach( $values['rss_members'] AS $member )
|
||||
{
|
||||
@@ -281,7 +265,7 @@ class _Rss extends \IPS\Node\Model
|
||||
{
|
||||
\IPS\Lang::saveCustom( 'core', "rss_export_title_{$this->_id}", $values['rss_name'] );
|
||||
|
||||
if ( is_array( $values['rss_name'] ) )
|
||||
if ( \is_array( $values['rss_name'] ) )
|
||||
{
|
||||
reset( $values['rss_name'] );
|
||||
$this->seo_title = \IPS\Http\Url\Friendly::seoTitle( $values['rss_name'][ key( $values['rss_name'] ) ] );
|
||||
@@ -304,32 +288,13 @@ class _Rss extends \IPS\Node\Model
|
||||
/* Pass to parent */
|
||||
return parent::formatFormValues( $values );
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Perform actions after saving the form
|
||||
*
|
||||
* @param array $values Values from the form
|
||||
* @return void
|
||||
*/
|
||||
public function postSaveForm( $values )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->rssFeeds );
|
||||
|
||||
parent::postSaveForm( $values );
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Delete Record
|
||||
*
|
||||
* @return void
|
||||
* @brief [ActiveRecord] Caches
|
||||
* @note Defined cache keys will be cleared automatically as needed
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
parent::delete();
|
||||
protected $caches = array( 'rssFeeds' );
|
||||
|
||||
unset( \IPS\Data\Store::i()->rssFeeds );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Configuration
|
||||
*
|
||||
@@ -343,7 +308,7 @@ class _Rss extends \IPS\Node\Model
|
||||
/**
|
||||
* Set Configuration
|
||||
*
|
||||
* @param array The configuration
|
||||
* @param array $values The configuration
|
||||
* @return void
|
||||
*/
|
||||
public function set_configuration( array $values )
|
||||
@@ -354,12 +319,12 @@ class _Rss extends \IPS\Node\Model
|
||||
/**
|
||||
* Set Groups
|
||||
*
|
||||
* @param array|string The groups, or an asterisk for all groups
|
||||
* @param array|string $values The groups, or an asterisk for all groups
|
||||
* @return void
|
||||
*/
|
||||
public function set_groups( $values )
|
||||
{
|
||||
if ( is_array( $values ) )
|
||||
if ( \is_array( $values ) )
|
||||
{
|
||||
$this->_data['groups'] = implode( ',', $values );
|
||||
}
|
||||
@@ -387,7 +352,7 @@ class _Rss extends \IPS\Node\Model
|
||||
/**
|
||||
* Generate the feed
|
||||
*
|
||||
* @param \IPS\Member|NULL The member, or NULL for a Guest
|
||||
* @param \IPS\Member|NULL $member The member, or NULL for a Guest
|
||||
* @return string
|
||||
*/
|
||||
public function generate( $member=NULL )
|
||||
@@ -397,7 +362,7 @@ class _Rss extends \IPS\Node\Model
|
||||
$search = \IPS\Content\Search\Query::init( $member );
|
||||
$filterByClass = FALSE;
|
||||
|
||||
if ( count( $this->configuration['classes'] ) )
|
||||
if ( \count( $this->configuration['classes'] ) )
|
||||
{
|
||||
$filterByClass = TRUE;
|
||||
$filters = array();
|
||||
@@ -427,7 +392,7 @@ class _Rss extends \IPS\Node\Model
|
||||
$search->filterByContent( $filters );
|
||||
}
|
||||
|
||||
if ( isset( $this->configuration['members'] ) AND count( $this->configuration['members'] ) )
|
||||
if ( isset( $this->configuration['members'] ) AND \count( $this->configuration['members'] ) )
|
||||
{
|
||||
$search->filterByAuthor( $this->configuration['members'] );
|
||||
}
|
||||
@@ -435,7 +400,7 @@ class _Rss extends \IPS\Node\Model
|
||||
$search->setLimit( $this->count );
|
||||
$search->setOrder( \IPS\Content\Search\Query::ORDER_NEWEST_CREATED );
|
||||
|
||||
if( $filterByClass == TRUE AND !count( $filters ) )
|
||||
if( $filterByClass == TRUE AND !\count( $filters ) )
|
||||
{
|
||||
$results = array();
|
||||
}
|
||||
@@ -459,39 +424,29 @@ class _Rss extends \IPS\Node\Model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get All Available Feeds
|
||||
* Get all saved RSS feeds (enabled status must be checked in userland code)
|
||||
*
|
||||
* @return array
|
||||
* @deprecated
|
||||
*/
|
||||
public static function getAllFeeds()
|
||||
{
|
||||
return static::getStore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all saved RSS feeds (enabled status must be checked in userland code)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getStore()
|
||||
{
|
||||
if ( !isset( \IPS\Data\Store::i()->rssFeeds ) )
|
||||
{
|
||||
$rows = array();
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_rss_export', NULL, 'rss_position' ) AS $row )
|
||||
{
|
||||
$rows[ $row['rss_id'] ] = $row;
|
||||
}
|
||||
|
||||
\IPS\Data\Store::i()->rssFeeds = $rows;
|
||||
\IPS\Data\Store::i()->rssFeeds = iterator_to_array( \IPS\Db::i()->select( '*', static::$databaseTable, NULL, "rss_position ASC" )->setKeyField( 'rss_id' ) );
|
||||
}
|
||||
|
||||
$return = array();
|
||||
|
||||
if ( count( \IPS\Data\Store::i()->rssFeeds ) )
|
||||
{
|
||||
foreach( \IPS\Data\Store::i()->rssFeeds AS $feed_id => $feed )
|
||||
{
|
||||
$feed = static::constructFromData( $feed );
|
||||
|
||||
if ( $feed->_enabled )
|
||||
{
|
||||
$return[ $feed->_id ] = $feed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
return \IPS\Data\Store::i()->rssFeeds;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user