Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,36 +12,53 @@
|
||||
namespace IPS\blog\modules\front\blogs;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\blog\Blog;
|
||||
use IPS\blog\Entry;
|
||||
use IPS\core\FrontNavigation;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit
|
||||
*/
|
||||
class _submit extends \IPS\Dispatcher\Controller
|
||||
class submit extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief This blog
|
||||
*/
|
||||
protected $blog = NULL;
|
||||
protected ?Blog $blog = NULL;
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->id ) )
|
||||
if ( isset( Request::i()->id ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->blog = \IPS\blog\Blog::load( \IPS\Request::i()->id );
|
||||
$this->blog = Blog::load( Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e ) {}
|
||||
\IPS\blog\Entry::canCreate( \IPS\Member::loggedIn(), $this->blog, TRUE );
|
||||
catch( OutOfRangeException ) {}
|
||||
Entry::canCreate( Member::loggedIn(), $this->blog, TRUE );
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
@@ -52,9 +69,9 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'submit_entry' );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'submit_entry' );
|
||||
|
||||
/* Load Blog */
|
||||
try
|
||||
@@ -62,54 +79,54 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
/* Can we add to this Blog? We load the blog in execute, so emulate an OutOfRangeException here if we don't actually have one. */
|
||||
if ( $this->blog === NULL )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
\IPS\blog\Entry::canCreate( \IPS\Member::loggedIn(), $this->blog, TRUE );
|
||||
Entry::canCreate( Member::loggedIn(), $this->blog, TRUE );
|
||||
|
||||
$form = \IPS\blog\Entry::create( $this->blog );
|
||||
$formTemplate = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'submit', 'blog' ), 'submitFormTemplate' ) );
|
||||
$form = Entry::create( $this->blog );
|
||||
$formTemplate = $form->customTemplate( array( Theme::i()->getTemplate( 'submit', 'blog' ), 'submitFormTemplate' ) );
|
||||
|
||||
if ( $club = $this->blog->club() )
|
||||
{
|
||||
\IPS\core\FrontNavigation::$clubTabActive = TRUE;
|
||||
\IPS\Output::i()->breadcrumb = array();
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), \IPS\Member::loggedIn()->language()->addToStack('module__core_clubs') );
|
||||
\IPS\Output::i()->breadcrumb[] = array( $club->url(), $club->name );
|
||||
FrontNavigation::$clubTabActive = TRUE;
|
||||
Output::i()->breadcrumb = array();
|
||||
Output::i()->breadcrumb[] = array( Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), Member::loggedIn()->language()->addToStack('module__core_clubs') );
|
||||
Output::i()->breadcrumb[] = array( $club->url(), $club->name );
|
||||
|
||||
if ( \IPS\Settings::i()->clubs_header == 'sidebar' )
|
||||
if ( Settings::i()->clubs_header == 'sidebar' )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $this->blog, 'sidebar' );
|
||||
Output::i()->sidebar['contextual'] = Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $this->blog, 'sidebar' );
|
||||
}
|
||||
}
|
||||
\IPS\Output::i()->breadcrumb[] = array( $this->blog->url(), $this->blog->_title );
|
||||
Output::i()->breadcrumb[] = array( $this->blog->url(), $this->blog->_title );
|
||||
|
||||
if( !$this->blog->social_group )
|
||||
{
|
||||
\IPS\Session::i()->setLocation( $this->blog->url(), array(), 'loc_blog_adding_entry', array( $this->blog->_title => FALSE ) );
|
||||
Session::i()->setLocation( $this->blog->url(), array(), 'loc_blog_adding_entry', array( $this->blog->_title => FALSE ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'submit' )->submit( $formTemplate, $this->blog );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'submit' )->submit( $formTemplate, $this->blog );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'select_blog', 'continue' );
|
||||
$form->class = 'ipsForm_vertical ipsForm_noLabels';
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'blog_select', NULL, TRUE, array(
|
||||
'url' => \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=submit', 'front', 'blog_submit' ),
|
||||
$form = new Form( 'select_blog', 'continue' );
|
||||
$form->class = 'ipsForm--vertical ipsForm--manage-blog ipsForm--noLabels';
|
||||
$form->add( new Node( 'blog_select', NULL, TRUE, array(
|
||||
'url' => Url::internal( 'app=blog&module=blogs&controller=submit', 'front', 'blog_submit' ),
|
||||
'class' => 'IPS\blog\Blog',
|
||||
'permissionCheck' => 'add',
|
||||
'forceOwner' => \IPS\Member::loggedIn(),
|
||||
'clubs' => \IPS\Settings::i()->club_nodes_in_apps
|
||||
'forceOwner' => Member::loggedIn(),
|
||||
'clubs' => Settings::i()->club_nodes_in_apps
|
||||
) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$url = \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=submit', 'front', 'blog_submit' )->setQueryString( 'id', $values['blog_select']->_id );
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
$url = Url::internal( 'app=blog&module=blogs&controller=submit', 'front', 'blog_submit' )->setQueryString( 'id', $values['blog_select']->_id );
|
||||
Output::i()->redirect( $url );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'submit' )->blogSelector( $form );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'submit' )->blogSelector( $form );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user