Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Ajax only methods
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Content
|
||||
* @since 01 Oct 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\modules\front\database;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief [Database] Category Controller
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Content
|
||||
* @since 16 April 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\modules\front\database;
|
||||
@@ -186,12 +185,12 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
{
|
||||
if ( $obj->type == 'Number' )
|
||||
{
|
||||
$table->sortOptions['field_' . $id ] = 'LENGTH(`field_' . $id . '`) ' . $table->sortDirection . ',`field_' . $id . '`';
|
||||
$table->sortBy = 'LENGTH(`field_' . $id . '`) ' . $table->sortDirection . ',`field_' . $id . '`';
|
||||
break;
|
||||
}
|
||||
elseif( $obj->type == 'Date' )
|
||||
{
|
||||
$table->sortOptions['field_' . $id ] = 'CAST(`field_' . $id . '` AS UNSIGNED)';
|
||||
$table->sortBy = 'CAST(`field_' . $id . '` AS UNSIGNED)';
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -255,7 +254,7 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
break;
|
||||
case 'record_rating':
|
||||
$sortBy[ $database->field_sort ] = 'database_field__rating';
|
||||
$table->sortOptions['database_field__rating'] = $database->field_sort;
|
||||
$table->sortOptions['rating'] = $database->field_sort;
|
||||
\IPS\Member::loggedIn()->language()->words['sort_database_field__rating'] = \IPS\Member::loggedIn()->language()->addToStack('database_field__rating');
|
||||
break;
|
||||
}
|
||||
@@ -303,11 +302,11 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
if ( $obj->filter )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['content_field_' . $obj->id ] = $obj->_title;
|
||||
if ( $obj->type == 'DateRange' )
|
||||
if ( in_array( $obj->type, array( 'Date', 'DateRange' ) ) )
|
||||
{
|
||||
$table->advancedSearch[ 'content_field_' . $obj->id ] = array( \IPS\Helpers\Table\SEARCH_DATE_RANGE, array( 'noDefault' => true ) );
|
||||
}
|
||||
if ( $obj->type == 'Number' )
|
||||
else if ( $obj->type == 'Number' )
|
||||
{
|
||||
$table->advancedSearch[ 'content_field_' . $obj->id ] = array( \IPS\Helpers\Table\SEARCH_NUMERIC_TEXT, array( 'noDefault' => true ) );
|
||||
}
|
||||
@@ -562,7 +561,7 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
\IPS\Output::i()->allowDefaultWidgets = FALSE;
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\cms\Pages\Page::$currentPage->getWidgets();
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\cms\Theme::i(), 'getTemplate' ), array( $database->template_form, 'cms', 'database' ) ), 'recordForm' ), NULL, $category, $database, \IPS\cms\Pages\Page::$currentPage, $title, $hasModOptions );
|
||||
\IPS\cms\Databases\Dispatcher::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\cms\Theme::i(), 'getTemplate' ), array( $database->template_form, 'cms', 'database' ) ), 'recordForm' ), NULL, $category, $database, \IPS\cms\Pages\Page::$currentPage, $title, $hasModOptions );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( $title );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'records/form.css', 'cms', 'front' ) );
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief [Database] Category List Controller
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Content
|
||||
* @since 16 April 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\modules\front\database;
|
||||
@@ -141,7 +140,7 @@ class _index extends \IPS\cms\Databases\Controller
|
||||
|
||||
/* Load into memory */
|
||||
$class::loadIntoMemory();
|
||||
$categories = $class::roots('view', \IPS\Member::loggedIn(), null, $database->_id );
|
||||
$categories = $class::roots();
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'records/index.css', 'cms', 'front' ) );
|
||||
\IPS\Output::i()->title = $database->pageTitle();
|
||||
@@ -182,8 +181,8 @@ class _index extends \IPS\cms\Databases\Controller
|
||||
\IPS\Output::i()->redirect( $values['category']->url()->setQueryString( 'do', 'form' ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'cms_select_category' );
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'cms_select_category' ) );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'records' )->categorySelector( $form );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'cms_select_category' );
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'cms_select_category' ) );
|
||||
\IPS\cms\Databases\Dispatcher::i()->output = \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'records' )->categorySelector( $form );
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Record View
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Content
|
||||
* @since 17 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\modules\front\database;
|
||||
@@ -146,6 +145,9 @@ class _record extends \IPS\Content\Controller
|
||||
\IPS\Output::i()->metaTags['og:description'] = $record->record_meta_description;
|
||||
}
|
||||
|
||||
/* Set record URL as canonical tag */
|
||||
\IPS\Output::i()->linkTags['canonical'] = $record->url();
|
||||
|
||||
/* Update location */
|
||||
if( $record->database()->use_categories )
|
||||
{
|
||||
@@ -172,6 +174,82 @@ class _record extends \IPS\Content\Controller
|
||||
{
|
||||
\IPS\Output::i()->metaTags['og:image'] = (string) \IPS\File::get( 'cms_Records', $record->record_image )->url;
|
||||
}
|
||||
|
||||
/* Add Json-LD */
|
||||
\IPS\Output::i()->jsonLd['article'] = array(
|
||||
'@context' => "http://schema.org",
|
||||
'@type' => "Article",
|
||||
'url' => (string) $record->url(),
|
||||
'discussionUrl' => (string) $record->url(),
|
||||
'mainEntityOfPage' => (string) $record->url(),
|
||||
'name' => htmlspecialchars( $record->_title, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'headline' => htmlspecialchars( $record->_title, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'text' => strip_tags( $record->truncated() ),
|
||||
'articleBody' => strip_tags( $record->truncated() ),
|
||||
'dateCreated' => \IPS\DateTime::ts( $record->record_saved )->format( \IPS\DateTime::ISO8601 ),
|
||||
'datePublished' => \IPS\DateTime::ts( $record->record_publish_date ?: $record->record_saved )->format( \IPS\DateTime::ISO8601 ),
|
||||
'dateModified' => \IPS\DateTime::ts( $record->record_edit_time ?: ( $record->record_publish_date ?: $record->record_saved ) )->format( \IPS\DateTime::ISO8601 ),
|
||||
'pageStart' => 1,
|
||||
'pageEnd' => $record->commentPageCount(),
|
||||
/* Image is required */
|
||||
'image' => $record->record_image ? (string) \IPS\File::get( 'cms_Records', $record->record_image )->url : \IPS\Member::load( $record->member_id )->get_photo(),
|
||||
'author' => array(
|
||||
'@type' => 'Person',
|
||||
'name' => htmlspecialchars( \IPS\Member::load( $record->member_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'url' => (string) \IPS\Member::load( $record->member_id )->url(),
|
||||
'image' => \IPS\Member::load( $record->member_id )->get_photo()
|
||||
),
|
||||
'publisher' => array(
|
||||
'@type' => 'Organization',
|
||||
'name' => htmlspecialchars( \IPS\Member::load( $record->member_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'url' => (string) \IPS\Member::load( $record->member_id )->url(),
|
||||
'image' => \IPS\Member::load( $record->member_id )->get_photo(),
|
||||
'logo' => \IPS\Member::load( $record->member_id )->get_photo()
|
||||
),
|
||||
'interactionStatistic' => array(
|
||||
array(
|
||||
'@type' => 'InteractionCounter',
|
||||
'interactionType' => "http://schema.org/ViewAction",
|
||||
'userInteractionCount' => $record->record_views
|
||||
),
|
||||
array(
|
||||
'@type' => 'InteractionCounter',
|
||||
'interactionType' => "http://schema.org/FollowAction",
|
||||
'userInteractionCount' => $record::containerFollowerCount( $record->container() )
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if( $record->averageReviewRating() )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['article']['aggregateRating'] = array(
|
||||
'@type' => 'AggregateRating',
|
||||
'ratingValue' => $record->averageReviewRating(),
|
||||
'ratingCount' => $record->rating_hits,
|
||||
'reviewCount' => $record->record_reviews,
|
||||
'bestRating' => \IPS\Settings::i()->reviews_rating_out_of
|
||||
);
|
||||
}
|
||||
|
||||
if( $record::database()->options['reviews'] )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['article']['interactionStatistic'][] = array(
|
||||
'@type' => 'InteractionCounter',
|
||||
'interactionType' => "http://schema.org/ReviewAction",
|
||||
'userInteractionCount' => $record->record_reviews
|
||||
);
|
||||
}
|
||||
|
||||
if( $record::database()->options['comments'] )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['article']['commentCount'] = $record->record_comments;
|
||||
\IPS\Output::i()->jsonLd['article']['interactionStatistic'][] = array(
|
||||
'@type' => 'InteractionCounter',
|
||||
'interactionType' => "http://schema.org/CommentAction",
|
||||
'userInteractionCount' => $record->record_comments
|
||||
);
|
||||
}
|
||||
|
||||
\IPS\Output::i()->contextualSearchOptions = array();
|
||||
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $record::$title ) ) ) ) ] = array( 'type' => mb_strtolower( str_replace( '\\', '_', mb_substr( $class, 4 ) ) ), 'nodes' => $record->_id );
|
||||
\IPS\cms\Databases\Dispatcher::i()->output .= \IPS\cms\Theme::i()->getTemplate( $record->container()->_template_display, 'cms', 'database' )->record( $record, $comments, $form, $nextUnread );
|
||||
@@ -304,8 +382,8 @@ class _record extends \IPS\Content\Controller
|
||||
|
||||
\IPS\Output::i()->breadcrumb[] = array( $record->url(), $record->_title );
|
||||
|
||||
\IPS\Output::i()->title = $title;
|
||||
\IPS\Output::i()->output .= (string) $table;
|
||||
\IPS\Output::i()->title = $title;
|
||||
\IPS\cms\Databases\Dispatcher::i()->output .= (string) $table;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,7 +524,7 @@ class _record extends \IPS\Content\Controller
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'codemirror/codemirror.js', 'core', 'interface' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'codemirror/codemirror.css', 'core', 'interface' ) );
|
||||
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'revisions', 'cms' ), 'view' ), $record, $revision, $conflicts );
|
||||
\IPS\cms\Databases\Dispatcher::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'revisions', 'cms' ), 'view' ), $record, $revision, $conflicts );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -527,7 +605,7 @@ class _record extends \IPS\Content\Controller
|
||||
\IPS\Output::i()->allowDefaultWidgets = FALSE;
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\cms\Pages\Page::$currentPage->getWidgets();
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\cms\Theme::i(), 'getTemplate' ), array( $database->template_form, 'cms', 'database' ) ), 'recordForm' ), NULL, $category, $database, \IPS\cms\Pages\Page::$currentPage, $title, $hasModOptions );
|
||||
\IPS\cms\Databases\Dispatcher::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\cms\Theme::i(), 'getTemplate' ), array( $database->template_form, 'cms', 'database' ) ), 'recordForm' ), NULL, $category, $database, \IPS\cms\Pages\Page::$currentPage, $title, $hasModOptions );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( $title );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'records/form.css', 'cms', 'front' ) );
|
||||
|
||||
@@ -698,9 +776,9 @@ class _record extends \IPS\Content\Controller
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
*/
|
||||
protected function _rep( $commentClass, $comment, $item )
|
||||
protected function _react( $commentClass, $comment, $item )
|
||||
{
|
||||
return $this->_doSomething( '_rep', $commentClass, $comment, $item );
|
||||
return $this->_doSomething( '_react', $commentClass, $comment, $item );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -712,9 +790,9 @@ class _record extends \IPS\Content\Controller
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
*/
|
||||
protected function _showRep( $commentClass, $comment, $item )
|
||||
protected function _showReactions( $commentClass, $comment, $item )
|
||||
{
|
||||
return $this->_doSomething( '_showRep', $commentClass, $comment, $item );
|
||||
return $this->_doSomething( '_showReactions', $commentClass, $comment, $item );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -747,4 +825,16 @@ class _record extends \IPS\Content\Controller
|
||||
\IPS\Output::i()->error( 'node_error', '2T252/F', 403, '' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moderate
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function moderate()
|
||||
{
|
||||
parent::moderate();
|
||||
|
||||
\IPS\cms\Databases\Dispatcher::i()->output = \IPS\Output::i()->output;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief topic
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Pages
|
||||
* @since 03 Mar 2017
|
||||
*/
|
||||
|
||||
namespace IPS\cms\modules\front\database;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* topic
|
||||
*/
|
||||
class _topic extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
if ( !\IPS\Member::loggedIn()->modPermission( 'can_copy_topic_database' ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2T353/1', 403, '' );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$this->topic = \IPS\forums\Topic::load( \IPS\Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2T353/3', 404, '' );
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$wizard = new \IPS\Helpers\Wizard( array(
|
||||
'database' => array( $this, '_database' ),
|
||||
'category' => array( $this, '_category' ),
|
||||
), \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&id=" . \IPS\Request::i()->id, 'front', 'topic_copy', $this->topic->title_seo ), FALSE );
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' );
|
||||
\IPS\Output::i()->output = (string) $wizard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function _database( $data )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'database', 'copy_select_database', \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&id=" . \IPS\Request::i()->id, 'front', 'topic_copy', $this->topic->title_seo ) );
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->hiddenValues['topic_id'] = \IPS\Request::i()->id;
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'database', NULL, TRUE, array( 'class' => '\IPS\cms\Databases', 'permissionCheck' => function( $row )
|
||||
{
|
||||
if ( !$row->field_title OR !$row->field_content )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return $row->can( 'add' );
|
||||
} ) ) );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
return array(
|
||||
'topic_id' => $values['topic_id'],
|
||||
'database_id' => $values['database']->_id
|
||||
);
|
||||
}
|
||||
|
||||
return $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Category
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function _category( $data )
|
||||
{
|
||||
/* Do we need to even bother? */
|
||||
$database = \IPS\cms\Databases::load( $data['database_id'] );
|
||||
|
||||
if ( !$database->use_categories )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&do=form&id={$data['topic_id']}", 'front', 'topic_copy', $this->topic->title_seo )->csrf()->setQueryString( array( 'database_id' => $data['database_id'], 'category_id' => $database->default_category ) ) );
|
||||
}
|
||||
|
||||
$catClass = 'IPS\cms\Categories' . $data['database_id'];
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'category', 'copy_select_category', \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&id=" . \IPS\Request::i()->id, 'front', 'topic_copy', $this->topic->title_seo ) );
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->hiddenValues['topic_id'] = $data['topic_id'];
|
||||
$form->hiddenValues['database_id'] = $data['database_id'];
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'select_category', NULL, TRUE, array( 'class' => $catClass, 'permissionCheck' => 'add' ) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&do=form&id={$values['topic_id']}", 'front', 'topic_copy', $this->topic->title_seo )->csrf()->setQueryString( array( 'database_id' => $values['database_id'], 'category_id' => $values['select_category']->_id ) ) );
|
||||
}
|
||||
|
||||
return $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_records.js', 'cms' ) );
|
||||
|
||||
try
|
||||
{
|
||||
$database = \IPS\cms\Databases::load( \IPS\Request::i()->database_id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2T353/2', 404, '' );
|
||||
}
|
||||
|
||||
$recordClass = 'IPS\cms\Records' . $database->_id;
|
||||
$commentClass = 'IPS\cms\Comments' . $database->_id;
|
||||
$fieldClass = 'IPS\cms\Fields' . $database->_id;
|
||||
$catClass = 'IPS\cms\Categories' . $database->_id;
|
||||
$category = $catClass::load( \IPS\Request::i()->category_id );
|
||||
|
||||
$titleField = "field_{$database->field_title}";
|
||||
$contentField = "field_{$database->field_content}";
|
||||
|
||||
$fakeRecord = new $recordClass;
|
||||
$fakeRecord->$titleField = $this->topic->mapped('title');
|
||||
$fakeRecord->$contentField = $this->topic->content();
|
||||
|
||||
\IPS\Member::loggedIn()->language()->words['copy_comments_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'copy_comments_desc' ), $recordClass::_definiteArticle() );
|
||||
\IPS\Member::loggedIn()->language()->words['copy_author_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'copy_author_desc' ), $recordClass::_definiteArticle() );
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->hiddenValues['record_category_id'] = $category->_id;
|
||||
|
||||
foreach( $recordClass::formElements( $fakeRecord, $category ) AS $key => $element )
|
||||
{
|
||||
/* Skip these */
|
||||
if ( in_array( $key, array( 'record_edit_reason', 'record_edit_show' ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$form->add( $element );
|
||||
}
|
||||
|
||||
if ( $database->options['comments'] )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'copy_comments', FALSE ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'copy_author', TRUE ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$comments = FALSE;
|
||||
if ( array_key_exists( 'copy_comments', $values ) )
|
||||
{
|
||||
$comments = $values['copy_comments'];
|
||||
unset( $values['copy_comments'] );
|
||||
}
|
||||
|
||||
$author = $values['copy_author'];
|
||||
unset( $values['copy_author'] );
|
||||
|
||||
$record = $recordClass::createFromForm( $values, $category );
|
||||
|
||||
if ( $author )
|
||||
{
|
||||
$record->changeAuthor( $this->topic->author() );
|
||||
}
|
||||
|
||||
if ( $comments )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&do=comments&id={$this->topic->tid}", 'front', 'topic_copy', $this->topic->title_seo )->setQueryString( array( 'record_id' => $record->primary_id_field, 'database_id' => $database->_id ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
/* If the database is on a page, go to the record */
|
||||
\IPS\Output::i()->redirect( $record->url() );
|
||||
}
|
||||
catch( \LogicException $e )
|
||||
{
|
||||
/* If it is NOT then go back to the topic */
|
||||
\IPS\Output::i()->redirect( $this->topic->url() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$hasModOptions = FALSE;
|
||||
|
||||
if ( $recordClass::modPermission( 'lock', NULL, $category ) or
|
||||
$recordClass::modPermission( 'pin', NULL, $category ) or
|
||||
$recordClass::modPermission( 'hide', NULL, $category ) or
|
||||
$recordClass::modPermission( 'feature', NULL, $category ) or
|
||||
$fieldClass::fixedFieldFormShow( 'record_allow_comments' ) or
|
||||
$fieldClass::fixedFieldFormShow( 'record_expiry_date' ) or
|
||||
$fieldClass::fixedFieldFormShow( 'record_comment_cutoff' ) or
|
||||
\IPS\Member::loggedIn()->modPermission('can_content_edit_meta_tags') )
|
||||
{
|
||||
$hasModOptions = TRUE;
|
||||
}
|
||||
|
||||
array_shift( \IPS\Output::i()->breadcrumb );
|
||||
$container = NULL;
|
||||
try
|
||||
{
|
||||
$container = $this->topic->container();
|
||||
foreach ( $container->parents() as $parent )
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
|
||||
}
|
||||
\IPS\Output::i()->breadcrumb[] = array( $container->url(), $container->_title );
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
\IPS\Output::i()->breadcrumb[] = array( $this->topic->url(), $this->topic->mapped( 'title' ) );
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' );
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\cms\Theme::i(), 'getTemplate' ), array( $database->template_form, 'cms', 'database' ) ), 'recordForm' ), NULL, $category, $database, \IPS\cms\Pages\Page::load( $database->page_id ), \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' ), $hasModOptions );
|
||||
}
|
||||
|
||||
/**
|
||||
* Comments
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function comments()
|
||||
{
|
||||
$mr = new \IPS\Helpers\MultipleRedirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&id=" . \IPS\Request::i()->id . "&do=comments", 'front', 'topic_copy', $this->topic->title_seo )->setQueryString( array( 'database_id' => \IPS\Request::i()->database_id, 'record_id' => \IPS\Request::i()->record_id ) ), function( $data ) {
|
||||
$database = \IPS\cms\Databases::load( \IPS\Request::i()->database_id );
|
||||
$recordClass = 'IPS\cms\Records' . \IPS\Request::i()->database_id;
|
||||
$commentClass = $recordClass::$commentClass;
|
||||
$record = $recordClass::load( \IPS\Request::i()->record_id );
|
||||
$total = \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts', array( "topic_id=? AND new_topic=? AND queued!=?", \IPS\Request::i()->id, 0, 2 ) )->first();
|
||||
|
||||
$done = 0;
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'forums_posts', array( "topic_id=? AND new_topic=? AND queued!=?", \IPS\Request::i()->id, 0, -2 ), "pid ASC", array( $data, 100 ) ), 'IPS\forums\Topic\Post' ) AS $post )
|
||||
{
|
||||
$commentClass::create( $record, $post->content(), FALSE, NULL, TRUE, $post->author(), \IPS\DateTime::create(), $post->ip_address, $post->hidden() );
|
||||
$done++;
|
||||
}
|
||||
|
||||
if ( !$done )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return array( $data + $done, \IPS\Member::loggedIn()->language()->addToStack( 'copying_comments' ), 100 / $total * ( $data + 100 ) );
|
||||
|
||||
}, function() {
|
||||
$recordClass = 'IPS\cms\Records' . \IPS\Request::i()->database_id;
|
||||
$record = $recordClass::load( \IPS\Request::i()->record_id );
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Output::i()->redirect( $record->url() );
|
||||
}
|
||||
catch( \LogicException $e )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\forums\Topic::load( \IPS\Request::i()->id )->url() );
|
||||
}
|
||||
} );
|
||||
|
||||
$topic = \IPS\forums\Topic::load( \IPS\Request::i()->id );
|
||||
|
||||
array_shift( \IPS\Output::i()->breadcrumb );
|
||||
$container = NULL;
|
||||
try
|
||||
{
|
||||
$container = $topic->container();
|
||||
foreach ( $container->parents() as $parent )
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
|
||||
}
|
||||
\IPS\Output::i()->breadcrumb[] = array( $container->url(), $container->_title );
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
\IPS\Output::i()->breadcrumb[] = array( $topic->url(), $topic->mapped( 'title' ) );
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' ) );
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'copying_comments' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->genericBlock( (string) $mr, \IPS\Member::loggedIn()->language()->addToStack( 'copying_comments' ), 'ipsBox ipsPad' );
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief [Front] Page Controller
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Content
|
||||
* @since 25 Feb 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\modules\front\pages;
|
||||
@@ -246,7 +245,7 @@ class _builder extends \IPS\core\modules\front\system\widgets
|
||||
\IPS\Db::i()->insert( 'cms_page_widget_areas', array( 'area_page_id' => \IPS\Request::i()->pageID, 'area_area' => \IPS\Request::i()->pageArea, 'area_widgets' => json_encode( $blocks ) ), TRUE );
|
||||
\IPS\Output::i()->json( 'OK' );
|
||||
}
|
||||
\IPS\Output::i()->sendOutput( $widget->configuration()->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'widgets', 'core' ) ), 'formTemplate' ), $widget ) );
|
||||
\IPS\Output::i()->output = $widget->configuration()->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'widgets', 'core' ) ), 'formTemplate' ), $widget );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief [Front] Page Controller
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Content
|
||||
* @since 25 Feb 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\modules\front\pages;
|
||||
@@ -68,8 +67,16 @@ class _page extends \IPS\Dispatcher\Controller
|
||||
$permissions = $page->permissions();
|
||||
\IPS\Session::i()->setLocation( $page->url(), explode( ",", $permissions['perm_view'] ), 'loc_cms_viewing_page', array( 'cms_page_' . $page->_id => TRUE ) );
|
||||
}
|
||||
|
||||
$page->output();
|
||||
|
||||
try
|
||||
{
|
||||
$page->output();
|
||||
}
|
||||
catch ( \ParseError $e )
|
||||
{
|
||||
\IPS\Log::log( $e, 'page_error' );
|
||||
\IPS\Output::i()->error( 'content_err_page_500', '2T187/4', 500, 'content_err_page_500_admin', array(), $e );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +168,14 @@ class _page extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\cms\Databases\Dispatcher::i()->setDatabase( $databaseId )->run();
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
return \IPS\cms\Databases\Dispatcher::i()->setDatabase( $databaseId )->run();
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output();
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user