mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-05 08:17:47 +02:00
[ticket/13713] Create source interface
PHPBB3-13713
This commit is contained in:
@@ -32,6 +32,9 @@ class friend extends user
|
|||||||
parent::__construct($db);
|
parent::__construct($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
protected function query($keyword, $topic_id)
|
protected function query($keyword, $topic_id)
|
||||||
{
|
{
|
||||||
$query = $this->db->sql_build_query('SELECT', [
|
$query = $this->db->sql_build_query('SELECT', [
|
||||||
|
27
phpbb/phpbb/mention/source/source_interface.php
Normal file
27
phpbb/phpbb/mention/source/source_interface.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\mention\source;
|
||||||
|
|
||||||
|
interface source_interface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Searches database for names to mention
|
||||||
|
* and returns and array of found items
|
||||||
|
*
|
||||||
|
* @param string $keyword Search string
|
||||||
|
* @param int $topic_id Current topic ID
|
||||||
|
* @return array Array of names
|
||||||
|
*/
|
||||||
|
public function get($keyword, $topic_id);
|
||||||
|
}
|
@@ -15,6 +15,9 @@ namespace phpbb\mention\source;
|
|||||||
|
|
||||||
class topic extends user
|
class topic extends user
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
protected function query($keyword, $topic_id)
|
protected function query($keyword, $topic_id)
|
||||||
{
|
{
|
||||||
$query = $this->db->sql_build_query('SELECT', [
|
$query = $this->db->sql_build_query('SELECT', [
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
namespace phpbb\mention\source;
|
namespace phpbb\mention\source;
|
||||||
|
|
||||||
abstract class user
|
abstract class user implements source_interface
|
||||||
{
|
{
|
||||||
/** @var \phpbb\db\driver\driver_interface */
|
/** @var \phpbb\db\driver\driver_interface */
|
||||||
protected $db;
|
protected $db;
|
||||||
@@ -26,8 +26,18 @@ abstract class user
|
|||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a query based on user input
|
||||||
|
*
|
||||||
|
* @param string $keyword Search string
|
||||||
|
* @param int $topic_id Current topic ID
|
||||||
|
* @return string Query ready for execution
|
||||||
|
*/
|
||||||
abstract protected function query($keyword, $topic_id);
|
abstract protected function query($keyword, $topic_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function get($keyword, $topic_id)
|
public function get($keyword, $topic_id)
|
||||||
{
|
{
|
||||||
$keyword = utf8_clean_string($keyword);
|
$keyword = utf8_clean_string($keyword);
|
||||||
|
Reference in New Issue
Block a user