Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

@@ -30,17 +30,21 @@ class _Records
public $classes = array();
/**
* Define classes here
* Constructor
*
* @return array
* @param \IPS\Member|NULL $member If checking access, the member to check for, or NULL to not check access
* @return void
*/
public function __construct()
public function __construct( \IPS\Member $member = NULL )
{
try
{
foreach ( \IPS\Db::i()->select( 'database_id', 'cms_databases', 'database_page_id>0' ) as $id )
{
$this->classes[] = 'IPS\cms\Records' . $id;
if ( !$member or call_user_func( array( 'IPS\cms\Databases', 'load' ), $id )->can( 'view', $member ) )
{
$this->classes[] = 'IPS\cms\Records' . $id;
}
}
}
catch ( \Exception $e ) {} // If you have not upgraded pages but it is installed, this throws an error
@@ -43,7 +43,7 @@ class _Cms
public function on( $data=NULL )
{
\IPS\cms\Theme\Advanced\Theme::export();
\IPS\cms\Media::exportDesignersModeMedia();
return TRUE;
}
@@ -55,6 +55,7 @@ class _Cms
public function off( $data=NULL )
{
\IPS\cms\Theme\Advanced\Theme::import();
\IPS\cms\Media::importDesignersModeMedia();
return TRUE;
}
@@ -58,8 +58,7 @@ class _BlockContent
{
try
{
$recordClass = '\IPS\cms\Records' . $id3;
return $recordClass::load( $id1 )->canView( $member );
return \IPS\cms\Blocks\Block::load( $id1 )->can( 'view' );
}
catch ( \OutOfRangeException $e )
{
@@ -80,8 +79,7 @@ class _BlockContent
{
try
{
$recordClass = '\IPS\cms\Records' . $id3;
return $recordClass::load( $id1 );
return \IPS\cms\Blocks\Block::load( $id1 );
}
catch ( \OutOfRangeException $e )
{
@@ -0,0 +1,119 @@
<?php
/**
* @brief File Storage Extension: Media
* @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 07 July 2015
* @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 Media
*/
class _Media
{
/**
* Count stored files
*
* @return int
*/
public function count()
{
return \IPS\Db::i()->select( 'COUNT(*)', 'cms_media' )->first();
}
/**
* 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|int An offset integer to use on the next cycle, or nothing
*/
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
{
$media = \IPS\Db::i()->select( '*', 'cms_media', array(), 'media_id', array( $offset, 1 ) )->first();
try
{
$file = \IPS\File::get( $oldConfiguration ?: 'cms_Media', $media['media_file_object'] )->move( $storageConfiguration );
if ( (string) $file != $media['media_file_object'] )
{
\IPS\Db::i()->update( 'cms_media', array( 'media_file_object' => (string) $file ), array( 'media_id=?', $media['media_id'] ) );
}
}
catch( \Exception $e )
{
/* Any issues are logged */
}
}
/**
* 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 )
{
$media = \IPS\Db::i()->select( '*', 'cms_media', array(), 'media_id', array( $offset, 1 ) )->first();
if ( $new = \IPS\File::repairUrl( $media['media_file_object'] ) )
{
\IPS\Db::i()->update( 'cms_media', array( 'media_file_object' => $new ), array( 'media_id=?', $media['media_id'] ) );
unset( \IPS\Data\Store::i()->emoticons );
}
}
/**
* Check if a file is valid
*
* @param \IPS\Http\Url $file The file to check
* @return bool
*/
public function isValidFile( $file )
{
try
{
$media = \IPS\Db::i()->select( '*', 'cms_media', array( 'media_file_object=?', (string) $file ) )->first();
return TRUE;
}
catch ( \UnderflowException $e )
{
return FALSE;
}
}
/**
* Delete all stored files
*
* @return void
*/
public function delete()
{
foreach( \IPS\Db::i()->select( '*', 'cms_media', 'media_file_object IS NOT NULL' ) as $item )
{
try
{
\IPS\File::get( 'cms_Media', $item['media_file_object'] )->delete();
}
catch( \Exception $e ){}
}
}
}
@@ -338,7 +338,7 @@ class _Records
{
try
{
$record = \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, array( 'field_' . $fieldId .'=?', (string) $file ) )->first();
$record = \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, 'field_' . $fieldId . " LIKE '%" . (string) $file . "%'" )->first();
return TRUE;
}
@@ -1,15 +1,5 @@
<?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
*/
/* 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 */
@@ -20,143 +10,10 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
}
/**
* Front Navigation Extension: Content
* Front Navigation Extension: Pages
*/
class _Cms
class _Cms extends \IPS\core\FrontNavigation\FrontNavigationAbstract
{
/**
* @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
*
@@ -164,121 +21,15 @@ class _Cms
*/
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
* Get 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;
}
}
@@ -0,0 +1,178 @@
<?php
/**
* @brief Front Navigation 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 Pages
* @since 01 Jul 2015
* @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: Pages
*/
class _Pages extends \IPS\core\FrontNavigation\FrontNavigationAbstract
{
/**
* Get Type Title which will display in the AdminCP Menu Manager
*
* @return string
*/
public static function typeTitle()
{
return \IPS\Member::loggedIn()->language()->addToStack('menu_content_page');
}
/**
* Allow multiple instances?
*
* @return string
*/
public static function allowMultiple()
{
return TRUE;
}
/**
* 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
* @return array
*/
public static function configuration( $existingConfiguration, $id = NULL )
{
$pages = array();
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'cms_pages' ), 'IPS\cms\Pages\Page' ) as $page )
{
$pages[ $page->id ] = $page->full_path;
}
return array(
new \IPS\Helpers\Form\Select( 'menu_content_page', isset( $existingConfiguration['menu_content_page'] ) ? $existingConfiguration['menu_content_page'] : NULL, NULL, array( 'options' => $pages ), NULL, NULL, NULL, 'menu_content_page' ),
new \IPS\Helpers\Form\Radio( 'menu_title_page_type', isset( $existingConfiguration['menu_title_page'] ) ? $existingConfiguration['menu_title_page'] : 0, NULL, array( 'options' => array( 0 => 'menu_title_page_inherit', 1 => 'menu_title_page_custom' ), 'toggles' => array( 1 => array( 'menu_title_page' ) ) ), NULL, NULL, NULL, 'menu_title_page_type' ),
new \IPS\Helpers\Form\Translatable( 'menu_title_page', NULL, NULL, array( 'app' => 'cms', 'key' => $id ? "cms_menu_title_{$id}" : NULL ), NULL, NULL, NULL, 'menu_title_page' ),
);
}
/**
* Parse configuration fields
*
* @param array $configuration The values received from the form
* @return array
*/
public static function parseConfiguration( $configuration, $id )
{
if ( $configuration['menu_title_page_type'] )
{
\IPS\Lang::saveCustom( 'cms', "cms_menu_title_{$id}", $configuration['menu_title_page'] );
}
else
{
\IPS\Lang::deleteCustom( 'cms', "cms_menu_title_{$id}" );
}
unset( $configuration['menu_title_page'] );
return $configuration;
}
/**
* Can access?
*
* @return bool
*/
public function canView()
{
if ( $this->permissions )
{
if ( $this->permissions != '*' )
{
return \IPS\Member::loggedIn()->inGroup( explode( ',', $this->permissions ) );
}
return TRUE;
}
/* Inherit from page */
$store = \IPS\cms\Pages\Page::getPageUrlStore();
if ( isset( $store[ $this->configuration['menu_content_page'] ] ) )
{
if ( $store[ $this->configuration['menu_content_page'] ]['perm'] != '*' )
{
return \IPS\Member::loggedIn()->inGroup( explode( ',', $store[ $this->configuration['menu_content_page'] ]['perm'] ) );
}
return TRUE;
}
return FALSE;
}
/**
* Get Title
*
* @return string
*/
public function title()
{
if ( $this->configuration['menu_title_page_type'] )
{
return \IPS\Member::loggedIn()->language()->addToStack( "cms_menu_title_{$this->id}" );
}
else
{
return \IPS\Member::loggedIn()->language()->addToStack( "cms_page_{$this->configuration['menu_content_page']}" );
}
}
/**
* Get Link
*
* @return \IPS\Http\Url
*/
public function link()
{
$store = \IPS\cms\Pages\Page::getPageUrlStore();
if ( isset( $store[ $this->configuration['menu_content_page'] ] ) )
{
return $store[ $this->configuration['menu_content_page'] ]['url'];
}
/* Fall back here */
return \IPS\cms\Pages\Page::load( $this->configuration['menu_content_page'] )->url();
}
/**
* Is Active?
*
* @return bool
*/
public function active()
{
return ( \IPS\cms\Pages\Page::$currentPage and \IPS\cms\Pages\Page::$currentPage->id == $this->configuration['menu_content_page'] ) or parent::active();
}
/**
* Children
*
* @return array
*/
public function children()
{
return array();
}
}
@@ -50,11 +50,7 @@ class _Databases
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
\IPS\Db::i()->findInSet( 'field_' . $field['field_id'], array( $member2->member_id ) )
);
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $field['field_database_id'], $where ) as $record )
@@ -99,11 +95,7 @@ class _Databases
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
\IPS\Db::i()->findInSet( 'field_' . $field['field_id'], array( $member->member_id ) )
);
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $field['field_database_id'], $where ) as $record )
@@ -0,0 +1,65 @@
<?php
/**
* @brief Template Plugin - Pages: Media
* @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 07 July 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: Media
*/
class _Media
{
/**
* @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 )
{
if ( is_numeric( $data ) )
{
try
{
$url = \IPS\cms\Media::load( $data )->url();
}
catch( \OutOfRangeException $ex )
{
$url = NULL;
}
}
else
{
try
{
$url = \IPS\cms\Media::load( $data, 'media_full_path' )->url();
}
catch( \OutOfRangeException $ex )
{
$url = NULL;
}
}
return "'" . (string) $url . "'";
}
}
@@ -119,7 +119,7 @@ class _Databases
{
$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 ) )
else if ( $nodeClass::$ownerTypes !== NULL and is_subclass_of( $nodeClass, 'IPS\Node\Model' ) )
{
$select = $nodeClass::loadByOwner( new \IPS\Member );
}