Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\ContentRouter;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\ContentRouter;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\CreateMenu;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\DesignersMode;
|
||||
|
||||
/* 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;
|
||||
@@ -37,6 +37,7 @@ class _Cms
|
||||
/**
|
||||
* Designer's mode on
|
||||
*
|
||||
* @param mixed $data Data
|
||||
* @return bool
|
||||
*/
|
||||
public function on( $data=NULL )
|
||||
@@ -51,6 +52,7 @@ class _Cms
|
||||
/**
|
||||
* Designer's mode off
|
||||
*
|
||||
* @param mixed $data Data
|
||||
* @return bool
|
||||
*/
|
||||
public function off( $data=NULL )
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\EditorLocations;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\EditorLocations;
|
||||
|
||||
/* 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;
|
||||
@@ -73,18 +73,48 @@ class _Records
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
$className = $this->_getClassName( $id3 );
|
||||
$id = ( mb_strpos( $className, 'Review' ) !== FALSE OR mb_strpos( $className, 'Comment' ) !== FALSE ) ? $id2 : $id1;
|
||||
|
||||
try
|
||||
{
|
||||
$recordClass = '\IPS\cms\Records' . $id3;
|
||||
|
||||
return $recordClass::load( $id1 )->canView( $member );
|
||||
return $className::load( $id )->canView( $member );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Figure out the correct class name to return
|
||||
*
|
||||
* @param string|int $id3 The id3 value stored
|
||||
* @return string
|
||||
*/
|
||||
protected function _getClassName( $id3 )
|
||||
{
|
||||
/* Review? */
|
||||
if( mb_strpos( $id3, '-review' ) )
|
||||
{
|
||||
$bits = explode( '-', $id3 );
|
||||
$className = '\IPS\cms\Records\Review' . $bits[0];
|
||||
}
|
||||
/* Comment? */
|
||||
elseif( mb_strpos( $id3, '-comment' ) )
|
||||
{
|
||||
$bits = explode( '-', $id3 );
|
||||
$className = '\IPS\cms\Records\Comment' . $bits[0];
|
||||
}
|
||||
/* Record */
|
||||
else
|
||||
{
|
||||
$className = '\IPS\cms\Records' . $id3;
|
||||
}
|
||||
|
||||
return $className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment lookup
|
||||
@@ -101,8 +131,10 @@ class _Records
|
||||
{
|
||||
if ( $id3 )
|
||||
{
|
||||
$recordClass = '\IPS\cms\Records' . $id3;
|
||||
$return = $recordClass::load( $id1 );
|
||||
$className = $this->_getClassName( $id3 );
|
||||
$id = ( mb_strpos( $className, 'Review' ) !== FALSE OR mb_strpos( $className, 'Comment' ) !== FALSE ) ? $id2 : $id1;
|
||||
|
||||
$return = $className::load( $id );
|
||||
$return->url(); // Need to check that won't throw an exception later, which might happen if the database no longer has a page
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\EditorLocations;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\FileStorage;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\FileStorage;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\FileStorage;
|
||||
|
||||
/* 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;
|
||||
@@ -79,7 +79,7 @@ class _Records
|
||||
|
||||
$data = \IPS\Data\Store::i()->cms_files_move_data;
|
||||
|
||||
if ( ! count( $data ) )
|
||||
if ( ! \count( $data ) )
|
||||
{
|
||||
/* all done */
|
||||
unset( \IPS\Data\Store::i()->cms_files_move_data );
|
||||
@@ -122,8 +122,9 @@ class _Records
|
||||
$files = array( $row[ $field ] );
|
||||
}
|
||||
|
||||
$finished = array();
|
||||
$save = FALSE;
|
||||
$finished = array();
|
||||
$save = FALSE;
|
||||
$fixed = FALSE;
|
||||
|
||||
foreach( $files as $file )
|
||||
{
|
||||
@@ -167,7 +168,7 @@ class _Records
|
||||
unset( $data[ $databaseId ] );
|
||||
}
|
||||
|
||||
if ( ! count( $data ) )
|
||||
if ( ! \count( $data ) )
|
||||
{
|
||||
if ( isset( \IPS\Data\Store::i()->cms_files_move_data ) )
|
||||
{
|
||||
@@ -202,7 +203,7 @@ class _Records
|
||||
|
||||
$data = \IPS\Data\Store::i()->cms_files_repair_data;
|
||||
|
||||
if ( ! count( $data ) )
|
||||
if ( ! \count( $data ) )
|
||||
{
|
||||
/* all done */
|
||||
unset( \IPS\Data\Store::i()->cms_files_repair_data );
|
||||
@@ -288,7 +289,7 @@ class _Records
|
||||
unset( $data[ $databaseId ] );
|
||||
}
|
||||
|
||||
if ( ! count( $data ) )
|
||||
if ( ! \count( $data ) )
|
||||
{
|
||||
if ( isset( \IPS\Data\Store::i()->cms_files_repair_data ) )
|
||||
{
|
||||
@@ -329,7 +330,7 @@ class _Records
|
||||
$fields[ $field['field_database_id'] ][] = $field['field_id'];
|
||||
}
|
||||
|
||||
if ( is_array( $fields ) )
|
||||
if ( \is_array( $fields ) )
|
||||
{
|
||||
foreach( $fields as $databaseId => $data )
|
||||
{
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
/* This file has been removed in 4.1 but we do not want the 4.0 extension to load */
|
||||
namespace IPS\cms\extensions\core\FrontNavigation;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Pages
|
||||
*/
|
||||
class _Cms
|
||||
{
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
final public function deprecated()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\FrontNavigation;
|
||||
|
||||
/* 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;
|
||||
@@ -36,7 +36,7 @@ class _Pages extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
/**
|
||||
* Allow multiple instances?
|
||||
*
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
public static function allowMultiple()
|
||||
{
|
||||
@@ -46,8 +46,8 @@ class _Pages extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
/**
|
||||
* Get configuration fields
|
||||
*
|
||||
* @param array $configuration The existing configuration, if editing an existing item
|
||||
* @param int $id The ID number of the existing item, if editing
|
||||
* @param array $existingConfiguration The existing configuration, if editing an existing item
|
||||
* @param int $id The ID number of the existing item, if editing
|
||||
* @return array
|
||||
*/
|
||||
public static function configuration( $existingConfiguration, $id = NULL )
|
||||
@@ -69,6 +69,7 @@ class _Pages extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
* Parse configuration fields
|
||||
*
|
||||
* @param array $configuration The values received from the form
|
||||
* @param int $id The ID number of the existing item, if editing
|
||||
* @return array
|
||||
*/
|
||||
public static function parseConfiguration( $configuration, $id )
|
||||
@@ -105,7 +106,7 @@ class _Pages extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
}
|
||||
|
||||
/* Inherit from page */
|
||||
$store = \IPS\cms\Pages\Page::getPageUrlStore();
|
||||
$store = \IPS\cms\Pages\Page::getStore();
|
||||
|
||||
if ( isset( $store[ $this->configuration['menu_content_page'] ] ) )
|
||||
{
|
||||
@@ -133,7 +134,16 @@ class _Pages extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( "cms_page_{$this->configuration['menu_content_page']}" );
|
||||
$page = \IPS\cms\Pages\Page::load( $this->configuration['menu_content_page'] );
|
||||
|
||||
if( $database = $page->getDatabase() and $database->pageTitle() )
|
||||
{
|
||||
return $database->pageTitle();
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( "cms_page_{$this->configuration['menu_content_page']}" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +154,7 @@ class _Pages extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
*/
|
||||
public function link()
|
||||
{
|
||||
$store = \IPS\cms\Pages\Page::getPageUrlStore();
|
||||
$store = \IPS\cms\Pages\Page::getStore();
|
||||
|
||||
if ( isset( $store[ $this->configuration['menu_content_page'] ] ) )
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\MemberSync;
|
||||
|
||||
/* 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;
|
||||
|
||||
Whitespace-only changes.
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\ModeratorPermissions;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\OutputPlugins;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\OutputPlugins;
|
||||
|
||||
/* 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;
|
||||
@@ -83,7 +83,7 @@ class _Database
|
||||
|
||||
try
|
||||
{
|
||||
if ( is_numeric( $data ) )
|
||||
if ( \is_numeric( $data ) )
|
||||
{
|
||||
$database = \IPS\cms\Databases::load( $data );
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\OutputPlugins;
|
||||
|
||||
/* 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;
|
||||
@@ -37,7 +37,7 @@ class _Media
|
||||
*/
|
||||
public static function runPlugin( $data, $options )
|
||||
{
|
||||
if ( is_numeric( $data ) )
|
||||
if ( \is_numeric( $data ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\OutputPlugins;
|
||||
|
||||
/* 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;
|
||||
@@ -37,13 +37,13 @@ class _Pageurl
|
||||
*/
|
||||
public static function runPlugin( $data, $options )
|
||||
{
|
||||
if ( is_numeric( $data ) )
|
||||
if ( \is_numeric( $data ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$url = \IPS\cms\Pages\Page::load( $data )->url();
|
||||
}
|
||||
catch( \OutOfRageException $ex )
|
||||
catch( \OutOfRangeException $ex )
|
||||
{
|
||||
$url = NULL;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\OutputPlugins;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\Queue;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Background Task
|
||||
* @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 05 Dec 2019
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\Queue;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Background Task
|
||||
*/
|
||||
class _FixCommentAttachments
|
||||
{
|
||||
/**
|
||||
* Parse data before queuing
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function preQueueData( $data )
|
||||
{
|
||||
$data['count'] = \IPS\Db::i()->select( 'COUNT(*)', 'core_attachments_map', \IPS\Db::i()->like( 'location_key', 'cms_Records' ) )->first();
|
||||
|
||||
if( $data['count'] == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run Background Task
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return int New offset
|
||||
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( $data, $offset )
|
||||
{
|
||||
$completed = 0;
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_attachments_map', \IPS\Db::i()->like( 'location_key', 'cms_Records' ), 'attachment_id ASC', array( $offset, \IPS\REBUILD_NORMAL ) ) as $map )
|
||||
{
|
||||
$completed++;
|
||||
|
||||
/* If id3 has "-review" in it, this is a review attachment and we can skip already */
|
||||
if( mb_strpos( $map['id3'], '-review' ) !== FALSE )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If id3 already has "-comment" in it, this is a known comment attachment (likely submitted after the upgrade) and we can skip already */
|
||||
if( mb_strpos( $map['id3'], '-comment' ) !== FALSE )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Otherwise, we need to see if the attachment was used in a comment. If so, update the map, otherwise just continue - record maps didn't change. */
|
||||
try
|
||||
{
|
||||
$comment = \IPS\Db::i()->select( 'comment_post', 'cms_database_comments', array( 'comment_database_id=? AND comment_id=?', $map['id3'], $map['id2'] ) )->first();
|
||||
|
||||
/* We are looking for data-fileid="{attach_id}" */
|
||||
if( preg_match( "/data\-fileid=['\"]{$map['attachment_id']}[\"']/ims", $comment ) )
|
||||
{
|
||||
/* We found it - attachment is for the comment so update the map record */
|
||||
\IPS\Db::i()->update( 'core_attachments_map', array( 'id3' => $map['id3'] . '-comment' ), array( 'attachment_id=? AND location_key=? AND id1=? AND id2=?', $map['attachment_id'], $map['location_key'], $map['id1'], $map['id2'] ) );
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if( !$completed )
|
||||
{
|
||||
throw new \IPS\Task\Queue\OutOfRangeException;
|
||||
}
|
||||
|
||||
return $offset + $completed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Progress
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function getProgress( $data, $offset )
|
||||
{
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack( 'rebuilding_cms_comment_attachments' ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Background Task
|
||||
* @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 20 Aug 2019
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\Queue;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Background Task
|
||||
*/
|
||||
class _MoveComments
|
||||
{
|
||||
/**
|
||||
* @brief Number of content items to rebuild per cycle
|
||||
*/
|
||||
public $rebuild = \IPS\REBUILD_SLOW;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function preQueueData( $data )
|
||||
{
|
||||
$data['done'] = 0;
|
||||
$data['lastId'] = 0;
|
||||
|
||||
try
|
||||
{
|
||||
switch( $data['to'] )
|
||||
{
|
||||
case 'forums':
|
||||
if ( isset( $data['categoryId'] ) )
|
||||
{
|
||||
$where = array( \IPS\Db::i()->in( 'comment_record_id', iterator_to_array( \IPS\Db::i()->select( 'record_id', "cms_custom_database_{$data['databaseId']}", array( "category_id=?", $data['categoryId'] ) ) ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = array( "comment_database_id=?", $data['databaseId'] );
|
||||
}
|
||||
|
||||
$data['count'] = \IPS\Db::i()->select( 'COUNT(*)', 'cms_database_comments', $where )->first();
|
||||
break;
|
||||
|
||||
case 'pages':
|
||||
if ( isset( $data['categoryId'] ) )
|
||||
{
|
||||
$where = array( "new_topic=? AND " . \IPS\Db::i()->in( 'topic_id', iterator_to_array( \IPS\Db::i()->select( 'record_topicid', "cms_custom_database_{$data['databaseId']}", array( "category_id=?", $data['categoryId'] ) ) ) ), 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = array( "new_topic=? AND " . \IPS\Db::i()->in( 'topic_id', iterator_to_array( \IPS\Db::i()->select( 'record_topicid', "cms_custom_database_{$data['databaseId']}" ) ) ), 0 );
|
||||
}
|
||||
|
||||
$data['count'] = \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts', $where )->first();
|
||||
break;
|
||||
}
|
||||
|
||||
/* If there are no comments, then don't bother. */
|
||||
if ( !$data['count'] )
|
||||
{
|
||||
/* But wait... if we're going from Pages to Forums, we still need to create the topics, so kick off that task instead. */
|
||||
if ( $data['to'] === 'forums' )
|
||||
{
|
||||
\IPS\Task::queue( 'cms', 'ResyncTopicContent', array( 'databaseId' => $data['databaseId'] ), 3, array( 'databaseId' ) );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
catch( \Throwable $e )
|
||||
{
|
||||
/* Something went wrong - log it and return */
|
||||
\IPS\Log::log( $e, 'cms_move_comments' );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run Background Task
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return int New offset
|
||||
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( &$data, $offset )
|
||||
{
|
||||
/* Okay let's figure out what we're doing. Separate these out to different methods since they can be a little complex. */
|
||||
switch( $data['to'] )
|
||||
{
|
||||
case 'forums':
|
||||
$done = $this->_toForums( $data, $offset );
|
||||
break;
|
||||
|
||||
case 'pages':
|
||||
$done = $this->_toPages( $data, $offset );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $done )
|
||||
{
|
||||
return $done;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \IPS\Task\Queue\OutOfRangeException;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Progress
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function getProgress( $data, $offset )
|
||||
{
|
||||
$database = \IPS\cms\Databases::load( $data['databaseId'] );
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack( 'moving_database_comments', NULL, array( 'sprintf' => array( $database->_title ) ) ), 'complete' => $data['done'] ? ( round( 100 / $data['count'] * $data['done'], 2 ) ) : 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Move Comments to the Forums
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return int New offset
|
||||
*/
|
||||
protected function _toForums( &$data, int $offset ): int
|
||||
{
|
||||
$done = 0;
|
||||
/* This is easy... kind of */
|
||||
$database = \IPS\cms\Databases::load( $data['databaseId'] );
|
||||
$commentClass = '\IPS\cms\Records\Comment' . $database->_id;
|
||||
if ( isset( $data['categoryId'] ) )
|
||||
{
|
||||
$where = array( "comment_database_id=? AND comment_id>? AND " . \IPS\Db::i()->in( 'comment_record_id', iterator_to_array( \IPS\Db::i()->select( 'primary_id_field', "cms_custom_database_{$database->_id}", array( "category_id=?", $data['categoryId'] ) ) ) ), $database->_id, $data['lastId'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = array( "comment_database_id=? AND comment_id>?", $database->_id, $data['lastId'] );
|
||||
}
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'cms_database_comments', $where, "comment_id ASC", $this->rebuild ), $commentClass ) AS $row )
|
||||
{
|
||||
/* First, create the topic if it doesn't already exist */
|
||||
if ( !$row->item()->record_topicid )
|
||||
{
|
||||
$row->item()->syncTopic( FALSE ); # Sync Topic will create it for us and link it, while also handling database and category level settings.
|
||||
}
|
||||
|
||||
/* I'm not sure how to do this properly yet */
|
||||
$queued = 0;
|
||||
if ( $row->approved == 0 )
|
||||
{
|
||||
$queued = 1;
|
||||
}
|
||||
else if ( $row->approved == -1 )
|
||||
{
|
||||
$queued = -1;
|
||||
}
|
||||
|
||||
$post = new \IPS\forums\Topic\Post;
|
||||
$post->author_id = $row->user;
|
||||
$post->append_edit = $row->edit_show;
|
||||
$post->edit_time = $row->edit_date;
|
||||
$post->author_name = $row->author;
|
||||
$post->ip_address = $row->ip_address;
|
||||
$post->post_date = $row->date;
|
||||
$post->post = $row->post;
|
||||
$post->queued = $queued;
|
||||
$post->topic_id = $row->item()->record_topicid;
|
||||
$post->edit_name = $row->edit_member_name;
|
||||
$post->post_edit_reason = $row->edit_reason ?: '';
|
||||
$post->save();
|
||||
|
||||
\IPS\Content\Search\Index::i()->index( $post );
|
||||
|
||||
$data['lastId'] = $row->id;
|
||||
$data['done']++;
|
||||
$done++;
|
||||
|
||||
$row->delete();
|
||||
|
||||
/* Are we done? If so, sync the topic */
|
||||
if ( !(bool) \IPS\Db::i()->select( 'COUNT(*)', 'cms_database_comments', array( "comment_database_id=? AND comment_record_id=?", $database->_id, $row->item()->primary_id_field ) )->first() )
|
||||
{
|
||||
$topic = \IPS\forums\Topic::load( $row->item()->record_topicid );
|
||||
$topic->resyncCommentCounts();
|
||||
$topic->save();
|
||||
|
||||
$forum = $topic->container();
|
||||
$forum->resetCommentCounts();
|
||||
$forum->save();
|
||||
|
||||
$record = $row->item();
|
||||
$category = $record->container();
|
||||
|
||||
$record->resyncCommentCounts();
|
||||
$record->save();
|
||||
|
||||
$category->resetCommentCounts();
|
||||
$category->save();
|
||||
}
|
||||
}
|
||||
|
||||
return $done;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move Comments to Pages
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return int New offset
|
||||
*/
|
||||
protected function _toPages( &$data, int $offset ): int
|
||||
{
|
||||
$done = 0;
|
||||
|
||||
/* This ones a little more complicated */
|
||||
$database = \IPS\cms\Databases::load( $data['databaseId'] );
|
||||
$commentClass = '\IPS\cms\Records\Comment' . $database->_id;
|
||||
$recordClass = '\IPS\cms\Records' . $database->_id;
|
||||
if ( isset( $data['categoryId'] ) )
|
||||
{
|
||||
$subquery = iterator_to_array( \IPS\Db::i()->select( 'record_topicid', "cms_custom_database_{$database->_id}", array( "category_id=?", $data['categoryId'] ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$subquery = iterator_to_array( \IPS\Db::i()->select( 'record_topicid', "cms_custom_database_{$database->_id}" ) );
|
||||
}
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'forums_posts', array( "pid>? AND new_topic=? AND " . \IPS\Db::i()->in( 'topic_id', $subquery ), $data['lastId'], 0 ), "pid ASC", $this->rebuild ), 'IPS\forums\Topic\Post' ) AS $row )
|
||||
{
|
||||
$record = $recordClass::load( $row->topic_id, 'record_topicid' );
|
||||
|
||||
$approved = 1;
|
||||
if ( $row->queued == 1 )
|
||||
{
|
||||
$approved = 0;
|
||||
}
|
||||
else if ( $row->queued == -1 )
|
||||
{
|
||||
$approved = -1;
|
||||
}
|
||||
|
||||
$comment = new $commentClass;
|
||||
$comment->user = $row->author_id;
|
||||
$comment->database_id = $database->_id;
|
||||
$comment->record_id = $record->primary_id_field;
|
||||
$comment->date = $row->post_date;
|
||||
$comment->ip_address = $row->ip_address;
|
||||
$comment->post = $row->post;
|
||||
$comment->approved = $approved;
|
||||
$comment->author = $row->author_name;
|
||||
$comment->edit_date = $row->edit_time ?: 0;
|
||||
$comment->edit_reason = $row->edit_reason;
|
||||
$comment->edit_member_name = $row->edit_name;
|
||||
$comment->save();
|
||||
|
||||
\IPS\Content\Search\Index::i()->index( $comment );
|
||||
|
||||
$row->delete();
|
||||
|
||||
$data['lastId'] = $row->pid;
|
||||
$data['done']++;
|
||||
$done++;
|
||||
|
||||
/* If we're no longer keeping the topic, then delete it, but only if we're really done with it (ex, only the first post still exists). Otherwise, we still want the topic linked, we're just not using it for comments anymore. */
|
||||
if ( $data['deleteTopics'] AND (int) \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts', array( "topic_id=?", $row->topic_id ) )->first() === 1 )
|
||||
{
|
||||
\IPS\forums\Topic::load( $row->topic_id )->delete();
|
||||
$record->record_topicid = 0;
|
||||
}
|
||||
|
||||
$record->resyncCommentCounts();
|
||||
$record->save();
|
||||
|
||||
$category = $record->container();
|
||||
$category->resetCommentCounts();
|
||||
$category->save();
|
||||
}
|
||||
|
||||
return $done;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Background Task
|
||||
* @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 28 Aug 2019
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\Queue;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Background Task
|
||||
*/
|
||||
class _MoveSingleRecord
|
||||
{
|
||||
/**
|
||||
* @brief Number of content items to rebuild per cycle
|
||||
*/
|
||||
public $rebuild = \IPS\REBUILD_SLOW;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function preQueueData( $data )
|
||||
{
|
||||
$data['done'] = 0;
|
||||
$data['lastId'] = 0;
|
||||
$recordClass = '\IPS\cms\Records' . $data['databaseId'];
|
||||
$record = $recordClass::load( $data['recordId'] );
|
||||
|
||||
if ( $data['to'] === 'forums' )
|
||||
{
|
||||
$data['count'] = \IPS\Db::i()->select( 'COUNT(*)', 'cms_database_comments', array( "comment_database_id=? AND comment_record_id=?", $data['databaseId'], $record->primary_id_field ) )->first();
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['count'] = \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts', array( "topic_id=? AND new_topic=0", $record->record_topicid ) )->first();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run Background Task
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return int New offset
|
||||
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( $data, $offset )
|
||||
{
|
||||
$done = 0;
|
||||
$recordClass = '\IPS\cms\Records' . $data['databaseId'];
|
||||
$commentClass = '\IPS\cms\Records\Comment' . $data['databaseId'];
|
||||
$record = $recordClass::load( $data['recordId'] );
|
||||
$map = array(
|
||||
'user' => 'author_id',
|
||||
'date' => 'post_date',
|
||||
'ip_address' => 'ip_address',
|
||||
'post' => 'post',
|
||||
'approved' => 'queued',
|
||||
'author' => 'author_name',
|
||||
'edit_date' => 'edit_time',
|
||||
'edit_reason' => 'post_edit_reason',
|
||||
'edit_member_name' => 'edit_name',
|
||||
);
|
||||
|
||||
if ( $data['to'] === 'forums' )
|
||||
{
|
||||
$it = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'cms_database_comments', array( "comment_id>? AND comment_database_id=? AND comment_record_id=?", $data['lastId'], $data['databaseId'], $data['recordId'] ), 'comment_id ASC', $this->rebuild ), $commentClass );
|
||||
}
|
||||
else
|
||||
{
|
||||
$it = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'forums_posts', array( "pid>? AND new_topic=0 AND topic_id=?", $data['lastId'], $record->record_topicid ), 'pid ASC', $this->rebuild ), 'IPS\forums\Topic\Post' );
|
||||
$map = \array_flip( $map );
|
||||
}
|
||||
|
||||
foreach( $it AS $old )
|
||||
{
|
||||
if ( $data['to'] === 'forums' )
|
||||
{
|
||||
$new = new \IPS\forums\Topic\Post;
|
||||
$new->topic_id = $record->record_topicid;
|
||||
$newIdColumn = 'pid';
|
||||
$oldIdColumn = 'id';
|
||||
}
|
||||
else
|
||||
{
|
||||
$new = new $commentClass;
|
||||
$new->record_id = $data['recordId'];
|
||||
$newIdColumn = 'id';
|
||||
$oldIdColumn = 'pid';
|
||||
}
|
||||
|
||||
foreach( $map AS $k => $v )
|
||||
{
|
||||
switch( $k )
|
||||
{
|
||||
case 'approved':
|
||||
if ( $old->$k == 1 )
|
||||
{
|
||||
$new->$v = 0;
|
||||
}
|
||||
else if ( $old->$k == 0 )
|
||||
{
|
||||
$new->$v = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$new->$v = -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'queued':
|
||||
if ( $old->$k == 0 )
|
||||
{
|
||||
$new->$v = 1;
|
||||
}
|
||||
elseif ( $old->$k == 1 )
|
||||
{
|
||||
$new->$v = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$new->$v = -1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$new->$v = $old->$k ?? '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$new->save();
|
||||
|
||||
\IPS\Content\Search\Index::i()->index( $new );
|
||||
|
||||
$old->delete();
|
||||
|
||||
$data['lastId'] = $old->$oldIdColumn;
|
||||
$data['done']++;
|
||||
$done++;
|
||||
}
|
||||
|
||||
$record->syncRecordFromTopic( $record->topic( FALSE ) );
|
||||
|
||||
if ( !$done )
|
||||
{
|
||||
throw new \IPS\Task\Queue\OutOfRangeException;
|
||||
}
|
||||
|
||||
return $done;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Progress
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function getProgress( $data, $offset )
|
||||
{
|
||||
$recordClass = '\IPS\cms\Records' . $data['databaseId'];
|
||||
$record = $recordClass::load( $data['recordId'] );
|
||||
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack( 'moving_database_comments_single', NULL, array( 'sprintf' => array( $record->url(), $record->mapped('title') ) ) ), 'complete' => 100 / $data['count'] * $data['done'] );
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\Queue;
|
||||
|
||||
/* 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;
|
||||
@@ -26,7 +26,7 @@ class _RebuildCategories
|
||||
/**
|
||||
* @brief Number of content items to rebuild per cycle
|
||||
*/
|
||||
public $rebuild = 50;
|
||||
public $rebuild = \IPS\REBUILD_NORMAL;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\Queue;
|
||||
|
||||
/* 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;
|
||||
@@ -26,7 +26,7 @@ class _RebuildCommentLikes
|
||||
/**
|
||||
* @brief Number of content items to rebuild per cycle
|
||||
*/
|
||||
public $rebuild = 500;
|
||||
public $rebuild = \IPS\REBUILD_QUICK;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
@@ -71,7 +71,7 @@ class _RebuildCommentLikes
|
||||
|
||||
try
|
||||
{
|
||||
$databaseId = \IPS\Db::i()->select( 'comment_database_id', 'cms_database_comments', array( 'comment_id=?', intval( $item['id'] ) ) )->first();
|
||||
$databaseId = \IPS\Db::i()->select( 'comment_database_id', 'cms_database_comments', array( 'comment_id=?', \intval( $item['id'] ) ) )->first();
|
||||
|
||||
\IPS\Db::i()->update( 'core_reputation_index', array( 'type' => 'comment_id_' . $databaseId ), array( 'id=?', $item['id'] ) );
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\Queue;
|
||||
|
||||
/* 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;
|
||||
@@ -26,7 +26,7 @@ class _RebuildEditorFields
|
||||
/**
|
||||
* @brief Number of content items to rebuild per cycle
|
||||
*/
|
||||
public $rebuild = 50;
|
||||
public $rebuild = \IPS\REBUILD_SLOW;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
@@ -53,6 +53,8 @@ class _RebuildEditorFields
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$data['completed'] = 0;
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -65,7 +67,7 @@ class _RebuildEditorFields
|
||||
* @return int New offset
|
||||
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( $data, $offset )
|
||||
public function run( &$data, $offset )
|
||||
{
|
||||
$classname = $data['class'];
|
||||
$databaseId = mb_substr( $classname, 15 );
|
||||
@@ -116,7 +118,7 @@ class _RebuildEditorFields
|
||||
|
||||
try
|
||||
{
|
||||
$item->$contentColumn = \IPS\Text\LegacyParser::parseStatic( $item->$contentColumn, $member, $canUseHtml, 'cms_Records', $item->$idColumn, $data['fieldId'], $databaseId, isset( $classname::$itemClass ) ? $classname::$itemClass : get_class( $item ) );
|
||||
$item->$contentColumn = \IPS\Text\LegacyParser::parseStatic( $item->$contentColumn, $member, $canUseHtml, 'cms_Records', $item->$idColumn, $data['fieldId'], $databaseId, isset( $classname::$itemClass ) ? $classname::$itemClass : \get_class( $item ) );
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
{
|
||||
@@ -133,6 +135,7 @@ class _RebuildEditorFields
|
||||
$item->save();
|
||||
|
||||
$last = $item->$idColumn;
|
||||
$data['completed']++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +160,6 @@ class _RebuildEditorFields
|
||||
$classname = $data['class'];
|
||||
$databaseId = mb_substr( $classname, 15 );
|
||||
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_records', FALSE, array( 'sprintf' => array( \IPS\cms\Databases::load( $databaseId )->_title ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_records', FALSE, array( 'sprintf' => array( \IPS\cms\Databases::load( $databaseId )->_title ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $data['completed'], 2 ) ) : 100 );
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\Queue;
|
||||
|
||||
/* 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;
|
||||
@@ -26,7 +26,7 @@ class _RebuildReciprocalMaps
|
||||
/**
|
||||
* @brief Number of content items to rebuild per cycle
|
||||
*/
|
||||
public $rebuild = 500;
|
||||
public $rebuild = \IPS\REBUILD_QUICK;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
@@ -53,6 +53,8 @@ class _RebuildReciprocalMaps
|
||||
return null;
|
||||
}
|
||||
|
||||
$data['completed'] = 0;
|
||||
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
@@ -63,18 +65,18 @@ class _RebuildReciprocalMaps
|
||||
* @return int|null New offset or NULL if complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( $data, $offset )
|
||||
public function run( &$data, $offset )
|
||||
{
|
||||
$databaseId = $data['database'];
|
||||
$databaseId = $data['database'];
|
||||
$fieldId = $data['field'];
|
||||
$parsed = 0;
|
||||
$last = NULL;
|
||||
|
||||
if ( \IPS\Db::i()->checkForTable( 'cms_custom_database_' . $databaseId ) )
|
||||
{
|
||||
$fieldsClass = 'IPS\cms\Fields' . $databaseId;
|
||||
$field = $fieldsClass::load( $fieldId );
|
||||
|
||||
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, array( 'field_' . $fieldId . ' != \'\' or field_' . $fieldId . ' IS NOT NULL' ), 'primary_id_field asc', array( $offset, $this->rebuild ) ) as $row )
|
||||
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, array( 'primary_id_field > ? AND (field_' . $fieldId . ' != \'\' or field_' . $fieldId . ' IS NOT NULL)', $offset ), 'primary_id_field asc', array( 0, $this->rebuild ) ) as $row )
|
||||
{
|
||||
$extra = $field->extra;
|
||||
if ( $row[ 'field_' . $fieldId ] and ! empty( $extra['database'] ) )
|
||||
@@ -94,16 +96,17 @@ class _RebuildReciprocalMaps
|
||||
}
|
||||
}
|
||||
|
||||
$parsed++;
|
||||
$data['completed']++;
|
||||
$last = $row['primary_id_field'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $parsed )
|
||||
if ( $last === NULL )
|
||||
{
|
||||
throw new \IPS\Task\Queue\OutOfRangeException;
|
||||
}
|
||||
|
||||
return $offset + $this->rebuild;
|
||||
return $last;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,6 +120,6 @@ class _RebuildReciprocalMaps
|
||||
public function getProgress( $data, $offset )
|
||||
{
|
||||
$databaseId = $data['database'];
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_reciprocal_map', FALSE, array( 'sprintf' => array( \IPS\cms\Databases::load( $databaseId )->_title, $data['field'] ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_reciprocal_map', FALSE, array( 'sprintf' => array( \IPS\cms\Databases::load( $databaseId )->_title, $data['field'] ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $data['completed'], 2 ) ) : 100 );
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\Queue;
|
||||
|
||||
/* 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;
|
||||
@@ -26,7 +26,7 @@ class _RebuildRecords
|
||||
/**
|
||||
* @brief Number of content items to rebuild per cycle
|
||||
*/
|
||||
public $rebuild = 50;
|
||||
public $rebuild = \IPS\REBUILD_SLOW;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
@@ -54,6 +54,8 @@ class _RebuildRecords
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$data['completed'] = 0;
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -66,10 +68,11 @@ class _RebuildRecords
|
||||
* @return int New offset
|
||||
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( $data, $offset )
|
||||
public function run( &$data, $offset )
|
||||
{
|
||||
$classname = $data['class'];
|
||||
$databaseId = mb_substr( $classname, 15 );
|
||||
$classname = $data['class'];
|
||||
$databaseId = mb_substr( $classname, 15 );
|
||||
$last = NULL;
|
||||
|
||||
/* Make sure there's even content to parse */
|
||||
if( !class_exists( $classname ) or !isset( $classname::$databaseColumnMap['content'] ) )
|
||||
@@ -80,12 +83,11 @@ class _RebuildRecords
|
||||
$fixImage = isset( $data['fixImage'] ) ? (boolean) $data['fixImage'] : TRUE;
|
||||
$fixHtml = isset( $data['fixHtml'] ) ? (boolean) $data['fixHtml'] : FALSE;
|
||||
$fixFurls = isset( $data['fixFurls']) ? (boolean) $data['fixFurls'] : FALSE;
|
||||
$parsed = 0;
|
||||
$class = '\IPS\cms\Records' . $databaseId;
|
||||
|
||||
if ( \IPS\Db::i()->checkForTable( 'cms_custom_database_' . $databaseId ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, NULL, 'primary_id_field asc', array( $offset, $this->rebuild ) ) as $row )
|
||||
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, array( 'primary_id_field > ?', $offset ), 'primary_id_field asc', array( 0, $this->rebuild ) ) as $row )
|
||||
{
|
||||
$record = $class::constructFromData( $row );
|
||||
$record->resetLastComment();
|
||||
@@ -128,7 +130,7 @@ class _RebuildRecords
|
||||
{
|
||||
$fields = iterator_to_array( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'field_database_id=? AND field_type=? AND field_html=1', $databaseId, 'Editor' ) ) );
|
||||
|
||||
if ( count( $fields ) )
|
||||
if ( \count( $fields ) )
|
||||
{
|
||||
foreach( $fields as $field )
|
||||
{
|
||||
@@ -167,16 +169,17 @@ class _RebuildRecords
|
||||
}
|
||||
}
|
||||
|
||||
$parsed++;
|
||||
$data['completed']++;
|
||||
$last = $record->primary_id_field;
|
||||
}
|
||||
}
|
||||
|
||||
if( $parsed != $this->rebuild )
|
||||
if( $last === NULL )
|
||||
{
|
||||
throw new \IPS\Task\Queue\OutOfRangeException;
|
||||
}
|
||||
|
||||
return ( $offset + $this->rebuild );
|
||||
return $last;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,6 +196,6 @@ class _RebuildRecords
|
||||
$databaseId = mb_substr( $classname, 15 );
|
||||
|
||||
$title = ( \IPS\Application::appIsEnabled('cms') ) ? \IPS\cms\Databases::load( $databaseId )->_title : 'Database #' . $databaseId;
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_records', FALSE, array( 'sprintf' => array( $title ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_records', FALSE, array( 'sprintf' => array( $title ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $data['completed'], 2 ) ) : 100 );
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\Queue;
|
||||
|
||||
/* 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;
|
||||
@@ -26,7 +26,7 @@ class _ResyncTopicContent
|
||||
/**
|
||||
* @brief Number of content items to rebuild per cycle
|
||||
*/
|
||||
public $rebuild = 100;
|
||||
public $rebuild = \IPS\REBUILD_NORMAL;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
@@ -48,7 +48,7 @@ class _ResyncTopicContent
|
||||
{
|
||||
$cats = iterator_to_array( \IPS\Db::i()->select( 'category_id', 'cms_database_categories', array( 'category_forum_record=1 AND category_database_id=?', $data['databaseId'] ) ) );
|
||||
|
||||
if ( count( $cats ) )
|
||||
if ( \count( $cats ) )
|
||||
{
|
||||
$data['count'] = (int) \IPS\Db::i()->select( 'COUNT(*)', 'cms_custom_database_' . $data['databaseId'], array( \IPS\Db::i()->in( 'category_id', $cats ) ) )->first();
|
||||
}
|
||||
@@ -67,6 +67,8 @@ class _ResyncTopicContent
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$data['completed'] = 0;
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -79,11 +81,12 @@ class _ResyncTopicContent
|
||||
* @return int New offset
|
||||
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( $data, $offset )
|
||||
public function run( &$data, $offset )
|
||||
{
|
||||
$class = '\IPS\cms\Records' . $data['databaseId'];
|
||||
$where = NULL;
|
||||
$parsed = 0;
|
||||
$class = '\IPS\cms\Records' . $data['databaseId'];
|
||||
$where = array( 'primary_id_field>?', $offset );
|
||||
$last = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
$database = \IPS\cms\Databases::load( $data['databaseId'] );
|
||||
@@ -101,7 +104,7 @@ class _ResyncTopicContent
|
||||
|
||||
if ( \IPS\Db::i()->checkForTable( 'cms_custom_database_' . $data['databaseId'] ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $data['databaseId'], $where, 'primary_id_field asc', array( $offset, $this->rebuild ) ) as $row )
|
||||
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $data['databaseId'], $where, 'primary_id_field asc', array( 0, $this->rebuild ) ) as $row )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -110,16 +113,17 @@ class _ResyncTopicContent
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
|
||||
$parsed++;
|
||||
$data['completed']++;
|
||||
$last = $row['primary_id_field'];
|
||||
}
|
||||
}
|
||||
|
||||
if( $parsed != $this->rebuild )
|
||||
if( $last === NULL )
|
||||
{
|
||||
throw new \IPS\Task\Queue\OutOfRangeException;
|
||||
}
|
||||
|
||||
return ( $offset + $this->rebuild );
|
||||
return $last;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,6 +137,6 @@ class _ResyncTopicContent
|
||||
public function getProgress( $data, $offset )
|
||||
{
|
||||
$title = ( \IPS\Application::appIsEnabled('cms') ) ? \IPS\cms\Databases::load( $data['databaseId'] )->_title : 'Database #' . $data['databaseId'];
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_sync_topics', FALSE, array( 'sprintf' => array( $title ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_sync_topics', FALSE, array( 'sprintf' => array( $title ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $data['completed'], 2 ) ) : 100 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief RSS Import extension: RssImport
|
||||
* @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 09 Oct 2019
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\RssImport;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief RSS Import extension: RssImport
|
||||
*/
|
||||
class _RssImport
|
||||
{
|
||||
/**
|
||||
* @brief RSSImport Classes
|
||||
*/
|
||||
public $classes = array();
|
||||
|
||||
/**
|
||||
* @brief Filestorage class
|
||||
*/
|
||||
public $fileStorage = 'cms_Records';
|
||||
|
||||
/**
|
||||
* @brief Encosure images to process
|
||||
*/
|
||||
public static $enclosures = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach ( \IPS\cms\Databases::databases() as $id => $database )
|
||||
{
|
||||
if ( $database->canImportRss() )
|
||||
{
|
||||
$this->classes[] = 'IPS\\cms\\Records' . $id;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show in the Admin CP?
|
||||
*
|
||||
* @param Object $class The class to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function showInAdminCp( $class ): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return available options for a Form\Select
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function availableOptions()
|
||||
{
|
||||
$options = array();
|
||||
try
|
||||
{
|
||||
foreach ( \IPS\cms\Databases::databases() as $id => $database )
|
||||
{
|
||||
if ( $database->canImportRss() )
|
||||
{
|
||||
$options['IPS\cms\Records' . $id] = $database->_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
} // If you have not upgraded pages but it is installed, this throws an error
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Node selector options
|
||||
*
|
||||
* @param \IPS\core\Rss\Import|null $rss Existing RSS object if editing|NULL if not
|
||||
* @return array
|
||||
*/
|
||||
public function nodeSelectorOptions( $rss )
|
||||
{
|
||||
/* Get the correct class */
|
||||
$class = $rss->_class;
|
||||
$nodeClass = $class::$containerNodeClass;
|
||||
|
||||
return array( 'class' => $nodeClass );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \IPS\core\Rss\Import $rss RSS object
|
||||
* @param array $article RSS feed article importing
|
||||
* @param \IPS\Node\Model $container Container object
|
||||
* @param string $content Post content with read more link if set
|
||||
* @return \IPS\Content
|
||||
*/
|
||||
public function create( \IPS\core\Rss\Import $rss, $article, \IPS\Node\Model $container, $content )
|
||||
{
|
||||
$settings = $rss->settings;
|
||||
$recordClass = $rss->_class;
|
||||
$member = \IPS\Member::load( $rss->member );
|
||||
$fieldsClass = '\IPS\cms\Fields' . $recordClass::database()->id;
|
||||
$customFields = $fieldsClass::fields( $settings, 'add' );
|
||||
|
||||
$values = array(
|
||||
'content_field_' . $recordClass::database()->field_title => $article['title'],
|
||||
'content_field_' . $recordClass::database()->field_content => $content,
|
||||
'record_member_id' => $member
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
$record = $recordClass::createFromForm( $values, $container );
|
||||
|
||||
if ( ! $settings['record_open'] )
|
||||
{
|
||||
$record->record_locked = 1;
|
||||
}
|
||||
|
||||
if ( $settings['record_hide'] )
|
||||
{
|
||||
$record->record_approved = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$record->record_approved = 1;
|
||||
}
|
||||
|
||||
/* Any custom fields? */
|
||||
foreach( $settings as $k => $v )
|
||||
{
|
||||
if ( mb_substr( $k, 0, 6 ) == 'field_' )
|
||||
{
|
||||
$id = mb_substr( $k, 6 );
|
||||
|
||||
/* Make sure field still exists */
|
||||
if ( isset( $customFields[ $id ] ) )
|
||||
{
|
||||
$record->$k = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$record->record_saved = $article['date']->getTimestamp();
|
||||
$record->record_updated = $article['date']->getTimestamp();
|
||||
$record->record_last_comment = $article['date']->getTimestamp();
|
||||
$record->record_publish_date = $article['date']->getTimestamp();
|
||||
|
||||
if ( isset( static::$enclosures[ $article['guid'] ] ) )
|
||||
{
|
||||
$record->record_image = (string) static::$enclosures[ $article['guid'] ];
|
||||
|
||||
$fixedFieldSettings = $recordClass::database()->fixed_field_settings;
|
||||
|
||||
if ( isset( $fixedFieldSettings['record_image']['thumb_dims'] ) )
|
||||
{
|
||||
$record->record_image_thumb = (string) static::$enclosures[$article['guid']]->thumbnail( 'cms_Records', $fixedFieldSettings['record_image']['thumb_dims'][0], $fixedFieldSettings['record_image']['thumb_dims'][1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$record->record_image_thumb = $record->record_image;
|
||||
}
|
||||
}
|
||||
else if ( isset( $article['attachment'] ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_attachments_map', array(
|
||||
'attachment_id' => $article['attachment']['attach_id'],
|
||||
'location_key' => 'cms_Records' . $recordClass::database()->id,
|
||||
'id1' => $record->primary_id_field,
|
||||
'id3' => $recordClass::database()->id,
|
||||
) );
|
||||
}
|
||||
|
||||
$record->save();
|
||||
|
||||
return $record;
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the enclosure
|
||||
*
|
||||
* @param \IPS\core\Rss\Import $rss
|
||||
* @param \IPS\Http $response
|
||||
* @param array $article
|
||||
* @return bool
|
||||
*/
|
||||
public function processEnclosure( \IPS\core\Rss\Import $rss, \IPS\Http\Response $response, $article )
|
||||
{
|
||||
$settings = $rss->settings;
|
||||
$recordClass = $rss->_class;
|
||||
$fieldsClass = '\IPS\cms\Fields' . $recordClass::database()->id;
|
||||
|
||||
if ( empty( $settings['record_image'] ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$image = \IPS\Image::create( $response );
|
||||
$fixedFieldSettings = $recordClass::database()->fixed_field_settings;
|
||||
|
||||
$dims = NULL;
|
||||
if ( isset( $fixedFieldSettings['record_image']['image_dims'] ) and $fixedFieldSettings['record_image']['image_dims'][0] > 0 )
|
||||
{
|
||||
$dims = array('maxWidth' => $fixedFieldSettings['record_image']['image_dims'][0], 'maxHeight' => $fixedFieldSettings['record_image']['image_dims'][1]);
|
||||
}
|
||||
|
||||
if ( $dims !== NULL )
|
||||
{
|
||||
$image->resizeToMax( $fixedFieldSettings['record_image']['image_dims'][0], $fixedFieldSettings['record_image']['image_dims'][1] );
|
||||
}
|
||||
|
||||
static::$enclosures[ $article['guid'] ] = \IPS\File::create( $this->fileStorage, 'rssImage-' . $article['guid'] . '.' . $image->type, (string)$image );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Addition Form elements
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form
|
||||
* @param \IPS\core\Rss\Import $rss Existing RSS object
|
||||
* @return void
|
||||
*/
|
||||
public function form( &$form, \IPS\core\Rss\Import $rss )
|
||||
{
|
||||
$settings = $rss->settings;
|
||||
$recordClass = $rss->_class;
|
||||
$nodeClass = $recordClass::$containerNodeClass;
|
||||
$fieldsClass = '\IPS\cms\Fields' . $recordClass::database()->id;
|
||||
$customFields = $fieldsClass::fields( $settings, 'add', $rss->node_id ? $nodeClass::load( $rss->node_id ) : NULL );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'rss_import_record_open', ( $settings ? $settings['record_open'] : 1 ), FALSE, array( 'options' => array( 1 => 'unlocked', 0 => 'locked' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'rss_import_record_hide', ( $settings ? $settings['record_hide'] : 0 ), FALSE, array( 'options' => array( 0 => 'unhidden', 1 => 'hidden' ) ) ) );
|
||||
|
||||
if ( $rss->has_enclosures and $fieldsClass::fixedFieldFormShow( 'record_image' ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'rss_import_record_image', ( $settings ? $settings['record_image'] : 1 ), FALSE, array( 'options' => array( 1 => 'rss_import_record_image_header', 0 => 'rss_import_record_image_inline' ) ) ) );
|
||||
}
|
||||
|
||||
if ( \count( $customFields ) )
|
||||
{
|
||||
$fields = array();
|
||||
foreach( $customFields as $id => $field )
|
||||
{
|
||||
if ( $id == $recordClass::database()->field_title or $id == $recordClass::database()->field_content )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$fields[] = $field;
|
||||
}
|
||||
|
||||
if ( \count( $fields ) )
|
||||
{
|
||||
$form->addHeader('rss_import_cms_defaults');
|
||||
$form->addMessage('rss_import_cms_defaults_desc', 'ipsType_light');
|
||||
|
||||
foreach( $fields as $f )
|
||||
{
|
||||
$form->add( $f );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process additional fields unique to this extension
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @param \IPS\core\Rss\Import $rss Existing RSS object
|
||||
* @return array
|
||||
*/
|
||||
public function saveForm( &$values, $rss )
|
||||
{
|
||||
$return = array(
|
||||
'record_open' => $values['rss_import_record_open'],
|
||||
'record_hide' => $values['rss_import_record_hide']
|
||||
);
|
||||
|
||||
unset( $values['rss_import_record_open'], $values['rss_import_record_hide'] );
|
||||
|
||||
if ( isset( $values['rss_import_record_image'] ) )
|
||||
{
|
||||
$return['record_image'] = $values['rss_import_record_image'];
|
||||
|
||||
unset( $values['rss_import_record_image'] );
|
||||
}
|
||||
|
||||
$recordClass = $rss->_class;
|
||||
$fieldsClass = '\IPS\cms\Fields' . $recordClass::database()->id;
|
||||
$customValues = array();
|
||||
|
||||
foreach( $values as $k => $v )
|
||||
{
|
||||
if ( mb_substr( $k, 0, 14 ) === 'content_field_' )
|
||||
{
|
||||
$customValues[ $k ] = $v;
|
||||
unset( $values[ $k ] );
|
||||
}
|
||||
}
|
||||
|
||||
$customFields = $fieldsClass::fields( $customValues, 'add', NULL );
|
||||
|
||||
foreach( $customFields as $key => $field )
|
||||
{
|
||||
if ( $key == $recordClass::database()->field_title or $key == $recordClass::database()->field_content )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = 'field_' . $key;
|
||||
|
||||
if ( isset( $customValues[ $field->name ] ) and \get_class( $field ) == 'IPS\Helpers\Form\Upload' )
|
||||
{
|
||||
if ( \is_array( $customValues[ $field->name ] ) )
|
||||
{
|
||||
$items = array();
|
||||
foreach( $customValues[ $field->name ] as $obj )
|
||||
{
|
||||
$items[] = (string) $obj;
|
||||
}
|
||||
$return[ $key ] = implode( ',', $items );
|
||||
}
|
||||
else
|
||||
{
|
||||
$return[ $key ] = (string) $customValues[ $field->name ];
|
||||
}
|
||||
}
|
||||
/* If we're using decimals, then the database field is set to DECIMALS, so we cannot using stringValue() */
|
||||
else if ( isset( $customValues[ $field->name ] ) and \get_class( $field ) == 'IPS\Helpers\Form\Number' and ( isset( $field->options['decimals'] ) and $field->options['decimals'] > 0 ) )
|
||||
{
|
||||
$return[ $key ] = $field->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$return[ $key ] = $field::stringValue( isset( $customValues[ $field->name ] ) ? $customValues[ $field->name ] : NULL );
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\Sitemap;
|
||||
|
||||
/* 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;
|
||||
@@ -27,8 +27,9 @@ class _Databases
|
||||
* @brief Recommended Settings
|
||||
*/
|
||||
public $recommendedSettings = array(
|
||||
'sitemap_databases_count' => -1,
|
||||
'sitemap_databases_priority' => 1
|
||||
'sitemap_databases_include' => true,
|
||||
'sitemap_databases_count' => -1,
|
||||
'sitemap_databases_priority' => 1
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -39,6 +40,7 @@ class _Databases
|
||||
public function settings()
|
||||
{
|
||||
return array(
|
||||
'sitemap_databases_include' => new \IPS\Helpers\Form\YesNo( "sitemap_databases_include", \IPS\Settings::i()->sitemap_databases_count != 0, FALSE, array( 'togglesOn' => array( "sitemap_databases_count", "sitemap_databases_priority" ) ), NULL, NULL, NULL, "sitemap_databases_include" ),
|
||||
'sitemap_databases_count' => new \IPS\Helpers\Form\Number( 'sitemap_databases_count', \IPS\Settings::i()->sitemap_databases_count, FALSE, array( 'min' => '-1', 'unlimited' => '-1' ), NULL, NULL, NULL, 'sitemap_databases_count' ),
|
||||
'sitemap_databases_priority' => new \IPS\Helpers\Form\Select( 'sitemap_databases_priority', \IPS\Settings::i()->sitemap_databases_priority, FALSE, array( 'options' => \IPS\Sitemap::$priorities, 'unlimited' => '-1', 'unlimitedLang' => 'sitemap_dont_include' ), NULL, NULL, NULL, 'sitemap_databases_priority' )
|
||||
);
|
||||
@@ -58,7 +60,7 @@ class _Databases
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Settings::i()->changeValues( array( 'sitemap_databases_count' => $values['sitemap_databases_count'], 'sitemap_databases_priority' => $values['sitemap_databases_priority'] ) );
|
||||
\IPS\Settings::i()->changeValues( array( 'sitemap_databases_count' => $values['sitemap_databases_include'] ? $values['sitemap_databases_count'] : 0, 'sitemap_databases_priority' => $values['sitemap_databases_priority'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +71,12 @@ class _Databases
|
||||
*/
|
||||
public function getFilenames()
|
||||
{
|
||||
/* Are we including? */
|
||||
if ( ! \IPS\Settings::i()->sitemap_databases_count )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$files = array();
|
||||
|
||||
/* Check that guests can access the content at all */
|
||||
@@ -113,7 +121,7 @@ class _Databases
|
||||
}
|
||||
|
||||
/* And however many for the content items */
|
||||
$count = ceil( max( (int) $class::getItemsWithPermission( $class::sitemapWhere(), NULL, 10, 'read', \IPS\Content\Hideable::FILTER_PUBLIC_ONLY, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS, new \IPS\Member )->count( TRUE ), \IPS\Settings::i()->sitemap_databases_count ) / \IPS\Sitemap::MAX_PER_FILE );
|
||||
$count = ceil( max( (int) $class::getItemsWithPermission( $class::sitemapWhere(), NULL, 10, 'read', \IPS\Content\Hideable::FILTER_PUBLIC_ONLY, 0, new \IPS\Member, FALSE, FALSE, FALSE, TRUE ), \IPS\Settings::i()->sitemap_databases_count ) / \IPS\Sitemap::MAX_PER_FILE );
|
||||
for( $i=1; $i <= $count; $i++ )
|
||||
{
|
||||
$files[] = $database->id . '_sitemap_database_records_' . $i;
|
||||
@@ -140,35 +148,79 @@ class _Databases
|
||||
}
|
||||
|
||||
$tmp = explode( '_', $filename );
|
||||
$databaseId = intval( array_shift( $tmp ) );
|
||||
$database = \IPS\cms\Databases::load( $databaseId );
|
||||
|
||||
$class = '\IPS\cms\Records' . $databaseId;
|
||||
if ( isset( $class::$containerNodeClass ) )
|
||||
$databaseId = \intval( array_shift( $tmp ) );
|
||||
try
|
||||
{
|
||||
$nodeClass = $class::$containerNodeClass;
|
||||
}
|
||||
$entries = array();
|
||||
|
||||
if ( isset( $nodeClass ) and $filename == $databaseId . '_sitemap_database_categories' )
|
||||
{
|
||||
$select = array();
|
||||
if ( in_array( 'IPS\Content\Permissions', class_implements( $nodeClass ) ) or in_array( 'IPS\Node\Permissions', class_implements( $nodeClass ) ) )
|
||||
$database = \IPS\cms\Databases::load( $databaseId );
|
||||
$class = '\IPS\cms\Records' . $databaseId;
|
||||
if ( isset( $class::$containerNodeClass ) )
|
||||
{
|
||||
$select = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', $nodeClass::$databaseTable, array( 'category_database_id=? AND (' . \IPS\Db::i()->findInSet( 'perm_view', array( \IPS\Settings::i()->guest_group ) ) . ' OR ' . 'perm_view=? )', $databaseId, '*' ) )->join( 'core_permission_index', array( "core_permission_index.app=? AND core_permission_index.perm_type=? AND core_permission_index.perm_type_id={$nodeClass::$databaseTable}.{$nodeClass::$databasePrefix}{$nodeClass::$databaseColumnId}", $nodeClass::$permApp, $nodeClass::$permType ) ), $nodeClass );
|
||||
}
|
||||
else if ( $nodeClass::$ownerTypes !== NULL and is_subclass_of( $nodeClass, 'IPS\Node\Model' ) )
|
||||
{
|
||||
$select = $nodeClass::loadByOwner( new \IPS\Member );
|
||||
$nodeClass = $class::$containerNodeClass;
|
||||
}
|
||||
$entries = array();
|
||||
|
||||
foreach ( $select as $node )
|
||||
if ( isset( $nodeClass ) and $filename == $databaseId . '_sitemap_database_categories' )
|
||||
{
|
||||
if( $node->url() !== NULL )
|
||||
$select = array();
|
||||
if ( \in_array( 'IPS\Content\Permissions', class_implements( $nodeClass ) ) or \in_array( 'IPS\Node\Permissions', class_implements( $nodeClass ) ) )
|
||||
{
|
||||
$data = array( 'url' => $node->url() );
|
||||
|
||||
$priority = intval( \IPS\Settings::i()->sitemap_databases_priority );
|
||||
$select = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', $nodeClass::$databaseTable, array( 'category_database_id=? AND (' . \IPS\Db::i()->findInSet( 'perm_view', array( \IPS\Settings::i()->guest_group ) ) . ' OR ' . 'perm_view=? )', $databaseId, '*' ) )->join( 'core_permission_index', array( "core_permission_index.app=? AND core_permission_index.perm_type=? AND core_permission_index.perm_type_id={$nodeClass::$databaseTable}.{$nodeClass::$databasePrefix}{$nodeClass::$databaseColumnId}", $nodeClass::$permApp, $nodeClass::$permType ) ), $nodeClass );
|
||||
}
|
||||
else if ( $nodeClass::$ownerTypes !== NULL and is_subclass_of( $nodeClass, 'IPS\Node\Model' ) )
|
||||
{
|
||||
$select = $nodeClass::loadByOwner( new \IPS\Member );
|
||||
}
|
||||
|
||||
foreach ( $select as $node )
|
||||
{
|
||||
/* We only want nodes we can see, and that have actual content inside */
|
||||
if( $node->url() !== NULL and $node->can( 'view', new \IPS\Member ) and ( $node->hasChildren() OR ( $node->show_records and $node->getContentItemCount() ) ) )
|
||||
{
|
||||
$data = array( 'url' => $node->url(), 'lastmod' => $node->getLastCommentTime() );
|
||||
|
||||
$priority = \intval( \IPS\Settings::i()->sitemap_databases_priority );
|
||||
if ( $priority !== -1 )
|
||||
{
|
||||
$data['priority'] = $priority;
|
||||
}
|
||||
|
||||
$entries[] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$exploded = explode( '_', $filename );
|
||||
$block = (int) array_pop( $exploded );
|
||||
|
||||
$offset = ( $block - 1 ) * \IPS\Sitemap::MAX_PER_FILE;
|
||||
$limit = \IPS\Sitemap::MAX_PER_FILE;
|
||||
|
||||
$totalLimit = \IPS\Settings::i()->sitemap_databases_count;
|
||||
if ( $totalLimit > -1 and ( $offset + $limit ) > $totalLimit )
|
||||
{
|
||||
if ( $totalLimit < $limit )
|
||||
{
|
||||
$limit = $totalLimit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$limit = $totalLimit - $offset;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $class::getItemsWithPermission( $class::sitemapWhere(), NULL, array( $offset, $limit ), 'read', \IPS\Content\Hideable::FILTER_PUBLIC_ONLY, 0, new \IPS\Member, TRUE ) as $item )
|
||||
{
|
||||
$data = array( 'url' => $item->url() );
|
||||
|
||||
$lastMod = $item->lastModificationDate();
|
||||
|
||||
if ( $lastMod )
|
||||
{
|
||||
$data['lastmod'] = $lastMod;
|
||||
}
|
||||
|
||||
$priority = ( $item->sitemapPriority() ?: ( \intval( \IPS\Settings::i()->sitemap_databases_priority ) ) );
|
||||
if ( $priority !== -1 )
|
||||
{
|
||||
$data['priority'] = $priority;
|
||||
@@ -177,41 +229,12 @@ class _Databases
|
||||
$entries[] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
$sitemap->buildSitemapFile( $filename, $entries );
|
||||
}
|
||||
else
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$exploded = explode( '_', $filename );
|
||||
$block = (int) array_pop( $exploded );
|
||||
|
||||
$offset = ( $block - 1 ) * \IPS\Sitemap::MAX_PER_FILE;
|
||||
$limit = \IPS\Sitemap::MAX_PER_FILE;
|
||||
|
||||
$totalLimit = \IPS\Settings::i()->sitemap_databases_count;
|
||||
if ( $totalLimit > -1 and ( $offset + $limit ) > $totalLimit )
|
||||
{
|
||||
if ( $totalLimit < $limit )
|
||||
{
|
||||
$limit = $totalLimit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$limit = $totalLimit - $offset;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $class::getItemsWithPermission( $class::sitemapWhere(), NULL, array( $offset, $limit ), 'read', \IPS\Content\Hideable::FILTER_PUBLIC_ONLY, 0, new \IPS\Member, TRUE ) as $item )
|
||||
{
|
||||
$data = array( 'url' => $item->url() );
|
||||
$priority = ( $item->sitemapPriority() ?: ( intval( \IPS\Settings::i()->sitemap_databases_priority ) ) );
|
||||
if ( $priority !== -1 )
|
||||
{
|
||||
$data['priority'] = $priority;
|
||||
}
|
||||
|
||||
$entries[] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
$sitemap->buildSitemapFile( $filename, $entries );
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\Sitemap;
|
||||
|
||||
/* 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;
|
||||
@@ -27,8 +27,9 @@ class _Pages
|
||||
* @brief Recommended Settings
|
||||
*/
|
||||
public $recommendedSettings = array(
|
||||
'sitemap_pages_count' => -1,
|
||||
'sitemap_pages_priority' => 1
|
||||
'sitemap_pages_include' => true,
|
||||
'sitemap_pages_count' => -1,
|
||||
'sitemap_pages_priority' => 1
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -39,6 +40,7 @@ class _Pages
|
||||
public function settings()
|
||||
{
|
||||
return array(
|
||||
'sitemap_pages_include' => new \IPS\Helpers\Form\YesNo( "sitemap_pages_include", \IPS\Settings::i()->sitemap_pages_count != 0, FALSE, array( 'togglesOn' => array( "sitemap_pages_count", "sitemap_pages_priority" ) ), NULL, NULL, NULL, "sitemap_pages_include" ),
|
||||
'sitemap_pages_count' => new \IPS\Helpers\Form\Number( 'sitemap_pages_count', \IPS\Settings::i()->sitemap_pages_count, FALSE, array( 'min' => '-1', 'unlimited' => '-1' ), NULL, NULL, NULL, 'sitemap_pages_count' ),
|
||||
'sitemap_pages_priority' => new \IPS\Helpers\Form\Select( 'sitemap_pages_priority', \IPS\Settings::i()->sitemap_pages_priority, FALSE, array( 'options' => \IPS\Sitemap::$priorities, 'unlimited' => '-1', 'unlimitedLang' => 'sitemap_dont_include' ), NULL, NULL, NULL, 'sitemap_pages_priority' )
|
||||
);
|
||||
@@ -58,7 +60,7 @@ class _Pages
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Settings::i()->changeValues( array( 'sitemap_pages_count' => $values['sitemap_pages_count'], 'sitemap_pages_priority' => $values['sitemap_pages_priority'] ) );
|
||||
\IPS\Settings::i()->changeValues( array( 'sitemap_pages_count' => $values['sitemap_pages_include'] ? $values['sitemap_pages_count'] : 0, 'sitemap_pages_priority' => $values['sitemap_pages_priority'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +71,12 @@ class _Pages
|
||||
*/
|
||||
public function getFilenames()
|
||||
{
|
||||
/* Are we even including? */
|
||||
if( \IPS\Settings::i()->sitemap_pages_count == 0 )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$files = array();
|
||||
$class = '\IPS\cms\Pages\Page';
|
||||
$count = 0;
|
||||
@@ -132,8 +140,9 @@ class _Pages
|
||||
}
|
||||
|
||||
$where = array( array( '(' . \IPS\Db::i()->findInSet( 'perm_' . $class::$permissionMap[ $permissionCheck ], $member->groups ) . ' OR ' . 'perm_' . $class::$permissionMap[ $permissionCheck ] . '=? )', '*' ) );
|
||||
|
||||
$select = \IPS\Db::i()->select( '*', $class::$databaseTable, $where, 'page_id ASC', array( $offset, $limit ) )
|
||||
|
||||
$direction = ( $totalLimit > \IPS\Sitemap::MAX_PER_FILE ) ? ' ASC' : ' DESC';
|
||||
$select = \IPS\Db::i()->select( '*', $class::$databaseTable, $where, 'page_id' . $direction, array( $offset, $limit ) )
|
||||
->join( 'core_permission_index', array( "core_permission_index.app=? AND core_permission_index.perm_type=? AND core_permission_index.perm_type_id=" . $class::$databaseTable . "." . $class::$databasePrefix . $class::$databaseColumnId, $class::$permApp, $class::$permType ) );
|
||||
|
||||
foreach( $select as $row )
|
||||
@@ -141,12 +150,13 @@ class _Pages
|
||||
$item = $class::constructFromData( $row );
|
||||
|
||||
$data = array( 'url' => $item->url() );
|
||||
$priority = intval( \IPS\Settings::i()->sitemap_pages_priority );
|
||||
$priority = \intval( \IPS\Settings::i()->sitemap_pages_priority );
|
||||
if ( $priority !== -1 )
|
||||
{
|
||||
$data['priority'] = $priority;
|
||||
$entries[] = $data;
|
||||
}
|
||||
|
||||
$entries[] = $data;
|
||||
}
|
||||
|
||||
$sitemap->buildSitemapFile( $filename, $entries );
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\Uninstall;
|
||||
|
||||
/* 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;
|
||||
@@ -66,7 +66,7 @@ class _Databases
|
||||
{
|
||||
foreach( $databaseTables as $row )
|
||||
{
|
||||
if( is_array( $row ) )
|
||||
if( \is_array( $row ) )
|
||||
{
|
||||
$tables[] = array_pop($row);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\cms\extensions\core\Uninstall;
|
||||
|
||||
/* 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;
|
||||
|
||||
Reference in new issue
Block a user