Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -1,4 +1,5 @@
<?php
/**
* @brief Ajax only methods
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
@@ -12,25 +13,37 @@
namespace IPS\cms\modules\front\database;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\cms\Databases;
use IPS\DateTime;
use IPS\Db;
use IPS\Dispatcher\Controller;
use IPS\Http\Url\Friendly;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\cms\Records;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Ajax only methods
*/
class _ajax extends \IPS\Dispatcher\Controller
class ajax extends Controller
{
/**
* Return a FURL
*
* @return void
*/
protected function makeFurl()
protected function makeFurl() : void
{
return \IPS\Output::i()->json( array( 'slug' => \IPS\Http\Url\Friendly::seoTitle( \IPS\Request::i()->slug ) ) );
Output::i()->json( array( 'slug' => Friendly::seoTitle( Request::i()->slug ) ) );
}
/**
@@ -38,19 +51,21 @@ class _ajax extends \IPS\Dispatcher\Controller
*
* @return void
*/
public function findRecord()
public function findRecord() : void
{
$results = array();
$database = \IPS\cms\Databases::load( \IPS\Request::i()->id );
$input = mb_strtolower( \IPS\Request::i()->input );
$database = Databases::load( Request::i()->id );
$input = mb_strtolower( Request::i()->input );
$field = "field_" . $database->field_title;
/* @var Records $class */
$class = '\IPS\cms\Records' . $database->id;
$category = '';
$where = array( $field . " LIKE CONCAT('%', ?, '%')" );
$binds = array( $input );
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $database->id, array_merge( array( implode( ' OR ', $where ) ), $binds ), 'LENGTH(' . $field . ') ASC', array( 0, 20 ) ) as $row )
foreach ( Db::i()->select( '*', 'cms_custom_database_' . $database->id, array_merge( array( implode( ' OR ', $where ) ), $binds ), 'LENGTH(' . $field . ') ASC', array( 0, 20 ) ) as $row )
{
$record = $class::constructFromData( $row );
@@ -61,18 +76,18 @@ class _ajax extends \IPS\Dispatcher\Controller
if ( $database->use_categories )
{
$category = \IPS\Member::loggedIn()->language()->addToStack( 'cms_autocomplete_category', FALSE, array( 'sprintf' => array( $record->container()->_title ) ) );
$category = Member::loggedIn()->language()->addToStack( 'cms_autocomplete_category', FALSE, array( 'sprintf' => array( $record->container()->_title ) ) );
}
$results[] = array(
'id' => $record->_id,
'value' => $record->_title,
'category' => $category,
'date' => \IPS\DateTime::ts( $record->record_publish_date )->html(),
'date' => DateTime::ts( $record->record_publish_date )->html(),
);
}
\IPS\Output::i()->json( $results );
Output::i()->json( $results );
}
}