Skip to content

Commit

Permalink
RSI v1.0.0
Browse files Browse the repository at this point in the history
Signed-off-by: Dark❶ <dark-1@users.noreply.github.com>
  • Loading branch information
Dark❶ committed Mar 11, 2020
1 parent 146fdc4 commit 6e4ec67
Show file tree
Hide file tree
Showing 10 changed files with 528 additions and 367 deletions.
15 changes: 11 additions & 4 deletions README.md
Expand Up @@ -77,11 +77,18 @@ Detailed phpBB standard Updation of Extensions here : [phpBB Extensions Updating
Detailed phpBB standard Uninstallation of Extensions here : [phpBB Extensions Removing](https://www.phpbb.com/extensions/installing/#removing)


GitHub Repository: [reducesearchindex](https://github.com/dark-1/reducesearchindex)
phpBB Customisation Database Extension: [Reduce Search Index](https://www.phpbb.com/customise/db/extension/reduce_search_index)
For more Details Go Here : [Reduce Search Index [RSI]](https://dark-1.github.io/reducesearchindex)
## **Links :**

## License [GPLv2](license.txt)
**GitHub Repository** : [reducesearchindex](https://github.com/dark-1/reducesearchindex)
**phpBB Customisation Database Extension** : [Reduce Search Index](https://www.phpbb.com/customise/db/extension/reduce_search_index)
**For more Details Go Here** : [Reduce Search Index [RSI]](https://dark-1.github.io/reducesearchindex)

**Credit where credit's due** :
Date & Time Picker : **Any+Time** by *Andrew M. Andrews III* at [ama3.com/anytime](https://www.ama3.com/anytime),
which can be found at `dark1/reducesearchindex/styles/all/template/DateTimePicker`


## License [GPLv2](license.txt)

--------------
EnJoY 😃
Expand Down
38 changes: 26 additions & 12 deletions acp/main_module.php
Expand Up @@ -30,22 +30,36 @@ public function main($id, $mode)
{
global $phpbb_container;

/** @var \dark1\reducesearchindex\controller\acp_controller $acp_controller */
$acp_controller = $phpbb_container->get('dark1.reducesearchindex.controller.acp');
// Normalize the Mode to Lowercase
$mode = strtolower($mode);

// Load the display handle in our ACP controller
$acp_controller->set_data($id, $mode, $this->u_action);
// check for valid Mode
if (class_exists('dark1\reducesearchindex\controller\acp_' . $mode))
{
// Get ACP controller for Mode
$acp_controller = $phpbb_container->get('dark1.reducesearchindex.controller.acp.' . $mode);

// Get data from our ACP controller
$acp_get_data = $acp_controller->get_data();
// Load the display handle in our ACP controller
$acp_controller->set_data($id, $mode, $this->u_action);

// Load a template from adm/style for our ACP page
$this->tpl_name = $acp_get_data['tpl_name'];
// Get data from our ACP controller
$acp_get_data = $acp_controller->get_data();

// Set the page title for our ACP page
$this->page_title = $acp_get_data['page_title'];
// Load a template from adm/style for our ACP page
$this->tpl_name = $acp_get_data['tpl_name'];

// Load the display handle in our ACP controller
$acp_controller->display();
// Set the page title for our ACP page
$this->page_title = $acp_get_data['page_title'];

// Load the setup in our ACP controller
$acp_controller->setup();

// Load the handle in our ACP controller
$acp_controller->handle();
}
else
{
trigger_error('FORM_INVALID', E_USER_WARNING);
}
}
}
2 changes: 1 addition & 1 deletion adm/style/dark1_rsi_acp_cron.html
Expand Up @@ -54,7 +54,7 @@ <h2>{{ RSI_EXT_MODE }}</h2>
<br><span class="responsive-hide">&nbsp;</span>
</dt>
<dd>
<input class="button1" type="submit" name="runcrontask" value="{{ lang('ACP_RSI_CRON_RUN_NOW') }}" /> {% if DONE_RUN_LS_CRON %}<span class="acp-rsi-crdn">&bull; {{ lang('ACP_RSI_CRON_RUN_DONE') }}</span>{% endif %}
<input class="button1" type="submit" name="runcrontask" value="{{ lang('ACP_RSI_CRON_RUN_NOW') }}" />
</dd>
</dl>
</fieldset>
Expand Down
23 changes: 21 additions & 2 deletions config/services.yml
@@ -1,14 +1,33 @@
services:
dark1.reducesearchindex.controller.acp:
class: dark1\reducesearchindex\controller\acp_controller
dark1.reducesearchindex.controller.acp.main:
class: dark1\reducesearchindex\controller\acp_main
arguments:
- '@language'
- '@log'
- '@request'
- '@template'
- '@user'
- '@config'

dark1.reducesearchindex.controller.acp.forum:
class: dark1\reducesearchindex\controller\acp_forum
arguments:
- '@language'
- '@log'
- '@request'
- '@template'
- '@user'
- '@dbal.conn'

dark1.reducesearchindex.controller.acp.cron:
class: dark1\reducesearchindex\controller\acp_cron
arguments:
- '@language'
- '@log'
- '@request'
- '@template'
- '@user'
- '@config'
- '@cron.manager'

dark1.reducesearchindex.listener:
Expand Down
153 changes: 153 additions & 0 deletions controller/acp_base.php
@@ -0,0 +1,153 @@
<?php
/**
*
* Reduce Search Index [RSI]. An extension for the phpBB Forum Software package.
*
* @copyright (c) 2020, Dark❶, https://dark1.tech
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace dark1\reducesearchindex\controller;

/**
* @ignore
*/
use phpbb\template\template;
use phpbb\user;
use phpbb\language\language;
use phpbb\log\log;
use phpbb\request\request;

/**
* Reduce Search Index [RSI] ACP controller Base.
*/
class acp_base
{
/** @var \phpbb\language\language */
protected $language;

/** @var \phpbb\log\log */
protected $log;

/** @var \phpbb\request\request */
protected $request;

/** @var \phpbb\template\template */
protected $template;

/** @var \phpbb\user */
protected $user;

/** @var string The module ID */
protected $id;

/** @var string The module mode */
protected $mode;

/** @var string Custom form action */
protected $u_action;

/**
* Constructor.
*
* @param \phpbb\language\language $language Language object
* @param \phpbb\log\log $log Log object
* @param \phpbb\request\request $request Request object
* @param \phpbb\template\template $template Template object
* @param \phpbb\user $user User object
*/
public function __construct(language $language, log $log, request $request, template $template, user $user)
{
$this->language = $language;
$this->log = $log;
$this->request = $request;
$this->template = $template;
$this->user = $user;
}

/**
* Set Data form.
*
* @param int $id The module ID
* @param string $mode The module mode
* @param string $u_action Custom form action
*
* @return void
*/
public function set_data($id, $mode, $u_action)
{
$this->id = $id;
$this->mode = $mode;
$this->u_action = $u_action;
}

/**
* Get Data form.
*
* @return array Having keys 'tpl_name' & 'page_title'
*/
public function get_data()
{
return [
'tpl_name' => 'dark1_rsi_acp_' . $this->mode,
'page_title' => $this->language->lang('ACP_RSI_TITLE') . ' - ' . $this->language->lang('ACP_RSI_' . strtoupper($this->mode)),
];
}

/**
* Set Display form.
*
* @return void
*/
public function setup()
{
$ext_name_rsi = 'Reduce Search Index [RSI]';
$ext_by_dark1 = 'Dark❶ [dark1]';

// Add our common language file
$this->language->add_lang('lang_rsi', 'dark1/reducesearchindex');

// Create a form key for preventing CSRF attacks
add_form_key('dark1_rsi_acp_' . $this->mode);

// Set u_action in the template
$this->template->assign_vars([
'U_ACTION' => $this->u_action,
'RSI_MODE' => $this->mode,
'RSI_EXT_MODE' => $this->language->lang('ACP_RSI_' . strtoupper($this->mode)),
'RSI_EXT_NAME' => $ext_name_rsi,
'RSI_EXT_DEV' => $ext_by_dark1,
]);
}

/**
* Check Form On Submit .
*
* @return void
*/
protected function check_form_on_submit()
{
// Test if the submitted form is valid
if (!check_form_key('dark1_rsi_acp_' . $this->mode))
{
trigger_error('FORM_INVALID', E_USER_WARNING);
}
}

/**
* Success Form On Submit.
* Used to Log & Trigger Success Err0r.
*
* @return void
*/
protected function success_form_on_submit()
{
// Add option settings change action to the admin log
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_RSI_LOG_SET_SAV', time(), array($this->language->lang('ACP_RSI_' . strtoupper($this->mode))));

// Option settings have been updated and logged
// Confirm this to the user and provide link back to previous page
trigger_error($this->language->lang('ACP_RSI_LOG_SET_SAV', $this->language->lang('ACP_RSI_' . strtoupper($this->mode))) . adm_back_link($this->u_action), E_USER_NOTICE);
}
}

0 comments on commit 6e4ec67

Please sign in to comment.