Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
@@ -57,11 +57,25 @@ class _Database extends \IPS\Widget
|
||||
}
|
||||
|
||||
$databases = array();
|
||||
$disabled = array();
|
||||
|
||||
foreach( \IPS\cms\Databases::databases() as $db )
|
||||
{
|
||||
if ( ! $db->page_id )
|
||||
$databases[ $db->id ] = $db->_title;
|
||||
|
||||
if ( $db->page_id )
|
||||
{
|
||||
$databases[ $db->id ] = $db->_title;
|
||||
$disabled[] = $db->id;
|
||||
|
||||
try
|
||||
{
|
||||
$page = \IPS\cms\Pages\Page::load( $db->page_id );
|
||||
$databases[ $db->id ] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_db_in_use_by_page', NULL, array( 'sprintf' => array( $db->_title, $page->full_path ) ) );
|
||||
}
|
||||
catch( \OutOfRangeException $ex )
|
||||
{
|
||||
unset( $databases[ $db->id ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +85,7 @@ class _Database extends \IPS\Widget
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'database', ( isset( $this->configuration['database'] ) ? $this->configuration['database'] : NULL ), FALSE, array( 'options' => $databases ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'database', ( isset( $this->configuration['database'] ) ? $this->configuration['database'] : NULL ), FALSE, array( 'options' => $databases, 'disabled' => $disabled ) ) );
|
||||
}
|
||||
|
||||
return $form;
|
||||
|
||||
@@ -22,7 +22,7 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* RecordFeed Widget
|
||||
*/
|
||||
class _RecordFeed extends \IPS\Widget\PermissionCache
|
||||
class _RecordFeed extends \IPS\Content\Widget
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
@@ -40,16 +40,9 @@ class _RecordFeed extends \IPS\Widget\PermissionCache
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Initialise this widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
// Use this to perform any set up and to assign a template that is not in the following format:
|
||||
// $this->template( array( \IPS\Theme::i()->getTemplate( 'widgets', $this->app, 'front' ), $this->key ) );
|
||||
}
|
||||
* Class
|
||||
*/
|
||||
protected static $class = 'IPS\cms\Records';
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
@@ -73,9 +66,10 @@ class _RecordFeed extends \IPS\Widget\PermissionCache
|
||||
$databases[ $obj->_id ] = $obj->_title;
|
||||
}
|
||||
|
||||
if ( isset( $this->configuration['cms_rf_database'] ) AND $obj->id == $this->configuration['cms_rf_database'] )
|
||||
if ( ( isset( \IPS\Request::i()->cms_rf_database ) AND $obj->id == \IPS\Request::i()->cms_rf_database ) OR ( ( isset( $this->configuration['cms_rf_database'] ) AND $obj->id == $this->configuration['cms_rf_database'] ) ) )
|
||||
{
|
||||
$database = $obj;
|
||||
static::$class = '\IPS\cms\Records' . $database->id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,26 +78,7 @@ class _RecordFeed extends \IPS\Widget\PermissionCache
|
||||
'options' => $databases
|
||||
) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'cms_rf_category', isset( $this->configuration['cms_rf_category'] ) ? $this->configuration['cms_rf_category'] : 0, FALSE, array(
|
||||
'class' => '\IPS\cms\Categories' . ( isset( $this->configuration['cms_rf_database'] ) ? $this->configuration['cms_rf_database'] : '' ),
|
||||
'zeroVal' => 'cms_rf_all_categories',
|
||||
'permissionCheck' => 'view',
|
||||
'multiple' => true
|
||||
) ) );
|
||||
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'cms_rf_record_status', isset( $this->configuration['cms_rf_record_status'] ) ? $this->configuration['cms_rf_record_status'] : array( 'open', 'pinned', 'notpinned', 'visible', 'featured', 'notfeatured' ), FALSE, array(
|
||||
'options' => array(
|
||||
'open' => 'cms_rf_open_status_open',
|
||||
'closed' => 'cms_rf_open_status_closed',
|
||||
'pinned' => 'cms_rf_open_status_pinned',
|
||||
'notpinned' => 'cms_rf_open_status_notpinned',
|
||||
'visible' => 'cms_rf_open_status_visible',
|
||||
'hidden' => 'cms_rf_open_status_hidden',
|
||||
'featured' => 'cms_rf_open_status_featured',
|
||||
'notfeatured' => 'cms_rf_open_status_notfeatured'
|
||||
)
|
||||
) ) );
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
/* Tags */
|
||||
if ( $database and $database->tags_enabled )
|
||||
@@ -122,49 +97,18 @@ class _RecordFeed extends \IPS\Widget\PermissionCache
|
||||
|
||||
$options['autocomplete']['prefix'] = FALSE;
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'cms_rf_tags', ( isset( $this->configuration['cms_rf_tags'] ) ? $this->configuration['cms_rf_tags'] : array( 'tags' => NULL ) ), FALSE, $options ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'widget_feed_tags', ( isset( $this->configuration['widget_feed_tags'] ) ? $this->configuration['widget_feed_tags'] : array( 'tags' => NULL ) ), FALSE, $options ) );
|
||||
}
|
||||
|
||||
$author = NULL;
|
||||
|
||||
try
|
||||
|
||||
if ( $database )
|
||||
{
|
||||
if ( isset( $this->configuration['cms_rf_author'] ) and is_array( $this->configuration['cms_rf_author'] ) )
|
||||
{
|
||||
foreach( $this->configuration['cms_rf_author'] as $id )
|
||||
{
|
||||
$author[ $id ] = \IPS\Member::load( $id );
|
||||
}
|
||||
}
|
||||
\IPS\Member::loggedIn()->language()->words['widget_feed_container_content_db_lang_su_' . $database->id ] = \IPS\Member::loggedIn()->language()->addToStack('widget_feed_container_cms');
|
||||
}
|
||||
catch( \OutOfRangeException $ex ) { }
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'cms_rf_author', $author, FALSE, array( 'multiple' => true ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'cms_rf_min_posts', isset( $this->configuration['cms_rf_min_posts'] ) ? $this->configuration['cms_rf_min_posts'] : 0, FALSE, array( 'unlimitedLang' => 'cms_rf_min_posts_any', 'unlimited' => 0 ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'cms_rf_show', isset( $this->configuration['cms_rf_show'] ) ? $this->configuration['cms_rf_show'] : 5, TRUE ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'cms_rf_sort_on', isset( $this->configuration['cms_rf_sort_on'] ) ? $this->configuration['cms_rf_sort_on'] : 'record_last_comment', FALSE, array(
|
||||
'options' => array(
|
||||
'record_last_comment' => 'cms_rf_record_last_comment',
|
||||
'record_title' => 'cms_rf_title',
|
||||
'record_comments' => 'cms_rf_record_comments',
|
||||
'record_publish_date' => 'cms_rf_record_publish_date',
|
||||
'record_views' => 'cms_rf_record_views'
|
||||
)
|
||||
) ), NULL, NULL, NULL, 'cms_rf_sort_on' );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'cms_rf_sort_dir', isset( $this->configuration['cms_rf_sort_dir'] ) ? $this->configuration['cms_rf_sort_dir'] : 'desc', FALSE, array(
|
||||
'options' => array(
|
||||
'desc' => 'cms_rf_sort_dir_dsc',
|
||||
'asc' => 'cms_rf_sort_dir_asc'
|
||||
)
|
||||
) ) );
|
||||
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Ran before saving widget configuration
|
||||
*
|
||||
* @param array $values Values from form
|
||||
@@ -172,7 +116,8 @@ class _RecordFeed extends \IPS\Widget\PermissionCache
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
{
|
||||
return $values;
|
||||
static::$class = '\IPS\cms\Records' . $values['cms_rf_database'];
|
||||
return parent::preConfig( $values );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,6 +132,7 @@ class _RecordFeed extends \IPS\Widget\PermissionCache
|
||||
try
|
||||
{
|
||||
$database = \IPS\cms\Databases::load($this->configuration['cms_rf_database']);
|
||||
static::$class = '\IPS\cms\Records' . $database->id;
|
||||
|
||||
if ( ! $database->page_id )
|
||||
{
|
||||
@@ -203,109 +149,6 @@ class _RecordFeed extends \IPS\Widget\PermissionCache
|
||||
return '';
|
||||
}
|
||||
|
||||
$where = array();
|
||||
$order = NULL;
|
||||
$limit = isset( $this->configuration['cms_rf_show'] ) ? $this->configuration['cms_rf_show'] : 5;
|
||||
$permissionKey = 'read';
|
||||
$includeHidden = false;
|
||||
|
||||
if ( isset( $this->configuration['cms_rf_category'] ) and is_array( $this->configuration['cms_rf_category'] ) )
|
||||
{
|
||||
$where[] = array( 'category_id IN (' . implode( ",", array_values( $this->configuration['cms_rf_category'] ) ) . ')' );
|
||||
}
|
||||
|
||||
if ( isset( $this->configuration['cms_rf_record_status'] ) and is_array( $this->configuration['cms_rf_record_status'] ) )
|
||||
{
|
||||
$status = array_values( $this->configuration['cms_rf_record_status'] );
|
||||
|
||||
if ( ! in_array( 'open', $status ) or ! in_array( 'closed', $status ) )
|
||||
{
|
||||
if ( ! in_array( 'open', $status ) )
|
||||
{
|
||||
$where[] = array( "record_locked=1" );
|
||||
}
|
||||
else if ( ! in_array( 'closed', $status ) )
|
||||
{
|
||||
$where[] = array( "record_locked=0" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( 'hidden', $status ) )
|
||||
{
|
||||
$includeHidden = true;
|
||||
}
|
||||
|
||||
if ( ! in_array( 'featured', $status ) or ! in_array( 'notfeatured', $status ) )
|
||||
{
|
||||
if ( ! in_array( 'featured', $status ) )
|
||||
{
|
||||
$where[] = array( 'record_featured=0' );
|
||||
}
|
||||
else if ( ! in_array( 'notfeatured', $status ) )
|
||||
{
|
||||
$where[] = array( 'record_featured=1' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! in_array( 'pinned', $status ) or ! in_array( 'notpinned', $status ) )
|
||||
{
|
||||
if ( ! in_array( 'pinned', $status ) )
|
||||
{
|
||||
$where[] = array( 'record_pinned=0' );
|
||||
}
|
||||
else if ( ! in_array( 'notpinned', $status ) )
|
||||
{
|
||||
$where[] = array( 'record_pinned=1' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $this->configuration['cms_rf_author'] ) and !empty( $this->configuration['cms_rf_author'] ) )
|
||||
{
|
||||
$where[] = array( "starter_id IN(" . implode( ',', $this->configuration['cms_rf_author'] ) . ")" );
|
||||
}
|
||||
|
||||
if ( isset( $this->configuration['cms_rf_sort_on'] ) and isset( $this->configuration['cms_rf_sort_on'] ) )
|
||||
{
|
||||
if ( $this->configuration['cms_rf_sort_on'] == 'record_title' )
|
||||
{
|
||||
$this->configuration['cms_rf_sort_on'] = $database->field_title;
|
||||
}
|
||||
|
||||
$order = $this->configuration['cms_rf_sort_on'] . ' ' . $this->configuration['cms_rf_sort_dir'];
|
||||
}
|
||||
|
||||
/* Tags */
|
||||
if ( isset( $this->configuration['cms_rf_tags'] ) and $this->configuration['cms_rf_tags'] )
|
||||
{
|
||||
$tagsWhere = array( array( 'tag_meta_app=? AND tag_meta_area=?', 'cms', 'records' . $database->_id ) );
|
||||
|
||||
if ( isset( $this->configuration['cms_rf_category'] ) and is_array( $this->configuration['cms_rf_category'] ) )
|
||||
{
|
||||
$tagsWhere[] = array( 'tag_meta_parent_id IN (' . implode( array_values( $this->configuration['cms_rf_category'] ) ) . ')' );
|
||||
}
|
||||
|
||||
$ids = array();
|
||||
foreach( \IPS\Db::i()->select('tag_meta_id', 'core_tags', $tagsWhere, 'tag_added DESC', array(0, 250) ) as $tag )
|
||||
{
|
||||
$ids[] = $tag['tag_meta_id'];
|
||||
}
|
||||
|
||||
if ( count( $ids ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in('primary_id_field', $ids ) );
|
||||
}
|
||||
}
|
||||
|
||||
$class = '\IPS\cms\Records' . $database->_id;
|
||||
$records = $class::getItemsWithPermission( $where, $order, $limit, $permissionKey, $includeHidden );
|
||||
if ( count( $records ) )
|
||||
{
|
||||
return $this->output( $database, $records );
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,34 @@ class _Wysiwyg extends \IPS\Widget\StaticCache
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Before the widget is removed, we can do some clean up
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_attachments_map', array( array( 'location_key=? and id3=?', 'cms_Widgets', $this->uniqueKey ) ) ) as $map )
|
||||
{
|
||||
try
|
||||
{
|
||||
$attachment = \IPS\Db::i()->select( '*', 'core_attachments', array( 'attach_id=?', $map['attachment_id'] ) )->first();
|
||||
|
||||
\IPS\Db::i()->delete( 'core_attachments_map', array( array( 'attachment_id=?', $attachment['attach_id'] ) ) );
|
||||
\IPS\Db::i()->delete( 'core_attachments', array( 'attach_id=?', $attachment['attach_id'] ) );
|
||||
|
||||
|
||||
\IPS\File::get( 'core_Attachment', $attachment['attach_location'] )->delete();
|
||||
if ( $attachment['attach_thumb_location'] )
|
||||
{
|
||||
\IPS\File::get( 'core_Attachment', $attachment['attach_thumb_location'] )->delete();
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-save config method
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user