1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-29 10:38:08 +01:00

Form handler code cleanup/optimization. Added getSupportedProviders() caching to reduce execution time.

This commit is contained in:
Cameron 2020-12-23 12:42:06 -08:00
parent c699a24ef0
commit 3cd4aa0018
5 changed files with 1252 additions and 959 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1200,6 +1200,13 @@ class e_user_provider
*/
public static function getSupportedProviders()
{
$regId = 'core/e107/user/provider';
if($cached = e107::getRegistry($regId))
{
return $cached;
}
$providers = [];
try
@ -1232,6 +1239,9 @@ class e_user_provider
}
sort($providers);
e107::setRegistry($regId, $providers);
return $providers;
}

View File

@ -52,8 +52,8 @@ class _blank_admin implements e_admin_addon_interface
switch($type)
{
case "news": // hook into the news admin form.
$config['fields']['url'] = array ( 'title' =>"Custom Field", 'type' => 'url', 'tab'=>1, 'writeParms'=> array('size'=>'xxlarge', 'placeholder'=>'', 'default'=>$defaultValue), 'width' => 'auto', 'help' => '', 'readParms' => '', 'class' => 'left', 'thclass' => 'left', );
case 'news': // hook into the news admin form.
$config['fields']['url'] = array ('title' => 'Custom Field', 'type' => 'url', 'tab' =>1, 'writeParms' => array('size' =>'xxlarge', 'placeholder' =>'', 'default' =>$defaultValue), 'width' => 'auto', 'help' => '', 'readParms' => '', 'class' => 'left', 'thclass' => 'left', );
$config['batchOptions'] = array('custom' => 'Custom Batch Command');
break;
@ -71,7 +71,7 @@ class _blank_admin implements e_admin_addon_interface
* @param object $ui admin-ui
* @param int|array $id - Primary ID of the record being created/edited/deleted or array data of a batch process.
*/
public function process(e_admin_ui $ui, $id=0)
public function process(e_admin_ui $ui, $id=null)
{
$data = $ui->getPosted(); // ie $_POST field-data
@ -86,6 +86,7 @@ class _blank_admin implements e_admin_addon_interface
if($action === 'batch')
{
$id = (array) $id;
$arrayOfRecordIds = $id['ids'];
$command = $id['cmd'];

View File

@ -322,12 +322,14 @@ class e_formTest extends \Codeception\Test\Unit
$this->assertEquals($expected, $actual);
}
/*
public function testUserlist()
{
$list = $this->_frm->userlist('name',null);
$this->assertStringContainsString("<option value='1'>e107</option>",$list);
}
/*
public function testUserpicker()
{

View File

@ -31,6 +31,7 @@ class e_user_providerTest extends \Codeception\Test\Unit
public function testGetSupportedProviders()
{
$result = e_user_provider::getSupportedProviders();
$this->assertIsArray($result);
$this->assertContains("Facebook", $result);
$this->assertContains("Twitter", $result);