Version 4.0.13.1
This commit is contained in:
1 parent
f9e857d255
commit
c6a86f0d9b
7517 files changed
+597400
-668041
No files matched your search
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Custom Blocks Block
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage content
|
||||
* @since 17 Oct 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom block Widget
|
||||
*/
|
||||
class _Blocks extends \IPS\Widget\PermissionCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'Blocks';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'cms';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param String $uniqueKey Unique key for this specific instance
|
||||
* @param array $configuration Widget custom configuration
|
||||
* @param null|string|array $access Array/JSON string of executable apps (core=sidebar only, content=IP.Content only, etc)
|
||||
* @param null|string $orientation Orientation (top, bottom, right, left)
|
||||
* @param boolean $allowReuse If true, when the block is used, it will remain in the sidebar so it can be used again.
|
||||
* @param string $menuStyle Menu is a drop down menu, modal is a bigger modal panel.
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $uniqueKey, array $configuration, $access=null, $orientation=null )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( isset( $configuration['cms_widget_custom_block'] ) )
|
||||
{
|
||||
$block = \IPS\cms\Blocks\Block::load( $configuration['cms_widget_custom_block'], 'block_key' );
|
||||
if ( $block->type === 'custom' AND ! $block->cache )
|
||||
{
|
||||
$this->neverCache = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ) { }
|
||||
|
||||
parent::__construct( $uniqueKey, $configuration, $access, $orientation );
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form Form Object
|
||||
* @return null|\IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'cms_widget_custom_block', ( isset( $this->configuration['cms_widget_custom_block'] ) ? $this->configuration['cms_widget_custom_block'] : NULL ), FALSE, array(
|
||||
'class' => '\IPS\cms\Blocks\Container',
|
||||
'permissionCheck' => function( $node )
|
||||
{
|
||||
if ( $node instanceof \IPS\cms\Blocks\Container )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
) ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre config
|
||||
*
|
||||
* @param array $values Form values
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
{
|
||||
$newValues = array();
|
||||
|
||||
if ( isset( $values['cms_widget_custom_block'] ) )
|
||||
{
|
||||
$newValues['cms_widget_custom_block'] = $values['cms_widget_custom_block']->key;
|
||||
}
|
||||
|
||||
return $newValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ( isset( $this->configuration['cms_widget_custom_block'] ) )
|
||||
{
|
||||
return (string) \IPS\cms\Blocks\Block::display( $this->configuration['cms_widget_custom_block'], $this->orientation );
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Categories Widget
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage content
|
||||
* @since 24 Sept 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Categories Widget
|
||||
*/
|
||||
class _Categories extends \IPS\Widget\PermissionCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'Categories';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'cms';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
/* Scope makes it possible for this block to fire before the main block which sets up the dispatcher */
|
||||
$db = NULL;
|
||||
if ( ! \IPS\cms\Databases\Dispatcher::i()->databaseId )
|
||||
{
|
||||
try
|
||||
{
|
||||
$db = \IPS\cms\Pages\Page::$currentPage->getDatabase()->id;
|
||||
}
|
||||
catch( \Exception $ex )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$db = \IPS\cms\Databases\Dispatcher::i()->databaseId;
|
||||
}
|
||||
|
||||
if ( ! \IPS\cms\Pages\Page::$currentPage->full_path or ! $db )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=page&path=" . \IPS\cms\Pages\Page::$currentPage->full_path, 'front', 'content_page_path', \IPS\cms\Pages\Page::$currentPage->full_path );
|
||||
|
||||
return $this->output($url);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Database Widget
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage content
|
||||
* @since 22 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Database Widget
|
||||
*/
|
||||
class _Database extends \IPS\Widget
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'Database';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'cms';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* @brief HTML if widget is called more than once, we store it.
|
||||
*/
|
||||
protected static $html = NULL;
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @return null|\IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
|
||||
$databases = array();
|
||||
foreach( \IPS\cms\Databases::databases() as $db )
|
||||
{
|
||||
if ( ! $db->page_id )
|
||||
{
|
||||
$databases[ $db->id ] = $db->_title;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! count( $databases ) )
|
||||
{
|
||||
$form->addMessage('cms_err_no_databases_to_use');
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'database', ( isset( $this->configuration['database'] ) ? $this->configuration['database'] : NULL ), FALSE, array( 'options' => $databases ) ) );
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre save
|
||||
*
|
||||
* @param array $values Form values
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
{
|
||||
if ( \IPS\Request::i()->pageID and $values['database'] )
|
||||
{
|
||||
\IPS\cms\Pages\Page::load( \IPS\Request::i()->pageID )->mapToDatabase( $values['database'] );
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ( self::$html === NULL )
|
||||
{
|
||||
if ( isset( $this->configuration['database'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$database = \IPS\cms\Databases::load( intval( $this->configuration['database'] ) );
|
||||
self::$html = \IPS\cms\Databases\Dispatcher::i()->setDatabase( $database->id )->run();
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
self::$html = '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
return self::$html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief DatabaseFilters Widget
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage content
|
||||
* @since 02 Sept 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* LatestArticles Widget
|
||||
*/
|
||||
class _DatabaseFilters extends \IPS\Widget
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'DatabaseFilters';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'cms';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
/* Viewing a record */
|
||||
if ( \IPS\cms\Databases\Dispatcher::i()->recordId )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( ! \IPS\cms\Databases\Dispatcher::i()->databaseId AND ! \IPS\cms\Databases\Dispatcher::i()->categoryId )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$database = \IPS\cms\Databases::load( \IPS\cms\Databases\Dispatcher::i()->databaseId );
|
||||
$database->preLoadWords();
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$category = \IPS\cms\Categories::load( \IPS\cms\Databases\Dispatcher::i()->categoryId );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( ! $database->use_categories AND $database->cat_index_type !== 0 )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$fieldClass = 'IPS\cms\Fields' . $database->id;
|
||||
|
||||
$fields = array();
|
||||
$cookie = $category->getFilterCookie();
|
||||
$cookieValues = ( $cookie !== NULL ) ? array_combine( array_map( create_function( '$k', 'return "field_" . $k;'), array_keys( $cookie ) ), $cookie ) : array();
|
||||
|
||||
foreach( $fieldClass::fields( $cookieValues, 'view', $category, $fieldClass::FIELD_SKIP_TITLE_CONTENT | $fieldClass::FIELD_DISPLAY_FILTERS ) as $id => $field )
|
||||
{
|
||||
$fields[ $id ] = $field;
|
||||
}
|
||||
|
||||
if ( count( $fields ) )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'category_filters', 'update', $category->url() );
|
||||
$form->class = 'ipsForm_vertical';
|
||||
if ( \IPS\Request::i()->sortby )
|
||||
{
|
||||
$form->hiddenValues['sortby'] = \IPS\Request::i()->sortby;
|
||||
$form->hiddenValues['sortdirection'] = isset( \IPS\Request::i()->sortdirection ) ? \IPS\Request::i()->sortdirection : 'desc';
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->hiddenValues['sortby'] = $database->field_sort;
|
||||
$form->hiddenValues['sortdirection'] = $database->field_direction;
|
||||
}
|
||||
|
||||
$form->hiddenValues['record_type'] = 'all';
|
||||
$form->hiddenValues['time_frame'] = 'show_all';
|
||||
|
||||
foreach( $fields as $id => $field )
|
||||
{
|
||||
$form->add( $field );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Checkbox( 'cms_widget_filters_remember', ( $cookie !== NULL ) ? TRUE : FALSE , FALSE, array( 'label' => 'cms_widget_filters_remember_text') ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$url = $category->url()->setQueryString( array( 'advanced_search_submitted' => 1, 'csrfKey' => \IPS\Session::i()->csrfKey ) );
|
||||
$cookie = array();
|
||||
$params = array();
|
||||
foreach( $values as $k => $v )
|
||||
{
|
||||
if ( mb_substr( $k, 0, 14 ) === 'content_field_' )
|
||||
{
|
||||
$cookie[ mb_substr( $k, 14 ) ] = $v;
|
||||
$params[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $form->hiddenValues ) )
|
||||
{
|
||||
foreach( $form->hiddenValues as $k => $v )
|
||||
{
|
||||
if ( $k !== 'csrfKey' )
|
||||
{
|
||||
if ( !in_array( $k, array( 'sortby', 'sortdirection' ) ) )
|
||||
{
|
||||
$cookie[ $k ] = $v;
|
||||
}
|
||||
$params[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $values['cms_widget_filters_remember'] )
|
||||
{
|
||||
$category->saveFilterCookie( $cookie );
|
||||
\IPS\Output::i()->redirect( $category->url() );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $url->setQueryString( $params ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $this->output( $database, $category, $form );
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief RecordFeed Widget
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage cms
|
||||
* @since 24 Nov 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* RecordFeed Widget
|
||||
*/
|
||||
class _RecordFeed extends \IPS\Widget\PermissionCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'RecordFeed';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'cms';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
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 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return null|\IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
|
||||
$databases = array();
|
||||
$database = NULL;
|
||||
foreach( \IPS\cms\Databases::databases() as $obj )
|
||||
{
|
||||
if ( $obj->page_id )
|
||||
{
|
||||
$databases[ $obj->_id ] = $obj->_title;
|
||||
}
|
||||
|
||||
if ( isset( $this->configuration['cms_rf_database'] ) AND $obj->id == $this->configuration['cms_rf_database'] )
|
||||
{
|
||||
$database = $obj;
|
||||
}
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'cms_rf_database', isset( $this->configuration['cms_rf_database'] ) ? $this->configuration['cms_rf_database'] : 0, FALSE, array(
|
||||
'disabled' => isset( $this->configuration['cms_rf_database'] ) ? true : false,
|
||||
'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'
|
||||
)
|
||||
) ) );
|
||||
|
||||
/* Tags */
|
||||
if ( $database and $database->tags_enabled )
|
||||
{
|
||||
$options = array( 'autocomplete' => array( 'unique' => TRUE, 'source' => NULL, 'freeChoice' => TRUE ) );
|
||||
|
||||
if ( \IPS\Settings::i()->tags_force_lower )
|
||||
{
|
||||
$options['autocomplete']['forceLower'] = TRUE;
|
||||
}
|
||||
|
||||
if ( \IPS\Settings::i()->tags_clean )
|
||||
{
|
||||
$options['autocomplete']['filterProfanity'] = TRUE;
|
||||
}
|
||||
|
||||
$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 ) );
|
||||
}
|
||||
|
||||
$author = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
{
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if( isset( $this->configuration['cms_rf_database'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$database = \IPS\cms\Databases::load($this->configuration['cms_rf_database']);
|
||||
|
||||
if ( ! $database->page_id )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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 '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Rss Widget
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage cms
|
||||
* @since 10 Dec 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rss Widget
|
||||
*/
|
||||
class _Rss extends \IPS\Widget\StaticCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'Rss';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'cms';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
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 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return null|\IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'block_rss_import_title', ( isset( $this->configuration['block_rss_import_title'] ) ? $this->configuration['block_rss_import_title'] : NULL ), TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'block_rss_import_url', ( isset( $this->configuration['block_rss_import_url'] ) ? $this->configuration['block_rss_import_url'] : NULL ), TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'block_rss_import_number', ( isset( $this->configuration['block_rss_import_number'] ) ? $this->configuration['block_rss_import_number'] : 5 ), TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'block_rss_import_cache', ( isset( $this->configuration['block_rss_import_cache'] ) ? $this->configuration['block_rss_import_cache'] : 30 ), TRUE, array(), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('block_rss_import_cache_suffix') ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ran before saving widget configuration
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
{
|
||||
$values['block_rss_import_url'] = (string) $values['block_rss_import_url'];
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ( ! isset( $this->configuration['block_rss_import_url'] ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$key = "cms_rss_import_" . md5( json_encode( $this->configuration ) );
|
||||
|
||||
if ( isset( \IPS\Data\Store::i()->$key ) )
|
||||
{
|
||||
$cache = \IPS\Data\Store::i()->$key;
|
||||
|
||||
if ( isset( $cache['time'] ) and isset( $cache['items'] ) and $cache['time'] > ( time() - ( $this->configuration['block_rss_import_cache'] * 60 ) ) )
|
||||
{
|
||||
return $this->output( $cache['items'], $this->configuration['block_rss_import_title'] );
|
||||
}
|
||||
}
|
||||
|
||||
/* Still here? Best grab the data then */
|
||||
try
|
||||
{
|
||||
$request = \IPS\Http\Url::external( $this->configuration['block_rss_import_url'] )->request()->get();
|
||||
|
||||
$i = 0;
|
||||
$items = array();
|
||||
foreach ( $request->decodeXml()->articles() as $guid => $article )
|
||||
{
|
||||
if ( isset( $article['title'] ) and isset( $article['link'] ) )
|
||||
{
|
||||
$items[ $guid ] = array(
|
||||
'title' => $article['title'],
|
||||
'content' => \IPS\Text\Parser::parseStatic( $article['content'] ),
|
||||
'link' => (string) $article['link'],
|
||||
'date' => ( $article['date'] instanceof \IPS\DateTime ) ? $article['date']->getTimestamp() : $article['date']
|
||||
);
|
||||
}
|
||||
|
||||
$i++;
|
||||
|
||||
if ( $i >= $this->configuration['block_rss_import_number'] )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
$items = array();
|
||||
}
|
||||
|
||||
\IPS\Data\Store::i()->$key = array( 'time' => time(), 'items' => $items );
|
||||
|
||||
return $this->output( $items, $this->configuration['block_rss_import_title'] );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief WYSIWYG Widget
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage content
|
||||
* @since 22 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* WYSIWYG Widget
|
||||
*/
|
||||
class _Wysiwyg extends \IPS\Widget\StaticCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'Wysiwyg';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'cms';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @return null|\IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'content', ( isset( $this->configuration['content'] ) ? $this->configuration['content'] : NULL ), FALSE, array(
|
||||
'app' => $this->app,
|
||||
'key' => 'Widgets',
|
||||
'autoSaveKey' => 'widget-' . $this->uniqueKey,
|
||||
'attachIds' => isset( $this->configuration['content'] ) ? array( 0, 0, $this->uniqueKey ) : NULL
|
||||
) ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-save config method
|
||||
*
|
||||
* @param array $values Form values
|
||||
* @return void
|
||||
*/
|
||||
public function preConfig( $values=array() )
|
||||
{
|
||||
\IPS\File::claimAttachments( 'widget-' . $this->uniqueKey, 0, 0, $this->uniqueKey );
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return $this->output( isset( $this->configuration['content'] ) ? $this->configuration['content'] : '' );
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
Reference in new issue
Block a user