Version 4.0.13.1
This commit is contained in:
1 parent
f9e857d255
commit
c6a86f0d9b
7517 files changed
+597400
-668041
No files matched your search
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Content Router extension: Records
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Board
|
||||
* @since 17 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\ContentRouter;
|
||||
|
||||
/* 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 Content Router extension: Records
|
||||
*/
|
||||
class _Records
|
||||
{
|
||||
/**
|
||||
* @brief Content Item Classes
|
||||
*/
|
||||
public $classes = array();
|
||||
|
||||
/**
|
||||
* Define classes here
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( 'database_id', 'cms_databases', 'database_page_id>0' ) as $id )
|
||||
{
|
||||
$this->classes[] = 'IPS\cms\Records' . $id;
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) {} // If you have not upgraded pages but it is installed, this throws an error
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Create Menu Extension : Records
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Pages
|
||||
* @since 18 Dec 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\CreateMenu;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Menu Extension: Records
|
||||
*/
|
||||
class _Records
|
||||
{
|
||||
/**
|
||||
* Get Items
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
$items = array();
|
||||
|
||||
foreach( \IPS\cms\Databases::databases() as $database )
|
||||
{
|
||||
if ( $database->page_id > 0 and $database->can('view') )
|
||||
{
|
||||
$catClass = '\IPS\cms\Categories' . $database->id;
|
||||
if ( $database->can('add') )
|
||||
{
|
||||
try
|
||||
{
|
||||
$page = \IPS\cms\Pages\Page::load( $database->page_id );
|
||||
|
||||
$items[ 'cms_create_menu_records_' . $database->id ] = array(
|
||||
'link' => $page->url()->setQueryString('do', 'form'),
|
||||
'extraData' => ( $database->use_categories ) ? array( 'data-ipsDialog' => true, 'data-ipsDialog-size' => "narrow" ) : array(),
|
||||
'title' => 'cms_select_category'
|
||||
);
|
||||
|
||||
}
|
||||
catch( \OutOfRangeException $ex ) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ksort( $items );
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Designers Mode Extension
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Board
|
||||
* @since 28 Nov 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\DesignersMode;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Designers Mode Extension
|
||||
*/
|
||||
class _Cms
|
||||
{
|
||||
/**
|
||||
* Anything need building?
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toBuild()
|
||||
{
|
||||
/* Yeah.. not gonna even bother trying to match up timestamps and such like and so on etc and etcetera is that spelled right? */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Designer's mode on
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function on( $data=NULL )
|
||||
{
|
||||
\IPS\cms\Theme\Advanced\Theme::export();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Designer's mode off
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function off( $data=NULL )
|
||||
{
|
||||
\IPS\cms\Theme\Advanced\Theme::import();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Editor Extension: Block Form
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 20 Feb 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\EditorLocations;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Block Content
|
||||
*/
|
||||
class _BlockContent
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return bool
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3 )
|
||||
{
|
||||
try
|
||||
{
|
||||
$recordClass = '\IPS\cms\Records' . $id3;
|
||||
return $recordClass::load( $id1 )->canView( $member );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment lookup
|
||||
*
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
{
|
||||
try
|
||||
{
|
||||
$recordClass = '\IPS\cms\Records' . $id3;
|
||||
return $recordClass::load( $id1 );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Editor Extension: Contact Form
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 12 Nov 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\EditorLocations;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Page Content
|
||||
*/
|
||||
class _PageContent
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return bool
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3 )
|
||||
{
|
||||
try
|
||||
{
|
||||
$recordClass = '\IPS\cms\Records' . $id3;
|
||||
return $recordClass::load( $id1 )->canView( $member );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment lookup
|
||||
*
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
{
|
||||
try
|
||||
{
|
||||
$recordClass = '\IPS\cms\Records' . $id3;
|
||||
return $recordClass::load( $id1 );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Editor Extension: Record Form
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 20 Feb 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\EditorLocations;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Record Content
|
||||
*/
|
||||
class _Records
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return bool
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3 )
|
||||
{
|
||||
if ( ! $id3 )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$recordClass = '\IPS\cms\Records' . str_replace( '-review', '', $id3 );
|
||||
|
||||
return $recordClass::load( $id1 )->canView( $member );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment lookup
|
||||
*
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( $id3 )
|
||||
{
|
||||
$recordClass = '\IPS\cms\Records' . str_replace( '-review', '', $id3 );
|
||||
$return = $recordClass::load( $id1 );
|
||||
$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;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Editor Extension: Record Form
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 20 Feb 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\EditorLocations;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Record Content
|
||||
*/
|
||||
class _Widgets
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return bool
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3 )
|
||||
{
|
||||
if ( ! $id3 )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
$pageId = $this->getPageIdFromWidgetUniqueId( $id3 );
|
||||
|
||||
if ( $pageId === NULL )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
return \IPS\cms\Pages\Page::load( $pageId )->can( 'view', $member );
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment lookup
|
||||
*
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
{
|
||||
$pageId = $this->getPageIdFromWidgetUniqueId( $id3 );
|
||||
|
||||
if ( $pageId === NULL )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return \IPS\cms\Pages\Page::load( $pageId );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the page ID based on the widget's unique ID
|
||||
*
|
||||
* @param string $uniqueId The widget's unique ID
|
||||
* @return null|int
|
||||
*/
|
||||
protected function getPageIdFromWidgetUniqueId( $uniqueId )
|
||||
{
|
||||
$pageId = NULL;
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_page_widget_areas' ) as $item )
|
||||
{
|
||||
$widgets = json_decode( $item['area_widgets'], TRUE );
|
||||
|
||||
foreach( $widgets as $widget )
|
||||
{
|
||||
if ( $widget['unique'] == $uniqueId )
|
||||
{
|
||||
$pageId = $item['area_page_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $pageId;
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Pages
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Board
|
||||
* @since 20 October 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\FileStorage;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: CMS Pages
|
||||
*/
|
||||
class _Pages
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return 1; # Number of steps needed to clear/move files
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
/* Just remove page object data so it will rebuild on the next iteration */
|
||||
\IPS\cms\Pages\Page::deleteCachedIncludes();
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
/* Just remove page object data so it will rebuild on the next iteration */
|
||||
\IPS\cms\Pages\Page::deleteCachedIncludes();
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
$bits = explode( '/', (string) $file );
|
||||
$name = array_pop( $bits );
|
||||
|
||||
try
|
||||
{
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*)', 'cms_pages', array( "page_js_css_objects LIKE '%" . \IPS\Db::i()->escape_string( $name ) . "%'") )->first();
|
||||
|
||||
return $count ? TRUE : FALSE;
|
||||
}
|
||||
catch( \IPS\Db\Exception $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
\IPS\cms\Pages\Page::deleteCachedIncludes();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,392 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Records
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Board
|
||||
* @since 11 April 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\FileStorage;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Records
|
||||
*/
|
||||
class _Records
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
$count = 0;
|
||||
|
||||
$fields = array();
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'LOWER(field_type)=\'upload\'' ) ) as $field )
|
||||
{
|
||||
$fields[ $field['field_database_id'] ][] = $field['field_id'];
|
||||
}
|
||||
|
||||
foreach( \IPS\cms\Databases::databases() as $id => $db )
|
||||
{
|
||||
$where = array( array( 'record_image IS NOT NULL' ) );
|
||||
|
||||
if ( isset( $fields[ $id ] ) )
|
||||
{
|
||||
foreach( $fields[ $id ] as $field_id )
|
||||
{
|
||||
$where[] = array( 'field_' . $field_id . ' IS NOT NULL' );
|
||||
}
|
||||
}
|
||||
|
||||
$count += \IPS\Db::i()->select( 'COUNT(*)', 'cms_custom_database_' . $id, $where )->first();
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
if ( ! isset( \IPS\Data\Store::i()->cms_files_move_data ) )
|
||||
{
|
||||
foreach( \IPS\cms\Databases::databases() as $id => $database )
|
||||
{
|
||||
$data[ $id ] = 0;
|
||||
}
|
||||
|
||||
\IPS\Data\Store::i()->cms_files_move_data = $data;
|
||||
}
|
||||
|
||||
$data = \IPS\Data\Store::i()->cms_files_move_data;
|
||||
|
||||
if ( ! count( $data ) )
|
||||
{
|
||||
/* all done */
|
||||
unset( \IPS\Data\Store::i()->cms_files_move_data );
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
reset( $data );
|
||||
$databaseId = key( $data );
|
||||
$realOffset = $data[ $databaseId ];
|
||||
|
||||
$done = 0;
|
||||
$fields = array( 'record_image', 'record_image_thumb' );
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'field_database_id=? AND LOWER(field_type)=\'upload\'', $databaseId ) ) as $field )
|
||||
{
|
||||
$fields[] = 'field_' . $field['field_id'];
|
||||
}
|
||||
|
||||
$conditions = array();
|
||||
|
||||
foreach( $fields as $field )
|
||||
{
|
||||
$conditions[] = $field . ' IS NOT NULL';
|
||||
}
|
||||
|
||||
$where = array( implode( ' OR ', $conditions ) );
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, $where, 'primary_id_field ASC', array( $realOffset, 1 ) ) as $row )
|
||||
{
|
||||
foreach( $fields as $field )
|
||||
{
|
||||
if ( isset( $row[ $field ] ) and ! empty( $row[ $field ] ) )
|
||||
{
|
||||
if ( mb_strstr( $row[ $field ], ',' ) )
|
||||
{
|
||||
$files = explode( ',', $row[ $field ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$files = array( $row[ $field ] );
|
||||
}
|
||||
|
||||
$finished = array();
|
||||
$save = FALSE;
|
||||
|
||||
foreach( $files as $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
$check = \IPS\File::get( $oldConfiguration ?: 'cms_Records', $file )->move( $storageConfiguration );
|
||||
|
||||
if ( (string) $file != $check )
|
||||
{
|
||||
$fixed = TRUE;
|
||||
$save[] = $check;
|
||||
}
|
||||
else
|
||||
{
|
||||
$save[] = $file;
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
$save[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $fixed )
|
||||
{
|
||||
\IPS\Db::i()->update( 'cms_custom_database_' . $databaseId, array( $field => implode( ',', $save ) ), array( 'primary_id_field=?', $row['primary_id_field'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$done++;
|
||||
}
|
||||
|
||||
if ( $done )
|
||||
{
|
||||
$data[ $databaseId ] = $realOffset + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Assume all done */
|
||||
unset( $data[ $databaseId ] );
|
||||
}
|
||||
|
||||
if ( ! count( $data ) )
|
||||
{
|
||||
if ( isset( \IPS\Data\Store::i()->cms_files_move_data ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->cms_files_move_data );
|
||||
}
|
||||
|
||||
throw new \Underflowexception;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Data\Store::i()->cms_files_move_data = $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
if ( ! isset( \IPS\Data\Store::i()->cms_files_repair_data ) )
|
||||
{
|
||||
foreach( \IPS\cms\Databases::databases() as $id => $database )
|
||||
{
|
||||
$data[ $id ] = 0;
|
||||
}
|
||||
|
||||
\IPS\Data\Store::i()->cms_files_repair_data = $data;
|
||||
}
|
||||
|
||||
$data = \IPS\Data\Store::i()->cms_files_repair_data;
|
||||
|
||||
if ( ! count( $data ) )
|
||||
{
|
||||
/* all done */
|
||||
unset( \IPS\Data\Store::i()->cms_files_repair_data );
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
reset( $data );
|
||||
$databaseId = key( $data );
|
||||
$realOffset = $data[ $databaseId ];
|
||||
|
||||
$done = 0;
|
||||
$fields = array( 'record_image', 'record_image_thumb' );
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'field_database_id=? AND LOWER(field_type)=\'upload\'', $databaseId ) ) as $field )
|
||||
{
|
||||
$fields[] = 'field_' . $field['field_id'];
|
||||
}
|
||||
|
||||
$conditions = array();
|
||||
|
||||
foreach( $fields as $field )
|
||||
{
|
||||
$conditions[] = $field . ' IS NOT NULL';
|
||||
}
|
||||
|
||||
$where = array( implode( ' OR ', $conditions ) );
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, $where, 'primary_id_field ASC', array( $realOffset, 1 ) ) as $row )
|
||||
{
|
||||
foreach( $fields as $field )
|
||||
{
|
||||
if ( isset( $row[ $field ] ) and ! empty( $row[ $field ] ) )
|
||||
{
|
||||
if ( mb_strstr( $row[ $field ], ',' ) )
|
||||
{
|
||||
$files = explode( ',', $row[ $field ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$files = array( $row[ $field ] );
|
||||
}
|
||||
|
||||
$finished = array();
|
||||
$save = FALSE;
|
||||
|
||||
foreach( $files as $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( $new = \IPS\File::repairUrl( $file ) )
|
||||
{
|
||||
$fixed = TRUE;
|
||||
$save[] = $new;
|
||||
}
|
||||
else
|
||||
{
|
||||
$save[] = $file;
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
$save[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $fixed )
|
||||
{
|
||||
\IPS\Db::i()->update( 'cms_custom_database_' . $databaseId, array( $field => implode( ',', $save ) ), array( 'primary_id_field=?', $row['primary_id_field'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$done++;
|
||||
}
|
||||
|
||||
if ( $done )
|
||||
{
|
||||
$data[ $databaseId ] = $realOffset + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Assume all done */
|
||||
unset( $data[ $databaseId ] );
|
||||
}
|
||||
|
||||
if ( ! count( $data ) )
|
||||
{
|
||||
if ( isset( \IPS\Data\Store::i()->cms_files_repair_data ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->cms_files_repair_data );
|
||||
}
|
||||
|
||||
throw new \Underflowexception;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Data\Store::i()->cms_files_repair_data = $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach( \IPS\cms\Databases::databases() as $id => $db )
|
||||
{
|
||||
$theFile = \IPS\Db::i()->select( '*', 'cms_custom_database_' . $id, array( 'record_image=? OR record_image_thumb=?', (string) $file, (string) $file ) )->first();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
/* Gather all the upload fields */
|
||||
$fields = array();
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'LOWER(field_type)=\'upload\'' ) ) as $field )
|
||||
{
|
||||
$fields[ $field['field_database_id'] ][] = $field['field_id'];
|
||||
}
|
||||
|
||||
if ( is_array( $fields ) )
|
||||
{
|
||||
foreach( $fields as $databaseId => $data )
|
||||
{
|
||||
foreach( $data as $fieldId )
|
||||
{
|
||||
try
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, array( 'field_' . $fieldId .'=?', (string) $file ) )->first();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
/* Might be in another field */
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach( \IPS\cms\Databases::databases() as $databaseId => $database )
|
||||
{
|
||||
$fields = array( 'record_image', 'record_image_thumb' );
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'field_database_id=? AND LOWER(field_type)=\'upload\'', $databaseId ) ) as $field )
|
||||
{
|
||||
$fields[] = 'field_' . $field['field_id'];
|
||||
}
|
||||
|
||||
$where = array();
|
||||
|
||||
foreach( $fields as $field )
|
||||
{
|
||||
$where[] = array( $field . ' IS NOT NULL' );
|
||||
}
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, $where, 'primary_id_field ASC' ) as $row )
|
||||
{
|
||||
foreach( $fields as $field )
|
||||
{
|
||||
if ( isset( $row[ $field ] ) and ! empty( $row[ $field ] ) )
|
||||
{
|
||||
$file = \IPS\File::get( 'cms_Records', $row[ $field ] )->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,284 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Front Navigation Extension: Forums
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Board
|
||||
* @since 08 Jan 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
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: Content
|
||||
*/
|
||||
class _Cms
|
||||
{
|
||||
/**
|
||||
* @brief ID
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @brief Parent ID
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* Generate a number of classes for this extension
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function generate()
|
||||
{
|
||||
/* Toggling mod_rewrite doesn't update cms_menu cache automatically */
|
||||
if ( isset( \IPS\Data\Store::i()->cms_menu ) )
|
||||
{
|
||||
if ( ! isset( \IPS\Data\Store::i()->cms_menu['htaccess_mod_rewrite'] ) OR \IPS\Data\Store::i()->cms_menu['htaccess_mod_rewrite'] !== \IPS\Settings::i()->htaccess_mod_rewrite )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->cms_menu );
|
||||
}
|
||||
|
||||
if ( ! isset( \IPS\Data\Store::i()->cms_menu['pages_is_default'] ) OR \IPS\Data\Store::i()->cms_menu['pages_is_default'] != \IPS\Application::load('cms')->default )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->cms_menu );
|
||||
}
|
||||
}
|
||||
|
||||
/* Make a tree if we don't have one */
|
||||
if ( !isset( \IPS\Data\Store::i()->cms_menu ) )
|
||||
{
|
||||
$menu = array();
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_page_menu', NULL, 'menu_position' ) as $row )
|
||||
{
|
||||
/* Construct the node */
|
||||
$node = \IPS\cms\Pages\Menu::constructFromData( $row );
|
||||
|
||||
/* Can we see the parent? */
|
||||
$permission = $node->permission;
|
||||
if ( $node->type === 'page' and $node->permission === 'page' )
|
||||
{
|
||||
try
|
||||
{
|
||||
$perms = \IPS\cms\Pages\Page::load( $node->content )->permissions();
|
||||
|
||||
$permission = $perms['perm_view'];
|
||||
}
|
||||
catch( \OutOfRangeException $ex )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Work out the parent */
|
||||
$parent = $node->parent_id ?: 0;
|
||||
|
||||
/* Add it */
|
||||
$menu[ $parent ][ $node->_id ] = array(
|
||||
'id' => $node->_id,
|
||||
'type' => $node->type,
|
||||
'content' => $node->content,
|
||||
'title' => $node->title,
|
||||
'url' => ( string ) $node->_url,
|
||||
'permission' => $permission
|
||||
);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$defaultUrl = \IPS\cms\Pages\Page::getDefaultPage()->url();
|
||||
}
|
||||
catch( \OutOfRangeException $ex )
|
||||
{
|
||||
$defaultUrl = \IPS\Http\Url::internal( 'app=cms&module=pages&controller=page', 'front', 'content' );
|
||||
}
|
||||
|
||||
\IPS\Data\Store::i()->cms_menu = array(
|
||||
'menu' => $menu,
|
||||
'default' => (string) $defaultUrl,
|
||||
'htaccess_mod_rewrite' => \IPS\Settings::i()->htaccess_mod_rewrite,
|
||||
'pages_is_default' => \IPS\Application::load('cms')->default
|
||||
);
|
||||
}
|
||||
|
||||
$return = array();
|
||||
if ( count( \IPS\Data\Store::i()->cms_menu['menu'] ) )
|
||||
{
|
||||
foreach( \IPS\Data\Store::i()->cms_menu['menu'][0] as $id => $data )
|
||||
{
|
||||
$return[] = new self( $id );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$return[] = new self(0);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id The ID (0 for root)
|
||||
* @param int $parent The Parent ID (0 for root)
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $id = 0, $parent = 0 )
|
||||
{
|
||||
/* Set ID */
|
||||
$this->id = $id;
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can access?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canView()
|
||||
{
|
||||
if ( $this->id )
|
||||
{
|
||||
return \IPS\Data\Store::i()->cms_menu['menu'][ $this->parent ][ $this->id ]['permission'] === '*' or \IPS\Member::loggedIn()->inGroup( explode( ',', \IPS\Data\Store::i()->cms_menu['menu'][ $this->parent ][ $this->id ]['permission'] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return !\IPS\Application::load('cms')->hide_tab and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'cms', 'pages' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
if ( isset( \IPS\Data\Store::i()->cms_menu['menu'][ $this->parent ][ $this->id ] ) )
|
||||
{
|
||||
$item = \IPS\Data\Store::i()->cms_menu['menu'][ $this->parent ][ $this->id ];
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( $this->id ? ( ( ! $item['title'] and $item['type'] === 'page' ) ? 'cms_page_' . $item['content'] : 'cms_menu_title_' . $this->id ) : '__app_cms' );
|
||||
}
|
||||
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('__app_cms');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Root Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function link()
|
||||
{
|
||||
if ( $this->id )
|
||||
{
|
||||
return \IPS\Data\Store::i()->cms_menu['menu'][ $this->parent ][ $this->id ]['url'] ?: '#';
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Data\Store::i()->cms_menu['default'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get children
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function children()
|
||||
{
|
||||
if ( isset( \IPS\Data\Store::i()->cms_menu['menu'][ $this->id ] ) and count( \IPS\Data\Store::i()->cms_menu['menu'][ $this->id ] ) )
|
||||
{
|
||||
$return = array();
|
||||
foreach ( \IPS\Data\Store::i()->cms_menu['menu'][ $this->id ] as $child )
|
||||
{
|
||||
$return[] = new Cms( $child['id'], $this->id );
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
{
|
||||
if ( \IPS\Dispatcher::i()->application->directory === 'cms' )
|
||||
{
|
||||
if ( ! count( \IPS\Data\Store::i()->cms_menu['menu'] ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( \IPS\cms\Pages\Page::$currentPage )
|
||||
{
|
||||
/* A page... ? */
|
||||
if ( \IPS\Data\Store::i()->cms_menu['menu'][ $this->parent ][ $this->id ]['type'] === 'page' AND \IPS\cms\Pages\Page::$currentPage->id == \IPS\Data\Store::i()->cms_menu['menu'][ $this->parent ][ $this->id ]['content'] )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* A folder that has the page inside? */
|
||||
if ( \IPS\Data\Store::i()->cms_menu['menu'][ $this->parent ][ $this->id ]['type'] === 'folder' )
|
||||
{
|
||||
if ( isset( \IPS\Data\Store::i()->cms_menu['menu'][ $this->id ] ) )
|
||||
{
|
||||
foreach( \IPS\Data\Store::i()->cms_menu['menu'][ $this->id ] as $id => $data )
|
||||
{
|
||||
if ( $this->checkInsideFolderForCurrentPage( $this->id ) === TRUE )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check recursively to see if the current page is in side the folder
|
||||
*
|
||||
* @param $parent
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkInsideFolderForCurrentPage( $parent )
|
||||
{
|
||||
if ( isset( \IPS\Data\Store::i()->cms_menu['menu'][ $parent ] ) )
|
||||
{
|
||||
foreach( \IPS\Data\Store::i()->cms_menu['menu'][ $parent ] as $id => $data )
|
||||
{
|
||||
if ( \IPS\cms\Pages\Page::$currentPage->id == $data['content'] )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $this->checkInsideFolderForCurrentPage( $id ) === TRUE )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Member Sync
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Pages
|
||||
* @since 20 Aug 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\MemberSync;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Member Sync
|
||||
*/
|
||||
class _Databases
|
||||
{
|
||||
/**
|
||||
* Member is merged with another member
|
||||
*
|
||||
* @param \IPS\Member $member Member being kept
|
||||
* @param \IPS\Member $member2 Member being removed
|
||||
* @return void
|
||||
*/
|
||||
public function onMerge( $member, $member2 )
|
||||
{
|
||||
\IPS\Db::i()->update( 'cms_database_revisions', array( 'revision_member_id' => $member->member_id ), array( 'revision_member_id=?', $member2->member_id ) );
|
||||
|
||||
try
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( 'database_id', 'cms_databases' ) as $id )
|
||||
{
|
||||
\IPS\Db::i()->update( 'cms_custom_database_' . $id, array( 'record_last_comment_by' => $member->member_id, 'record_last_comment_name' => $member->name, 'record_last_comment_seo' => $member->members_seo_name ), array( 'record_last_comment_by=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'cms_custom_database_' . $id, array( 'record_last_review_by' => $member->member_id, 'record_last_review_name' => $member->name, 'record_last_review_seo' => $member->members_seo_name ), array( 'record_last_review_by=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'cms_custom_database_' . $id, array( 'record_edit_member_id' => $member->member_id, 'record_edit_member_name' => $member->name ), array( 'record_edit_member_id=?', $member2->member_id ) );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) {} // If you have not upgraded pages but it is installed, this throws an error
|
||||
|
||||
/* Update member fields in the db */
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'field_type=?', 'Member' ) ) as $field )
|
||||
{
|
||||
$where = array(
|
||||
'field_' . $field['field_id'] . '=? OR field_' . $field['field_id'] . ' LIKE ? OR ' . $field['field_id'] . ' LIKE ? OR ' . $field['field_id'] . ' LIKE ?',
|
||||
$member2->member_id,
|
||||
$member2->member_id . ',%',
|
||||
'%,' . $member2->member_id . ',%',
|
||||
'%,' . $member2->member_id
|
||||
);
|
||||
|
||||
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $field['field_database_id'], $where ) as $record )
|
||||
{
|
||||
$members = explode( ',', $record['field_' . $field['field_id'] ] );
|
||||
|
||||
foreach( $members as $k => $_member )
|
||||
{
|
||||
if( $_member == $member2->member_id )
|
||||
{
|
||||
$members[ $k ] = $member->member_id;
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'cms_custom_database_' . $field['field_database_id'], array( 'field_' . $field['field_id'] => implode( ',', $members ) ), array( 'primary_id_field=?', $record['primary_id_field'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Member is deleted
|
||||
*
|
||||
* @param $member \IPS\Member The member
|
||||
* @return void
|
||||
*/
|
||||
public function onDelete( $member )
|
||||
{
|
||||
\IPS\Db::i()->update( 'cms_database_revisions', array( 'revision_member_id' => 0 ), array( 'revision_member_id=?', $member->member_id ) );
|
||||
|
||||
try
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( 'database_id', 'cms_databases' ) as $id )
|
||||
{
|
||||
\IPS\Db::i()->update( 'cms_custom_database_' . $id, array( 'record_last_comment_by' => 0 ), array( 'record_last_comment_by=?', $member->member_id ) );
|
||||
\IPS\Db::i()->update( 'cms_custom_database_' . $id, array( 'record_last_review_by' => 0 ), array( 'record_last_review_by=?', $member->member_id ) );
|
||||
\IPS\Db::i()->update( 'cms_custom_database_' . $id, array( 'record_edit_member_id' => 0 ), array( 'record_edit_member_id=?', $member->member_id ) );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) {} // If you have not upgraded pages but it is installed, this throws an error
|
||||
|
||||
/* Update member fields in the db */
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'field_type=?', 'Member' ) ) as $field )
|
||||
{
|
||||
$where = array(
|
||||
'field_' . $field['field_id'] . '=? OR field_' . $field['field_id'] . ' LIKE ? OR ' . $field['field_id'] . ' LIKE ? OR ' . $field['field_id'] . ' LIKE ?',
|
||||
$member->member_id,
|
||||
$member->member_id . ',%',
|
||||
'%,' . $member->member_id . ',%',
|
||||
'%,' . $member->member_id
|
||||
);
|
||||
|
||||
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $field['field_database_id'], $where ) as $record )
|
||||
{
|
||||
$members = explode( ',', $record['field_' . $field['field_id'] ] );
|
||||
|
||||
foreach( $members as $k => $_member )
|
||||
{
|
||||
if( $_member == $member2->member_id )
|
||||
{
|
||||
unset( $members[ $k ] );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'cms_custom_database_' . $field['field_database_id'], array( 'field_' . $field['field_id'] => implode( ',', $members ) ), array( 'primary_id_field=?', $record['primary_id_field'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Moderator Permissions: Databases
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 30 April 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\ModeratorPermissions;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moderator Permissions: Databases
|
||||
*/
|
||||
class _Databases
|
||||
{
|
||||
/**
|
||||
* Get Permissions
|
||||
*
|
||||
* @code
|
||||
return array(
|
||||
'key' => 'YesNo', // Can just return a string with type
|
||||
'key' => array( // Or an array for more options
|
||||
'YesNo' // Type
|
||||
array( ... ) // Options (as defined by type's class)
|
||||
'prefix', // Prefix
|
||||
'suffix' // Suffix
|
||||
),
|
||||
...
|
||||
);
|
||||
* @endcode
|
||||
* @return array
|
||||
*/
|
||||
public function getPermissions()
|
||||
{
|
||||
/* Preload words */
|
||||
\IPS\cms\Databases::databases();
|
||||
|
||||
return array(
|
||||
'can_content_revisions_content' => 'YesNo',
|
||||
'can_content_edit_record_slugs' => "YesNo",
|
||||
'can_content_edit_meta_tags' => "YesNo"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* After change
|
||||
*
|
||||
* @param array $moderator The moderator
|
||||
* @param array $changed Values that were changed
|
||||
* @return void
|
||||
*/
|
||||
public function onChange( $moderator, $changed )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* After delete
|
||||
*
|
||||
* @param array $moderator The moderator
|
||||
* @return void
|
||||
*/
|
||||
public function onDelete( $moderator )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Template Plugin - Content: Block
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 12 March 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\OutputPlugins;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Template Plugin - Content: Block
|
||||
*/
|
||||
class _Block
|
||||
{
|
||||
/**
|
||||
* @brief Can be used when compiling CSS
|
||||
*/
|
||||
public static $canBeUsedInCss = TRUE;
|
||||
|
||||
/**
|
||||
* Run the plug-in
|
||||
*
|
||||
* @param string $data The initial data from the tag
|
||||
* @param array $options Array of options
|
||||
* @return string Code to eval
|
||||
*/
|
||||
public static function runPlugin( $data, $options )
|
||||
{
|
||||
return "\IPS\cms\Blocks\Block::display( \"$data\" )";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Template Plugin - Content: Database
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 12 March 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\OutputPlugins;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Template Plugin - Content: Database
|
||||
*/
|
||||
class _Database
|
||||
{
|
||||
/**
|
||||
* @brief Can be used when compiling CSS
|
||||
*/
|
||||
public static $canBeUsedInCss = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Record how many database tags there are per page
|
||||
*/
|
||||
public static $count = 0;
|
||||
|
||||
/**
|
||||
* Run the plug-in
|
||||
*
|
||||
* @param string $data The initial data from the tag
|
||||
* @param array $options Array of options
|
||||
* @return string Code to eval
|
||||
*/
|
||||
public static function runPlugin( $data, $options )
|
||||
{
|
||||
if ( isset( $options['category'] ) )
|
||||
{
|
||||
return '\IPS\cms\Databases\Dispatcher::i()->setDatabase( "' . $data . '" )->setCategory( "' . $options['category'] . '" )->run()';
|
||||
}
|
||||
|
||||
return '\IPS\cms\Databases\Dispatcher::i()->setDatabase( "' . $data . '" )->run()';
|
||||
}
|
||||
|
||||
/**
|
||||
* Do any processing before a page is added/saved
|
||||
*
|
||||
* @param string $data The initial data from the tag
|
||||
* @param array $options Array of options
|
||||
* @param object $page Page being edited/saved
|
||||
* @return void
|
||||
*/
|
||||
public static function preSaveProcess( $data, $options, $page )
|
||||
{
|
||||
/* Keep a count of databases used so far */
|
||||
static::$count++;
|
||||
|
||||
if ( static::$count > 1 )
|
||||
{
|
||||
throw new \LogicException( \IPS\Member::loggedIn()->language()->addToStack('cms_err_db_already_on_page') );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do any processing after a page is added/saved
|
||||
*
|
||||
* @param string $data The initial data from the tag
|
||||
* @param array $options Array of options
|
||||
* @param object $page Page being edited/saved
|
||||
* @return void
|
||||
*/
|
||||
public static function postSaveProcess( $data, $options, $page )
|
||||
{
|
||||
$database = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
if ( is_numeric( $data ) )
|
||||
{
|
||||
$database = \IPS\cms\Databases::load( $data );
|
||||
}
|
||||
else
|
||||
{
|
||||
$database = \IPS\cms\Databases::load( $data, 'database_key' );
|
||||
}
|
||||
|
||||
if ( $database->id AND $page->id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$page->mapToDatabase( $database->id );
|
||||
}
|
||||
catch( \LogicException $ex )
|
||||
{
|
||||
throw new \LogicException( $ex->getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \OutofRangeException $ex ) { }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Template Plugin - Pages: Page Url
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 27 May 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\OutputPlugins;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Template Plugin - Content: Block
|
||||
*/
|
||||
class _Pageurl
|
||||
{
|
||||
/**
|
||||
* @brief Can be used when compiling CSS
|
||||
*/
|
||||
public static $canBeUsedInCss = FALSE;
|
||||
|
||||
/**
|
||||
* Run the plug-in
|
||||
*
|
||||
* @param string $data The initial data from the tag
|
||||
* @param array $options Array of options
|
||||
* @return string Code to eval
|
||||
*/
|
||||
public static function runPlugin( $data, $options )
|
||||
{
|
||||
if ( is_numeric( $data ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$url = \IPS\cms\Pages\Page::load( $data )->url();
|
||||
}
|
||||
catch( \OutOfRageException $ex )
|
||||
{
|
||||
$url = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = ltrim( $data );
|
||||
$url = \IPS\Http\Url::internal( 'app=cms&module=pages&controller=page&path=' . $data, 'front', 'content_page_path', array( $data ) );
|
||||
}
|
||||
|
||||
return "'" . (string) $url . "'";
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Background Task: Rebuild database categories
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 13 Jun 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
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: Rebuild database categories
|
||||
*/
|
||||
class _RebuildCategories
|
||||
{
|
||||
/**
|
||||
* @brief Number of content items to rebuild per cycle
|
||||
*/
|
||||
public $rebuild = 50;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function preQueueData( $data )
|
||||
{
|
||||
$classname = $data['class'];
|
||||
$databaseId = mb_substr( $classname, 18 );
|
||||
|
||||
\IPS\Log::i( LOG_DEBUG )->write( "Getting preQueueData for " . $classname, 'rebuildCategories' );
|
||||
|
||||
try
|
||||
{
|
||||
$data['count'] = (int) \IPS\Db::i()->select( 'COUNT(*)', 'cms_database_categories' )->first();
|
||||
}
|
||||
catch( \Exception $ex )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
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|null New offset or NULL if complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( $data, $offset )
|
||||
{
|
||||
$classname = $data['class'];
|
||||
$databaseId = mb_substr( $classname, 18 );
|
||||
|
||||
$class = '\IPS\cms\Categories' . $databaseId;
|
||||
$parsed = 0;
|
||||
|
||||
foreach ( \IPS\Db::i()->select( '*', 'cms_database_categories', array( 'category_database_id=?', $databaseId ), 'category_id asc', array( $offset, $this->rebuild ) ) as $row )
|
||||
{
|
||||
try
|
||||
{
|
||||
$cat = $class::constructFromData( $row );
|
||||
$cat->setLastComment();
|
||||
$cat->save();
|
||||
|
||||
$parsed++;
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return ( $parsed == $this->rebuild ) ? ( $offset + $this->rebuild ) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 explaning task and percentage complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function getProgress( $data, $offset )
|
||||
{
|
||||
$classname = $data['class'];
|
||||
$databaseId = mb_substr( $classname, 18 );
|
||||
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack( 'rebuilding_cms_database_categories', FALSE, array( 'sprintf' => array( \IPS\cms\Databases::load( $databaseId )->_title ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Background Task: Rebuild database editor fields
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 27 March 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
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: Rebuild database editor fields
|
||||
*/
|
||||
class _RebuildEditorFields
|
||||
{
|
||||
/**
|
||||
* @brief Number of content items to rebuild per cycle
|
||||
*/
|
||||
public $rebuild = 50;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function preQueueData( $data )
|
||||
{
|
||||
$classname = $data['class'];
|
||||
$databaseId = mb_substr( $classname, 15 );
|
||||
$fieldId = $data['fieldId'];
|
||||
|
||||
try
|
||||
{
|
||||
$data['count'] = (int) \IPS\Db::i()->select( 'MAX(primary_id_field)', 'cms_custom_database_' . $databaseId )->first();
|
||||
}
|
||||
catch( \Exception $ex )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
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|null New offset or NULL if complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( $data, $offset )
|
||||
{
|
||||
$classname = $data['class'];
|
||||
$databaseId = mb_substr( $classname, 15 );
|
||||
$fieldId = $data['fieldId'];
|
||||
|
||||
$parsed = 0;
|
||||
$class = '\IPS\cms\Records' . $databaseId;
|
||||
$last = NULL;
|
||||
|
||||
if ( \IPS\Db::i()->checkForTable( 'cms_custom_database_' . $databaseId ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, array( 'primary_id_field > ?', $offset ), 'primary_id_field asc', array( 0, $this->rebuild ) ) as $row )
|
||||
{
|
||||
$item = $class::constructFromData( $row );
|
||||
$contentColumn = 'field_' . $fieldId;
|
||||
|
||||
$member = \IPS\Member::load( $item->mapped('author') );
|
||||
$extensions = \IPS\Application::load( $classname::$application )->extensions( 'core', 'EditorLocations' );
|
||||
$idColumn = $classname::$databaseColumnId;
|
||||
|
||||
if( isset( $classname::$itemClass ) )
|
||||
{
|
||||
$itemClass = $classname::$itemClass;
|
||||
$module = ucfirst( $itemClass::$module );
|
||||
}
|
||||
else
|
||||
{
|
||||
$module = ucfirst( $classname::$module );
|
||||
}
|
||||
|
||||
$extension = NULL;
|
||||
|
||||
if ( isset( $extensions[ $module ] ) )
|
||||
{
|
||||
$extension = $extensions[ $module ];
|
||||
}
|
||||
|
||||
$canUseHtml = (bool) $member->group['g_dohtml'];
|
||||
|
||||
if ( $extension )
|
||||
{
|
||||
$extensionCanUseHtml = $extension->canUseHtml( $member );
|
||||
if ( $extensionCanUseHtml !== NULL )
|
||||
{
|
||||
$canUseHtml = $extensionCanUseHtml;
|
||||
}
|
||||
}
|
||||
|
||||
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 ) );
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
{
|
||||
if( $e->getcode() == 103014 )
|
||||
{
|
||||
$item->$contentColumn = preg_replace( "#\[/?([^\]]+?)\]#", '', $item->$contentColumn );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
$item->save();
|
||||
|
||||
$last = $item->$idColumn;
|
||||
}
|
||||
}
|
||||
|
||||
return $last;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 explaning task and percentage complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function getProgress( $data, $offset )
|
||||
{
|
||||
$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 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Background Task: Rebuild database records
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 13 Jun 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
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: Rebuild database records
|
||||
*/
|
||||
class _RebuildRecords
|
||||
{
|
||||
/**
|
||||
* @brief Number of content items to rebuild per cycle
|
||||
*/
|
||||
public $rebuild = 50;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function preQueueData( $data )
|
||||
{
|
||||
$classname = $data['class'];
|
||||
$databaseId = mb_substr( $classname, 15 );
|
||||
|
||||
\IPS\Log::i( LOG_DEBUG )->write( "Getting preQueueData for " . $classname, 'rebuildRecords' );
|
||||
|
||||
try
|
||||
{
|
||||
$data['count'] = (int) \IPS\Db::i()->select( 'COUNT(*)', 'cms_custom_database_' . $databaseId )->first();
|
||||
}
|
||||
catch( \Exception $ex )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
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|null New offset or NULL if complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( $data, $offset )
|
||||
{
|
||||
$classname = $data['class'];
|
||||
$databaseId = mb_substr( $classname, 15 );
|
||||
|
||||
/* Make sure there's even content to parse */
|
||||
if( !isset( $classname::$databaseColumnMap['content'] ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
$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 )
|
||||
{
|
||||
$record = $class::constructFromData( $row );
|
||||
$record->resetLastComment();
|
||||
|
||||
if ( $record->record_image and file_exists( \IPS\ROOT_PATH . '/uploads/' . $record->record_image ) )
|
||||
{
|
||||
$record->record_image = (string) \IPS\File::create( 'content_Records', $record->record_image, file_get_contents( \IPS\ROOT_PATH . '/uploads/' . $record->record_image ) );
|
||||
$record->save();
|
||||
}
|
||||
|
||||
if ( ! $record->record_publish_date )
|
||||
{
|
||||
$record->record_publish_date = $record->record_saved;
|
||||
$record->save();
|
||||
}
|
||||
|
||||
$parsed++;
|
||||
}
|
||||
}
|
||||
|
||||
return ( $parsed == $this->rebuild ) ? ( $offset + $this->rebuild ) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 explaning task and percentage complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function getProgress( $data, $offset )
|
||||
{
|
||||
$classname = $data['class'];
|
||||
$databaseId = mb_substr( $classname, 18 );
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Support Pages Databases in sitemaps
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 1 April 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\Sitemap;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Support Pages Databases in sitemaps
|
||||
*/
|
||||
class _Databases
|
||||
{
|
||||
/**
|
||||
* @brief Recommended Settings
|
||||
*/
|
||||
public $recommendedSettings = array(
|
||||
'sitemap_databases_count' => -1,
|
||||
'sitemap_databases_priority' => -1
|
||||
);
|
||||
|
||||
/**
|
||||
* Settings for ACP configuration to the form
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function settings()
|
||||
{
|
||||
return array(
|
||||
'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' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sitemap filename(s)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFilenames()
|
||||
{
|
||||
$files = array();
|
||||
|
||||
/* Check that guests can access the content at all */
|
||||
foreach( \IPS\cms\Databases::databases() as $database )
|
||||
{
|
||||
if ( $database->page_id > 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( !$database->can( 'view', new \IPS\Member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = '\IPS\cms\Records' . $database->id;
|
||||
|
||||
if ( isset( $class::$containerNodeClass ) )
|
||||
{
|
||||
$nodeClass = $class::$containerNodeClass;
|
||||
|
||||
/* We need one file for the nodes */
|
||||
$files[] = $database->id . '_sitemap_database_categories';
|
||||
}
|
||||
|
||||
/* And however many for the content items */
|
||||
$count = ceil( max( (int) $class::getItemsWithPermission( $class::sitemapWhere(), NULL, 10, 'read', 10, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS, new \IPS\Member )->count( 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the sitemap
|
||||
*
|
||||
* @param string $filename The sitemap file to build (should be one returned from getFilenames())
|
||||
* @param \IPS\Sitemap $sitemap Sitemap object reference
|
||||
* @return void
|
||||
*/
|
||||
public function generateSitemap( $filename, $sitemap )
|
||||
{
|
||||
$tmp = explode( '_', $filename );
|
||||
$databaseId = intval( array_shift( $tmp ) );
|
||||
$database = \IPS\cms\Databases::load( $databaseId );
|
||||
|
||||
$class = '\IPS\cms\Records' . $databaseId;
|
||||
if ( isset( $class::$containerNodeClass ) )
|
||||
{
|
||||
$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 ) ) )
|
||||
{
|
||||
$select = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', $nodeClass::$databaseTable, array( '(' . \IPS\Db::i()->findInSet( 'perm_view', array( \IPS\Settings::i()->guest_group ) ) . ' OR ' . 'perm_view=? )', '*' ) )->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', true ) )
|
||||
{
|
||||
$select = $nodeClass::loadByOwner( new \IPS\Member );
|
||||
}
|
||||
|
||||
foreach ( $select as $node )
|
||||
{
|
||||
if( $node->url() !== NULL )
|
||||
{
|
||||
$data = array( 'url' => $node->url() );
|
||||
|
||||
$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 )
|
||||
{
|
||||
$limit = $totalLimit - $offset;
|
||||
}
|
||||
|
||||
foreach ( $class::getItemsWithPermission( $class::sitemapWhere(), NULL, array( $offset, $limit ), 'read', FALSE, 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 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Support Pages in sitemaps
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 1 April 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\Sitemap;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Support Pages in sitemaps
|
||||
*/
|
||||
class _Pages
|
||||
{
|
||||
/**
|
||||
* @brief Recommended Settings
|
||||
*/
|
||||
public $recommendedSettings = array(
|
||||
'sitemap_pages_count' => -1,
|
||||
'sitemap_pages_priority' => -1
|
||||
);
|
||||
|
||||
/**
|
||||
* Settings for ACP configuration to the form
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function settings()
|
||||
{
|
||||
return array(
|
||||
'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' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sitemap filename(s)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFilenames()
|
||||
{
|
||||
$files = array();
|
||||
$class = '\IPS\cms\Pages\Page';
|
||||
$count = 0;
|
||||
$member = new \IPS\Member;
|
||||
$permissionCheck = 'view';
|
||||
|
||||
$where = array( array( '(' . \IPS\Db::i()->findInSet( 'perm_' . $class::$permissionMap[ $permissionCheck ], $member->groups ) . ' OR ' . 'perm_' . $class::$permissionMap[ $permissionCheck ] . '=? )', '*' ) );
|
||||
|
||||
$count = \IPS\Db::i()->select( '*', $class::$databaseTable )
|
||||
->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 ) )
|
||||
->count();
|
||||
|
||||
$count = ceil( max( $count, \IPS\Settings::i()->sitemap_pages_count ) / \IPS\Sitemap::MAX_PER_FILE );
|
||||
|
||||
for( $i=1; $i <= $count; $i++ )
|
||||
{
|
||||
$files[] = 'sitemap_pages_' . $i;
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the sitemap
|
||||
*
|
||||
* @param string $filename The sitemap file to build (should be one returned from getFilenames())
|
||||
* @param \IPS\Sitemap $sitemap Sitemap object reference
|
||||
* @return void
|
||||
*/
|
||||
public function generateSitemap( $filename, $sitemap )
|
||||
{
|
||||
$class = '\IPS\cms\Pages\Page';
|
||||
$count = 0;
|
||||
$member = new \IPS\Member;
|
||||
$permissionCheck = 'view';
|
||||
|
||||
$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_pages_count;
|
||||
if ( $totalLimit > -1 and ( $offset + $limit ) > $totalLimit )
|
||||
{
|
||||
$limit = $totalLimit - $offset;
|
||||
}
|
||||
|
||||
$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, NULL, 'page_id ASC', 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 )
|
||||
{
|
||||
$item = $class::constructFromData( $row );
|
||||
|
||||
$data = array( 'url' => $item->url() );
|
||||
$priority = intval( \IPS\Settings::i()->sitemap_pages_priority );
|
||||
if ( $priority !== -1 )
|
||||
{
|
||||
$data['priority'] = $priority;
|
||||
}
|
||||
|
||||
$entries[] = $data;
|
||||
}
|
||||
|
||||
$sitemap->buildSitemapFile( $filename, $entries );
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Records
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Board
|
||||
* @since 11 April 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\cms\extensions\core\Uninstall;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove custom databases
|
||||
*/
|
||||
class _Databases
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstall custom databases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preUninstall( )
|
||||
{
|
||||
if ( \IPS\Db::i()->checkForTable( 'cms_databases' ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'cms_databases') as $db )
|
||||
{
|
||||
/* The content router only returns databases linked to pages. In theory, you may have linked a database and then removed it,
|
||||
so the method to remove all app content from the search index fails, so we need to account for that here: */
|
||||
\IPS\Content\Search\Index::i()->removeClassFromSearchIndex( 'IPS\cms\Records' . $db['database_id'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstall custom databases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postUninstall()
|
||||
{
|
||||
/* cms_databases has been removed */
|
||||
$tables = array();
|
||||
try
|
||||
{
|
||||
$databaseTables = \IPS\Db::i()->query("SHOW TABLES LIKE '" . \IPS\Db::i()->prefix . "cms_custom_database_%'" )->fetch_assoc();
|
||||
if ( $databaseTables )
|
||||
{
|
||||
foreach( $databaseTables as $row )
|
||||
{
|
||||
if( is_array( $row ) )
|
||||
{
|
||||
$tables[] = array_pop($row);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tables[] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch( \IPS\Db\Exception $ex ) { }
|
||||
|
||||
foreach( $tables as $table )
|
||||
{
|
||||
if ( \IPS\Db::i()->checkForTable( $table ) )
|
||||
{
|
||||
\IPS\Db::i()->dropTable( $table );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Data\Store::i()->cms_menu ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->cms_menu );
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
Whitespace-only changes.
Reference in new issue
Block a user